diff --git a/tasks/construct-ae-p32-spherical-design-l1-s0/environment/Dockerfile b/tasks/construct-ae-p32-spherical-design-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-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-ae-p32-spherical-design-l1-s0/environment/instance.json b/tasks/construct-ae-p32-spherical-design-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ca79c6abb85cacb5bee83b2aedcba9980178bff6 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"t": 7, "N": 32, "family": "ae_p32_spherical_designs", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p32-spherical-design-l1-s0/solution/solve.sh b/tasks/construct-ae-p32-spherical-design-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..902cc7fa04429f245f41bd06460675ee643f2a36 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-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' +{"points": [[0.11606245518956762, -0.16610236292160294, 0.9792545693164928], [-0.39675347898353364, 0.021959702877615433, 0.9176624915316032], [0.48607965266991554, 0.3267742455138338, 0.8105215381031888], [-0.5028561752354322, -0.5750524338141748, 0.6453296563710569], [-0.028977008371302036, 0.6135860519291835, 0.7890959953413823], [0.5777480561971958, -0.47035296633303025, 0.6670646674963989], [-0.8420308379668259, 0.1041135493697409, 0.5292867245175527], [0.4881919910817507, 0.8046658299621788, 0.33790750499939154], [0.05682487551774614, -0.774372788635976, 0.6301727681695984], [-0.5062108733612531, 0.6777469568328439, 0.5333006789744942], [0.8794695462925934, 0.04158955579889673, 0.474134607461162], [-0.824292194748616, -0.526747348849163, 0.20755627708380178], [0.03579833654889291, 0.9932353461313679, 0.11046278240038192], [0.43737764389826533, -0.8976265455739514, 0.05447367528427997], [-0.9674139517139864, 0.2527458976385419, 0.015157745743229844], [0.8886047473718967, 0.4575428942323253, 0.03218855208975348], [-0.19945016049042963, -0.9765802130317549, 0.08068903887885889], [-0.5625217409955832, 0.8258384454171637, -0.03949877185761976], [0.8572022318024186, -0.5109673200807969, 0.06416176121648516], [-0.9020508634918853, -0.28444012594837104, -0.32465066521419417], [0.5380327326930923, 0.7340076582810167, -0.4144315819717673], [0.2598906488008719, -0.815213720040663, -0.5175745756152687], [-0.7070637245329644, 0.4835136486653401, -0.5160188378382152], [0.950916697141367, -0.05600374474698265, -0.30433701002682667], [-0.4784134955383967, -0.8056610046010311, -0.3493291756380935], [-0.04565799735558514, 0.8577605502323268, -0.5120177592062733], [0.6188703713672925, -0.41712374259641766, -0.6655878956276676], [-0.6087554544458175, -0.0691406036458159, -0.7903394040600269], [0.5928789130408082, 0.29380189301906434, -0.7497833301227523], [-0.21108669618117018, -0.5264950943862514, -0.8235565082509704], [-0.1545704268221741, 0.43945924916465534, -0.8848635778896362], [0.15415618062128142, -0.0564614598601123, -0.9864319416598004]]} +RLMATH_EOF diff --git a/tasks/construct-ae-p32-spherical-design-l1-s0/tests/check.py b/tasks/construct-ae-p32-spherical-design-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..5973c15b3df2d6228d713d9b186ced8e47dcbb48 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l1-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-l1-s0/tests/instance.json b/tasks/construct-ae-p32-spherical-design-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ca79c6abb85cacb5bee83b2aedcba9980178bff6 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"t": 7, "N": 32, "family": "ae_p32_spherical_designs", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p32-spherical-design-l1-s0/tests/run.py b/tasks/construct-ae-p32-spherical-design-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-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-ae-p32-spherical-design-l1-s0/tests/test.sh b/tasks/construct-ae-p32-spherical-design-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-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-ae-p38-factorial-factors-l2-s1/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l2-s1/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dd65b9eecbe948237ee9cd45e9ebf52009d5102b --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"N": 88, "t": 25, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s1/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b31dc0f1d0741182457ef74ba7c6e8c195d0b034 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [150, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 33, 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-s1/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-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-l2-s1/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dd65b9eecbe948237ee9cd45e9ebf52009d5102b --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"N": 88, "t": 25, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s1/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l2-s1/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l2-s8/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l2-s8/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..43f7ba50e7c9ebc82e4c8050c2ae1142df06ad4f --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"N": 139, "t": 40, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s8/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7948820a1668ca39559a1d2ce9ccf851d036092f --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [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, 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, 45, 45, 45, 45, 45, 46, 46, 46, 46, 46, 46, 47, 47, 48, 49, 49, 49, 49, 49, 51, 51, 51, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 53, 53, 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, 81, 81, 81, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s8/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s8/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-s8/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..43f7ba50e7c9ebc82e4c8050c2ae1142df06ad4f --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"N": 139, "t": 40, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s8/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l2-s8/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s0/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s0/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..171004f5f5a79693c29fc83d56871cd9833aed31 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"N": 5043, "t": 1631, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s0/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2f106509af6b579df0f3c92692e6ab78ca794f04 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [4893, 1631, 1631, 1631, 1631, 1631, 1631, 1631, 1631, 1631, 1631, 1631, 1631, 1631, 1631, 1631, 1631, 1631, 1631, 1631, 1631, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1632, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1633, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1634, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1635, 1636, 1636, 1636, 1636, 1636, 1636, 1636, 1636, 1636, 1636, 1636, 1636, 1637, 1637, 1637, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1638, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1639, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1640, 1641, 1641, 1641, 1641, 1641, 1641, 1641, 1641, 1641, 1642, 1642, 1642, 1642, 1642, 1642, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1643, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1644, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1645, 1646, 1646, 1646, 1646, 1646, 1646, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1647, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1648, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1649, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1650, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1651, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1652, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1653, 1654, 1654, 1654, 1654, 1654, 1654, 1655, 1655, 1655, 1655, 1655, 1655, 1655, 1655, 1655, 1655, 1655, 1655, 1655, 1655, 1655, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1656, 1657, 1657, 1657, 1658, 1658, 1658, 1658, 1658, 1658, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1659, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1660, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1661, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1662, 1663, 1663, 1663, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1664, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1665, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1666, 1667, 1667, 1667, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1668, 1669, 1669, 1669, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1670, 1671, 1671, 1671, 1671, 1671, 1671, 1671, 1671, 1671, 1673, 1673, 1673, 1673, 1673, 1673, 1673, 1673, 1673, 1673, 1673, 1673, 1673, 1673, 1673, 1673, 1673, 1673, 1673, 1673, 1673, 1674, 1674, 1674, 1674, 1674, 1674, 1674, 1674, 1674, 1674, 1674, 1674, 1674, 1674, 1674, 1674, 1674, 1674, 1674, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1675, 1676, 1676, 1676, 1676, 1676, 1676, 1676, 1676, 1676, 1676, 1676, 1676, 1678, 1678, 1678, 1678, 1678, 1678, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1679, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1682, 1683, 1683, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1684, 1685, 1685, 1685, 1685, 1685, 1685, 1685, 1685, 1685, 1685, 1685, 1685, 1685, 1685, 1686, 1686, 1686, 1686, 1686, 1686, 1686, 1686, 1686, 1686, 1686, 1686, 1686, 1686, 1686, 1686, 1686, 1687, 1687, 1687, 1687, 1687, 1687, 1687, 1687, 1687, 1687, 1687, 1687, 1687, 1687, 1687, 1687, 1687, 1687, 1687, 1687, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1688, 1689, 1689, 1689, 1689, 1689, 1689, 1689, 1689, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1691, 1693, 1693, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1694, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1697, 1697, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1698, 1699, 1699, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1703, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1705, 1706, 1706, 1706, 1706, 1706, 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707, 1709, 1709, 1711, 1711, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1712, 1713, 1713, 1713, 1713, 1713, 1713, 1713, 1713, 1714, 1714, 1714, 1714, 1714, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1717, 1718, 1718, 1718, 1718, 1718, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1719, 1721, 1721, 1722, 1723, 1723, 1724, 1724, 1724, 1724, 1724, 1724, 1724, 1724, 1724, 1724, 1724, 1726, 1726, 1726, 1726, 1726, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1727, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1730, 1731, 1731, 1731, 1731, 1731, 1731, 1731, 1731, 1732, 1732, 1732, 1732, 1732, 1732, 1732, 1732, 1732, 1732, 1732, 1733, 1733, 1735, 1735, 1735, 1735, 1735, 1735, 1735, 1735, 1735, 1735, 1735, 1735, 1735, 1735, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1737, 1741, 1741, 1745, 1745, 1745, 1745, 1745, 1745, 1745, 1745, 1745, 1745, 1745, 1745, 1745, 1745, 1747, 1747, 1750, 1750, 1751, 1753, 1753, 1754, 1754, 1754, 1754, 1754, 1756, 1756, 1756, 1756, 1756, 1756, 1756, 1756, 1756, 1756, 1756, 1757, 1757, 1757, 1757, 1757, 1757, 1757, 1757, 1757, 1757, 1757, 1757, 1757, 1757, 1757, 1757, 1757, 1757, 1757, 1757, 1758, 1758, 1758, 1758, 1758, 1758, 1758, 1758, 1758, 1758, 1758, 1758, 1758, 1758, 1758, 1758, 1758, 1759, 1759, 1761, 1761, 1761, 1761, 1761, 1761, 1761, 1761, 1762, 1762, 1762, 1762, 1762, 1765, 1765, 1765, 1765, 1765, 1765, 1765, 1765, 1765, 1765, 1765, 1765, 1765, 1765, 1766, 1766, 1766, 1766, 1766, 1769, 1769, 1772, 1772, 1772, 1772, 1772, 1772, 1772, 1772, 1772, 1772, 1772, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1773, 1774, 1774, 1774, 1774, 1774, 1777, 1777, 1779, 1779, 1779, 1779, 1779, 1779, 1779, 1779, 1783, 1783, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1784, 1787, 1787, 1789, 1789, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1790, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1791, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1793, 1795, 1795, 1795, 1795, 1795, 1795, 1795, 1795, 1795, 1795, 1795, 1795, 1795, 1795, 1796, 1796, 1796, 1796, 1796, 1796, 1796, 1796, 1796, 1796, 1796, 1797, 1797, 1797, 1797, 1797, 1797, 1797, 1797, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1799, 1801, 1801, 1803, 1803, 1803, 1803, 1803, 1803, 1803, 1803, 1808, 1808, 1809, 1809, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1810, 1811, 1811, 1814, 1814, 1814, 1814, 1814, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1816, 1821, 1821, 1821, 1821, 1821, 1821, 1821, 1821, 1822, 1822, 1822, 1822, 1822, 1823, 1823, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1828, 1831, 1831, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1832, 1835, 1835, 1835, 1835, 1835, 1835, 1835, 1835, 1835, 1835, 1835, 1835, 1835, 1838, 1838, 1838, 1838, 1838, 1839, 1839, 1839, 1839, 1839, 1839, 1839, 1839, 1841, 1841, 1841, 1841, 1841, 1841, 1841, 1841, 1841, 1841, 1841, 1841, 1841, 1841, 1841, 1841, 1841, 1841, 1841, 1842, 1842, 1842, 1842, 1842, 1842, 1842, 1842, 1842, 1842, 1842, 1842, 1842, 1842, 1842, 1842, 1844, 1844, 1844, 1844, 1844, 1844, 1844, 1844, 1844, 1844, 1847, 1847, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1851, 1852, 1852, 1852, 1852, 1852, 1852, 1852, 1852, 1852, 1852, 1857, 1857, 1857, 1857, 1857, 1857, 1857, 1857, 1858, 1858, 1858, 1858, 1858, 1861, 1861, 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, 1867, 1867, 1868, 1868, 1868, 1868, 1868, 1868, 1868, 1868, 1868, 1868, 1871, 1871, 1873, 1873, 1874, 1874, 1874, 1874, 1874, 1877, 1877, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1878, 1879, 1879, 1882, 1882, 1882, 1882, 1882, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1883, 1889, 1889, 1893, 1893, 1893, 1893, 1893, 1893, 1893, 1894, 1894, 1894, 1894, 1894, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1901, 1901, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1902, 1906, 1906, 1906, 1906, 1906, 1907, 1907, 1913, 1913, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1915, 1916, 1916, 1916, 1916, 1916, 1916, 1916, 1916, 1916, 1916, 1919, 1923, 1923, 1923, 1923, 1923, 1923, 1923, 1929, 1929, 1929, 1929, 1929, 1929, 1929, 1931, 1931, 1933, 1933, 1934, 1934, 1934, 1934, 1934, 1941, 1941, 1941, 1941, 1941, 1941, 1941, 1942, 1942, 1942, 1942, 1942, 1945, 1945, 1945, 1945, 1945, 1945, 1945, 1945, 1945, 1945, 1945, 1945, 1948, 1948, 1948, 1948, 1948, 1948, 1948, 1948, 1948, 1948, 1949, 1949, 1951, 1951, 1954, 1954, 1954, 1954, 1954, 1959, 1959, 1959, 1959, 1959, 1959, 1959, 1964, 1964, 1964, 1964, 1964, 1964, 1964, 1964, 1964, 1964, 1966, 1966, 1966, 1966, 1966, 1973, 1973, 1977, 1977, 1977, 1977, 1977, 1977, 1977, 1979, 1979, 1982, 1982, 1982, 1982, 1982, 1983, 1983, 1983, 1983, 1983, 1983, 1983, 1985, 1985, 1985, 1985, 1985, 1985, 1985, 1985, 1985, 1985, 1985, 1985, 1987, 1987, 1993, 1993, 1994, 1994, 1994, 1994, 1994, 1996, 1996, 1996, 1996, 1996, 1996, 1996, 1996, 1996, 1996, 1997, 1997, 1999, 1999, 2003, 2003, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2005, 2011, 2011, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2017, 2017, 2018, 2018, 2018, 2018, 2019, 2019, 2019, 2019, 2019, 2019, 2019, 2026, 2026, 2026, 2026, 2027, 2027, 2029, 2029, 2031, 2031, 2031, 2031, 2031, 2031, 2031, 2036, 2036, 2036, 2036, 2036, 2036, 2036, 2036, 2036, 2038, 2038, 2038, 2038, 2039, 2039, 2042, 2042, 2042, 2042, 2049, 2049, 2049, 2049, 2049, 2049, 2049, 2053, 2053, 2062, 2062, 2062, 2062, 2063, 2063, 2066, 2066, 2066, 2066, 2069, 2069, 2073, 2073, 2073, 2073, 2073, 2073, 2073, 2078, 2078, 2078, 2078, 2081, 2081, 2083, 2083, 2084, 2084, 2084, 2084, 2084, 2084, 2084, 2084, 2084, 2087, 2087, 2089, 2089, 2092, 2092, 2092, 2092, 2092, 2092, 2092, 2092, 2092, 2098, 2098, 2098, 2098, 2099, 2099, 2102, 2102, 2102, 2102, 2103, 2103, 2103, 2103, 2103, 2103, 2103, 2111, 2111, 2113, 2113, 2122, 2122, 2122, 2122, 2126, 2126, 2126, 2126, 2127, 2127, 2127, 2127, 2127, 2127, 2127, 2129, 2129, 2131, 2131, 2137, 2137, 2138, 2138, 2138, 2138, 2141, 2141, 2143, 2143, 2153, 2153, 2157, 2157, 2157, 2157, 2157, 2157, 2157, 2161, 2161, 2164, 2164, 2164, 2164, 2164, 2164, 2164, 2164, 2164, 2174, 2174, 2174, 2174, 2179, 2179, 2181, 2181, 2181, 2181, 2181, 2181, 2182, 2182, 2182, 2182, 2186, 2186, 2186, 2186, 2194, 2194, 2194, 2194, 2199, 2199, 2199, 2199, 2199, 2199, 2203, 2203, 2206, 2206, 2206, 2206, 2207, 2207, 2213, 2213, 2217, 2217, 2217, 2217, 2217, 2217, 2218, 2218, 2218, 2218, 2221, 2221, 2229, 2229, 2229, 2229, 2229, 2229, 2234, 2234, 2234, 2234, 2237, 2237, 2239, 2239, 2243, 2243, 2246, 2246, 2246, 2246, 2251, 2251, 2253, 2253, 2253, 2253, 2253, 2253, 2258, 2258, 2258, 2258, 2267, 2267, 2269, 2269, 2271, 2271, 2271, 2271, 2271, 2271, 2273, 2273, 2281, 2281, 2283, 2283, 2283, 2283, 2283, 2283, 2287, 2287, 2293, 2293, 2297, 2297, 2302, 2302, 2302, 2302, 2306, 2306, 2306, 2306, 2307, 2307, 2307, 2307, 2307, 2307, 2309, 2309, 2311, 2311, 2319, 2319, 2319, 2319, 2319, 2319, 2326, 2326, 2326, 2326, 2333, 2333, 2339, 2339, 2341, 2341, 2342, 2342, 2342, 2342, 2347, 2347, 2351, 2351, 2357, 2357, 2361, 2361, 2361, 2361, 2361, 2361, 2362, 2362, 2362, 2362, 2371, 2371, 2374, 2374, 2374, 2374, 2377, 2377, 2381, 2381, 2383, 2383, 2386, 2386, 2386, 2386, 2389, 2389, 2391, 2391, 2391, 2391, 2391, 2391, 2393, 2393, 2399, 2399, 2402, 2402, 2402, 2402, 2411, 2411, 2417, 2417, 2423, 2423, 2426, 2426, 2426, 2426, 2427, 2427, 2427, 2427, 2427, 2427, 2433, 2433, 2433, 2433, 2433, 2433, 2434, 2434, 2434, 2434, 2437, 2437, 2441, 2441, 2446, 2446, 2446, 2446, 2447, 2447, 2458, 2458, 2458, 2458, 2459, 2459, 2462, 2462, 2462, 2462, 2467, 2467, 2473, 2473, 2474, 2474, 2474, 2474, 2477, 2477, 2498, 2498, 2498, 2498, 2503, 2503, 2518, 2518, 2518, 2518, 2521, 2521, 2531, 2539, 2543, 2549, 2551, 2554, 2554, 2554, 2557, 2558, 2558, 2558, 2566, 2566, 2566, 2578, 2578, 2578, 2579, 2582, 2582, 2582, 2591, 2593, 2594, 2594, 2594, 2602, 2602, 2602, 2606, 2606, 2606, 2609, 2614, 2614, 2614, 2617, 2621, 2633, 2638, 2638, 2638, 2642, 2642, 2642, 2647, 2654, 2654, 2654, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2722, 2722, 2722, 2729, 2731, 2734, 2734, 2734, 2741, 2746, 2746, 2746, 2749, 2753, 2762, 2762, 2762, 2767, 2777, 2789, 2791, 2797, 2798, 2798, 2798, 2801, 2803, 2818, 2818, 2818, 2819, 2833, 2837, 2843, 2846, 2846, 2846, 2851, 2854, 2854, 2854, 2857, 2858, 2858, 2858, 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, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 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]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s0/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-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-l6-s0/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..171004f5f5a79693c29fc83d56871cd9833aed31 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"N": 5043, "t": 1631, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s0/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s0/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s7/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l6-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s7/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1aad478cfd3db47aaabc974ff436d70bfcdc0274 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s7/environment/instance.json @@ -0,0 +1 @@ +{"N": 8731, "t": 2851, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s7/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l6-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9e63e55588ec8d4430a7ef63a6376d3759a2b40c --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [14255, 2851, 2851, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 2852, 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, 2853, 2854, 2854, 2854, 2854, 2854, 2854, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2856, 2857, 2857, 2857, 2858, 2858, 2858, 2858, 2858, 2858, 2859, 2859, 2859, 2859, 2859, 2859, 2859, 2859, 2859, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2860, 2861, 2861, 2861, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2862, 2863, 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, 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, 2865, 2866, 2866, 2866, 2866, 2866, 2866, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 2867, 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, 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, 2869, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2870, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2871, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2872, 2873, 2873, 2873, 2873, 2873, 2873, 2873, 2873, 2873, 2873, 2873, 2873, 2873, 2873, 2873, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2875, 2876, 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, 2877, 2877, 2878, 2878, 2878, 2878, 2878, 2878, 2879, 2879, 2879, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2880, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 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, 2882, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2887, 2887, 2887, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 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, 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, 2893, 2894, 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, 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, 2896, 2896, 2897, 2897, 2897, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 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, 2899, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2901, 2901, 2901, 2901, 2901, 2901, 2901, 2901, 2901, 2902, 2902, 2902, 2902, 2902, 2902, 2903, 2903, 2903, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2906, 2906, 2906, 2906, 2906, 2906, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2909, 2909, 2909, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2913, 2913, 2913, 2913, 2913, 2913, 2913, 2913, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2917, 2917, 2918, 2918, 2918, 2918, 2918, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 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, 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, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2927, 2927, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 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, 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, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 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, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 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, 2941, 2942, 2942, 2942, 2942, 2942, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2944, 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, 2951, 2952, 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, 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, 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, 2959, 2961, 2961, 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, 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, 2979, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 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, 2981, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 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, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3007, 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, 3012, 3013, 3017, 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, 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, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3031, 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, 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, 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, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3049, 3049, 3054, 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, 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, 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, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3086, 3086, 3086, 3086, 3086, 3089, 3089, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3092, 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, 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, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3117, 3117, 3117, 3117, 3117, 3117, 3117, 3117, 3118, 3118, 3118, 3118, 3118, 3119, 3119, 3121, 3121, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3134, 3134, 3134, 3134, 3134, 3137, 3137, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3142, 3142, 3142, 3142, 3142, 3143, 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, 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, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3181, 3181, 3183, 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, 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, 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, 3207, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 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, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 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, 3246, 3251, 3251, 3253, 3253, 3254, 3254, 3254, 3254, 3254, 3257, 3257, 3259, 3259, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3271, 3271, 3273, 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, 3295, 3299, 3299, 3301, 3301, 3305, 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, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 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, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 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, 3394, 3398, 3398, 3398, 3398, 3398, 3407, 3407, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3413, 3413, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3418, 3418, 3418, 3418, 3418, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3433, 3433, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3442, 3442, 3442, 3442, 3442, 3446, 3446, 3446, 3446, 3446, 3449, 3449, 3452, 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, 3466, 3467, 3467, 3469, 3469, 3482, 3482, 3482, 3482, 3482, 3489, 3489, 3489, 3489, 3489, 3489, 3489, 3491, 3491, 3494, 3494, 3494, 3494, 3499, 3499, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 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, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 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, 3639, 3643, 3643, 3644, 3644, 3644, 3644, 3644, 3644, 3644, 3644, 3644, 3646, 3646, 3646, 3646, 3651, 3651, 3651, 3651, 3651, 3651, 3651, 3659, 3659, 3662, 3662, 3662, 3662, 3669, 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, 3687, 3691, 3691, 3693, 3693, 3693, 3693, 3693, 3693, 3693, 3694, 3694, 3694, 3694, 3697, 3697, 3701, 3701, 3709, 3709, 3711, 3711, 3711, 3711, 3711, 3711, 3711, 3716, 3716, 3716, 3716, 3716, 3716, 3716, 3716, 3716, 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, 3748, 3748, 3748, 3748, 3748, 3748, 3748, 3748, 3748, 3754, 3754, 3754, 3754, 3758, 3758, 3758, 3758, 3761, 3761, 3764, 3764, 3764, 3764, 3764, 3764, 3764, 3764, 3764, 3767, 3767, 3769, 3769, 3777, 3777, 3777, 3777, 3777, 3777, 3778, 3778, 3778, 3778, 3779, 3779, 3788, 3788, 3788, 3788, 3788, 3788, 3788, 3788, 3788, 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, 4197, 4197, 4197, 4197, 4197, 4197, 4198, 4198, 4198, 4198, 4201, 4201, 4211, 4211, 4217, 4217, 4219, 4219, 4222, 4222, 4222, 4222, 4226, 4226, 4226, 4226, 4227, 4227, 4227, 4227, 4227, 4227, 4229, 4229, 4231, 4231, 4241, 4241, 4243, 4243, 4253, 4253, 4258, 4258, 4258, 4258, 4259, 4259, 4261, 4261, 4262, 4262, 4262, 4262, 4269, 4269, 4269, 4269, 4269, 4269, 4271, 4271, 4273, 4273, 4274, 4274, 4274, 4274, 4282, 4282, 4282, 4282, 4283, 4283, 4286, 4286, 4286, 4286, 4289, 4289, 4297, 4297, 4306, 4306, 4306, 4306, 4322, 4322, 4322, 4322, 4327, 4327, 4337, 4337, 4339, 4339, 4349, 4349, 4357, 4357, 4358, 4358, 4358, 4358, 4363, 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, 5554, 5554, 5554, 5557, 5563, 5569, 5573, 5578, 5578, 5578, 5581, 5582, 5582, 5582, 5591, 5594, 5594, 5594, 5602, 5602, 5602, 5606, 5606, 5606, 5623, 5638, 5638, 5638, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5666, 5666, 5666, 5669, 5674, 5674, 5674, 5683, 5686, 5686, 5686, 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, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s7/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l6-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-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-l6-s7/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1aad478cfd3db47aaabc974ff436d70bfcdc0274 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s7/tests/instance.json @@ -0,0 +1 @@ +{"N": 8731, "t": 2851, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s7/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l6-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s7/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l6-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p52-erdos-squarefree-l2-s3/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l2-s3/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2b9ff90aec29b030d2a68159878b45bc8f625d2f --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"N": 156, "t": 6, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s3/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6f3206b25fb9108a5347aaafc757373cd8f98f09 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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' +{"A": [7, 32, 57, 82, 107, 132]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s3/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s3/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-s3/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2b9ff90aec29b030d2a68159878b45bc8f625d2f --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"N": 156, "t": 6, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s3/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l2-s3/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l2-s4/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l2-s4/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bd6bec0d5c219c4e166dc4d46f331d7e5a359cb6 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"N": 241, "t": 10, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s4/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c95aa51469178b68838c8d965c879f48484d325c --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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' +{"A": [7, 32, 57, 82, 107, 132, 157, 182, 207, 232]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s4/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s4/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-s4/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bd6bec0d5c219c4e166dc4d46f331d7e5a359cb6 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"N": 241, "t": 10, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s4/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l2-s4/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-mc-all-interval-l2-s1/environment/Dockerfile b/tasks/construct-mc-all-interval-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-all-interval-l2-s1/environment/instance.json b/tasks/construct-mc-all-interval-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..45b1c740c7ec81636f552319b1491b8ce4124236 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 10, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l2-s1/solution/solve.sh b/tasks/construct-mc-all-interval-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5526d2a3686e270c76b5cd282e8c70dbdd9c8090 --- /dev/null +++ b/tasks/construct-mc-all-interval-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' +{"x": [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l2-s1/tests/check.py b/tasks/construct-mc-all-interval-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-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-l2-s1/tests/instance.json b/tasks/construct-mc-all-interval-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..45b1c740c7ec81636f552319b1491b8ce4124236 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 10, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l2-s1/tests/run.py b/tasks/construct-mc-all-interval-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-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-all-interval-l2-s1/tests/test.sh b/tasks/construct-mc-all-interval-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-all-interval-l6-s0/tests/run.py b/tasks/construct-mc-all-interval-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-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-mc-bibd-l4-s4/environment/Dockerfile b/tasks/construct-mc-bibd-l4-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-bibd-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-mc-bibd-l4-s4/environment/instance.json b/tasks/construct-mc-bibd-l4-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..03b3ca2f50eec5ab9f2523e60288a8a4ebedbe4a --- /dev/null +++ b/tasks/construct-mc-bibd-l4-s4/environment/instance.json @@ -0,0 +1 @@ +{"v": 15, "k": 3, "lambda": 2, "b": 70, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l4-s4/solution/solve.sh b/tasks/construct-mc-bibd-l4-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..24849a265e01cc8860f13dadcbb2658b9eaa6a37 --- /dev/null +++ b/tasks/construct-mc-bibd-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' +{"blocks": [[0, 10, 13], [0, 3, 4], [2, 7, 9], [10, 13, 14], [2, 8, 14], [2, 4, 5], [0, 5, 12], [1, 4, 10], [5, 10, 12], [0, 2, 6], [8, 9, 13], [9, 12, 13], [0, 1, 9], [9, 12, 14], [4, 9, 11], [0, 4, 8], [6, 9, 14], [5, 8, 13], [0, 12, 14], [3, 8, 14], [0, 10, 11], [4, 7, 10], [7, 8, 12], [2, 3, 13], [2, 10, 12], [10, 11, 14], [0, 1, 2], [0, 7, 8], [3, 5, 8], [3, 12, 13], [5, 6, 13], [1, 4, 13], [0, 13, 14], [0, 3, 9], [2, 4, 13], [1, 2, 5], [3, 6, 10], [1, 3, 9], [4, 7, 12], [4, 5, 14], [2, 7, 14], [1, 11, 12], [2, 11, 12], [5, 6, 10], [5, 7, 9], [4, 8, 11], [6, 8, 11], [3, 7, 11], [1, 3, 5], [7, 11, 13], [3, 6, 12], [1, 8, 10], [2, 9, 10], [3, 7, 10], [2, 3, 11], [1, 6, 14], [6, 11, 13], [2, 6, 8], [1, 11, 14], [4, 6, 12], [8, 9, 10], [1, 8, 12], [4, 6, 9], [5, 9, 11], [3, 4, 14], [1, 7, 13], [5, 7, 14], [0, 5, 11], [0, 6, 7], [1, 6, 7]]} +RLMATH_EOF diff --git a/tasks/construct-mc-bibd-l4-s4/tests/check.py b/tasks/construct-mc-bibd-l4-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c4b5da62477026f27ff9869fe33602fcc41e2ea9 --- /dev/null +++ b/tasks/construct-mc-bibd-l4-s4/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-l4-s4/tests/instance.json b/tasks/construct-mc-bibd-l4-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..03b3ca2f50eec5ab9f2523e60288a8a4ebedbe4a --- /dev/null +++ b/tasks/construct-mc-bibd-l4-s4/tests/instance.json @@ -0,0 +1 @@ +{"v": 15, "k": 3, "lambda": 2, "b": 70, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l4-s4/tests/run.py b/tasks/construct-mc-bibd-l4-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-bibd-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-mc-bibd-l4-s4/tests/test.sh b/tasks/construct-mc-bibd-l4-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-bibd-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-mc-costas-array-l4-s0/environment/Dockerfile b/tasks/construct-mc-costas-array-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-costas-array-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-costas-array-l4-s0/environment/instance.json b/tasks/construct-mc-costas-array-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b546184b95e4774eb9a548dbcf0ecfe84f0b4239 --- /dev/null +++ b/tasks/construct-mc-costas-array-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 16, "fixed": [], "family": "mc_costas_array", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-costas-array-l4-s0/solution/solve.sh b/tasks/construct-mc-costas-array-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..23ae670c5c978ae5058760d4f7bdea7a5625b1b2 --- /dev/null +++ b/tasks/construct-mc-costas-array-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": [14, 8, 7, 10, 2, 4, 11, 12, 3, 15, 0, 6, 1, 5, 13, 9]} +RLMATH_EOF diff --git a/tasks/construct-mc-costas-array-l4-s0/tests/check.py b/tasks/construct-mc-costas-array-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c86323a5b639b23787ecd4d5f358b986bbd91b6c --- /dev/null +++ b/tasks/construct-mc-costas-array-l4-s0/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-s0/tests/instance.json b/tasks/construct-mc-costas-array-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b546184b95e4774eb9a548dbcf0ecfe84f0b4239 --- /dev/null +++ b/tasks/construct-mc-costas-array-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 16, "fixed": [], "family": "mc_costas_array", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-costas-array-l4-s0/tests/run.py b/tasks/construct-mc-costas-array-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-costas-array-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-costas-array-l4-s0/tests/test.sh b/tasks/construct-mc-costas-array-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-costas-array-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-debruijn-l5-s2/environment/Dockerfile b/tasks/construct-mc-debruijn-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-debruijn-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-debruijn-l5-s2/environment/instance.json b/tasks/construct-mc-debruijn-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b24c56bf19f75a78de5813ea786e1c121f81bcb7 --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"b": 4, "n": 5, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l5-s2/solution/solve.sh b/tasks/construct-mc-debruijn-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..42ea830831a37ccb0e86e2c2313f5f8582310d2a --- /dev/null +++ b/tasks/construct-mc-debruijn-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' +{"seq": [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 1, 1, 0, 0, 0, 1, 2, 0, 0, 0, 1, 3, 0, 0, 0, 2, 1, 0, 0, 0, 2, 2, 0, 0, 0, 2, 3, 0, 0, 0, 3, 1, 0, 0, 0, 3, 2, 0, 0, 0, 3, 3, 0, 0, 1, 0, 1, 0, 0, 1, 0, 2, 0, 0, 1, 0, 3, 0, 0, 1, 1, 1, 0, 0, 1, 1, 2, 0, 0, 1, 1, 3, 0, 0, 1, 2, 1, 0, 0, 1, 2, 2, 0, 0, 1, 2, 3, 0, 0, 1, 3, 1, 0, 0, 1, 3, 2, 0, 0, 1, 3, 3, 0, 0, 2, 0, 1, 0, 0, 2, 0, 2, 0, 0, 2, 0, 3, 0, 0, 2, 1, 1, 0, 0, 2, 1, 2, 0, 0, 2, 1, 3, 0, 0, 2, 2, 1, 0, 0, 2, 2, 2, 0, 0, 2, 2, 3, 0, 0, 2, 3, 1, 0, 0, 2, 3, 2, 0, 0, 2, 3, 3, 0, 0, 3, 0, 1, 0, 0, 3, 0, 2, 0, 0, 3, 0, 3, 0, 0, 3, 1, 1, 0, 0, 3, 1, 2, 0, 0, 3, 1, 3, 0, 0, 3, 2, 1, 0, 0, 3, 2, 2, 0, 0, 3, 2, 3, 0, 0, 3, 3, 1, 0, 0, 3, 3, 2, 0, 0, 3, 3, 3, 0, 1, 0, 1, 1, 0, 1, 0, 1, 2, 0, 1, 0, 1, 3, 0, 1, 0, 2, 1, 0, 1, 0, 2, 2, 0, 1, 0, 2, 3, 0, 1, 0, 3, 1, 0, 1, 0, 3, 2, 0, 1, 0, 3, 3, 0, 1, 1, 0, 2, 0, 1, 1, 0, 3, 0, 1, 1, 1, 1, 0, 1, 1, 1, 2, 0, 1, 1, 1, 3, 0, 1, 1, 2, 1, 0, 1, 1, 2, 2, 0, 1, 1, 2, 3, 0, 1, 1, 3, 1, 0, 1, 1, 3, 2, 0, 1, 1, 3, 3, 0, 1, 2, 0, 2, 0, 1, 2, 0, 3, 0, 1, 2, 1, 1, 0, 1, 2, 1, 2, 0, 1, 2, 1, 3, 0, 1, 2, 2, 1, 0, 1, 2, 2, 2, 0, 1, 2, 2, 3, 0, 1, 2, 3, 1, 0, 1, 2, 3, 2, 0, 1, 2, 3, 3, 0, 1, 3, 0, 2, 0, 1, 3, 0, 3, 0, 1, 3, 1, 1, 0, 1, 3, 1, 2, 0, 1, 3, 1, 3, 0, 1, 3, 2, 1, 0, 1, 3, 2, 2, 0, 1, 3, 2, 3, 0, 1, 3, 3, 1, 0, 1, 3, 3, 2, 0, 1, 3, 3, 3, 0, 2, 0, 2, 1, 0, 2, 0, 2, 2, 0, 2, 0, 2, 3, 0, 2, 0, 3, 1, 0, 2, 0, 3, 2, 0, 2, 0, 3, 3, 0, 2, 1, 0, 3, 0, 2, 1, 1, 1, 0, 2, 1, 1, 2, 0, 2, 1, 1, 3, 0, 2, 1, 2, 1, 0, 2, 1, 2, 2, 0, 2, 1, 2, 3, 0, 2, 1, 3, 1, 0, 2, 1, 3, 2, 0, 2, 1, 3, 3, 0, 2, 2, 0, 3, 0, 2, 2, 1, 1, 0, 2, 2, 1, 2, 0, 2, 2, 1, 3, 0, 2, 2, 2, 1, 0, 2, 2, 2, 2, 0, 2, 2, 2, 3, 0, 2, 2, 3, 1, 0, 2, 2, 3, 2, 0, 2, 2, 3, 3, 0, 2, 3, 0, 3, 0, 2, 3, 1, 1, 0, 2, 3, 1, 2, 0, 2, 3, 1, 3, 0, 2, 3, 2, 1, 0, 2, 3, 2, 2, 0, 2, 3, 2, 3, 0, 2, 3, 3, 1, 0, 2, 3, 3, 2, 0, 2, 3, 3, 3, 0, 3, 0, 3, 1, 0, 3, 0, 3, 2, 0, 3, 0, 3, 3, 0, 3, 1, 1, 1, 0, 3, 1, 1, 2, 0, 3, 1, 1, 3, 0, 3, 1, 2, 1, 0, 3, 1, 2, 2, 0, 3, 1, 2, 3, 0, 3, 1, 3, 1, 0, 3, 1, 3, 2, 0, 3, 1, 3, 3, 0, 3, 2, 1, 1, 0, 3, 2, 1, 2, 0, 3, 2, 1, 3, 0, 3, 2, 2, 1, 0, 3, 2, 2, 2, 0, 3, 2, 2, 3, 0, 3, 2, 3, 1, 0, 3, 2, 3, 2, 0, 3, 2, 3, 3, 0, 3, 3, 1, 1, 0, 3, 3, 1, 2, 0, 3, 3, 1, 3, 0, 3, 3, 2, 1, 0, 3, 3, 2, 2, 0, 3, 3, 2, 3, 0, 3, 3, 3, 1, 0, 3, 3, 3, 2, 0, 3, 3, 3, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 3, 1, 1, 1, 2, 2, 1, 1, 1, 2, 3, 1, 1, 1, 3, 2, 1, 1, 1, 3, 3, 1, 1, 2, 1, 2, 1, 1, 2, 1, 3, 1, 1, 2, 2, 2, 1, 1, 2, 2, 3, 1, 1, 2, 3, 2, 1, 1, 2, 3, 3, 1, 1, 3, 1, 2, 1, 1, 3, 1, 3, 1, 1, 3, 2, 2, 1, 1, 3, 2, 3, 1, 1, 3, 3, 2, 1, 1, 3, 3, 3, 1, 2, 1, 2, 2, 1, 2, 1, 2, 3, 1, 2, 1, 3, 2, 1, 2, 1, 3, 3, 1, 2, 2, 1, 3, 1, 2, 2, 2, 2, 1, 2, 2, 2, 3, 1, 2, 2, 3, 2, 1, 2, 2, 3, 3, 1, 2, 3, 1, 3, 1, 2, 3, 2, 2, 1, 2, 3, 2, 3, 1, 2, 3, 3, 2, 1, 2, 3, 3, 3, 1, 3, 1, 3, 2, 1, 3, 1, 3, 3, 1, 3, 2, 2, 2, 1, 3, 2, 2, 3, 1, 3, 2, 3, 2, 1, 3, 2, 3, 3, 1, 3, 3, 2, 2, 1, 3, 3, 2, 3, 1, 3, 3, 3, 2, 1, 3, 3, 3, 3, 2, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3, 2, 2, 3, 2, 3, 2, 2, 3, 3, 3, 2, 3, 2, 3, 3, 2, 3, 3, 3, 3, 3]} +RLMATH_EOF diff --git a/tasks/construct-mc-debruijn-l5-s2/tests/check.py b/tasks/construct-mc-debruijn-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c9d6f0177d2b3bde8306d74939ee9704c1501a23 --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-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-l5-s2/tests/instance.json b/tasks/construct-mc-debruijn-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b24c56bf19f75a78de5813ea786e1c121f81bcb7 --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"b": 4, "n": 5, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l5-s2/tests/run.py b/tasks/construct-mc-debruijn-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-debruijn-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-debruijn-l5-s2/tests/test.sh b/tasks/construct-mc-debruijn-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-debruijn-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-golomb-l2-s2/environment/Dockerfile b/tasks/construct-mc-golomb-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-golomb-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-golomb-l2-s2/environment/instance.json b/tasks/construct-mc-golomb-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2455b77a5afa7dd7d12bcf68297bd2280eda8416 --- /dev/null +++ b/tasks/construct-mc-golomb-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "max_length": 34, "fixed": [], "family": "mc_golomb", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-golomb-l2-s2/solution/solve.sh b/tasks/construct-mc-golomb-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6660b5c9de5f203c3584b8ee2d137377489bbfba --- /dev/null +++ b/tasks/construct-mc-golomb-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' +{"marks": [0, 1, 4, 9, 15, 22, 32, 34]} +RLMATH_EOF diff --git a/tasks/construct-mc-golomb-l2-s2/tests/instance.json b/tasks/construct-mc-golomb-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2455b77a5afa7dd7d12bcf68297bd2280eda8416 --- /dev/null +++ b/tasks/construct-mc-golomb-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "max_length": 34, "fixed": [], "family": "mc_golomb", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-golomb-l2-s2/tests/test.sh b/tasks/construct-mc-golomb-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-golomb-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-golomb-l6-s3/environment/Dockerfile b/tasks/construct-mc-golomb-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-golomb-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-golomb-l6-s3/environment/instance.json b/tasks/construct-mc-golomb-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..21443be08561a580dc5bf9ebbb51f49747d0f67e --- /dev/null +++ b/tasks/construct-mc-golomb-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "max_length": 283, "fixed": [], "family": "mc_golomb", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-golomb-l6-s3/solution/solve.sh b/tasks/construct-mc-golomb-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6089e802e811dd8766a19067b86ce5e31b03c584 --- /dev/null +++ b/tasks/construct-mc-golomb-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' +{"marks": [0, 1, 8, 11, 68, 77, 94, 116, 121, 156, 158, 179, 194, 208, 212, 228, 240, 253, 259, 283]} +RLMATH_EOF diff --git a/tasks/construct-mc-golomb-l6-s3/tests/check.py b/tasks/construct-mc-golomb-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..84aedd6e33fee7271543bfa49ab05128e23c31ee --- /dev/null +++ b/tasks/construct-mc-golomb-l6-s3/tests/check.py @@ -0,0 +1,27 @@ +"""Golomb ruler with n marks and length <= L (MathConstraint golomb, CC-BY-4.0, reframed as a decision +problem with the target length stated). Accepts any valid ruler. +Upstream note: the upstream prompt states no length bound and its verifier re-solves the optimisation +model with the marks fixed, which returns OPTIMUM for any Golomb ruler, so any ruler (e.g. 0,1,3,7,15,..) +was accepted. Here the length bound is part of the instance and enforced.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, L = inst["n"], inst["max_length"] + a = int_list(ans.get("marks"), n, 0, L, "marks") + if a[0] != 0: + raise Invalid("first mark must be 0") + if any(a[i] >= a[i + 1] for i in range(n - 1)): + raise Invalid("marks must be strictly increasing") + for name, i, v in inst.get("fixed", []): + if a[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + seen = set() + for i, j in itertools.combinations(range(n), 2): + d = a[j] - a[i] + if d in seen: + raise Invalid(f"difference {d} occurs twice") + seen.add(d) + return None, {"length": a[-1]} diff --git a/tasks/construct-mc-golomb-l6-s3/tests/instance.json b/tasks/construct-mc-golomb-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..21443be08561a580dc5bf9ebbb51f49747d0f67e --- /dev/null +++ b/tasks/construct-mc-golomb-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "max_length": 283, "fixed": [], "family": "mc_golomb", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-golomb-l6-s3/tests/run.py b/tasks/construct-mc-golomb-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-golomb-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-golomb-l6-s3/tests/test.sh b/tasks/construct-mc-golomb-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-golomb-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-graceful-graph-l1-s0/environment/Dockerfile b/tasks/construct-mc-graceful-graph-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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-graceful-graph-l1-s0/environment/instance.json b/tasks/construct-mc-graceful-graph-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b983d943629a4307f52c6128eb50676c38e72420 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"k": 2, "p": 5, "num_vertices": 10, "edges": [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]], "fixed": [], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l1-s0/solution/solve.sh b/tasks/construct-mc-graceful-graph-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4fabf51f4ff001400662a7aad59df8907523570 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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' +{"labels": [11, 6, 4, 10, 1, 2, 12, 0, 3, 13]} +RLMATH_EOF diff --git a/tasks/construct-mc-graceful-graph-l1-s0/tests/check.py b/tasks/construct-mc-graceful-graph-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f4d33af1d63c0495c3b32d34db6ae10f0fb45923 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l1-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-l1-s0/tests/instance.json b/tasks/construct-mc-graceful-graph-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b983d943629a4307f52c6128eb50676c38e72420 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"k": 2, "p": 5, "num_vertices": 10, "edges": [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]], "fixed": [], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l1-s0/tests/run.py b/tasks/construct-mc-graceful-graph-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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-graceful-graph-l1-s0/tests/test.sh b/tasks/construct-mc-graceful-graph-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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-hadamard-l1-s0/environment/Dockerfile b/tasks/construct-mc-hadamard-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-hadamard-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-hadamard-l1-s0/environment/instance.json b/tasks/construct-mc-hadamard-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..02db493d95ea61fe6dd8e4e666c9a8eb63fef9de --- /dev/null +++ b/tasks/construct-mc-hadamard-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 9, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l1-s0/solution/solve.sh b/tasks/construct-mc-hadamard-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0dbc66243f488ebac659659adaa1c994f5746bf4 --- /dev/null +++ b/tasks/construct-mc-hadamard-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": [1, 1, 1, -1, 1, -1, 1, -1, -1], "y": [1, 1, 1, 1, -1, -1, 1, -1, -1]} +RLMATH_EOF diff --git a/tasks/construct-mc-hadamard-l1-s0/tests/check.py b/tasks/construct-mc-hadamard-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..fc4b93160fd7473dd14935db9d712e52abdd00c2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l1-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-l1-s0/tests/instance.json b/tasks/construct-mc-hadamard-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..02db493d95ea61fe6dd8e4e666c9a8eb63fef9de --- /dev/null +++ b/tasks/construct-mc-hadamard-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 9, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l1-s0/tests/run.py b/tasks/construct-mc-hadamard-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-hadamard-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-hadamard-l1-s0/tests/test.sh b/tasks/construct-mc-hadamard-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-hadamard-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-l1-s1/environment/Dockerfile b/tasks/construct-mc-langford-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-langford-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-langford-l1-s1/environment/instance.json b/tasks/construct-mc-langford-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..83c5de8c5e17a3067b5a3e0a959a28cc07091181 --- /dev/null +++ b/tasks/construct-mc-langford-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 4, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l1-s1/solution/solve.sh b/tasks/construct-mc-langford-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..53bda82734f6a10cbe045955d28bc695a56aa174 --- /dev/null +++ b/tasks/construct-mc-langford-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' +{"seq": [2, 3, 4, 2, 1, 3, 1, 4]} +RLMATH_EOF diff --git a/tasks/construct-mc-langford-l1-s1/tests/check.py b/tasks/construct-mc-langford-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4672d7eacf321991933cb280d6c940f1c4a67935 --- /dev/null +++ b/tasks/construct-mc-langford-l1-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-l1-s1/tests/instance.json b/tasks/construct-mc-langford-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..83c5de8c5e17a3067b5a3e0a959a28cc07091181 --- /dev/null +++ b/tasks/construct-mc-langford-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 4, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l1-s1/tests/run.py b/tasks/construct-mc-langford-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-langford-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-langford-l1-s1/tests/test.sh b/tasks/construct-mc-langford-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-langford-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-langford-l5-s0/environment/Dockerfile b/tasks/construct-mc-langford-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-langford-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-langford-l5-s0/environment/instance.json b/tasks/construct-mc-langford-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3f9e047cd088c18cd6591c8c063d9d494a6873eb --- /dev/null +++ b/tasks/construct-mc-langford-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 32, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l5-s0/solution/solve.sh b/tasks/construct-mc-langford-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..998e1d88f43fd0774a6fb87aede205c232790061 --- /dev/null +++ b/tasks/construct-mc-langford-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' +{"seq": [26, 21, 23, 14, 17, 13, 32, 16, 25, 20, 1, 19, 1, 22, 2, 4, 27, 2, 14, 13, 4, 31, 17, 21, 16, 15, 23, 26, 30, 28, 20, 19, 12, 29, 25, 11, 22, 24, 10, 32, 9, 15, 18, 8, 27, 12, 7, 11, 6, 10, 9, 5, 8, 31, 7, 6, 3, 5, 28, 30, 3, 18, 24, 29]} +RLMATH_EOF diff --git a/tasks/construct-mc-langford-l5-s0/tests/check.py b/tasks/construct-mc-langford-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4672d7eacf321991933cb280d6c940f1c4a67935 --- /dev/null +++ b/tasks/construct-mc-langford-l5-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-l5-s0/tests/instance.json b/tasks/construct-mc-langford-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3f9e047cd088c18cd6591c8c063d9d494a6873eb --- /dev/null +++ b/tasks/construct-mc-langford-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 32, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l5-s0/tests/run.py b/tasks/construct-mc-langford-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-langford-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-langford-l5-s0/tests/test.sh b/tasks/construct-mc-langford-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-langford-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-low-autocorrelation-l6-s2/environment/Dockerfile b/tasks/construct-mc-low-autocorrelation-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l6-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-low-autocorrelation-l6-s2/environment/instance.json b/tasks/construct-mc-low-autocorrelation-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6931caca515bb75c5e990d95f92bbdde2041d54b --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 60, "bound": 266, "fixed": [], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l6-s2/solution/solve.sh b/tasks/construct-mc-low-autocorrelation-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b4deee7abdfcf835c5e6ac3a0301ae83b1831777 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l6-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": [-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, -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-low-autocorrelation-l6-s2/tests/check.py b/tasks/construct-mc-low-autocorrelation-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8456f7b1c0ff0c9fb4bc9ae5a49074c8afa7d1aa --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l6-s2/tests/check.py @@ -0,0 +1,20 @@ +"""+-1 sequence of length n with aperiodic autocorrelation energy sum_k C_k^2 <= bound +(MathConstraint low_autocorrelation, CC-BY-4.0). Exact integer arithmetic.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, bound = inst["n"], inst["bound"] + s = int_list(ans.get("seq"), n, -1, 1, "seq") + if any(v == 0 for v in s): + raise Invalid("entries must be -1 or +1") + c = [sum(s[i] * s[i + k] for i in range(n - k)) for k in range(1, n)] + e = sum(v * v for v in c) + # fixed values: seq[i] or c[k] (c[k] is the autocorrelation at shift k+1, as upstream) + seqs = {"seq": s, "c": c} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + if e > bound: + raise Invalid(f"energy {e} exceeds the bound {bound}") + return None, {"energy": e} diff --git a/tasks/construct-mc-low-autocorrelation-l6-s2/tests/instance.json b/tasks/construct-mc-low-autocorrelation-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6931caca515bb75c5e990d95f92bbdde2041d54b --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 60, "bound": 266, "fixed": [], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l6-s2/tests/run.py b/tasks/construct-mc-low-autocorrelation-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l6-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-low-autocorrelation-l6-s2/tests/test.sh b/tasks/construct-mc-low-autocorrelation-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l6-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-independent-set-l4-s7/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l4-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-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-max-independent-set-l4-s7/environment/instance.json b/tasks/construct-mc-max-independent-set-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..114404eb4999b21ea80d0010efc4b152027897fd --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 1], [0, 4], [0, 6], [0, 8], [0, 17], [0, 20], [0, 27], [0, 35], [0, 40], [0, 43], [0, 45], [0, 46], [0, 47], [0, 48], [0, 50], [0, 52], [0, 57], [1, 3], [1, 4], [1, 10], [1, 11], [1, 13], [1, 14], [1, 15], [1, 16], [1, 21], [1, 23], [1, 27], [1, 28], [1, 29], [1, 38], [1, 47], [1, 48], [1, 53], [1, 54], [1, 55], [1, 56], [1, 59], [2, 4], [2, 6], [2, 7], [2, 9], [2, 13], [2, 16], [2, 25], [2, 29], [2, 31], [2, 32], [2, 33], [2, 37], [2, 44], [2, 46], [2, 48], [2, 49], [3, 6], [3, 10], [3, 11], [3, 12], [3, 17], [3, 18], [3, 19], [3, 20], [3, 26], [3, 27], [3, 34], [3, 36], [3, 41], [3, 51], [3, 53], [4, 8], [4, 11], [4, 13], [4, 14], [4, 16], [4, 21], [4, 22], [4, 23], [4, 30], [4, 35], [4, 37], [4, 42], [4, 45], [4, 47], [4, 48], [5, 7], [5, 9], [5, 15], [5, 23], [5, 31], [5, 35], [5, 39], [5, 40], [5, 45], [5, 49], [5, 50], [5, 52], [5, 53], [5, 55], [5, 56], [5, 57], [6, 7], [6, 12], [6, 14], [6, 23], [6, 24], [6, 25], [6, 29], [6, 43], [6, 45], [6, 46], [6, 49], [6, 52], [6, 54], [7, 8], [7, 9], [7, 10], [7, 13], [7, 18], [7, 21], [7, 24], [7, 25], [7, 26], [7, 32], [7, 34], [7, 35], [7, 41], [7, 45], [7, 47], [8, 11], [8, 12], [8, 13], [8, 14], [8, 20], [8, 26], [8, 28], [8, 34], [8, 37], [8, 39], [8, 40], [8, 50], [8, 51], [8, 56], [9, 11], [9, 15], [9, 17], [9, 21], [9, 22], [9, 24], [9, 31], [9, 33], [9, 35], [9, 38], [9, 40], [9, 44], [9, 47], [9, 52], [9, 56], [9, 57], [10, 11], [10, 15], [10, 24], [10, 25], [10, 27], [10, 28], [10, 37], [10, 42], [10, 51], [10, 54], [10, 56], [11, 12], [11, 13], [11, 14], [11, 15], [11, 21], [11, 28], [11, 29], [11, 36], [11, 39], [11, 44], [11, 49], [11, 50], [11, 55], [12, 14], [12, 17], [12, 19], [12, 22], [12, 26], [12, 27], [12, 33], [12, 34], [12, 35], [12, 40], [12, 42], [12, 43], [12, 46], [12, 49], [13, 14], [13, 16], [13, 17], [13, 20], [13, 23], [13, 27], [13, 29], [13, 30], [13, 33], [13, 41], [13, 43], [13, 44], [13, 45], [13, 51], [13, 53], [13, 55], [13, 56], [13, 57], [13, 58], [14, 15], [14, 16], [14, 17], [14, 25], [14, 26], [14, 27], [14, 31], [14, 32], [14, 33], [14, 36], [14, 42], [14, 46], [14, 52], [14, 53], [14, 55], [14, 56], [14, 57], [14, 58], [14, 59], [15, 16], [15, 20], [15, 25], [15, 26], [15, 27], [15, 30], [15, 35], [15, 38], [15, 39], [15, 44], [15, 47], [15, 51], [15, 52], [15, 59], [16, 18], [16, 20], [16, 34], [16, 36], [16, 42], [16, 43], [16, 54], [16, 56], [17, 20], [17, 23], [17, 28], [17, 32], [17, 38], [17, 46], [17, 48], [17, 50], [17, 51], [17, 52], [17, 55], [18, 19], [18, 23], [18, 24], [18, 25], [18, 31], [18, 32], [18, 33], [18, 34], [18, 36], [18, 37], [18, 43], [18, 53], [19, 21], [19, 23], [19, 24], [19, 25], [19, 28], [19, 30], [19, 36], [19, 40], [19, 43], [19, 45], [19, 46], [19, 53], [19, 57], [20, 22], [20, 25], [20, 29], [20, 31], [20, 32], [20, 44], [20, 45], [20, 49], [20, 57], [20, 59], [21, 22], [21, 26], [21, 30], [21, 32], [21, 33], [21, 34], [21, 37], [21, 42], [21, 43], [21, 51], [21, 53], [21, 57], [21, 58], [21, 59], [22, 25], [22, 30], [22, 32], [22, 35], [22, 42], [23, 26], [23, 28], [23, 30], [23, 31], [23, 37], [23, 43], [23, 45], [23, 46], [23, 48], [23, 54], [23, 55], [23, 56], [23, 57], [23, 59], [24, 26], [24, 27], [24, 28], [24, 30], [24, 31], [24, 40], [24, 54], [24, 57], [24, 58], [25, 26], [25, 27], [25, 28], [25, 31], [25, 33], [25, 34], [25, 39], [25, 40], [25, 50], [25, 53], [26, 27], [26, 29], [26, 30], [26, 32], [26, 34], [26, 37], [26, 38], [26, 42], [26, 43], [26, 48], [26, 53], [26, 55], [27, 34], [27, 36], [27, 39], [27, 47], [27, 48], [27, 52], [27, 55], [27, 57], [27, 59], [28, 31], [28, 33], [28, 35], [28, 37], [28, 39], [28, 51], [28, 57], [29, 31], [29, 33], [29, 34], [29, 42], [29, 52], [30, 33], [30, 39], [30, 44], [30, 54], [31, 43], [32, 34], [32, 39], [32, 42], [32, 46], [32, 53], [32, 55], [32, 58], [33, 35], [33, 45], [33, 49], [33, 50], [33, 56], [33, 59], [34, 48], [34, 50], [34, 54], [34, 55], [34, 59], [35, 37], [35, 38], [35, 42], [35, 43], [35, 44], [35, 46], [35, 49], [35, 52], [35, 54], [35, 56], [35, 59], [36, 46], [36, 49], [36, 51], [36, 52], [36, 56], [36, 57], [37, 39], [37, 40], [37, 44], [37, 53], [37, 58], [37, 59], [38, 40], [38, 41], [38, 49], [38, 52], [39, 42], [39, 44], [39, 45], [39, 46], [39, 47], [39, 49], [39, 50], [39, 57], [39, 59], [40, 45], [40, 46], [40, 48], [40, 49], [40, 54], [40, 55], [40, 59], [41, 42], [41, 48], [41, 49], [41, 57], [42, 43], [42, 44], [42, 45], [42, 47], [42, 48], [42, 52], [43, 54], [43, 55], [43, 57], [44, 45], [44, 46], [44, 51], [44, 52], [44, 56], [44, 59], [45, 47], [45, 49], [46, 47], [46, 52], [46, 59], [47, 54], [47, 58], [48, 49], [48, 52], [48, 56], [49, 53], [49, 54], [49, 57], [50, 51], [50, 54], [50, 58], [50, 59], [51, 53], [51, 54], [51, 56], [51, 59], [52, 54], [52, 57], [53, 54], [53, 59], [54, 56], [54, 57], [55, 56], [56, 59], [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-s7/solution/solve.sh b/tasks/construct-mc-max-independent-set-l4-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a7047a5f8f137b3f41b07000b1b6112801265900 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-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' +{"independent_set": [6, 8, 10, 16, 22, 31, 33, 38, 44, 48, 53, 55, 57, 58]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l4-s9/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l4-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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-mc-max-independent-set-l4-s9/environment/instance.json b/tasks/construct-mc-max-independent-set-l4-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..83f16c72c04ad8cd23e7e045a590f6b14b305f99 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 7], [0, 11], [0, 13], [0, 17], [0, 34], [0, 35], [0, 38], [0, 41], [0, 42], [0, 47], [0, 48], [0, 53], [0, 56], [0, 57], [1, 4], [1, 9], [1, 10], [1, 14], [1, 19], [1, 26], [1, 28], [1, 29], [1, 34], [1, 43], [1, 45], [1, 46], [1, 48], [1, 50], [1, 54], [2, 4], [2, 6], [2, 9], [2, 11], [2, 13], [2, 14], [2, 15], [2, 16], [2, 20], [2, 21], [2, 23], [2, 24], [2, 25], [2, 28], [2, 29], [2, 33], [2, 39], [2, 40], [2, 41], [2, 44], [2, 56], [3, 5], [3, 6], [3, 16], [3, 18], [3, 20], [3, 21], [3, 38], [3, 39], [3, 40], [3, 45], [3, 47], [3, 50], [3, 51], [3, 56], [3, 59], [4, 5], [4, 6], [4, 9], [4, 10], [4, 12], [4, 14], [4, 18], [4, 19], [4, 25], [4, 33], [4, 34], [4, 35], [4, 42], [4, 43], [4, 52], [4, 55], [5, 7], [5, 13], [5, 14], [5, 15], [5, 18], [5, 24], [5, 25], [5, 27], [5, 31], [5, 37], [5, 38], [5, 39], [5, 47], [5, 50], [5, 56], [5, 59], [6, 9], [6, 13], [6, 15], [6, 16], [6, 18], [6, 25], [6, 29], [6, 34], [6, 36], [6, 38], [6, 39], [6, 42], [6, 46], [6, 51], [6, 52], [7, 8], [7, 9], [7, 10], [7, 15], [7, 19], [7, 23], [7, 27], [7, 33], [7, 38], [7, 44], [7, 53], [7, 54], [8, 11], [8, 13], [8, 17], [8, 20], [8, 26], [8, 33], [8, 35], [8, 36], [8, 40], [8, 41], [8, 42], [8, 46], [8, 48], [8, 49], [8, 52], [8, 53], [9, 10], [9, 11], [9, 16], [9, 19], [9, 26], [9, 33], [9, 36], [9, 42], [9, 48], [9, 49], [9, 52], [9, 53], [9, 54], [9, 58], [10, 12], [10, 15], [10, 16], [10, 17], [10, 21], [10, 22], [10, 26], [10, 29], [10, 34], [10, 38], [10, 39], [10, 41], [10, 42], [10, 43], [10, 44], [10, 45], [10, 51], [10, 52], [10, 56], [10, 57], [10, 59], [11, 12], [11, 17], [11, 20], [11, 25], [11, 26], [11, 27], [11, 34], [11, 36], [11, 39], [11, 40], [11, 41], [11, 45], [11, 49], [11, 53], [11, 55], [11, 57], [11, 58], [11, 59], [12, 15], [12, 23], [12, 24], [12, 26], [12, 31], [12, 33], [12, 35], [12, 41], [12, 44], [12, 50], [12, 54], [12, 55], [12, 56], [12, 57], [12, 58], [13, 15], [13, 19], [13, 21], [13, 23], [13, 25], [13, 27], [13, 30], [13, 31], [13, 40], [13, 46], [13, 47], [13, 53], [13, 54], [13, 58], [14, 19], [14, 27], [14, 34], [14, 35], [14, 36], [14, 40], [14, 45], [14, 47], [14, 48], [14, 51], [14, 53], [14, 54], [14, 56], [14, 59], [15, 23], [15, 26], [15, 29], [15, 31], [15, 32], [15, 37], [15, 39], [15, 41], [15, 44], [15, 45], [15, 46], [15, 49], [15, 53], [15, 55], [15, 59], [16, 23], [16, 24], [16, 27], [16, 36], [16, 40], [16, 41], [16, 43], [16, 46], [16, 50], [16, 54], [17, 18], [17, 19], [17, 23], [17, 27], [17, 29], [17, 31], [17, 42], [17, 44], [17, 49], [17, 55], [17, 57], [17, 59], [18, 23], [18, 25], [18, 32], [18, 33], [18, 36], [18, 40], [18, 41], [18, 48], [18, 51], [18, 54], [19, 21], [19, 24], [19, 31], [19, 32], [19, 37], [19, 38], [19, 39], [19, 43], [19, 44], [19, 45], [19, 49], [19, 50], [19, 52], [19, 53], [19, 54], [19, 59], [20, 26], [20, 34], [20, 36], [20, 48], [20, 54], [20, 58], [21, 24], [21, 27], [21, 32], [21, 35], [21, 41], [21, 44], [21, 50], [21, 51], [22, 24], [22, 27], [22, 29], [22, 31], [22, 36], [22, 40], [22, 41], [22, 43], [22, 45], [23, 33], [23, 35], [23, 38], [23, 41], [23, 47], [23, 48], [23, 51], [23, 52], [23, 58], [24, 28], [24, 30], [24, 31], [24, 33], [24, 52], [24, 54], [25, 28], [25, 34], [25, 37], [25, 38], [25, 43], [25, 45], [25, 46], [25, 53], [25, 54], [25, 55], [26, 37], [26, 40], [26, 41], [26, 43], [26, 45], [26, 46], [26, 47], [26, 48], [26, 52], [26, 53], [26, 55], [26, 56], [27, 29], [27, 33], [27, 36], [27, 43], [27, 45], [27, 47], [27, 48], [27, 51], [27, 52], [27, 54], [27, 56], [28, 32], [28, 33], [28, 34], [28, 35], [28, 36], [28, 37], [28, 38], [28, 40], [28, 41], [28, 43], [28, 44], [28, 46], [28, 48], [28, 54], [28, 56], [29, 34], [29, 42], [29, 43], [29, 44], [29, 53], [29, 58], [30, 37], [30, 38], [30, 42], [30, 43], [30, 46], [30, 53], [31, 35], [31, 38], [31, 40], [31, 41], [31, 44], [31, 46], [31, 47], [31, 50], [31, 51], [31, 59], [32, 33], [32, 37], [32, 38], [32, 40], [32, 42], [32, 49], [32, 50], [32, 54], [32, 55], [32, 56], [32, 57], [33, 34], [33, 35], [33, 41], [33, 44], [33, 47], [33, 52], [33, 53], [34, 41], [34, 42], [34, 46], [34, 47], [34, 49], [34, 55], [34, 57], [35, 39], [35, 44], [35, 45], [35, 47], [35, 49], [35, 51], [35, 56], [35, 59], [36, 39], [36, 40], [36, 41], [36, 42], [36, 43], [36, 49], [36, 50], [36, 51], [36, 59], [37, 40], [37, 45], [37, 48], [37, 49], [37, 50], [37, 54], [37, 58], [38, 39], [38, 41], [38, 43], [38, 44], [38, 49], [38, 54], [38, 57], [38, 58], [39, 50], [39, 53], [39, 58], [39, 59], [40, 43], [40, 46], [40, 51], [40, 52], [41, 47], [41, 49], [41, 52], [41, 58], [41, 59], [42, 44], [42, 45], [42, 47], [42, 49], [42, 50], [42, 51], [42, 59], [43, 49], [43, 51], [43, 53], [43, 56], [43, 59], [44, 47], [44, 49], [44, 52], [44, 53], [44, 54], [44, 55], [44, 56], [45, 49], [45, 50], [45, 51], [45, 52], [45, 54], [45, 56], [45, 58], [45, 59], [46, 47], [46, 51], [46, 52], [46, 54], [46, 55], [47, 48], [47, 53], [48, 53], [48, 56], [48, 57], [49, 52], [49, 58], [50, 52], [50, 55], [50, 59], [52, 57], [52, 58], [52, 59], [53, 56], [55, 56], [55, 59], [56, 59], [57, 58], [57, 59]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s9/solution/solve.sh b/tasks/construct-mc-max-independent-set-l4-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2f45ab30b809400ffc00099e28ea37157113381e --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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' +{"independent_set": [7, 14, 16, 18, 20, 21, 28, 29, 30, 31, 39, 49, 55, 57]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l4-s9/tests/check.py b/tasks/construct-mc-max-independent-set-l4-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s9/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-s9/tests/instance.json b/tasks/construct-mc-max-independent-set-l4-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..83f16c72c04ad8cd23e7e045a590f6b14b305f99 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 7], [0, 11], [0, 13], [0, 17], [0, 34], [0, 35], [0, 38], [0, 41], [0, 42], [0, 47], [0, 48], [0, 53], [0, 56], [0, 57], [1, 4], [1, 9], [1, 10], [1, 14], [1, 19], [1, 26], [1, 28], [1, 29], [1, 34], [1, 43], [1, 45], [1, 46], [1, 48], [1, 50], [1, 54], [2, 4], [2, 6], [2, 9], [2, 11], [2, 13], [2, 14], [2, 15], [2, 16], [2, 20], [2, 21], [2, 23], [2, 24], [2, 25], [2, 28], [2, 29], [2, 33], [2, 39], [2, 40], [2, 41], [2, 44], [2, 56], [3, 5], [3, 6], [3, 16], [3, 18], [3, 20], [3, 21], [3, 38], [3, 39], [3, 40], [3, 45], [3, 47], [3, 50], [3, 51], [3, 56], [3, 59], [4, 5], [4, 6], [4, 9], [4, 10], [4, 12], [4, 14], [4, 18], [4, 19], [4, 25], [4, 33], [4, 34], [4, 35], [4, 42], [4, 43], [4, 52], [4, 55], [5, 7], [5, 13], [5, 14], [5, 15], [5, 18], [5, 24], [5, 25], [5, 27], [5, 31], [5, 37], [5, 38], [5, 39], [5, 47], [5, 50], [5, 56], [5, 59], [6, 9], [6, 13], [6, 15], [6, 16], [6, 18], [6, 25], [6, 29], [6, 34], [6, 36], [6, 38], [6, 39], [6, 42], [6, 46], [6, 51], [6, 52], [7, 8], [7, 9], [7, 10], [7, 15], [7, 19], [7, 23], [7, 27], [7, 33], [7, 38], [7, 44], [7, 53], [7, 54], [8, 11], [8, 13], [8, 17], [8, 20], [8, 26], [8, 33], [8, 35], [8, 36], [8, 40], [8, 41], [8, 42], [8, 46], [8, 48], [8, 49], [8, 52], [8, 53], [9, 10], [9, 11], [9, 16], [9, 19], [9, 26], [9, 33], [9, 36], [9, 42], [9, 48], [9, 49], [9, 52], [9, 53], [9, 54], [9, 58], [10, 12], [10, 15], [10, 16], [10, 17], [10, 21], [10, 22], [10, 26], [10, 29], [10, 34], [10, 38], [10, 39], [10, 41], [10, 42], [10, 43], [10, 44], [10, 45], [10, 51], [10, 52], [10, 56], [10, 57], [10, 59], [11, 12], [11, 17], [11, 20], [11, 25], [11, 26], [11, 27], [11, 34], [11, 36], [11, 39], [11, 40], [11, 41], [11, 45], [11, 49], [11, 53], [11, 55], [11, 57], [11, 58], [11, 59], [12, 15], [12, 23], [12, 24], [12, 26], [12, 31], [12, 33], [12, 35], [12, 41], [12, 44], [12, 50], [12, 54], [12, 55], [12, 56], [12, 57], [12, 58], [13, 15], [13, 19], [13, 21], [13, 23], [13, 25], [13, 27], [13, 30], [13, 31], [13, 40], [13, 46], [13, 47], [13, 53], [13, 54], [13, 58], [14, 19], [14, 27], [14, 34], [14, 35], [14, 36], [14, 40], [14, 45], [14, 47], [14, 48], [14, 51], [14, 53], [14, 54], [14, 56], [14, 59], [15, 23], [15, 26], [15, 29], [15, 31], [15, 32], [15, 37], [15, 39], [15, 41], [15, 44], [15, 45], [15, 46], [15, 49], [15, 53], [15, 55], [15, 59], [16, 23], [16, 24], [16, 27], [16, 36], [16, 40], [16, 41], [16, 43], [16, 46], [16, 50], [16, 54], [17, 18], [17, 19], [17, 23], [17, 27], [17, 29], [17, 31], [17, 42], [17, 44], [17, 49], [17, 55], [17, 57], [17, 59], [18, 23], [18, 25], [18, 32], [18, 33], [18, 36], [18, 40], [18, 41], [18, 48], [18, 51], [18, 54], [19, 21], [19, 24], [19, 31], [19, 32], [19, 37], [19, 38], [19, 39], [19, 43], [19, 44], [19, 45], [19, 49], [19, 50], [19, 52], [19, 53], [19, 54], [19, 59], [20, 26], [20, 34], [20, 36], [20, 48], [20, 54], [20, 58], [21, 24], [21, 27], [21, 32], [21, 35], [21, 41], [21, 44], [21, 50], [21, 51], [22, 24], [22, 27], [22, 29], [22, 31], [22, 36], [22, 40], [22, 41], [22, 43], [22, 45], [23, 33], [23, 35], [23, 38], [23, 41], [23, 47], [23, 48], [23, 51], [23, 52], [23, 58], [24, 28], [24, 30], [24, 31], [24, 33], [24, 52], [24, 54], [25, 28], [25, 34], [25, 37], [25, 38], [25, 43], [25, 45], [25, 46], [25, 53], [25, 54], [25, 55], [26, 37], [26, 40], [26, 41], [26, 43], [26, 45], [26, 46], [26, 47], [26, 48], [26, 52], [26, 53], [26, 55], [26, 56], [27, 29], [27, 33], [27, 36], [27, 43], [27, 45], [27, 47], [27, 48], [27, 51], [27, 52], [27, 54], [27, 56], [28, 32], [28, 33], [28, 34], [28, 35], [28, 36], [28, 37], [28, 38], [28, 40], [28, 41], [28, 43], [28, 44], [28, 46], [28, 48], [28, 54], [28, 56], [29, 34], [29, 42], [29, 43], [29, 44], [29, 53], [29, 58], [30, 37], [30, 38], [30, 42], [30, 43], [30, 46], [30, 53], [31, 35], [31, 38], [31, 40], [31, 41], [31, 44], [31, 46], [31, 47], [31, 50], [31, 51], [31, 59], [32, 33], [32, 37], [32, 38], [32, 40], [32, 42], [32, 49], [32, 50], [32, 54], [32, 55], [32, 56], [32, 57], [33, 34], [33, 35], [33, 41], [33, 44], [33, 47], [33, 52], [33, 53], [34, 41], [34, 42], [34, 46], [34, 47], [34, 49], [34, 55], [34, 57], [35, 39], [35, 44], [35, 45], [35, 47], [35, 49], [35, 51], [35, 56], [35, 59], [36, 39], [36, 40], [36, 41], [36, 42], [36, 43], [36, 49], [36, 50], [36, 51], [36, 59], [37, 40], [37, 45], [37, 48], [37, 49], [37, 50], [37, 54], [37, 58], [38, 39], [38, 41], [38, 43], [38, 44], [38, 49], [38, 54], [38, 57], [38, 58], [39, 50], [39, 53], [39, 58], [39, 59], [40, 43], [40, 46], [40, 51], [40, 52], [41, 47], [41, 49], [41, 52], [41, 58], [41, 59], [42, 44], [42, 45], [42, 47], [42, 49], [42, 50], [42, 51], [42, 59], [43, 49], [43, 51], [43, 53], [43, 56], [43, 59], [44, 47], [44, 49], [44, 52], [44, 53], [44, 54], [44, 55], [44, 56], [45, 49], [45, 50], [45, 51], [45, 52], [45, 54], [45, 56], [45, 58], [45, 59], [46, 47], [46, 51], [46, 52], [46, 54], [46, 55], [47, 48], [47, 53], [48, 53], [48, 56], [48, 57], [49, 52], [49, 58], [50, 52], [50, 55], [50, 59], [52, 57], [52, 58], [52, 59], [53, 56], [55, 56], [55, 59], [56, 59], [57, 58], [57, 59]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s9/tests/run.py b/tasks/construct-mc-max-independent-set-l4-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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-mc-max-independent-set-l4-s9/tests/test.sh b/tasks/construct-mc-max-independent-set-l4-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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-mc-non-transitive-dice-l1-s1/environment/Dockerfile b/tasks/construct-mc-non-transitive-dice-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-non-transitive-dice-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-non-transitive-dice-l1-s1/environment/instance.json b/tasks/construct-mc-non-transitive-dice-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ef934edb43c8e0fd57d11528b75dbc08ddfb81c4 --- /dev/null +++ b/tasks/construct-mc-non-transitive-dice-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 3, "m": 4, "family": "mc_non_transitive_dice", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-non-transitive-dice-l1-s1/solution/solve.sh b/tasks/construct-mc-non-transitive-dice-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bf596093cf93496b5daf2e6769de9986e6a78794 --- /dev/null +++ b/tasks/construct-mc-non-transitive-dice-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' +{"dice": [[0, 4, 5, 5], [2, 3, 3, 7], [0, 2, 6, 6]]} +RLMATH_EOF diff --git a/tasks/construct-mc-non-transitive-dice-l1-s1/tests/check.py b/tasks/construct-mc-non-transitive-dice-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3d5c04fa6e2819bf32f34fafe13a383437dc62a --- /dev/null +++ b/tasks/construct-mc-non-transitive-dice-l1-s1/tests/check.py @@ -0,0 +1,18 @@ +"""Cyclically intransitive dice (MathConstraint non_transitive_dice, CC-BY-4.0): n dice with m faces in +0..2m-1; die i beats die (i+1) mod n, i.e. #{(a, b): face_i(a) > face_{i+1}(b)} > floor(m^2 / 2). +Face order is irrelevant (upstream additionally demanded sorted faces as a symmetry break; not required).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, m = inst["n"], inst["m"] + D = ans.get("dice") + if not isinstance(D, list) or len(D) != n: + raise Invalid(f"dice must be a list of {n} dice") + D = [int_list(d, m, 0, 2 * m - 1, "die") for d in D] + for i in range(n): + A, B = D[i], D[(i + 1) % n] + w = sum(1 for a in A for b in B if a > b) + if w <= m * m // 2: + raise Invalid(f"die {i} wins only {w} of {m * m} face pairs against die {(i + 1) % n}") + return None, {} diff --git a/tasks/construct-mc-non-transitive-dice-l1-s1/tests/instance.json b/tasks/construct-mc-non-transitive-dice-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ef934edb43c8e0fd57d11528b75dbc08ddfb81c4 --- /dev/null +++ b/tasks/construct-mc-non-transitive-dice-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 3, "m": 4, "family": "mc_non_transitive_dice", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-non-transitive-dice-l1-s1/tests/run.py b/tasks/construct-mc-non-transitive-dice-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-non-transitive-dice-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-non-transitive-dice-l1-s1/tests/test.sh b/tasks/construct-mc-non-transitive-dice-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-non-transitive-dice-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-number-partitioning-l1-s2/environment/Dockerfile b/tasks/construct-mc-number-partitioning-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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-number-partitioning-l1-s2/environment/instance.json b/tasks/construct-mc-number-partitioning-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cbc3fbd204488953ea58ddd480649be60f977459 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 3, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l1-s2/solution/solve.sh b/tasks/construct-mc-number-partitioning-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..97ff1c2607b28f3f12fbf9dbbb76dae4d86dc279 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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' +{"x": [0, 1, 2, 2, 1, 0, 0, 1, 2, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-number-partitioning-l1-s2/tests/check.py b/tasks/construct-mc-number-partitioning-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..67793721db8ba7d3c3979ea0e1e07091491ffa7e --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l1-s2/tests/check.py @@ -0,0 +1,14 @@ +"""Partition {1..n} into k subsets of equal sum (MathConstraint number_partitioning, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + x = int_list(ans.get("x"), n, 0, k - 1, "x") + target = n * (n + 1) // 2 // k + sums = [0] * k + for i, s in enumerate(x): + sums[s] += i + 1 + if any(t != target for t in sums): + raise Invalid(f"subset sums {sums} are not all {target}") + return None, {} diff --git a/tasks/construct-mc-number-partitioning-l1-s2/tests/instance.json b/tasks/construct-mc-number-partitioning-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cbc3fbd204488953ea58ddd480649be60f977459 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 3, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l1-s2/tests/run.py b/tasks/construct-mc-number-partitioning-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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-number-partitioning-l1-s2/tests/test.sh b/tasks/construct-mc-number-partitioning-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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-number-partitioning-l1-s5/environment/Dockerfile b/tasks/construct-mc-number-partitioning-l1-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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-number-partitioning-l1-s5/environment/instance.json b/tasks/construct-mc-number-partitioning-l1-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cbed04ac364398dd1f7e7f4cdfead1bf3351d293 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l1-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 11, "k": 6, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l1-s5/solution/solve.sh b/tasks/construct-mc-number-partitioning-l1-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b1921e1f87ac82b6bf2ffc23e80155715c2c77 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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' +{"x": [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-number-partitioning-l1-s5/tests/check.py b/tasks/construct-mc-number-partitioning-l1-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..67793721db8ba7d3c3979ea0e1e07091491ffa7e --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l1-s5/tests/check.py @@ -0,0 +1,14 @@ +"""Partition {1..n} into k subsets of equal sum (MathConstraint number_partitioning, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + x = int_list(ans.get("x"), n, 0, k - 1, "x") + target = n * (n + 1) // 2 // k + sums = [0] * k + for i, s in enumerate(x): + sums[s] += i + 1 + if any(t != target for t in sums): + raise Invalid(f"subset sums {sums} are not all {target}") + return None, {} diff --git a/tasks/construct-mc-number-partitioning-l1-s5/tests/instance.json b/tasks/construct-mc-number-partitioning-l1-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cbed04ac364398dd1f7e7f4cdfead1bf3351d293 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l1-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 11, "k": 6, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l1-s5/tests/run.py b/tasks/construct-mc-number-partitioning-l1-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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-number-partitioning-l1-s5/tests/test.sh b/tasks/construct-mc-number-partitioning-l1-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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-number-partitioning-l5-s3/environment/Dockerfile b/tasks/construct-mc-number-partitioning-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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-number-partitioning-l5-s3/environment/instance.json b/tasks/construct-mc-number-partitioning-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4705bf67be74493d63d94aaec4d39592cbd8c524 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 6, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l5-s3/solution/solve.sh b/tasks/construct-mc-number-partitioning-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..107e61c6c02946c9909be6c713dc407b01491cdd --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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' +{"x": [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-number-partitioning-l5-s3/tests/check.py b/tasks/construct-mc-number-partitioning-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..67793721db8ba7d3c3979ea0e1e07091491ffa7e --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l5-s3/tests/check.py @@ -0,0 +1,14 @@ +"""Partition {1..n} into k subsets of equal sum (MathConstraint number_partitioning, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + x = int_list(ans.get("x"), n, 0, k - 1, "x") + target = n * (n + 1) // 2 // k + sums = [0] * k + for i, s in enumerate(x): + sums[s] += i + 1 + if any(t != target for t in sums): + raise Invalid(f"subset sums {sums} are not all {target}") + return None, {} diff --git a/tasks/construct-mc-number-partitioning-l5-s3/tests/instance.json b/tasks/construct-mc-number-partitioning-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4705bf67be74493d63d94aaec4d39592cbd8c524 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 6, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l5-s3/tests/run.py b/tasks/construct-mc-number-partitioning-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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-number-partitioning-l5-s3/tests/test.sh b/tasks/construct-mc-number-partitioning-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-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-ortholatin-l3-s2/environment/Dockerfile b/tasks/construct-mc-ortholatin-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ortholatin-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-ortholatin-l3-s2/environment/instance.json b/tasks/construct-mc-ortholatin-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..34981d7778859d1666730f0790ef1f52062ce9a7 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 11, "family": "mc_ortholatin", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ortholatin-l3-s2/solution/solve.sh b/tasks/construct-mc-ortholatin-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..811b221f1f45dea9d89fdd7311a28ab4c53ae28c --- /dev/null +++ b/tasks/construct-mc-ortholatin-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": [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2], [4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3], [5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4], [6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5], [7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6], [8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7], [9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8], [10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]], "Y": [[0, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9], [1, 3, 5, 7, 9, 0, 2, 4, 6, 8, 10], [2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 0], [3, 5, 7, 9, 0, 2, 4, 6, 8, 10, 1], [4, 6, 8, 10, 1, 3, 5, 7, 9, 0, 2], [5, 7, 9, 0, 2, 4, 6, 8, 10, 1, 3], [6, 8, 10, 1, 3, 5, 7, 9, 0, 2, 4], [7, 9, 0, 2, 4, 6, 8, 10, 1, 3, 5], [8, 10, 1, 3, 5, 7, 9, 0, 2, 4, 6], [9, 0, 2, 4, 6, 8, 10, 1, 3, 5, 7], [10, 1, 3, 5, 7, 9, 0, 2, 4, 6, 8]]} +RLMATH_EOF diff --git a/tasks/construct-mc-ortholatin-l3-s2/tests/check.py b/tasks/construct-mc-ortholatin-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a5418a59fae1c86318eee903e90d75b36d8a3306 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l3-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-l3-s2/tests/instance.json b/tasks/construct-mc-ortholatin-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..34981d7778859d1666730f0790ef1f52062ce9a7 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 11, "family": "mc_ortholatin", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ortholatin-l3-s2/tests/run.py b/tasks/construct-mc-ortholatin-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ortholatin-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-ortholatin-l3-s2/tests/test.sh b/tasks/construct-mc-ortholatin-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ortholatin-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-pysms-chromatic-girth-l3-s2/environment/Dockerfile b/tasks/construct-mc-pysms-chromatic-girth-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-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-pysms-chromatic-girth-l3-s2/environment/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d8464ae9ffa315a791d7ea95f16efa1fdead8884 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 14, "required_edges": [], "max_chromatic_number": 3, "min_edges": 20, "min_girth": 6, "family": "mc_pysms_chromatic_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-chromatic-girth-l3-s2/solution/solve.sh b/tasks/construct-mc-pysms-chromatic-girth-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f082ac108da7d325ef0b27338e2a6d2c35d155c9 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-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' +{"edges": [[0, 11], [0, 12], [0, 13], [1, 9], [1, 10], [1, 13], [2, 8], [2, 10], [2, 12], [3, 8], [3, 9], [3, 11], [4, 7], [4, 10], [4, 11], [5, 7], [5, 9], [5, 12], [6, 7], [6, 8], [6, 13]], "coloring": [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-chromatic-girth-l3-s2/tests/check.py b/tasks/construct-mc-pysms-chromatic-girth-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l3-s2/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-l3-s2/tests/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d8464ae9ffa315a791d7ea95f16efa1fdead8884 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 14, "required_edges": [], "max_chromatic_number": 3, "min_edges": 20, "min_girth": 6, "family": "mc_pysms_chromatic_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-chromatic-girth-l3-s2/tests/run.py b/tasks/construct-mc-pysms-chromatic-girth-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-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-pysms-chromatic-girth-l3-s2/tests/test.sh b/tasks/construct-mc-pysms-chromatic-girth-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-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-pysms-girth-degree-l4-s1/environment/Dockerfile b/tasks/construct-mc-pysms-girth-degree-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-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-girth-degree-l4-s1/environment/instance.json b/tasks/construct-mc-pysms-girth-degree-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9918748ec79b0715779522be8a2378030e1e3caf --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 23, "required_edges": [], "max_degree": 6, "min_degree": 3, "min_girth": 6, "family": "mc_pysms_girth_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-girth-degree-l4-s1/solution/solve.sh b/tasks/construct-mc-pysms-girth-degree-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ea107ef130e98288b5f664141e2338db5b8e903b --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-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, 20], [0, 21], [0, 22], [1, 18], [1, 19], [1, 22], [2, 17], [2, 19], [2, 21], [3, 15], [3, 16], [3, 22], [4, 14], [4, 16], [4, 21], [5, 13], [5, 16], [5, 19], [5, 20], [6, 13], [6, 15], [6, 17], [7, 13], [7, 14], [7, 18], [8, 12], [8, 15], [8, 18], [9, 11], [9, 14], [9, 17], [9, 22], [10, 11], [10, 13], [10, 21], [11, 12], [12, 20]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-girth-degree-l4-s1/tests/check.py b/tasks/construct-mc-pysms-girth-degree-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-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-girth-degree-l4-s1/tests/instance.json b/tasks/construct-mc-pysms-girth-degree-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9918748ec79b0715779522be8a2378030e1e3caf --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 23, "required_edges": [], "max_degree": 6, "min_degree": 3, "min_girth": 6, "family": "mc_pysms_girth_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-girth-degree-l4-s1/tests/run.py b/tasks/construct-mc-pysms-girth-degree-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-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-girth-degree-l4-s1/tests/test.sh b/tasks/construct-mc-pysms-girth-degree-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-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-independent-connectivity-l4-s1/environment/Dockerfile b/tasks/construct-mc-pysms-independent-connectivity-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-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-independent-connectivity-l4-s1/environment/instance.json b/tasks/construct-mc-pysms-independent-connectivity-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b638b2057f606ed58128d9f6e3899d7d8e2b7bc5 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 15, "required_edges": [[2, 5], [8, 11], [0, 2], [5, 9], [2, 10], [2, 11], [4, 13], [7, 14], [2, 13], [11, 14], [4, 6], [9, 10], [4, 14], [12, 13], [3, 4], [0, 7], [1, 5], [2, 3], [5, 8], [11, 12], [7, 10]], "max_independent_set": 4, "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-s1/solution/solve.sh b/tasks/construct-mc-pysms-independent-connectivity-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..202381af71f4ba7b8da0d1a923832175f9607239 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-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], [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], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 14]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-independent-connectivity-l4-s1/tests/check.py b/tasks/construct-mc-pysms-independent-connectivity-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-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-independent-connectivity-l4-s1/tests/instance.json b/tasks/construct-mc-pysms-independent-connectivity-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b638b2057f606ed58128d9f6e3899d7d8e2b7bc5 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 15, "required_edges": [[2, 5], [8, 11], [0, 2], [5, 9], [2, 10], [2, 11], [4, 13], [7, 14], [2, 13], [11, 14], [4, 6], [9, 10], [4, 14], [12, 13], [3, 4], [0, 7], [1, 5], [2, 3], [5, 8], [11, 12], [7, 10]], "max_independent_set": 4, "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-s1/tests/run.py b/tasks/construct-mc-pysms-independent-connectivity-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-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-independent-connectivity-l4-s1/tests/test.sh b/tasks/construct-mc-pysms-independent-connectivity-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-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-min-girth-l4-s0/environment/Dockerfile b/tasks/construct-mc-pysms-min-girth-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-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-min-girth-l4-s0/environment/instance.json b/tasks/construct-mc-pysms-min-girth-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a7940a9f15a57dfbd83c6171df60cca91fe79e8f --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 14, "required_edges": [[9, 13], [4, 13]], "min_girth": 6, "family": "mc_pysms_min_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-girth-l4-s0/solution/solve.sh b/tasks/construct-mc-pysms-min-girth-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1c4371614072d14124a1ea07a224f5e6ac83f8d9 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-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, 13], [1, 13], [2, 13], [3, 13], [4, 13], [5, 13], [6, 13], [7, 13], [8, 13], [9, 13], [10, 13], [11, 13], [12, 13]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-min-girth-l4-s0/tests/check.py b/tasks/construct-mc-pysms-min-girth-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-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-min-girth-l4-s0/tests/instance.json b/tasks/construct-mc-pysms-min-girth-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a7940a9f15a57dfbd83c6171df60cca91fe79e8f --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 14, "required_edges": [[9, 13], [4, 13]], "min_girth": 6, "family": "mc_pysms_min_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-girth-l4-s0/tests/run.py b/tasks/construct-mc-pysms-min-girth-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-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-min-girth-l4-s0/tests/test.sh b/tasks/construct-mc-pysms-min-girth-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-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-num-edges-bounds-l2-s0/environment/Dockerfile b/tasks/construct-mc-pysms-num-edges-bounds-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-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-pysms-num-edges-bounds-l2-s0/environment/instance.json b/tasks/construct-mc-pysms-num-edges-bounds-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..106d3ae88c0bb3d074a6f853254ad6dbf41653ef --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 11, "required_edges": [[1, 9], [2, 9], [6, 9], [3, 10], [5, 7], [2, 8], [7, 9], [4, 6]], "max_edges": 43, "min_edges": 32, "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-s0/solution/solve.sh b/tasks/construct-mc-pysms-num-edges-bounds-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..59583aed544d91f3e6aabdd7a51d78983946578f --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-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' +{"edges": [[0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 3], [2, 4], [2, 5], [2, 7], [2, 8], [2, 9], [2, 10], [3, 4], [3, 5], [3, 6], [3, 8], [3, 9], [3, 10], [4, 5], [4, 6], [4, 7], [4, 9], [4, 10], [5, 6], [5, 7], [5, 8], [5, 10], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [9, 10]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l2-s0/tests/check.py b/tasks/construct-mc-pysms-num-edges-bounds-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l2-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-num-edges-bounds-l2-s0/tests/instance.json b/tasks/construct-mc-pysms-num-edges-bounds-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..106d3ae88c0bb3d074a6f853254ad6dbf41653ef --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 11, "required_edges": [[1, 9], [2, 9], [6, 9], [3, 10], [5, 7], [2, 8], [7, 9], [4, 6]], "max_edges": 43, "min_edges": 32, "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-s0/tests/run.py b/tasks/construct-mc-pysms-num-edges-bounds-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-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-pysms-num-edges-bounds-l2-s0/tests/test.sh b/tasks/construct-mc-pysms-num-edges-bounds-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-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-ramsey-l4-s0/environment/Dockerfile b/tasks/construct-mc-ramsey-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-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-ramsey-l4-s0/environment/instance.json b/tasks/construct-mc-ramsey-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dc8ee4a92c5a25d8d578135453441672dd8b3445 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 21, "r": 3, "s": 7, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s0/solution/solve.sh b/tasks/construct-mc-ramsey-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..037a1c19944cd11e36ca6e6da6f320eca2d4a304 --- /dev/null +++ b/tasks/construct-mc-ramsey-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' +{"colors": [1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 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-s0/tests/check.py b/tasks/construct-mc-ramsey-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s0/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-s0/tests/instance.json b/tasks/construct-mc-ramsey-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dc8ee4a92c5a25d8d578135453441672dd8b3445 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 21, "r": 3, "s": 7, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s0/tests/run.py b/tasks/construct-mc-ramsey-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-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-ramsey-l4-s0/tests/test.sh b/tasks/construct-mc-ramsey-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-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-ramsey-l4-s7/environment/Dockerfile b/tasks/construct-mc-ramsey-l4-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-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-ramsey-l4-s7/environment/instance.json b/tasks/construct-mc-ramsey-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..54b2550054d1e05c340a9570c33fcecaafdf1bd1 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "r": 5, "s": 4, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s7/solution/solve.sh b/tasks/construct-mc-ramsey-l4-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..eb2466adc65e66c455a698ce8dd49da29da5b356 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-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' +{"colors": [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-ramsey-l4-s7/tests/check.py b/tasks/construct-mc-ramsey-l4-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s7/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-s7/tests/instance.json b/tasks/construct-mc-ramsey-l4-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..54b2550054d1e05c340a9570c33fcecaafdf1bd1 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "r": 5, "s": 4, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s7/tests/run.py b/tasks/construct-mc-ramsey-l4-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-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-ramsey-l4-s7/tests/test.sh b/tasks/construct-mc-ramsey-l4-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-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-ramsey-l4-s9/environment/Dockerfile b/tasks/construct-mc-ramsey-l4-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-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-mc-ramsey-l4-s9/environment/instance.json b/tasks/construct-mc-ramsey-l4-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ed30ac9064d99f69b6e6b41acbaf3356e88ab5e4 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "r": 3, "s": 7, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s9/solution/solve.sh b/tasks/construct-mc-ramsey-l4-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5d601e837cc9b96a08da3773cd9afa3c0a087d74 --- /dev/null +++ b/tasks/construct-mc-ramsey-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' +{"colors": [1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 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-s9/tests/check.py b/tasks/construct-mc-ramsey-l4-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s9/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-s9/tests/instance.json b/tasks/construct-mc-ramsey-l4-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ed30ac9064d99f69b6e6b41acbaf3356e88ab5e4 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "r": 3, "s": 7, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s9/tests/run.py b/tasks/construct-mc-ramsey-l4-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-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-mc-ramsey-l4-s9/tests/test.sh b/tasks/construct-mc-ramsey-l4-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-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-mc-social-golfers-l1-s2/environment/Dockerfile b/tasks/construct-mc-social-golfers-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-social-golfers-l1-s2/environment/instance.json b/tasks/construct-mc-social-golfers-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4b78d8c0d3e30a2c58023468e6174f1ae5bb68be --- /dev/null +++ b/tasks/construct-mc-social-golfers-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"n_groups": 4, "group_size": 4, "n_weeks": 3, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l1-s2/solution/solve.sh b/tasks/construct-mc-social-golfers-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5746a4e16e4847545ae6476a7545fa1597d764fe --- /dev/null +++ b/tasks/construct-mc-social-golfers-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' +{"schedule": [[0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3], [0, 1, 2, 3, 1, 0, 3, 2, 2, 3, 0, 1, 3, 2, 1, 0], [0, 1, 2, 3, 2, 3, 0, 1, 3, 2, 1, 0, 1, 0, 3, 2]]} +RLMATH_EOF diff --git a/tasks/construct-mc-social-golfers-l1-s2/tests/check.py b/tasks/construct-mc-social-golfers-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..73977815b7b6094a8491075b6dc2ae1293e44930 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l1-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-l1-s2/tests/instance.json b/tasks/construct-mc-social-golfers-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4b78d8c0d3e30a2c58023468e6174f1ae5bb68be --- /dev/null +++ b/tasks/construct-mc-social-golfers-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"n_groups": 4, "group_size": 4, "n_weeks": 3, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l1-s2/tests/run.py b/tasks/construct-mc-social-golfers-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-social-golfers-l1-s2/tests/test.sh b/tasks/construct-mc-social-golfers-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-l5-s2/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-vertex-cover-l5-s2/environment/instance.json b/tasks/construct-mc-vertex-cover-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d82bc9345dd99912245e614595c7eb034d21ac1d --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 4], [0, 15], [0, 20], [0, 23], [0, 43], [0, 48], [0, 56], [0, 59], [0, 65], [0, 66], [0, 71], [0, 79], [0, 80], [0, 81], [0, 84], [0, 86], [1, 3], [1, 4], [1, 6], [1, 7], [1, 11], [1, 23], [1, 24], [1, 28], [1, 37], [1, 52], [1, 59], [1, 63], [1, 64], [1, 74], [1, 77], [1, 78], [2, 20], [2, 29], [2, 36], [2, 37], [2, 40], [2, 43], [2, 47], [2, 51], [2, 66], [2, 68], [2, 84], [2, 85], [3, 5], [3, 6], [3, 22], [3, 36], [3, 41], [3, 45], [3, 48], [3, 67], [3, 72], [4, 11], [4, 14], [4, 18], [4, 22], [4, 28], [4, 57], [4, 59], [4, 62], [4, 70], [4, 78], [4, 80], [4, 81], [4, 82], [5, 11], [5, 12], [5, 20], [5, 30], [5, 31], [5, 37], [5, 54], [5, 62], [5, 63], [5, 71], [5, 75], [5, 87], [6, 12], [6, 14], [6, 17], [6, 18], [6, 37], [6, 41], [6, 44], [6, 46], [6, 47], [6, 62], [6, 69], [6, 72], [6, 87], [7, 9], [7, 15], [7, 21], [7, 34], [7, 42], [7, 48], [7, 58], [7, 72], [7, 76], [7, 78], [7, 79], [7, 89], [8, 23], [8, 41], [8, 64], [8, 71], [9, 12], [9, 16], [9, 25], [9, 29], [9, 32], [9, 34], [9, 39], [9, 43], [9, 48], [9, 50], [9, 56], [9, 68], [9, 80], [9, 85], [10, 17], [10, 22], [10, 32], [10, 34], [10, 37], [10, 77], [11, 21], [11, 23], [11, 24], [11, 27], [11, 38], [11, 39], [11, 47], [11, 64], [11, 67], [11, 74], [11, 79], [11, 81], [12, 20], [12, 22], [12, 30], [12, 41], [12, 46], [12, 54], [12, 59], [12, 65], [12, 66], [12, 70], [12, 71], [12, 72], [12, 73], [12, 76], [12, 78], [12, 87], [13, 19], [13, 27], [13, 34], [13, 42], [13, 47], [13, 54], [13, 55], [13, 56], [13, 58], [13, 65], [13, 80], [13, 88], [14, 20], [14, 22], [14, 25], [14, 40], [14, 43], [14, 55], [14, 68], [14, 71], [15, 31], [15, 33], [15, 42], [15, 44], [15, 58], [15, 59], [15, 60], [15, 62], [15, 76], [15, 78], [15, 80], [16, 45], [16, 47], [16, 50], [16, 55], [16, 56], [16, 62], [16, 74], [16, 80], [16, 83], [17, 21], [17, 23], [17, 32], [17, 74], [17, 77], [18, 30], [18, 37], [18, 71], [18, 75], [19, 21], [19, 28], [19, 36], [19, 40], [19, 48], [19, 58], [19, 63], [19, 78], [19, 79], [19, 83], [19, 86], [19, 88], [20, 24], [20, 34], [20, 36], [20, 51], [20, 54], [20, 64], [20, 75], [20, 76], [20, 77], [20, 78], [20, 80], [20, 88], [21, 23], [21, 38], [21, 41], [21, 45], [21, 52], [21, 56], [21, 62], [21, 68], [21, 81], [21, 88], [22, 24], [22, 27], [22, 28], [22, 43], [22, 51], [22, 53], [22, 54], [22, 62], [22, 63], [22, 81], [22, 84], [22, 86], [23, 27], [23, 29], [23, 39], [23, 42], [23, 43], [23, 51], [23, 57], [23, 62], [23, 68], [24, 25], [24, 41], [24, 42], [24, 52], [24, 55], [24, 60], [24, 67], [24, 68], [24, 74], [24, 83], [24, 84], [25, 32], [25, 40], [25, 43], [25, 49], [25, 56], [25, 65], [25, 68], [25, 78], [25, 80], [25, 81], [25, 87], [26, 30], [26, 34], [26, 54], [26, 59], [26, 67], [26, 75], [26, 86], [27, 28], [27, 29], [27, 35], [27, 41], [27, 50], [27, 51], [27, 58], [27, 61], [27, 62], [27, 71], [28, 40], [28, 43], [28, 57], [28, 59], [28, 73], [28, 82], [28, 83], [29, 33], [29, 35], [29, 39], [29, 40], [29, 49], [29, 52], [29, 57], [29, 59], [29, 60], [29, 71], [29, 77], [29, 81], [30, 41], [30, 51], [30, 65], [30, 69], [30, 82], [31, 37], [31, 42], [31, 48], [31, 55], [31, 57], [31, 71], [31, 87], [32, 44], [32, 52], [32, 60], [32, 61], [32, 62], [32, 70], [32, 76], [32, 77], [32, 86], [32, 87], [32, 88], [33, 72], [33, 73], [33, 80], [33, 86], [34, 41], [34, 43], [34, 52], [34, 61], [34, 63], [34, 66], [34, 71], [34, 84], [34, 86], [35, 67], [35, 73], [35, 76], [35, 77], [36, 47], [36, 48], [36, 54], [36, 70], [36, 77], [37, 49], [37, 51], [37, 55], [37, 57], [37, 64], [37, 65], [37, 68], [37, 72], [37, 76], [37, 80], [37, 81], [38, 39], [38, 49], [38, 52], [38, 63], [38, 84], [39, 45], [39, 47], [39, 50], [39, 51], [39, 58], [39, 71], [39, 81], [40, 41], [40, 62], [40, 63], [40, 86], [41, 51], [41, 65], [41, 70], [41, 76], [41, 80], [41, 81], [41, 84], [42, 53], [42, 56], [42, 57], [42, 65], [42, 75], [42, 77], [43, 45], [43, 49], [43, 54], [43, 55], [43, 60], [43, 74], [43, 77], [43, 83], [44, 49], [44, 64], [44, 77], [44, 78], [44, 80], [44, 86], [44, 87], [45, 48], [45, 50], [45, 73], [45, 78], [45, 82], [45, 86], [46, 49], [46, 50], [46, 55], [46, 68], [46, 72], [46, 74], [46, 77], [47, 68], [47, 70], [47, 75], [47, 77], [47, 78], [47, 87], [47, 89], [48, 49], [48, 52], [48, 54], [48, 62], [49, 63], [49, 66], [49, 73], [49, 74], [49, 77], [49, 85], [49, 88], [50, 54], [50, 62], [50, 67], [50, 75], [50, 89], [51, 54], [51, 77], [51, 88], [52, 61], [52, 73], [52, 79], [52, 81], [52, 82], [53, 55], [53, 56], [53, 57], [53, 59], [53, 63], [53, 67], [53, 78], [53, 80], [53, 83], [54, 61], [54, 63], [54, 64], [54, 71], [54, 79], [55, 78], [55, 81], [56, 67], [56, 70], [56, 72], [56, 73], [56, 77], [56, 80], [57, 60], [57, 63], [57, 66], [57, 67], [57, 71], [57, 82], [57, 86], [58, 59], [58, 61], [58, 73], [58, 83], [58, 84], [58, 88], [59, 67], [59, 82], [60, 66], [60, 73], [60, 77], [60, 79], [60, 82], [60, 84], [61, 66], [61, 69], [61, 70], [61, 73], [62, 72], [62, 78], [62, 85], [62, 89], [63, 64], [63, 69], [63, 72], [63, 74], [63, 76], [63, 81], [63, 82], [63, 86], [64, 74], [64, 75], [64, 78], [64, 86], [64, 87], [64, 88], [65, 68], [65, 78], [65, 80], [66, 77], [66, 88], [67, 82], [68, 70], [68, 85], [70, 75], [71, 73], [71, 78], [72, 73], [73, 76], [73, 77], [73, 83], [73, 84], [73, 85], [73, 88], [74, 86], [75, 76], [75, 77], [75, 86], [76, 88], [77, 86], [77, 89], [78, 85], [78, 87], [79, 87], [81, 84], [83, 86], [83, 88], [84, 85]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s2/solution/solve.sh b/tasks/construct-mc-vertex-cover-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3ba81632c419ed9f0edd6d39e09542adf8579d21 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [0, 1, 2, 4, 5, 6, 7, 9, 11, 12, 13, 14, 15, 17, 19, 20, 21, 22, 23, 25, 27, 28, 29, 30, 32, 34, 35, 36, 37, 39, 41, 42, 45, 47, 48, 49, 50, 52, 54, 55, 56, 57, 59, 60, 61, 62, 63, 64, 67, 68, 71, 72, 73, 74, 75, 77, 78, 80, 83, 84, 86, 87, 88]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l5-s2/tests/check.py b/tasks/construct-mc-vertex-cover-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-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-l5-s2/tests/instance.json b/tasks/construct-mc-vertex-cover-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d82bc9345dd99912245e614595c7eb034d21ac1d --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 4], [0, 15], [0, 20], [0, 23], [0, 43], [0, 48], [0, 56], [0, 59], [0, 65], [0, 66], [0, 71], [0, 79], [0, 80], [0, 81], [0, 84], [0, 86], [1, 3], [1, 4], [1, 6], [1, 7], [1, 11], [1, 23], [1, 24], [1, 28], [1, 37], [1, 52], [1, 59], [1, 63], [1, 64], [1, 74], [1, 77], [1, 78], [2, 20], [2, 29], [2, 36], [2, 37], [2, 40], [2, 43], [2, 47], [2, 51], [2, 66], [2, 68], [2, 84], [2, 85], [3, 5], [3, 6], [3, 22], [3, 36], [3, 41], [3, 45], [3, 48], [3, 67], [3, 72], [4, 11], [4, 14], [4, 18], [4, 22], [4, 28], [4, 57], [4, 59], [4, 62], [4, 70], [4, 78], [4, 80], [4, 81], [4, 82], [5, 11], [5, 12], [5, 20], [5, 30], [5, 31], [5, 37], [5, 54], [5, 62], [5, 63], [5, 71], [5, 75], [5, 87], [6, 12], [6, 14], [6, 17], [6, 18], [6, 37], [6, 41], [6, 44], [6, 46], [6, 47], [6, 62], [6, 69], [6, 72], [6, 87], [7, 9], [7, 15], [7, 21], [7, 34], [7, 42], [7, 48], [7, 58], [7, 72], [7, 76], [7, 78], [7, 79], [7, 89], [8, 23], [8, 41], [8, 64], [8, 71], [9, 12], [9, 16], [9, 25], [9, 29], [9, 32], [9, 34], [9, 39], [9, 43], [9, 48], [9, 50], [9, 56], [9, 68], [9, 80], [9, 85], [10, 17], [10, 22], [10, 32], [10, 34], [10, 37], [10, 77], [11, 21], [11, 23], [11, 24], [11, 27], [11, 38], [11, 39], [11, 47], [11, 64], [11, 67], [11, 74], [11, 79], [11, 81], [12, 20], [12, 22], [12, 30], [12, 41], [12, 46], [12, 54], [12, 59], [12, 65], [12, 66], [12, 70], [12, 71], [12, 72], [12, 73], [12, 76], [12, 78], [12, 87], [13, 19], [13, 27], [13, 34], [13, 42], [13, 47], [13, 54], [13, 55], [13, 56], [13, 58], [13, 65], [13, 80], [13, 88], [14, 20], [14, 22], [14, 25], [14, 40], [14, 43], [14, 55], [14, 68], [14, 71], [15, 31], [15, 33], [15, 42], [15, 44], [15, 58], [15, 59], [15, 60], [15, 62], [15, 76], [15, 78], [15, 80], [16, 45], [16, 47], [16, 50], [16, 55], [16, 56], [16, 62], [16, 74], [16, 80], [16, 83], [17, 21], [17, 23], [17, 32], [17, 74], [17, 77], [18, 30], [18, 37], [18, 71], [18, 75], [19, 21], [19, 28], [19, 36], [19, 40], [19, 48], [19, 58], [19, 63], [19, 78], [19, 79], [19, 83], [19, 86], [19, 88], [20, 24], [20, 34], [20, 36], [20, 51], [20, 54], [20, 64], [20, 75], [20, 76], [20, 77], [20, 78], [20, 80], [20, 88], [21, 23], [21, 38], [21, 41], [21, 45], [21, 52], [21, 56], [21, 62], [21, 68], [21, 81], [21, 88], [22, 24], [22, 27], [22, 28], [22, 43], [22, 51], [22, 53], [22, 54], [22, 62], [22, 63], [22, 81], [22, 84], [22, 86], [23, 27], [23, 29], [23, 39], [23, 42], [23, 43], [23, 51], [23, 57], [23, 62], [23, 68], [24, 25], [24, 41], [24, 42], [24, 52], [24, 55], [24, 60], [24, 67], [24, 68], [24, 74], [24, 83], [24, 84], [25, 32], [25, 40], [25, 43], [25, 49], [25, 56], [25, 65], [25, 68], [25, 78], [25, 80], [25, 81], [25, 87], [26, 30], [26, 34], [26, 54], [26, 59], [26, 67], [26, 75], [26, 86], [27, 28], [27, 29], [27, 35], [27, 41], [27, 50], [27, 51], [27, 58], [27, 61], [27, 62], [27, 71], [28, 40], [28, 43], [28, 57], [28, 59], [28, 73], [28, 82], [28, 83], [29, 33], [29, 35], [29, 39], [29, 40], [29, 49], [29, 52], [29, 57], [29, 59], [29, 60], [29, 71], [29, 77], [29, 81], [30, 41], [30, 51], [30, 65], [30, 69], [30, 82], [31, 37], [31, 42], [31, 48], [31, 55], [31, 57], [31, 71], [31, 87], [32, 44], [32, 52], [32, 60], [32, 61], [32, 62], [32, 70], [32, 76], [32, 77], [32, 86], [32, 87], [32, 88], [33, 72], [33, 73], [33, 80], [33, 86], [34, 41], [34, 43], [34, 52], [34, 61], [34, 63], [34, 66], [34, 71], [34, 84], [34, 86], [35, 67], [35, 73], [35, 76], [35, 77], [36, 47], [36, 48], [36, 54], [36, 70], [36, 77], [37, 49], [37, 51], [37, 55], [37, 57], [37, 64], [37, 65], [37, 68], [37, 72], [37, 76], [37, 80], [37, 81], [38, 39], [38, 49], [38, 52], [38, 63], [38, 84], [39, 45], [39, 47], [39, 50], [39, 51], [39, 58], [39, 71], [39, 81], [40, 41], [40, 62], [40, 63], [40, 86], [41, 51], [41, 65], [41, 70], [41, 76], [41, 80], [41, 81], [41, 84], [42, 53], [42, 56], [42, 57], [42, 65], [42, 75], [42, 77], [43, 45], [43, 49], [43, 54], [43, 55], [43, 60], [43, 74], [43, 77], [43, 83], [44, 49], [44, 64], [44, 77], [44, 78], [44, 80], [44, 86], [44, 87], [45, 48], [45, 50], [45, 73], [45, 78], [45, 82], [45, 86], [46, 49], [46, 50], [46, 55], [46, 68], [46, 72], [46, 74], [46, 77], [47, 68], [47, 70], [47, 75], [47, 77], [47, 78], [47, 87], [47, 89], [48, 49], [48, 52], [48, 54], [48, 62], [49, 63], [49, 66], [49, 73], [49, 74], [49, 77], [49, 85], [49, 88], [50, 54], [50, 62], [50, 67], [50, 75], [50, 89], [51, 54], [51, 77], [51, 88], [52, 61], [52, 73], [52, 79], [52, 81], [52, 82], [53, 55], [53, 56], [53, 57], [53, 59], [53, 63], [53, 67], [53, 78], [53, 80], [53, 83], [54, 61], [54, 63], [54, 64], [54, 71], [54, 79], [55, 78], [55, 81], [56, 67], [56, 70], [56, 72], [56, 73], [56, 77], [56, 80], [57, 60], [57, 63], [57, 66], [57, 67], [57, 71], [57, 82], [57, 86], [58, 59], [58, 61], [58, 73], [58, 83], [58, 84], [58, 88], [59, 67], [59, 82], [60, 66], [60, 73], [60, 77], [60, 79], [60, 82], [60, 84], [61, 66], [61, 69], [61, 70], [61, 73], [62, 72], [62, 78], [62, 85], [62, 89], [63, 64], [63, 69], [63, 72], [63, 74], [63, 76], [63, 81], [63, 82], [63, 86], [64, 74], [64, 75], [64, 78], [64, 86], [64, 87], [64, 88], [65, 68], [65, 78], [65, 80], [66, 77], [66, 88], [67, 82], [68, 70], [68, 85], [70, 75], [71, 73], [71, 78], [72, 73], [73, 76], [73, 77], [73, 83], [73, 84], [73, 85], [73, 88], [74, 86], [75, 76], [75, 77], [75, 86], [76, 88], [77, 86], [77, 89], [78, 85], [78, 87], [79, 87], [81, 84], [83, 86], [83, 88], [84, 85]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s2/tests/run.py b/tasks/construct-mc-vertex-cover-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-vertex-cover-l5-s2/tests/test.sh b/tasks/construct-mc-vertex-cover-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-l5-s5/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-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-l5-s5/environment/instance.json b/tasks/construct-mc-vertex-cover-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..749ad0ae31502f50a13bfe7e4c06a2e2d6b3444e --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 5], [0, 9], [0, 17], [0, 30], [0, 35], [0, 43], [0, 45], [0, 47], [0, 50], [0, 66], [0, 67], [0, 68], [0, 73], [0, 83], [1, 8], [1, 13], [1, 23], [1, 41], [1, 50], [1, 59], [1, 60], [1, 61], [1, 75], [1, 83], [2, 6], [2, 10], [2, 25], [2, 63], [2, 67], [2, 75], [2, 76], [2, 77], [2, 81], [3, 11], [3, 20], [3, 21], [3, 22], [3, 28], [3, 41], [3, 43], [3, 49], [3, 51], [3, 55], [3, 73], [3, 75], [3, 84], [3, 86], [4, 16], [4, 21], [4, 22], [4, 23], [4, 36], [4, 43], [4, 50], [4, 56], [4, 59], [4, 61], [4, 65], [4, 68], [4, 69], [4, 72], [4, 75], [4, 76], [4, 84], [5, 9], [5, 21], [5, 25], [5, 38], [5, 44], [5, 59], [5, 70], [5, 75], [5, 78], [5, 89], [6, 8], [6, 23], [6, 30], [6, 32], [6, 48], [6, 63], [6, 66], [6, 69], [6, 70], [6, 72], [6, 75], [6, 86], [6, 89], [7, 15], [7, 24], [7, 33], [7, 35], [7, 46], [7, 49], [7, 57], [7, 62], [7, 66], [7, 72], [7, 73], [7, 78], [7, 84], [8, 12], [8, 24], [8, 31], [8, 32], [8, 48], [8, 52], [8, 54], [8, 60], [8, 63], [8, 67], [8, 82], [8, 83], [9, 18], [9, 24], [9, 26], [9, 36], [9, 43], [9, 45], [9, 49], [9, 50], [9, 54], [9, 61], [9, 67], [9, 70], [9, 80], [9, 89], [10, 22], [10, 26], [10, 27], [10, 34], [10, 46], [10, 50], [10, 52], [10, 54], [10, 74], [10, 84], [10, 87], [11, 12], [11, 19], [11, 37], [11, 39], [11, 50], [11, 55], [11, 80], [11, 82], [11, 89], [12, 13], [12, 17], [12, 32], [12, 36], [12, 37], [12, 38], [12, 52], [12, 60], [12, 64], [12, 69], [12, 70], [12, 76], [12, 81], [13, 15], [13, 24], [13, 33], [13, 34], [13, 38], [13, 41], [13, 48], [13, 49], [13, 59], [13, 72], [13, 83], [14, 15], [14, 18], [14, 26], [14, 39], [14, 41], [14, 43], [14, 57], [14, 60], [14, 65], [14, 66], [14, 68], [14, 72], [14, 77], [14, 88], [15, 20], [15, 23], [15, 57], [15, 59], [15, 61], [15, 63], [15, 74], [15, 82], [16, 18], [16, 20], [16, 22], [16, 23], [16, 28], [16, 30], [16, 32], [16, 35], [16, 53], [16, 60], [16, 83], [17, 23], [17, 38], [17, 45], [17, 50], [17, 58], [17, 83], [17, 89], [18, 24], [18, 27], [18, 28], [18, 45], [18, 47], [18, 69], [18, 74], [18, 78], [18, 83], [19, 23], [19, 28], [19, 34], [19, 36], [19, 41], [19, 44], [19, 47], [19, 71], [19, 83], [19, 89], [20, 22], [20, 31], [20, 34], [20, 42], [20, 44], [20, 50], [20, 57], [20, 59], [20, 62], [20, 66], [20, 67], [20, 70], [20, 77], [20, 78], [20, 83], [21, 24], [21, 30], [21, 33], [21, 46], [21, 66], [21, 74], [21, 81], [21, 82], [21, 85], [22, 30], [22, 31], [22, 45], [22, 46], [22, 55], [22, 58], [22, 59], [22, 61], [22, 68], [22, 70], [22, 74], [22, 88], [23, 34], [23, 42], [23, 61], [23, 65], [24, 53], [24, 61], [24, 62], [24, 67], [24, 80], [24, 89], [25, 35], [25, 36], [25, 42], [25, 51], [25, 54], [25, 59], [25, 72], [25, 79], [25, 82], [25, 89], [26, 41], [26, 44], [26, 49], [26, 57], [26, 58], [26, 83], [26, 89], [27, 41], [27, 47], [27, 52], [27, 53], [27, 61], [27, 62], [27, 69], [27, 75], [27, 77], [28, 34], [28, 36], [28, 52], [28, 56], [28, 61], [28, 63], [28, 77], [29, 43], [29, 49], [29, 70], [29, 78], [29, 88], [29, 89], [30, 36], [30, 48], [30, 61], [30, 69], [30, 72], [30, 73], [30, 88], [31, 33], [31, 38], [31, 47], [31, 55], [31, 61], [31, 63], [31, 69], [31, 75], [31, 83], [32, 33], [32, 41], [32, 43], [32, 56], [32, 61], [32, 64], [32, 66], [32, 72], [32, 75], [32, 79], [32, 87], [33, 63], [33, 67], [33, 81], [34, 36], [34, 37], [34, 42], [34, 48], [34, 49], [34, 50], [34, 67], [34, 70], [34, 78], [34, 79], [35, 58], [35, 74], [35, 82], [36, 37], [36, 39], [36, 42], [36, 51], [36, 75], [36, 76], [36, 83], [37, 43], [37, 48], [37, 51], [37, 58], [37, 59], [37, 67], [37, 72], [38, 45], [38, 51], [38, 52], [38, 54], [38, 60], [38, 61], [38, 65], [38, 74], [38, 78], [38, 84], [39, 41], [39, 46], [39, 51], [39, 57], [39, 60], [39, 65], [39, 73], [39, 79], [40, 45], [40, 52], [40, 57], [40, 74], [40, 78], [41, 44], [41, 46], [41, 51], [41, 54], [41, 61], [41, 62], [41, 65], [41, 68], [42, 69], [42, 80], [42, 82], [43, 61], [43, 67], [43, 69], [43, 70], [43, 78], [43, 82], [43, 83], [44, 48], [44, 50], [44, 54], [44, 60], [44, 81], [44, 85], [45, 70], [45, 73], [45, 77], [46, 51], [46, 56], [46, 66], [46, 71], [46, 82], [46, 86], [46, 87], [47, 48], [47, 49], [47, 56], [47, 67], [47, 70], [47, 74], [47, 78], [48, 52], [48, 59], [48, 62], [48, 67], [48, 69], [48, 70], [48, 74], [48, 82], [49, 75], [49, 76], [49, 79], [49, 84], [49, 86], [50, 55], [50, 68], [50, 78], [50, 85], [50, 87], [51, 53], [51, 66], [51, 80], [52, 57], [52, 61], [52, 64], [52, 68], [52, 71], [52, 74], [52, 86], [53, 74], [53, 77], [53, 79], [53, 81], [53, 84], [53, 85], [53, 88], [54, 61], [54, 62], [54, 86], [55, 86], [55, 87], [56, 66], [56, 73], [56, 75], [56, 80], [56, 84], [57, 59], [57, 72], [57, 76], [57, 88], [58, 59], [58, 62], [58, 64], [58, 77], [58, 85], [59, 62], [59, 65], [59, 85], [60, 71], [60, 83], [60, 89], [62, 72], [62, 79], [63, 67], [63, 68], [63, 78], [63, 82], [63, 85], [64, 70], [64, 76], [64, 77], [65, 77], [65, 83], [66, 73], [66, 81], [67, 69], [67, 73], [67, 79], [67, 85], [68, 69], [68, 77], [68, 87], [68, 88], [69, 78], [69, 83], [69, 84], [69, 87], [70, 73], [70, 84], [72, 77], [72, 80], [72, 81], [72, 83], [73, 75], [73, 76], [73, 77], [73, 89], [74, 81], [74, 88], [74, 89], [75, 84], [75, 85], [75, 86], [76, 86], [76, 89], [77, 83], [80, 81], [82, 87], [82, 89], [83, 86], [83, 87], [84, 86], [84, 88]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s5/solution/solve.sh b/tasks/construct-mc-vertex-cover-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a3343814dc24dac732aad98c090621cea69f3d1e --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-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": [0, 2, 3, 4, 6, 7, 8, 9, 10, 12, 13, 14, 16, 18, 19, 20, 21, 23, 25, 30, 31, 32, 34, 36, 37, 38, 39, 41, 43, 44, 45, 46, 47, 49, 50, 52, 53, 55, 56, 57, 58, 59, 60, 61, 62, 63, 66, 67, 68, 69, 70, 74, 75, 76, 77, 78, 80, 81, 82, 83, 86, 88, 89]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l5-s5/tests/check.py b/tasks/construct-mc-vertex-cover-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-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-l5-s5/tests/instance.json b/tasks/construct-mc-vertex-cover-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..749ad0ae31502f50a13bfe7e4c06a2e2d6b3444e --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 5], [0, 9], [0, 17], [0, 30], [0, 35], [0, 43], [0, 45], [0, 47], [0, 50], [0, 66], [0, 67], [0, 68], [0, 73], [0, 83], [1, 8], [1, 13], [1, 23], [1, 41], [1, 50], [1, 59], [1, 60], [1, 61], [1, 75], [1, 83], [2, 6], [2, 10], [2, 25], [2, 63], [2, 67], [2, 75], [2, 76], [2, 77], [2, 81], [3, 11], [3, 20], [3, 21], [3, 22], [3, 28], [3, 41], [3, 43], [3, 49], [3, 51], [3, 55], [3, 73], [3, 75], [3, 84], [3, 86], [4, 16], [4, 21], [4, 22], [4, 23], [4, 36], [4, 43], [4, 50], [4, 56], [4, 59], [4, 61], [4, 65], [4, 68], [4, 69], [4, 72], [4, 75], [4, 76], [4, 84], [5, 9], [5, 21], [5, 25], [5, 38], [5, 44], [5, 59], [5, 70], [5, 75], [5, 78], [5, 89], [6, 8], [6, 23], [6, 30], [6, 32], [6, 48], [6, 63], [6, 66], [6, 69], [6, 70], [6, 72], [6, 75], [6, 86], [6, 89], [7, 15], [7, 24], [7, 33], [7, 35], [7, 46], [7, 49], [7, 57], [7, 62], [7, 66], [7, 72], [7, 73], [7, 78], [7, 84], [8, 12], [8, 24], [8, 31], [8, 32], [8, 48], [8, 52], [8, 54], [8, 60], [8, 63], [8, 67], [8, 82], [8, 83], [9, 18], [9, 24], [9, 26], [9, 36], [9, 43], [9, 45], [9, 49], [9, 50], [9, 54], [9, 61], [9, 67], [9, 70], [9, 80], [9, 89], [10, 22], [10, 26], [10, 27], [10, 34], [10, 46], [10, 50], [10, 52], [10, 54], [10, 74], [10, 84], [10, 87], [11, 12], [11, 19], [11, 37], [11, 39], [11, 50], [11, 55], [11, 80], [11, 82], [11, 89], [12, 13], [12, 17], [12, 32], [12, 36], [12, 37], [12, 38], [12, 52], [12, 60], [12, 64], [12, 69], [12, 70], [12, 76], [12, 81], [13, 15], [13, 24], [13, 33], [13, 34], [13, 38], [13, 41], [13, 48], [13, 49], [13, 59], [13, 72], [13, 83], [14, 15], [14, 18], [14, 26], [14, 39], [14, 41], [14, 43], [14, 57], [14, 60], [14, 65], [14, 66], [14, 68], [14, 72], [14, 77], [14, 88], [15, 20], [15, 23], [15, 57], [15, 59], [15, 61], [15, 63], [15, 74], [15, 82], [16, 18], [16, 20], [16, 22], [16, 23], [16, 28], [16, 30], [16, 32], [16, 35], [16, 53], [16, 60], [16, 83], [17, 23], [17, 38], [17, 45], [17, 50], [17, 58], [17, 83], [17, 89], [18, 24], [18, 27], [18, 28], [18, 45], [18, 47], [18, 69], [18, 74], [18, 78], [18, 83], [19, 23], [19, 28], [19, 34], [19, 36], [19, 41], [19, 44], [19, 47], [19, 71], [19, 83], [19, 89], [20, 22], [20, 31], [20, 34], [20, 42], [20, 44], [20, 50], [20, 57], [20, 59], [20, 62], [20, 66], [20, 67], [20, 70], [20, 77], [20, 78], [20, 83], [21, 24], [21, 30], [21, 33], [21, 46], [21, 66], [21, 74], [21, 81], [21, 82], [21, 85], [22, 30], [22, 31], [22, 45], [22, 46], [22, 55], [22, 58], [22, 59], [22, 61], [22, 68], [22, 70], [22, 74], [22, 88], [23, 34], [23, 42], [23, 61], [23, 65], [24, 53], [24, 61], [24, 62], [24, 67], [24, 80], [24, 89], [25, 35], [25, 36], [25, 42], [25, 51], [25, 54], [25, 59], [25, 72], [25, 79], [25, 82], [25, 89], [26, 41], [26, 44], [26, 49], [26, 57], [26, 58], [26, 83], [26, 89], [27, 41], [27, 47], [27, 52], [27, 53], [27, 61], [27, 62], [27, 69], [27, 75], [27, 77], [28, 34], [28, 36], [28, 52], [28, 56], [28, 61], [28, 63], [28, 77], [29, 43], [29, 49], [29, 70], [29, 78], [29, 88], [29, 89], [30, 36], [30, 48], [30, 61], [30, 69], [30, 72], [30, 73], [30, 88], [31, 33], [31, 38], [31, 47], [31, 55], [31, 61], [31, 63], [31, 69], [31, 75], [31, 83], [32, 33], [32, 41], [32, 43], [32, 56], [32, 61], [32, 64], [32, 66], [32, 72], [32, 75], [32, 79], [32, 87], [33, 63], [33, 67], [33, 81], [34, 36], [34, 37], [34, 42], [34, 48], [34, 49], [34, 50], [34, 67], [34, 70], [34, 78], [34, 79], [35, 58], [35, 74], [35, 82], [36, 37], [36, 39], [36, 42], [36, 51], [36, 75], [36, 76], [36, 83], [37, 43], [37, 48], [37, 51], [37, 58], [37, 59], [37, 67], [37, 72], [38, 45], [38, 51], [38, 52], [38, 54], [38, 60], [38, 61], [38, 65], [38, 74], [38, 78], [38, 84], [39, 41], [39, 46], [39, 51], [39, 57], [39, 60], [39, 65], [39, 73], [39, 79], [40, 45], [40, 52], [40, 57], [40, 74], [40, 78], [41, 44], [41, 46], [41, 51], [41, 54], [41, 61], [41, 62], [41, 65], [41, 68], [42, 69], [42, 80], [42, 82], [43, 61], [43, 67], [43, 69], [43, 70], [43, 78], [43, 82], [43, 83], [44, 48], [44, 50], [44, 54], [44, 60], [44, 81], [44, 85], [45, 70], [45, 73], [45, 77], [46, 51], [46, 56], [46, 66], [46, 71], [46, 82], [46, 86], [46, 87], [47, 48], [47, 49], [47, 56], [47, 67], [47, 70], [47, 74], [47, 78], [48, 52], [48, 59], [48, 62], [48, 67], [48, 69], [48, 70], [48, 74], [48, 82], [49, 75], [49, 76], [49, 79], [49, 84], [49, 86], [50, 55], [50, 68], [50, 78], [50, 85], [50, 87], [51, 53], [51, 66], [51, 80], [52, 57], [52, 61], [52, 64], [52, 68], [52, 71], [52, 74], [52, 86], [53, 74], [53, 77], [53, 79], [53, 81], [53, 84], [53, 85], [53, 88], [54, 61], [54, 62], [54, 86], [55, 86], [55, 87], [56, 66], [56, 73], [56, 75], [56, 80], [56, 84], [57, 59], [57, 72], [57, 76], [57, 88], [58, 59], [58, 62], [58, 64], [58, 77], [58, 85], [59, 62], [59, 65], [59, 85], [60, 71], [60, 83], [60, 89], [62, 72], [62, 79], [63, 67], [63, 68], [63, 78], [63, 82], [63, 85], [64, 70], [64, 76], [64, 77], [65, 77], [65, 83], [66, 73], [66, 81], [67, 69], [67, 73], [67, 79], [67, 85], [68, 69], [68, 77], [68, 87], [68, 88], [69, 78], [69, 83], [69, 84], [69, 87], [70, 73], [70, 84], [72, 77], [72, 80], [72, 81], [72, 83], [73, 75], [73, 76], [73, 77], [73, 89], [74, 81], [74, 88], [74, 89], [75, 84], [75, 85], [75, 86], [76, 86], [76, 89], [77, 83], [80, 81], [82, 87], [82, 89], [83, 86], [83, 87], [84, 86], [84, 88]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s5/tests/run.py b/tasks/construct-mc-vertex-cover-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-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-l5-s5/tests/test.sh b/tasks/construct-mc-vertex-cover-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-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-nppc-3col-l4-s2/solution/solve.sh b/tasks/construct-nppc-3col-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..aff5669df97a332b70555113fcc4bf4c9f79b61f --- /dev/null +++ b/tasks/construct-nppc-3col-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' +{"coloring": [0, 2, 2, 0, 0, 1, 1, 0, 2, 2, 0, 1, 0, 1, 0, 2, 0, 2, 1, 1, 2, 2, 0, 2, 1, 1, 1, 0, 2, 1]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l4-s2/tests/check.py b/tasks/construct-nppc-3col-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l4-s2/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-l4-s2/tests/instance.json b/tasks/construct-nppc-3col-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9eed294c51329e09bce36b35579ec1f749d8066b --- /dev/null +++ b/tasks/construct-nppc-3col-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "edges": [[0, 5], [0, 8], [0, 9], [0, 11], [0, 18], [0, 20], [0, 21], [0, 24], [0, 25], [0, 26], [1, 3], [1, 10], [1, 11], [1, 12], [1, 14], [1, 16], [1, 27], [2, 4], [2, 12], [2, 18], [2, 27], [3, 5], [3, 13], [3, 18], [3, 20], [3, 21], [3, 28], [4, 8], [4, 11], [4, 17], [4, 18], [4, 25], [5, 9], [5, 12], [5, 16], [5, 20], [5, 28], [6, 8], [6, 12], [6, 16], [6, 21], [6, 22], [7, 15], [7, 19], [7, 23], [7, 28], [8, 10], [8, 19], [8, 26], [9, 19], [9, 29], [10, 15], [10, 20], [10, 25], [11, 17], [11, 23], [12, 19], [12, 25], [12, 26], [12, 29], [13, 14], [14, 28], [15, 24], [15, 26], [15, 29], [16, 17], [16, 21], [16, 23], [17, 19], [17, 26], [17, 29], [18, 23], [18, 28], [21, 24], [21, 26], [22, 25], [23, 26], [24, 27], [24, 28], [26, 28]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l4-s2/tests/run.py b/tasks/construct-nppc-3col-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l4-s2/tests/test.sh b/tasks/construct-nppc-3col-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-bandwidth-l3-s7/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l3-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-nppc-bandwidth-l3-s7/environment/instance.json b/tasks/construct-nppc-bandwidth-l3-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3ecd2c4bc23ba512e575c7b59b55dbedb42c831c --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s7/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 4], [1, 2], [1, 7], [2, 3], [2, 7], [3, 7], [4, 5], [5, 6]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s7/solution/solve.sh b/tasks/construct-nppc-bandwidth-l3-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0505d236a3f135618d3cb8397b853e0fc4735e63 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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' +{"layout": [7, 3, 2, 0, 6, 4, 5, 1]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l3-s7/tests/check.py b/tasks/construct-nppc-bandwidth-l3-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s7/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-s7/tests/instance.json b/tasks/construct-nppc-bandwidth-l3-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3ecd2c4bc23ba512e575c7b59b55dbedb42c831c --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s7/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 4], [1, 2], [1, 7], [2, 3], [2, 7], [3, 7], [4, 5], [5, 6]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s7/tests/run.py b/tasks/construct-nppc-bandwidth-l3-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-nppc-bandwidth-l3-s7/tests/test.sh b/tasks/construct-nppc-bandwidth-l3-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-nppc-bandwidth-l3-s9/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l3-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-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-bandwidth-l3-s9/environment/instance.json b/tasks/construct-nppc-bandwidth-l3-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7fc817a320be872241f96a03e9b11b9ea2686290 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s9/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 1], [0, 5], [1, 3], [2, 4], [3, 6], [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-s9/solution/solve.sh b/tasks/construct-nppc-bandwidth-l3-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5f181cc34e32d6289239533e3ea6ca58fa84a4c2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-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' +{"layout": [5, 7, 0, 6, 1, 3, 4, 2]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l3-s9/tests/check.py b/tasks/construct-nppc-bandwidth-l3-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s9/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-s9/tests/instance.json b/tasks/construct-nppc-bandwidth-l3-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7fc817a320be872241f96a03e9b11b9ea2686290 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s9/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 1], [0, 5], [1, 3], [2, 4], [3, 6], [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-s9/tests/run.py b/tasks/construct-nppc-bandwidth-l3-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-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-bandwidth-l3-s9/tests/test.sh b/tasks/construct-nppc-bandwidth-l3-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-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-clique-l2-s0/environment/Dockerfile b/tasks/construct-nppc-clique-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-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-nppc-clique-l2-s0/environment/instance.json b/tasks/construct-nppc-clique-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b16b1c2ff1fca103d7e6d0d32b446e4380f0cf82 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 13], [1, 4], [1, 6], [1, 7], [2, 3], [2, 5], [2, 6], [2, 9], [2, 11], [2, 12], [3, 4], [3, 5], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [4, 5], [4, 6], [4, 8], [4, 9], [4, 12], [4, 13], [5, 6], [5, 9], [5, 10], [5, 11], [5, 13], [6, 8], [6, 9], [6, 10], [6, 13], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [9, 10], [9, 11], [9, 12], [10, 11], [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-s0/solution/solve.sh b/tasks/construct-nppc-clique-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7d297ff6cdf98560b2b701c83bdffea4eccf32c5 --- /dev/null +++ b/tasks/construct-nppc-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": [3, 7, 8, 9, 10, 11, 12]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l2-s0/tests/check.py b/tasks/construct-nppc-clique-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s0/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-s0/tests/instance.json b/tasks/construct-nppc-clique-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b16b1c2ff1fca103d7e6d0d32b446e4380f0cf82 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 13], [1, 4], [1, 6], [1, 7], [2, 3], [2, 5], [2, 6], [2, 9], [2, 11], [2, 12], [3, 4], [3, 5], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [4, 5], [4, 6], [4, 8], [4, 9], [4, 12], [4, 13], [5, 6], [5, 9], [5, 10], [5, 11], [5, 13], [6, 8], [6, 9], [6, 10], [6, 13], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [9, 10], [9, 11], [9, 12], [10, 11], [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-s0/tests/run.py b/tasks/construct-nppc-clique-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-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-nppc-clique-l2-s0/tests/test.sh b/tasks/construct-nppc-clique-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-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-nppc-clique-l2-s7/environment/Dockerfile b/tasks/construct-nppc-clique-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-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-nppc-clique-l2-s7/environment/instance.json b/tasks/construct-nppc-clique-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..89ff92f688574c788720b0013b6ce9e0e097ce2f --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 7], [0, 8], [0, 10], [1, 3], [1, 12], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 13], [3, 6], [3, 9], [3, 11], [3, 13], [4, 5], [4, 6], [4, 7], [4, 11], [5, 8], [5, 10], [5, 11], [5, 12], [5, 13], [6, 7], [6, 8], [6, 9], [6, 10], [6, 12], [6, 13], [7, 8], [7, 9], [7, 10], [7, 13], [8, 9], [8, 10], [8, 13], [9, 10], [9, 13], [10, 12], [10, 13], [11, 13], [12, 13]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s7/solution/solve.sh b/tasks/construct-nppc-clique-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e66845f907ab3a32ed6d4329f9e294add0356a5a --- /dev/null +++ b/tasks/construct-nppc-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": [2, 6, 7, 8, 9, 10, 13]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l2-s7/tests/check.py b/tasks/construct-nppc-clique-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-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-l2-s7/tests/instance.json b/tasks/construct-nppc-clique-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..89ff92f688574c788720b0013b6ce9e0e097ce2f --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 7], [0, 8], [0, 10], [1, 3], [1, 12], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 13], [3, 6], [3, 9], [3, 11], [3, 13], [4, 5], [4, 6], [4, 7], [4, 11], [5, 8], [5, 10], [5, 11], [5, 12], [5, 13], [6, 7], [6, 8], [6, 9], [6, 10], [6, 12], [6, 13], [7, 8], [7, 9], [7, 10], [7, 13], [8, 9], [8, 10], [8, 13], [9, 10], [9, 13], [10, 12], [10, 13], [11, 13], [12, 13]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s7/tests/run.py b/tasks/construct-nppc-clique-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-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-nppc-clique-l2-s7/tests/test.sh b/tasks/construct-nppc-clique-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-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-nppc-clique-l6-s1/environment/Dockerfile b/tasks/construct-nppc-clique-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-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-clique-l6-s1/solution/solve.sh b/tasks/construct-nppc-clique-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..98731f39d9278575d99a9e6d3b874d0ec3946958 --- /dev/null +++ b/tasks/construct-nppc-clique-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' +{"clique": [2, 10, 13, 20, 26, 27, 29, 39, 43, 46, 48, 50, 51, 56, 59, 79, 80, 84, 91, 98]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l6-s1/tests/check.py b/tasks/construct-nppc-clique-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-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-l6-s1/tests/instance.json b/tasks/construct-nppc-clique-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b5f4f0de4b57cc9bca00330661bf2cbae5d63981 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 1], [0, 2], [0, 6], [0, 17], [0, 18], [0, 20], [0, 24], [0, 25], [0, 27], [0, 29], [0, 30], [0, 32], [0, 35], [0, 37], [0, 41], [0, 42], [0, 43], [0, 44], [0, 46], [0, 48], [0, 49], [0, 53], [0, 54], [0, 55], [0, 56], [0, 57], [0, 59], [0, 61], [0, 65], [0, 68], [0, 70], [0, 71], [0, 75], [0, 76], [0, 80], [0, 81], [0, 83], [0, 84], [0, 86], [0, 87], [0, 88], [0, 90], [0, 91], [0, 92], [0, 93], [0, 94], [0, 95], [0, 97], [0, 99], [1, 2], [1, 7], [1, 8], [1, 9], [1, 11], [1, 19], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 30], [1, 31], [1, 33], [1, 35], [1, 36], [1, 38], [1, 39], [1, 40], [1, 41], [1, 42], [1, 44], [1, 45], [1, 46], [1, 48], [1, 49], [1, 51], [1, 52], [1, 56], [1, 58], [1, 59], [1, 61], [1, 62], [1, 63], [1, 66], [1, 68], [1, 69], [1, 70], [1, 72], [1, 73], [1, 78], [1, 79], [1, 80], [1, 82], [1, 84], [1, 88], [1, 89], [1, 91], [1, 94], [1, 95], [1, 96], [1, 97], [1, 98], [2, 5], [2, 7], [2, 8], [2, 10], [2, 11], [2, 13], [2, 16], [2, 20], [2, 22], [2, 23], [2, 24], [2, 26], [2, 27], [2, 29], [2, 32], [2, 36], [2, 37], [2, 38], [2, 39], [2, 40], [2, 42], [2, 43], [2, 44], [2, 46], [2, 47], [2, 48], [2, 49], [2, 50], [2, 51], [2, 53], [2, 54], [2, 56], [2, 58], [2, 59], [2, 62], [2, 63], [2, 65], [2, 66], [2, 68], [2, 69], [2, 75], [2, 78], [2, 79], [2, 80], [2, 83], [2, 84], [2, 87], [2, 88], [2, 89], [2, 91], [2, 92], [2, 94], [2, 96], [2, 97], [2, 98], [3, 4], [3, 5], [3, 7], [3, 10], [3, 13], [3, 15], [3, 16], [3, 20], [3, 21], [3, 22], [3, 23], [3, 26], [3, 31], [3, 32], [3, 33], [3, 37], [3, 42], [3, 43], [3, 48], [3, 49], [3, 51], [3, 53], [3, 54], [3, 63], [3, 69], [3, 70], [3, 73], [3, 75], [3, 76], [3, 80], [3, 82], [3, 83], [3, 84], [3, 85], [3, 86], [3, 88], [3, 89], [3, 90], [3, 91], [3, 93], [3, 95], [3, 96], [4, 7], [4, 9], [4, 12], [4, 13], [4, 14], [4, 16], [4, 17], [4, 20], [4, 27], [4, 28], [4, 29], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 40], [4, 42], [4, 43], [4, 45], [4, 50], [4, 52], [4, 53], [4, 55], [4, 59], [4, 60], [4, 61], [4, 63], [4, 64], [4, 65], [4, 66], [4, 67], [4, 68], [4, 70], [4, 71], [4, 72], [4, 74], [4, 76], [4, 77], [4, 78], [4, 79], [4, 80], [4, 84], [4, 85], [4, 86], [4, 88], [4, 91], [4, 92], [4, 93], [4, 94], [4, 95], [4, 96], [4, 97], [4, 99], [5, 6], [5, 7], [5, 8], [5, 10], [5, 11], [5, 12], [5, 16], [5, 17], [5, 18], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 27], [5, 28], [5, 29], [5, 31], [5, 32], [5, 33], [5, 37], [5, 40], [5, 43], [5, 46], [5, 49], [5, 53], [5, 55], [5, 56], [5, 59], [5, 60], [5, 61], [5, 62], [5, 66], [5, 67], [5, 69], [5, 70], [5, 71], [5, 74], [5, 75], [5, 76], [5, 78], [5, 81], [5, 85], [5, 86], [5, 87], [5, 89], [5, 92], [5, 95], [5, 96], [5, 97], [5, 99], [6, 7], [6, 9], [6, 12], [6, 14], [6, 17], [6, 19], [6, 20], [6, 22], [6, 23], [6, 27], [6, 30], [6, 33], [6, 37], [6, 38], [6, 40], [6, 41], [6, 42], [6, 44], [6, 46], [6, 48], [6, 49], [6, 54], [6, 55], [6, 56], [6, 58], [6, 59], [6, 60], [6, 61], [6, 62], [6, 63], [6, 65], [6, 66], [6, 68], [6, 69], [6, 70], [6, 71], [6, 74], [6, 75], [6, 76], [6, 83], [6, 98], [7, 9], [7, 10], [7, 12], [7, 15], [7, 17], [7, 18], [7, 20], [7, 21], [7, 22], [7, 24], [7, 25], [7, 26], [7, 29], [7, 31], [7, 40], [7, 42], [7, 44], [7, 45], [7, 46], [7, 48], [7, 52], [7, 53], [7, 56], [7, 59], [7, 60], [7, 64], [7, 65], [7, 67], [7, 68], [7, 72], [7, 73], [7, 74], [7, 75], [7, 77], [7, 78], [7, 83], [7, 86], [7, 87], [7, 88], [7, 92], [7, 93], [7, 94], [7, 95], [7, 96], [7, 97], [7, 99], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 18], [8, 19], [8, 21], [8, 23], [8, 25], [8, 32], [8, 33], [8, 35], [8, 36], [8, 37], [8, 38], [8, 41], [8, 43], [8, 45], [8, 47], [8, 49], [8, 51], [8, 52], [8, 54], [8, 55], [8, 56], [8, 57], [8, 58], [8, 61], [8, 63], [8, 64], [8, 73], [8, 74], [8, 79], [8, 81], [8, 83], [8, 84], [8, 85], [8, 86], [8, 87], [8, 88], [8, 89], [8, 90], [8, 94], [8, 95], [8, 96], [8, 99], [9, 12], [9, 13], [9, 16], [9, 19], [9, 21], [9, 22], [9, 24], [9, 25], [9, 27], [9, 29], [9, 30], [9, 32], [9, 33], [9, 34], [9, 35], [9, 36], [9, 40], [9, 41], [9, 43], [9, 47], [9, 48], [9, 49], [9, 51], [9, 54], [9, 55], [9, 56], [9, 57], [9, 59], [9, 62], [9, 64], [9, 65], [9, 67], [9, 69], [9, 72], [9, 73], [9, 75], [9, 78], [9, 79], [9, 81], [9, 82], [9, 86], [9, 88], [9, 89], [9, 92], [9, 93], [9, 94], [9, 95], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 20], [10, 24], [10, 26], [10, 27], [10, 28], [10, 29], [10, 32], [10, 33], [10, 37], [10, 38], [10, 39], [10, 42], [10, 43], [10, 44], [10, 46], [10, 47], [10, 48], [10, 50], [10, 51], [10, 54], [10, 55], [10, 56], [10, 57], [10, 59], [10, 60], [10, 61], [10, 63], [10, 65], [10, 68], [10, 71], [10, 76], [10, 77], [10, 79], [10, 80], [10, 81], [10, 84], [10, 88], [10, 91], [10, 92], [10, 93], [10, 95], [10, 98], [11, 13], [11, 18], [11, 21], [11, 22], [11, 24], [11, 25], [11, 32], [11, 34], [11, 37], [11, 39], [11, 40], [11, 41], [11, 45], [11, 46], [11, 47], [11, 49], [11, 52], [11, 53], [11, 54], [11, 55], [11, 56], [11, 57], [11, 58], [11, 59], [11, 60], [11, 63], [11, 65], [11, 66], [11, 67], [11, 68], [11, 69], [11, 70], [11, 73], [11, 75], [11, 77], [11, 79], [11, 80], [11, 81], [11, 84], [11, 86], [11, 87], [11, 91], [11, 92], [11, 93], [11, 95], [11, 97], [11, 99], [12, 13], [12, 16], [12, 19], [12, 21], [12, 25], [12, 26], [12, 28], [12, 31], [12, 32], [12, 37], [12, 38], [12, 40], [12, 41], [12, 42], [12, 43], [12, 45], [12, 46], [12, 47], [12, 49], [12, 50], [12, 55], [12, 56], [12, 57], [12, 60], [12, 62], [12, 63], [12, 68], [12, 69], [12, 72], [12, 77], [12, 78], [12, 79], [12, 80], [12, 83], [12, 84], [12, 85], [12, 88], [12, 90], [12, 94], [12, 95], [12, 96], [12, 97], [12, 99], [13, 15], [13, 17], [13, 18], [13, 20], [13, 21], [13, 23], [13, 26], [13, 27], [13, 28], [13, 29], [13, 32], [13, 35], [13, 39], [13, 40], [13, 43], [13, 45], [13, 46], [13, 48], [13, 50], [13, 51], [13, 54], [13, 55], [13, 56], [13, 58], [13, 59], [13, 60], [13, 63], [13, 64], [13, 65], [13, 66], [13, 67], [13, 68], [13, 69], [13, 70], [13, 71], [13, 72], [13, 75], [13, 76], [13, 79], [13, 80], [13, 81], [13, 83], [13, 84], [13, 86], [13, 87], [13, 89], [13, 90], [13, 91], [13, 93], [13, 94], [13, 95], [13, 96], [13, 97], [13, 98], [13, 99], [14, 16], [14, 17], [14, 18], [14, 21], [14, 23], [14, 25], [14, 31], [14, 33], [14, 34], [14, 37], [14, 40], [14, 42], [14, 44], [14, 47], [14, 49], [14, 50], [14, 52], [14, 54], [14, 55], [14, 56], [14, 57], [14, 62], [14, 67], [14, 69], [14, 71], [14, 73], [14, 74], [14, 75], [14, 76], [14, 77], [14, 78], [14, 82], [14, 85], [14, 86], [14, 87], [14, 89], [14, 97], [14, 98], [15, 16], [15, 17], [15, 18], [15, 21], [15, 23], [15, 24], [15, 25], [15, 26], [15, 27], [15, 31], [15, 33], [15, 37], [15, 39], [15, 40], [15, 41], [15, 44], [15, 46], [15, 47], [15, 54], [15, 58], [15, 62], [15, 63], [15, 66], [15, 68], [15, 71], [15, 73], [15, 74], [15, 75], [15, 76], [15, 77], [15, 78], [15, 79], [15, 80], [15, 82], [15, 86], [15, 87], [15, 89], [15, 92], [15, 93], [15, 98], [15, 99], [16, 17], [16, 18], [16, 19], [16, 24], [16, 26], [16, 27], [16, 28], [16, 29], [16, 33], [16, 37], [16, 42], [16, 43], [16, 45], [16, 47], [16, 50], [16, 52], [16, 53], [16, 58], [16, 59], [16, 61], [16, 63], [16, 66], [16, 74], [16, 75], [16, 77], [16, 79], [16, 81], [16, 85], [16, 86], [16, 87], [16, 88], [16, 90], [16, 92], [16, 93], [16, 94], [16, 98], [16, 99], [17, 23], [17, 25], [17, 27], [17, 29], [17, 31], [17, 33], [17, 35], [17, 36], [17, 38], [17, 42], [17, 44], [17, 46], [17, 47], [17, 49], [17, 52], [17, 55], [17, 57], [17, 58], [17, 61], [17, 62], [17, 63], [17, 64], [17, 69], [17, 70], [17, 72], [17, 77], [17, 78], [17, 80], [17, 82], [17, 83], [17, 86], [17, 87], [17, 88], [17, 89], [17, 91], [17, 92], [17, 93], [17, 96], [17, 98], [18, 19], [18, 20], [18, 22], [18, 24], [18, 27], [18, 28], [18, 30], [18, 31], [18, 33], [18, 35], [18, 36], [18, 37], [18, 38], [18, 39], [18, 40], [18, 42], [18, 43], [18, 47], [18, 49], [18, 51], [18, 52], [18, 53], [18, 60], [18, 62], [18, 66], [18, 67], [18, 69], [18, 71], [18, 72], [18, 73], [18, 75], [18, 76], [18, 77], [18, 78], [18, 80], [18, 83], [18, 85], [18, 86], [18, 88], [18, 89], [18, 91], [18, 92], [18, 93], [18, 94], [18, 95], [18, 96], [18, 97], [19, 20], [19, 22], [19, 23], [19, 27], [19, 31], [19, 34], [19, 35], [19, 36], [19, 37], [19, 38], [19, 39], [19, 41], [19, 44], [19, 48], [19, 50], [19, 52], [19, 53], [19, 57], [19, 59], [19, 63], [19, 65], [19, 66], [19, 67], [19, 68], [19, 70], [19, 71], [19, 72], [19, 73], [19, 75], [19, 77], [19, 78], [19, 79], [19, 82], [19, 83], [19, 84], [19, 85], [19, 86], [19, 88], [19, 89], [19, 92], [19, 93], [19, 96], [19, 98], [19, 99], [20, 21], [20, 23], [20, 24], [20, 26], [20, 27], [20, 29], [20, 31], [20, 33], [20, 35], [20, 39], [20, 43], [20, 44], [20, 46], [20, 48], [20, 49], [20, 50], [20, 51], [20, 54], [20, 55], [20, 56], [20, 57], [20, 58], [20, 59], [20, 60], [20, 63], [20, 66], [20, 67], [20, 68], [20, 69], [20, 71], [20, 72], [20, 74], [20, 77], [20, 78], [20, 79], [20, 80], [20, 81], [20, 84], [20, 89], [20, 90], [20, 91], [20, 93], [20, 94], [20, 95], [20, 96], [20, 97], [20, 98], [21, 23], [21, 27], [21, 28], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [21, 40], [21, 42], [21, 43], [21, 44], [21, 46], [21, 50], [21, 51], [21, 53], [21, 55], [21, 56], [21, 57], [21, 60], [21, 64], [21, 66], [21, 67], [21, 68], [21, 70], [21, 71], [21, 72], [21, 73], [21, 76], [21, 77], [21, 78], [21, 79], [21, 80], [21, 82], [21, 84], [21, 90], [21, 91], [21, 92], [21, 93], [21, 95], [21, 96], [21, 99], [22, 25], [22, 26], [22, 27], [22, 28], [22, 31], [22, 32], [22, 33], [22, 34], [22, 42], [22, 44], [22, 47], [22, 52], [22, 53], [22, 54], [22, 56], [22, 59], [22, 62], [22, 63], [22, 67], [22, 69], [22, 72], [22, 73], [22, 76], [22, 77], [22, 78], [22, 79], [22, 80], [22, 81], [22, 82], [22, 83], [22, 90], [22, 91], [22, 92], [22, 95], [22, 97], [22, 98], [22, 99], [23, 24], [23, 26], [23, 28], [23, 29], [23, 30], [23, 31], [23, 35], [23, 36], [23, 37], [23, 38], [23, 39], [23, 40], [23, 41], [23, 43], [23, 44], [23, 47], [23, 48], [23, 52], [23, 55], [23, 56], [23, 58], [23, 61], [23, 62], [23, 66], [23, 67], [23, 68], [23, 69], [23, 71], [23, 73], [23, 78], [23, 80], [23, 89], [23, 90], [23, 94], [23, 95], [23, 96], [23, 97], [23, 99], [24, 26], [24, 28], [24, 29], [24, 30], [24, 33], [24, 34], [24, 35], [24, 39], [24, 41], [24, 42], [24, 44], [24, 45], [24, 47], [24, 48], [24, 49], [24, 50], [24, 53], [24, 54], [24, 56], [24, 60], [24, 64], [24, 66], [24, 67], [24, 71], [24, 72], [24, 74], [24, 75], [24, 76], [24, 78], [24, 79], [24, 80], [24, 81], [24, 82], [24, 86], [24, 87], [24, 90], [24, 91], [24, 93], [24, 98], [25, 28], [25, 29], [25, 30], [25, 32], [25, 33], [25, 34], [25, 39], [25, 40], [25, 41], [25, 42], [25, 43], [25, 46], [25, 49], [25, 51], [25, 52], [25, 55], [25, 56], [25, 60], [25, 62], [25, 64], [25, 68], [25, 72], [25, 74], [25, 75], [25, 77], [25, 78], [25, 82], [25, 83], [25, 84], [25, 85], [25, 88], [25, 90], [25, 97], [26, 27], [26, 29], [26, 30], [26, 34], [26, 35], [26, 37], [26, 39], [26, 41], [26, 42], [26, 43], [26, 44], [26, 46], [26, 47], [26, 48], [26, 50], [26, 51], [26, 55], [26, 56], [26, 57], [26, 58], [26, 59], [26, 60], [26, 64], [26, 65], [26, 67], [26, 70], [26, 73], [26, 74], [26, 75], [26, 77], [26, 78], [26, 79], [26, 80], [26, 82], [26, 84], [26, 86], [26, 91], [26, 92], [26, 96], [26, 98], [27, 28], [27, 29], [27, 32], [27, 33], [27, 35], [27, 39], [27, 40], [27, 42], [27, 43], [27, 44], [27, 46], [27, 48], [27, 49], [27, 50], [27, 51], [27, 53], [27, 54], [27, 56], [27, 58], [27, 59], [27, 60], [27, 64], [27, 65], [27, 66], [27, 68], [27, 69], [27, 70], [27, 71], [27, 74], [27, 79], [27, 80], [27, 81], [27, 82], [27, 84], [27, 87], [27, 89], [27, 91], [27, 96], [27, 98], [27, 99], [28, 29], [28, 30], [28, 31], [28, 35], [28, 36], [28, 40], [28, 41], [28, 44], [28, 46], [28, 54], [28, 56], [28, 57], [28, 60], [28, 62], [28, 64], [28, 66], [28, 68], [28, 69], [28, 70], [28, 72], [28, 73], [28, 74], [28, 76], [28, 78], [28, 79], [28, 82], [28, 83], [28, 84], [28, 87], [28, 91], [28, 93], [28, 95], [28, 99], [29, 30], [29, 31], [29, 33], [29, 37], [29, 38], [29, 39], [29, 40], [29, 41], [29, 43], [29, 46], [29, 48], [29, 49], [29, 50], [29, 51], [29, 53], [29, 56], [29, 58], [29, 59], [29, 60], [29, 61], [29, 66], [29, 67], [29, 70], [29, 71], [29, 72], [29, 73], [29, 75], [29, 79], [29, 80], [29, 81], [29, 82], [29, 84], [29, 85], [29, 87], [29, 88], [29, 90], [29, 91], [29, 92], [29, 93], [29, 94], [29, 97], [29, 98], [30, 31], [30, 33], [30, 34], [30, 36], [30, 37], [30, 39], [30, 40], [30, 41], [30, 43], [30, 46], [30, 53], [30, 54], [30, 56], [30, 57], [30, 60], [30, 62], [30, 63], [30, 66], [30, 68], [30, 70], [30, 71], [30, 72], [30, 74], [30, 75], [30, 81], [30, 82], [30, 85], [30, 88], [30, 92], [30, 93], [30, 94], [30, 98], [30, 99], [31, 32], [31, 35], [31, 36], [31, 37], [31, 39], [31, 40], [31, 41], [31, 42], [31, 45], [31, 47], [31, 49], [31, 50], [31, 52], [31, 53], [31, 54], [31, 56], [31, 57], [31, 62], [31, 64], [31, 65], [31, 66], [31, 68], [31, 69], [31, 72], [31, 73], [31, 75], [31, 76], [31, 77], [31, 81], [31, 82], [31, 85], [31, 87], [31, 94], [31, 96], [31, 98], [32, 33], [32, 35], [32, 37], [32, 38], [32, 41], [32, 42], [32, 43], [32, 44], [32, 47], [32, 55], [32, 56], [32, 58], [32, 66], [32, 71], [32, 72], [32, 73], [32, 77], [32, 79], [32, 81], [32, 82], [32, 83], [32, 88], [32, 90], [32, 91], [32, 92], [32, 96], [32, 98], [33, 34], [33, 35], [33, 36], [33, 40], [33, 42], [33, 45], [33, 46], [33, 49], [33, 51], [33, 52], [33, 53], [33, 54], [33, 55], [33, 56], [33, 58], [33, 59], [33, 60], [33, 61], [33, 65], [33, 66], [33, 70], [33, 72], [33, 73], [33, 75], [33, 81], [33, 82], [33, 85], [33, 86], [33, 88], [33, 89], [33, 92], [33, 93], [33, 95], [33, 96], [33, 99], [34, 35], [34, 41], [34, 42], [34, 45], [34, 48], [34, 49], [34, 50], [34, 53], [34, 54], [34, 56], [34, 64], [34, 65], [34, 66], [34, 68], [34, 69], [34, 71], [34, 72], [34, 74], [34, 75], [34, 77], [34, 84], [34, 92], [34, 93], [34, 96], [34, 98], [35, 38], [35, 40], [35, 41], [35, 45], [35, 46], [35, 47], [35, 48], [35, 49], [35, 51], [35, 53], [35, 54], [35, 58], [35, 59], [35, 60], [35, 63], [35, 64], [35, 67], [35, 68], [35, 69], [35, 71], [35, 72], [35, 74], [35, 75], [35, 80], [35, 83], [35, 85], [35, 88], [35, 89], [35, 91], [35, 92], [35, 93], [35, 95], [35, 97], [35, 99], [36, 37], [36, 38], [36, 40], [36, 41], [36, 48], [36, 52], [36, 54], [36, 55], [36, 57], [36, 58], [36, 59], [36, 60], [36, 61], [36, 62], [36, 64], [36, 65], [36, 70], [36, 72], [36, 75], [36, 76], [36, 77], [36, 78], [36, 79], [36, 83], [36, 84], [36, 85], [36, 86], [36, 87], [36, 88], [36, 91], [36, 93], [36, 96], [37, 39], [37, 40], [37, 43], [37, 44], [37, 45], [37, 49], [37, 51], [37, 52], [37, 54], [37, 56], [37, 57], [37, 58], [37, 59], [37, 64], [37, 65], [37, 66], [37, 68], [37, 71], [37, 76], [37, 78], [37, 79], [37, 82], [37, 83], [37, 84], [37, 86], [37, 94], [37, 95], [37, 97], [37, 98], [38, 39], [38, 40], [38, 42], [38, 43], [38, 44], [38, 45], [38, 47], [38, 53], [38, 57], [38, 62], [38, 64], [38, 65], [38, 67], [38, 68], [38, 69], [38, 70], [38, 71], [38, 72], [38, 73], [38, 74], [38, 76], [38, 78], [38, 79], [38, 81], [38, 82], [38, 83], [38, 85], [38, 86], [38, 89], [38, 90], [38, 91], [38, 92], [38, 93], [38, 98], [39, 43], [39, 45], [39, 46], [39, 48], [39, 49], [39, 50], [39, 51], [39, 52], [39, 54], [39, 55], [39, 56], [39, 58], [39, 59], [39, 60], [39, 61], [39, 64], [39, 65], [39, 66], [39, 67], [39, 71], [39, 73], [39, 75], [39, 76], [39, 79], [39, 80], [39, 84], [39, 85], [39, 86], [39, 90], [39, 91], [39, 92], [39, 93], [39, 94], [39, 95], [39, 96], [39, 97], [39, 98], [39, 99], [40, 41], [40, 42], [40, 43], [40, 44], [40, 45], [40, 48], [40, 51], [40, 53], [40, 54], [40, 55], [40, 56], [40, 57], [40, 58], [40, 59], [40, 60], [40, 61], [40, 62], [40, 64], [40, 65], [40, 67], [40, 69], [40, 70], [40, 71], [40, 74], [40, 75], [40, 77], [40, 78], [40, 79], [40, 81], [40, 82], [40, 84], [40, 85], [40, 87], [40, 90], [40, 92], [40, 97], [40, 98], [40, 99], [41, 42], [41, 43], [41, 44], [41, 50], [41, 54], [41, 60], [41, 62], [41, 65], [41, 68], [41, 69], [41, 71], [41, 78], [41, 79], [41, 83], [41, 84], [41, 85], [41, 87], [41, 91], [41, 93], [41, 94], [41, 95], [41, 96], [41, 98], [41, 99], [42, 46], [42, 47], [42, 48], [42, 49], [42, 55], [42, 57], [42, 58], [42, 61], [42, 64], [42, 66], [42, 67], [42, 68], [42, 71], [42, 72], [42, 73], [42, 77], [42, 78], [42, 80], [42, 82], [42, 86], [42, 87], [42, 88], [42, 90], [42, 93], [42, 94], [42, 95], [42, 97], [42, 99], [43, 44], [43, 45], [43, 46], [43, 48], [43, 49], [43, 50], [43, 51], [43, 54], [43, 55], [43, 56], [43, 58], [43, 59], [43, 62], [43, 63], [43, 65], [43, 66], [43, 67], [43, 69], [43, 71], [43, 72], [43, 76], [43, 78], [43, 79], [43, 80], [43, 81], [43, 83], [43, 84], [43, 86], [43, 88], [43, 90], [43, 91], [43, 92], [43, 95], [43, 96], [43, 97], [43, 98], [44, 46], [44, 47], [44, 49], [44, 50], [44, 51], [44, 53], [44, 55], [44, 56], [44, 57], [44, 58], [44, 60], [44, 62], [44, 67], [44, 68], [44, 70], [44, 71], [44, 76], [44, 80], [44, 82], [44, 83], [44, 84], [44, 86], [44, 87], [44, 90], [44, 92], [44, 96], [45, 46], [45, 47], [45, 49], [45, 50], [45, 54], [45, 57], [45, 60], [45, 61], [45, 62], [45, 65], [45, 66], [45, 67], [45, 68], [45, 72], [45, 74], [45, 78], [45, 79], [45, 80], [45, 82], [45, 84], [45, 85], [45, 87], [45, 88], [45, 89], [45, 90], [45, 91], [45, 92], [45, 96], [45, 97], [45, 99], [46, 48], [46, 50], [46, 51], [46, 56], [46, 59], [46, 62], [46, 64], [46, 65], [46, 66], [46, 67], [46, 70], [46, 71], [46, 72], [46, 73], [46, 74], [46, 76], [46, 77], [46, 79], [46, 80], [46, 81], [46, 82], [46, 83], [46, 84], [46, 86], [46, 89], [46, 90], [46, 91], [46, 92], [46, 93], [46, 94], [46, 95], [46, 96], [46, 97], [46, 98], [46, 99], [47, 51], [47, 52], [47, 57], [47, 58], [47, 61], [47, 64], [47, 66], [47, 67], [47, 70], [47, 71], [47, 73], [47, 78], [47, 79], [47, 80], [47, 83], [47, 84], [47, 85], [47, 89], [47, 90], [47, 93], [47, 95], [47, 96], [47, 97], [47, 98], [48, 50], [48, 51], [48, 52], [48, 53], [48, 55], [48, 56], [48, 58], [48, 59], [48, 61], [48, 63], [48, 67], [48, 68], [48, 70], [48, 71], [48, 73], [48, 75], [48, 79], [48, 80], [48, 81], [48, 84], [48, 85], [48, 87], [48, 88], [48, 89], [48, 91], [48, 94], [48, 97], [48, 98], [48, 99], [49, 50], [49, 53], [49, 54], [49, 57], [49, 58], [49, 60], [49, 63], [49, 64], [49, 65], [49, 67], [49, 72], [49, 75], [49, 78], [49, 79], [49, 82], [49, 83], [49, 84], [49, 85], [49, 88], [49, 90], [49, 91], [49, 93], [49, 94], [49, 97], [49, 98], [50, 51], [50, 53], [50, 54], [50, 55], [50, 56], [50, 57], [50, 58], [50, 59], [50, 63], [50, 64], [50, 65], [50, 66], [50, 68], [50, 69], [50, 73], [50, 76], [50, 77], [50, 78], [50, 79], [50, 80], [50, 81], [50, 82], [50, 84], [50, 86], [50, 87], [50, 88], [50, 89], [50, 91], [50, 93], [50, 94], [50, 97], [50, 98], [51, 52], [51, 56], [51, 57], [51, 59], [51, 60], [51, 61], [51, 62], [51, 68], [51, 69], [51, 71], [51, 73], [51, 74], [51, 75], [51, 76], [51, 77], [51, 79], [51, 80], [51, 84], [51, 89], [51, 90], [51, 91], [51, 92], [51, 94], [51, 95], [51, 97], [51, 98], [51, 99], [52, 53], [52, 58], [52, 59], [52, 62], [52, 63], [52, 68], [52, 74], [52, 75], [52, 77], [52, 78], [52, 82], [52, 87], [52, 90], [52, 92], [52, 95], [52, 96], [52, 97], [52, 98], [53, 56], [53, 58], [53, 60], [53, 62], [53, 65], [53, 67], [53, 68], [53, 69], [53, 70], [53, 71], [53, 72], [53, 73], [53, 77], [53, 79], [53, 81], [53, 82], [53, 83], [53, 84], [53, 85], [53, 86], [53, 87], [53, 88], [53, 89], [53, 91], [53, 95], [53, 98], [53, 99], [54, 55], [54, 56], [54, 58], [54, 60], [54, 62], [54, 63], [54, 64], [54, 66], [54, 67], [54, 69], [54, 72], [54, 73], [54, 74], [54, 77], [54, 78], [54, 82], [54, 83], [54, 85], [54, 87], [54, 91], [54, 92], [54, 97], [54, 98], [54, 99], [55, 56], [55, 58], [55, 59], [55, 63], [55, 68], [55, 69], [55, 70], [55, 71], [55, 72], [55, 73], [55, 74], [55, 75], [55, 79], [55, 80], [55, 81], [55, 83], [55, 84], [55, 85], [55, 87], [55, 93], [55, 94], [55, 98], [55, 99], [56, 59], [56, 60], [56, 61], [56, 62], [56, 63], [56, 67], [56, 70], [56, 71], [56, 72], [56, 75], [56, 76], [56, 77], [56, 79], [56, 80], [56, 82], [56, 84], [56, 85], [56, 86], [56, 87], [56, 88], [56, 89], [56, 91], [56, 94], [56, 97], [56, 98], [56, 99], [57, 58], [57, 59], [57, 63], [57, 64], [57, 65], [57, 68], [57, 71], [57, 72], [57, 73], [57, 74], [57, 75], [57, 79], [57, 81], [57, 82], [57, 83], [57, 84], [57, 85], [57, 86], [57, 89], [57, 91], [57, 92], [58, 60], [58, 61], [58, 62], [58, 66], [58, 67], [58, 68], [58, 69], [58, 70], [58, 71], [58, 72], [58, 74], [58, 76], [58, 77], [58, 80], [58, 84], [58, 86], [58, 87], [58, 90], [58, 91], [58, 92], [58, 93], [58, 97], [59, 63], [59, 66], [59, 67], [59, 70], [59, 72], [59, 74], [59, 75], [59, 77], [59, 78], [59, 79], [59, 80], [59, 81], [59, 82], [59, 83], [59, 84], [59, 89], [59, 90], [59, 91], [59, 93], [59, 94], [59, 95], [59, 98], [59, 99], [60, 62], [60, 63], [60, 66], [60, 67], [60, 69], [60, 70], [60, 73], [60, 74], [60, 76], [60, 78], [60, 80], [60, 81], [60, 91], [60, 92], [60, 95], [60, 96], [60, 98], [61, 62], [61, 64], [61, 65], [61, 67], [61, 69], [61, 70], [61, 74], [61, 76], [61, 79], [61, 80], [61, 82], [61, 83], [61, 86], [61, 87], [61, 90], [61, 91], [61, 94], [61, 96], [61, 97], [62, 63], [62, 65], [62, 67], [62, 71], [62, 72], [62, 74], [62, 77], [62, 81], [62, 83], [62, 90], [62, 93], [62, 96], [62, 97], [62, 98], [62, 99], [63, 64], [63, 66], [63, 68], [63, 70], [63, 73], [63, 76], [63, 79], [63, 80], [63, 81], [63, 82], [63, 88], [63, 89], [63, 90], [63, 91], [63, 92], [63, 93], [63, 96], [63, 98], [63, 99], [64, 67], [64, 69], [64, 70], [64, 71], [64, 73], [64, 76], [64, 84], [64, 86], [64, 88], [64, 89], [64, 91], [64, 92], [64, 93], [64, 94], [64, 96], [64, 98], [65, 66], [65, 67], [65, 69], [65, 70], [65, 73], [65, 76], [65, 77], [65, 79], [65, 82], [65, 84], [65, 85], [65, 86], [65, 88], [65, 91], [65, 92], [65, 93], [65, 94], [65, 96], [65, 98], [66, 67], [66, 68], [66, 70], [66, 71], [66, 75], [66, 77], [66, 80], [66, 85], [66, 87], [66, 88], [66, 90], [66, 91], [66, 96], [66, 97], [66, 98], [66, 99], [67, 68], [67, 72], [67, 78], [67, 81], [67, 82], [67, 84], [67, 86], [67, 87], [67, 88], [67, 90], [67, 91], [67, 94], [67, 97], [67, 98], [67, 99], [68, 71], [68, 73], [68, 76], [68, 79], [68, 80], [68, 82], [68, 87], [68, 92], [68, 94], [68, 95], [68, 96], [68, 98], [68, 99], [69, 72], [69, 74], [69, 75], [69, 76], [69, 77], [69, 78], [69, 79], [69, 80], [69, 83], [69, 86], [69, 87], [69, 89], [69, 91], [69, 92], [69, 93], [69, 94], [69, 95], [69, 96], [69, 99], [70, 71], [70, 73], [70, 75], [70, 76], [70, 77], [70, 78], [70, 82], [70, 86], [70, 88], [70, 90], [70, 94], [70, 95], [70, 96], [70, 97], [71, 72], [71, 73], [71, 75], [71, 76], [71, 77], [71, 78], [71, 79], [71, 84], [71, 85], [71, 87], [71, 88], [71, 89], [71, 91], [71, 92], [71, 97], [72, 73], [72, 74], [72, 75], [72, 76], [72, 80], [72, 81], [72, 84], [72, 85], [72, 87], [72, 89], [72, 92], [72, 95], [72, 96], [72, 99], [73, 76], [73, 77], [73, 79], [73, 86], [73, 88], [73, 91], [73, 95], [73, 96], [73, 97], [73, 99], [74, 75], [74, 78], [74, 79], [74, 81], [74, 88], [74, 89], [74, 93], [74, 94], [74, 95], [74, 96], [74, 97], [74, 99], [75, 77], [75, 79], [75, 81], [75, 82], [75, 83], [75, 86], [75, 88], [75, 89], [75, 90], [75, 91], [75, 92], [75, 93], [75, 94], [75, 95], [75, 96], [75, 97], [75, 98], [75, 99], [76, 78], [76, 84], [76, 85], [76, 87], [76, 89], [76, 90], [76, 92], [76, 97], [76, 98], [76, 99], [77, 79], [77, 84], [77, 85], [77, 87], [77, 88], [77, 91], [77, 92], [77, 93], [77, 94], [77, 96], [77, 98], [78, 80], [78, 83], [78, 84], [78, 85], [78, 86], [78, 88], [78, 91], [78, 96], [78, 97], [78, 98], [78, 99], [79, 80], [79, 81], [79, 83], [79, 84], [79, 85], [79, 86], [79, 87], [79, 89], [79, 91], [79, 92], [79, 94], [79, 95], [79, 96], [79, 98], [79, 99], [80, 81], [80, 82], [80, 84], [80, 85], [80, 86], [80, 88], [80, 89], [80, 91], [80, 92], [80, 93], [80, 97], [80, 98], [81, 82], [81, 85], [81, 86], [81, 89], [81, 90], [81, 92], [81, 94], [81, 95], [81, 98], [82, 86], [82, 87], [82, 88], [82, 89], [82, 91], [82, 92], [82, 96], [82, 99], [83, 86], [83, 87], [83, 92], [83, 94], [83, 95], [83, 98], [84, 89], [84, 91], [84, 93], [84, 94], [84, 96], [84, 97], [84, 98], [85, 89], [85, 90], [85, 92], [85, 93], [85, 94], [85, 97], [86, 87], [86, 90], [86, 91], [86, 93], [86, 94], [86, 95], [86, 96], [86, 98], [86, 99], [87, 90], [87, 93], [87, 94], [87, 96], [88, 93], [88, 97], [89, 90], [89, 92], [89, 93], [89, 95], [89, 97], [89, 99], [90, 94], [90, 96], [91, 94], [91, 95], [91, 98], [92, 93], [92, 95], [92, 96], [92, 97], [92, 98], [93, 95], [93, 96], [94, 95], [94, 96], [94, 97], [94, 99], [95, 97], [95, 98], [95, 99], [96, 99], [97, 98], [97, 99]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s1/tests/run.py b/tasks/construct-nppc-clique-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-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-clique-l6-s1/tests/test.sh b/tasks/construct-nppc-clique-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-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-clique-l6-s8/environment/Dockerfile b/tasks/construct-nppc-clique-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-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-nppc-clique-l6-s8/environment/instance.json b/tasks/construct-nppc-clique-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8ac63dfb93967a4b981314a025b8530fa442f43a --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 10], [0, 11], [0, 12], [0, 13], [0, 16], [0, 18], [0, 22], [0, 23], [0, 26], [0, 30], [0, 32], [0, 33], [0, 36], [0, 41], [0, 43], [0, 45], [0, 46], [0, 47], [0, 50], [0, 51], [0, 52], [0, 54], [0, 55], [0, 56], [0, 57], [0, 58], [0, 60], [0, 61], [0, 64], [0, 65], [0, 66], [0, 69], [0, 72], [0, 73], [0, 74], [0, 76], [0, 82], [0, 83], [0, 86], [0, 89], [0, 90], [0, 91], [0, 94], [0, 96], [0, 99], [1, 5], [1, 6], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 18], [1, 20], [1, 21], [1, 24], [1, 28], [1, 30], [1, 32], [1, 35], [1, 36], [1, 40], [1, 41], [1, 45], [1, 47], [1, 48], [1, 53], [1, 54], [1, 55], [1, 58], [1, 67], [1, 68], [1, 69], [1, 70], [1, 71], [1, 74], [1, 75], [1, 77], [1, 81], [1, 82], [1, 85], [1, 87], [1, 91], [1, 92], [1, 94], [1, 95], [1, 99], [2, 3], [2, 4], [2, 6], [2, 8], [2, 16], [2, 17], [2, 18], [2, 20], [2, 21], [2, 22], [2, 26], [2, 29], [2, 31], [2, 36], [2, 37], [2, 40], [2, 41], [2, 42], [2, 45], [2, 46], [2, 47], [2, 50], [2, 52], [2, 54], [2, 58], [2, 60], [2, 62], [2, 63], [2, 67], [2, 69], [2, 70], [2, 71], [2, 73], [2, 74], [2, 75], [2, 76], [2, 78], [2, 80], [2, 81], [2, 84], [2, 85], [2, 86], [2, 88], [2, 90], [2, 91], [2, 93], [2, 99], [3, 4], [3, 5], [3, 8], [3, 9], [3, 13], [3, 14], [3, 16], [3, 18], [3, 19], [3, 22], [3, 23], [3, 28], [3, 29], [3, 31], [3, 34], [3, 35], [3, 36], [3, 41], [3, 43], [3, 44], [3, 51], [3, 56], [3, 60], [3, 61], [3, 63], [3, 65], [3, 68], [3, 70], [3, 72], [3, 75], [3, 77], [3, 78], [3, 80], [3, 81], [3, 82], [3, 86], [3, 87], [3, 88], [3, 91], [3, 94], [4, 8], [4, 9], [4, 10], [4, 12], [4, 14], [4, 15], [4, 16], [4, 22], [4, 24], [4, 25], [4, 28], [4, 29], [4, 30], [4, 32], [4, 35], [4, 36], [4, 37], [4, 39], [4, 40], [4, 42], [4, 43], [4, 44], [4, 50], [4, 52], [4, 53], [4, 57], [4, 60], [4, 62], [4, 64], [4, 67], [4, 68], [4, 70], [4, 76], [4, 77], [4, 78], [4, 79], [4, 82], [4, 84], [4, 85], [4, 86], [4, 87], [4, 89], [4, 90], [4, 94], [4, 95], [4, 97], [5, 6], [5, 10], [5, 11], [5, 15], [5, 16], [5, 17], [5, 21], [5, 22], [5, 26], [5, 27], [5, 30], [5, 31], [5, 33], [5, 34], [5, 35], [5, 37], [5, 39], [5, 43], [5, 45], [5, 48], [5, 50], [5, 51], [5, 58], [5, 61], [5, 63], [5, 65], [5, 70], [5, 72], [5, 73], [5, 74], [5, 76], [5, 79], [5, 86], [5, 88], [5, 90], [5, 92], [5, 94], [5, 95], [5, 96], [5, 97], [5, 99], [6, 8], [6, 10], [6, 11], [6, 12], [6, 14], [6, 17], [6, 18], [6, 19], [6, 23], [6, 24], [6, 25], [6, 27], [6, 28], [6, 30], [6, 32], [6, 35], [6, 36], [6, 37], [6, 39], [6, 40], [6, 41], [6, 43], [6, 44], [6, 45], [6, 46], [6, 48], [6, 49], [6, 51], [6, 58], [6, 59], [6, 60], [6, 63], [6, 64], [6, 67], [6, 69], [6, 70], [6, 71], [6, 72], [6, 73], [6, 75], [6, 79], [6, 81], [6, 82], [6, 88], [6, 91], [6, 93], [6, 95], [6, 96], [6, 98], [6, 99], [7, 10], [7, 14], [7, 16], [7, 18], [7, 24], [7, 25], [7, 29], [7, 33], [7, 34], [7, 37], [7, 38], [7, 39], [7, 42], [7, 44], [7, 45], [7, 47], [7, 48], [7, 52], [7, 54], [7, 56], [7, 57], [7, 58], [7, 59], [7, 60], [7, 63], [7, 64], [7, 65], [7, 70], [7, 73], [7, 79], [7, 81], [7, 84], [7, 85], [7, 86], [7, 90], [7, 91], [7, 92], [7, 93], [7, 94], [8, 9], [8, 11], [8, 12], [8, 16], [8, 17], [8, 19], [8, 20], [8, 22], [8, 24], [8, 25], [8, 26], [8, 30], [8, 31], [8, 35], [8, 37], [8, 39], [8, 41], [8, 42], [8, 43], [8, 46], [8, 47], [8, 48], [8, 50], [8, 51], [8, 53], [8, 55], [8, 56], [8, 63], [8, 64], [8, 66], [8, 67], [8, 70], [8, 71], [8, 78], [8, 79], [8, 82], [8, 83], [8, 84], [8, 85], [8, 86], [8, 89], [8, 90], [8, 91], [8, 92], [8, 94], [8, 95], [8, 96], [8, 98], [8, 99], [9, 14], [9, 15], [9, 18], [9, 19], [9, 20], [9, 24], [9, 25], [9, 26], [9, 27], [9, 29], [9, 30], [9, 45], [9, 46], [9, 49], [9, 50], [9, 51], [9, 53], [9, 54], [9, 55], [9, 56], [9, 57], [9, 59], [9, 65], [9, 66], [9, 67], [9, 68], [9, 73], [9, 74], [9, 75], [9, 76], [9, 77], [9, 81], [9, 82], [9, 84], [9, 85], [9, 87], [9, 91], [9, 93], [9, 94], [9, 96], [9, 97], [9, 99], [10, 12], [10, 15], [10, 16], [10, 18], [10, 20], [10, 21], [10, 22], [10, 23], [10, 25], [10, 26], [10, 27], [10, 29], [10, 31], [10, 32], [10, 34], [10, 35], [10, 36], [10, 38], [10, 44], [10, 46], [10, 47], [10, 48], [10, 49], [10, 54], [10, 56], [10, 59], [10, 60], [10, 63], [10, 64], [10, 65], [10, 66], [10, 67], [10, 68], [10, 69], [10, 71], [10, 72], [10, 74], [10, 75], [10, 76], [10, 78], [10, 80], [10, 81], [10, 85], [10, 88], [10, 91], [10, 92], [10, 94], [10, 97], [10, 98], [10, 99], [11, 12], [11, 13], [11, 16], [11, 18], [11, 20], [11, 22], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 37], [11, 39], [11, 41], [11, 43], [11, 45], [11, 47], [11, 53], [11, 54], [11, 56], [11, 60], [11, 65], [11, 67], [11, 68], [11, 70], [11, 71], [11, 73], [11, 74], [11, 75], [11, 80], [11, 81], [11, 83], [11, 86], [11, 87], [11, 88], [11, 94], [11, 95], [11, 96], [12, 13], [12, 14], [12, 15], [12, 18], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 27], [12, 28], [12, 29], [12, 35], [12, 38], [12, 40], [12, 42], [12, 43], [12, 44], [12, 50], [12, 51], [12, 52], [12, 53], [12, 55], [12, 57], [12, 62], [12, 65], [12, 67], [12, 71], [12, 73], [12, 74], [12, 80], [12, 81], [12, 85], [12, 88], [12, 91], [12, 93], [12, 96], [13, 14], [13, 15], [13, 17], [13, 20], [13, 22], [13, 25], [13, 28], [13, 29], [13, 33], [13, 34], [13, 35], [13, 36], [13, 39], [13, 43], [13, 44], [13, 45], [13, 46], [13, 48], [13, 49], [13, 50], [13, 53], [13, 54], [13, 55], [13, 57], [13, 59], [13, 62], [13, 63], [13, 64], [13, 67], [13, 68], [13, 70], [13, 71], [13, 72], [13, 73], [13, 74], [13, 78], [13, 80], [13, 82], [13, 84], [13, 87], [13, 88], [13, 90], [13, 91], [13, 94], [13, 96], [13, 98], [14, 15], [14, 16], [14, 17], [14, 19], [14, 21], [14, 22], [14, 23], [14, 25], [14, 27], [14, 29], [14, 31], [14, 33], [14, 36], [14, 37], [14, 38], [14, 39], [14, 41], [14, 46], [14, 48], [14, 49], [14, 50], [14, 51], [14, 52], [14, 55], [14, 56], [14, 58], [14, 59], [14, 65], [14, 70], [14, 72], [14, 74], [14, 75], [14, 76], [14, 77], [14, 81], [14, 82], [14, 83], [14, 84], [14, 86], [14, 87], [14, 90], [14, 91], [14, 93], [14, 95], [15, 16], [15, 17], [15, 18], [15, 19], [15, 23], [15, 26], [15, 27], [15, 28], [15, 29], [15, 31], [15, 33], [15, 34], [15, 37], [15, 38], [15, 40], [15, 41], [15, 46], [15, 49], [15, 50], [15, 52], [15, 53], [15, 56], [15, 59], [15, 60], [15, 61], [15, 63], [15, 69], [15, 71], [15, 72], [15, 74], [15, 75], [15, 77], [15, 81], [15, 82], [15, 83], [15, 84], [15, 85], [15, 87], [15, 89], [15, 93], [15, 96], [15, 99], [16, 18], [16, 19], [16, 22], [16, 23], [16, 24], [16, 26], [16, 27], [16, 33], [16, 34], [16, 35], [16, 37], [16, 38], [16, 39], [16, 41], [16, 42], [16, 43], [16, 44], [16, 45], [16, 48], [16, 49], [16, 51], [16, 52], [16, 53], [16, 54], [16, 59], [16, 60], [16, 62], [16, 64], [16, 66], [16, 70], [16, 71], [16, 72], [16, 75], [16, 76], [16, 77], [16, 78], [16, 79], [16, 84], [16, 85], [16, 88], [16, 89], [16, 90], [16, 92], [16, 93], [16, 94], [16, 95], [16, 97], [17, 18], [17, 21], [17, 24], [17, 28], [17, 30], [17, 31], [17, 32], [17, 34], [17, 36], [17, 37], [17, 38], [17, 39], [17, 40], [17, 42], [17, 43], [17, 48], [17, 50], [17, 51], [17, 52], [17, 54], [17, 55], [17, 58], [17, 61], [17, 64], [17, 66], [17, 68], [17, 70], [17, 72], [17, 74], [17, 75], [17, 77], [17, 78], [17, 80], [17, 81], [17, 83], [17, 84], [17, 88], [17, 91], [17, 92], [17, 94], [18, 20], [18, 22], [18, 24], [18, 27], [18, 28], [18, 29], [18, 30], [18, 31], [18, 32], [18, 34], [18, 35], [18, 37], [18, 41], [18, 42], [18, 43], [18, 44], [18, 50], [18, 51], [18, 53], [18, 57], [18, 58], [18, 60], [18, 62], [18, 63], [18, 64], [18, 65], [18, 68], [18, 69], [18, 71], [18, 78], [18, 82], [18, 85], [18, 86], [18, 88], [18, 90], [18, 91], [18, 93], [18, 94], [18, 96], [18, 98], [18, 99], [19, 22], [19, 24], [19, 25], [19, 29], [19, 30], [19, 31], [19, 34], [19, 38], [19, 39], [19, 40], [19, 41], [19, 42], [19, 44], [19, 46], [19, 47], [19, 48], [19, 49], [19, 50], [19, 51], [19, 56], [19, 57], [19, 58], [19, 61], [19, 62], [19, 67], [19, 68], [19, 69], [19, 70], [19, 73], [19, 75], [19, 77], [19, 78], [19, 79], [19, 81], [19, 83], [19, 84], [19, 85], [19, 86], [19, 89], [19, 90], [19, 94], [19, 96], [19, 97], [19, 98], [20, 25], [20, 26], [20, 29], [20, 32], [20, 33], [20, 35], [20, 36], [20, 37], [20, 38], [20, 39], [20, 42], [20, 43], [20, 45], [20, 46], [20, 47], [20, 48], [20, 50], [20, 52], [20, 54], [20, 56], [20, 61], [20, 62], [20, 63], [20, 65], [20, 66], [20, 69], [20, 71], [20, 73], [20, 74], [20, 75], [20, 76], [20, 79], [20, 80], [20, 81], [20, 84], [20, 85], [20, 86], [20, 87], [20, 88], [20, 90], [20, 91], [20, 92], [20, 96], [20, 98], [20, 99], [21, 23], [21, 24], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 34], [21, 36], [21, 40], [21, 41], [21, 43], [21, 44], [21, 45], [21, 46], [21, 47], [21, 48], [21, 51], [21, 52], [21, 53], [21, 55], [21, 59], [21, 60], [21, 62], [21, 63], [21, 67], [21, 68], [21, 69], [21, 70], [21, 73], [21, 76], [21, 77], [21, 78], [21, 82], [21, 83], [21, 86], [21, 87], [21, 88], [21, 89], [21, 91], [21, 93], [21, 94], [21, 95], [21, 96], [21, 99], [22, 23], [22, 29], [22, 30], [22, 31], [22, 35], [22, 36], [22, 39], [22, 41], [22, 42], [22, 43], [22, 44], [22, 45], [22, 46], [22, 50], [22, 53], [22, 54], [22, 59], [22, 60], [22, 61], [22, 64], [22, 65], [22, 67], [22, 68], [22, 70], [22, 72], [22, 75], [22, 76], [22, 78], [22, 87], [22, 90], [22, 91], [22, 92], [22, 93], [22, 95], [22, 96], [22, 97], [22, 98], [22, 99], [23, 24], [23, 25], [23, 27], [23, 31], [23, 32], [23, 33], [23, 36], [23, 38], [23, 41], [23, 42], [23, 45], [23, 48], [23, 49], [23, 53], [23, 55], [23, 56], [23, 60], [23, 61], [23, 63], [23, 71], [23, 72], [23, 73], [23, 74], [23, 76], [23, 77], [23, 80], [23, 83], [23, 84], [23, 85], [23, 87], [23, 88], [23, 94], [23, 95], [23, 96], [23, 97], [23, 99], [24, 25], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 33], [24, 34], [24, 36], [24, 40], [24, 41], [24, 42], [24, 43], [24, 44], [24, 45], [24, 48], [24, 49], [24, 50], [24, 51], [24, 52], [24, 53], [24, 57], [24, 58], [24, 63], [24, 64], [24, 66], [24, 67], [24, 69], [24, 70], [24, 72], [24, 73], [24, 74], [24, 75], [24, 76], [24, 77], [24, 80], [24, 82], [24, 83], [24, 86], [24, 87], [24, 89], [24, 90], [24, 91], [24, 92], [24, 93], [24, 94], [24, 95], [24, 96], [24, 98], [24, 99], [25, 26], [25, 28], [25, 35], [25, 39], [25, 40], [25, 43], [25, 44], [25, 45], [25, 46], [25, 48], [25, 52], [25, 56], [25, 57], [25, 59], [25, 61], [25, 64], [25, 65], [25, 66], [25, 67], [25, 70], [25, 72], [25, 74], [25, 75], [25, 76], [25, 77], [25, 79], [25, 80], [25, 85], [25, 86], [25, 87], [25, 91], [25, 96], [25, 97], [25, 99], [26, 27], [26, 28], [26, 31], [26, 32], [26, 33], [26, 34], [26, 39], [26, 44], [26, 45], [26, 47], [26, 49], [26, 50], [26, 52], [26, 53], [26, 55], [26, 57], [26, 58], [26, 59], [26, 61], [26, 62], [26, 63], [26, 65], [26, 71], [26, 72], [26, 73], [26, 78], [26, 80], [26, 84], [26, 86], [26, 90], [26, 91], [26, 97], [26, 99], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 34], [27, 35], [27, 36], [27, 38], [27, 39], [27, 40], [27, 41], [27, 46], [27, 47], [27, 50], [27, 51], [27, 52], [27, 56], [27, 60], [27, 61], [27, 62], [27, 63], [27, 66], [27, 67], [27, 68], [27, 71], [27, 74], [27, 75], [27, 76], [27, 78], [27, 80], [27, 81], [27, 82], [27, 85], [27, 86], [27, 87], [27, 91], [27, 92], [27, 93], [27, 95], [27, 96], [27, 98], [27, 99], [28, 29], [28, 30], [28, 32], [28, 33], [28, 34], [28, 36], [28, 37], [28, 39], [28, 40], [28, 43], [28, 45], [28, 47], [28, 49], [28, 51], [28, 52], [28, 53], [28, 54], [28, 56], [28, 57], [28, 59], [28, 61], [28, 63], [28, 65], [28, 66], [28, 70], [28, 71], [28, 76], [28, 77], [28, 78], [28, 79], [28, 81], [28, 82], [28, 83], [28, 84], [28, 85], [28, 86], [28, 87], [28, 89], [28, 91], [28, 93], [28, 94], [28, 95], [28, 96], [28, 98], [28, 99], [29, 30], [29, 32], [29, 34], [29, 37], [29, 38], [29, 40], [29, 43], [29, 48], [29, 51], [29, 52], [29, 53], [29, 55], [29, 62], [29, 63], [29, 65], [29, 68], [29, 70], [29, 71], [29, 73], [29, 74], [29, 75], [29, 76], [29, 77], [29, 79], [29, 80], [29, 82], [29, 83], [29, 85], [29, 86], [29, 87], [29, 89], [29, 92], [29, 93], [29, 94], [29, 95], [29, 96], [29, 98], [29, 99], [30, 31], [30, 32], [30, 34], [30, 35], [30, 36], [30, 37], [30, 40], [30, 42], [30, 43], [30, 45], [30, 47], [30, 48], [30, 49], [30, 50], [30, 51], [30, 55], [30, 62], [30, 63], [30, 65], [30, 70], [30, 71], [30, 72], [30, 73], [30, 76], [30, 77], [30, 80], [30, 81], [30, 82], [30, 83], [30, 85], [30, 86], [30, 87], [30, 88], [30, 89], [30, 93], [30, 94], [30, 95], [30, 96], [30, 97], [30, 98], [30, 99], [31, 38], [31, 39], [31, 40], [31, 41], [31, 42], [31, 45], [31, 51], [31, 52], [31, 53], [31, 56], [31, 59], [31, 61], [31, 62], [31, 63], [31, 66], [31, 69], [31, 71], [31, 72], [31, 74], [31, 77], [31, 78], [31, 79], [31, 80], [31, 81], [31, 83], [31, 85], [31, 86], [31, 89], [31, 90], [31, 91], [31, 93], [31, 95], [31, 96], [31, 97], [31, 99], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 38], [32, 39], [32, 40], [32, 43], [32, 45], [32, 47], [32, 49], [32, 51], [32, 53], [32, 60], [32, 61], [32, 62], [32, 66], [32, 67], [32, 69], [32, 72], [32, 73], [32, 74], [32, 75], [32, 78], [32, 80], [32, 81], [32, 83], [32, 86], [32, 89], [32, 90], [32, 95], [32, 97], [32, 98], [33, 35], [33, 36], [33, 38], [33, 39], [33, 41], [33, 42], [33, 44], [33, 49], [33, 50], [33, 52], [33, 55], [33, 56], [33, 58], [33, 64], [33, 65], [33, 66], [33, 68], [33, 69], [33, 70], [33, 71], [33, 74], [33, 78], [33, 79], [33, 81], [33, 82], [33, 87], [33, 88], [33, 90], [33, 91], [33, 92], [33, 95], [33, 96], [33, 98], [33, 99], [34, 36], [34, 38], [34, 40], [34, 43], [34, 45], [34, 46], [34, 47], [34, 48], [34, 52], [34, 54], [34, 55], [34, 56], [34, 59], [34, 61], [34, 62], [34, 63], [34, 64], [34, 65], [34, 66], [34, 67], [34, 68], [34, 69], [34, 70], [34, 71], [34, 76], [34, 77], [34, 78], [34, 79], [34, 80], [34, 81], [34, 82], [34, 84], [34, 86], [34, 89], [34, 90], [34, 91], [34, 93], [34, 94], [34, 95], [34, 96], [34, 98], [34, 99], [35, 37], [35, 39], [35, 40], [35, 43], [35, 44], [35, 45], [35, 46], [35, 49], [35, 54], [35, 55], [35, 58], [35, 59], [35, 66], [35, 68], [35, 71], [35, 74], [35, 76], [35, 79], [35, 81], [35, 82], [35, 83], [35, 87], [35, 88], [35, 90], [35, 94], [35, 98], [35, 99], [36, 38], [36, 41], [36, 47], [36, 48], [36, 50], [36, 52], [36, 53], [36, 54], [36, 57], [36, 59], [36, 61], [36, 62], [36, 64], [36, 66], [36, 68], [36, 69], [36, 74], [36, 76], [36, 78], [36, 79], [36, 81], [36, 84], [36, 86], [36, 88], [36, 89], [36, 90], [36, 91], [36, 92], [36, 97], [36, 98], [37, 38], [37, 39], [37, 40], [37, 45], [37, 46], [37, 47], [37, 49], [37, 51], [37, 53], [37, 54], [37, 56], [37, 58], [37, 60], [37, 63], [37, 64], [37, 65], [37, 68], [37, 69], [37, 71], [37, 75], [37, 77], [37, 78], [37, 79], [37, 80], [37, 85], [37, 88], [37, 90], [37, 91], [37, 92], [37, 93], [37, 94], [37, 95], [37, 96], [37, 98], [37, 99], [38, 40], [38, 41], [38, 42], [38, 44], [38, 45], [38, 46], [38, 51], [38, 52], [38, 53], [38, 54], [38, 55], [38, 59], [38, 62], [38, 66], [38, 68], [38, 69], [38, 72], [38, 75], [38, 76], [38, 77], [38, 80], [38, 83], [38, 84], [38, 85], [38, 86], [38, 87], [38, 88], [38, 90], [38, 94], [38, 95], [38, 99], [39, 40], [39, 41], [39, 43], [39, 44], [39, 46], [39, 49], [39, 51], [39, 53], [39, 54], [39, 55], [39, 56], [39, 57], [39, 60], [39, 62], [39, 63], [39, 67], [39, 69], [39, 70], [39, 73], [39, 74], [39, 75], [39, 76], [39, 77], [39, 79], [39, 83], [39, 84], [39, 87], [39, 89], [39, 90], [39, 91], [39, 94], [39, 95], [39, 96], [39, 97], [39, 99], [40, 41], [40, 42], [40, 43], [40, 45], [40, 48], [40, 54], [40, 55], [40, 58], [40, 60], [40, 62], [40, 63], [40, 65], [40, 66], [40, 68], [40, 69], [40, 70], [40, 72], [40, 73], [40, 74], [40, 75], [40, 76], [40, 77], [40, 78], [40, 80], [40, 82], [40, 84], [40, 86], [40, 87], [40, 89], [40, 93], [40, 94], [40, 95], [40, 96], [40, 97], [40, 99], [41, 42], [41, 47], [41, 48], [41, 50], [41, 52], [41, 54], [41, 55], [41, 57], [41, 59], [41, 64], [41, 65], [41, 66], [41, 67], [41, 71], [41, 75], [41, 78], [41, 82], [41, 84], [41, 85], [41, 88], [41, 89], [41, 91], [41, 92], [41, 96], [42, 43], [42, 51], [42, 54], [42, 56], [42, 57], [42, 58], [42, 59], [42, 65], [42, 66], [42, 68], [42, 70], [42, 72], [42, 74], [42, 76], [42, 83], [42, 84], [42, 85], [42, 86], [42, 89], [42, 93], [42, 95], [42, 97], [42, 98], [42, 99], [43, 47], [43, 50], [43, 51], [43, 52], [43, 54], [43, 55], [43, 60], [43, 62], [43, 63], [43, 65], [43, 66], [43, 68], [43, 69], [43, 70], [43, 72], [43, 74], [43, 76], [43, 77], [43, 78], [43, 79], [43, 82], [43, 83], [43, 86], [43, 87], [43, 89], [43, 91], [43, 93], [43, 94], [43, 95], [43, 96], [43, 99], [44, 45], [44, 46], [44, 47], [44, 48], [44, 51], [44, 54], [44, 56], [44, 61], [44, 62], [44, 68], [44, 69], [44, 70], [44, 73], [44, 78], [44, 79], [44, 80], [44, 82], [44, 83], [44, 86], [44, 87], [44, 88], [44, 90], [44, 91], [44, 92], [44, 93], [44, 94], [44, 95], [44, 96], [44, 97], [44, 98], [45, 46], [45, 49], [45, 50], [45, 51], [45, 53], [45, 55], [45, 56], [45, 59], [45, 62], [45, 64], [45, 65], [45, 66], [45, 67], [45, 72], [45, 75], [45, 78], [45, 79], [45, 85], [45, 86], [45, 87], [45, 91], [45, 92], [45, 93], [45, 94], [45, 95], [45, 96], [45, 98], [45, 99], [46, 51], [46, 52], [46, 57], [46, 58], [46, 60], [46, 62], [46, 63], [46, 65], [46, 66], [46, 67], [46, 69], [46, 72], [46, 74], [46, 77], [46, 78], [46, 80], [46, 84], [46, 85], [46, 86], [46, 92], [46, 94], [46, 98], [47, 48], [47, 49], [47, 50], [47, 53], [47, 54], [47, 57], [47, 58], [47, 60], [47, 66], [47, 67], [47, 68], [47, 69], [47, 71], [47, 73], [47, 74], [47, 82], [47, 83], [47, 85], [47, 89], [47, 90], [47, 91], [47, 92], [47, 93], [47, 95], [47, 96], [47, 98], [48, 49], [48, 51], [48, 56], [48, 59], [48, 60], [48, 61], [48, 63], [48, 64], [48, 67], [48, 73], [48, 74], [48, 75], [48, 78], [48, 80], [48, 81], [48, 84], [48, 85], [48, 86], [48, 87], [48, 88], [48, 89], [48, 90], [48, 94], [48, 97], [48, 98], [48, 99], [49, 50], [49, 51], [49, 54], [49, 55], [49, 56], [49, 60], [49, 64], [49, 66], [49, 67], [49, 69], [49, 71], [49, 72], [49, 73], [49, 75], [49, 76], [49, 78], [49, 81], [49, 82], [49, 83], [49, 85], [49, 87], [49, 89], [49, 92], [49, 96], [49, 97], [49, 99], [50, 52], [50, 54], [50, 59], [50, 62], [50, 64], [50, 65], [50, 66], [50, 67], [50, 68], [50, 70], [50, 72], [50, 75], [50, 76], [50, 77], [50, 78], [50, 80], [50, 84], [50, 85], [50, 86], [50, 88], [50, 90], [50, 92], [50, 93], [50, 95], [50, 98], [51, 52], [51, 55], [51, 58], [51, 59], [51, 60], [51, 63], [51, 64], [51, 65], [51, 67], [51, 68], [51, 69], [51, 71], [51, 73], [51, 74], [51, 75], [51, 76], [51, 77], [51, 78], [51, 80], [51, 84], [51, 85], [51, 86], [51, 89], [51, 90], [51, 91], [51, 92], [51, 93], [51, 94], [51, 95], [51, 97], [51, 98], [52, 53], [52, 56], [52, 63], [52, 64], [52, 66], [52, 69], [52, 70], [52, 76], [52, 77], [52, 87], [52, 89], [52, 94], [52, 97], [52, 98], [52, 99], [53, 55], [53, 58], [53, 60], [53, 62], [53, 64], [53, 65], [53, 66], [53, 68], [53, 69], [53, 70], [53, 72], [53, 73], [53, 74], [53, 75], [53, 77], [53, 82], [53, 83], [53, 84], [53, 86], [53, 89], [53, 90], [53, 91], [53, 92], [53, 93], [53, 94], [53, 95], [53, 96], [53, 97], [53, 98], [54, 59], [54, 60], [54, 63], [54, 66], [54, 67], [54, 69], [54, 71], [54, 75], [54, 80], [54, 86], [54, 88], [54, 89], [54, 92], [54, 93], [54, 94], [54, 96], [54, 97], [55, 57], [55, 58], [55, 59], [55, 60], [55, 64], [55, 65], [55, 66], [55, 68], [55, 71], [55, 74], [55, 75], [55, 78], [55, 80], [55, 81], [55, 82], [55, 83], [55, 84], [55, 88], [55, 91], [55, 93], [55, 97], [56, 62], [56, 63], [56, 64], [56, 66], [56, 67], [56, 69], [56, 70], [56, 71], [56, 73], [56, 80], [56, 83], [56, 84], [56, 85], [56, 88], [56, 90], [56, 92], [56, 93], [56, 94], [57, 59], [57, 60], [57, 63], [57, 64], [57, 66], [57, 67], [57, 68], [57, 70], [57, 71], [57, 75], [57, 79], [57, 80], [57, 81], [57, 82], [57, 84], [57, 86], [57, 87], [57, 88], [57, 89], [57, 90], [57, 91], [57, 92], [57, 94], [57, 95], [58, 59], [58, 67], [58, 68], [58, 69], [58, 70], [58, 71], [58, 72], [58, 76], [58, 78], [58, 79], [58, 80], [58, 81], [58, 82], [58, 83], [58, 86], [58, 87], [58, 88], [58, 89], [58, 90], [58, 93], [58, 95], [58, 96], [58, 99], [59, 61], [59, 62], [59, 64], [59, 65], [59, 68], [59, 76], [59, 79], [59, 81], [59, 86], [59, 87], [59, 88], [59, 90], [59, 91], [59, 92], [59, 93], [59, 95], [59, 96], [59, 98], [60, 61], [60, 62], [60, 63], [60, 66], [60, 68], [60, 70], [60, 71], [60, 73], [60, 78], [60, 85], [60, 86], [60, 87], [60, 88], [60, 89], [60, 90], [60, 93], [60, 97], [60, 99], [61, 62], [61, 64], [61, 66], [61, 67], [61, 68], [61, 70], [61, 75], [61, 76], [61, 77], [61, 78], [61, 81], [61, 82], [61, 83], [61, 85], [61, 89], [61, 90], [61, 92], [61, 96], [61, 97], [61, 98], [61, 99], [62, 64], [62, 67], [62, 68], [62, 70], [62, 72], [62, 75], [62, 76], [62, 79], [62, 84], [62, 85], [62, 87], [62, 89], [62, 90], [62, 93], [62, 95], [62, 99], [63, 65], [63, 66], [63, 67], [63, 68], [63, 70], [63, 74], [63, 75], [63, 76], [63, 77], [63, 80], [63, 81], [63, 82], [63, 83], [63, 86], [63, 87], [63, 88], [63, 89], [63, 90], [63, 91], [63, 93], [63, 94], [63, 95], [63, 96], [63, 97], [63, 98], [63, 99], [64, 67], [64, 68], [64, 72], [64, 73], [64, 74], [64, 75], [64, 76], [64, 80], [64, 81], [64, 85], [64, 86], [64, 87], [64, 91], [64, 93], [64, 95], [65, 66], [65, 67], [65, 69], [65, 71], [65, 73], [65, 74], [65, 76], [65, 80], [65, 82], [65, 85], [65, 86], [65, 87], [65, 88], [65, 92], [65, 96], [65, 97], [65, 99], [66, 67], [66, 70], [66, 71], [66, 72], [66, 73], [66, 74], [66, 75], [66, 76], [66, 77], [66, 80], [66, 81], [66, 82], [66, 83], [66, 85], [66, 89], [66, 90], [66, 91], [66, 95], [66, 96], [66, 97], [66, 98], [66, 99], [67, 70], [67, 72], [67, 74], [67, 75], [67, 76], [67, 77], [67, 80], [67, 82], [67, 83], [67, 85], [67, 86], [67, 91], [67, 92], [67, 98], [68, 71], [68, 72], [68, 73], [68, 74], [68, 80], [68, 81], [68, 87], [68, 88], [68, 90], [68, 94], [68, 95], [68, 96], [68, 97], [68, 99], [69, 71], [69, 72], [69, 76], [69, 77], [69, 78], [69, 79], [69, 81], [69, 82], [69, 83], [69, 87], [69, 88], [69, 90], [69, 91], [69, 92], [69, 93], [69, 94], [69, 95], [69, 96], [70, 72], [70, 73], [70, 76], [70, 77], [70, 82], [70, 83], [70, 84], [70, 85], [70, 86], [70, 87], [70, 88], [70, 89], [70, 90], [70, 93], [70, 94], [70, 95], [70, 96], [70, 97], [70, 98], [70, 99], [71, 73], [71, 74], [71, 76], [71, 78], [71, 85], [71, 87], [71, 88], [71, 90], [71, 92], [71, 94], [71, 99], [72, 74], [72, 75], [72, 76], [72, 80], [72, 81], [72, 82], [72, 84], [72, 86], [72, 87], [72, 90], [72, 91], [72, 93], [72, 94], [72, 97], [73, 74], [73, 75], [73, 78], [73, 80], [73, 81], [73, 83], [73, 86], [73, 89], [73, 91], [73, 93], [73, 94], [73, 98], [73, 99], [74, 75], [74, 76], [74, 78], [74, 79], [74, 82], [74, 84], [74, 85], [74, 86], [74, 87], [74, 88], [74, 93], [74, 94], [74, 95], [74, 96], [74, 98], [75, 77], [75, 79], [75, 81], [75, 82], [75, 88], [75, 89], [75, 90], [75, 93], [75, 94], [75, 95], [75, 97], [75, 98], [75, 99], [76, 77], [76, 78], [76, 79], [76, 82], [76, 86], [76, 87], [76, 89], [76, 91], [76, 92], [76, 93], [76, 94], [76, 95], [76, 96], [76, 97], [76, 98], [76, 99], [77, 78], [77, 80], [77, 82], [77, 84], [77, 86], [77, 88], [77, 89], [77, 90], [77, 91], [77, 92], [77, 93], [77, 94], [77, 95], [77, 96], [77, 97], [77, 98], [77, 99], [78, 79], [78, 80], [78, 81], [78, 86], [78, 88], [78, 89], [78, 92], [78, 93], [78, 98], [79, 83], [79, 84], [79, 88], [79, 90], [79, 91], [79, 93], [79, 94], [79, 95], [79, 98], [79, 99], [80, 81], [80, 86], [80, 89], [80, 90], [80, 91], [80, 92], [80, 95], [80, 97], [80, 98], [80, 99], [81, 82], [81, 83], [81, 84], [81, 85], [81, 87], [81, 88], [81, 89], [81, 91], [81, 92], [81, 98], [82, 83], [82, 85], [82, 86], [82, 88], [82, 89], [82, 92], [82, 93], [82, 94], [82, 95], [82, 96], [82, 97], [82, 99], [83, 84], [83, 86], [83, 88], [83, 90], [83, 92], [83, 93], [83, 95], [83, 99], [84, 86], [84, 87], [84, 88], [84, 89], [84, 90], [84, 91], [84, 95], [84, 97], [84, 98], [85, 92], [85, 94], [85, 95], [85, 99], [86, 87], [86, 88], [86, 89], [86, 90], [86, 91], [86, 92], [86, 93], [86, 94], [86, 95], [86, 96], [86, 97], [86, 98], [86, 99], [87, 88], [87, 89], [87, 90], [87, 91], [87, 92], [87, 97], [87, 98], [88, 89], [88, 91], [88, 94], [88, 95], [88, 97], [88, 99], [89, 90], [89, 91], [89, 93], [89, 94], [89, 95], [89, 96], [89, 99], [90, 92], [90, 93], [90, 94], [90, 95], [90, 97], [91, 92], [91, 95], [91, 96], [91, 97], [91, 99], [92, 95], [92, 96], [92, 97], [92, 98], [92, 99], [93, 94], [93, 95], [93, 96], [93, 97], [93, 99], [94, 95], [94, 96], [94, 99], [95, 96], [95, 99], [96, 99]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s8/solution/solve.sh b/tasks/construct-nppc-clique-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f73d0478c6b45ba5a659cd9889bc1fcb58edda9b --- /dev/null +++ b/tasks/construct-nppc-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": [21, 24, 28, 29, 30, 34, 40, 43, 63, 70, 76, 77, 82, 86, 89, 93, 94, 95, 96, 99]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l6-s8/tests/check.py b/tasks/construct-nppc-clique-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-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-l6-s8/tests/instance.json b/tasks/construct-nppc-clique-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8ac63dfb93967a4b981314a025b8530fa442f43a --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 10], [0, 11], [0, 12], [0, 13], [0, 16], [0, 18], [0, 22], [0, 23], [0, 26], [0, 30], [0, 32], [0, 33], [0, 36], [0, 41], [0, 43], [0, 45], [0, 46], [0, 47], [0, 50], [0, 51], [0, 52], [0, 54], [0, 55], [0, 56], [0, 57], [0, 58], [0, 60], [0, 61], [0, 64], [0, 65], [0, 66], [0, 69], [0, 72], [0, 73], [0, 74], [0, 76], [0, 82], [0, 83], [0, 86], [0, 89], [0, 90], [0, 91], [0, 94], [0, 96], [0, 99], [1, 5], [1, 6], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 18], [1, 20], [1, 21], [1, 24], [1, 28], [1, 30], [1, 32], [1, 35], [1, 36], [1, 40], [1, 41], [1, 45], [1, 47], [1, 48], [1, 53], [1, 54], [1, 55], [1, 58], [1, 67], [1, 68], [1, 69], [1, 70], [1, 71], [1, 74], [1, 75], [1, 77], [1, 81], [1, 82], [1, 85], [1, 87], [1, 91], [1, 92], [1, 94], [1, 95], [1, 99], [2, 3], [2, 4], [2, 6], [2, 8], [2, 16], [2, 17], [2, 18], [2, 20], [2, 21], [2, 22], [2, 26], [2, 29], [2, 31], [2, 36], [2, 37], [2, 40], [2, 41], [2, 42], [2, 45], [2, 46], [2, 47], [2, 50], [2, 52], [2, 54], [2, 58], [2, 60], [2, 62], [2, 63], [2, 67], [2, 69], [2, 70], [2, 71], [2, 73], [2, 74], [2, 75], [2, 76], [2, 78], [2, 80], [2, 81], [2, 84], [2, 85], [2, 86], [2, 88], [2, 90], [2, 91], [2, 93], [2, 99], [3, 4], [3, 5], [3, 8], [3, 9], [3, 13], [3, 14], [3, 16], [3, 18], [3, 19], [3, 22], [3, 23], [3, 28], [3, 29], [3, 31], [3, 34], [3, 35], [3, 36], [3, 41], [3, 43], [3, 44], [3, 51], [3, 56], [3, 60], [3, 61], [3, 63], [3, 65], [3, 68], [3, 70], [3, 72], [3, 75], [3, 77], [3, 78], [3, 80], [3, 81], [3, 82], [3, 86], [3, 87], [3, 88], [3, 91], [3, 94], [4, 8], [4, 9], [4, 10], [4, 12], [4, 14], [4, 15], [4, 16], [4, 22], [4, 24], [4, 25], [4, 28], [4, 29], [4, 30], [4, 32], [4, 35], [4, 36], [4, 37], [4, 39], [4, 40], [4, 42], [4, 43], [4, 44], [4, 50], [4, 52], [4, 53], [4, 57], [4, 60], [4, 62], [4, 64], [4, 67], [4, 68], [4, 70], [4, 76], [4, 77], [4, 78], [4, 79], [4, 82], [4, 84], [4, 85], [4, 86], [4, 87], [4, 89], [4, 90], [4, 94], [4, 95], [4, 97], [5, 6], [5, 10], [5, 11], [5, 15], [5, 16], [5, 17], [5, 21], [5, 22], [5, 26], [5, 27], [5, 30], [5, 31], [5, 33], [5, 34], [5, 35], [5, 37], [5, 39], [5, 43], [5, 45], [5, 48], [5, 50], [5, 51], [5, 58], [5, 61], [5, 63], [5, 65], [5, 70], [5, 72], [5, 73], [5, 74], [5, 76], [5, 79], [5, 86], [5, 88], [5, 90], [5, 92], [5, 94], [5, 95], [5, 96], [5, 97], [5, 99], [6, 8], [6, 10], [6, 11], [6, 12], [6, 14], [6, 17], [6, 18], [6, 19], [6, 23], [6, 24], [6, 25], [6, 27], [6, 28], [6, 30], [6, 32], [6, 35], [6, 36], [6, 37], [6, 39], [6, 40], [6, 41], [6, 43], [6, 44], [6, 45], [6, 46], [6, 48], [6, 49], [6, 51], [6, 58], [6, 59], [6, 60], [6, 63], [6, 64], [6, 67], [6, 69], [6, 70], [6, 71], [6, 72], [6, 73], [6, 75], [6, 79], [6, 81], [6, 82], [6, 88], [6, 91], [6, 93], [6, 95], [6, 96], [6, 98], [6, 99], [7, 10], [7, 14], [7, 16], [7, 18], [7, 24], [7, 25], [7, 29], [7, 33], [7, 34], [7, 37], [7, 38], [7, 39], [7, 42], [7, 44], [7, 45], [7, 47], [7, 48], [7, 52], [7, 54], [7, 56], [7, 57], [7, 58], [7, 59], [7, 60], [7, 63], [7, 64], [7, 65], [7, 70], [7, 73], [7, 79], [7, 81], [7, 84], [7, 85], [7, 86], [7, 90], [7, 91], [7, 92], [7, 93], [7, 94], [8, 9], [8, 11], [8, 12], [8, 16], [8, 17], [8, 19], [8, 20], [8, 22], [8, 24], [8, 25], [8, 26], [8, 30], [8, 31], [8, 35], [8, 37], [8, 39], [8, 41], [8, 42], [8, 43], [8, 46], [8, 47], [8, 48], [8, 50], [8, 51], [8, 53], [8, 55], [8, 56], [8, 63], [8, 64], [8, 66], [8, 67], [8, 70], [8, 71], [8, 78], [8, 79], [8, 82], [8, 83], [8, 84], [8, 85], [8, 86], [8, 89], [8, 90], [8, 91], [8, 92], [8, 94], [8, 95], [8, 96], [8, 98], [8, 99], [9, 14], [9, 15], [9, 18], [9, 19], [9, 20], [9, 24], [9, 25], [9, 26], [9, 27], [9, 29], [9, 30], [9, 45], [9, 46], [9, 49], [9, 50], [9, 51], [9, 53], [9, 54], [9, 55], [9, 56], [9, 57], [9, 59], [9, 65], [9, 66], [9, 67], [9, 68], [9, 73], [9, 74], [9, 75], [9, 76], [9, 77], [9, 81], [9, 82], [9, 84], [9, 85], [9, 87], [9, 91], [9, 93], [9, 94], [9, 96], [9, 97], [9, 99], [10, 12], [10, 15], [10, 16], [10, 18], [10, 20], [10, 21], [10, 22], [10, 23], [10, 25], [10, 26], [10, 27], [10, 29], [10, 31], [10, 32], [10, 34], [10, 35], [10, 36], [10, 38], [10, 44], [10, 46], [10, 47], [10, 48], [10, 49], [10, 54], [10, 56], [10, 59], [10, 60], [10, 63], [10, 64], [10, 65], [10, 66], [10, 67], [10, 68], [10, 69], [10, 71], [10, 72], [10, 74], [10, 75], [10, 76], [10, 78], [10, 80], [10, 81], [10, 85], [10, 88], [10, 91], [10, 92], [10, 94], [10, 97], [10, 98], [10, 99], [11, 12], [11, 13], [11, 16], [11, 18], [11, 20], [11, 22], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 37], [11, 39], [11, 41], [11, 43], [11, 45], [11, 47], [11, 53], [11, 54], [11, 56], [11, 60], [11, 65], [11, 67], [11, 68], [11, 70], [11, 71], [11, 73], [11, 74], [11, 75], [11, 80], [11, 81], [11, 83], [11, 86], [11, 87], [11, 88], [11, 94], [11, 95], [11, 96], [12, 13], [12, 14], [12, 15], [12, 18], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 27], [12, 28], [12, 29], [12, 35], [12, 38], [12, 40], [12, 42], [12, 43], [12, 44], [12, 50], [12, 51], [12, 52], [12, 53], [12, 55], [12, 57], [12, 62], [12, 65], [12, 67], [12, 71], [12, 73], [12, 74], [12, 80], [12, 81], [12, 85], [12, 88], [12, 91], [12, 93], [12, 96], [13, 14], [13, 15], [13, 17], [13, 20], [13, 22], [13, 25], [13, 28], [13, 29], [13, 33], [13, 34], [13, 35], [13, 36], [13, 39], [13, 43], [13, 44], [13, 45], [13, 46], [13, 48], [13, 49], [13, 50], [13, 53], [13, 54], [13, 55], [13, 57], [13, 59], [13, 62], [13, 63], [13, 64], [13, 67], [13, 68], [13, 70], [13, 71], [13, 72], [13, 73], [13, 74], [13, 78], [13, 80], [13, 82], [13, 84], [13, 87], [13, 88], [13, 90], [13, 91], [13, 94], [13, 96], [13, 98], [14, 15], [14, 16], [14, 17], [14, 19], [14, 21], [14, 22], [14, 23], [14, 25], [14, 27], [14, 29], [14, 31], [14, 33], [14, 36], [14, 37], [14, 38], [14, 39], [14, 41], [14, 46], [14, 48], [14, 49], [14, 50], [14, 51], [14, 52], [14, 55], [14, 56], [14, 58], [14, 59], [14, 65], [14, 70], [14, 72], [14, 74], [14, 75], [14, 76], [14, 77], [14, 81], [14, 82], [14, 83], [14, 84], [14, 86], [14, 87], [14, 90], [14, 91], [14, 93], [14, 95], [15, 16], [15, 17], [15, 18], [15, 19], [15, 23], [15, 26], [15, 27], [15, 28], [15, 29], [15, 31], [15, 33], [15, 34], [15, 37], [15, 38], [15, 40], [15, 41], [15, 46], [15, 49], [15, 50], [15, 52], [15, 53], [15, 56], [15, 59], [15, 60], [15, 61], [15, 63], [15, 69], [15, 71], [15, 72], [15, 74], [15, 75], [15, 77], [15, 81], [15, 82], [15, 83], [15, 84], [15, 85], [15, 87], [15, 89], [15, 93], [15, 96], [15, 99], [16, 18], [16, 19], [16, 22], [16, 23], [16, 24], [16, 26], [16, 27], [16, 33], [16, 34], [16, 35], [16, 37], [16, 38], [16, 39], [16, 41], [16, 42], [16, 43], [16, 44], [16, 45], [16, 48], [16, 49], [16, 51], [16, 52], [16, 53], [16, 54], [16, 59], [16, 60], [16, 62], [16, 64], [16, 66], [16, 70], [16, 71], [16, 72], [16, 75], [16, 76], [16, 77], [16, 78], [16, 79], [16, 84], [16, 85], [16, 88], [16, 89], [16, 90], [16, 92], [16, 93], [16, 94], [16, 95], [16, 97], [17, 18], [17, 21], [17, 24], [17, 28], [17, 30], [17, 31], [17, 32], [17, 34], [17, 36], [17, 37], [17, 38], [17, 39], [17, 40], [17, 42], [17, 43], [17, 48], [17, 50], [17, 51], [17, 52], [17, 54], [17, 55], [17, 58], [17, 61], [17, 64], [17, 66], [17, 68], [17, 70], [17, 72], [17, 74], [17, 75], [17, 77], [17, 78], [17, 80], [17, 81], [17, 83], [17, 84], [17, 88], [17, 91], [17, 92], [17, 94], [18, 20], [18, 22], [18, 24], [18, 27], [18, 28], [18, 29], [18, 30], [18, 31], [18, 32], [18, 34], [18, 35], [18, 37], [18, 41], [18, 42], [18, 43], [18, 44], [18, 50], [18, 51], [18, 53], [18, 57], [18, 58], [18, 60], [18, 62], [18, 63], [18, 64], [18, 65], [18, 68], [18, 69], [18, 71], [18, 78], [18, 82], [18, 85], [18, 86], [18, 88], [18, 90], [18, 91], [18, 93], [18, 94], [18, 96], [18, 98], [18, 99], [19, 22], [19, 24], [19, 25], [19, 29], [19, 30], [19, 31], [19, 34], [19, 38], [19, 39], [19, 40], [19, 41], [19, 42], [19, 44], [19, 46], [19, 47], [19, 48], [19, 49], [19, 50], [19, 51], [19, 56], [19, 57], [19, 58], [19, 61], [19, 62], [19, 67], [19, 68], [19, 69], [19, 70], [19, 73], [19, 75], [19, 77], [19, 78], [19, 79], [19, 81], [19, 83], [19, 84], [19, 85], [19, 86], [19, 89], [19, 90], [19, 94], [19, 96], [19, 97], [19, 98], [20, 25], [20, 26], [20, 29], [20, 32], [20, 33], [20, 35], [20, 36], [20, 37], [20, 38], [20, 39], [20, 42], [20, 43], [20, 45], [20, 46], [20, 47], [20, 48], [20, 50], [20, 52], [20, 54], [20, 56], [20, 61], [20, 62], [20, 63], [20, 65], [20, 66], [20, 69], [20, 71], [20, 73], [20, 74], [20, 75], [20, 76], [20, 79], [20, 80], [20, 81], [20, 84], [20, 85], [20, 86], [20, 87], [20, 88], [20, 90], [20, 91], [20, 92], [20, 96], [20, 98], [20, 99], [21, 23], [21, 24], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 34], [21, 36], [21, 40], [21, 41], [21, 43], [21, 44], [21, 45], [21, 46], [21, 47], [21, 48], [21, 51], [21, 52], [21, 53], [21, 55], [21, 59], [21, 60], [21, 62], [21, 63], [21, 67], [21, 68], [21, 69], [21, 70], [21, 73], [21, 76], [21, 77], [21, 78], [21, 82], [21, 83], [21, 86], [21, 87], [21, 88], [21, 89], [21, 91], [21, 93], [21, 94], [21, 95], [21, 96], [21, 99], [22, 23], [22, 29], [22, 30], [22, 31], [22, 35], [22, 36], [22, 39], [22, 41], [22, 42], [22, 43], [22, 44], [22, 45], [22, 46], [22, 50], [22, 53], [22, 54], [22, 59], [22, 60], [22, 61], [22, 64], [22, 65], [22, 67], [22, 68], [22, 70], [22, 72], [22, 75], [22, 76], [22, 78], [22, 87], [22, 90], [22, 91], [22, 92], [22, 93], [22, 95], [22, 96], [22, 97], [22, 98], [22, 99], [23, 24], [23, 25], [23, 27], [23, 31], [23, 32], [23, 33], [23, 36], [23, 38], [23, 41], [23, 42], [23, 45], [23, 48], [23, 49], [23, 53], [23, 55], [23, 56], [23, 60], [23, 61], [23, 63], [23, 71], [23, 72], [23, 73], [23, 74], [23, 76], [23, 77], [23, 80], [23, 83], [23, 84], [23, 85], [23, 87], [23, 88], [23, 94], [23, 95], [23, 96], [23, 97], [23, 99], [24, 25], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 33], [24, 34], [24, 36], [24, 40], [24, 41], [24, 42], [24, 43], [24, 44], [24, 45], [24, 48], [24, 49], [24, 50], [24, 51], [24, 52], [24, 53], [24, 57], [24, 58], [24, 63], [24, 64], [24, 66], [24, 67], [24, 69], [24, 70], [24, 72], [24, 73], [24, 74], [24, 75], [24, 76], [24, 77], [24, 80], [24, 82], [24, 83], [24, 86], [24, 87], [24, 89], [24, 90], [24, 91], [24, 92], [24, 93], [24, 94], [24, 95], [24, 96], [24, 98], [24, 99], [25, 26], [25, 28], [25, 35], [25, 39], [25, 40], [25, 43], [25, 44], [25, 45], [25, 46], [25, 48], [25, 52], [25, 56], [25, 57], [25, 59], [25, 61], [25, 64], [25, 65], [25, 66], [25, 67], [25, 70], [25, 72], [25, 74], [25, 75], [25, 76], [25, 77], [25, 79], [25, 80], [25, 85], [25, 86], [25, 87], [25, 91], [25, 96], [25, 97], [25, 99], [26, 27], [26, 28], [26, 31], [26, 32], [26, 33], [26, 34], [26, 39], [26, 44], [26, 45], [26, 47], [26, 49], [26, 50], [26, 52], [26, 53], [26, 55], [26, 57], [26, 58], [26, 59], [26, 61], [26, 62], [26, 63], [26, 65], [26, 71], [26, 72], [26, 73], [26, 78], [26, 80], [26, 84], [26, 86], [26, 90], [26, 91], [26, 97], [26, 99], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 34], [27, 35], [27, 36], [27, 38], [27, 39], [27, 40], [27, 41], [27, 46], [27, 47], [27, 50], [27, 51], [27, 52], [27, 56], [27, 60], [27, 61], [27, 62], [27, 63], [27, 66], [27, 67], [27, 68], [27, 71], [27, 74], [27, 75], [27, 76], [27, 78], [27, 80], [27, 81], [27, 82], [27, 85], [27, 86], [27, 87], [27, 91], [27, 92], [27, 93], [27, 95], [27, 96], [27, 98], [27, 99], [28, 29], [28, 30], [28, 32], [28, 33], [28, 34], [28, 36], [28, 37], [28, 39], [28, 40], [28, 43], [28, 45], [28, 47], [28, 49], [28, 51], [28, 52], [28, 53], [28, 54], [28, 56], [28, 57], [28, 59], [28, 61], [28, 63], [28, 65], [28, 66], [28, 70], [28, 71], [28, 76], [28, 77], [28, 78], [28, 79], [28, 81], [28, 82], [28, 83], [28, 84], [28, 85], [28, 86], [28, 87], [28, 89], [28, 91], [28, 93], [28, 94], [28, 95], [28, 96], [28, 98], [28, 99], [29, 30], [29, 32], [29, 34], [29, 37], [29, 38], [29, 40], [29, 43], [29, 48], [29, 51], [29, 52], [29, 53], [29, 55], [29, 62], [29, 63], [29, 65], [29, 68], [29, 70], [29, 71], [29, 73], [29, 74], [29, 75], [29, 76], [29, 77], [29, 79], [29, 80], [29, 82], [29, 83], [29, 85], [29, 86], [29, 87], [29, 89], [29, 92], [29, 93], [29, 94], [29, 95], [29, 96], [29, 98], [29, 99], [30, 31], [30, 32], [30, 34], [30, 35], [30, 36], [30, 37], [30, 40], [30, 42], [30, 43], [30, 45], [30, 47], [30, 48], [30, 49], [30, 50], [30, 51], [30, 55], [30, 62], [30, 63], [30, 65], [30, 70], [30, 71], [30, 72], [30, 73], [30, 76], [30, 77], [30, 80], [30, 81], [30, 82], [30, 83], [30, 85], [30, 86], [30, 87], [30, 88], [30, 89], [30, 93], [30, 94], [30, 95], [30, 96], [30, 97], [30, 98], [30, 99], [31, 38], [31, 39], [31, 40], [31, 41], [31, 42], [31, 45], [31, 51], [31, 52], [31, 53], [31, 56], [31, 59], [31, 61], [31, 62], [31, 63], [31, 66], [31, 69], [31, 71], [31, 72], [31, 74], [31, 77], [31, 78], [31, 79], [31, 80], [31, 81], [31, 83], [31, 85], [31, 86], [31, 89], [31, 90], [31, 91], [31, 93], [31, 95], [31, 96], [31, 97], [31, 99], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 38], [32, 39], [32, 40], [32, 43], [32, 45], [32, 47], [32, 49], [32, 51], [32, 53], [32, 60], [32, 61], [32, 62], [32, 66], [32, 67], [32, 69], [32, 72], [32, 73], [32, 74], [32, 75], [32, 78], [32, 80], [32, 81], [32, 83], [32, 86], [32, 89], [32, 90], [32, 95], [32, 97], [32, 98], [33, 35], [33, 36], [33, 38], [33, 39], [33, 41], [33, 42], [33, 44], [33, 49], [33, 50], [33, 52], [33, 55], [33, 56], [33, 58], [33, 64], [33, 65], [33, 66], [33, 68], [33, 69], [33, 70], [33, 71], [33, 74], [33, 78], [33, 79], [33, 81], [33, 82], [33, 87], [33, 88], [33, 90], [33, 91], [33, 92], [33, 95], [33, 96], [33, 98], [33, 99], [34, 36], [34, 38], [34, 40], [34, 43], [34, 45], [34, 46], [34, 47], [34, 48], [34, 52], [34, 54], [34, 55], [34, 56], [34, 59], [34, 61], [34, 62], [34, 63], [34, 64], [34, 65], [34, 66], [34, 67], [34, 68], [34, 69], [34, 70], [34, 71], [34, 76], [34, 77], [34, 78], [34, 79], [34, 80], [34, 81], [34, 82], [34, 84], [34, 86], [34, 89], [34, 90], [34, 91], [34, 93], [34, 94], [34, 95], [34, 96], [34, 98], [34, 99], [35, 37], [35, 39], [35, 40], [35, 43], [35, 44], [35, 45], [35, 46], [35, 49], [35, 54], [35, 55], [35, 58], [35, 59], [35, 66], [35, 68], [35, 71], [35, 74], [35, 76], [35, 79], [35, 81], [35, 82], [35, 83], [35, 87], [35, 88], [35, 90], [35, 94], [35, 98], [35, 99], [36, 38], [36, 41], [36, 47], [36, 48], [36, 50], [36, 52], [36, 53], [36, 54], [36, 57], [36, 59], [36, 61], [36, 62], [36, 64], [36, 66], [36, 68], [36, 69], [36, 74], [36, 76], [36, 78], [36, 79], [36, 81], [36, 84], [36, 86], [36, 88], [36, 89], [36, 90], [36, 91], [36, 92], [36, 97], [36, 98], [37, 38], [37, 39], [37, 40], [37, 45], [37, 46], [37, 47], [37, 49], [37, 51], [37, 53], [37, 54], [37, 56], [37, 58], [37, 60], [37, 63], [37, 64], [37, 65], [37, 68], [37, 69], [37, 71], [37, 75], [37, 77], [37, 78], [37, 79], [37, 80], [37, 85], [37, 88], [37, 90], [37, 91], [37, 92], [37, 93], [37, 94], [37, 95], [37, 96], [37, 98], [37, 99], [38, 40], [38, 41], [38, 42], [38, 44], [38, 45], [38, 46], [38, 51], [38, 52], [38, 53], [38, 54], [38, 55], [38, 59], [38, 62], [38, 66], [38, 68], [38, 69], [38, 72], [38, 75], [38, 76], [38, 77], [38, 80], [38, 83], [38, 84], [38, 85], [38, 86], [38, 87], [38, 88], [38, 90], [38, 94], [38, 95], [38, 99], [39, 40], [39, 41], [39, 43], [39, 44], [39, 46], [39, 49], [39, 51], [39, 53], [39, 54], [39, 55], [39, 56], [39, 57], [39, 60], [39, 62], [39, 63], [39, 67], [39, 69], [39, 70], [39, 73], [39, 74], [39, 75], [39, 76], [39, 77], [39, 79], [39, 83], [39, 84], [39, 87], [39, 89], [39, 90], [39, 91], [39, 94], [39, 95], [39, 96], [39, 97], [39, 99], [40, 41], [40, 42], [40, 43], [40, 45], [40, 48], [40, 54], [40, 55], [40, 58], [40, 60], [40, 62], [40, 63], [40, 65], [40, 66], [40, 68], [40, 69], [40, 70], [40, 72], [40, 73], [40, 74], [40, 75], [40, 76], [40, 77], [40, 78], [40, 80], [40, 82], [40, 84], [40, 86], [40, 87], [40, 89], [40, 93], [40, 94], [40, 95], [40, 96], [40, 97], [40, 99], [41, 42], [41, 47], [41, 48], [41, 50], [41, 52], [41, 54], [41, 55], [41, 57], [41, 59], [41, 64], [41, 65], [41, 66], [41, 67], [41, 71], [41, 75], [41, 78], [41, 82], [41, 84], [41, 85], [41, 88], [41, 89], [41, 91], [41, 92], [41, 96], [42, 43], [42, 51], [42, 54], [42, 56], [42, 57], [42, 58], [42, 59], [42, 65], [42, 66], [42, 68], [42, 70], [42, 72], [42, 74], [42, 76], [42, 83], [42, 84], [42, 85], [42, 86], [42, 89], [42, 93], [42, 95], [42, 97], [42, 98], [42, 99], [43, 47], [43, 50], [43, 51], [43, 52], [43, 54], [43, 55], [43, 60], [43, 62], [43, 63], [43, 65], [43, 66], [43, 68], [43, 69], [43, 70], [43, 72], [43, 74], [43, 76], [43, 77], [43, 78], [43, 79], [43, 82], [43, 83], [43, 86], [43, 87], [43, 89], [43, 91], [43, 93], [43, 94], [43, 95], [43, 96], [43, 99], [44, 45], [44, 46], [44, 47], [44, 48], [44, 51], [44, 54], [44, 56], [44, 61], [44, 62], [44, 68], [44, 69], [44, 70], [44, 73], [44, 78], [44, 79], [44, 80], [44, 82], [44, 83], [44, 86], [44, 87], [44, 88], [44, 90], [44, 91], [44, 92], [44, 93], [44, 94], [44, 95], [44, 96], [44, 97], [44, 98], [45, 46], [45, 49], [45, 50], [45, 51], [45, 53], [45, 55], [45, 56], [45, 59], [45, 62], [45, 64], [45, 65], [45, 66], [45, 67], [45, 72], [45, 75], [45, 78], [45, 79], [45, 85], [45, 86], [45, 87], [45, 91], [45, 92], [45, 93], [45, 94], [45, 95], [45, 96], [45, 98], [45, 99], [46, 51], [46, 52], [46, 57], [46, 58], [46, 60], [46, 62], [46, 63], [46, 65], [46, 66], [46, 67], [46, 69], [46, 72], [46, 74], [46, 77], [46, 78], [46, 80], [46, 84], [46, 85], [46, 86], [46, 92], [46, 94], [46, 98], [47, 48], [47, 49], [47, 50], [47, 53], [47, 54], [47, 57], [47, 58], [47, 60], [47, 66], [47, 67], [47, 68], [47, 69], [47, 71], [47, 73], [47, 74], [47, 82], [47, 83], [47, 85], [47, 89], [47, 90], [47, 91], [47, 92], [47, 93], [47, 95], [47, 96], [47, 98], [48, 49], [48, 51], [48, 56], [48, 59], [48, 60], [48, 61], [48, 63], [48, 64], [48, 67], [48, 73], [48, 74], [48, 75], [48, 78], [48, 80], [48, 81], [48, 84], [48, 85], [48, 86], [48, 87], [48, 88], [48, 89], [48, 90], [48, 94], [48, 97], [48, 98], [48, 99], [49, 50], [49, 51], [49, 54], [49, 55], [49, 56], [49, 60], [49, 64], [49, 66], [49, 67], [49, 69], [49, 71], [49, 72], [49, 73], [49, 75], [49, 76], [49, 78], [49, 81], [49, 82], [49, 83], [49, 85], [49, 87], [49, 89], [49, 92], [49, 96], [49, 97], [49, 99], [50, 52], [50, 54], [50, 59], [50, 62], [50, 64], [50, 65], [50, 66], [50, 67], [50, 68], [50, 70], [50, 72], [50, 75], [50, 76], [50, 77], [50, 78], [50, 80], [50, 84], [50, 85], [50, 86], [50, 88], [50, 90], [50, 92], [50, 93], [50, 95], [50, 98], [51, 52], [51, 55], [51, 58], [51, 59], [51, 60], [51, 63], [51, 64], [51, 65], [51, 67], [51, 68], [51, 69], [51, 71], [51, 73], [51, 74], [51, 75], [51, 76], [51, 77], [51, 78], [51, 80], [51, 84], [51, 85], [51, 86], [51, 89], [51, 90], [51, 91], [51, 92], [51, 93], [51, 94], [51, 95], [51, 97], [51, 98], [52, 53], [52, 56], [52, 63], [52, 64], [52, 66], [52, 69], [52, 70], [52, 76], [52, 77], [52, 87], [52, 89], [52, 94], [52, 97], [52, 98], [52, 99], [53, 55], [53, 58], [53, 60], [53, 62], [53, 64], [53, 65], [53, 66], [53, 68], [53, 69], [53, 70], [53, 72], [53, 73], [53, 74], [53, 75], [53, 77], [53, 82], [53, 83], [53, 84], [53, 86], [53, 89], [53, 90], [53, 91], [53, 92], [53, 93], [53, 94], [53, 95], [53, 96], [53, 97], [53, 98], [54, 59], [54, 60], [54, 63], [54, 66], [54, 67], [54, 69], [54, 71], [54, 75], [54, 80], [54, 86], [54, 88], [54, 89], [54, 92], [54, 93], [54, 94], [54, 96], [54, 97], [55, 57], [55, 58], [55, 59], [55, 60], [55, 64], [55, 65], [55, 66], [55, 68], [55, 71], [55, 74], [55, 75], [55, 78], [55, 80], [55, 81], [55, 82], [55, 83], [55, 84], [55, 88], [55, 91], [55, 93], [55, 97], [56, 62], [56, 63], [56, 64], [56, 66], [56, 67], [56, 69], [56, 70], [56, 71], [56, 73], [56, 80], [56, 83], [56, 84], [56, 85], [56, 88], [56, 90], [56, 92], [56, 93], [56, 94], [57, 59], [57, 60], [57, 63], [57, 64], [57, 66], [57, 67], [57, 68], [57, 70], [57, 71], [57, 75], [57, 79], [57, 80], [57, 81], [57, 82], [57, 84], [57, 86], [57, 87], [57, 88], [57, 89], [57, 90], [57, 91], [57, 92], [57, 94], [57, 95], [58, 59], [58, 67], [58, 68], [58, 69], [58, 70], [58, 71], [58, 72], [58, 76], [58, 78], [58, 79], [58, 80], [58, 81], [58, 82], [58, 83], [58, 86], [58, 87], [58, 88], [58, 89], [58, 90], [58, 93], [58, 95], [58, 96], [58, 99], [59, 61], [59, 62], [59, 64], [59, 65], [59, 68], [59, 76], [59, 79], [59, 81], [59, 86], [59, 87], [59, 88], [59, 90], [59, 91], [59, 92], [59, 93], [59, 95], [59, 96], [59, 98], [60, 61], [60, 62], [60, 63], [60, 66], [60, 68], [60, 70], [60, 71], [60, 73], [60, 78], [60, 85], [60, 86], [60, 87], [60, 88], [60, 89], [60, 90], [60, 93], [60, 97], [60, 99], [61, 62], [61, 64], [61, 66], [61, 67], [61, 68], [61, 70], [61, 75], [61, 76], [61, 77], [61, 78], [61, 81], [61, 82], [61, 83], [61, 85], [61, 89], [61, 90], [61, 92], [61, 96], [61, 97], [61, 98], [61, 99], [62, 64], [62, 67], [62, 68], [62, 70], [62, 72], [62, 75], [62, 76], [62, 79], [62, 84], [62, 85], [62, 87], [62, 89], [62, 90], [62, 93], [62, 95], [62, 99], [63, 65], [63, 66], [63, 67], [63, 68], [63, 70], [63, 74], [63, 75], [63, 76], [63, 77], [63, 80], [63, 81], [63, 82], [63, 83], [63, 86], [63, 87], [63, 88], [63, 89], [63, 90], [63, 91], [63, 93], [63, 94], [63, 95], [63, 96], [63, 97], [63, 98], [63, 99], [64, 67], [64, 68], [64, 72], [64, 73], [64, 74], [64, 75], [64, 76], [64, 80], [64, 81], [64, 85], [64, 86], [64, 87], [64, 91], [64, 93], [64, 95], [65, 66], [65, 67], [65, 69], [65, 71], [65, 73], [65, 74], [65, 76], [65, 80], [65, 82], [65, 85], [65, 86], [65, 87], [65, 88], [65, 92], [65, 96], [65, 97], [65, 99], [66, 67], [66, 70], [66, 71], [66, 72], [66, 73], [66, 74], [66, 75], [66, 76], [66, 77], [66, 80], [66, 81], [66, 82], [66, 83], [66, 85], [66, 89], [66, 90], [66, 91], [66, 95], [66, 96], [66, 97], [66, 98], [66, 99], [67, 70], [67, 72], [67, 74], [67, 75], [67, 76], [67, 77], [67, 80], [67, 82], [67, 83], [67, 85], [67, 86], [67, 91], [67, 92], [67, 98], [68, 71], [68, 72], [68, 73], [68, 74], [68, 80], [68, 81], [68, 87], [68, 88], [68, 90], [68, 94], [68, 95], [68, 96], [68, 97], [68, 99], [69, 71], [69, 72], [69, 76], [69, 77], [69, 78], [69, 79], [69, 81], [69, 82], [69, 83], [69, 87], [69, 88], [69, 90], [69, 91], [69, 92], [69, 93], [69, 94], [69, 95], [69, 96], [70, 72], [70, 73], [70, 76], [70, 77], [70, 82], [70, 83], [70, 84], [70, 85], [70, 86], [70, 87], [70, 88], [70, 89], [70, 90], [70, 93], [70, 94], [70, 95], [70, 96], [70, 97], [70, 98], [70, 99], [71, 73], [71, 74], [71, 76], [71, 78], [71, 85], [71, 87], [71, 88], [71, 90], [71, 92], [71, 94], [71, 99], [72, 74], [72, 75], [72, 76], [72, 80], [72, 81], [72, 82], [72, 84], [72, 86], [72, 87], [72, 90], [72, 91], [72, 93], [72, 94], [72, 97], [73, 74], [73, 75], [73, 78], [73, 80], [73, 81], [73, 83], [73, 86], [73, 89], [73, 91], [73, 93], [73, 94], [73, 98], [73, 99], [74, 75], [74, 76], [74, 78], [74, 79], [74, 82], [74, 84], [74, 85], [74, 86], [74, 87], [74, 88], [74, 93], [74, 94], [74, 95], [74, 96], [74, 98], [75, 77], [75, 79], [75, 81], [75, 82], [75, 88], [75, 89], [75, 90], [75, 93], [75, 94], [75, 95], [75, 97], [75, 98], [75, 99], [76, 77], [76, 78], [76, 79], [76, 82], [76, 86], [76, 87], [76, 89], [76, 91], [76, 92], [76, 93], [76, 94], [76, 95], [76, 96], [76, 97], [76, 98], [76, 99], [77, 78], [77, 80], [77, 82], [77, 84], [77, 86], [77, 88], [77, 89], [77, 90], [77, 91], [77, 92], [77, 93], [77, 94], [77, 95], [77, 96], [77, 97], [77, 98], [77, 99], [78, 79], [78, 80], [78, 81], [78, 86], [78, 88], [78, 89], [78, 92], [78, 93], [78, 98], [79, 83], [79, 84], [79, 88], [79, 90], [79, 91], [79, 93], [79, 94], [79, 95], [79, 98], [79, 99], [80, 81], [80, 86], [80, 89], [80, 90], [80, 91], [80, 92], [80, 95], [80, 97], [80, 98], [80, 99], [81, 82], [81, 83], [81, 84], [81, 85], [81, 87], [81, 88], [81, 89], [81, 91], [81, 92], [81, 98], [82, 83], [82, 85], [82, 86], [82, 88], [82, 89], [82, 92], [82, 93], [82, 94], [82, 95], [82, 96], [82, 97], [82, 99], [83, 84], [83, 86], [83, 88], [83, 90], [83, 92], [83, 93], [83, 95], [83, 99], [84, 86], [84, 87], [84, 88], [84, 89], [84, 90], [84, 91], [84, 95], [84, 97], [84, 98], [85, 92], [85, 94], [85, 95], [85, 99], [86, 87], [86, 88], [86, 89], [86, 90], [86, 91], [86, 92], [86, 93], [86, 94], [86, 95], [86, 96], [86, 97], [86, 98], [86, 99], [87, 88], [87, 89], [87, 90], [87, 91], [87, 92], [87, 97], [87, 98], [88, 89], [88, 91], [88, 94], [88, 95], [88, 97], [88, 99], [89, 90], [89, 91], [89, 93], [89, 94], [89, 95], [89, 96], [89, 99], [90, 92], [90, 93], [90, 94], [90, 95], [90, 97], [91, 92], [91, 95], [91, 96], [91, 97], [91, 99], [92, 95], [92, 96], [92, 97], [92, 98], [92, 99], [93, 94], [93, 95], [93, 96], [93, 97], [93, 99], [94, 95], [94, 96], [94, 99], [95, 96], [95, 99], [96, 99]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s8/tests/run.py b/tasks/construct-nppc-clique-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-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-nppc-clique-l6-s8/tests/test.sh b/tasks/construct-nppc-clique-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-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-nppc-dominating-set-l3-s0/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l3-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-dominating-set-l3-s0/environment/instance.json b/tasks/construct-nppc-dominating-set-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5339cac6052da58e71619a5097f81ae96f99609d --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 50, "k": 20, "edges": [[0, 8], [0, 13], [0, 14], [0, 17], [0, 18], [0, 19], [0, 23], [0, 26], [0, 28], [0, 29], [0, 33], [0, 35], [0, 36], [0, 41], [0, 42], [0, 43], [0, 44], [0, 46], [0, 49], [1, 4], [1, 5], [1, 8], [1, 13], [1, 20], [1, 21], [1, 23], [1, 24], [1, 25], [1, 27], [1, 28], [1, 36], [1, 39], [1, 42], [1, 44], [2, 7], [2, 10], [2, 24], [2, 26], [2, 27], [2, 30], [2, 34], [2, 39], [2, 41], [2, 42], [2, 46], [2, 47], [2, 49], [3, 5], [3, 6], [3, 7], [3, 11], [3, 12], [3, 13], [3, 16], [3, 26], [3, 27], [3, 38], [3, 41], [3, 43], [3, 47], [3, 48], [4, 6], [4, 10], [4, 18], [4, 19], [4, 26], [4, 29], [4, 33], [4, 37], [4, 39], [4, 40], [4, 41], [4, 46], [5, 8], [5, 12], [5, 13], [5, 16], [5, 17], [5, 18], [5, 22], [5, 23], [5, 26], [5, 34], [5, 39], [5, 43], [5, 46], [5, 47], [5, 48], [6, 7], [6, 8], [6, 10], [6, 13], [6, 18], [6, 23], [6, 24], [6, 27], [6, 31], [6, 34], [6, 40], [6, 43], [6, 44], [7, 9], [7, 10], [7, 12], [7, 17], [7, 20], [7, 30], [7, 31], [7, 34], [7, 36], [7, 40], [7, 41], [7, 42], [7, 46], [8, 18], [8, 26], [8, 27], [8, 34], [8, 36], [8, 37], [8, 39], [8, 40], [8, 41], [8, 42], [8, 44], [8, 49], [9, 11], [9, 13], [9, 18], [9, 23], [9, 27], [9, 32], [9, 38], [9, 41], [9, 42], [10, 12], [10, 13], [10, 18], [10, 23], [10, 28], [10, 31], [10, 34], [10, 37], [10, 41], [10, 49], [11, 17], [11, 25], [11, 26], [11, 29], [11, 34], [11, 35], [11, 37], [11, 44], [11, 48], [12, 20], [12, 23], [12, 26], [12, 27], [12, 33], [12, 41], [12, 42], [12, 43], [12, 48], [12, 49], [13, 16], [13, 20], [13, 21], [13, 24], [13, 34], [13, 36], [13, 37], [13, 44], [13, 46], [13, 48], [13, 49], [14, 18], [14, 19], [14, 24], [14, 25], [14, 28], [14, 29], [14, 30], [14, 39], [14, 40], [14, 41], [14, 47], [14, 48], [14, 49], [15, 16], [15, 20], [15, 21], [15, 24], [15, 28], [15, 29], [15, 32], [15, 33], [15, 44], [16, 18], [16, 20], [16, 27], [16, 34], [16, 38], [16, 39], [16, 41], [16, 43], [16, 45], [16, 46], [16, 48], [17, 18], [17, 23], [17, 26], [17, 27], [17, 30], [17, 39], [17, 43], [17, 46], [18, 21], [18, 28], [18, 30], [18, 31], [18, 38], [18, 46], [19, 23], [19, 24], [19, 27], [19, 33], [19, 34], [19, 35], [19, 37], [19, 38], [19, 40], [19, 42], [19, 48], [20, 21], [20, 25], [20, 29], [20, 39], [20, 42], [20, 44], [20, 46], [20, 47], [21, 22], [21, 23], [21, 24], [21, 25], [21, 29], [21, 30], [21, 33], [21, 34], [21, 37], [21, 40], [21, 41], [21, 42], [21, 47], [22, 24], [22, 25], [22, 27], [22, 31], [22, 34], [22, 35], [22, 37], [22, 41], [22, 49], [23, 24], [23, 28], [23, 31], [23, 34], [23, 36], [23, 39], [23, 43], [23, 45], [23, 47], [23, 49], [24, 27], [24, 31], [24, 32], [24, 49], [25, 29], [25, 36], [25, 37], [25, 38], [25, 39], [25, 40], [25, 41], [25, 43], [26, 27], [26, 28], [26, 31], [26, 36], [26, 38], [26, 41], [26, 45], [26, 47], [26, 49], [27, 29], [27, 33], [27, 34], [27, 35], [27, 39], [27, 42], [27, 46], [28, 32], [28, 33], [28, 34], [28, 35], [28, 36], [29, 30], [29, 36], [29, 37], [29, 39], [29, 40], [29, 41], [29, 43], [29, 44], [29, 46], [29, 49], [30, 31], [30, 40], [30, 45], [31, 32], [31, 37], [31, 39], [31, 44], [31, 45], [32, 33], [32, 37], [32, 40], [32, 46], [32, 47], [32, 48], [33, 37], [33, 38], [33, 39], [33, 40], [33, 44], [33, 47], [34, 35], [34, 41], [34, 46], [35, 36], [35, 37], [35, 38], [35, 39], [35, 41], [35, 42], [35, 47], [35, 49], [36, 39], [36, 41], [36, 42], [36, 43], [36, 44], [36, 46], [36, 47], [37, 38], [37, 39], [37, 40], [37, 41], [37, 46], [37, 47], [38, 39], [38, 42], [38, 43], [38, 44], [38, 49], [39, 43], [39, 44], [39, 49], [40, 41], [40, 44], [40, 45], [40, 46], [40, 47], [41, 42], [41, 44], [41, 47], [42, 46], [42, 47], [43, 46], [43, 48], [44, 46], [45, 47], [45, 48], [45, 49], [46, 47], [46, 48], [47, 48], [47, 49], [48, 49]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l3-s0/solution/solve.sh b/tasks/construct-nppc-dominating-set-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1fa1b609f11fb698bec042f1a376b100c9da7b4f --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l3-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' +{"dominating_set": [0, 3, 5, 6, 7, 10, 14, 19, 20, 21, 23, 24, 26, 29, 34, 35, 38, 40, 44, 48]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l3-s0/tests/check.py b/tasks/construct-nppc-dominating-set-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l3-s0/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-l3-s0/tests/instance.json b/tasks/construct-nppc-dominating-set-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5339cac6052da58e71619a5097f81ae96f99609d --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 50, "k": 20, "edges": [[0, 8], [0, 13], [0, 14], [0, 17], [0, 18], [0, 19], [0, 23], [0, 26], [0, 28], [0, 29], [0, 33], [0, 35], [0, 36], [0, 41], [0, 42], [0, 43], [0, 44], [0, 46], [0, 49], [1, 4], [1, 5], [1, 8], [1, 13], [1, 20], [1, 21], [1, 23], [1, 24], [1, 25], [1, 27], [1, 28], [1, 36], [1, 39], [1, 42], [1, 44], [2, 7], [2, 10], [2, 24], [2, 26], [2, 27], [2, 30], [2, 34], [2, 39], [2, 41], [2, 42], [2, 46], [2, 47], [2, 49], [3, 5], [3, 6], [3, 7], [3, 11], [3, 12], [3, 13], [3, 16], [3, 26], [3, 27], [3, 38], [3, 41], [3, 43], [3, 47], [3, 48], [4, 6], [4, 10], [4, 18], [4, 19], [4, 26], [4, 29], [4, 33], [4, 37], [4, 39], [4, 40], [4, 41], [4, 46], [5, 8], [5, 12], [5, 13], [5, 16], [5, 17], [5, 18], [5, 22], [5, 23], [5, 26], [5, 34], [5, 39], [5, 43], [5, 46], [5, 47], [5, 48], [6, 7], [6, 8], [6, 10], [6, 13], [6, 18], [6, 23], [6, 24], [6, 27], [6, 31], [6, 34], [6, 40], [6, 43], [6, 44], [7, 9], [7, 10], [7, 12], [7, 17], [7, 20], [7, 30], [7, 31], [7, 34], [7, 36], [7, 40], [7, 41], [7, 42], [7, 46], [8, 18], [8, 26], [8, 27], [8, 34], [8, 36], [8, 37], [8, 39], [8, 40], [8, 41], [8, 42], [8, 44], [8, 49], [9, 11], [9, 13], [9, 18], [9, 23], [9, 27], [9, 32], [9, 38], [9, 41], [9, 42], [10, 12], [10, 13], [10, 18], [10, 23], [10, 28], [10, 31], [10, 34], [10, 37], [10, 41], [10, 49], [11, 17], [11, 25], [11, 26], [11, 29], [11, 34], [11, 35], [11, 37], [11, 44], [11, 48], [12, 20], [12, 23], [12, 26], [12, 27], [12, 33], [12, 41], [12, 42], [12, 43], [12, 48], [12, 49], [13, 16], [13, 20], [13, 21], [13, 24], [13, 34], [13, 36], [13, 37], [13, 44], [13, 46], [13, 48], [13, 49], [14, 18], [14, 19], [14, 24], [14, 25], [14, 28], [14, 29], [14, 30], [14, 39], [14, 40], [14, 41], [14, 47], [14, 48], [14, 49], [15, 16], [15, 20], [15, 21], [15, 24], [15, 28], [15, 29], [15, 32], [15, 33], [15, 44], [16, 18], [16, 20], [16, 27], [16, 34], [16, 38], [16, 39], [16, 41], [16, 43], [16, 45], [16, 46], [16, 48], [17, 18], [17, 23], [17, 26], [17, 27], [17, 30], [17, 39], [17, 43], [17, 46], [18, 21], [18, 28], [18, 30], [18, 31], [18, 38], [18, 46], [19, 23], [19, 24], [19, 27], [19, 33], [19, 34], [19, 35], [19, 37], [19, 38], [19, 40], [19, 42], [19, 48], [20, 21], [20, 25], [20, 29], [20, 39], [20, 42], [20, 44], [20, 46], [20, 47], [21, 22], [21, 23], [21, 24], [21, 25], [21, 29], [21, 30], [21, 33], [21, 34], [21, 37], [21, 40], [21, 41], [21, 42], [21, 47], [22, 24], [22, 25], [22, 27], [22, 31], [22, 34], [22, 35], [22, 37], [22, 41], [22, 49], [23, 24], [23, 28], [23, 31], [23, 34], [23, 36], [23, 39], [23, 43], [23, 45], [23, 47], [23, 49], [24, 27], [24, 31], [24, 32], [24, 49], [25, 29], [25, 36], [25, 37], [25, 38], [25, 39], [25, 40], [25, 41], [25, 43], [26, 27], [26, 28], [26, 31], [26, 36], [26, 38], [26, 41], [26, 45], [26, 47], [26, 49], [27, 29], [27, 33], [27, 34], [27, 35], [27, 39], [27, 42], [27, 46], [28, 32], [28, 33], [28, 34], [28, 35], [28, 36], [29, 30], [29, 36], [29, 37], [29, 39], [29, 40], [29, 41], [29, 43], [29, 44], [29, 46], [29, 49], [30, 31], [30, 40], [30, 45], [31, 32], [31, 37], [31, 39], [31, 44], [31, 45], [32, 33], [32, 37], [32, 40], [32, 46], [32, 47], [32, 48], [33, 37], [33, 38], [33, 39], [33, 40], [33, 44], [33, 47], [34, 35], [34, 41], [34, 46], [35, 36], [35, 37], [35, 38], [35, 39], [35, 41], [35, 42], [35, 47], [35, 49], [36, 39], [36, 41], [36, 42], [36, 43], [36, 44], [36, 46], [36, 47], [37, 38], [37, 39], [37, 40], [37, 41], [37, 46], [37, 47], [38, 39], [38, 42], [38, 43], [38, 44], [38, 49], [39, 43], [39, 44], [39, 49], [40, 41], [40, 44], [40, 45], [40, 46], [40, 47], [41, 42], [41, 44], [41, 47], [42, 46], [42, 47], [43, 46], [43, 48], [44, 46], [45, 47], [45, 48], [45, 49], [46, 47], [46, 48], [47, 48], [47, 49], [48, 49]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l3-s0/tests/run.py b/tasks/construct-nppc-dominating-set-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l3-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-dominating-set-l3-s0/tests/test.sh b/tasks/construct-nppc-dominating-set-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l3-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-dominating-set-l3-s7/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l3-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-dominating-set-l3-s7/environment/instance.json b/tasks/construct-nppc-dominating-set-l3-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f046489c2f761d9c0e3f2f6ce6dc5c9ce9299fc9 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l3-s7/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 50, "k": 20, "edges": [[0, 1], [0, 6], [0, 9], [0, 13], [0, 19], [0, 20], [0, 22], [0, 26], [0, 27], [0, 34], [0, 35], [0, 37], [0, 39], [0, 42], [1, 6], [1, 11], [1, 13], [1, 15], [1, 19], [1, 22], [1, 24], [1, 26], [1, 28], [1, 34], [1, 36], [1, 38], [1, 40], [1, 48], [2, 3], [2, 6], [2, 11], [2, 14], [2, 19], [2, 23], [2, 25], [2, 27], [2, 28], [2, 30], [2, 36], [2, 37], [2, 38], [2, 40], [2, 42], [2, 46], [2, 47], [2, 48], [3, 7], [3, 10], [3, 11], [3, 13], [3, 17], [3, 20], [3, 23], [3, 27], [3, 29], [3, 33], [3, 34], [3, 43], [3, 45], [3, 49], [4, 7], [4, 8], [4, 10], [4, 11], [4, 14], [4, 19], [4, 20], [4, 27], [4, 28], [4, 34], [4, 35], [4, 36], [4, 37], [4, 44], [5, 7], [5, 9], [5, 11], [5, 14], [5, 19], [5, 25], [5, 30], [5, 34], [5, 37], [5, 38], [5, 41], [5, 42], [5, 48], [6, 13], [6, 17], [6, 19], [6, 20], [6, 23], [6, 26], [6, 27], [6, 40], [6, 48], [6, 49], [7, 9], [7, 10], [7, 11], [7, 13], [7, 15], [7, 25], [7, 29], [7, 38], [7, 40], [7, 41], [7, 44], [7, 47], [8, 9], [8, 10], [8, 18], [8, 20], [8, 22], [8, 25], [8, 26], [8, 27], [8, 29], [8, 35], [8, 47], [8, 49], [9, 13], [9, 15], [9, 17], [9, 19], [9, 21], [9, 24], [9, 32], [9, 36], [9, 38], [9, 40], [9, 48], [10, 12], [10, 15], [10, 16], [10, 18], [10, 24], [10, 27], [10, 29], [10, 37], [10, 38], [10, 43], [10, 44], [10, 45], [10, 47], [10, 48], [11, 12], [11, 16], [11, 20], [11, 21], [11, 23], [11, 26], [11, 29], [11, 30], [11, 34], [11, 35], [11, 36], [11, 37], [11, 38], [11, 42], [11, 45], [11, 46], [11, 48], [11, 49], [12, 13], [12, 14], [12, 15], [12, 25], [12, 26], [12, 27], [12, 30], [12, 34], [12, 36], [12, 40], [12, 41], [12, 43], [12, 45], [12, 46], [12, 47], [12, 48], [12, 49], [13, 15], [13, 20], [13, 25], [13, 29], [13, 30], [13, 31], [13, 33], [13, 37], [13, 39], [13, 40], [13, 43], [13, 45], [13, 49], [14, 15], [14, 16], [14, 19], [14, 22], [14, 24], [14, 26], [14, 27], [14, 29], [14, 35], [14, 36], [14, 37], [14, 38], [14, 46], [14, 47], [15, 17], [15, 19], [15, 29], [15, 30], [15, 32], [15, 33], [15, 37], [15, 39], [15, 42], [15, 43], [15, 45], [16, 18], [16, 21], [16, 23], [16, 24], [16, 26], [16, 27], [16, 30], [16, 31], [16, 32], [16, 33], [16, 34], [16, 42], [16, 45], [17, 19], [17, 23], [17, 24], [17, 32], [17, 33], [17, 39], [17, 41], [17, 43], [17, 46], [17, 47], [18, 21], [18, 26], [18, 31], [18, 32], [18, 40], [19, 24], [19, 25], [19, 30], [19, 31], [19, 32], [19, 33], [19, 36], [19, 38], [19, 42], [19, 49], [20, 21], [20, 30], [20, 35], [20, 37], [20, 39], [20, 41], [20, 45], [20, 47], [21, 25], [21, 26], [21, 27], [21, 28], [21, 31], [21, 34], [21, 37], [21, 40], [21, 45], [21, 46], [21, 47], [22, 23], [22, 28], [22, 31], [22, 34], [22, 39], [22, 41], [22, 43], [22, 44], [22, 48], [23, 24], [23, 26], [23, 29], [23, 31], [23, 33], [23, 37], [23, 40], [23, 46], [24, 29], [24, 35], [24, 41], [24, 48], [25, 31], [25, 32], [25, 42], [25, 46], [26, 29], [26, 31], [26, 38], [26, 40], [26, 48], [27, 30], [27, 31], [27, 32], [27, 34], [27, 43], [27, 44], [27, 47], [27, 48], [28, 30], [28, 33], [28, 38], [28, 41], [28, 46], [29, 33], [29, 36], [29, 39], [29, 40], [29, 42], [29, 45], [29, 46], [29, 47], [30, 31], [30, 46], [30, 47], [31, 36], [31, 37], [31, 41], [31, 42], [31, 46], [31, 48], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 41], [32, 45], [32, 48], [32, 49], [33, 38], [33, 49], [34, 42], [34, 48], [35, 44], [35, 47], [36, 37], [36, 40], [36, 43], [36, 44], [37, 38], [37, 39], [37, 40], [37, 45], [37, 46], [37, 47], [37, 48], [37, 49], [38, 40], [38, 41], [38, 45], [38, 47], [39, 41], [39, 42], [39, 49], [40, 41], [40, 46], [41, 42], [41, 48], [42, 44], [42, 45], [42, 46], [43, 48], [43, 49], [44, 46], [45, 46], [45, 49], [46, 47], [46, 49]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l3-s7/solution/solve.sh b/tasks/construct-nppc-dominating-set-l3-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a416d35ee15689c204660906ced0123599047224 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [1, 4, 6, 9, 16, 18, 21, 22, 31, 32, 34, 35, 36, 37, 39, 41, 43, 44, 45, 47]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l3-s7/tests/check.py b/tasks/construct-nppc-dominating-set-l3-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l3-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-l3-s7/tests/instance.json b/tasks/construct-nppc-dominating-set-l3-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f046489c2f761d9c0e3f2f6ce6dc5c9ce9299fc9 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l3-s7/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 50, "k": 20, "edges": [[0, 1], [0, 6], [0, 9], [0, 13], [0, 19], [0, 20], [0, 22], [0, 26], [0, 27], [0, 34], [0, 35], [0, 37], [0, 39], [0, 42], [1, 6], [1, 11], [1, 13], [1, 15], [1, 19], [1, 22], [1, 24], [1, 26], [1, 28], [1, 34], [1, 36], [1, 38], [1, 40], [1, 48], [2, 3], [2, 6], [2, 11], [2, 14], [2, 19], [2, 23], [2, 25], [2, 27], [2, 28], [2, 30], [2, 36], [2, 37], [2, 38], [2, 40], [2, 42], [2, 46], [2, 47], [2, 48], [3, 7], [3, 10], [3, 11], [3, 13], [3, 17], [3, 20], [3, 23], [3, 27], [3, 29], [3, 33], [3, 34], [3, 43], [3, 45], [3, 49], [4, 7], [4, 8], [4, 10], [4, 11], [4, 14], [4, 19], [4, 20], [4, 27], [4, 28], [4, 34], [4, 35], [4, 36], [4, 37], [4, 44], [5, 7], [5, 9], [5, 11], [5, 14], [5, 19], [5, 25], [5, 30], [5, 34], [5, 37], [5, 38], [5, 41], [5, 42], [5, 48], [6, 13], [6, 17], [6, 19], [6, 20], [6, 23], [6, 26], [6, 27], [6, 40], [6, 48], [6, 49], [7, 9], [7, 10], [7, 11], [7, 13], [7, 15], [7, 25], [7, 29], [7, 38], [7, 40], [7, 41], [7, 44], [7, 47], [8, 9], [8, 10], [8, 18], [8, 20], [8, 22], [8, 25], [8, 26], [8, 27], [8, 29], [8, 35], [8, 47], [8, 49], [9, 13], [9, 15], [9, 17], [9, 19], [9, 21], [9, 24], [9, 32], [9, 36], [9, 38], [9, 40], [9, 48], [10, 12], [10, 15], [10, 16], [10, 18], [10, 24], [10, 27], [10, 29], [10, 37], [10, 38], [10, 43], [10, 44], [10, 45], [10, 47], [10, 48], [11, 12], [11, 16], [11, 20], [11, 21], [11, 23], [11, 26], [11, 29], [11, 30], [11, 34], [11, 35], [11, 36], [11, 37], [11, 38], [11, 42], [11, 45], [11, 46], [11, 48], [11, 49], [12, 13], [12, 14], [12, 15], [12, 25], [12, 26], [12, 27], [12, 30], [12, 34], [12, 36], [12, 40], [12, 41], [12, 43], [12, 45], [12, 46], [12, 47], [12, 48], [12, 49], [13, 15], [13, 20], [13, 25], [13, 29], [13, 30], [13, 31], [13, 33], [13, 37], [13, 39], [13, 40], [13, 43], [13, 45], [13, 49], [14, 15], [14, 16], [14, 19], [14, 22], [14, 24], [14, 26], [14, 27], [14, 29], [14, 35], [14, 36], [14, 37], [14, 38], [14, 46], [14, 47], [15, 17], [15, 19], [15, 29], [15, 30], [15, 32], [15, 33], [15, 37], [15, 39], [15, 42], [15, 43], [15, 45], [16, 18], [16, 21], [16, 23], [16, 24], [16, 26], [16, 27], [16, 30], [16, 31], [16, 32], [16, 33], [16, 34], [16, 42], [16, 45], [17, 19], [17, 23], [17, 24], [17, 32], [17, 33], [17, 39], [17, 41], [17, 43], [17, 46], [17, 47], [18, 21], [18, 26], [18, 31], [18, 32], [18, 40], [19, 24], [19, 25], [19, 30], [19, 31], [19, 32], [19, 33], [19, 36], [19, 38], [19, 42], [19, 49], [20, 21], [20, 30], [20, 35], [20, 37], [20, 39], [20, 41], [20, 45], [20, 47], [21, 25], [21, 26], [21, 27], [21, 28], [21, 31], [21, 34], [21, 37], [21, 40], [21, 45], [21, 46], [21, 47], [22, 23], [22, 28], [22, 31], [22, 34], [22, 39], [22, 41], [22, 43], [22, 44], [22, 48], [23, 24], [23, 26], [23, 29], [23, 31], [23, 33], [23, 37], [23, 40], [23, 46], [24, 29], [24, 35], [24, 41], [24, 48], [25, 31], [25, 32], [25, 42], [25, 46], [26, 29], [26, 31], [26, 38], [26, 40], [26, 48], [27, 30], [27, 31], [27, 32], [27, 34], [27, 43], [27, 44], [27, 47], [27, 48], [28, 30], [28, 33], [28, 38], [28, 41], [28, 46], [29, 33], [29, 36], [29, 39], [29, 40], [29, 42], [29, 45], [29, 46], [29, 47], [30, 31], [30, 46], [30, 47], [31, 36], [31, 37], [31, 41], [31, 42], [31, 46], [31, 48], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 41], [32, 45], [32, 48], [32, 49], [33, 38], [33, 49], [34, 42], [34, 48], [35, 44], [35, 47], [36, 37], [36, 40], [36, 43], [36, 44], [37, 38], [37, 39], [37, 40], [37, 45], [37, 46], [37, 47], [37, 48], [37, 49], [38, 40], [38, 41], [38, 45], [38, 47], [39, 41], [39, 42], [39, 49], [40, 41], [40, 46], [41, 42], [41, 48], [42, 44], [42, 45], [42, 46], [43, 48], [43, 49], [44, 46], [45, 46], [45, 49], [46, 47], [46, 49]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l3-s7/tests/run.py b/tasks/construct-nppc-dominating-set-l3-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-dominating-set-l3-s7/tests/test.sh b/tasks/construct-nppc-dominating-set-l3-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-independent-set-l3-s0/environment/Dockerfile b/tasks/construct-nppc-independent-set-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-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-independent-set-l3-s0/environment/instance.json b/tasks/construct-nppc-independent-set-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..20a25ba11957e9c93eb4158be67d614d5b8bc42f --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 8], [0, 10], [0, 19], [0, 21], [0, 22], [0, 23], [1, 3], [1, 4], [1, 8], [1, 9], [1, 10], [1, 19], [2, 3], [2, 4], [2, 8], [2, 9], [2, 19], [2, 22], [3, 8], [3, 10], [3, 16], [3, 19], [3, 23], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 13], [4, 20], [4, 21], [4, 22], [4, 23], [5, 8], [5, 9], [5, 15], [5, 16], [5, 18], [5, 19], [5, 22], [6, 9], [7, 8], [7, 10], [7, 18], [7, 19], [7, 21], [8, 10], [8, 11], [8, 13], [8, 17], [8, 21], [8, 22], [8, 23], [9, 13], [9, 14], [9, 16], [9, 17], [9, 18], [9, 23], [10, 12], [10, 14], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 23], [11, 16], [11, 18], [11, 19], [11, 21], [11, 22], [11, 23], [12, 16], [12, 21], [12, 22], [12, 23], [13, 16], [14, 16], [14, 18], [14, 19], [15, 16], [15, 18], [15, 19], [15, 21], [15, 23], [16, 21], [16, 23], [17, 19], [17, 23], [18, 19], [18, 20], [18, 22], [18, 23], [19, 21], [19, 23], [20, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s0/solution/solve.sh b/tasks/construct-nppc-independent-set-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d7f194f69e13bf84e51a4099a3ed828a436a3715 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-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' +{"independent_set": [0, 1, 2, 5, 6, 7, 11, 12, 13, 14, 17, 20]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l3-s0/tests/check.py b/tasks/construct-nppc-independent-set-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s0/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-s0/tests/instance.json b/tasks/construct-nppc-independent-set-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..20a25ba11957e9c93eb4158be67d614d5b8bc42f --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 8], [0, 10], [0, 19], [0, 21], [0, 22], [0, 23], [1, 3], [1, 4], [1, 8], [1, 9], [1, 10], [1, 19], [2, 3], [2, 4], [2, 8], [2, 9], [2, 19], [2, 22], [3, 8], [3, 10], [3, 16], [3, 19], [3, 23], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 13], [4, 20], [4, 21], [4, 22], [4, 23], [5, 8], [5, 9], [5, 15], [5, 16], [5, 18], [5, 19], [5, 22], [6, 9], [7, 8], [7, 10], [7, 18], [7, 19], [7, 21], [8, 10], [8, 11], [8, 13], [8, 17], [8, 21], [8, 22], [8, 23], [9, 13], [9, 14], [9, 16], [9, 17], [9, 18], [9, 23], [10, 12], [10, 14], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 23], [11, 16], [11, 18], [11, 19], [11, 21], [11, 22], [11, 23], [12, 16], [12, 21], [12, 22], [12, 23], [13, 16], [14, 16], [14, 18], [14, 19], [15, 16], [15, 18], [15, 19], [15, 21], [15, 23], [16, 21], [16, 23], [17, 19], [17, 23], [18, 19], [18, 20], [18, 22], [18, 23], [19, 21], [19, 23], [20, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s0/tests/run.py b/tasks/construct-nppc-independent-set-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-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-independent-set-l3-s0/tests/test.sh b/tasks/construct-nppc-independent-set-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-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-independent-set-l3-s7/environment/Dockerfile b/tasks/construct-nppc-independent-set-l3-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-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-nppc-independent-set-l3-s7/environment/instance.json b/tasks/construct-nppc-independent-set-l3-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bf9bc931d9dbdc232afea9072543ace39eb55db1 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s7/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 2], [0, 5], [0, 6], [0, 9], [0, 10], [0, 11], [0, 13], [0, 16], [0, 17], [0, 18], [0, 21], [0, 23], [1, 2], [1, 4], [1, 16], [1, 18], [2, 3], [2, 8], [2, 11], [2, 12], [2, 14], [2, 15], [2, 17], [2, 21], [2, 22], [2, 23], [3, 10], [3, 11], [3, 16], [3, 17], [3, 19], [4, 5], [4, 6], [4, 7], [4, 9], [4, 10], [4, 11], [4, 14], [4, 16], [4, 19], [4, 20], [4, 23], [5, 10], [5, 19], [6, 8], [6, 10], [6, 14], [6, 17], [6, 18], [7, 12], [7, 14], [7, 17], [7, 18], [8, 11], [8, 14], [8, 16], [8, 17], [8, 19], [8, 20], [8, 22], [9, 10], [9, 11], [9, 14], [9, 16], [9, 19], [10, 12], [10, 14], [10, 17], [10, 20], [10, 21], [10, 22], [11, 14], [11, 18], [11, 19], [11, 21], [11, 22], [11, 23], [12, 13], [12, 14], [12, 15], [12, 19], [12, 23], [13, 14], [13, 16], [13, 17], [14, 15], [14, 16], [14, 17], [14, 22], [14, 23], [15, 17], [15, 18], [15, 19], [16, 18], [16, 20], [16, 22], [17, 18], [17, 20], [18, 19], [18, 21], [18, 22], [19, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s7/solution/solve.sh b/tasks/construct-nppc-independent-set-l3-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cb381bf0acee34fc93726ac6199c17ac3f35dad --- /dev/null +++ b/tasks/construct-nppc-independent-set-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' +{"independent_set": [1, 3, 5, 6, 7, 9, 13, 15, 20, 21, 22, 23]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l3-s7/tests/check.py b/tasks/construct-nppc-independent-set-l3-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s7/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-s7/tests/instance.json b/tasks/construct-nppc-independent-set-l3-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bf9bc931d9dbdc232afea9072543ace39eb55db1 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s7/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 2], [0, 5], [0, 6], [0, 9], [0, 10], [0, 11], [0, 13], [0, 16], [0, 17], [0, 18], [0, 21], [0, 23], [1, 2], [1, 4], [1, 16], [1, 18], [2, 3], [2, 8], [2, 11], [2, 12], [2, 14], [2, 15], [2, 17], [2, 21], [2, 22], [2, 23], [3, 10], [3, 11], [3, 16], [3, 17], [3, 19], [4, 5], [4, 6], [4, 7], [4, 9], [4, 10], [4, 11], [4, 14], [4, 16], [4, 19], [4, 20], [4, 23], [5, 10], [5, 19], [6, 8], [6, 10], [6, 14], [6, 17], [6, 18], [7, 12], [7, 14], [7, 17], [7, 18], [8, 11], [8, 14], [8, 16], [8, 17], [8, 19], [8, 20], [8, 22], [9, 10], [9, 11], [9, 14], [9, 16], [9, 19], [10, 12], [10, 14], [10, 17], [10, 20], [10, 21], [10, 22], [11, 14], [11, 18], [11, 19], [11, 21], [11, 22], [11, 23], [12, 13], [12, 14], [12, 15], [12, 19], [12, 23], [13, 14], [13, 16], [13, 17], [14, 15], [14, 16], [14, 17], [14, 22], [14, 23], [15, 17], [15, 18], [15, 19], [16, 18], [16, 20], [16, 22], [17, 18], [17, 20], [18, 19], [18, 21], [18, 22], [19, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s7/tests/run.py b/tasks/construct-nppc-independent-set-l3-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-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-nppc-independent-set-l3-s7/tests/test.sh b/tasks/construct-nppc-independent-set-l3-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-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-nppc-independent-set-l3-s9/environment/Dockerfile b/tasks/construct-nppc-independent-set-l3-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-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-independent-set-l3-s9/environment/instance.json b/tasks/construct-nppc-independent-set-l3-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3efbd4d5064907ff8a70b0400b4aeaea8594b17d --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s9/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 2], [0, 8], [0, 13], [0, 20], [0, 22], [1, 2], [1, 4], [1, 5], [1, 8], [1, 10], [2, 3], [2, 4], [2, 7], [2, 8], [2, 10], [2, 11], [2, 12], [2, 15], [2, 16], [2, 18], [2, 19], [2, 21], [2, 22], [3, 4], [3, 6], [3, 8], [3, 10], [3, 13], [3, 20], [3, 22], [3, 23], [4, 5], [4, 7], [4, 8], [4, 12], [4, 13], [4, 14], [4, 18], [4, 19], [4, 21], [4, 22], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 18], [5, 19], [5, 20], [5, 21], [5, 23], [6, 7], [6, 18], [6, 19], [6, 21], [7, 8], [7, 10], [7, 11], [7, 17], [7, 20], [7, 21], [7, 22], [8, 9], [8, 12], [8, 13], [8, 18], [8, 22], [8, 23], [9, 13], [9, 20], [9, 22], [9, 23], [10, 11], [10, 14], [10, 15], [10, 16], [10, 18], [10, 20], [10, 23], [11, 12], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 23], [12, 13], [13, 14], [13, 16], [13, 18], [13, 19], [13, 23], [14, 20], [14, 23], [15, 20], [15, 22], [15, 23], [17, 22], [17, 23], [18, 20], [18, 22], [18, 23], [19, 20], [19, 22], [20, 21], [20, 22], [20, 23], [21, 22]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s9/solution/solve.sh b/tasks/construct-nppc-independent-set-l3-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b4efb2c8ce8f64a0a7fa142632e7cabaac2b0166 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-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' +{"independent_set": [0, 1, 3, 9, 12, 14, 15, 16, 17, 18, 19, 21]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l3-s9/tests/check.py b/tasks/construct-nppc-independent-set-l3-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s9/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-s9/tests/instance.json b/tasks/construct-nppc-independent-set-l3-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3efbd4d5064907ff8a70b0400b4aeaea8594b17d --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s9/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 2], [0, 8], [0, 13], [0, 20], [0, 22], [1, 2], [1, 4], [1, 5], [1, 8], [1, 10], [2, 3], [2, 4], [2, 7], [2, 8], [2, 10], [2, 11], [2, 12], [2, 15], [2, 16], [2, 18], [2, 19], [2, 21], [2, 22], [3, 4], [3, 6], [3, 8], [3, 10], [3, 13], [3, 20], [3, 22], [3, 23], [4, 5], [4, 7], [4, 8], [4, 12], [4, 13], [4, 14], [4, 18], [4, 19], [4, 21], [4, 22], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 18], [5, 19], [5, 20], [5, 21], [5, 23], [6, 7], [6, 18], [6, 19], [6, 21], [7, 8], [7, 10], [7, 11], [7, 17], [7, 20], [7, 21], [7, 22], [8, 9], [8, 12], [8, 13], [8, 18], [8, 22], [8, 23], [9, 13], [9, 20], [9, 22], [9, 23], [10, 11], [10, 14], [10, 15], [10, 16], [10, 18], [10, 20], [10, 23], [11, 12], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 23], [12, 13], [13, 14], [13, 16], [13, 18], [13, 19], [13, 23], [14, 20], [14, 23], [15, 20], [15, 22], [15, 23], [17, 22], [17, 23], [18, 20], [18, 22], [18, 23], [19, 20], [19, 22], [20, 21], [20, 22], [20, 23], [21, 22]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s9/tests/run.py b/tasks/construct-nppc-independent-set-l3-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-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-independent-set-l3-s9/tests/test.sh b/tasks/construct-nppc-independent-set-l3-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-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-l2-s1/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l2-s1/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a150e868cc64096807e6726d90f9b5469bc86945 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"a": 859, "b": 695, "c": 630079779, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s1/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..25293e9e2db57dfafa90757017cca16a87419802 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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' +{"x": 856, "y": 949} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l2-s1/tests/check.py b/tasks/construct-nppc-quad-diophantine-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-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-l2-s1/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a150e868cc64096807e6726d90f9b5469bc86945 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"a": 859, "b": 695, "c": 630079779, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s1/tests/run.py b/tasks/construct-nppc-quad-diophantine-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l2-s1/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l2-s6/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l2-s6/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..10d0723560c4bfc361f87a2a6a390b6b43f1f820 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"a": 603, "b": 963, "c": 2436381, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s6/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7ac5a9c037de5d16886748a6c2a833e9f125ac3d --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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' +{"x": 62, "y": 123} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l2-s6/tests/check.py b/tasks/construct-nppc-quad-diophantine-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-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-l2-s6/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..10d0723560c4bfc361f87a2a6a390b6b43f1f820 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"a": 603, "b": 963, "c": 2436381, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s6/tests/run.py b/tasks/construct-nppc-quad-diophantine-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l2-s6/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l6-s9/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l6-s9/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..987bb5a4e347c3084d37e85ec59ade23360b095e --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"a": 8710231508, "b": 3870768249, "c": 5236256626610643773153378280, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s9/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..881bae274562a82df009a1bf05044c7558d4321a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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' +{"x": 775346109, "y": 3863733268} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l6-s9/tests/check.py b/tasks/construct-nppc-quad-diophantine-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-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-l6-s9/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..987bb5a4e347c3084d37e85ec59ade23360b095e --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"a": 8710231508, "b": 3870768249, "c": 5236256626610643773153378280, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s9/tests/run.py b/tasks/construct-nppc-quad-diophantine-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l6-s9/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quadratic-congruence-l2-s1/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l2-s1/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a83728f975a4baba3a9a658b5758c76c195a4e65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"a": 768, "b": 2272, "c": 10179, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s1/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bee1fb6425bc96cce63716866b983632c809cf7b --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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' +{"x": 2720} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s1/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-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-l2-s1/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a83728f975a4baba3a9a658b5758c76c195a4e65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"a": 768, "b": 2272, "c": 10179, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s1/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l2-s1/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l2-s6/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l2-s6/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d08a6933bb6144f6bb668219a14f04e62b31c04a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"a": 5314, "b": 5481, "c": 14113, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s6/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..888919c6d36c5e19a09b593edf81d9256f80d75e --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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' +{"x": 5069} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s6/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-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-l2-s6/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d08a6933bb6144f6bb668219a14f04e62b31c04a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"a": 5314, "b": 5481, "c": 14113, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s6/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l2-s6/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l6-s9/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l6-s9/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2911a2a03f102324913fccf888ca61fdd4ca7e46 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"a": 54411231287342036586557456943569560239781274087, "b": 67903019655856310312545467541604458285820320537, "c": 48293723721277017789522921140705095396913061173, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s9/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..132b4901b75f63fc40a6dae66b47911a6bc7149e --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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' +{"x": 48292796818317024962048407435450600420549279215} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s9/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-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-l6-s9/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2911a2a03f102324913fccf888ca61fdd4ca7e46 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"a": 54411231287342036586557456943569560239781274087, "b": 67903019655856310312545467541604458285820320537, "c": 48293723721277017789522921140705095396913061173, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s9/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l6-s9/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-vertex-cover-l4-s2/environment/Dockerfile b/tasks/construct-nppc-vertex-cover-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l4-s2/environment/instance.json b/tasks/construct-nppc-vertex-cover-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..14a504d62d8ddeef708a7565f6b9cbcebd4d0f02 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 1], [0, 7], [0, 8], [0, 9], [0, 13], [0, 15], [0, 22], [0, 26], [0, 34], [0, 35], [0, 36], [0, 38], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 11], [1, 13], [1, 14], [1, 15], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 34], [1, 35], [1, 37], [1, 38], [1, 39], [2, 7], [2, 9], [2, 15], [2, 17], [2, 28], [2, 30], [2, 31], [2, 36], [2, 38], [3, 5], [3, 7], [3, 8], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 20], [3, 21], [3, 23], [3, 26], [3, 28], [3, 29], [3, 30], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [4, 7], [4, 8], [4, 13], [4, 18], [4, 28], [4, 30], [4, 34], [4, 35], [5, 7], [5, 13], [5, 15], [5, 17], [5, 18], [5, 26], [5, 28], [5, 29], [5, 38], [5, 39], [6, 8], [6, 13], [6, 15], [6, 26], [6, 28], [6, 29], [6, 30], [6, 31], [6, 34], [7, 8], [7, 9], [7, 13], [7, 14], [7, 17], [7, 18], [7, 22], [7, 25], [7, 26], [7, 28], [7, 30], [7, 33], [7, 36], [7, 37], [7, 38], [7, 39], [8, 9], [8, 11], [8, 14], [8, 16], [8, 17], [8, 18], [8, 22], [8, 25], [8, 26], [8, 27], [8, 29], [8, 30], [8, 31], [8, 33], [8, 35], [8, 37], [8, 38], [8, 39], [9, 10], [9, 13], [9, 15], [9, 17], [9, 18], [9, 21], [9, 22], [9, 24], [9, 26], [9, 27], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 36], [9, 38], [10, 13], [10, 17], [10, 18], [10, 22], [10, 26], [10, 28], [10, 29], [10, 31], [10, 36], [11, 13], [11, 15], [11, 22], [11, 28], [11, 30], [11, 31], [11, 34], [11, 39], [12, 13], [12, 17], [12, 18], [12, 22], [12, 28], [12, 29], [12, 31], [12, 35], [12, 39], [13, 14], [13, 15], [13, 17], [13, 19], [13, 20], [13, 22], [13, 23], [13, 24], [13, 26], [13, 28], [13, 31], [13, 33], [13, 34], [13, 35], [13, 36], [13, 37], [13, 38], [13, 39], [14, 15], [14, 17], [14, 18], [14, 28], [14, 30], [14, 35], [14, 36], [14, 38], [14, 39], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 26], [15, 28], [15, 29], [15, 30], [15, 32], [15, 33], [15, 34], [15, 35], [15, 36], [15, 38], [15, 39], [16, 22], [16, 26], [16, 28], [16, 29], [16, 34], [16, 36], [16, 38], [16, 39], [17, 18], [17, 21], [17, 22], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 35], [17, 38], [18, 19], [18, 22], [18, 25], [18, 26], [18, 28], [18, 30], [18, 33], [18, 34], [18, 35], [18, 36], [18, 37], [18, 38], [18, 39], [19, 22], [19, 28], [19, 29], [19, 31], [19, 35], [19, 38], [19, 39], [20, 26], [20, 30], [20, 34], [20, 35], [21, 22], [21, 29], [21, 30], [21, 31], [21, 34], [21, 35], [21, 38], [22, 23], [22, 26], [22, 27], [22, 28], [22, 30], [22, 31], [22, 33], [22, 34], [22, 39], [23, 31], [23, 34], [24, 29], [24, 34], [24, 35], [24, 36], [24, 38], [25, 28], [25, 29], [25, 30], [25, 31], [25, 34], [25, 35], [25, 39], [26, 27], [26, 28], [26, 29], [26, 30], [26, 31], [26, 36], [26, 38], [26, 39], [27, 30], [27, 35], [27, 38], [27, 39], [28, 30], [28, 31], [28, 32], [28, 34], [28, 35], [28, 36], [28, 37], [28, 38], [28, 39], [29, 30], [29, 31], [29, 33], [29, 35], [29, 36], [29, 38], [30, 31], [30, 33], [30, 34], [30, 36], [30, 38], [30, 39], [31, 32], [31, 34], [31, 35], [31, 36], [31, 38], [31, 39], [32, 34], [32, 35], [32, 36], [32, 38], [33, 34], [33, 36], [33, 38], [34, 35], [34, 36], [34, 37], [34, 38], [34, 39], [35, 36], [35, 37], [35, 39], [36, 37], [36, 38], [36, 39], [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-s2/solution/solve.sh b/tasks/construct-nppc-vertex-cover-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e99fe414858418c5995eb4cd8419e4c0ea39e173 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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' +{"cover": [1, 3, 7, 8, 9, 13, 15, 17, 18, 22, 26, 28, 29, 30, 31, 34, 35, 36, 38, 39]} +RLMATH_EOF diff --git a/tasks/construct-nppc-vertex-cover-l4-s2/tests/check.py b/tasks/construct-nppc-vertex-cover-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d8ed740cc660c4837d941a8d70ea394c3bc9f69e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s2/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-s2/tests/instance.json b/tasks/construct-nppc-vertex-cover-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..14a504d62d8ddeef708a7565f6b9cbcebd4d0f02 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 1], [0, 7], [0, 8], [0, 9], [0, 13], [0, 15], [0, 22], [0, 26], [0, 34], [0, 35], [0, 36], [0, 38], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 11], [1, 13], [1, 14], [1, 15], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 34], [1, 35], [1, 37], [1, 38], [1, 39], [2, 7], [2, 9], [2, 15], [2, 17], [2, 28], [2, 30], [2, 31], [2, 36], [2, 38], [3, 5], [3, 7], [3, 8], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 20], [3, 21], [3, 23], [3, 26], [3, 28], [3, 29], [3, 30], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [4, 7], [4, 8], [4, 13], [4, 18], [4, 28], [4, 30], [4, 34], [4, 35], [5, 7], [5, 13], [5, 15], [5, 17], [5, 18], [5, 26], [5, 28], [5, 29], [5, 38], [5, 39], [6, 8], [6, 13], [6, 15], [6, 26], [6, 28], [6, 29], [6, 30], [6, 31], [6, 34], [7, 8], [7, 9], [7, 13], [7, 14], [7, 17], [7, 18], [7, 22], [7, 25], [7, 26], [7, 28], [7, 30], [7, 33], [7, 36], [7, 37], [7, 38], [7, 39], [8, 9], [8, 11], [8, 14], [8, 16], [8, 17], [8, 18], [8, 22], [8, 25], [8, 26], [8, 27], [8, 29], [8, 30], [8, 31], [8, 33], [8, 35], [8, 37], [8, 38], [8, 39], [9, 10], [9, 13], [9, 15], [9, 17], [9, 18], [9, 21], [9, 22], [9, 24], [9, 26], [9, 27], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 36], [9, 38], [10, 13], [10, 17], [10, 18], [10, 22], [10, 26], [10, 28], [10, 29], [10, 31], [10, 36], [11, 13], [11, 15], [11, 22], [11, 28], [11, 30], [11, 31], [11, 34], [11, 39], [12, 13], [12, 17], [12, 18], [12, 22], [12, 28], [12, 29], [12, 31], [12, 35], [12, 39], [13, 14], [13, 15], [13, 17], [13, 19], [13, 20], [13, 22], [13, 23], [13, 24], [13, 26], [13, 28], [13, 31], [13, 33], [13, 34], [13, 35], [13, 36], [13, 37], [13, 38], [13, 39], [14, 15], [14, 17], [14, 18], [14, 28], [14, 30], [14, 35], [14, 36], [14, 38], [14, 39], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 26], [15, 28], [15, 29], [15, 30], [15, 32], [15, 33], [15, 34], [15, 35], [15, 36], [15, 38], [15, 39], [16, 22], [16, 26], [16, 28], [16, 29], [16, 34], [16, 36], [16, 38], [16, 39], [17, 18], [17, 21], [17, 22], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 35], [17, 38], [18, 19], [18, 22], [18, 25], [18, 26], [18, 28], [18, 30], [18, 33], [18, 34], [18, 35], [18, 36], [18, 37], [18, 38], [18, 39], [19, 22], [19, 28], [19, 29], [19, 31], [19, 35], [19, 38], [19, 39], [20, 26], [20, 30], [20, 34], [20, 35], [21, 22], [21, 29], [21, 30], [21, 31], [21, 34], [21, 35], [21, 38], [22, 23], [22, 26], [22, 27], [22, 28], [22, 30], [22, 31], [22, 33], [22, 34], [22, 39], [23, 31], [23, 34], [24, 29], [24, 34], [24, 35], [24, 36], [24, 38], [25, 28], [25, 29], [25, 30], [25, 31], [25, 34], [25, 35], [25, 39], [26, 27], [26, 28], [26, 29], [26, 30], [26, 31], [26, 36], [26, 38], [26, 39], [27, 30], [27, 35], [27, 38], [27, 39], [28, 30], [28, 31], [28, 32], [28, 34], [28, 35], [28, 36], [28, 37], [28, 38], [28, 39], [29, 30], [29, 31], [29, 33], [29, 35], [29, 36], [29, 38], [30, 31], [30, 33], [30, 34], [30, 36], [30, 38], [30, 39], [31, 32], [31, 34], [31, 35], [31, 36], [31, 38], [31, 39], [32, 34], [32, 35], [32, 36], [32, 38], [33, 34], [33, 36], [33, 38], [34, 35], [34, 36], [34, 37], [34, 38], [34, 39], [35, 36], [35, 37], [35, 39], [36, 37], [36, 38], [36, 39], [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-s2/tests/run.py b/tasks/construct-nppc-vertex-cover-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l4-s2/tests/test.sh b/tasks/construct-nppc-vertex-cover-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l4-s5/environment/Dockerfile b/tasks/construct-nppc-vertex-cover-l4-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l4-s5/environment/instance.json b/tasks/construct-nppc-vertex-cover-l4-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a81dc2958da0de609cbda522286410e10a9a59dd --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s5/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 7], [0, 8], [0, 10], [0, 11], [0, 12], [0, 14], [0, 16], [0, 17], [0, 21], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 30], [0, 32], [0, 33], [0, 34], [0, 35], [0, 36], [0, 37], [0, 39], [1, 2], [1, 4], [1, 6], [1, 9], [1, 10], [1, 11], [1, 12], [1, 14], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 34], [1, 36], [1, 37], [1, 38], [1, 39], [2, 5], [2, 6], [2, 10], [2, 11], [2, 12], [2, 14], [2, 17], [2, 20], [2, 21], [2, 22], [2, 26], [2, 27], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 38], [3, 10], [3, 11], [3, 14], [3, 17], [3, 21], [3, 23], [3, 26], [3, 29], [3, 32], [3, 38], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 14], [4, 15], [4, 16], [4, 17], [4, 19], [4, 21], [4, 22], [4, 24], [4, 26], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 35], [4, 36], [4, 38], [4, 39], [5, 11], [5, 16], [5, 17], [5, 26], [5, 29], [5, 32], [5, 33], [5, 38], [6, 8], [6, 10], [6, 12], [6, 15], [6, 16], [6, 17], [6, 18], [6, 20], [6, 21], [6, 23], [6, 25], [6, 26], [6, 28], [6, 30], [6, 31], [6, 32], [6, 33], [6, 34], [6, 36], [6, 37], [6, 38], [6, 39], [7, 10], [7, 16], [7, 21], [7, 23], [7, 26], [7, 29], [7, 30], [7, 33], [8, 16], [8, 21], [8, 26], [8, 29], [8, 32], [9, 14], [9, 16], [9, 17], [9, 23], [9, 29], [9, 31], [9, 32], [9, 33], [10, 11], [10, 15], [10, 16], [10, 17], [10, 23], [10, 26], [10, 27], [10, 30], [10, 31], [10, 32], [10, 33], [10, 34], [10, 36], [10, 37], [10, 39], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 18], [11, 22], [11, 23], [11, 24], [11, 30], [11, 31], [11, 32], [11, 33], [11, 34], [11, 35], [11, 36], [11, 38], [12, 14], [12, 16], [12, 17], [12, 23], [12, 29], [12, 30], [12, 31], [13, 14], [13, 16], [13, 17], [13, 22], [13, 29], [13, 30], [14, 16], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 37], [14, 38], [15, 22], [15, 26], [15, 32], [16, 18], [16, 23], [16, 24], [16, 26], [16, 30], [16, 31], [16, 32], [16, 33], [16, 36], [16, 38], [16, 39], [17, 21], [17, 22], [17, 23], [17, 24], [17, 32], [17, 33], [17, 35], [17, 37], [17, 39], [18, 22], [18, 23], [18, 31], [18, 32], [18, 33], [19, 22], [19, 23], [19, 26], [19, 29], [19, 30], [19, 33], [20, 21], [20, 23], [20, 26], [20, 31], [20, 32], [21, 23], [21, 24], [21, 26], [21, 27], [21, 30], [21, 31], [21, 32], [21, 35], [21, 36], [21, 38], [21, 39], [22, 23], [22, 32], [22, 33], [22, 34], [22, 35], [22, 39], [23, 28], [23, 29], [23, 31], [23, 34], [23, 35], [23, 36], [23, 38], [23, 39], [24, 30], [24, 32], [24, 38], [25, 26], [25, 30], [25, 31], [25, 38], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 36], [26, 38], [27, 30], [27, 32], [27, 33], [27, 38], [28, 30], [28, 38], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 36], [29, 37], [29, 38], [29, 39], [30, 31], [30, 32], [30, 36], [30, 38], [30, 39], [31, 32], [31, 34], [31, 35], [31, 36], [31, 37], [31, 38], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [33, 36], [33, 37], [33, 38], [34, 38], [35, 38]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s5/solution/solve.sh b/tasks/construct-nppc-vertex-cover-l4-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..80989e2cce201366228cee5b19a95c62e16961c1 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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' +{"cover": [0, 1, 2, 4, 6, 10, 11, 14, 16, 17, 21, 22, 23, 26, 29, 30, 31, 32, 33, 38]} +RLMATH_EOF diff --git a/tasks/construct-nppc-vertex-cover-l4-s5/tests/check.py b/tasks/construct-nppc-vertex-cover-l4-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d8ed740cc660c4837d941a8d70ea394c3bc9f69e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s5/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-s5/tests/instance.json b/tasks/construct-nppc-vertex-cover-l4-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a81dc2958da0de609cbda522286410e10a9a59dd --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s5/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 7], [0, 8], [0, 10], [0, 11], [0, 12], [0, 14], [0, 16], [0, 17], [0, 21], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 30], [0, 32], [0, 33], [0, 34], [0, 35], [0, 36], [0, 37], [0, 39], [1, 2], [1, 4], [1, 6], [1, 9], [1, 10], [1, 11], [1, 12], [1, 14], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 34], [1, 36], [1, 37], [1, 38], [1, 39], [2, 5], [2, 6], [2, 10], [2, 11], [2, 12], [2, 14], [2, 17], [2, 20], [2, 21], [2, 22], [2, 26], [2, 27], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 38], [3, 10], [3, 11], [3, 14], [3, 17], [3, 21], [3, 23], [3, 26], [3, 29], [3, 32], [3, 38], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 14], [4, 15], [4, 16], [4, 17], [4, 19], [4, 21], [4, 22], [4, 24], [4, 26], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 35], [4, 36], [4, 38], [4, 39], [5, 11], [5, 16], [5, 17], [5, 26], [5, 29], [5, 32], [5, 33], [5, 38], [6, 8], [6, 10], [6, 12], [6, 15], [6, 16], [6, 17], [6, 18], [6, 20], [6, 21], [6, 23], [6, 25], [6, 26], [6, 28], [6, 30], [6, 31], [6, 32], [6, 33], [6, 34], [6, 36], [6, 37], [6, 38], [6, 39], [7, 10], [7, 16], [7, 21], [7, 23], [7, 26], [7, 29], [7, 30], [7, 33], [8, 16], [8, 21], [8, 26], [8, 29], [8, 32], [9, 14], [9, 16], [9, 17], [9, 23], [9, 29], [9, 31], [9, 32], [9, 33], [10, 11], [10, 15], [10, 16], [10, 17], [10, 23], [10, 26], [10, 27], [10, 30], [10, 31], [10, 32], [10, 33], [10, 34], [10, 36], [10, 37], [10, 39], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 18], [11, 22], [11, 23], [11, 24], [11, 30], [11, 31], [11, 32], [11, 33], [11, 34], [11, 35], [11, 36], [11, 38], [12, 14], [12, 16], [12, 17], [12, 23], [12, 29], [12, 30], [12, 31], [13, 14], [13, 16], [13, 17], [13, 22], [13, 29], [13, 30], [14, 16], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 37], [14, 38], [15, 22], [15, 26], [15, 32], [16, 18], [16, 23], [16, 24], [16, 26], [16, 30], [16, 31], [16, 32], [16, 33], [16, 36], [16, 38], [16, 39], [17, 21], [17, 22], [17, 23], [17, 24], [17, 32], [17, 33], [17, 35], [17, 37], [17, 39], [18, 22], [18, 23], [18, 31], [18, 32], [18, 33], [19, 22], [19, 23], [19, 26], [19, 29], [19, 30], [19, 33], [20, 21], [20, 23], [20, 26], [20, 31], [20, 32], [21, 23], [21, 24], [21, 26], [21, 27], [21, 30], [21, 31], [21, 32], [21, 35], [21, 36], [21, 38], [21, 39], [22, 23], [22, 32], [22, 33], [22, 34], [22, 35], [22, 39], [23, 28], [23, 29], [23, 31], [23, 34], [23, 35], [23, 36], [23, 38], [23, 39], [24, 30], [24, 32], [24, 38], [25, 26], [25, 30], [25, 31], [25, 38], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 36], [26, 38], [27, 30], [27, 32], [27, 33], [27, 38], [28, 30], [28, 38], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 36], [29, 37], [29, 38], [29, 39], [30, 31], [30, 32], [30, 36], [30, 38], [30, 39], [31, 32], [31, 34], [31, 35], [31, 36], [31, 37], [31, 38], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [33, 36], [33, 37], [33, 38], [34, 38], [35, 38]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s5/tests/run.py b/tasks/construct-nppc-vertex-cover-l4-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l4-s5/tests/test.sh b/tasks/construct-nppc-vertex-cover-l4-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-rg-graph-color-l2-s1/environment/Dockerfile b/tasks/construct-rg-graph-color-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l2-s1/environment/instance.json b/tasks/construct-rg-graph-color-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..58ce37d81a92f575270df20db387e4f056a32bc3 --- /dev/null +++ b/tasks/construct-rg-graph-color-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 4, "edges": [[0, 4], [0, 6], [0, 7], [1, 2], [1, 7], [2, 8], [2, 9], [3, 8], [4, 9], [5, 6], [5, 7], [5, 8], [6, 8], [7, 8]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l2-s1/solution/solve.sh b/tasks/construct-rg-graph-color-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..403435a69eac597a59fc336a396bf565629796da --- /dev/null +++ b/tasks/construct-rg-graph-color-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' +{"coloring": [1, 1, 2, 1, 2, 1, 2, 2, 3, 1]} +RLMATH_EOF diff --git a/tasks/construct-rg-graph-color-l2-s1/tests/check.py b/tasks/construct-rg-graph-color-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e9328912405d1c894970c90415be62bf9556ed36 --- /dev/null +++ b/tasks/construct-rg-graph-color-l2-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-l2-s1/tests/instance.json b/tasks/construct-rg-graph-color-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..58ce37d81a92f575270df20db387e4f056a32bc3 --- /dev/null +++ b/tasks/construct-rg-graph-color-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 4, "edges": [[0, 4], [0, 6], [0, 7], [1, 2], [1, 7], [2, 8], [2, 9], [3, 8], [4, 9], [5, 6], [5, 7], [5, 8], [6, 8], [7, 8]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l2-s1/tests/run.py b/tasks/construct-rg-graph-color-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l2-s1/tests/test.sh b/tasks/construct-rg-graph-color-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l6-s9/environment/Dockerfile b/tasks/construct-rg-graph-color-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l6-s9/environment/instance.json b/tasks/construct-rg-graph-color-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4b71ec13f90851aa473d68c5e1ad219f8c6f376e --- /dev/null +++ b/tasks/construct-rg-graph-color-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"num_vertices": 40, "num_colors": 3, "edges": [[0, 14], [0, 19], [1, 4], [1, 15], [1, 30], [2, 8], [2, 17], [2, 21], [3, 21], [3, 25], [3, 33], [3, 39], [4, 13], [4, 26], [4, 32], [4, 36], [5, 12], [5, 14], [6, 16], [6, 29], [7, 25], [7, 29], [8, 13], [8, 28], [8, 33], [8, 34], [9, 12], [9, 27], [9, 34], [10, 11], [10, 14], [10, 15], [10, 32], [11, 12], [11, 21], [11, 22], [11, 33], [11, 34], [12, 20], [12, 24], [13, 20], [13, 30], [13, 32], [13, 37], [14, 16], [14, 25], [14, 33], [15, 22], [15, 36], [16, 31], [16, 38], [17, 24], [17, 35], [18, 30], [20, 21], [21, 22], [22, 28], [22, 30], [22, 34], [23, 25], [23, 32], [24, 25], [25, 27], [26, 32], [27, 33], [27, 34], [28, 31], [30, 36], [31, 36], [31, 37]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l6-s9/solution/solve.sh b/tasks/construct-rg-graph-color-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..08f6001a8f6de22a3a844e2e6e604048b8c91493 --- /dev/null +++ b/tasks/construct-rg-graph-color-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' +{"coloring": [1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 2, 3, 1, 2, 2, 3, 2, 1, 2, 2, 3, 1, 1, 1, 3, 1, 2, 3, 2, 2, 1, 3, 3, 3, 1, 3, 2, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rg-graph-color-l6-s9/tests/check.py b/tasks/construct-rg-graph-color-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e9328912405d1c894970c90415be62bf9556ed36 --- /dev/null +++ b/tasks/construct-rg-graph-color-l6-s9/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-l6-s9/tests/instance.json b/tasks/construct-rg-graph-color-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4b71ec13f90851aa473d68c5e1ad219f8c6f376e --- /dev/null +++ b/tasks/construct-rg-graph-color-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"num_vertices": 40, "num_colors": 3, "edges": [[0, 14], [0, 19], [1, 4], [1, 15], [1, 30], [2, 8], [2, 17], [2, 21], [3, 21], [3, 25], [3, 33], [3, 39], [4, 13], [4, 26], [4, 32], [4, 36], [5, 12], [5, 14], [6, 16], [6, 29], [7, 25], [7, 29], [8, 13], [8, 28], [8, 33], [8, 34], [9, 12], [9, 27], [9, 34], [10, 11], [10, 14], [10, 15], [10, 32], [11, 12], [11, 21], [11, 22], [11, 33], [11, 34], [12, 20], [12, 24], [13, 20], [13, 30], [13, 32], [13, 37], [14, 16], [14, 25], [14, 33], [15, 22], [15, 36], [16, 31], [16, 38], [17, 24], [17, 35], [18, 30], [20, 21], [21, 22], [22, 28], [22, 30], [22, 34], [23, 25], [23, 32], [24, 25], [25, 27], [26, 32], [27, 33], [27, 34], [28, 31], [30, 36], [31, 36], [31, 37]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l6-s9/tests/run.py b/tasks/construct-rg-graph-color-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l6-s9/tests/test.sh b/tasks/construct-rg-graph-color-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-intermediate-integration-l1-s4/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s4/environment/instance.json b/tasks/construct-rg-intermediate-integration-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..243493818a4409a7d6c7b45ed2b46edfdbf81833 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "2*(9*x + 5)**3", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s4/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c2c510e5c089ce6503e7b8a086e7163e5f195235 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "729*x**4/2 + 810*x**3 + 675*x**2 + 250*x + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l1-s4/tests/check.py b/tasks/construct-rg-intermediate-integration-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-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-l1-s4/tests/instance.json b/tasks/construct-rg-intermediate-integration-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..243493818a4409a7d6c7b45ed2b46edfdbf81833 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "2*(9*x + 5)**3", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s4/tests/run.py b/tasks/construct-rg-intermediate-integration-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-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-l1-s4/tests/test.sh b/tasks/construct-rg-intermediate-integration-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s2/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s2/environment/instance.json b/tasks/construct-rg-intermediate-integration-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f9f1a7ff30bbecf183f050936beedca5ac568111 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "2*x*sin(3*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-s2/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..47d9e356abab18cc498fe7d0600f84374d21bcf6 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "-2*x*cos(3*x)/3 + 2*sin(3*x)/9 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l5-s2/tests/check.py b/tasks/construct-rg-intermediate-integration-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s2/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-s2/tests/instance.json b/tasks/construct-rg-intermediate-integration-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f9f1a7ff30bbecf183f050936beedca5ac568111 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "2*x*sin(3*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-s2/tests/run.py b/tasks/construct-rg-intermediate-integration-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s2/tests/test.sh b/tasks/construct-rg-intermediate-integration-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s5/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-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-l5-s5/environment/instance.json b/tasks/construct-rg-intermediate-integration-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e398a9eedfa02bd8639d1530d9a2b0991325b956 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "3*x*cos(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-s5/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9dba5ac9b413d0e062c9482e649a211538cb963d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-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": "3*x*sin(x) + 3*cos(x) + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l5-s5/tests/check.py b/tasks/construct-rg-intermediate-integration-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-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-l5-s5/tests/instance.json b/tasks/construct-rg-intermediate-integration-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e398a9eedfa02bd8639d1530d9a2b0991325b956 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "3*x*cos(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-s5/tests/run.py b/tasks/construct-rg-intermediate-integration-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-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-l5-s5/tests/test.sh b/tasks/construct-rg-intermediate-integration-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-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-simple-integration-l2-s0/environment/Dockerfile b/tasks/construct-rg-simple-integration-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l2-s0/environment/instance.json b/tasks/construct-rg-simple-integration-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a3a46b00ff33a5553522fa3d076c6c38dc68606f --- /dev/null +++ b/tasks/construct-rg-simple-integration-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "7*x**4 - 3*x**2", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l2-s0/solution/solve.sh b/tasks/construct-rg-simple-integration-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..92ebab78e899a23f8dd766b7b00cbee500db746f --- /dev/null +++ b/tasks/construct-rg-simple-integration-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' +{"antiderivative": "7*x**5/5 - x**3 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l2-s0/tests/check.py b/tasks/construct-rg-simple-integration-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l2-s0/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-l2-s0/tests/instance.json b/tasks/construct-rg-simple-integration-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a3a46b00ff33a5553522fa3d076c6c38dc68606f --- /dev/null +++ b/tasks/construct-rg-simple-integration-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "7*x**4 - 3*x**2", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l2-s0/tests/run.py b/tasks/construct-rg-simple-integration-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l2-s0/tests/test.sh b/tasks/construct-rg-simple-integration-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l2-s7/environment/Dockerfile b/tasks/construct-rg-simple-integration-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l2-s7/environment/instance.json b/tasks/construct-rg-simple-integration-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3df9c2e79ef06c354e620f3e2ff83eb33970b596 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "-21*X**5/2 + 4*X/3 - 1/4", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l2-s7/solution/solve.sh b/tasks/construct-rg-simple-integration-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..942188a0c93d74161345b340ae3ad0d5f16564c7 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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' +{"antiderivative": "-7*X**6/4 + 2*X**2/3 - X/4 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l2-s7/tests/check.py b/tasks/construct-rg-simple-integration-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l2-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-l2-s7/tests/instance.json b/tasks/construct-rg-simple-integration-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3df9c2e79ef06c354e620f3e2ff83eb33970b596 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "-21*X**5/2 + 4*X/3 - 1/4", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l2-s7/tests/run.py b/tasks/construct-rg-simple-integration-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l2-s7/tests/test.sh b/tasks/construct-rg-simple-integration-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l6-s6/environment/Dockerfile b/tasks/construct-rg-simple-integration-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l6-s6/environment/instance.json b/tasks/construct-rg-simple-integration-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4a68f885d752c4a0ea69bdb461eb882d723819c9 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "33*X**10 - 70*X**6 - 12*X - 8 - 2/(5*X**2) - 129/(20*X**7)", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l6-s6/solution/solve.sh b/tasks/construct-rg-simple-integration-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..337e1dfc7aa7692c432b69e21afec3aff834ecbb --- /dev/null +++ b/tasks/construct-rg-simple-integration-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' +{"antiderivative": "3*X**11 - 10*X**7 - 6*X**2 - 8*X + 2/(5*X) + 43/(40*X**6) + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l6-s6/tests/check.py b/tasks/construct-rg-simple-integration-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l6-s6/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-l6-s6/tests/instance.json b/tasks/construct-rg-simple-integration-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4a68f885d752c4a0ea69bdb461eb882d723819c9 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "33*X**10 - 70*X**6 - 12*X - 8 - 2/(5*X**2) - 129/(20*X**7)", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l6-s6/tests/run.py b/tasks/construct-rg-simple-integration-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l6-s6/tests/test.sh b/tasks/construct-rg-simple-integration-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l6-s8/environment/Dockerfile b/tasks/construct-rg-simple-integration-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l6-s8/environment/instance.json b/tasks/construct-rg-simple-integration-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bf4d7f37e7b75b1fa3b45358df7607da1793d842 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "45*x**9 - 30*x**4/7 - 18*x - 9/x**4 + 16/(3*x**5) + 24/x**7 - 81/x**10", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l6-s8/solution/solve.sh b/tasks/construct-rg-simple-integration-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..83e2b01f9bf6295a946f538b28e937d670bdfa21 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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' +{"antiderivative": "9*x**10/2 - 6*x**5/7 - 9*x**2 + 3/x**3 - 4/(3*x**4) - 4/x**6 + 9/x**9 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l6-s8/tests/check.py b/tasks/construct-rg-simple-integration-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l6-s8/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-l6-s8/tests/instance.json b/tasks/construct-rg-simple-integration-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bf4d7f37e7b75b1fa3b45358df7607da1793d842 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "45*x**9 - 30*x**4/7 - 18*x - 9/x**4 + 16/(3*x**5) + 24/x**7 - 81/x**10", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l6-s8/tests/run.py b/tasks/construct-rg-simple-integration-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l6-s8/tests/test.sh b/tasks/construct-rg-simple-integration-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-antiderivative-l3-s0/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l3-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-l3-s0/environment/instance.json b/tasks/construct-rlve-antiderivative-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..40fb489eced61596e717e1d117fddb318f116bbc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "(x*cos(x) + sin(x))*sin(x*sin(x))*sin(sin(cos(x*sin(x))))*cos(cos(x*sin(x)))", "max_ops": 40, "max_len": 860, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l3-s0/solution/solve.sh b/tasks/construct-rlve-antiderivative-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..48300ffa8a920dd661c7fc791aa4777d60e58804 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l3-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(sin(cos(x*sin(x))))"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l3-s0/tests/check.py b/tasks/construct-rlve-antiderivative-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l3-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-l3-s0/tests/instance.json b/tasks/construct-rlve-antiderivative-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..40fb489eced61596e717e1d117fddb318f116bbc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "(x*cos(x) + sin(x))*sin(x*sin(x))*sin(sin(cos(x*sin(x))))*cos(cos(x*sin(x)))", "max_ops": 40, "max_len": 860, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l3-s0/tests/run.py b/tasks/construct-rlve-antiderivative-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l3-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-l3-s0/tests/test.sh b/tasks/construct-rlve-antiderivative-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l3-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-l3-s9/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l3-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l3-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-l3-s9/environment/instance.json b/tasks/construct-rlve-antiderivative-l3-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..77f0d195789071a387c6ecfc196e36b94d6ab96e --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l3-s9/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "-sin(2*x)/2 - 1", "max_ops": 36, "max_len": 700, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l3-s9/solution/solve.sh b/tasks/construct-rlve-antiderivative-l3-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..205a9de387dbcf299fdd443fa09874b2d46f2a48 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l3-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": "-x + cos(2*x)/4"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l3-s9/tests/check.py b/tasks/construct-rlve-antiderivative-l3-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l3-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-l3-s9/tests/instance.json b/tasks/construct-rlve-antiderivative-l3-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..77f0d195789071a387c6ecfc196e36b94d6ab96e --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l3-s9/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "-sin(2*x)/2 - 1", "max_ops": 36, "max_len": 700, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l3-s9/tests/run.py b/tasks/construct-rlve-antiderivative-l3-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l3-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-l3-s9/tests/test.sh b/tasks/construct-rlve-antiderivative-l3-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l3-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-bezout-identity-l2-s4/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l2-s4/environment/instance.json b/tasks/construct-rlve-bezout-identity-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..11fa1f67f84d0f66bc75558435cabd891da1bd44 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"A": [3, -102, 105, 9], "target": 3, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l2-s4/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..73e439dfbcf1a18ab64533feb7128416679821ce --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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": [1, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l2-s4/tests/check.py b/tasks/construct-rlve-bezout-identity-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l2-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-l2-s4/tests/instance.json b/tasks/construct-rlve-bezout-identity-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..11fa1f67f84d0f66bc75558435cabd891da1bd44 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"A": [3, -102, 105, 9], "target": 3, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l2-s4/tests/run.py b/tasks/construct-rlve-bezout-identity-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l2-s4/tests/test.sh b/tasks/construct-rlve-bezout-identity-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l6-s5/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l6-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-l6-s5/environment/instance.json b/tasks/construct-rlve-bezout-identity-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aed4c074008d9b1644b117d844e52669f7ef181d --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"A": [90, -30434, -858, -8804, -15114, 20198, 18568, 7604, -11974, -1562, -9286, -1772], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l6-s5/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..33474dcd4ac85276031973e5b02da7d6c382d962 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l6-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": [-4396, -13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l6-s5/tests/check.py b/tasks/construct-rlve-bezout-identity-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l6-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-l6-s5/tests/instance.json b/tasks/construct-rlve-bezout-identity-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aed4c074008d9b1644b117d844e52669f7ef181d --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"A": [90, -30434, -858, -8804, -15114, 20198, 18568, 7604, -11974, -1562, -9286, -1772], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l6-s5/tests/run.py b/tasks/construct-rlve-bezout-identity-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l6-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-l6-s5/tests/test.sh b/tasks/construct-rlve-bezout-identity-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l6-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-s0/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l1-s0/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..11f49976987954d7f52101972c770f5b280989ee --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"mod": 52, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s0/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c390f8933bfd8314241f9f066b3d9f6a715c4263 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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' +{"L": 3, "R": 13} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s0/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-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-l1-s0/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..11f49976987954d7f52101972c770f5b280989ee --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"mod": 52, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s0/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l1-s0/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l1-s7/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l1-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l1-s7/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aa4306f051f3e9a603fc89aabeeffe5ebae390e5 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s7/environment/instance.json @@ -0,0 +1 @@ +{"mod": 30, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s7/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l1-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c567eb1dd00b89beb7a9e248b538581bd62a18b6 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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' +{"L": 4, "R": 8} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s7/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l1-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-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-l1-s7/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aa4306f051f3e9a603fc89aabeeffe5ebae390e5 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s7/tests/instance.json @@ -0,0 +1 @@ +{"mod": 30, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s7/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l1-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l1-s7/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l1-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l5-s1/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l5-s1/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d0906ef92f7688ce977547c05f82653514f18d5c --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"mod": 674321634672658, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s1/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..13f0ddfb87b1a9678c84b13f46015818890166e0 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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' +{"L": 443216346726580, "R": 543216346726579} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s1/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-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-l5-s1/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d0906ef92f7688ce977547c05f82653514f18d5c --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"mod": 674321634672658, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s1/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l5-s1/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l5-s8/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l5-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l5-s8/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..304b0e84e6818c64b8c70f8f919777c41f3841c5 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s8/environment/instance.json @@ -0,0 +1 @@ +{"mod": 544748334121030, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s8/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l5-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5903c8ed5e53320d70723f5548e035712334b57e --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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' +{"L": 236980009452360, "R": 336980009452359} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s8/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l5-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s8/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-s8/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..304b0e84e6818c64b8c70f8f919777c41f3841c5 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s8/tests/instance.json @@ -0,0 +1 @@ +{"mod": 544748334121030, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s8/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l5-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l5-s8/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l5-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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/construct-rlve-crt-l1-s8/environment/Dockerfile b/tasks/construct-rlve-crt-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l1-s8/environment/instance.json b/tasks/construct-rlve-crt-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2a66f260e646f70a2abbeac61067c1563d131ace --- /dev/null +++ b/tasks/construct-rlve-crt-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"moduli": [14, 13], "residues": [2, 3], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l1-s8/solution/solve.sh b/tasks/construct-rlve-crt-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..705a22748a7b60f74829857496f39d20f161dbde --- /dev/null +++ b/tasks/construct-rlve-crt-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' +{"x": 16} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l1-s8/tests/check.py b/tasks/construct-rlve-crt-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l1-s8/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-l1-s8/tests/instance.json b/tasks/construct-rlve-crt-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2a66f260e646f70a2abbeac61067c1563d131ace --- /dev/null +++ b/tasks/construct-rlve-crt-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [14, 13], "residues": [2, 3], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l1-s8/tests/run.py b/tasks/construct-rlve-crt-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l1-s8/tests/test.sh b/tasks/construct-rlve-crt-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l5-s0/environment/Dockerfile b/tasks/construct-rlve-crt-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l5-s0/environment/instance.json b/tasks/construct-rlve-crt-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6f7dbbdc4f9b80169382e2c5a9f0bd8ef76d15db --- /dev/null +++ b/tasks/construct-rlve-crt-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"moduli": [158298035, 1499470965, 947951029, 354154797, 699828353, 287902062], "residues": [124385906, 366193326, 917713262, 94890306, 466007585, 138251919], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l5-s0/solution/solve.sh b/tasks/construct-rlve-crt-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fafd1085012e70afe5f3e7fddbe92115022b323a --- /dev/null +++ b/tasks/construct-rlve-crt-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": 1865664291} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l5-s0/tests/check.py b/tasks/construct-rlve-crt-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l5-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-l5-s0/tests/instance.json b/tasks/construct-rlve-crt-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6f7dbbdc4f9b80169382e2c5a9f0bd8ef76d15db --- /dev/null +++ b/tasks/construct-rlve-crt-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [158298035, 1499470965, 947951029, 354154797, 699828353, 287902062], "residues": [124385906, 366193326, 917713262, 94890306, 466007585, 138251919], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l5-s0/tests/run.py b/tasks/construct-rlve-crt-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l5-s0/tests/test.sh b/tasks/construct-rlve-crt-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l5-s7/environment/Dockerfile b/tasks/construct-rlve-crt-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l5-s7/environment/instance.json b/tasks/construct-rlve-crt-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b93f0b4530603e7d54123daca31ca655114cbf1d --- /dev/null +++ b/tasks/construct-rlve-crt-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"moduli": [3138480415, 4411274497, 3506412757, 2829265016, 247255816, 2724611332], "residues": [2068962579, 796168497, 1701030237, 2378177978, 15070858, 2482831662], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l5-s7/solution/solve.sh b/tasks/construct-rlve-crt-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f1d6039dd59a41416dc175b3a641d24728a4f49 --- /dev/null +++ b/tasks/construct-rlve-crt-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' +{"x": 5207442994} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l5-s7/tests/check.py b/tasks/construct-rlve-crt-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l5-s7/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-l5-s7/tests/instance.json b/tasks/construct-rlve-crt-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b93f0b4530603e7d54123daca31ca655114cbf1d --- /dev/null +++ b/tasks/construct-rlve-crt-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [3138480415, 4411274497, 3506412757, 2829265016, 247255816, 2724611332], "residues": [2068962579, 796168497, 1701030237, 2378177978, 15070858, 2482831662], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l5-s7/tests/run.py b/tasks/construct-rlve-crt-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l5-s7/tests/test.sh b/tasks/construct-rlve-crt-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-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-distinct-subset-sum-permutation-l4-s0/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l4-s0/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dd029bd7a8a38df2f2c0f22d478decc095a23559 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"A": [4, 16, 10, 6, 23, 1, 19, 11, 13, 20, 3, 24, 9, 26], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s0/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6e9ae1b33f4d1d0eb44449cc48f4e64157f9253b --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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' +{"B": [6, 19, 11, 9, 24, 3, 20, 13, 16, 23, 4, 26, 10, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s0/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s0/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-l4-s0/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dd029bd7a8a38df2f2c0f22d478decc095a23559 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"A": [4, 16, 10, 6, 23, 1, 19, 11, 13, 20, 3, 24, 9, 26], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s0/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l4-s0/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l4-s7/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-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-l4-s7/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..207d9f684d9403e99fd8f315d71855116ec4af45 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"A": [23, 17, 27, 18, 7, 12, 26, 11, 0, 3, 16, 9, 13, 2], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s7/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b94d2909e81809c918a685206595c2b0a9c2faa5 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-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": [26, 18, 0, 23, 9, 13, 27, 12, 2, 7, 17, 11, 16, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s7/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-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-l4-s7/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..207d9f684d9403e99fd8f315d71855116ec4af45 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s7/tests/instance.json @@ -0,0 +1 @@ +{"A": [23, 17, 27, 18, 7, 12, 26, 11, 0, 3, 16, 9, 13, 2], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s7/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-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-l4-s7/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l4-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-l1-s1/environment/Dockerfile b/tasks/construct-rlve-even-degree-partition-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l1-s1/environment/instance.json b/tasks/construct-rlve-even-degree-partition-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8d39b03a7f1c0e50b8aa0fa5f12f74fc7b448a0e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 5, "edges": [[1, 4], [2, 4]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l1-s1/solution/solve.sh b/tasks/construct-rlve-even-degree-partition-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fc4e8ab45ff4d58ae544b0547e2e4c040c7c9db0 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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' +{"groups": [2, 1, 1, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-even-degree-partition-l1-s1/tests/check.py b/tasks/construct-rlve-even-degree-partition-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c7f0f71ea6d10264ececcc933b97a4a0e6eaf8e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l1-s1/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-l1-s1/tests/instance.json b/tasks/construct-rlve-even-degree-partition-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8d39b03a7f1c0e50b8aa0fa5f12f74fc7b448a0e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 5, "edges": [[1, 4], [2, 4]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l1-s1/tests/run.py b/tasks/construct-rlve-even-degree-partition-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l1-s1/tests/test.sh b/tasks/construct-rlve-even-degree-partition-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l1-s6/environment/Dockerfile b/tasks/construct-rlve-even-degree-partition-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l1-s6/environment/instance.json b/tasks/construct-rlve-even-degree-partition-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..15efadb1d12db16e2feec68822d2bb558aa2bcd6 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 5, "edges": [[0, 1], [0, 2], [0, 3], [1, 4], [2, 4], [3, 4]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l1-s6/solution/solve.sh b/tasks/construct-rlve-even-degree-partition-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f9cbdd2874a1d448993749d364c39c70fa327105 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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' +{"groups": [2, 2, 2, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-even-degree-partition-l1-s6/tests/check.py b/tasks/construct-rlve-even-degree-partition-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c7f0f71ea6d10264ececcc933b97a4a0e6eaf8e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l1-s6/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-l1-s6/tests/instance.json b/tasks/construct-rlve-even-degree-partition-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..15efadb1d12db16e2feec68822d2bb558aa2bcd6 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 5, "edges": [[0, 1], [0, 2], [0, 3], [1, 4], [2, 4], [3, 4]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l1-s6/tests/run.py b/tasks/construct-rlve-even-degree-partition-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l1-s6/tests/test.sh b/tasks/construct-rlve-even-degree-partition-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l5-s7/environment/Dockerfile b/tasks/construct-rlve-even-degree-partition-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l5-s7/environment/instance.json b/tasks/construct-rlve-even-degree-partition-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c4510cab818379bd93f49d326bb7036e36a586fc --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 28, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 9], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [1, 2], [1, 4], [1, 5], [1, 7], [1, 8], [1, 9], [1, 10], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 18], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 27], [2, 5], [2, 6], [2, 7], [2, 9], [2, 11], [2, 14], [2, 15], [2, 16], [2, 19], [2, 21], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [3, 6], [3, 9], [3, 11], [3, 16], [3, 17], [3, 19], [3, 20], [3, 22], [3, 23], [3, 24], [3, 25], [3, 27], [4, 5], [4, 6], [4, 9], [4, 11], [4, 14], [4, 17], [4, 20], [4, 21], [4, 22], [4, 24], [4, 25], [4, 26], [4, 27], [5, 6], [5, 7], [5, 9], [5, 10], [5, 11], [5, 14], [5, 18], [5, 19], [5, 24], [5, 25], [5, 27], [6, 8], [6, 9], [6, 10], [6, 11], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 20], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [7, 8], [7, 9], [7, 11], [7, 12], [7, 13], [7, 14], [7, 16], [7, 17], [7, 19], [7, 20], [7, 21], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [8, 9], [8, 11], [8, 14], [8, 19], [8, 20], [8, 25], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 20], [9, 21], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [10, 11], [10, 14], [10, 16], [10, 19], [10, 20], [10, 27], [11, 12], [11, 13], [11, 14], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 26], [11, 27], [12, 14], [12, 16], [12, 17], [12, 19], [12, 21], [12, 22], [12, 24], [12, 25], [12, 26], [12, 27], [13, 14], [13, 15], [13, 17], [13, 19], [13, 20], [13, 21], [13, 23], [13, 24], [13, 26], [13, 27], [14, 15], [14, 16], [14, 17], [14, 18], [14, 21], [14, 23], [14, 26], [15, 16], [15, 19], [15, 20], [15, 21], [15, 22], [15, 24], [15, 25], [15, 26], [15, 27], [16, 20], [16, 21], [16, 24], [17, 19], [17, 20], [17, 21], [17, 25], [17, 26], [17, 27], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [18, 25], [18, 26], [18, 27], [19, 20], [19, 22], [19, 26], [19, 27], [20, 21], [20, 22], [20, 23], [20, 24], [20, 27], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [23, 24], [23, 25], [23, 26], [23, 27], [24, 25], [24, 26], [24, 27], [25, 26], [25, 27], [26, 27]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l5-s7/solution/solve.sh b/tasks/construct-rlve-even-degree-partition-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7b0529f798c640462de41ede865ca287c513d9b1 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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' +{"groups": [1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-even-degree-partition-l5-s7/tests/check.py b/tasks/construct-rlve-even-degree-partition-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c7f0f71ea6d10264ececcc933b97a4a0e6eaf8e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l5-s7/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-l5-s7/tests/instance.json b/tasks/construct-rlve-even-degree-partition-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c4510cab818379bd93f49d326bb7036e36a586fc --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 28, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 9], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [1, 2], [1, 4], [1, 5], [1, 7], [1, 8], [1, 9], [1, 10], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 18], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 27], [2, 5], [2, 6], [2, 7], [2, 9], [2, 11], [2, 14], [2, 15], [2, 16], [2, 19], [2, 21], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [3, 6], [3, 9], [3, 11], [3, 16], [3, 17], [3, 19], [3, 20], [3, 22], [3, 23], [3, 24], [3, 25], [3, 27], [4, 5], [4, 6], [4, 9], [4, 11], [4, 14], [4, 17], [4, 20], [4, 21], [4, 22], [4, 24], [4, 25], [4, 26], [4, 27], [5, 6], [5, 7], [5, 9], [5, 10], [5, 11], [5, 14], [5, 18], [5, 19], [5, 24], [5, 25], [5, 27], [6, 8], [6, 9], [6, 10], [6, 11], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 20], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [7, 8], [7, 9], [7, 11], [7, 12], [7, 13], [7, 14], [7, 16], [7, 17], [7, 19], [7, 20], [7, 21], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [8, 9], [8, 11], [8, 14], [8, 19], [8, 20], [8, 25], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 20], [9, 21], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [10, 11], [10, 14], [10, 16], [10, 19], [10, 20], [10, 27], [11, 12], [11, 13], [11, 14], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 26], [11, 27], [12, 14], [12, 16], [12, 17], [12, 19], [12, 21], [12, 22], [12, 24], [12, 25], [12, 26], [12, 27], [13, 14], [13, 15], [13, 17], [13, 19], [13, 20], [13, 21], [13, 23], [13, 24], [13, 26], [13, 27], [14, 15], [14, 16], [14, 17], [14, 18], [14, 21], [14, 23], [14, 26], [15, 16], [15, 19], [15, 20], [15, 21], [15, 22], [15, 24], [15, 25], [15, 26], [15, 27], [16, 20], [16, 21], [16, 24], [17, 19], [17, 20], [17, 21], [17, 25], [17, 26], [17, 27], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [18, 25], [18, 26], [18, 27], [19, 20], [19, 22], [19, 26], [19, 27], [20, 21], [20, 22], [20, 23], [20, 24], [20, 27], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [23, 24], [23, 25], [23, 26], [23, 27], [24, 25], [24, 26], [24, 27], [25, 26], [25, 27], [26, 27]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l5-s7/tests/run.py b/tasks/construct-rlve-even-degree-partition-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l5-s7/tests/test.sh b/tasks/construct-rlve-even-degree-partition-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-l5-s9/environment/Dockerfile b/tasks/construct-rlve-even-degree-partition-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l5-s9/environment/instance.json b/tasks/construct-rlve-even-degree-partition-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..67fcb6733b04d75861425dc963aa9ed8d804d9d5 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 28, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 10], [0, 13], [0, 15], [0, 16], [0, 18], [0, 19], [0, 20], [0, 21], [0, 23], [0, 25], [0, 26], [0, 27], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 11], [1, 12], [1, 13], [1, 15], [1, 16], [1, 21], [1, 22], [1, 24], [1, 26], [1, 27], [2, 3], [2, 5], [2, 6], [2, 8], [2, 10], [2, 11], [2, 13], [2, 15], [2, 16], [2, 18], [2, 19], [3, 4], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 16], [3, 17], [3, 18], [3, 20], [3, 21], [3, 22], [3, 24], [3, 25], [3, 27], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 15], [4, 16], [4, 18], [4, 20], [4, 21], [4, 23], [4, 25], [5, 6], [5, 9], [5, 10], [5, 13], [5, 15], [5, 16], [5, 20], [5, 21], [5, 22], [5, 24], [5, 25], [5, 26], [5, 27], [6, 8], [6, 10], [6, 11], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [7, 8], [7, 10], [7, 11], [7, 13], [7, 16], [7, 17], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 27], [8, 9], [8, 10], [8, 11], [8, 15], [8, 18], [8, 19], [8, 20], [8, 24], [8, 25], [8, 26], [9, 10], [9, 11], [9, 15], [9, 16], [9, 18], [9, 20], [9, 25], [9, 27], [10, 12], [10, 13], [10, 16], [10, 18], [10, 20], [10, 23], [10, 27], [11, 13], [11, 14], [11, 15], [11, 16], [11, 18], [11, 19], [11, 21], [11, 22], [11, 23], [11, 25], [12, 13], [12, 15], [12, 18], [13, 15], [13, 16], [13, 18], [13, 19], [13, 26], [14, 15], [14, 18], [14, 19], [14, 20], [14, 26], [15, 16], [15, 17], [15, 18], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 27], [16, 18], [16, 19], [16, 23], [16, 26], [17, 18], [17, 19], [17, 20], [17, 26], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [19, 21], [19, 22], [19, 23], [19, 25], [19, 26], [19, 27], [20, 22], [20, 23], [20, 24], [20, 27], [21, 24], [21, 26], [22, 23], [22, 25], [22, 26], [23, 26], [23, 27], [24, 25], [24, 27], [25, 26], [25, 27]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l5-s9/solution/solve.sh b/tasks/construct-rlve-even-degree-partition-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4fe18f8f25746e8b6b5e38988f06f1c8158669a --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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' +{"groups": [2, 1, 2, 1, 2, 1, 1, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-even-degree-partition-l5-s9/tests/check.py b/tasks/construct-rlve-even-degree-partition-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c7f0f71ea6d10264ececcc933b97a4a0e6eaf8e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l5-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-l5-s9/tests/instance.json b/tasks/construct-rlve-even-degree-partition-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..67fcb6733b04d75861425dc963aa9ed8d804d9d5 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 28, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 10], [0, 13], [0, 15], [0, 16], [0, 18], [0, 19], [0, 20], [0, 21], [0, 23], [0, 25], [0, 26], [0, 27], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 11], [1, 12], [1, 13], [1, 15], [1, 16], [1, 21], [1, 22], [1, 24], [1, 26], [1, 27], [2, 3], [2, 5], [2, 6], [2, 8], [2, 10], [2, 11], [2, 13], [2, 15], [2, 16], [2, 18], [2, 19], [3, 4], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 16], [3, 17], [3, 18], [3, 20], [3, 21], [3, 22], [3, 24], [3, 25], [3, 27], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 15], [4, 16], [4, 18], [4, 20], [4, 21], [4, 23], [4, 25], [5, 6], [5, 9], [5, 10], [5, 13], [5, 15], [5, 16], [5, 20], [5, 21], [5, 22], [5, 24], [5, 25], [5, 26], [5, 27], [6, 8], [6, 10], [6, 11], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [7, 8], [7, 10], [7, 11], [7, 13], [7, 16], [7, 17], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 27], [8, 9], [8, 10], [8, 11], [8, 15], [8, 18], [8, 19], [8, 20], [8, 24], [8, 25], [8, 26], [9, 10], [9, 11], [9, 15], [9, 16], [9, 18], [9, 20], [9, 25], [9, 27], [10, 12], [10, 13], [10, 16], [10, 18], [10, 20], [10, 23], [10, 27], [11, 13], [11, 14], [11, 15], [11, 16], [11, 18], [11, 19], [11, 21], [11, 22], [11, 23], [11, 25], [12, 13], [12, 15], [12, 18], [13, 15], [13, 16], [13, 18], [13, 19], [13, 26], [14, 15], [14, 18], [14, 19], [14, 20], [14, 26], [15, 16], [15, 17], [15, 18], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 27], [16, 18], [16, 19], [16, 23], [16, 26], [17, 18], [17, 19], [17, 20], [17, 26], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [19, 21], [19, 22], [19, 23], [19, 25], [19, 26], [19, 27], [20, 22], [20, 23], [20, 24], [20, 27], [21, 24], [21, 26], [22, 23], [22, 25], [22, 26], [23, 26], [23, 27], [24, 25], [24, 27], [25, 26], [25, 27]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l5-s9/tests/run.py b/tasks/construct-rlve-even-degree-partition-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l5-s9/tests/test.sh b/tasks/construct-rlve-even-degree-partition-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-graph-isomorphism-l3-s4/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l3-s4/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ae7b1595136d136f06012fff0436fb871e0f9d24 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges1": [[3, 7], [3, 10], [2, 11], [5, 9], [0, 6], [2, 3], [0, 2], [1, 11], [3, 9], [2, 5], [0, 8], [1, 4], [9, 11], [1, 9], [2, 8], [10, 11], [1, 2], [8, 11], [4, 7], [4, 5], [6, 8], [0, 5], [1, 8], [6, 10], [1, 7], [3, 8], [3, 4], [4, 10], [2, 6], [5, 8], [2, 9], [7, 10], [4, 8], [3, 6], [7, 9], [9, 10], [6, 11], [0, 4], [3, 11], [1, 3], [0, 10], [4, 6], [0, 7], [0, 3], [4, 9], [2, 4], [7, 11], [1, 10], [8, 10]], "edges2": [[0, 11], [2, 8], [5, 8], [7, 8], [8, 11], [2, 11], [1, 5], [10, 11], [0, 8], [4, 6], [1, 10], [4, 9], [5, 9], [5, 11], [4, 5], [7, 10], [0, 9], [1, 4], [5, 6], [7, 9], [2, 9], [4, 7], [2, 4], [5, 10], [1, 11], [7, 11], [0, 10], [3, 11], [2, 7], [6, 7], [5, 7], [6, 10], [3, 8], [2, 3], [9, 10], [6, 8], [2, 6], [0, 7], [0, 5], [0, 2], [0, 3], [2, 10], [3, 10], [3, 7], [3, 4], [6, 9], [8, 9], [1, 9], [4, 10]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l3-s4/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2ad524c74c8862f457b0346d8751b71ed9c65e64 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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' +{"p": [4, 0, 5, 7, 10, 1, 6, 3, 9, 11, 2, 8]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l3-s4/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l3-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-l3-s4/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ae7b1595136d136f06012fff0436fb871e0f9d24 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges1": [[3, 7], [3, 10], [2, 11], [5, 9], [0, 6], [2, 3], [0, 2], [1, 11], [3, 9], [2, 5], [0, 8], [1, 4], [9, 11], [1, 9], [2, 8], [10, 11], [1, 2], [8, 11], [4, 7], [4, 5], [6, 8], [0, 5], [1, 8], [6, 10], [1, 7], [3, 8], [3, 4], [4, 10], [2, 6], [5, 8], [2, 9], [7, 10], [4, 8], [3, 6], [7, 9], [9, 10], [6, 11], [0, 4], [3, 11], [1, 3], [0, 10], [4, 6], [0, 7], [0, 3], [4, 9], [2, 4], [7, 11], [1, 10], [8, 10]], "edges2": [[0, 11], [2, 8], [5, 8], [7, 8], [8, 11], [2, 11], [1, 5], [10, 11], [0, 8], [4, 6], [1, 10], [4, 9], [5, 9], [5, 11], [4, 5], [7, 10], [0, 9], [1, 4], [5, 6], [7, 9], [2, 9], [4, 7], [2, 4], [5, 10], [1, 11], [7, 11], [0, 10], [3, 11], [2, 7], [6, 7], [5, 7], [6, 10], [3, 8], [2, 3], [9, 10], [6, 8], [2, 6], [0, 7], [0, 5], [0, 2], [0, 3], [2, 10], [3, 10], [3, 7], [3, 4], [6, 9], [8, 9], [1, 9], [4, 10]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l3-s4/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l3-s4/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-grid-parity-construction-l3-s3/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l3-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-l3-s3/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bfddb223ae93661c9f77c41a0bb1bb6beb6bcb21 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["101010", "000011", "000110", "011001"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l3-s3/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f448ff467c130a20f5d039df04ec93ba1f969570 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l3-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": ["111110", "110111", "111111", "101111"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l3-s3/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l3-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-l3-s3/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bfddb223ae93661c9f77c41a0bb1bb6beb6bcb21 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["101010", "000011", "000110", "011001"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l3-s3/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l3-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-l3-s3/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l3-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-s3/environment/Dockerfile b/tasks/construct-rlve-imp-party-l4-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-rlve-imp-party-l4-s3/environment/instance.json b/tasks/construct-rlve-imp-party-l4-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3b83356b9f44ea4591a7c4a2de65d1ada14ec410 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 12], [0, 13], [0, 18], [0, 20], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 28], [0, 29], [0, 31], [0, 33], [0, 34], [0, 35], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 12], [1, 13], [1, 18], [1, 20], [1, 22], [1, 23], [1, 24], [1, 26], [1, 28], [1, 29], [1, 31], [1, 33], [1, 34], [1, 35], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 12], [2, 13], [2, 17], [2, 18], [2, 20], [2, 22], [2, 23], [2, 24], [2, 26], [2, 28], [2, 29], [2, 30], [2, 31], [2, 33], [2, 34], [2, 35], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 12], [3, 13], [3, 16], [3, 18], [3, 20], [3, 22], [3, 23], [3, 24], [3, 26], [3, 28], [3, 29], [3, 31], [3, 33], [3, 34], [3, 35], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 11], [4, 12], [4, 13], [4, 18], [4, 20], [4, 22], [4, 23], [4, 24], [4, 26], [4, 27], [4, 28], [4, 29], [4, 31], [4, 33], [4, 34], [4, 35], [5, 6], [5, 7], [5, 8], [5, 9], [5, 12], [5, 13], [5, 16], [5, 18], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 26], [5, 28], [5, 29], [5, 31], [5, 33], [5, 34], [5, 35], [6, 7], [6, 8], [6, 9], [6, 12], [6, 13], [6, 18], [6, 19], [6, 20], [6, 22], [6, 23], [6, 24], [6, 26], [6, 28], [6, 29], [6, 31], [6, 33], [6, 34], [6, 35], [7, 8], [7, 9], [7, 12], [7, 13], [7, 18], [7, 20], [7, 22], [7, 23], [7, 24], [7, 26], [7, 28], [7, 29], [7, 31], [7, 33], [7, 34], [7, 35], [8, 9], [8, 12], [8, 13], [8, 18], [8, 20], [8, 22], [8, 23], [8, 24], [8, 26], [8, 28], [8, 29], [8, 31], [8, 33], [8, 34], [8, 35], [9, 12], [9, 13], [9, 18], [9, 20], [9, 22], [9, 23], [9, 24], [9, 26], [9, 28], [9, 29], [9, 31], [9, 33], [9, 34], [9, 35], [10, 33], [12, 13], [12, 18], [12, 20], [12, 22], [12, 23], [12, 24], [12, 26], [12, 28], [12, 29], [12, 31], [12, 33], [12, 34], [12, 35], [13, 16], [13, 18], [13, 20], [13, 22], [13, 23], [13, 24], [13, 26], [13, 28], [13, 29], [13, 31], [13, 33], [13, 34], [13, 35], [17, 23], [17, 35], [18, 20], [18, 21], [18, 22], [18, 23], [18, 24], [18, 26], [18, 28], [18, 29], [18, 31], [18, 33], [18, 34], [18, 35], [20, 22], [20, 23], [20, 24], [20, 26], [20, 28], [20, 29], [20, 31], [20, 33], [20, 34], [20, 35], [21, 26], [22, 23], [22, 24], [22, 26], [22, 28], [22, 29], [22, 31], [22, 33], [22, 34], [22, 35], [23, 24], [23, 26], [23, 28], [23, 29], [23, 31], [23, 33], [23, 34], [23, 35], [24, 26], [24, 28], [24, 29], [24, 31], [24, 33], [24, 34], [24, 35], [26, 28], [26, 29], [26, 31], [26, 33], [26, 34], [26, 35], [28, 29], [28, 31], [28, 33], [28, 34], [28, 35], [29, 31], [29, 33], [29, 34], [29, 35], [31, 33], [31, 34], [31, 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-s3/solution/solve.sh b/tasks/construct-rlve-imp-party-l4-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f557c2abcc753b07b2ac609275a24761fd4db556 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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' +{"clique": [0, 1, 3, 5, 7, 13, 20, 24, 26, 28, 34, 35]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l4-s3/tests/check.py b/tasks/construct-rlve-imp-party-l4-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s3/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-s3/tests/instance.json b/tasks/construct-rlve-imp-party-l4-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3b83356b9f44ea4591a7c4a2de65d1ada14ec410 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 12], [0, 13], [0, 18], [0, 20], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 28], [0, 29], [0, 31], [0, 33], [0, 34], [0, 35], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 12], [1, 13], [1, 18], [1, 20], [1, 22], [1, 23], [1, 24], [1, 26], [1, 28], [1, 29], [1, 31], [1, 33], [1, 34], [1, 35], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 12], [2, 13], [2, 17], [2, 18], [2, 20], [2, 22], [2, 23], [2, 24], [2, 26], [2, 28], [2, 29], [2, 30], [2, 31], [2, 33], [2, 34], [2, 35], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 12], [3, 13], [3, 16], [3, 18], [3, 20], [3, 22], [3, 23], [3, 24], [3, 26], [3, 28], [3, 29], [3, 31], [3, 33], [3, 34], [3, 35], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 11], [4, 12], [4, 13], [4, 18], [4, 20], [4, 22], [4, 23], [4, 24], [4, 26], [4, 27], [4, 28], [4, 29], [4, 31], [4, 33], [4, 34], [4, 35], [5, 6], [5, 7], [5, 8], [5, 9], [5, 12], [5, 13], [5, 16], [5, 18], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 26], [5, 28], [5, 29], [5, 31], [5, 33], [5, 34], [5, 35], [6, 7], [6, 8], [6, 9], [6, 12], [6, 13], [6, 18], [6, 19], [6, 20], [6, 22], [6, 23], [6, 24], [6, 26], [6, 28], [6, 29], [6, 31], [6, 33], [6, 34], [6, 35], [7, 8], [7, 9], [7, 12], [7, 13], [7, 18], [7, 20], [7, 22], [7, 23], [7, 24], [7, 26], [7, 28], [7, 29], [7, 31], [7, 33], [7, 34], [7, 35], [8, 9], [8, 12], [8, 13], [8, 18], [8, 20], [8, 22], [8, 23], [8, 24], [8, 26], [8, 28], [8, 29], [8, 31], [8, 33], [8, 34], [8, 35], [9, 12], [9, 13], [9, 18], [9, 20], [9, 22], [9, 23], [9, 24], [9, 26], [9, 28], [9, 29], [9, 31], [9, 33], [9, 34], [9, 35], [10, 33], [12, 13], [12, 18], [12, 20], [12, 22], [12, 23], [12, 24], [12, 26], [12, 28], [12, 29], [12, 31], [12, 33], [12, 34], [12, 35], [13, 16], [13, 18], [13, 20], [13, 22], [13, 23], [13, 24], [13, 26], [13, 28], [13, 29], [13, 31], [13, 33], [13, 34], [13, 35], [17, 23], [17, 35], [18, 20], [18, 21], [18, 22], [18, 23], [18, 24], [18, 26], [18, 28], [18, 29], [18, 31], [18, 33], [18, 34], [18, 35], [20, 22], [20, 23], [20, 24], [20, 26], [20, 28], [20, 29], [20, 31], [20, 33], [20, 34], [20, 35], [21, 26], [22, 23], [22, 24], [22, 26], [22, 28], [22, 29], [22, 31], [22, 33], [22, 34], [22, 35], [23, 24], [23, 26], [23, 28], [23, 29], [23, 31], [23, 33], [23, 34], [23, 35], [24, 26], [24, 28], [24, 29], [24, 31], [24, 33], [24, 34], [24, 35], [26, 28], [26, 29], [26, 31], [26, 33], [26, 34], [26, 35], [28, 29], [28, 31], [28, 33], [28, 34], [28, 35], [29, 31], [29, 33], [29, 34], [29, 35], [31, 33], [31, 34], [31, 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-s3/tests/run.py b/tasks/construct-rlve-imp-party-l4-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-rlve-imp-party-l4-s3/tests/test.sh b/tasks/construct-rlve-imp-party-l4-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-rlve-integer-linear-system-l3-s3/environment/Dockerfile b/tasks/construct-rlve-integer-linear-system-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-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-integer-linear-system-l3-s3/environment/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1f88a6f9f50e5c8e1d424213f2ea31cbdd8eba67 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 1, 1, 1], [1, 0, 0, 0, 1, 1, 0, 1], [0, 1, 1, 1, 1, 1, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0, 1, 0], [1, 1, 1, 0, 1, 0, 0, 0], [1, 0, 0, 1, 0, 1, 0, 0], [1, 0, 0, 0, 0, 0, 1, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 1, 1, 0, 0, 1, 1, 1], [0, 1, 1, 0, 0, 1, 0, 1], [0, 1, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1, 1], [0, 1, 1, 1, 0, 0, 1, 1], [0, 1, 0, 1, 0, 1, 0, 0], [1, 0, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 1, 1, 0, 0]], "rhs": [22, 5, 21, 23, 31, 10, 24, 23, 24, 14, 15, 30, 31, 23, 16, 27, 23, 15, 21, 12], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s3/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8d2b3dee0520b24d0ae90771423b9201caadf129 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-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' +{"x": [7, 8, 4, 3, 5, 4, 1, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l3-s3/tests/check.py b/tasks/construct-rlve-integer-linear-system-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s3/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-s3/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1f88a6f9f50e5c8e1d424213f2ea31cbdd8eba67 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 1, 1, 1], [1, 0, 0, 0, 1, 1, 0, 1], [0, 1, 1, 1, 1, 1, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0, 1, 0], [1, 1, 1, 0, 1, 0, 0, 0], [1, 0, 0, 1, 0, 1, 0, 0], [1, 0, 0, 0, 0, 0, 1, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 1, 1, 0, 0, 1, 1, 1], [0, 1, 1, 0, 0, 1, 0, 1], [0, 1, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1, 1], [0, 1, 1, 1, 0, 0, 1, 1], [0, 1, 0, 1, 0, 1, 0, 0], [1, 0, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 1, 1, 0, 0]], "rhs": [22, 5, 21, 23, 31, 10, 24, 23, 24, 14, 15, 30, 31, 23, 16, 27, 23, 15, 21, 12], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s3/tests/run.py b/tasks/construct-rlve-integer-linear-system-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-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-integer-linear-system-l3-s3/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-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-convex-polygon-l1-s3/environment/Dockerfile b/tasks/construct-rlve-largest-convex-polygon-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-rlve-largest-convex-polygon-l1-s3/environment/instance.json b/tasks/construct-rlve-largest-convex-polygon-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c967dff51eb50f2849290627d94e6e6ac854270a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"points": [[0, 1], [4, 0], [4, 3], [6, 1], [0, 2], [2, 6]], "k": 5, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l1-s3/solution/solve.sh b/tasks/construct-rlve-largest-convex-polygon-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e51a48f1c4946d37565e02d368bfff25c982d455 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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' +{"indices": [0, 4, 5, 2, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-convex-polygon-l1-s3/tests/check.py b/tasks/construct-rlve-largest-convex-polygon-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3a09cc858f41ce5745e4e491188cd42360c65dae --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l1-s3/tests/check.py @@ -0,0 +1,27 @@ +from run import Invalid, int_list + + +def _cross(o, a, b): + return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) + + +def check(inst, ans): + P, k = inst["points"], inst["k"] + idx = int_list(ans.get("indices"), None, 0, len(P) - 1, "indices") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + if len(idx) < k: + raise Invalid(f"{len(idx)} points given, need {k}") + pts = sorted(tuple(P[i]) for i in idx) + lower, upper = [], [] + for p in pts: # monotone chain, strict (collinear points dropped) + while len(lower) >= 2 and _cross(lower[-2], lower[-1], p) <= 0: + lower.pop() + lower.append(p) + for p in reversed(pts): + while len(upper) >= 2 and _cross(upper[-2], upper[-1], p) <= 0: + upper.pop() + upper.append(p) + if len(lower) + len(upper) - 2 != len(pts): + raise Invalid("the chosen points are not in convex position") + return None, {} diff --git a/tasks/construct-rlve-largest-convex-polygon-l1-s3/tests/instance.json b/tasks/construct-rlve-largest-convex-polygon-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c967dff51eb50f2849290627d94e6e6ac854270a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"points": [[0, 1], [4, 0], [4, 3], [6, 1], [0, 2], [2, 6]], "k": 5, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l1-s3/tests/run.py b/tasks/construct-rlve-largest-convex-polygon-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-rlve-largest-convex-polygon-l1-s3/tests/test.sh b/tasks/construct-rlve-largest-convex-polygon-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-rlve-largest-convex-polygon-l1-s4/environment/Dockerfile b/tasks/construct-rlve-largest-convex-polygon-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-rlve-largest-convex-polygon-l1-s4/environment/instance.json b/tasks/construct-rlve-largest-convex-polygon-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bbcccc6a506a92e1ac1be414688232d4be8abbbe --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"points": [[5, 5], [3, 1], [1, 1], [4, 5], [2, 6], [6, 3]], "k": 5, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l1-s4/solution/solve.sh b/tasks/construct-rlve-largest-convex-polygon-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..82e3f64a527a56f0f14020043be87b8eacf7cc4c --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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' +{"indices": [2, 4, 3, 5, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-convex-polygon-l1-s4/tests/check.py b/tasks/construct-rlve-largest-convex-polygon-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3a09cc858f41ce5745e4e491188cd42360c65dae --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l1-s4/tests/check.py @@ -0,0 +1,27 @@ +from run import Invalid, int_list + + +def _cross(o, a, b): + return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) + + +def check(inst, ans): + P, k = inst["points"], inst["k"] + idx = int_list(ans.get("indices"), None, 0, len(P) - 1, "indices") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + if len(idx) < k: + raise Invalid(f"{len(idx)} points given, need {k}") + pts = sorted(tuple(P[i]) for i in idx) + lower, upper = [], [] + for p in pts: # monotone chain, strict (collinear points dropped) + while len(lower) >= 2 and _cross(lower[-2], lower[-1], p) <= 0: + lower.pop() + lower.append(p) + for p in reversed(pts): + while len(upper) >= 2 and _cross(upper[-2], upper[-1], p) <= 0: + upper.pop() + upper.append(p) + if len(lower) + len(upper) - 2 != len(pts): + raise Invalid("the chosen points are not in convex position") + return None, {} diff --git a/tasks/construct-rlve-largest-convex-polygon-l1-s4/tests/instance.json b/tasks/construct-rlve-largest-convex-polygon-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bbcccc6a506a92e1ac1be414688232d4be8abbbe --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"points": [[5, 5], [3, 1], [1, 1], [4, 5], [2, 6], [6, 3]], "k": 5, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l1-s4/tests/run.py b/tasks/construct-rlve-largest-convex-polygon-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l1-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-convex-polygon-l1-s4/tests/test.sh b/tasks/construct-rlve-largest-convex-polygon-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-rlve-largest-convex-polygon-l5-s2/environment/Dockerfile b/tasks/construct-rlve-largest-convex-polygon-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-rlve-largest-convex-polygon-l5-s2/environment/instance.json b/tasks/construct-rlve-largest-convex-polygon-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d5834735531564692ea494cbd3971aefd935b108 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"points": [[6, 18], [12, 1], [12, 16], [5, 4], [4, 15], [17, 24], [25, 4], [0, 11], [0, 23], [2, 20], [20, 13], [3, 9], [13, 7], [1, 8], [16, 12], [20, 18], [5, 2], [4, 13], [3, 23], [25, 5], [17, 25], [6, 0], [2, 15], [16, 14], [18, 11]], "k": 11, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l5-s2/solution/solve.sh b/tasks/construct-rlve-largest-convex-polygon-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b5ca4e8f95663e02cf3fedcf82ea69b0759579ed --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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' +{"indices": [22, 9, 18, 2, 24, 19, 6, 1, 21, 16, 11]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-convex-polygon-l5-s2/tests/check.py b/tasks/construct-rlve-largest-convex-polygon-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3a09cc858f41ce5745e4e491188cd42360c65dae --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l5-s2/tests/check.py @@ -0,0 +1,27 @@ +from run import Invalid, int_list + + +def _cross(o, a, b): + return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) + + +def check(inst, ans): + P, k = inst["points"], inst["k"] + idx = int_list(ans.get("indices"), None, 0, len(P) - 1, "indices") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + if len(idx) < k: + raise Invalid(f"{len(idx)} points given, need {k}") + pts = sorted(tuple(P[i]) for i in idx) + lower, upper = [], [] + for p in pts: # monotone chain, strict (collinear points dropped) + while len(lower) >= 2 and _cross(lower[-2], lower[-1], p) <= 0: + lower.pop() + lower.append(p) + for p in reversed(pts): + while len(upper) >= 2 and _cross(upper[-2], upper[-1], p) <= 0: + upper.pop() + upper.append(p) + if len(lower) + len(upper) - 2 != len(pts): + raise Invalid("the chosen points are not in convex position") + return None, {} diff --git a/tasks/construct-rlve-largest-convex-polygon-l5-s2/tests/instance.json b/tasks/construct-rlve-largest-convex-polygon-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d5834735531564692ea494cbd3971aefd935b108 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"points": [[6, 18], [12, 1], [12, 16], [5, 4], [4, 15], [17, 24], [25, 4], [0, 11], [0, 23], [2, 20], [20, 13], [3, 9], [13, 7], [1, 8], [16, 12], [20, 18], [5, 2], [4, 13], [3, 23], [25, 5], [17, 25], [6, 0], [2, 15], [16, 14], [18, 11]], "k": 11, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l5-s2/tests/run.py b/tasks/construct-rlve-largest-convex-polygon-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-rlve-largest-convex-polygon-l5-s2/tests/test.sh b/tasks/construct-rlve-largest-convex-polygon-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-rlve-largest-rectangle-l3-s3/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l3-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-l3-s3/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1534bf12c740c3a5d5a97d4af136ec8587a48797 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"points": [[-5, -15], [3, 12], [-14, 10], [-11, -10], [13, 16], [-15, -11], [-16, -2], [-5, -10], [4, -3], [-9, -11], [3, -3], [5, -8], [4, -10], [7, -4], [-1, -4], [0, -9]], "area": 26, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l3-s3/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b98cce94cf84ea68ef497329ebb7f4f01dc2593c --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l3-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": [8, 11, 15, 14]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l3-s3/tests/check.py b/tasks/construct-rlve-largest-rectangle-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l3-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-l3-s3/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1534bf12c740c3a5d5a97d4af136ec8587a48797 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"points": [[-5, -15], [3, 12], [-14, 10], [-11, -10], [13, 16], [-15, -11], [-16, -2], [-5, -10], [4, -3], [-9, -11], [3, -3], [5, -8], [4, -10], [7, -4], [-1, -4], [0, -9]], "area": 26, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l3-s3/tests/run.py b/tasks/construct-rlve-largest-rectangle-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l3-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-l3-s3/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l3-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-l3-s4/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l3-s4/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..76ed14a5ff7ff4f0d2161a0c6ccf4d34bbbc14e9 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"points": [[-5, -16], [-1, -5], [3, 2], [15, -12], [8, -5], [1, -4], [-4, 6], [-12, 11], [-3, -13], [-13, 4], [5, -14], [-5, 16], [-8, 7], [9, -15], [-8, -1], [-8, 11]], "area": 65, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l3-s4/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6a65773cec92d19f78348c0464bb42061b5123ef --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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' +{"indices": [1, 2, 6, 14]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l3-s4/tests/check.py b/tasks/construct-rlve-largest-rectangle-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l3-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-l3-s4/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..76ed14a5ff7ff4f0d2161a0c6ccf4d34bbbc14e9 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"points": [[-5, -16], [-1, -5], [3, 2], [15, -12], [8, -5], [1, -4], [-4, 6], [-12, 11], [-3, -13], [-13, 4], [5, -14], [-5, 16], [-8, 7], [9, -15], [-8, -1], [-8, 11]], "area": 65, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l3-s4/tests/run.py b/tasks/construct-rlve-largest-rectangle-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l3-s4/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-matrix-permutation-equivalence-l1-s0/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l1-s0/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e14141cc023eff2b84b1cd81d3cb5545bf9bc270 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"A": ["01", "00", "10"], "B": ["10", "00", "01"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s0/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bae30f9403ba73217a2da34d661343b3e3869a5a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [2, 1, 0], "b": [0, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s0/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-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-l1-s0/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e14141cc023eff2b84b1cd81d3cb5545bf9bc270 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"A": ["01", "00", "10"], "B": ["10", "00", "01"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s0/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l1-s0/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l1-s7/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l1-s7/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cb010939427f65a080fbe12510abe5e52c2b1c08 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s7/environment/instance.json @@ -0,0 +1 @@ +{"A": ["111", "101"], "B": ["110", "111"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s7/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..50a5f8a4c6a232f318df5db2ff220f650daa1dc1 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [1, 0], "b": [2, 0, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s7/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-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-l1-s7/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cb010939427f65a080fbe12510abe5e52c2b1c08 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s7/tests/instance.json @@ -0,0 +1 @@ +{"A": ["111", "101"], "B": ["110", "111"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s7/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l1-s7/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l5-s1/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l5-s1/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..66affd9beb4b6ef29a658a1155feda0439a892b2 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"A": ["010011111101", "111111110011", "110111101101", "101010110110", "111101111111", "101111011101", "001111101011", "111111111011"], "B": ["111011100111", "010011111111", "110100101111", "001001111111", "111110111110", "111110111111", "111111111101", "101111001010"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s1/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..90d0505cdfbb3b379484a32179583d93cb7a4167 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [5, 2, 6, 0, 1, 7, 4, 3], "b": [2, 3, 7, 10, 0, 9, 11, 1, 6, 5, 4, 8]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s1/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-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-l5-s1/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..66affd9beb4b6ef29a658a1155feda0439a892b2 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"A": ["010011111101", "111111110011", "110111101101", "101010110110", "111101111111", "101111011101", "001111101011", "111111111011"], "B": ["111011100111", "010011111111", "110100101111", "001001111111", "111110111110", "111110111111", "111111111101", "101111001010"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s1/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l5-s1/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l5-s8/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l5-s8/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0d2962a2c8520e406cb8a79af51a6789d1ff2ae2 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s8/environment/instance.json @@ -0,0 +1 @@ +{"A": ["0000100", "0000110", "0001011", "1100010", "0010011", "0000000", "1101000", "0001010", "0000000", "1011001", "0100000", "0000000", "0000000", "0000000", "0100000"], "B": ["0000010", "0010000", "0000000", "1100000", "1001101", "0101100", "0000000", "0110000", "0000000", "1000011", "0100011", "0000000", "1101000", "0000000", "0000010"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s8/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3e82abf77384b3576f29a839a14a28c116fc9a0c --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [10, 0, 5, 7, 9, 4, 8, 1, 11, 6, 3, 12, 2, 13, 14], "b": [3, 5, 4, 6, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s8/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s8/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-s8/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0d2962a2c8520e406cb8a79af51a6789d1ff2ae2 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s8/tests/instance.json @@ -0,0 +1 @@ +{"A": ["0000100", "0000110", "0001011", "1100010", "0010011", "0000000", "1101000", "0001010", "0000000", "1011001", "0100000", "0000000", "0000000", "0000000", "0100000"], "B": ["0000010", "0010000", "0000000", "1100000", "1001101", "0101100", "0000000", "0110000", "0000000", "1000011", "0100011", "0000000", "1101000", "0000000", "0000010"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s8/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l5-s8/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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/construct-rlve-max-achromatic-coloring-l1-s2/environment/Dockerfile b/tasks/construct-rlve-max-achromatic-coloring-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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-rlve-max-achromatic-coloring-l1-s2/environment/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ca2217cc85bcda591b8d13785139a1fd19ed3d15 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 3], [1, 4], [3, 4], [3, 5]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l1-s2/solution/solve.sh b/tasks/construct-rlve-max-achromatic-coloring-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..507750783edb4737b84f155ecabef4d2b36c3f75 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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' +{"colors": [0, 0, 0, 1, 2, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-max-achromatic-coloring-l1-s2/tests/check.py b/tasks/construct-rlve-max-achromatic-coloring-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..bb676a518264e5db4fb0964e27ccffccf6980807 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l1-s2/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("colors"), n, 0, k - 1, "colors") + if len(set(c)) != k: + raise Invalid(f"uses {len(set(c))} colours, need all {k}") + pairs = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pairs.add((min(c[u], c[v]), max(c[u], c[v]))) + if len(pairs) != k * (k - 1) // 2: + raise Invalid("some pair of colours is not joined by an edge") + return None, {} diff --git a/tasks/construct-rlve-max-achromatic-coloring-l1-s2/tests/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ca2217cc85bcda591b8d13785139a1fd19ed3d15 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 3], [1, 4], [3, 4], [3, 5]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l1-s2/tests/run.py b/tasks/construct-rlve-max-achromatic-coloring-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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-rlve-max-achromatic-coloring-l1-s2/tests/test.sh b/tasks/construct-rlve-max-achromatic-coloring-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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-rlve-max-achromatic-coloring-l1-s5/environment/Dockerfile b/tasks/construct-rlve-max-achromatic-coloring-l1-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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-rlve-max-achromatic-coloring-l1-s5/environment/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l1-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a31ef797a9a7b5235cc13ad913e51f4885e94632 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l1-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 4, "edges": [[0, 1], [0, 3], [1, 5], [2, 5], [3, 4], [3, 5], [4, 5]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l1-s5/solution/solve.sh b/tasks/construct-rlve-max-achromatic-coloring-l1-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b61244106d70cfb43a8b8062e3f38b6f1353bed6 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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' +{"colors": [0, 1, 0, 2, 1, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-max-achromatic-coloring-l1-s5/tests/check.py b/tasks/construct-rlve-max-achromatic-coloring-l1-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..bb676a518264e5db4fb0964e27ccffccf6980807 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l1-s5/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("colors"), n, 0, k - 1, "colors") + if len(set(c)) != k: + raise Invalid(f"uses {len(set(c))} colours, need all {k}") + pairs = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pairs.add((min(c[u], c[v]), max(c[u], c[v]))) + if len(pairs) != k * (k - 1) // 2: + raise Invalid("some pair of colours is not joined by an edge") + return None, {} diff --git a/tasks/construct-rlve-max-achromatic-coloring-l1-s5/tests/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l1-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a31ef797a9a7b5235cc13ad913e51f4885e94632 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l1-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 4, "edges": [[0, 1], [0, 3], [1, 5], [2, 5], [3, 4], [3, 5], [4, 5]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l1-s5/tests/run.py b/tasks/construct-rlve-max-achromatic-coloring-l1-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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-rlve-max-achromatic-coloring-l1-s5/tests/test.sh b/tasks/construct-rlve-max-achromatic-coloring-l1-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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-rlve-max-achromatic-coloring-l5-s3/environment/Dockerfile b/tasks/construct-rlve-max-achromatic-coloring-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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-rlve-max-achromatic-coloring-l5-s3/environment/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5bdbc345afd9b2ae85edae267e9169d64903fba0 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 13, "k": 8, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 11], [0, 12], [1, 2], [1, 3], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 12], [3, 7], [3, 8], [3, 10], [4, 5], [4, 9], [4, 11], [5, 7], [5, 8], [5, 9], [5, 11], [6, 9], [6, 10], [6, 12], [7, 10], [7, 12], [8, 11], [9, 10], [9, 11], [9, 12], [10, 12], [11, 12]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l5-s3/solution/solve.sh b/tasks/construct-rlve-max-achromatic-coloring-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f043f47b8e5bf0f319e6137ce4b851571e762fd5 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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' +{"colors": [0, 1, 2, 3, 3, 4, 5, 5, 6, 7, 2, 1, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-max-achromatic-coloring-l5-s3/tests/check.py b/tasks/construct-rlve-max-achromatic-coloring-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..bb676a518264e5db4fb0964e27ccffccf6980807 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l5-s3/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("colors"), n, 0, k - 1, "colors") + if len(set(c)) != k: + raise Invalid(f"uses {len(set(c))} colours, need all {k}") + pairs = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pairs.add((min(c[u], c[v]), max(c[u], c[v]))) + if len(pairs) != k * (k - 1) // 2: + raise Invalid("some pair of colours is not joined by an edge") + return None, {} diff --git a/tasks/construct-rlve-max-achromatic-coloring-l5-s3/tests/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5bdbc345afd9b2ae85edae267e9169d64903fba0 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 13, "k": 8, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 11], [0, 12], [1, 2], [1, 3], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 12], [3, 7], [3, 8], [3, 10], [4, 5], [4, 9], [4, 11], [5, 7], [5, 8], [5, 9], [5, 11], [6, 9], [6, 10], [6, 12], [7, 10], [7, 12], [8, 11], [9, 10], [9, 11], [9, 12], [10, 12], [11, 12]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l5-s3/tests/run.py b/tasks/construct-rlve-max-achromatic-coloring-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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-rlve-max-achromatic-coloring-l5-s3/tests/test.sh b/tasks/construct-rlve-max-achromatic-coloring-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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-rlve-maximum-clique-l2-s1/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-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-rlve-maximum-clique-l2-s1/environment/instance.json b/tasks/construct-rlve-maximum-clique-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..94665089faa05442037cfdc1ea59548ba76e5330 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 6, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 12], [1, 3], [1, 5], [1, 6], [1, 7], [1, 9], [1, 10], [1, 12], [1, 13], [2, 3], [2, 5], [2, 6], [2, 8], [2, 9], [2, 11], [2, 12], [2, 13], [3, 4], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [4, 5], [4, 6], [4, 8], [4, 9], [4, 11], [4, 12], [4, 13], [5, 6], [5, 7], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [6, 7], [6, 8], [6, 9], [6, 11], [6, 12], [6, 13], [7, 8], [7, 9], [7, 10], [7, 11], [7, 13], [8, 9], [8, 10], [8, 12], [8, 13], [9, 10], [9, 12], [10, 11], [10, 13], [11, 13], [12, 13]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s1/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f7cb780eeda770e16ce48145721bb80f7bd31076 --- /dev/null +++ b/tasks/construct-rlve-maximum-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": [0, 1, 5, 6, 7, 9]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l2-s1/tests/check.py b/tasks/construct-rlve-maximum-clique-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s1/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-s1/tests/instance.json b/tasks/construct-rlve-maximum-clique-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..94665089faa05442037cfdc1ea59548ba76e5330 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 6, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 12], [1, 3], [1, 5], [1, 6], [1, 7], [1, 9], [1, 10], [1, 12], [1, 13], [2, 3], [2, 5], [2, 6], [2, 8], [2, 9], [2, 11], [2, 12], [2, 13], [3, 4], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [4, 5], [4, 6], [4, 8], [4, 9], [4, 11], [4, 12], [4, 13], [5, 6], [5, 7], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [6, 7], [6, 8], [6, 9], [6, 11], [6, 12], [6, 13], [7, 8], [7, 9], [7, 10], [7, 11], [7, 13], [8, 9], [8, 10], [8, 12], [8, 13], [9, 10], [9, 12], [10, 11], [10, 13], [11, 13], [12, 13]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s1/tests/run.py b/tasks/construct-rlve-maximum-clique-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-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-rlve-maximum-clique-l2-s1/tests/test.sh b/tasks/construct-rlve-maximum-clique-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-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-rlve-maximum-clique-l2-s6/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-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-rlve-maximum-clique-l2-s6/environment/instance.json b/tasks/construct-rlve-maximum-clique-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0a2b7f5515c17a4c5d0be925aa5c8b78f76ba986 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 7, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 8], [1, 9], [1, 10], [1, 12], [1, 13], [2, 3], [2, 4], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 13], [3, 4], [3, 5], [3, 6], [3, 10], [3, 12], [3, 13], [4, 5], [4, 6], [4, 7], [4, 8], [4, 10], [4, 11], [4, 12], [4, 13], [5, 6], [5, 7], [5, 10], [5, 11], [6, 7], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [7, 10], [7, 11], [7, 12], [7, 13], [8, 10], [8, 11], [8, 12], [9, 10], [9, 12], [9, 13], [10, 11], [10, 13], [11, 12], [11, 13], [12, 13]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s6/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..eebb666aca0229eb870a45692dc5c0416c894684 --- /dev/null +++ b/tasks/construct-rlve-maximum-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, 2, 3, 4, 6, 10]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l2-s6/tests/check.py b/tasks/construct-rlve-maximum-clique-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-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-l2-s6/tests/instance.json b/tasks/construct-rlve-maximum-clique-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0a2b7f5515c17a4c5d0be925aa5c8b78f76ba986 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 7, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 8], [1, 9], [1, 10], [1, 12], [1, 13], [2, 3], [2, 4], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 13], [3, 4], [3, 5], [3, 6], [3, 10], [3, 12], [3, 13], [4, 5], [4, 6], [4, 7], [4, 8], [4, 10], [4, 11], [4, 12], [4, 13], [5, 6], [5, 7], [5, 10], [5, 11], [6, 7], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [7, 10], [7, 11], [7, 12], [7, 13], [8, 10], [8, 11], [8, 12], [9, 10], [9, 12], [9, 13], [10, 11], [10, 13], [11, 12], [11, 13], [12, 13]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s6/tests/run.py b/tasks/construct-rlve-maximum-clique-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-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-rlve-maximum-clique-l2-s6/tests/test.sh b/tasks/construct-rlve-maximum-clique-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-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-rlve-maximum-clique-l2-s8/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-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-rlve-maximum-clique-l2-s8/environment/instance.json b/tasks/construct-rlve-maximum-clique-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..19a12ccffdc21db6795f5ef0a7d5fb118a6957eb --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 6, "edges": [[0, 1], [0, 3], [0, 4], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [1, 2], [1, 4], [1, 5], [1, 6], [1, 13], [2, 3], [2, 5], [2, 7], [2, 8], [2, 9], [2, 12], [3, 4], [3, 5], [3, 6], [3, 7], [3, 9], [3, 12], [3, 13], [4, 6], [4, 8], [4, 10], [4, 11], [5, 6], [5, 7], [5, 9], [5, 11], [5, 12], [6, 7], [6, 8], [6, 11], [6, 13], [7, 9], [7, 12], [7, 13], [8, 9], [9, 12], [9, 13], [10, 12], [11, 12], [11, 13], [12, 13]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s8/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8878d1b517a654639976eefdb104ab32e9730cf3 --- /dev/null +++ b/tasks/construct-rlve-maximum-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": [2, 3, 5, 7, 9, 12]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l2-s8/tests/check.py b/tasks/construct-rlve-maximum-clique-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-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-l2-s8/tests/instance.json b/tasks/construct-rlve-maximum-clique-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..19a12ccffdc21db6795f5ef0a7d5fb118a6957eb --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 6, "edges": [[0, 1], [0, 3], [0, 4], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [1, 2], [1, 4], [1, 5], [1, 6], [1, 13], [2, 3], [2, 5], [2, 7], [2, 8], [2, 9], [2, 12], [3, 4], [3, 5], [3, 6], [3, 7], [3, 9], [3, 12], [3, 13], [4, 6], [4, 8], [4, 10], [4, 11], [5, 6], [5, 7], [5, 9], [5, 11], [5, 12], [6, 7], [6, 8], [6, 11], [6, 13], [7, 9], [7, 12], [7, 13], [8, 9], [9, 12], [9, 13], [10, 12], [11, 12], [11, 13], [12, 13]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s8/tests/run.py b/tasks/construct-rlve-maximum-clique-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-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-rlve-maximum-clique-l2-s8/tests/test.sh b/tasks/construct-rlve-maximum-clique-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-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-rlve-maximum-clique-l6-s7/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l6-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-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-rlve-maximum-clique-l6-s7/environment/instance.json b/tasks/construct-rlve-maximum-clique-l6-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d4225ab6757cb4026f365f9c3368e610ca524a7a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 11, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 9], [0, 11], [0, 12], [0, 13], [0, 14], [0, 17], [0, 18], [0, 19], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29], [0, 32], [0, 33], [0, 34], [0, 35], [0, 37], [0, 38], [0, 41], [0, 42], [0, 43], [0, 44], [0, 46], [0, 47], [0, 48], [0, 49], [0, 50], [0, 51], [0, 52], [1, 2], [1, 4], [1, 5], [1, 8], [1, 10], [1, 12], [1, 13], [1, 14], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 23], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 33], [1, 36], [1, 37], [1, 38], [1, 40], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 47], [1, 48], [1, 51], [1, 52], [1, 53], [1, 54], [1, 55], [2, 3], [2, 6], [2, 7], [2, 8], [2, 9], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 17], [2, 18], [2, 19], [2, 22], [2, 23], [2, 24], [2, 26], [2, 27], [2, 29], [2, 30], [2, 31], [2, 33], [2, 34], [2, 36], [2, 40], [2, 41], [2, 43], [2, 44], [2, 45], [2, 48], [2, 49], [2, 50], [2, 52], [2, 53], [2, 54], [3, 4], [3, 5], [3, 6], [3, 14], [3, 15], [3, 16], [3, 18], [3, 21], [3, 23], [3, 24], [3, 25], [3, 27], [3, 29], [3, 30], [3, 32], [3, 33], [3, 34], [3, 35], [3, 38], [3, 39], [3, 40], [3, 42], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 51], [3, 54], [3, 55], [4, 6], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 15], [4, 16], [4, 17], [4, 19], [4, 21], [4, 23], [4, 24], [4, 26], [4, 27], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 35], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 42], [4, 43], [4, 45], [4, 46], [4, 47], [4, 48], [4, 49], [4, 54], [4, 55], [5, 6], [5, 8], [5, 11], [5, 12], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 22], [5, 23], [5, 24], [5, 26], [5, 27], [5, 28], [5, 30], [5, 34], [5, 36], [5, 37], [5, 38], [5, 40], [5, 42], [5, 43], [5, 45], [5, 46], [5, 47], [5, 48], [5, 51], [5, 52], [5, 54], [5, 55], [6, 7], [6, 9], [6, 11], [6, 14], [6, 17], [6, 18], [6, 19], [6, 21], [6, 22], [6, 24], [6, 25], [6, 26], [6, 28], [6, 34], [6, 35], [6, 37], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 44], [6, 46], [6, 48], [6, 49], [6, 50], [6, 51], [6, 52], [6, 53], [6, 54], [6, 55], [7, 8], [7, 9], [7, 13], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 29], [7, 30], [7, 31], [7, 32], [7, 34], [7, 37], [7, 39], [7, 42], [7, 43], [7, 44], [7, 45], [7, 46], [7, 48], [7, 49], [7, 50], [7, 51], [7, 52], [7, 53], [7, 55], [8, 9], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 19], [8, 20], [8, 21], [8, 22], [8, 23], [8, 25], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [8, 37], [8, 38], [8, 39], [8, 40], [8, 43], [8, 45], [8, 46], [8, 51], [8, 52], [8, 53], [8, 54], [9, 12], [9, 13], [9, 14], [9, 15], [9, 17], [9, 19], [9, 20], [9, 21], [9, 24], [9, 26], [9, 27], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 36], [9, 37], [9, 38], [9, 42], [9, 43], [9, 44], [9, 45], [9, 46], [9, 47], [9, 49], [9, 50], [9, 52], [9, 53], [9, 54], [9, 55], [10, 11], [10, 12], [10, 13], [10, 14], [10, 16], [10, 17], [10, 20], [10, 21], [10, 25], [10, 26], [10, 27], [10, 28], [10, 29], [10, 30], [10, 31], [10, 34], [10, 35], [10, 36], [10, 37], [10, 38], [10, 39], [10, 40], [10, 42], [10, 44], [10, 45], [10, 48], [10, 50], [10, 51], [10, 52], [10, 54], [10, 55], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 22], [11, 23], [11, 25], [11, 27], [11, 28], [11, 30], [11, 31], [11, 32], [11, 33], [11, 35], [11, 36], [11, 37], [11, 38], [11, 40], [11, 41], [11, 42], [11, 43], [11, 44], [11, 45], [11, 49], [11, 51], [11, 53], [11, 54], [12, 13], [12, 14], [12, 15], [12, 16], [12, 18], [12, 19], [12, 20], [12, 21], [12, 23], [12, 24], [12, 25], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 33], [12, 34], [12, 36], [12, 37], [12, 38], [12, 39], [12, 40], [12, 41], [12, 42], [12, 43], [12, 44], [12, 45], [12, 46], [12, 48], [12, 50], [12, 51], [12, 53], [12, 54], [12, 55], [13, 14], [13, 15], [13, 16], [13, 18], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 26], [13, 27], [13, 28], [13, 31], [13, 36], [13, 37], [13, 38], [13, 39], [13, 40], [13, 41], [13, 42], [13, 43], [13, 46], [13, 47], [13, 49], [13, 50], [13, 51], [13, 53], [14, 15], [14, 16], [14, 17], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 26], [14, 28], [14, 29], [14, 31], [14, 33], [14, 34], [14, 35], [14, 37], [14, 38], [14, 39], [14, 40], [14, 41], [14, 42], [14, 44], [14, 45], [14, 47], [14, 49], [14, 51], [14, 52], [14, 53], [14, 54], [14, 55], [15, 17], [15, 22], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 32], [15, 33], [15, 34], [15, 35], [15, 36], [15, 38], [15, 42], [15, 43], [15, 44], [15, 45], [15, 46], [15, 47], [15, 49], [15, 50], [15, 51], [15, 52], [15, 53], [16, 17], [16, 19], [16, 20], [16, 22], [16, 23], [16, 24], [16, 26], [16, 29], [16, 30], [16, 31], [16, 32], [16, 34], [16, 35], [16, 36], [16, 37], [16, 39], [16, 42], [16, 43], [16, 44], [16, 45], [16, 47], [16, 48], [16, 49], [16, 50], [16, 51], [16, 53], [16, 54], [16, 55], [17, 18], [17, 19], [17, 22], [17, 23], [17, 24], [17, 26], [17, 27], [17, 28], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [17, 36], [17, 37], [17, 38], [17, 39], [17, 41], [17, 42], [17, 44], [17, 45], [17, 47], [17, 48], [17, 49], [17, 50], [17, 53], [18, 19], [18, 20], [18, 21], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 30], [18, 31], [18, 32], [18, 33], [18, 35], [18, 37], [18, 40], [18, 41], [18, 42], [18, 44], [18, 45], [18, 47], [18, 48], [18, 49], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [18, 55], [19, 20], [19, 21], [19, 23], [19, 26], [19, 27], [19, 32], [19, 33], [19, 35], [19, 36], [19, 37], [19, 39], [19, 41], [19, 42], [19, 43], [19, 44], [19, 46], [19, 47], [19, 48], [19, 49], [19, 51], [19, 52], [19, 55], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 33], [20, 35], [20, 37], [20, 39], [20, 40], [20, 42], [20, 43], [20, 44], [20, 45], [20, 46], [20, 47], [20, 48], [20, 50], [20, 51], [20, 52], [20, 53], [20, 54], [20, 55], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 32], [21, 33], [21, 34], [21, 36], [21, 39], [21, 40], [21, 41], [21, 44], [21, 45], [21, 47], [21, 48], [21, 49], [21, 50], [21, 51], [21, 52], [21, 55], [22, 23], [22, 28], [22, 29], [22, 30], [22, 31], [22, 33], [22, 34], [22, 36], [22, 38], [22, 39], [22, 40], [22, 41], [22, 43], [22, 44], [22, 45], [22, 47], [22, 51], [22, 52], [22, 53], [22, 54], [22, 55], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [23, 36], [23, 37], [23, 38], [23, 41], [23, 46], [23, 47], [23, 48], [23, 49], [23, 50], [23, 51], [23, 53], [23, 54], [24, 25], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 36], [24, 37], [24, 38], [24, 39], [24, 41], [24, 42], [24, 44], [24, 45], [24, 46], [24, 47], [24, 48], [24, 49], [24, 50], [24, 53], [24, 54], [24, 55], [25, 26], [25, 27], [25, 28], [25, 29], [25, 31], [25, 33], [25, 35], [25, 36], [25, 37], [25, 39], [25, 40], [25, 41], [25, 42], [25, 43], [25, 44], [25, 47], [25, 48], [25, 50], [25, 52], [25, 53], [25, 55], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [26, 36], [26, 37], [26, 38], [26, 39], [26, 41], [26, 42], [26, 43], [26, 44], [26, 48], [26, 49], [26, 50], [26, 51], [26, 53], [26, 54], [27, 29], [27, 31], [27, 32], [27, 33], [27, 35], [27, 36], [27, 37], [27, 40], [27, 41], [27, 42], [27, 43], [27, 46], [27, 47], [27, 48], [27, 49], [27, 50], [27, 52], [27, 55], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 39], [28, 40], [28, 41], [28, 42], [28, 43], [28, 44], [28, 47], [28, 49], [28, 51], [28, 55], [29, 31], [29, 33], [29, 34], [29, 36], [29, 37], [29, 38], [29, 39], [29, 40], [29, 42], [29, 44], [29, 46], [29, 50], [29, 52], [29, 53], [29, 54], [29, 55], [30, 32], [30, 33], [30, 34], [30, 35], [30, 36], [30, 37], [30, 38], [30, 42], [30, 43], [30, 44], [30, 46], [30, 47], [30, 48], [30, 49], [30, 52], [30, 53], [30, 55], [31, 32], [31, 33], [31, 35], [31, 36], [31, 37], [31, 39], [31, 41], [31, 43], [31, 45], [31, 46], [31, 47], [31, 48], [31, 49], [31, 52], [31, 54], [31, 55], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 38], [32, 39], [32, 41], [32, 43], [32, 46], [32, 48], [32, 50], [32, 51], [32, 52], [32, 54], [33, 35], [33, 36], [33, 38], [33, 39], [33, 40], [33, 41], [33, 43], [33, 44], [33, 45], [33, 46], [33, 47], [33, 48], [33, 50], [33, 51], [33, 54], [33, 55], [34, 35], [34, 36], [34, 37], [34, 39], [34, 40], [34, 41], [34, 42], [34, 43], [34, 44], [34, 45], [34, 46], [34, 48], [34, 49], [34, 50], [34, 51], [34, 52], [34, 53], [34, 54], [34, 55], [35, 36], [35, 37], [35, 38], [35, 40], [35, 41], [35, 42], [35, 44], [35, 45], [35, 48], [35, 49], [35, 50], [35, 51], [35, 52], [35, 53], [36, 37], [36, 38], [36, 39], [36, 40], [36, 41], [36, 42], [36, 43], [36, 44], [36, 45], [36, 46], [36, 47], [36, 48], [36, 49], [36, 50], [36, 51], [36, 53], [36, 55], [37, 39], [37, 40], [37, 41], [37, 42], [37, 43], [37, 45], [37, 46], [37, 47], [37, 49], [37, 51], [37, 52], [37, 53], [37, 55], [38, 39], [38, 40], [38, 41], [38, 42], [38, 44], [38, 46], [38, 47], [38, 48], [38, 49], [38, 50], [38, 53], [38, 54], [39, 40], [39, 43], [39, 44], [39, 45], [39, 46], [39, 47], [39, 48], [39, 49], [39, 51], [39, 53], [39, 54], [39, 55], [40, 41], [40, 42], [40, 44], [40, 46], [40, 47], [40, 48], [40, 49], [40, 50], [40, 52], [40, 54], [40, 55], [41, 42], [41, 43], [41, 44], [41, 45], [41, 48], [41, 49], [41, 50], [41, 52], [41, 53], [41, 54], [42, 44], [42, 46], [42, 48], [42, 49], [42, 50], [42, 53], [42, 54], [43, 44], [43, 46], [43, 48], [43, 49], [43, 50], [43, 51], [43, 52], [43, 55], [44, 45], [44, 46], [44, 47], [44, 49], [44, 51], [44, 52], [45, 46], [45, 49], [45, 50], [45, 52], [45, 53], [45, 55], [46, 47], [46, 48], [46, 50], [46, 51], [46, 54], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [47, 54], [47, 55], [48, 49], [48, 50], [48, 52], [48, 53], [48, 54], [48, 55], [49, 50], [49, 51], [49, 52], [49, 53], [49, 54], [49, 55], [50, 51], [50, 53], [50, 54], [50, 55], [51, 52], [51, 53], [51, 54], [52, 53], [52, 54], [53, 54], [53, 55], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s7/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l6-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7ca583e1e2e43b9dd13ad9ca357c8b840838bdbc --- /dev/null +++ b/tasks/construct-rlve-maximum-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": [0, 6, 9, 14, 17, 24, 28, 34, 42, 44, 49]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l6-s7/tests/check.py b/tasks/construct-rlve-maximum-clique-l6-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-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-l6-s7/tests/instance.json b/tasks/construct-rlve-maximum-clique-l6-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d4225ab6757cb4026f365f9c3368e610ca524a7a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 11, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 9], [0, 11], [0, 12], [0, 13], [0, 14], [0, 17], [0, 18], [0, 19], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29], [0, 32], [0, 33], [0, 34], [0, 35], [0, 37], [0, 38], [0, 41], [0, 42], [0, 43], [0, 44], [0, 46], [0, 47], [0, 48], [0, 49], [0, 50], [0, 51], [0, 52], [1, 2], [1, 4], [1, 5], [1, 8], [1, 10], [1, 12], [1, 13], [1, 14], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 23], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 33], [1, 36], [1, 37], [1, 38], [1, 40], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 47], [1, 48], [1, 51], [1, 52], [1, 53], [1, 54], [1, 55], [2, 3], [2, 6], [2, 7], [2, 8], [2, 9], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 17], [2, 18], [2, 19], [2, 22], [2, 23], [2, 24], [2, 26], [2, 27], [2, 29], [2, 30], [2, 31], [2, 33], [2, 34], [2, 36], [2, 40], [2, 41], [2, 43], [2, 44], [2, 45], [2, 48], [2, 49], [2, 50], [2, 52], [2, 53], [2, 54], [3, 4], [3, 5], [3, 6], [3, 14], [3, 15], [3, 16], [3, 18], [3, 21], [3, 23], [3, 24], [3, 25], [3, 27], [3, 29], [3, 30], [3, 32], [3, 33], [3, 34], [3, 35], [3, 38], [3, 39], [3, 40], [3, 42], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 51], [3, 54], [3, 55], [4, 6], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 15], [4, 16], [4, 17], [4, 19], [4, 21], [4, 23], [4, 24], [4, 26], [4, 27], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 35], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 42], [4, 43], [4, 45], [4, 46], [4, 47], [4, 48], [4, 49], [4, 54], [4, 55], [5, 6], [5, 8], [5, 11], [5, 12], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 22], [5, 23], [5, 24], [5, 26], [5, 27], [5, 28], [5, 30], [5, 34], [5, 36], [5, 37], [5, 38], [5, 40], [5, 42], [5, 43], [5, 45], [5, 46], [5, 47], [5, 48], [5, 51], [5, 52], [5, 54], [5, 55], [6, 7], [6, 9], [6, 11], [6, 14], [6, 17], [6, 18], [6, 19], [6, 21], [6, 22], [6, 24], [6, 25], [6, 26], [6, 28], [6, 34], [6, 35], [6, 37], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 44], [6, 46], [6, 48], [6, 49], [6, 50], [6, 51], [6, 52], [6, 53], [6, 54], [6, 55], [7, 8], [7, 9], [7, 13], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 29], [7, 30], [7, 31], [7, 32], [7, 34], [7, 37], [7, 39], [7, 42], [7, 43], [7, 44], [7, 45], [7, 46], [7, 48], [7, 49], [7, 50], [7, 51], [7, 52], [7, 53], [7, 55], [8, 9], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 19], [8, 20], [8, 21], [8, 22], [8, 23], [8, 25], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [8, 37], [8, 38], [8, 39], [8, 40], [8, 43], [8, 45], [8, 46], [8, 51], [8, 52], [8, 53], [8, 54], [9, 12], [9, 13], [9, 14], [9, 15], [9, 17], [9, 19], [9, 20], [9, 21], [9, 24], [9, 26], [9, 27], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 36], [9, 37], [9, 38], [9, 42], [9, 43], [9, 44], [9, 45], [9, 46], [9, 47], [9, 49], [9, 50], [9, 52], [9, 53], [9, 54], [9, 55], [10, 11], [10, 12], [10, 13], [10, 14], [10, 16], [10, 17], [10, 20], [10, 21], [10, 25], [10, 26], [10, 27], [10, 28], [10, 29], [10, 30], [10, 31], [10, 34], [10, 35], [10, 36], [10, 37], [10, 38], [10, 39], [10, 40], [10, 42], [10, 44], [10, 45], [10, 48], [10, 50], [10, 51], [10, 52], [10, 54], [10, 55], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 22], [11, 23], [11, 25], [11, 27], [11, 28], [11, 30], [11, 31], [11, 32], [11, 33], [11, 35], [11, 36], [11, 37], [11, 38], [11, 40], [11, 41], [11, 42], [11, 43], [11, 44], [11, 45], [11, 49], [11, 51], [11, 53], [11, 54], [12, 13], [12, 14], [12, 15], [12, 16], [12, 18], [12, 19], [12, 20], [12, 21], [12, 23], [12, 24], [12, 25], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 33], [12, 34], [12, 36], [12, 37], [12, 38], [12, 39], [12, 40], [12, 41], [12, 42], [12, 43], [12, 44], [12, 45], [12, 46], [12, 48], [12, 50], [12, 51], [12, 53], [12, 54], [12, 55], [13, 14], [13, 15], [13, 16], [13, 18], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 26], [13, 27], [13, 28], [13, 31], [13, 36], [13, 37], [13, 38], [13, 39], [13, 40], [13, 41], [13, 42], [13, 43], [13, 46], [13, 47], [13, 49], [13, 50], [13, 51], [13, 53], [14, 15], [14, 16], [14, 17], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 26], [14, 28], [14, 29], [14, 31], [14, 33], [14, 34], [14, 35], [14, 37], [14, 38], [14, 39], [14, 40], [14, 41], [14, 42], [14, 44], [14, 45], [14, 47], [14, 49], [14, 51], [14, 52], [14, 53], [14, 54], [14, 55], [15, 17], [15, 22], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 32], [15, 33], [15, 34], [15, 35], [15, 36], [15, 38], [15, 42], [15, 43], [15, 44], [15, 45], [15, 46], [15, 47], [15, 49], [15, 50], [15, 51], [15, 52], [15, 53], [16, 17], [16, 19], [16, 20], [16, 22], [16, 23], [16, 24], [16, 26], [16, 29], [16, 30], [16, 31], [16, 32], [16, 34], [16, 35], [16, 36], [16, 37], [16, 39], [16, 42], [16, 43], [16, 44], [16, 45], [16, 47], [16, 48], [16, 49], [16, 50], [16, 51], [16, 53], [16, 54], [16, 55], [17, 18], [17, 19], [17, 22], [17, 23], [17, 24], [17, 26], [17, 27], [17, 28], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [17, 36], [17, 37], [17, 38], [17, 39], [17, 41], [17, 42], [17, 44], [17, 45], [17, 47], [17, 48], [17, 49], [17, 50], [17, 53], [18, 19], [18, 20], [18, 21], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 30], [18, 31], [18, 32], [18, 33], [18, 35], [18, 37], [18, 40], [18, 41], [18, 42], [18, 44], [18, 45], [18, 47], [18, 48], [18, 49], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [18, 55], [19, 20], [19, 21], [19, 23], [19, 26], [19, 27], [19, 32], [19, 33], [19, 35], [19, 36], [19, 37], [19, 39], [19, 41], [19, 42], [19, 43], [19, 44], [19, 46], [19, 47], [19, 48], [19, 49], [19, 51], [19, 52], [19, 55], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 33], [20, 35], [20, 37], [20, 39], [20, 40], [20, 42], [20, 43], [20, 44], [20, 45], [20, 46], [20, 47], [20, 48], [20, 50], [20, 51], [20, 52], [20, 53], [20, 54], [20, 55], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 32], [21, 33], [21, 34], [21, 36], [21, 39], [21, 40], [21, 41], [21, 44], [21, 45], [21, 47], [21, 48], [21, 49], [21, 50], [21, 51], [21, 52], [21, 55], [22, 23], [22, 28], [22, 29], [22, 30], [22, 31], [22, 33], [22, 34], [22, 36], [22, 38], [22, 39], [22, 40], [22, 41], [22, 43], [22, 44], [22, 45], [22, 47], [22, 51], [22, 52], [22, 53], [22, 54], [22, 55], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [23, 36], [23, 37], [23, 38], [23, 41], [23, 46], [23, 47], [23, 48], [23, 49], [23, 50], [23, 51], [23, 53], [23, 54], [24, 25], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 36], [24, 37], [24, 38], [24, 39], [24, 41], [24, 42], [24, 44], [24, 45], [24, 46], [24, 47], [24, 48], [24, 49], [24, 50], [24, 53], [24, 54], [24, 55], [25, 26], [25, 27], [25, 28], [25, 29], [25, 31], [25, 33], [25, 35], [25, 36], [25, 37], [25, 39], [25, 40], [25, 41], [25, 42], [25, 43], [25, 44], [25, 47], [25, 48], [25, 50], [25, 52], [25, 53], [25, 55], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [26, 36], [26, 37], [26, 38], [26, 39], [26, 41], [26, 42], [26, 43], [26, 44], [26, 48], [26, 49], [26, 50], [26, 51], [26, 53], [26, 54], [27, 29], [27, 31], [27, 32], [27, 33], [27, 35], [27, 36], [27, 37], [27, 40], [27, 41], [27, 42], [27, 43], [27, 46], [27, 47], [27, 48], [27, 49], [27, 50], [27, 52], [27, 55], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 39], [28, 40], [28, 41], [28, 42], [28, 43], [28, 44], [28, 47], [28, 49], [28, 51], [28, 55], [29, 31], [29, 33], [29, 34], [29, 36], [29, 37], [29, 38], [29, 39], [29, 40], [29, 42], [29, 44], [29, 46], [29, 50], [29, 52], [29, 53], [29, 54], [29, 55], [30, 32], [30, 33], [30, 34], [30, 35], [30, 36], [30, 37], [30, 38], [30, 42], [30, 43], [30, 44], [30, 46], [30, 47], [30, 48], [30, 49], [30, 52], [30, 53], [30, 55], [31, 32], [31, 33], [31, 35], [31, 36], [31, 37], [31, 39], [31, 41], [31, 43], [31, 45], [31, 46], [31, 47], [31, 48], [31, 49], [31, 52], [31, 54], [31, 55], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 38], [32, 39], [32, 41], [32, 43], [32, 46], [32, 48], [32, 50], [32, 51], [32, 52], [32, 54], [33, 35], [33, 36], [33, 38], [33, 39], [33, 40], [33, 41], [33, 43], [33, 44], [33, 45], [33, 46], [33, 47], [33, 48], [33, 50], [33, 51], [33, 54], [33, 55], [34, 35], [34, 36], [34, 37], [34, 39], [34, 40], [34, 41], [34, 42], [34, 43], [34, 44], [34, 45], [34, 46], [34, 48], [34, 49], [34, 50], [34, 51], [34, 52], [34, 53], [34, 54], [34, 55], [35, 36], [35, 37], [35, 38], [35, 40], [35, 41], [35, 42], [35, 44], [35, 45], [35, 48], [35, 49], [35, 50], [35, 51], [35, 52], [35, 53], [36, 37], [36, 38], [36, 39], [36, 40], [36, 41], [36, 42], [36, 43], [36, 44], [36, 45], [36, 46], [36, 47], [36, 48], [36, 49], [36, 50], [36, 51], [36, 53], [36, 55], [37, 39], [37, 40], [37, 41], [37, 42], [37, 43], [37, 45], [37, 46], [37, 47], [37, 49], [37, 51], [37, 52], [37, 53], [37, 55], [38, 39], [38, 40], [38, 41], [38, 42], [38, 44], [38, 46], [38, 47], [38, 48], [38, 49], [38, 50], [38, 53], [38, 54], [39, 40], [39, 43], [39, 44], [39, 45], [39, 46], [39, 47], [39, 48], [39, 49], [39, 51], [39, 53], [39, 54], [39, 55], [40, 41], [40, 42], [40, 44], [40, 46], [40, 47], [40, 48], [40, 49], [40, 50], [40, 52], [40, 54], [40, 55], [41, 42], [41, 43], [41, 44], [41, 45], [41, 48], [41, 49], [41, 50], [41, 52], [41, 53], [41, 54], [42, 44], [42, 46], [42, 48], [42, 49], [42, 50], [42, 53], [42, 54], [43, 44], [43, 46], [43, 48], [43, 49], [43, 50], [43, 51], [43, 52], [43, 55], [44, 45], [44, 46], [44, 47], [44, 49], [44, 51], [44, 52], [45, 46], [45, 49], [45, 50], [45, 52], [45, 53], [45, 55], [46, 47], [46, 48], [46, 50], [46, 51], [46, 54], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [47, 54], [47, 55], [48, 49], [48, 50], [48, 52], [48, 53], [48, 54], [48, 55], [49, 50], [49, 51], [49, 52], [49, 53], [49, 54], [49, 55], [50, 51], [50, 53], [50, 54], [50, 55], [51, 52], [51, 53], [51, 54], [52, 53], [52, 54], [53, 54], [53, 55], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s7/tests/run.py b/tasks/construct-rlve-maximum-clique-l6-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-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-rlve-maximum-clique-l6-s7/tests/test.sh b/tasks/construct-rlve-maximum-clique-l6-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-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-rlve-maximum-clique-l6-s9/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-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-rlve-maximum-clique-l6-s9/environment/instance.json b/tasks/construct-rlve-maximum-clique-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..58a977ce0cab6200ae2083b0b7ec52403800e126 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 9, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 12], [0, 13], [0, 14], [0, 16], [0, 17], [0, 18], [0, 22], [0, 23], [0, 24], [0, 27], [0, 28], [0, 30], [0, 31], [0, 32], [0, 35], [0, 37], [0, 42], [0, 43], [0, 45], [0, 48], [0, 49], [0, 50], [0, 51], [0, 52], [0, 53], [0, 55], [1, 4], [1, 5], [1, 6], [1, 8], [1, 10], [1, 11], [1, 12], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 21], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 29], [1, 30], [1, 33], [1, 35], [1, 36], [1, 37], [1, 38], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 48], [1, 49], [1, 51], [1, 55], [2, 3], [2, 4], [2, 5], [2, 7], [2, 8], [2, 9], [2, 11], [2, 12], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 22], [2, 24], [2, 25], [2, 28], [2, 30], [2, 31], [2, 33], [2, 39], [2, 40], [2, 42], [2, 44], [2, 45], [2, 46], [2, 48], [2, 50], [2, 52], [2, 53], [2, 54], [3, 4], [3, 6], [3, 7], [3, 11], [3, 12], [3, 14], [3, 16], [3, 17], [3, 22], [3, 24], [3, 25], [3, 29], [3, 30], [3, 32], [3, 34], [3, 36], [3, 37], [3, 38], [3, 39], [3, 40], [3, 45], [3, 47], [3, 50], [3, 52], [3, 54], [3, 55], [4, 6], [4, 7], [4, 8], [4, 12], [4, 18], [4, 20], [4, 21], [4, 22], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 30], [4, 31], [4, 42], [4, 44], [4, 45], [4, 46], [4, 47], [4, 48], [4, 50], [4, 51], [4, 55], [5, 6], [5, 7], [5, 12], [5, 13], [5, 14], [5, 15], [5, 18], [5, 25], [5, 26], [5, 28], [5, 30], [5, 31], [5, 32], [5, 34], [5, 36], [5, 39], [5, 41], [5, 42], [5, 43], [5, 44], [5, 45], [5, 46], [5, 47], [5, 48], [5, 49], [5, 50], [5, 52], [5, 53], [5, 55], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 15], [6, 16], [6, 17], [6, 19], [6, 22], [6, 24], [6, 26], [6, 27], [6, 28], [6, 29], [6, 33], [6, 37], [6, 38], [6, 40], [6, 41], [6, 42], [6, 43], [6, 46], [6, 49], [6, 52], [6, 53], [6, 54], [6, 55], [7, 10], [7, 12], [7, 13], [7, 18], [7, 19], [7, 23], [7, 24], [7, 27], [7, 29], [7, 31], [7, 32], [7, 33], [7, 35], [7, 37], [7, 39], [7, 40], [7, 44], [7, 45], [7, 46], [7, 48], [7, 49], [7, 51], [7, 53], [7, 54], [7, 55], [8, 9], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 20], [8, 21], [8, 22], [8, 26], [8, 28], [8, 30], [8, 32], [8, 34], [8, 37], [8, 38], [8, 41], [8, 42], [8, 44], [8, 45], [8, 46], [8, 49], [8, 51], [8, 52], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 16], [9, 18], [9, 20], [9, 21], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 30], [9, 33], [9, 35], [9, 36], [9, 38], [9, 41], [9, 42], [9, 43], [9, 45], [9, 46], [9, 48], [9, 49], [9, 50], [9, 51], [9, 53], [9, 55], [10, 11], [10, 13], [10, 14], [10, 15], [10, 17], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 25], [10, 27], [10, 28], [10, 30], [10, 32], [10, 33], [10, 34], [10, 35], [10, 38], [10, 41], [10, 42], [10, 45], [10, 48], [10, 49], [10, 50], [10, 51], [10, 52], [10, 54], [10, 55], [11, 12], [11, 13], [11, 15], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 23], [11, 24], [11, 25], [11, 28], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 34], [11, 36], [11, 37], [11, 40], [11, 41], [11, 45], [11, 47], [11, 49], [11, 51], [11, 54], [12, 14], [12, 17], [12, 18], [12, 20], [12, 21], [12, 24], [12, 25], [12, 26], [12, 27], [12, 29], [12, 30], [12, 32], [12, 33], [12, 36], [12, 40], [12, 43], [12, 44], [12, 45], [12, 46], [12, 49], [12, 51], [12, 52], [12, 54], [13, 16], [13, 17], [13, 19], [13, 22], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 29], [13, 31], [13, 34], [13, 35], [13, 37], [13, 38], [13, 43], [13, 44], [13, 47], [13, 48], [13, 49], [13, 51], [13, 52], [13, 53], [13, 55], [14, 15], [14, 16], [14, 17], [14, 18], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 30], [14, 32], [14, 34], [14, 36], [14, 37], [14, 39], [14, 40], [14, 41], [14, 42], [14, 43], [14, 44], [14, 46], [14, 47], [14, 48], [14, 49], [14, 50], [14, 51], [14, 52], [14, 53], [14, 54], [14, 55], [15, 17], [15, 19], [15, 21], [15, 22], [15, 23], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 31], [15, 33], [15, 36], [15, 37], [15, 41], [15, 44], [15, 46], [15, 47], [15, 48], [15, 51], [15, 52], [15, 53], [15, 55], [16, 17], [16, 19], [16, 23], [16, 24], [16, 25], [16, 27], [16, 28], [16, 29], [16, 30], [16, 32], [16, 33], [16, 35], [16, 36], [16, 37], [16, 39], [16, 45], [16, 47], [16, 52], [16, 53], [16, 54], [17, 19], [17, 22], [17, 23], [17, 24], [17, 27], [17, 29], [17, 30], [17, 32], [17, 33], [17, 35], [17, 37], [17, 38], [17, 39], [17, 40], [17, 41], [17, 44], [17, 45], [17, 51], [17, 52], [17, 53], [17, 54], [18, 19], [18, 21], [18, 23], [18, 24], [18, 28], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [18, 36], [18, 37], [18, 39], [18, 40], [18, 41], [18, 42], [18, 44], [18, 45], [18, 46], [18, 47], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [18, 55], [19, 20], [19, 22], [19, 25], [19, 29], [19, 30], [19, 31], [19, 32], [19, 33], [19, 34], [19, 36], [19, 38], [19, 40], [19, 41], [19, 42], [19, 43], [19, 44], [19, 45], [19, 47], [19, 49], [19, 51], [19, 52], [19, 53], [19, 54], [19, 55], [20, 24], [20, 25], [20, 29], [20, 30], [20, 31], [20, 32], [20, 37], [20, 39], [20, 41], [20, 44], [20, 47], [20, 48], [20, 50], [20, 51], [20, 54], [20, 55], [21, 23], [21, 24], [21, 25], [21, 26], [21, 28], [21, 29], [21, 31], [21, 33], [21, 34], [21, 35], [21, 37], [21, 38], [21, 40], [21, 42], [21, 44], [21, 47], [21, 50], [21, 51], [21, 52], [21, 53], [21, 54], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 30], [22, 31], [22, 33], [22, 34], [22, 36], [22, 44], [22, 45], [22, 46], [22, 48], [22, 50], [22, 52], [22, 55], [23, 24], [23, 25], [23, 26], [23, 30], [23, 31], [23, 33], [23, 36], [23, 37], [23, 38], [23, 39], [23, 40], [23, 41], [23, 42], [23, 43], [23, 45], [23, 46], [23, 49], [23, 50], [23, 51], [23, 52], [23, 53], [23, 54], [24, 27], [24, 28], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [24, 37], [24, 38], [24, 39], [24, 41], [24, 42], [24, 43], [24, 44], [24, 46], [24, 47], [24, 48], [24, 50], [24, 51], [24, 52], [24, 54], [24, 55], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 35], [25, 36], [25, 37], [25, 38], [25, 39], [25, 44], [25, 45], [25, 46], [25, 49], [25, 50], [25, 51], [25, 55], [26, 27], [26, 29], [26, 31], [26, 32], [26, 36], [26, 38], [26, 39], [26, 40], [26, 43], [26, 45], [26, 46], [26, 47], [26, 48], [26, 49], [26, 53], [26, 54], [26, 55], [27, 29], [27, 31], [27, 32], [27, 33], [27, 36], [27, 39], [27, 41], [27, 42], [27, 43], [27, 46], [27, 47], [27, 48], [27, 49], [27, 50], [27, 51], [27, 54], [27, 55], [28, 29], [28, 34], [28, 35], [28, 38], [28, 42], [28, 44], [28, 48], [28, 52], [29, 30], [29, 31], [29, 32], [29, 34], [29, 35], [29, 37], [29, 38], [29, 39], [29, 40], [29, 42], [29, 43], [29, 44], [29, 46], [29, 47], [29, 48], [29, 49], [29, 50], [29, 53], [29, 54], [29, 55], [30, 32], [30, 33], [30, 34], [30, 35], [30, 38], [30, 43], [30, 45], [30, 47], [30, 49], [30, 50], [30, 51], [30, 53], [30, 55], [31, 32], [31, 34], [31, 35], [31, 36], [31, 39], [31, 40], [31, 42], [31, 43], [31, 44], [31, 46], [31, 47], [31, 49], [31, 50], [31, 52], [31, 55], [32, 34], [32, 35], [32, 37], [32, 38], [32, 40], [32, 41], [32, 42], [32, 43], [32, 45], [32, 46], [32, 47], [32, 48], [32, 49], [32, 52], [32, 54], [32, 55], [33, 34], [33, 35], [33, 36], [33, 39], [33, 40], [33, 41], [33, 42], [33, 43], [33, 44], [33, 47], [33, 48], [33, 50], [33, 52], [33, 53], [33, 55], [34, 35], [34, 36], [34, 40], [34, 41], [34, 42], [34, 43], [34, 44], [34, 45], [34, 46], [34, 47], [34, 48], [34, 49], [34, 54], [34, 55], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 43], [35, 45], [35, 46], [35, 47], [35, 48], [35, 49], [35, 51], [35, 54], [35, 55], [36, 39], [36, 41], [36, 43], [36, 44], [36, 45], [36, 46], [36, 47], [36, 51], [36, 52], [36, 53], [36, 54], [37, 39], [37, 41], [37, 43], [37, 45], [37, 48], [37, 49], [37, 50], [37, 51], [37, 52], [37, 54], [37, 55], [38, 39], [38, 42], [38, 43], [38, 44], [38, 45], [38, 48], [38, 49], [38, 51], [38, 52], [39, 44], [39, 45], [39, 47], [39, 49], [39, 50], [39, 51], [39, 52], [39, 54], [39, 55], [40, 41], [40, 43], [40, 44], [40, 45], [40, 46], [40, 48], [40, 50], [40, 51], [40, 54], [41, 42], [41, 44], [41, 45], [41, 48], [41, 49], [41, 52], [41, 55], [42, 45], [42, 47], [42, 48], [42, 49], [42, 51], [42, 54], [42, 55], [43, 44], [43, 45], [43, 46], [43, 47], [43, 48], [43, 50], [43, 52], [43, 53], [43, 54], [43, 55], [44, 45], [44, 46], [44, 48], [44, 49], [44, 52], [44, 54], [45, 46], [45, 47], [45, 48], [45, 50], [45, 51], [45, 52], [46, 47], [46, 48], [46, 49], [46, 50], [46, 51], [46, 52], [47, 48], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [48, 49], [48, 51], [48, 52], [48, 53], [48, 54], [48, 55], [49, 50], [49, 54], [50, 51], [50, 55], [51, 52], [51, 53], [51, 54], [52, 53], [52, 54], [52, 55], [53, 54], [53, 55], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s9/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fe8844fabe3abda722ad4bd8759befc7802a5961 --- /dev/null +++ b/tasks/construct-rlve-maximum-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": [0, 3, 14, 16, 17, 24, 32, 37, 52]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l6-s9/tests/check.py b/tasks/construct-rlve-maximum-clique-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-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-l6-s9/tests/instance.json b/tasks/construct-rlve-maximum-clique-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..58a977ce0cab6200ae2083b0b7ec52403800e126 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 9, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 12], [0, 13], [0, 14], [0, 16], [0, 17], [0, 18], [0, 22], [0, 23], [0, 24], [0, 27], [0, 28], [0, 30], [0, 31], [0, 32], [0, 35], [0, 37], [0, 42], [0, 43], [0, 45], [0, 48], [0, 49], [0, 50], [0, 51], [0, 52], [0, 53], [0, 55], [1, 4], [1, 5], [1, 6], [1, 8], [1, 10], [1, 11], [1, 12], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 21], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 29], [1, 30], [1, 33], [1, 35], [1, 36], [1, 37], [1, 38], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 48], [1, 49], [1, 51], [1, 55], [2, 3], [2, 4], [2, 5], [2, 7], [2, 8], [2, 9], [2, 11], [2, 12], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 22], [2, 24], [2, 25], [2, 28], [2, 30], [2, 31], [2, 33], [2, 39], [2, 40], [2, 42], [2, 44], [2, 45], [2, 46], [2, 48], [2, 50], [2, 52], [2, 53], [2, 54], [3, 4], [3, 6], [3, 7], [3, 11], [3, 12], [3, 14], [3, 16], [3, 17], [3, 22], [3, 24], [3, 25], [3, 29], [3, 30], [3, 32], [3, 34], [3, 36], [3, 37], [3, 38], [3, 39], [3, 40], [3, 45], [3, 47], [3, 50], [3, 52], [3, 54], [3, 55], [4, 6], [4, 7], [4, 8], [4, 12], [4, 18], [4, 20], [4, 21], [4, 22], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 30], [4, 31], [4, 42], [4, 44], [4, 45], [4, 46], [4, 47], [4, 48], [4, 50], [4, 51], [4, 55], [5, 6], [5, 7], [5, 12], [5, 13], [5, 14], [5, 15], [5, 18], [5, 25], [5, 26], [5, 28], [5, 30], [5, 31], [5, 32], [5, 34], [5, 36], [5, 39], [5, 41], [5, 42], [5, 43], [5, 44], [5, 45], [5, 46], [5, 47], [5, 48], [5, 49], [5, 50], [5, 52], [5, 53], [5, 55], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 15], [6, 16], [6, 17], [6, 19], [6, 22], [6, 24], [6, 26], [6, 27], [6, 28], [6, 29], [6, 33], [6, 37], [6, 38], [6, 40], [6, 41], [6, 42], [6, 43], [6, 46], [6, 49], [6, 52], [6, 53], [6, 54], [6, 55], [7, 10], [7, 12], [7, 13], [7, 18], [7, 19], [7, 23], [7, 24], [7, 27], [7, 29], [7, 31], [7, 32], [7, 33], [7, 35], [7, 37], [7, 39], [7, 40], [7, 44], [7, 45], [7, 46], [7, 48], [7, 49], [7, 51], [7, 53], [7, 54], [7, 55], [8, 9], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 20], [8, 21], [8, 22], [8, 26], [8, 28], [8, 30], [8, 32], [8, 34], [8, 37], [8, 38], [8, 41], [8, 42], [8, 44], [8, 45], [8, 46], [8, 49], [8, 51], [8, 52], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 16], [9, 18], [9, 20], [9, 21], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 30], [9, 33], [9, 35], [9, 36], [9, 38], [9, 41], [9, 42], [9, 43], [9, 45], [9, 46], [9, 48], [9, 49], [9, 50], [9, 51], [9, 53], [9, 55], [10, 11], [10, 13], [10, 14], [10, 15], [10, 17], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 25], [10, 27], [10, 28], [10, 30], [10, 32], [10, 33], [10, 34], [10, 35], [10, 38], [10, 41], [10, 42], [10, 45], [10, 48], [10, 49], [10, 50], [10, 51], [10, 52], [10, 54], [10, 55], [11, 12], [11, 13], [11, 15], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 23], [11, 24], [11, 25], [11, 28], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 34], [11, 36], [11, 37], [11, 40], [11, 41], [11, 45], [11, 47], [11, 49], [11, 51], [11, 54], [12, 14], [12, 17], [12, 18], [12, 20], [12, 21], [12, 24], [12, 25], [12, 26], [12, 27], [12, 29], [12, 30], [12, 32], [12, 33], [12, 36], [12, 40], [12, 43], [12, 44], [12, 45], [12, 46], [12, 49], [12, 51], [12, 52], [12, 54], [13, 16], [13, 17], [13, 19], [13, 22], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 29], [13, 31], [13, 34], [13, 35], [13, 37], [13, 38], [13, 43], [13, 44], [13, 47], [13, 48], [13, 49], [13, 51], [13, 52], [13, 53], [13, 55], [14, 15], [14, 16], [14, 17], [14, 18], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 30], [14, 32], [14, 34], [14, 36], [14, 37], [14, 39], [14, 40], [14, 41], [14, 42], [14, 43], [14, 44], [14, 46], [14, 47], [14, 48], [14, 49], [14, 50], [14, 51], [14, 52], [14, 53], [14, 54], [14, 55], [15, 17], [15, 19], [15, 21], [15, 22], [15, 23], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 31], [15, 33], [15, 36], [15, 37], [15, 41], [15, 44], [15, 46], [15, 47], [15, 48], [15, 51], [15, 52], [15, 53], [15, 55], [16, 17], [16, 19], [16, 23], [16, 24], [16, 25], [16, 27], [16, 28], [16, 29], [16, 30], [16, 32], [16, 33], [16, 35], [16, 36], [16, 37], [16, 39], [16, 45], [16, 47], [16, 52], [16, 53], [16, 54], [17, 19], [17, 22], [17, 23], [17, 24], [17, 27], [17, 29], [17, 30], [17, 32], [17, 33], [17, 35], [17, 37], [17, 38], [17, 39], [17, 40], [17, 41], [17, 44], [17, 45], [17, 51], [17, 52], [17, 53], [17, 54], [18, 19], [18, 21], [18, 23], [18, 24], [18, 28], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [18, 36], [18, 37], [18, 39], [18, 40], [18, 41], [18, 42], [18, 44], [18, 45], [18, 46], [18, 47], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [18, 55], [19, 20], [19, 22], [19, 25], [19, 29], [19, 30], [19, 31], [19, 32], [19, 33], [19, 34], [19, 36], [19, 38], [19, 40], [19, 41], [19, 42], [19, 43], [19, 44], [19, 45], [19, 47], [19, 49], [19, 51], [19, 52], [19, 53], [19, 54], [19, 55], [20, 24], [20, 25], [20, 29], [20, 30], [20, 31], [20, 32], [20, 37], [20, 39], [20, 41], [20, 44], [20, 47], [20, 48], [20, 50], [20, 51], [20, 54], [20, 55], [21, 23], [21, 24], [21, 25], [21, 26], [21, 28], [21, 29], [21, 31], [21, 33], [21, 34], [21, 35], [21, 37], [21, 38], [21, 40], [21, 42], [21, 44], [21, 47], [21, 50], [21, 51], [21, 52], [21, 53], [21, 54], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 30], [22, 31], [22, 33], [22, 34], [22, 36], [22, 44], [22, 45], [22, 46], [22, 48], [22, 50], [22, 52], [22, 55], [23, 24], [23, 25], [23, 26], [23, 30], [23, 31], [23, 33], [23, 36], [23, 37], [23, 38], [23, 39], [23, 40], [23, 41], [23, 42], [23, 43], [23, 45], [23, 46], [23, 49], [23, 50], [23, 51], [23, 52], [23, 53], [23, 54], [24, 27], [24, 28], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [24, 37], [24, 38], [24, 39], [24, 41], [24, 42], [24, 43], [24, 44], [24, 46], [24, 47], [24, 48], [24, 50], [24, 51], [24, 52], [24, 54], [24, 55], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 35], [25, 36], [25, 37], [25, 38], [25, 39], [25, 44], [25, 45], [25, 46], [25, 49], [25, 50], [25, 51], [25, 55], [26, 27], [26, 29], [26, 31], [26, 32], [26, 36], [26, 38], [26, 39], [26, 40], [26, 43], [26, 45], [26, 46], [26, 47], [26, 48], [26, 49], [26, 53], [26, 54], [26, 55], [27, 29], [27, 31], [27, 32], [27, 33], [27, 36], [27, 39], [27, 41], [27, 42], [27, 43], [27, 46], [27, 47], [27, 48], [27, 49], [27, 50], [27, 51], [27, 54], [27, 55], [28, 29], [28, 34], [28, 35], [28, 38], [28, 42], [28, 44], [28, 48], [28, 52], [29, 30], [29, 31], [29, 32], [29, 34], [29, 35], [29, 37], [29, 38], [29, 39], [29, 40], [29, 42], [29, 43], [29, 44], [29, 46], [29, 47], [29, 48], [29, 49], [29, 50], [29, 53], [29, 54], [29, 55], [30, 32], [30, 33], [30, 34], [30, 35], [30, 38], [30, 43], [30, 45], [30, 47], [30, 49], [30, 50], [30, 51], [30, 53], [30, 55], [31, 32], [31, 34], [31, 35], [31, 36], [31, 39], [31, 40], [31, 42], [31, 43], [31, 44], [31, 46], [31, 47], [31, 49], [31, 50], [31, 52], [31, 55], [32, 34], [32, 35], [32, 37], [32, 38], [32, 40], [32, 41], [32, 42], [32, 43], [32, 45], [32, 46], [32, 47], [32, 48], [32, 49], [32, 52], [32, 54], [32, 55], [33, 34], [33, 35], [33, 36], [33, 39], [33, 40], [33, 41], [33, 42], [33, 43], [33, 44], [33, 47], [33, 48], [33, 50], [33, 52], [33, 53], [33, 55], [34, 35], [34, 36], [34, 40], [34, 41], [34, 42], [34, 43], [34, 44], [34, 45], [34, 46], [34, 47], [34, 48], [34, 49], [34, 54], [34, 55], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 43], [35, 45], [35, 46], [35, 47], [35, 48], [35, 49], [35, 51], [35, 54], [35, 55], [36, 39], [36, 41], [36, 43], [36, 44], [36, 45], [36, 46], [36, 47], [36, 51], [36, 52], [36, 53], [36, 54], [37, 39], [37, 41], [37, 43], [37, 45], [37, 48], [37, 49], [37, 50], [37, 51], [37, 52], [37, 54], [37, 55], [38, 39], [38, 42], [38, 43], [38, 44], [38, 45], [38, 48], [38, 49], [38, 51], [38, 52], [39, 44], [39, 45], [39, 47], [39, 49], [39, 50], [39, 51], [39, 52], [39, 54], [39, 55], [40, 41], [40, 43], [40, 44], [40, 45], [40, 46], [40, 48], [40, 50], [40, 51], [40, 54], [41, 42], [41, 44], [41, 45], [41, 48], [41, 49], [41, 52], [41, 55], [42, 45], [42, 47], [42, 48], [42, 49], [42, 51], [42, 54], [42, 55], [43, 44], [43, 45], [43, 46], [43, 47], [43, 48], [43, 50], [43, 52], [43, 53], [43, 54], [43, 55], [44, 45], [44, 46], [44, 48], [44, 49], [44, 52], [44, 54], [45, 46], [45, 47], [45, 48], [45, 50], [45, 51], [45, 52], [46, 47], [46, 48], [46, 49], [46, 50], [46, 51], [46, 52], [47, 48], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [48, 49], [48, 51], [48, 52], [48, 53], [48, 54], [48, 55], [49, 50], [49, 54], [50, 51], [50, 55], [51, 52], [51, 53], [51, 54], [52, 53], [52, 54], [52, 55], [53, 54], [53, 55], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s9/tests/run.py b/tasks/construct-rlve-maximum-clique-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-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-rlve-maximum-clique-l6-s9/tests/test.sh b/tasks/construct-rlve-maximum-clique-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-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-rlve-min-chromatic-number-l4-s3/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l4-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-rlve-min-chromatic-number-l4-s3/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l4-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f268f6f59107f7088b530d48abb03173abc00046 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l4-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "k": 4, "edges": [[0, 1], [0, 13], [1, 2], [1, 4], [1, 6], [1, 8], [1, 12], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [3, 4], [3, 13], [4, 6], [4, 11], [4, 16], [5, 6], [5, 8], [5, 10], [5, 11], [5, 12], [5, 14], [5, 16], [6, 8], [6, 9], [6, 15], [6, 16], [7, 14], [7, 16], [8, 11], [8, 12], [8, 15], [8, 17], [9, 14], [9, 15], [12, 17], [13, 16]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l4-s3/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l4-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fe5df5fff0d8c93065b406a9d4c3c77b12c5289b --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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' +{"colors": [0, 1, 0, 0, 2, 0, 3, 0, 2, 0, 1, 1, 3, 2, 1, 1, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l4-s3/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l4-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l4-s3/tests/check.py @@ -0,0 +1,10 @@ +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") + 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-rlve-min-chromatic-number-l4-s3/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l4-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f268f6f59107f7088b530d48abb03173abc00046 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l4-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "k": 4, "edges": [[0, 1], [0, 13], [1, 2], [1, 4], [1, 6], [1, 8], [1, 12], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [3, 4], [3, 13], [4, 6], [4, 11], [4, 16], [5, 6], [5, 8], [5, 10], [5, 11], [5, 12], [5, 14], [5, 16], [6, 8], [6, 9], [6, 15], [6, 16], [7, 14], [7, 16], [8, 11], [8, 12], [8, 15], [8, 17], [9, 14], [9, 15], [12, 17], [13, 16]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l4-s3/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l4-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-rlve-min-chromatic-number-l4-s3/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l4-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-rlve-min-chromatic-number-l4-s4/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l4-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-rlve-min-chromatic-number-l4-s4/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l4-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5852e25c22d42069ece8af44933bc374a27df6c8 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l4-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "k": 7, "edges": [[0, 1], [0, 2], [0, 5], [0, 6], [0, 8], [0, 9], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [1, 2], [1, 3], [1, 4], [1, 6], [1, 8], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [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, 17], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 13], [3, 15], [3, 16], [3, 17], [4, 8], [4, 11], [4, 13], [4, 15], [4, 16], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 16], [5, 17], [6, 9], [6, 11], [6, 13], [6, 16], [6, 17], [7, 8], [7, 10], [7, 11], [7, 12], [7, 16], [8, 9], [8, 13], [8, 14], [8, 17], [9, 10], [9, 12], [9, 15], [9, 17], [10, 11], [10, 13], [10, 15], [10, 16], [10, 17], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [12, 13], [12, 16], [12, 17], [13, 14], [13, 17], [14, 15], [14, 17], [15, 16], [16, 17]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l4-s4/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l4-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7006a0fc9fcf1b4d2569d8f62ef62574fe03444d --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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' +{"colors": [0, 1, 2, 0, 3, 1, 3, 1, 4, 5, 3, 4, 3, 5, 3, 1, 2, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l4-s4/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l4-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l4-s4/tests/check.py @@ -0,0 +1,10 @@ +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") + 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-rlve-min-chromatic-number-l4-s4/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l4-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5852e25c22d42069ece8af44933bc374a27df6c8 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l4-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "k": 7, "edges": [[0, 1], [0, 2], [0, 5], [0, 6], [0, 8], [0, 9], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [1, 2], [1, 3], [1, 4], [1, 6], [1, 8], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [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, 17], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 13], [3, 15], [3, 16], [3, 17], [4, 8], [4, 11], [4, 13], [4, 15], [4, 16], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 16], [5, 17], [6, 9], [6, 11], [6, 13], [6, 16], [6, 17], [7, 8], [7, 10], [7, 11], [7, 12], [7, 16], [8, 9], [8, 13], [8, 14], [8, 17], [9, 10], [9, 12], [9, 15], [9, 17], [10, 11], [10, 13], [10, 15], [10, 16], [10, 17], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [12, 13], [12, 16], [12, 17], [13, 14], [13, 17], [14, 15], [14, 17], [15, 16], [16, 17]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l4-s4/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l4-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-rlve-min-chromatic-number-l4-s4/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l4-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-rlve-min-harmonious-coloring-l4-s9/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l4-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l4-s9/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l4-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..96388d80ebb0144a07c6a5de2dcd70cd40cb9b60 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l4-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 6, "edges": [[1, 4], [1, 7], [1, 10], [2, 4], [2, 8], [3, 4], [3, 6], [3, 7], [5, 8], [6, 7], [6, 9], [6, 10], [9, 11]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l4-s9/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l4-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ac5a2998d97dd536430f40c827041622fdb5a8ed --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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' +{"colors": [0, 0, 1, 2, 3, 0, 4, 5, 2, 3, 1, 5]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l4-s9/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l4-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l4-s9/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-l4-s9/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l4-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..96388d80ebb0144a07c6a5de2dcd70cd40cb9b60 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l4-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 6, "edges": [[1, 4], [1, 7], [1, 10], [2, 4], [2, 8], [3, 4], [3, 6], [3, 7], [5, 8], [6, 7], [6, 9], [6, 10], [9, 11]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l4-s9/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l4-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l4-s9/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l4-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-pairwise-sums-recovery-l2-s6/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-rlve-pairwise-sums-recovery-l2-s6/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b6b8b06124015369cb96545018a62675f2e48c12 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 5, "sums": [7, 12, 11, 13, 8, 17, 9, 14, 13, 12], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l2-s6/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3b9a9b16a9d365bab1f96d596d79c2998c9fa7fd --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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' +{"numbers": [3, 4, 5, 8, 9]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l2-s6/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l2-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-l2-s6/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b6b8b06124015369cb96545018a62675f2e48c12 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 5, "sums": [7, 12, 11, 13, 8, 17, 9, 14, 13, 12], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l2-s6/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-rlve-pairwise-sums-recovery-l2-s6/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-rlve-pairwise-sums-recovery-l2-s8/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-rlve-pairwise-sums-recovery-l2-s8/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e275101183a70c8d300346400bd899a57ae3c919 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 5, "sums": [5, 13, 7, 15, 9, 14, 12, 6, 8, 7], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l2-s8/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c1945db2f904f8d94ea8e297719ae7e812b5da89 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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' +{"numbers": [2, 3, 4, 5, 10]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l2-s8/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l2-s8/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-l2-s8/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e275101183a70c8d300346400bd899a57ae3c919 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 5, "sums": [5, 13, 7, 15, 9, 14, 12, 6, 8, 7], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l2-s8/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-rlve-pairwise-sums-recovery-l2-s8/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-rlve-pairwise-sums-recovery-l6-s7/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l6-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-rlve-pairwise-sums-recovery-l6-s7/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l6-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d2597a1c847536cc61650e79c0649d8f04561b3b --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l6-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 26, "sums": [45, 9, 70, 57, 46, 74, 44, 37, 78, 49, 48, 15, 49, 52, 75, 58, 34, 64, 14, 31, 59, 37, 43, 13, 35, 54, 47, 73, 70, 31, 69, 56, 66, 58, 44, 44, 22, 62, 43, 41, 25, 48, 21, 43, 39, 71, 37, 60, 8, 87, 60, 44, 44, 8, 59, 32, 36, 48, 22, 75, 35, 35, 38, 32, 34, 67, 46, 18, 33, 4, 62, 10, 59, 54, 19, 94, 65, 15, 50, 62, 36, 56, 88, 37, 71, 78, 76, 86, 82, 63, 50, 7, 39, 41, 23, 53, 54, 65, 51, 31, 64, 58, 79, 33, 7, 62, 61, 67, 12, 20, 53, 28, 28, 26, 43, 27, 71, 76, 26, 89, 15, 46, 57, 67, 20, 89, 37, 56, 37, 42, 46, 42, 47, 20, 52, 65, 51, 12, 32, 22, 46, 40, 21, 13, 93, 15, 73, 55, 40, 61, 39, 83, 69, 18, 26, 57, 70, 72, 49, 34, 42, 33, 60, 50, 39, 74, 78, 59, 52, 54, 49, 24, 61, 23, 41, 49, 60, 91, 30, 66, 34, 67, 84, 48, 30, 53, 27, 14, 80, 32, 56, 55, 66, 49, 50, 73, 85, 63, 35, 80, 11, 19, 64, 38, 46, 77, 23, 42, 45, 36, 73, 53, 63, 10, 43, 21, 13, 53, 48, 32, 16, 66, 47, 6, 33, 60, 19, 40, 49, 50, 16, 56, 45, 53, 31, 29, 31, 51, 29, 33, 63, 38, 5, 36, 72, 51, 30, 38, 24, 41, 77, 24, 51, 55, 24, 53, 27, 49, 40, 17, 58, 53, 87, 56, 59, 42, 38, 45, 55, 69, 9, 45, 31, 11, 67, 74, 52, 49, 32, 49, 52, 38, 34, 81, 25, 51, 26, 45, 91, 71, 16, 47, 64, 20, 9, 25, 11, 42, 27, 48, 33, 47, 28, 76, 46, 21, 55, 3, 80, 26, 29, 29, 69, 40, 76, 84, 17, 51, 44, 68, 35, 27, 54, 8, 38], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l6-s7/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l6-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b7863d832a3b67befdb1e9c29328a3f2611ffa02 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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' +{"numbers": [1, 2, 3, 5, 6, 7, 8, 10, 13, 14, 18, 19, 21, 24, 25, 28, 30, 31, 32, 35, 39, 41, 43, 45, 46, 48]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l6-s7/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l6-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l6-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-l6-s7/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l6-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d2597a1c847536cc61650e79c0649d8f04561b3b --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l6-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 26, "sums": [45, 9, 70, 57, 46, 74, 44, 37, 78, 49, 48, 15, 49, 52, 75, 58, 34, 64, 14, 31, 59, 37, 43, 13, 35, 54, 47, 73, 70, 31, 69, 56, 66, 58, 44, 44, 22, 62, 43, 41, 25, 48, 21, 43, 39, 71, 37, 60, 8, 87, 60, 44, 44, 8, 59, 32, 36, 48, 22, 75, 35, 35, 38, 32, 34, 67, 46, 18, 33, 4, 62, 10, 59, 54, 19, 94, 65, 15, 50, 62, 36, 56, 88, 37, 71, 78, 76, 86, 82, 63, 50, 7, 39, 41, 23, 53, 54, 65, 51, 31, 64, 58, 79, 33, 7, 62, 61, 67, 12, 20, 53, 28, 28, 26, 43, 27, 71, 76, 26, 89, 15, 46, 57, 67, 20, 89, 37, 56, 37, 42, 46, 42, 47, 20, 52, 65, 51, 12, 32, 22, 46, 40, 21, 13, 93, 15, 73, 55, 40, 61, 39, 83, 69, 18, 26, 57, 70, 72, 49, 34, 42, 33, 60, 50, 39, 74, 78, 59, 52, 54, 49, 24, 61, 23, 41, 49, 60, 91, 30, 66, 34, 67, 84, 48, 30, 53, 27, 14, 80, 32, 56, 55, 66, 49, 50, 73, 85, 63, 35, 80, 11, 19, 64, 38, 46, 77, 23, 42, 45, 36, 73, 53, 63, 10, 43, 21, 13, 53, 48, 32, 16, 66, 47, 6, 33, 60, 19, 40, 49, 50, 16, 56, 45, 53, 31, 29, 31, 51, 29, 33, 63, 38, 5, 36, 72, 51, 30, 38, 24, 41, 77, 24, 51, 55, 24, 53, 27, 49, 40, 17, 58, 53, 87, 56, 59, 42, 38, 45, 55, 69, 9, 45, 31, 11, 67, 74, 52, 49, 32, 49, 52, 38, 34, 81, 25, 51, 26, 45, 91, 71, 16, 47, 64, 20, 9, 25, 11, 42, 27, 48, 33, 47, 28, 76, 46, 21, 55, 3, 80, 26, 29, 29, 69, 40, 76, 84, 17, 51, 44, 68, 35, 27, 54, 8, 38], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l6-s7/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l6-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-rlve-pairwise-sums-recovery-l6-s7/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l6-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-rlve-pairwise-sums-recovery-l6-s9/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-rlve-pairwise-sums-recovery-l6-s9/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d1b37d6452fd85b947f176d50f1d0267657fabe9 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 26, "sums": [47, 46, 34, 60, 78, 51, 19, 50, 58, 27, 48, 28, 18, 42, 19, 27, 16, 9, 54, 10, 66, 35, 50, 64, 15, 41, 19, 18, 57, 62, 54, 65, 18, 37, 54, 39, 29, 32, 13, 29, 33, 25, 17, 43, 76, 21, 76, 47, 61, 26, 56, 81, 24, 39, 20, 47, 57, 45, 63, 24, 61, 49, 15, 24, 58, 36, 49, 31, 45, 37, 63, 16, 63, 21, 40, 34, 59, 13, 53, 31, 43, 19, 38, 13, 34, 41, 59, 21, 65, 27, 58, 77, 52, 63, 61, 84, 72, 22, 52, 59, 88, 45, 63, 66, 53, 20, 29, 26, 66, 22, 45, 28, 55, 12, 55, 32, 22, 34, 92, 52, 72, 74, 59, 40, 46, 17, 35, 65, 23, 29, 62, 10, 94, 41, 20, 46, 58, 68, 43, 36, 61, 69, 41, 54, 35, 44, 38, 42, 43, 42, 62, 21, 26, 38, 33, 39, 101, 75, 38, 70, 31, 23, 24, 50, 79, 58, 33, 78, 31, 25, 34, 21, 8, 62, 55, 82, 68, 33, 44, 32, 36, 30, 39, 56, 79, 17, 38, 75, 40, 49, 23, 14, 18, 60, 11, 23, 32, 91, 5, 33, 28, 60, 32, 26, 53, 7, 55, 40, 39, 36, 69, 63, 22, 48, 58, 49, 44, 31, 61, 75, 47, 24, 31, 15, 46, 29, 53, 44, 17, 37, 56, 81, 19, 50, 52, 38, 25, 53, 27, 60, 46, 65, 22, 28, 12, 30, 98, 47, 74, 27, 26, 24, 48, 51, 15, 23, 36, 72, 67, 31, 37, 52, 69, 42, 25, 89, 64, 66, 21, 45, 57, 73, 37, 29, 16, 49, 29, 95, 57, 20, 51, 37, 20, 30, 71, 75, 55, 26, 64, 25, 68, 50, 48, 62, 30, 40, 41, 44, 61, 57, 43, 60, 97, 14, 24, 50, 77, 53, 70, 67, 82, 35, 78, 33, 41, 34, 56, 59, 56, 27, 36, 47, 30, 85, 95], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l6-s9/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0f364a61910604d8d3c70237071d3baf9eb8f1b --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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' +{"numbers": [1, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 23, 25, 29, 30, 32, 33, 43, 45, 46, 49, 52]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l6-s9/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l6-s9/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-l6-s9/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d1b37d6452fd85b947f176d50f1d0267657fabe9 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 26, "sums": [47, 46, 34, 60, 78, 51, 19, 50, 58, 27, 48, 28, 18, 42, 19, 27, 16, 9, 54, 10, 66, 35, 50, 64, 15, 41, 19, 18, 57, 62, 54, 65, 18, 37, 54, 39, 29, 32, 13, 29, 33, 25, 17, 43, 76, 21, 76, 47, 61, 26, 56, 81, 24, 39, 20, 47, 57, 45, 63, 24, 61, 49, 15, 24, 58, 36, 49, 31, 45, 37, 63, 16, 63, 21, 40, 34, 59, 13, 53, 31, 43, 19, 38, 13, 34, 41, 59, 21, 65, 27, 58, 77, 52, 63, 61, 84, 72, 22, 52, 59, 88, 45, 63, 66, 53, 20, 29, 26, 66, 22, 45, 28, 55, 12, 55, 32, 22, 34, 92, 52, 72, 74, 59, 40, 46, 17, 35, 65, 23, 29, 62, 10, 94, 41, 20, 46, 58, 68, 43, 36, 61, 69, 41, 54, 35, 44, 38, 42, 43, 42, 62, 21, 26, 38, 33, 39, 101, 75, 38, 70, 31, 23, 24, 50, 79, 58, 33, 78, 31, 25, 34, 21, 8, 62, 55, 82, 68, 33, 44, 32, 36, 30, 39, 56, 79, 17, 38, 75, 40, 49, 23, 14, 18, 60, 11, 23, 32, 91, 5, 33, 28, 60, 32, 26, 53, 7, 55, 40, 39, 36, 69, 63, 22, 48, 58, 49, 44, 31, 61, 75, 47, 24, 31, 15, 46, 29, 53, 44, 17, 37, 56, 81, 19, 50, 52, 38, 25, 53, 27, 60, 46, 65, 22, 28, 12, 30, 98, 47, 74, 27, 26, 24, 48, 51, 15, 23, 36, 72, 67, 31, 37, 52, 69, 42, 25, 89, 64, 66, 21, 45, 57, 73, 37, 29, 16, 49, 29, 95, 57, 20, 51, 37, 20, 30, 71, 75, 55, 26, 64, 25, 68, 50, 48, 62, 30, 40, 41, 44, 61, 57, 43, 60, 97, 14, 24, 50, 77, 53, 70, 67, 82, 35, 78, 33, 41, 34, 56, 59, 56, 27, 36, 47, 30, 85, 95], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l6-s9/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-rlve-pairwise-sums-recovery-l6-s9/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-rlve-pan-solar-panels-l3-s3/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l3-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-pan-solar-panels-l3-s3/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8df1f6fe29139db303b28fe25df80cab5d3f0efb --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"A": 61659, "B": 83716, "C": 39815, "D": 51897, "target": 41858, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l3-s3/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8d94e5604870a048289ec3accc818dbfd10f492c --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l3-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' +{"X": 83716, "Y": 41858} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l3-s3/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l3-s3/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-l3-s3/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8df1f6fe29139db303b28fe25df80cab5d3f0efb --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"A": 61659, "B": 83716, "C": 39815, "D": 51897, "target": 41858, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l3-s3/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l3-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-pan-solar-panels-l3-s3/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l3-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-pan-solar-panels-l3-s4/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l3-s4/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cca1fc49c7aec132555bafebb47cf890218ef3eb --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"A": 3768, "B": 35631, "C": 47859, "D": 72030, "target": 35631, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l3-s4/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..93a6852f4c45c8e116d9a74be0aea67a0890ed41 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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": 35631, "Y": 71262} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l3-s4/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l3-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-l3-s4/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cca1fc49c7aec132555bafebb47cf890218ef3eb --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"A": 3768, "B": 35631, "C": 47859, "D": 72030, "target": 35631, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l3-s4/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l3-s4/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-global-minimum-l2-s9/environment/Dockerfile b/tasks/construct-rlve-polynomial-global-minimum-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-global-minimum-l2-s9/environment/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bced3a97b978494d094d3cc8b89fb57053c12ab1 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [18, 28, 26, 8, 1], "fmin": "8.55166289846733219174765454317744194832562008", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l2-s9/solution/solve.sh b/tasks/construct-rlve-polynomial-global-minimum-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4b35666c54e52d0fdfdd2961c8b59f4c2e180939 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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' +{"x0": -0.7865883372377703} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-global-minimum-l2-s9/tests/check.py b/tasks/construct-rlve-polynomial-global-minimum-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3be068f4391ad0838c29a4f7d521b8072cf39991 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l2-s9/tests/check.py @@ -0,0 +1,19 @@ +from fractions import Fraction + +from run import Invalid, num + + +def check(inst, ans): + x0 = Fraction(num(ans.get("x0"), "x0")) + if abs(x0) > 10 ** 6: + raise Invalid("x0 out of range") + v = Fraction(0) + for a in reversed(inst["coeffs"]): + v = v * x0 + a + fmin = Fraction(inst["fmin"]) + tol = Fraction(1, 10 ** 9) * max(Fraction(1), abs(fmin)) + if v > fmin + tol: + raise Invalid(f"f(x0) = {float(v)} is above the global minimum {float(fmin)}") + if v < fmin - tol: # cannot happen for a correct f_min; guards against a bad instance + raise Invalid("internal: f(x0) below recorded minimum") + return None, {"f_x0": float(v)} diff --git a/tasks/construct-rlve-polynomial-global-minimum-l2-s9/tests/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bced3a97b978494d094d3cc8b89fb57053c12ab1 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [18, 28, 26, 8, 1], "fmin": "8.55166289846733219174765454317744194832562008", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l2-s9/tests/run.py b/tasks/construct-rlve-polynomial-global-minimum-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-global-minimum-l2-s9/tests/test.sh b/tasks/construct-rlve-polynomial-global-minimum-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-global-minimum-l6-s1/environment/Dockerfile b/tasks/construct-rlve-polynomial-global-minimum-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-global-minimum-l6-s1/environment/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f0cdcc11bddba8d27f5b152f536db18487093e87 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [4101, -24576, 67698, -112980, 127737, -103372, 62140, -28776, 10925, -3762, 1266, -388, 92, -14, 1], "fmin": "59.0039109627281987932410883940007931597765564", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l6-s1/solution/solve.sh b/tasks/construct-rlve-polynomial-global-minimum-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c7e7006193ed2ea534342a82c1696023286064c9 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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' +{"x0": 0.756373857798139} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-global-minimum-l6-s1/tests/check.py b/tasks/construct-rlve-polynomial-global-minimum-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3be068f4391ad0838c29a4f7d521b8072cf39991 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l6-s1/tests/check.py @@ -0,0 +1,19 @@ +from fractions import Fraction + +from run import Invalid, num + + +def check(inst, ans): + x0 = Fraction(num(ans.get("x0"), "x0")) + if abs(x0) > 10 ** 6: + raise Invalid("x0 out of range") + v = Fraction(0) + for a in reversed(inst["coeffs"]): + v = v * x0 + a + fmin = Fraction(inst["fmin"]) + tol = Fraction(1, 10 ** 9) * max(Fraction(1), abs(fmin)) + if v > fmin + tol: + raise Invalid(f"f(x0) = {float(v)} is above the global minimum {float(fmin)}") + if v < fmin - tol: # cannot happen for a correct f_min; guards against a bad instance + raise Invalid("internal: f(x0) below recorded minimum") + return None, {"f_x0": float(v)} diff --git a/tasks/construct-rlve-polynomial-global-minimum-l6-s1/tests/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f0cdcc11bddba8d27f5b152f536db18487093e87 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [4101, -24576, 67698, -112980, 127737, -103372, 62140, -28776, 10925, -3762, 1266, -388, 92, -14, 1], "fmin": "59.0039109627281987932410883940007931597765564", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l6-s1/tests/run.py b/tasks/construct-rlve-polynomial-global-minimum-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-global-minimum-l6-s1/tests/test.sh b/tasks/construct-rlve-polynomial-global-minimum-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-global-minimum-l6-s6/environment/Dockerfile b/tasks/construct-rlve-polynomial-global-minimum-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-global-minimum-l6-s6/environment/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e02ea8c718f68bbe6858e64d685c1a8edf4ca133 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [9, 4, 400, -344, 3274, -2616, 8093, -5392, 7042, -3574, 2135, -704, 184, -28, 2], "fmin": "8.99004459031947540668898065482177119741379617", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l6-s6/solution/solve.sh b/tasks/construct-rlve-polynomial-global-minimum-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..37e6235244440d47aca260bdf8d45044f165fba3 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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' +{"x0": -0.004966169808665889} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-global-minimum-l6-s6/tests/check.py b/tasks/construct-rlve-polynomial-global-minimum-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3be068f4391ad0838c29a4f7d521b8072cf39991 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l6-s6/tests/check.py @@ -0,0 +1,19 @@ +from fractions import Fraction + +from run import Invalid, num + + +def check(inst, ans): + x0 = Fraction(num(ans.get("x0"), "x0")) + if abs(x0) > 10 ** 6: + raise Invalid("x0 out of range") + v = Fraction(0) + for a in reversed(inst["coeffs"]): + v = v * x0 + a + fmin = Fraction(inst["fmin"]) + tol = Fraction(1, 10 ** 9) * max(Fraction(1), abs(fmin)) + if v > fmin + tol: + raise Invalid(f"f(x0) = {float(v)} is above the global minimum {float(fmin)}") + if v < fmin - tol: # cannot happen for a correct f_min; guards against a bad instance + raise Invalid("internal: f(x0) below recorded minimum") + return None, {"f_x0": float(v)} diff --git a/tasks/construct-rlve-polynomial-global-minimum-l6-s6/tests/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e02ea8c718f68bbe6858e64d685c1a8edf4ca133 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [9, 4, 400, -344, 3274, -2616, 8093, -5392, 7042, -3574, 2135, -704, 184, -28, 2], "fmin": "8.99004459031947540668898065482177119741379617", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l6-s6/tests/run.py b/tasks/construct-rlve-polynomial-global-minimum-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-global-minimum-l6-s6/tests/test.sh b/tasks/construct-rlve-polynomial-global-minimum-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-integer-roots-l1-s3/environment/Dockerfile b/tasks/construct-rlve-polynomial-integer-roots-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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-rlve-polynomial-integer-roots-l1-s3/environment/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..42e8e8809e1779145145281686524c8706364397 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [2, -1, -2, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l1-s3/solution/solve.sh b/tasks/construct-rlve-polynomial-integer-roots-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..70ef4ab6e40d5fc34392d47d4cc4651d0162c419 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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' +{"roots": [-1, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-integer-roots-l1-s3/tests/check.py b/tasks/construct-rlve-polynomial-integer-roots-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2d30553cb884c5e03c8afe73ef652efc483ab791 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l1-s3/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + c = inst["coeffs"] # c[i] = coefficient of x^i, monic of degree len(c) - 1 + n = len(c) - 1 + r = int_list(ans.get("roots"), n, name="roots") + bound = 1 + max(abs(v) for v in c) # Cauchy bound on roots + if any(abs(a) > bound for a in r): # any integer root divides the constant term / is bounded by max|c_i| + raise Invalid("root out of range") + prod = [1] + for a in r: # multiply by (x - a) + nxt = [0] * (len(prod) + 1) + for i, v in enumerate(prod): + nxt[i + 1] += v + nxt[i] -= a * v + prod = nxt + if prod != c: + raise Invalid("the product does not expand to P(x)") + return None, {} diff --git a/tasks/construct-rlve-polynomial-integer-roots-l1-s3/tests/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..42e8e8809e1779145145281686524c8706364397 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [2, -1, -2, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l1-s3/tests/run.py b/tasks/construct-rlve-polynomial-integer-roots-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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-rlve-polynomial-integer-roots-l1-s3/tests/test.sh b/tasks/construct-rlve-polynomial-integer-roots-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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-rlve-polynomial-integer-roots-l1-s4/environment/Dockerfile b/tasks/construct-rlve-polynomial-integer-roots-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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-rlve-polynomial-integer-roots-l1-s4/environment/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..848f97853ce14b3cf7b0d21cb0259f0822a87cc5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [-18, -3, 4, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l1-s4/solution/solve.sh b/tasks/construct-rlve-polynomial-integer-roots-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ee2d9d17ee8696d32d91594a8ce6b084a7dcc99a --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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' +{"roots": [-3, -3, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-integer-roots-l1-s4/tests/check.py b/tasks/construct-rlve-polynomial-integer-roots-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2d30553cb884c5e03c8afe73ef652efc483ab791 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l1-s4/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + c = inst["coeffs"] # c[i] = coefficient of x^i, monic of degree len(c) - 1 + n = len(c) - 1 + r = int_list(ans.get("roots"), n, name="roots") + bound = 1 + max(abs(v) for v in c) # Cauchy bound on roots + if any(abs(a) > bound for a in r): # any integer root divides the constant term / is bounded by max|c_i| + raise Invalid("root out of range") + prod = [1] + for a in r: # multiply by (x - a) + nxt = [0] * (len(prod) + 1) + for i, v in enumerate(prod): + nxt[i + 1] += v + nxt[i] -= a * v + prod = nxt + if prod != c: + raise Invalid("the product does not expand to P(x)") + return None, {} diff --git a/tasks/construct-rlve-polynomial-integer-roots-l1-s4/tests/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..848f97853ce14b3cf7b0d21cb0259f0822a87cc5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [-18, -3, 4, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l1-s4/tests/run.py b/tasks/construct-rlve-polynomial-integer-roots-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l1-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-integer-roots-l1-s4/tests/test.sh b/tasks/construct-rlve-polynomial-integer-roots-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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-rlve-polynomial-integer-roots-l5-s5/environment/Dockerfile b/tasks/construct-rlve-polynomial-integer-roots-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l5-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-integer-roots-l5-s5/environment/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ee3a33b0f8db2c95329a7a173e9901413050b91e --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [-63685440000000, 99845784000000, -30833805600000, -9324970740000, 3798035394000, 367781615600, -162116078040, -8700978866, 3348027901, 122630940, -37541800, -966728, 233898, 3860, -760, -6, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l5-s5/solution/solve.sh b/tasks/construct-rlve-polynomial-integer-roots-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a0afdda4d3d85a606fdc742327a0f6849dec96cd --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l5-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' +{"roots": [-15, -12, -10, -9, -9, -8, -5, 1, 2, 4, 5, 10, 10, 13, 14, 15]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-integer-roots-l5-s5/tests/check.py b/tasks/construct-rlve-polynomial-integer-roots-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2d30553cb884c5e03c8afe73ef652efc483ab791 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l5-s5/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + c = inst["coeffs"] # c[i] = coefficient of x^i, monic of degree len(c) - 1 + n = len(c) - 1 + r = int_list(ans.get("roots"), n, name="roots") + bound = 1 + max(abs(v) for v in c) # Cauchy bound on roots + if any(abs(a) > bound for a in r): # any integer root divides the constant term / is bounded by max|c_i| + raise Invalid("root out of range") + prod = [1] + for a in r: # multiply by (x - a) + nxt = [0] * (len(prod) + 1) + for i, v in enumerate(prod): + nxt[i + 1] += v + nxt[i] -= a * v + prod = nxt + if prod != c: + raise Invalid("the product does not expand to P(x)") + return None, {} diff --git a/tasks/construct-rlve-polynomial-integer-roots-l5-s5/tests/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ee3a33b0f8db2c95329a7a173e9901413050b91e --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [-63685440000000, 99845784000000, -30833805600000, -9324970740000, 3798035394000, 367781615600, -162116078040, -8700978866, 3348027901, 122630940, -37541800, -966728, 233898, 3860, -760, -6, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l5-s5/tests/run.py b/tasks/construct-rlve-polynomial-integer-roots-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l5-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-integer-roots-l5-s5/tests/test.sh b/tasks/construct-rlve-polynomial-integer-roots-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l5-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-polynomial-interpolation-l2-s2/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-polynomial-interpolation-l2-s2/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..32e104e9227336387c4cf83844e930752e492e45 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"X": [-1, 0, -3, -2, 1], "Y": [5, -4, 407, 88, -5], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l2-s2/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6f9baf3bb6c9e69cbd2abb8e7170515fc3001a12 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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' +{"coeffs": [-4, -2, 0, -3, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l2-s2/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l2-s2/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-l2-s2/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..32e104e9227336387c4cf83844e930752e492e45 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"X": [-1, 0, -3, -2, 1], "Y": [5, -4, 407, 88, -5], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l2-s2/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-polynomial-interpolation-l2-s2/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-polynomial-interpolation-l2-s5/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-polynomial-interpolation-l2-s5/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7a4c577a280e367877f1da42f75dd4545fd312b2 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"X": [4, 3, 1, -3, 2], "Y": [1012, 344, 4, 116, 76], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l2-s5/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3d9ed5b7ae0a0db492120c269fa6a266e5908659 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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' +{"coeffs": [-4, 2, -1, 4, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l2-s5/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l2-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-l2-s5/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7a4c577a280e367877f1da42f75dd4545fd312b2 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"X": [4, 3, 1, -3, 2], "Y": [1012, 344, 4, 116, 76], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l2-s5/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-polynomial-interpolation-l2-s5/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-prefix-product-permutation-l2-s0/environment/Dockerfile b/tasks/construct-rlve-prefix-product-permutation-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-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-product-permutation-l2-s0/environment/instance.json b/tasks/construct-rlve-prefix-product-permutation-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..67af7071d921c8ba862989f6b2f2b5c545e156a5 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 83, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l2-s0/solution/solve.sh b/tasks/construct-rlve-prefix-product-permutation-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f09b3535e4b1e563d01c17da98c2c2da3dd38ee7 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-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": [1, 2, 43, 29, 22, 51, 15, 13, 53, 38, 26, 69, 8, 33, 7, 73, 27, 45, 61, 36, 55, 5, 35, 66, 46, 11, 17, 41, 4, 64, 37, 76, 14, 79, 23, 20, 31, 10, 60, 67, 28, 82, 3, 57, 18, 25, 75, 54, 65, 62, 6, 71, 9, 48, 21, 81, 44, 68, 74, 39, 19, 50, 80, 30, 49, 24, 40, 58, 12, 78, 52, 77, 16, 59, 47, 32, 72, 70, 34, 63, 56, 42, 83]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-product-permutation-l2-s0/tests/check.py b/tasks/construct-rlve-prefix-product-permutation-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3d93850acd79cc0f8fff05cdbb0c63aabc484815 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-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(), 1 + for v in p: + acc = acc * v % n + if acc in seen: + raise Invalid(f"prefix product residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-product-permutation-l2-s0/tests/instance.json b/tasks/construct-rlve-prefix-product-permutation-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..67af7071d921c8ba862989f6b2f2b5c545e156a5 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 83, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l2-s0/tests/run.py b/tasks/construct-rlve-prefix-product-permutation-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-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-product-permutation-l2-s0/tests/test.sh b/tasks/construct-rlve-prefix-product-permutation-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-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-product-permutation-l2-s7/environment/Dockerfile b/tasks/construct-rlve-prefix-product-permutation-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-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-product-permutation-l2-s7/environment/instance.json b/tasks/construct-rlve-prefix-product-permutation-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ca2ac9852accf3fd8c35a2d8b423b253d68e4257 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 71, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l2-s7/solution/solve.sh b/tasks/construct-rlve-prefix-product-permutation-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..151a5dda5ea071ad25f240b360ff3a005a282543 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-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": [1, 2, 37, 25, 19, 58, 13, 62, 10, 9, 65, 14, 7, 12, 67, 20, 41, 47, 5, 16, 33, 45, 43, 35, 4, 55, 42, 51, 34, 50, 46, 56, 21, 29, 24, 70, 3, 49, 44, 52, 17, 27, 23, 39, 22, 31, 18, 69, 38, 30, 28, 40, 57, 68, 26, 32, 53, 6, 61, 66, 59, 8, 64, 63, 11, 60, 15, 54, 48, 36, 71]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-product-permutation-l2-s7/tests/check.py b/tasks/construct-rlve-prefix-product-permutation-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3d93850acd79cc0f8fff05cdbb0c63aabc484815 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-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(), 1 + for v in p: + acc = acc * v % n + if acc in seen: + raise Invalid(f"prefix product residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-product-permutation-l2-s7/tests/instance.json b/tasks/construct-rlve-prefix-product-permutation-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ca2ac9852accf3fd8c35a2d8b423b253d68e4257 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 71, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l2-s7/tests/run.py b/tasks/construct-rlve-prefix-product-permutation-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-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-product-permutation-l2-s7/tests/test.sh b/tasks/construct-rlve-prefix-product-permutation-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-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-product-permutation-l6-s8/environment/Dockerfile b/tasks/construct-rlve-prefix-product-permutation-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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-prefix-product-permutation-l6-s8/environment/instance.json b/tasks/construct-rlve-prefix-product-permutation-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d9352455711232780c22267dbeeba4dbcee94118 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 12713, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l6-s8/solution/solve.sh b/tasks/construct-rlve-prefix-product-permutation-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5d6a931199545e384362013ad141314719fe6ace --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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' +{"perm": [1, 2, 6358, 4239, 9536, 7629, 2120, 10898, 11125, 9889, 3815, 4624, 7417, 979, 11806, 11019, 5563, 4488, 4945, 6023, 1908, 7871, 8669, 2212, 3709, 11697, 490, 3297, 12260, 9207, 5510, 4102, 2782, 1542, 8601, 4723, 2473, 1719, 3012, 327, 7311, 8373, 3936, 6801, 4335, 12149, 7463, 542, 1855, 5190, 5849, 9972, 6602, 9116, 1649, 11096, 12487, 6246, 4604, 8620, 9112, 8129, 8408, 6862, 7748, 10367, 7128, 760, 4301, 738, 2362, 9491, 1237, 9231, 860, 12375, 7863, 7926, 164, 10622, 3656, 9575, 4187, 11795, 8325, 3441, 3401, 11545, 2168, 10000, 6075, 3773, 3732, 1368, 6628, 3748, 928, 2098, 8952, 8990, 2925, 8812, 11343, 865, 9658, 1575, 10915, 10813, 825, 3500, 11905, 9049, 6244, 12489, 9480, 8071, 8659, 8585, 10667, 642, 10913, 1577, 4065, 11267, 10561, 9968, 9788, 3905, 10231, 10743, 5184, 10579, 9921, 9942, 6737, 8288, 2151, 8631, 6726, 6952, 7538, 4419, 4746, 8180, 619, 9470, 4616, 10206, 6787, 7680, 6188, 2190, 3932, 11800, 10320, 8449, 6439, 9556, 11668, 7277, 8185, 2133, 4788, 79, 2094, 7937, 5898, 12105, 4163, 3010, 1721, 10558, 1701, 2573, 5773, 3488, 7441, 2874, 11357, 9518, 3038, 7095, 1887, 6948, 8223, 10515, 7041, 8499, 9671, 2288, 8231, 11050, 6821, 9157, 7406, 7694, 10833, 969, 10852, 1662, 1463, 254, 10763, 12213, 5672, 4218, 433, 8722, 11186, 10950, 788, 12473, 5458, 7402, 5407, 1361, 413, 2403, 8107, 11553, 5953, 2302, 4525, 6329, 9479, 12601, 6245, 12658, 11097, 10882, 4036, 11118, 4330, 874, 4293, 7737, 5334, 7779, 6678, 11331, 5457, 12503, 789, 7430, 2033, 6124, 5634, 3398, 5281, 8170, 11341, 8814, 11251, 202, 1953, 9623, 5116, 11972, 5372, 7511, 8949, 3849, 5290, 3143, 4961, 1824, 11328, 3334, 3369, 3451, 10501, 9008, 1076, 5496, 4316, 2220, 9720, 3948, 9833, 8932, 10126, 9909, 2210, 8671, 8730, 1250, 10447, 1197, 310, 8491, 11092, 700, 8665, 11933, 11460, 6810, 3394, 7235, 10197, 1149, 9451, 8237, 7452, 2938, 8323, 11797, 12257, 5550, 11517, 289, 4225, 9035, 3220, 2438, 11135, 9001, 12191, 1926, 3639, 8928, 4093, 3605, 1067, 5590, 8751, 9702, 40, 5405, 7404, 9159, 3969, 2920, 9306, 3017, 6053, 5238, 2082, 1095, 7862, 12639, 861, 3841, 11636, 9823, 851, 2691, 1287, 6156, 2887, 3243, 8101, 7100, 3721, 5079, 7794, 1899, 5679, 8690, 11116, 4038, 7876, 7009, 3548, 4764, 944, 1847, 9831, 3950, 4112, 7994, 5258, 12200, 3521, 410, 4250, 7561, 4836, 2665, 7501, 11171, 4116, 5540, 11882, 9793, 3411, 1586, 4579, 12057, 10060, 5230, 10204, 4618, 5417, 3527, 485, 9753, 11783, 1410, 7188, 11790, 732, 7800, 6484, 6184, 5382, 7001, 6107, 9403, 9193, 374, 8466, 11353, 217, 10313, 10718, 7445, 11950, 2318, 11832, 8891, 6751, 2145, 6237, 9949, 9086, 689, 10058, 12059, 2704, 6965, 681, 8496, 207, 3994, 1202, 7395, 4054, 4132, 5777, 3534, 2977, 11878, 7508, 4650, 2263, 7086, 3165, 11036, 4740, 3427, 6301, 5385, 3123, 9206, 12686, 3298, 5549, 12408, 11798, 3934, 8375, 11997, 11916, 5218, 8522, 2817, 6794, 6235, 2147, 7374, 3869, 3186, 9024, 9865, 3890, 3293, 9696, 6664, 5666, 8149, 2729, 2089, 6252, 9187, 395, 2963, 10072, 7728, 1017, 27, 9419, 8157, 9174, 2786, 8056, 6884, 2641, 4989, 10442, 11058, 5671, 12511, 10764, 9858, 5626, 9391, 6458, 1004, 977, 7419, 4812, 6768, 8915, 3520, 12343, 5259, 9043, 9296, 3756, 5096, 4475, 4198, 1925, 12398, 9002, 5401, 1572, 5477, 2481, 6730, 7269, 9434, 12021, 645, 8024, 4706, 1685, 7411, 1726, 12030, 5251, 48, 10861, 10841, 6895, 5786, 9105, 675, 8515, 10792, 7467, 9853, 11217, 10599, 8331, 11981, 4917, 2466, 10823, 1502, 11420, 11309, 4955, 8243, 7462, 12669, 4336, 5001, 10722, 8737, 6982, 2695, 5224, 3684, 599, 1615, 6512, 7360, 4246, 3053, 11903, 3502, 6707, 7764, 4333, 6803, 5967, 5567, 12087, 7577, 9762, 8799, 8054, 2788, 3618, 7757, 5099, 9030, 575, 11101, 4726, 10641, 4119, 4323, 10083, 7944, 7826, 2619, 4162, 12547, 5899, 7866, 6129, 6596, 9132, 9882, 5759, 4534, 145, 3246, 2113, 2908, 4518, 8694, 7967, 4537, 7576, 12126, 5568, 4589, 4501, 10800, 6096, 8396, 7320, 5867, 1820, 2356, 10821, 2468, 2047, 120, 1803, 693, 534, 4692, 9152, 11594, 4376, 3096, 11208, 9277, 6377, 8684, 2703, 12287, 10059, 12327, 4580, 10264, 1985, 7348, 7817, 768, 11010, 9617, 1509, 954, 3027, 6348, 8976, 8830, 7398, 3609, 548, 4201, 10288, 3137, 6320, 5749, 431, 4220, 1921, 5250, 12175, 1727, 4912, 3628, 426, 2658, 1346, 10911, 644, 12182, 9435, 9019, 1444, 10963, 1622, 292, 4051, 8833, 9907, 10128, 1861, 11055, 2540, 4892, 10254, 4412, 950, 11069, 2840, 2943, 10702, 6722, 11915, 12253, 8376, 5164, 10295, 7389, 3505, 8406, 8131, 6980, 8739, 7363, 6829, 6715, 924, 401, 4916, 12159, 8332, 2042, 8413, 70, 10354, 9239, 8986, 5371, 12457, 5117, 1761, 6622, 6562, 2724, 8482, 6994, 3781, 2591, 8775, 11414, 1333, 5524, 3751, 7743, 5586, 68, 8415, 8571, 9127, 2317, 12298, 7446, 4897, 664, 1706, 6746, 7150, 8229, 2290, 7813, 6029, 11861, 11387, 6742, 8972, 9140, 11459, 12421, 8666, 9759, 2709, 1912, 1764, 211, 243, 5286, 4877, 1785, 5892, 3560, 7062, 9084, 9951, 5217, 12252, 11998, 6723, 1112, 10257, 5463, 9599, 2970, 9449, 1151, 9048, 12604, 3501, 12134, 3054, 7241, 4702, 10187, 4597, 1028, 6544, 10308, 10590, 6613, 5677, 1901, 109, 9216, 5157, 5243, 11716, 5077, 3723, 9792, 12332, 5541, 7516, 7507, 12273, 2978, 4446, 11820, 3376, 5579, 1073, 11779, 3119, 5688, 4975, 11123, 10900, 2891, 345, 10025, 11386, 11939, 6030, 4655, 7709, 7611, 3483, 75, 341, 8875, 10605, 1371, 104, 3058, 8354, 2831, 6958, 3278, 3698, 4949, 8384, 234, 8423, 3241, 2889, 10902, 8124, 8216, 1489, 8890, 12296, 2319, 10111, 10746, 8682, 6379, 1132, 4191, 9900, 6650, 1583, 3375, 11875, 4447, 8727, 8859, 1714, 8910, 3151, 1285, 2693, 6984, 1562, 6505, 10960, 11018, 12700, 980, 8006, 2792, 2775, 10319, 12561, 3933, 12256, 12409, 8324, 12631, 4188, 10326, 5999, 731, 12315, 7189, 8966, 97, 10618, 1780, 1409, 12318, 9754, 7250, 3118, 11871, 1074, 9010, 10044, 5051, 1935, 2676, 7950, 365, 10869, 3001, 4933, 4713, 8302, 711, 1647, 9118, 11205, 668, 9689, 7296, 9190, 11452, 4075, 3050, 1365, 11616, 1045, 5440, 9483, 9460, 4594, 1881, 198, 1864, 1482, 10030, 11393, 994, 10221, 11710, 509, 5297, 14, 910, 4710, 6040, 4079, 3661, 10944, 10365, 7750, 11529, 10385, 8035, 9799, 9648, 1321, 974, 2495, 7961, 11578, 5076, 11886, 5244, 2836, 8434, 6256, 508, 11739, 10222, 11286, 8510, 9170, 6389, 4696, 8841, 9586, 8560, 6859, 4986, 489, 12689, 3710, 2596, 8763, 8605, 9741, 1281, 4458, 3387, 8117, 818, 6172, 3275, 2630, 4773, 4522, 2327, 11005, 9373, 8235, 9453, 8905, 2803, 2238, 10528, 8456, 1098, 963, 7276, 12556, 9557, 10858, 7527, 2701, 8686, 7143, 6605, 2739, 5038, 1241, 3946, 9722, 10169, 3635, 8700, 11074, 5323, 6011, 9109, 323, 7126, 10369, 7850, 8710, 7135, 843, 937, 3706, 273, 7220, 9822, 12372, 3842, 2626, 1130, 6381, 2337, 5431, 3024, 5421, 9603, 3448, 10064, 9250, 6911, 4553, 10632, 338, 4854, 4258, 1044, 11753, 1366, 3734, 5555, 4927, 8922, 5609, 8089, 5300, 6903, 4166, 4082, 5991, 802, 2459, 8305, 7590, 11437, 5412, 3791, 7108, 4375, 12067, 9153, 5655, 2367, 2478, 2521, 4122, 5754, 10088, 1082, 6335, 889, 8525, 2391, 2501, 5075, 11718, 7962, 4369, 11263, 9848, 10909, 1348, 6085, 8969, 9805, 8199, 2517, 300, 3265, 808, 3668, 9613, 2967, 10037, 4767, 8480, 2726, 1527, 1767, 5952, 12495, 8108, 2067, 3354, 10346, 10239, 1744, 2167, 12627, 3402, 7644, 2984, 1540, 2784, 9176, 6044, 9074, 3789, 5414, 11238, 6449, 4400, 2247, 10384, 11727, 7751, 9351, 8166, 6427, 3879, 8946, 2550, 4125, 10872, 2267, 288, 12406, 5551, 4942, 8720, 435, 5321, 11076, 2060, 5044, 2162, 5794, 5042, 2062, 10329, 7633, 10270, 11362, 1310, 6572, 8438, 6018, 6274, 3161, 2950, 3135, 10290, 9845, 3065, 11396, 9655, 4363, 10923, 2225, 11298, 1736, 2880, 3785, 8624, 3223, 73, 3485, 7980, 7676, 1057, 8770, 7811, 2292, 8616, 6720, 10704, 1989, 3984, 286, 2269, 5011, 10145, 6809, 12420, 11934, 9141, 7202, 2295, 1758, 2251, 4074, 11757, 9191, 9405, 7669, 10555, 8279, 10017, 3317, 2934, 8473, 7267, 6732, 7535, 4468, 5411, 11599, 7591, 2973, 1024, 8258, 6417, 9563, 902, 10023, 347, 6560, 6624, 3305, 8703, 9681, 10933, 11308, 12154, 1503, 8545, 5294, 7905, 1332, 11961, 8776, 4639, 6538, 3189, 10941, 10699, 10613, 1352, 1215, 6144, 1378, 5030, 10458, 6164, 3172, 8647, 9654, 11489, 3066, 993, 11742, 10031, 3960, 3909, 10536, 6741, 11938, 11862, 10026, 4809, 1300, 755, 7192, 6834, 10838, 1514, 8844, 9531, 5935, 10845, 7917, 10772, 8104, 10056, 691, 1805, 1143, 6631, 3846, 2101, 1309, 11501, 10271, 1569, 4345, 9517, 12536, 2875, 7307, 216, 12303, 8467, 9664, 961, 1100, 8982, 94, 6088, 2109, 864, 12612, 8813, 12464, 8171, 5530, 6570, 1312, 7686, 9220, 7030, 10431, 5456, 12475, 6679, 3333, 12448, 1825, 4718, 1740, 4510, 9634, 7079, 9319, 5482, 9415, 7168, 8446, 6503, 1564, 2026, 2079, 4417, 7540, 4954, 12153, 11421, 10934, 931, 398, 5528, 8173, 7627, 9538, 8803, 1735, 11484, 2226, 8563, 3289, 6832, 7194, 5535, 8792, 7777, 5336, 1472, 8509, 11708, 10223, 9718, 2222, 5958, 10434, 6127, 7868, 10545, 2717, 8939, 9242, 5148, 7897, 3695, 697, 1753, 1699, 10560, 12591, 4066, 3063, 9847, 11575, 4370, 8488, 3682, 5226, 3415, 6580, 3358, 4776, 6819, 11052, 201, 12462, 8815, 4930, 6080, 8485, 10523, 8785, 7378, 1427, 4207, 11195, 6392, 6448, 11534, 5415, 4620, 5167, 10850, 971, 2686, 2307, 6229, 6533, 2559, 4498, 881, 3826, 9668, 10139, 9638, 9606, 7719, 10401, 10598, 12162, 9854, 4462, 1891, 560, 1296, 4171, 4388, 9276, 12064, 3097, 667, 11762, 9119, 1852, 1876, 1337, 3872, 3131, 9150, 4694, 6391, 11241, 4208, 4573, 4286, 9734, 4564, 9988, 1159, 10949, 12506, 8723, 10080, 2899, 2449, 10732, 6689, 6196, 7210, 6891, 9730, 1174, 9932, 34, 4115, 12335, 7502, 10229, 3907, 3962, 3015, 9308, 5931, 7337, 5694, 8359, 9728, 6893, 10843, 5937, 10927, 1689, 5730, 905, 6211, 1400, 10690, 3031, 4880, 2443, 1355, 8371, 7313, 527, 7239, 3056, 106, 1801, 122, 8651, 9000, 12400, 2439, 6064, 893, 9341, 9303, 386, 8137, 2244, 9888, 12706, 10899, 11867, 4976, 7383, 2609, 4329, 12483, 4037, 12356, 8691, 3362, 4551, 6913, 8820, 5129, 5807, 2732, 1868, 4800, 7357, 7842, 2471, 4725, 12115, 576, 6204, 10881, 12486, 12659, 1650, 1751, 699, 12424, 8492, 7884, 9569, 3621, 10784, 8708, 7852, 5094, 3758, 2299, 5941, 6871, 6167, 9629, 2059, 11511, 5322, 11652, 8701, 3307, 4396, 2839, 12003, 951, 3598, 55, 1620, 10965, 4213, 2579, 3285, 2622, 5670, 12215, 10443, 2539, 12009, 1862, 200, 11253, 6820, 12523, 8232, 2771, 5980, 10115, 7024, 3754, 9298, 6137, 7068, 7846, 3591, 8580, 4739, 12267, 3166, 8045, 3616, 2790, 8008, 537, 5305, 5890, 1787, 1560, 6986, 9201, 5211, 2488, 2051, 5562, 12699, 11807, 10961, 1446, 2156, 173, 10143, 5013, 9616, 12050, 769, 5970, 2913, 9372, 11680, 2328, 4682, 3855, 899, 3806, 4508, 1742, 10241, 38, 9704, 171, 2158, 4438, 6221, 5303, 539, 686, 7804, 6409, 9567, 7886, 2454, 10534, 3911, 1416, 1232, 9836, 5256, 7996, 1390, 8206, 1717, 2475, 1168, 10549, 3192, 6474, 9956, 4212, 11064, 1621, 12017, 1445, 11017, 11808, 6506, 10419, 1260, 10465, 7597, 745, 6094, 10802, 787, 12505, 11187, 1160, 6764, 5056, 10364, 11730, 3662, 10698, 11409, 3190, 10551, 6923, 7935, 2096, 930, 11307, 11422, 9682, 7837, 792, 6824, 1688, 11156, 5938, 5956, 2224, 11486, 4364, 4631, 4430, 3351, 7214, 3701, 10812, 12608, 1576, 12594, 643, 12023, 1347, 11573, 9849, 9337, 7138, 9917, 3253, 8123, 11837, 2890, 11866, 11124, 12707, 2121, 6847, 637, 10360, 9349, 7753, 266, 1388, 7998, 5160, 4183, 6281, 4380, 1967, 4035, 12485, 11098, 6205, 5876, 10519, 6880, 6316, 6437, 8451, 2266, 11520, 4126, 3000, 11770, 366, 2885, 6158, 2820, 3595, 1512, 10840, 12172, 49, 7526, 11666, 9558, 7247, 2586, 705, 1661, 12516, 970, 11234, 5168, 9982, 1608, 7916, 11374, 5936, 11158, 6894, 12171, 10862, 1513, 11379, 6835, 2526, 8120, 968, 12518, 7695, 2310, 10332, 5619, 183, 5768, 5435, 8252, 1501, 12156, 2467, 12076, 2357, 2235, 10508, 4920, 356, 7037, 824, 12607, 10916, 3702, 5603, 6194, 6691, 21, 4845, 2172, 10005, 786, 10952, 6095, 12083, 4502, 2038, 5061, 7882, 8494, 683, 7466, 12165, 8516, 523, 318, 9077, 3425, 4742, 8707, 11087, 3622, 8654, 7663, 941, 10040, 6456, 9393, 7289, 2381, 7098, 8103, 11372, 7918, 5697, 6132, 6854, 9508, 5111, 9857, 12212, 12512, 255, 3093, 2649, 3467, 6364, 3392, 6812, 7133, 8712, 9868, 9377, 5059, 2040, 8334, 1831, 8681, 11829, 10112, 5183, 12585, 10232, 5987, 5765, 4494, 5193, 3422, 4018, 5365, 4900, 6688, 11181, 2450, 661, 5368, 6844, 2010, 1248, 8732, 3981, 8736, 12146, 5002, 8895, 7444, 12300, 10314, 8979, 7162, 7775, 8794, 10574, 9458, 9485, 6646, 6611, 10592, 5870, 1988, 11468, 6721, 12000, 2944, 10612, 11408, 10942, 3663, 3195, 9679, 8705, 4744, 4421, 3030, 11150, 1401, 10637, 4454, 3430, 4105, 8850, 5284, 245, 6592, 6345, 4424, 8212, 1917, 7655, 1965, 4382, 736, 4303, 5645, 4871, 10246, 641, 12596, 8586, 10226, 1694, 7154, 4059, 5054, 6766, 4814, 9443, 3085, 1638, 1205, 7672, 1210, 2387, 6718, 8618, 4606, 1164, 9362, 5503, 5826, 4687, 5538, 4118, 12113, 4727, 6575, 4453, 10688, 1402, 8299, 7476, 337, 11621, 4554, 10585, 3007, 6906, 9985, 482, 6464, 9995, 3655, 12635, 165, 4779, 1779, 11786, 98, 3764, 8868, 1351, 11407, 10700, 2945, 3572, 5515, 3303, 6626, 1370, 11852, 8876, 9468, 621, 9808, 8330, 12161, 11218, 10402, 5085, 7, 1818, 5869, 10707, 6612, 11894, 10309, 2662, 5709, 3006, 10630, 4555, 4529, 162, 7928, 9920, 12583, 5185, 8282, 10282, 9457, 10712, 8795, 3568, 5963, 422, 6479, 469, 5342, 8210, 4426, 137, 4085, 9967, 12590, 11268, 1700, 12543, 1722, 8278, 11448, 7670, 1207, 6922, 10939, 3191, 10970, 1169, 89, 2716, 11278, 7869, 1910, 2711, 7355, 4802, 6565, 8081, 6740, 11389, 3910, 10982, 2455, 3456, 9511, 2277, 8455, 11673, 2239, 6526, 152, 8784, 11246, 8486, 4372, 6879, 10878, 5877, 6100, 7040, 12529, 8224, 3998, 2778, 5489, 2464, 4919, 10818, 2236, 2805, 283, 4045, 24, 9007, 12444, 3452, 6016, 8440, 7318, 8398, 276, 2996, 1432, 6758, 1791, 1230, 1418, 4153, 5858, 10152, 5944, 5719, 8936, 9063, 10357, 1896, 2208, 9911, 1041, 2188, 6190, 6034, 9384, 4577, 1588, 2828, 8314, 1184, 2332, 7596, 10956, 1261, 8642, 8418, 5102, 9234, 6163, 11401, 5031, 6898, 8043, 3168, 8064, 445, 5630, 4263, 1842, 1196, 12428, 1251, 7705, 2538, 11057, 12216, 4990, 10338, 3203, 2185, 4261, 5632, 6126, 11281, 5959, 5455, 11333, 7031, 5025, 3043, 190, 4485, 773, 4903, 1244, 4100, 5512, 1259, 10958, 6507, 8956, 1633, 6775, 6761, 222, 8191, 10390, 4807, 10028, 1484, 6487, 5019, 1884, 2384, 5084, 10597, 11219, 7720, 3587, 764, 418, 884, 2605, 9333, 4602, 6248, 4806, 10411, 8192, 1034, 1711, 8034, 11726, 11530, 2248, 5120, 9281, 7229, 6333, 1084, 7285, 6314, 6882, 8058, 5008, 10179, 4141, 7849, 11646, 7127, 12649, 7749, 11729, 10945, 5057, 9379, 9348, 10894, 638, 1895, 10481, 9064, 9238, 11976, 71, 3225, 4149, 8557, 7059, 1124, 10238, 11549, 3355, 5864, 8017, 3876, 9071, 4676, 3202, 10440, 4991, 3214, 5425, 1940, 5618, 10830, 2311, 7632, 11504, 2063, 5998, 11793, 4189, 1134, 10215, 6501, 8448, 12560, 11801, 2776, 4000, 8828, 8978, 10717, 12301, 218, 4609, 2661, 10589, 11895, 6545, 7387, 10297, 8879, 2532, 7438, 3552, 9254, 9466, 8878, 10305, 7388, 11994, 5165, 4622, 3817, 9844, 11492, 3136, 12038, 4202, 7012, 9961, 9643, 9456, 10576, 8283, 9366, 4089, 9494, 314, 1581, 6652, 7832, 7834, 1568, 11361, 11502, 7634, 4923, 9815, 1533, 1984, 12055, 4581, 4828, 1732, 2182, 9260, 5462, 11912, 1113, 4411, 12006, 4893, 7225, 2205, 7797, 558, 1893, 640, 10669, 4872, 1612, 7991, 37, 10997, 1743, 11548, 10347, 1125, 10195, 7237, 529, 5986, 10742, 12586, 3906, 11169, 7503, 1693, 10665, 8587, 9717, 11285, 11709, 11740, 995, 4755, 8349, 8086, 6500, 10323, 1135, 7641, 2506, 9311, 5073, 2503, 3405, 6786, 12567, 4617, 12324, 5231, 4571, 4210, 9958, 4515, 1148, 12416, 7236, 10236, 1126, 8594, 8394, 6098, 5879, 1879, 4596, 11899, 4703, 3927, 3835, 2412, 5278, 3444, 4140, 10372, 5009, 2271, 1659, 707, 7824, 7946, 4237, 6360, 3634, 11655, 9723, 5202, 3768, 1193, 8591, 6963, 2706, 7580, 5800, 3897, 3796, 6181, 1487, 8218, 6869, 5943, 10486, 5859, 3209, 5790, 4782, 7608, 6808, 11462, 5012, 11013, 174, 6943, 9637, 11223, 9669, 8501, 1653, 9431, 4352, 8675, 4841, 2959, 5467, 1860, 12011, 9908, 12434, 8933, 752, 3941, 4273, 5399, 9004, 1020, 3953, 5376, 7023, 11046, 5981, 5182, 10745, 11830, 2320, 3383, 9626, 5331, 1595, 8387, 5471, 7324, 5350, 5888, 5307, 5023, 7033, 4888, 608, 8554, 9429, 1655, 7046, 6990, 8872, 1081, 11586, 5755, 9439, 1031, 7943, 12110, 4324, 2898, 11184, 8724, 5745, 6977, 7890, 5830, 497, 7727, 12228, 2964, 5016, 6432, 8337, 9621, 1955, 9249, 11625, 3449, 3371, 5229, 12326, 12058, 12288, 690, 11370, 8105, 2405, 2127, 7007, 7878, 378, 5215, 9953, 9873, 9774, 5050, 11776, 9011, 7114, 6455, 10779, 942, 4766, 11560, 2968, 9601, 5423, 3216, 3959, 11392, 11743, 1483, 10409, 4808, 11385, 11863, 346, 11429, 903, 5732, 572, 7492, 3316, 11446, 8280, 5187, 1051, 4030, 655, 429, 5751, 2553, 5136, 2955, 785, 10804, 2173, 5361, 4759, 6074, 12625, 2169, 1438, 3777, 3654, 10624, 6465, 7911, 6152, 748, 4234, 1158, 11189, 4565, 481, 10627, 6907, 1607, 10848, 5169, 6404, 5221, 9401, 6109, 1055, 7678, 6789, 6601, 12663, 5850, 4407, 9787, 12589, 10562, 4086, 9893, 9122, 4137, 9642, 10285, 7013, 4514, 10200, 4211, 10967, 6475, 9872, 10048, 5216, 11918, 9085, 12291, 6238, 2845, 3340, 4482, 1667, 6736, 12581, 9922, 913, 2397, 8716, 2203, 7227, 9283, 8612, 33, 11174, 1175, 3540, 494, 4660, 594, 9098, 1683, 4708, 912, 9941, 12582, 10580, 7929, 3252, 10905, 7139, 6655, 7370, 3809, 1040, 10478, 2209, 12433, 10127, 12012, 8834, 3771, 6077, 3004, 5711, 6649, 11824, 4192, 466, 5922, 6556, 1850, 9121, 9965, 4087, 9368, 3814, 12705, 11126, 2245, 4402, 4360, 868, 5758, 12099, 9133, 7470, 1001, 4282, 8318, 1645, 713, 9773, 10047, 9954, 6476, 2768, 9376, 10753, 8713, 3889, 12241, 9025, 7858, 7093, 3040, 4255, 5625, 12211, 10765, 5112, 4461, 11216, 12163, 7468, 9135, 9336, 10908, 11574, 11264, 3064, 11491, 10291, 3818, 5273, 178, 1359, 5409, 4470, 5255, 10978, 1233, 8931, 12436, 3949, 12348, 1848, 6558, 349, 9473, 877, 1814, 850, 12371, 11637, 7221, 6296, 3154, 8390, 2634, 1532, 10267, 4924, 9103, 5788, 3211, 8542, 8329, 10601, 622, 8198, 11569, 8970, 6744, 1708, 3344, 9647, 11724, 8036, 9040, 8745, 332, 3410, 12331, 11883, 3724, 101, 3904, 12588, 9969, 4408, 5127, 8822, 6004, 9397, 1271, 4243, 8742, 5262, 304, 4393, 5049, 10046, 9874, 714, 2014, 2104, 9144, 5598, 9388, 9553, 1221, 9581, 8798, 12124, 7578, 2708, 11931, 8667, 7873, 2584, 7249, 11782, 12319, 486, 2644, 7700, 3101, 1154, 2679, 3115, 806, 3267, 5123, 1280, 11692, 8606, 9180, 441, 838, 8270, 4563, 11191, 4287, 5070, 1173, 11176, 6892, 11160, 8360, 3860, 7172, 5201, 10168, 11656, 3947, 12438, 2221, 11284, 10224, 8588, 1845, 946, 7783, 6637, 2812, 7005, 2129, 2086, 5810, 8551, 170, 10995, 39, 12389, 8752, 1549, 3408, 334, 6663, 12238, 3294, 4560, 7075, 7283, 1086, 7295, 11760, 669, 6368, 8293, 2024, 1566, 7836, 10932, 11423, 8704, 10695, 3196, 181, 5621, 2854, 8461, 7689, 2287, 12526, 8500, 10138, 11224, 3827, 8639, 960, 11351, 8468, 580, 813, 5475, 1574, 12610, 866, 4362, 11488, 11397, 8648, 1450, 2869, 1225, 1320, 11723, 9800, 3345, 8903, 9455, 10284, 9962, 4138, 3446, 9605, 11222, 10140, 6944, 7078, 11323, 4511, 6374, 3271, 2058, 11078, 6168, 5330, 10108, 3384, 5115, 12459, 1954, 10067, 8338, 650, 1508, 12049, 11011, 5014, 2966, 11562, 3669, 5196, 9204, 3125, 4180, 7718, 11221, 9639, 3447, 11627, 5422, 10035, 2969, 11910, 5464, 935, 845, 7028, 9222, 7329, 453, 3510, 3106, 8536, 7057, 8559, 11702, 8842, 1516, 3566, 8797, 9764, 1222, 2426, 678, 6396, 4186, 12633, 3657, 7424, 264, 7755, 3620, 11089, 7885, 10985, 6410, 3804, 901, 11431, 6418, 2896, 4326, 7246, 10857, 11667, 12557, 6440, 1220, 9766, 9389, 5628, 447, 1680, 4671, 2261, 4652, 5842, 6550, 1316, 4069, 6660, 7479, 8802, 11301, 7628, 12710, 4240, 5450, 5780, 5934, 11376, 8845, 472, 3692, 6176, 1305, 1775, 2165, 1746, 6242, 9051, 2019, 3037, 12535, 11358, 4346, 9038, 8038, 2376, 2276, 10531, 3457, 5110, 10767, 6855, 2565, 6926, 2904, 4174, 7723, 2379, 7291, 2682, 8757, 8367, 3679, 313, 10278, 4090, 1236, 12643, 2363, 8567, 6058, 5347, 6645, 10710, 9459, 11750, 5441, 8070, 12600, 12490, 6330, 5519, 7182, 4291, 876, 9827, 350, 4615, 12569, 620, 10603, 8877, 10299, 9255, 4785, 2797, 1811, 4593, 11749, 9484, 10711, 10575, 10283, 9644, 8904, 11677, 8236, 12414, 1150, 11908, 2971, 7593, 3436, 6340, 3084, 10658, 4815, 6542, 1030, 10086, 5756, 870, 9018, 12020, 12183, 7270, 4351, 10135, 1654, 10094, 8555, 4151, 1420, 5884, 6002, 8824, 476, 3020, 8156, 12224, 28, 456, 7167, 11319, 5483, 7199, 2107, 6090, 1290, 4013, 1643, 8320, 7668, 11450, 9192, 12307, 6108, 9978, 5222, 2697, 1270, 9782, 6005, 7543, 7288, 10777, 6457, 12209, 5627, 9552, 9767, 5599, 6262, 4576, 10473, 6035, 1386, 268, 9347, 10362, 5058, 10752, 9869, 2769, 8234, 11679, 11006, 2914, 3069, 3813, 9891, 4088, 10280, 8284, 1796, 5502, 10647, 1165, 2370, 6852, 6134, 1459, 7940, 8195, 4023, 1601, 8165, 11527, 7752, 10893, 10361, 9380, 269, 9265, 2653, 7487, 9302, 11131, 894, 841, 7137, 10907, 9850, 9136, 4601, 10394, 2606, 3090, 7601, 8256, 1026, 4599, 9138, 8974, 6350, 1958, 5904, 297, 5481, 11321, 7080, 248, 7435, 9273, 87, 1171, 5072, 10211, 2507, 5930, 11165, 3016, 12382, 2921, 385, 11130, 9342, 7488, 1457, 6136, 11043, 3755, 12197, 9044, 7521, 1978, 8698, 3637, 1928, 7974, 450, 6415, 8260, 2029, 8611, 9935, 7228, 10381, 5121, 3269, 6376, 12063, 11209, 4389, 86, 9315, 7436, 2534, 8576, 3075, 3111, 1089, 2652, 9345, 270, 2215, 6700, 5461, 10259, 2183, 3205, 7606, 4784, 9465, 10300, 3553, 7584, 6910, 11624, 10065, 1956, 6352, 7065, 8265, 6973, 5147, 11275, 8940, 8985, 11975, 10355, 9065, 7052, 6162, 10460, 5103, 859, 12641, 1238, 4736, 6941, 176, 5275, 9165, 7953, 7328, 9594, 7029, 11335, 7687, 8463, 5156, 11889, 110, 811, 582, 6009, 5325, 723, 4310, 5509, 12685, 12261, 3124, 9610, 5197, 5210, 11024, 6987, 4569, 5233, 4664, 3799, 514, 373, 12306, 9404, 11451, 11758, 7297, 394, 12231, 6253, 4731, 5594, 7263, 6937, 440, 9739, 8607, 8885, 6043, 11539, 2785, 12222, 8158, 8188, 6388, 11706, 8511, 5705, 363, 7952, 9225, 5276, 2414, 3462, 5132, 3968, 12385, 7405, 12521, 6822, 794, 5654, 11593, 12068, 4693, 11198, 3132, 3919, 2143, 6753, 5597, 9769, 2105, 7201, 11458, 11935, 8973, 9326, 4600, 9335, 9851, 7469, 9881, 12100, 6597, 8539, 4994, 2316, 11952, 8572, 4868, 1676, 4136, 9964, 9894, 1851, 11204, 11763, 1648, 12661, 6603, 7145, 8128, 12654, 8621, 322, 11649, 6012, 5316, 674, 12168, 5787, 9813, 4925, 5557, 4669, 1682, 9926, 595, 4959, 3145, 1627, 1932, 4062, 3717, 5919, 6482, 7802, 688, 12290, 9950, 11919, 7063, 6354, 2545, 1061, 4016, 3424, 10788, 319, 3788, 11537, 6045, 4675, 10341, 3877, 6429, 6490, 6049, 7051, 9237, 10356, 10482, 8937, 2719, 2092, 81, 3141, 5292, 8547, 8635, 984, 1772, 2018, 9521, 6243, 12603, 11906, 1152, 3103, 7520, 9295, 12198, 5260, 8744, 9797, 8037, 9515, 4347, 3219, 12403, 4226, 1455, 7490, 574, 12117, 5100, 8420, 4980, 7857, 9864, 12242, 3187, 6540, 4817, 1443, 12019, 9436, 871, 7767, 5500, 1798, 1904, 7113, 10043, 11777, 1075, 12443, 10502, 25, 1019, 10120, 5400, 12190, 12399, 11136, 8652, 3624, 6797, 7650, 5614, 353, 7637, 831, 2924, 12615, 8953, 6842, 5370, 11974, 9240, 8941, 93, 11348, 1101, 7161, 10716, 10315, 8829, 12044, 6349, 9325, 9139, 11936, 6743, 9804, 11570, 6086, 96, 11788, 7190, 757, 4973, 5690, 1671, 3418, 519, 7620, 1632, 10417, 6508, 6841, 8989, 12616, 2099, 3848, 12454, 7512, 2549, 11523, 3880, 2810, 6639, 92, 8984, 9241, 11276, 2718, 9062, 10483, 5720, 751, 10125, 12435, 9834, 1234, 4092, 12395, 3640, 1179, 7302, 1118, 5608, 11611, 4928, 8817, 2557, 6535, 8050, 3519, 12202, 6769, 6998, 6304, 3150, 11815, 1715, 8208, 5344, 2802, 11676, 9454, 9645, 3346, 2825, 11, 8092, 2423, 2872, 7443, 10720, 5003, 5910, 6750, 12295, 11833, 1490, 3048, 4077, 6042, 9178, 8608, 3867, 7376, 8787, 2531, 10304, 10298, 9467, 10604, 11853, 342, 1080, 10090, 6991, 6083, 1350, 10615, 3765, 262, 7426, 6516, 7574, 4539, 8032, 1713, 11817, 8728, 8673, 4354, 2989, 5544, 6425, 8168, 5283, 10684, 4106, 3832, 5340, 471, 9530, 11377, 1515, 9585, 11703, 4697, 2373, 3645, 6287, 1191, 3770, 9906, 12013, 4052, 7397, 12043, 8977, 10316, 4001, 2849, 475, 9423, 6003, 9784, 5128, 11111, 6914, 2556, 8920, 4929, 11250, 12463, 11342, 12613, 2926, 128, 2485, 1547, 8754, 1325, 2180, 1734, 11300, 9539, 7480, 8053, 12123, 9763, 9582, 3567, 10573, 10713, 7776, 11291, 5536, 4689, 8011, 2530, 8881, 7377, 11245, 10524, 153, 916, 460, 4341, 43, 5915, 4638, 11413, 11962, 2592, 8443, 6293, 7810, 11473, 1058, 2994, 278, 2883, 368, 8604, 11694, 2597, 7340, 8068, 5443, 8366, 9498, 2683, 1324, 8807, 1548, 9701, 12390, 5591, 5798, 7582, 3555, 331, 9796, 9041, 5261, 9779, 4244, 7362, 11988, 6981, 12145, 10723, 3982, 1991, 3980, 10725, 1249, 12430, 8672, 8858, 11818, 4448, 5744, 10079, 11185, 12507, 434, 11514, 4943, 4490, 2202, 9938, 2398, 3888, 9867, 10754, 7134, 11644, 7851, 11086, 10785, 4743, 10694, 9680, 11424, 3306, 11073, 11653, 3636, 9292, 1979, 7351, 7966, 12091, 4519, 3361, 11115, 12357, 5680, 7829, 7142, 11663, 2702, 12061, 6378, 11828, 10747, 1832, 231, 1598, 360, 4840, 10133, 4353, 8857, 8729, 12431, 2211, 12692, 7872, 9758, 11932, 12422, 701, 3883, 5319, 437, 8584, 12598, 8072, 5560, 2053, 7662, 10782, 3623, 8999, 11137, 123, 1449, 9653, 11398, 3173, 6056, 8569, 8417, 10463, 1262, 959, 9666, 3828, 6674, 983, 9055, 8548, 1110, 6725, 12577, 2152, 2749, 2823, 3348, 2436, 3222, 11480, 3786, 321, 9111, 12655, 4605, 10650, 6719, 11470, 2293, 7204, 32, 9934, 9284, 2030, 3866, 8884, 9179, 9740, 11693, 8764, 369, 4722, 12680, 1543, 381, 7176, 2073, 603, 8393, 10193, 1127, 6962, 10164, 1194, 1844, 9716, 10225, 10666, 12597, 8660, 438, 6939, 4738, 11038, 3592, 2752, 3074, 9270, 2535, 2344, 4867, 9126, 11953, 8416, 8644, 6057, 9489, 2364, 4159, 3288, 11296, 2227, 6858, 11701, 9587, 7058, 10350, 4150, 9428, 10095, 609, 169, 9706, 5811, 1109, 8634, 9056, 5293, 11418, 1504, 8328, 9810, 3212, 4993, 9130, 6598, 7056, 9589, 3107, 4998, 7554, 1828, 6435, 6318, 3139, 83, 921, 2390, 11582, 890, 2816, 12250, 5219, 6406, 7450, 8239, 522, 10791, 12166, 676, 2428, 5704, 9169, 11707, 11287, 1473, 1521, 8143, 2514, 2758, 1749, 1652, 10137, 9670, 12527, 7042, 206, 12283, 682, 10795, 7883, 11091, 12425, 311, 3681, 11261, 4371, 10522, 11247, 6081, 6993, 11966, 2725, 11558, 4768, 2543, 6356, 4, 3180, 7266, 11443, 2935, 3974, 5354, 579, 9663, 11352, 12304, 375, 5155, 9218, 7688, 9674, 2855, 7091, 7860, 1097, 11672, 10529, 2278, 7084, 2265, 10874, 6438, 12559, 10321, 6502, 11317, 7169, 6292, 8773, 2593, 7317, 10498, 6017, 11498, 6573, 4729, 6255, 11713, 2837, 4398, 6451, 8141, 1523, 2982, 7646, 6568, 5532, 3240, 11840, 235, 4979, 9028, 5101, 10462, 8643, 8570, 11954, 69, 11978, 2043, 7071, 4984, 6861, 12652, 8130, 11991, 3506, 7207, 5144, 6272, 6020, 7218, 275, 10496, 7319, 12081, 6097, 10192, 8595, 604, 2633, 9818, 3155, 5470, 10105, 1596, 233, 11842, 4950, 585, 5913, 45, 567, 7715, 5163, 11996, 12254, 3935, 12673, 7312, 11145, 1356, 3199, 3678, 9497, 8758, 5444, 3283, 2581, 4041, 3859, 9727, 11161, 5695, 7920, 8312, 2830, 11848, 3059, 1228, 1793, 8085, 10218, 4756, 4752, 1139, 1453, 4228, 2194, 5837, 5606, 1120, 649, 9620, 10068, 6433, 1830, 10749, 2041, 11980, 12160, 10600, 9809, 8543, 1505, 3440, 12630, 11796, 12410, 2939, 7667, 9407, 1644, 9877, 4283, 6265, 1183, 10469, 2829, 8356, 7921, 7746, 6864, 2745, 2929, 7589, 11601, 2460, 710, 11766, 4714, 7475, 10635, 1403, 5176, 142, 7970, 2023, 9686, 6369, 2036, 4504, 2150, 12579, 6738, 8083, 1795, 9365, 10281, 10577, 5186, 10016, 11447, 10556, 1723, 6495, 4821, 7855, 4982, 7073, 4562, 9736, 839, 896, 3989, 6972, 9245, 7066, 6139, 2077, 2028, 9286, 6416, 11433, 1025, 9329, 7602, 2860, 1500, 10825, 5436, 4532, 5761, 5179, 1276, 7305, 2877, 7461, 12151, 4956, 7618, 521, 8518, 7451, 12413, 9452, 11678, 9374, 2770, 11049, 12524, 2289, 11943, 7151, 18, 7771, 3997, 10514, 12530, 6949, 1976, 7523, 6868, 10155, 1488, 11835, 8125, 631, 1916, 10678, 4425, 10566, 5343, 8908, 1716, 10974, 1391, 3082, 6342, 5701, 2756, 2516, 11568, 9806, 623, 4022, 9355, 7941, 1033, 10389, 10412, 223, 6387, 9172, 8159, 2132, 12554, 7278, 4465, 6955, 618, 12571, 4747, 626, 5140, 3853, 4684, 7626, 11303, 5529, 11340, 12465, 5282, 8852, 6426, 11526, 9352, 1602, 5803, 1093, 2084, 2131, 8187, 9173, 12223, 9420, 3021, 5641, 4444, 2980, 1525, 2728, 12235, 5667, 5727, 3516, 7483, 2513, 8506, 1522, 8430, 6452, 3330, 2243, 11128, 387, 659, 2452, 7888, 6979, 11990, 8407, 12653, 9113, 7146, 630, 8215, 11836, 10903, 3254, 967, 10835, 2527, 817, 11688, 3388, 3578, 3381, 2322, 6468, 59, 4096, 2066, 11552, 12496, 2404, 10055, 11371, 10773, 7099, 12364, 3244, 147, 2510, 392, 7299, 1479, 7549, 2422, 8899, 12, 5299, 11609, 5610, 6499, 10217, 8350, 1794, 8286, 6739, 10538, 6566, 7648, 6799, 3938, 1303, 6178, 4667, 5559, 8658, 12599, 9481, 5442, 8760, 7341, 5206, 444, 10453, 3169, 6874, 6684, 856, 5007, 10374, 6883, 12220, 2787, 12122, 8800, 7481, 3518, 8917, 6536, 4641, 7157, 3615, 11034, 3167, 10455, 6899, 6669, 3643, 2375, 9514, 9039, 9798, 11725, 10386, 1712, 8861, 4540, 5090, 6888, 2071, 7178, 3925, 4705, 12180, 646, 3564, 1518, 6325, 1011, 3875, 10343, 5865, 7322, 5473, 815, 2529, 8789, 4690, 536, 11031, 2791, 11804, 981, 6676, 7781, 948, 4414, 5241, 5159, 10889, 1389, 10976, 5257, 12345, 4113, 36, 10243, 1613, 601, 2075, 6141, 4279, 6461, 3530, 7122, 6919, 7675, 11476, 3486, 5775, 4134, 1678, 449, 9289, 1929, 4009, 2022, 8295, 143, 4536, 12090, 8695, 7352, 7958, 4368, 11577, 11719, 2496, 4367, 7964, 7353, 2713, 6642, 7327, 9224, 9166, 364, 11772, 2677, 1156, 4236, 10173, 7825, 12109, 10084, 1032, 8194, 9356, 1460, 5897, 12549, 2095, 10937, 6924, 2567, 5108, 3459, 3251, 9919, 10581, 163, 12637, 7864, 5901, 5584, 7745, 8311, 8357, 5696, 10771, 11373, 10846, 1609, 5359, 2175, 6151, 9993, 6466, 2324, 2305, 2688, 1331, 11416, 5295, 511, 5948, 2056, 3273, 6174, 3694, 11273, 5149, 6219, 4440, 4861, 7623, 5829, 10076, 6978, 8133, 2453, 10984, 9568, 11090, 8493, 10796, 5062, 5153, 377, 10051, 7008, 12354, 4039, 2583, 9757, 8668, 12693, 1909, 10544, 11279, 6128, 12103, 5900, 7925, 12638, 12376, 1096, 8458, 7092, 9863, 9026, 4981, 8274, 4822, 5093, 11085, 8709, 11645, 10370, 4142, 3590, 11040, 7069, 2045, 2470, 11104, 7358, 6514, 7428, 791, 10931, 9683, 1567, 10273, 7833, 10274, 6653, 7141, 8688, 5681, 2618, 12108, 7945, 10174, 708, 2462, 5491, 4908, 5268, 767, 12052, 7349, 1981, 6028, 11941, 2291, 11472, 8771, 6294, 7223, 4895, 7448, 6408, 10987, 687, 9088, 6483, 12313, 733, 557, 10250, 2206, 1898, 12360, 5080, 2447, 2901, 3613, 7159, 1103, 3794, 3899, 1466, 6636, 9713, 947, 8003, 6677, 12477, 5335, 11290, 8793, 10714, 7163, 1200, 3996, 8226, 19, 6693, 5499, 9016, 872, 4332, 12131, 6708, 5174, 1405, 563, 4473, 5098, 12119, 3619, 9571, 265, 10892, 9350, 11528, 11728, 10366, 12650, 6863, 8310, 7922, 5585, 11957, 3752, 7026, 847, 1593, 5333, 12479, 4294, 3688, 4859, 4442, 5643, 4305, 5855, 1016, 12227, 10073, 498, 2274, 2378, 9502, 4175, 3586, 10400, 11220, 9607, 4181, 5162, 8378, 568, 1994, 3821, 6806, 7610, 11858, 4656, 2342, 2537, 10445, 1252, 2571, 1703, 3100, 9750, 2645, 6284, 6227, 2309, 10832, 12519, 7407, 2616, 5683, 2286, 9673, 8462, 9219, 11336, 1313, 2258, 5818, 6931, 6187, 12565, 6788, 9975, 1056, 11475, 7981, 6920, 1209, 10654, 1206, 10554, 11449, 9406, 8321, 2940, 2670, 940, 10781, 8655, 2054, 5950, 1769, 2352, 3337, 1964, 10676, 1918, 4834, 7563, 5613, 8996, 6798, 8079, 6567, 8427, 2983, 11543, 3403, 2505, 10213, 1136, 998, 830, 8993, 354, 4922, 10269, 11503, 10330, 2312, 2119, 12709, 9537, 11302, 8174, 4685, 5828, 7892, 4862, 1631, 8958, 520, 8241, 4957, 597, 3686, 4296, 2254, 3482, 11857, 7710, 6807, 10147, 4783, 9257, 3206, 1949, 2859, 8255, 9330, 3091, 257, 744, 10955, 10466, 2333, 3435, 9447, 2972, 11436, 11600, 8306, 2930, 3894, 1605, 6909, 9252, 3554, 8748, 5799, 10161, 2707, 9761, 12125, 12088, 4538, 8863, 6517, 5507, 4312, 6444, 5741, 3472, 1441, 4819, 6497, 5612, 7652, 4835, 12339, 4251, 3498, 827, 7473, 4716, 1827, 8533, 4999, 4338, 720, 2421, 8094, 1480, 1866, 2734, 6312, 7287, 9395, 6006, 4953, 11311, 4418, 12574, 6953, 4467, 11440, 6733, 2602, 1971, 131, 2137, 4434, 2700, 11665, 10859, 50, 6867, 8220, 1977, 9294, 9045, 3104, 3512, 7506, 11880, 5542, 2991, 2548, 8948, 12455, 5373, 4649, 12272, 11879, 7517, 3513, 1692, 10228, 11170, 12336, 2666, 2763, 798, 464, 4194, 6310, 2736, 3315, 10019, 573, 9032, 1456, 9301, 9343, 2654, 390, 2512, 8145, 3517, 8052, 8801, 9540, 6661, 336, 10634, 8300, 4715, 7557, 828, 1000, 9880, 9134, 9852, 12164, 10793, 684, 541, 12668, 12150, 8244, 2878, 1738, 4720, 371, 516, 3673, 3972, 2937, 12412, 8238, 8519, 6407, 7806, 4896, 11949, 12299, 10719, 8896, 2873, 12538, 3489, 3551, 10302, 2533, 9272, 9316, 249, 4546, 3864, 2032, 12471, 790, 7839, 6515, 8865, 263, 9573, 3658, 4169, 1298, 4811, 12205, 978, 12702, 4625, 1107, 5813, 6493, 1725, 12177, 1686, 6826, 2615, 7693, 12520, 9158, 12386, 5406, 12501, 5459, 6702, 3608, 12042, 8831, 4053, 12279, 1203, 1640, 1064, 6705, 3504, 11993, 10296, 10306, 6546, 3088, 2608, 11121, 4977, 237, 4937, 1426, 11244, 8786, 8882, 3868, 12245, 2148, 4506, 3808, 9914, 6656, 3228, 6071, 5390, 2613, 6828, 11987, 8740, 4245, 12137, 6513, 7841, 11105, 4801, 10541, 2712, 7957, 7965, 8696, 1980, 7816, 12053, 1986, 5872, 3728, 742, 259, 5205, 8067, 8761, 2598, 5693, 11163, 5932, 5782, 6530, 405, 5715, 6413, 452, 9593, 9223, 7954, 6643, 5349, 10103, 5472, 8015, 5866, 12080, 8397, 10497, 8441, 2594, 3712, 526, 11144, 8372, 12674, 328, 5312, 215, 11355, 2876, 8246, 1277, 1117, 8925, 1180, 1478, 8096, 393, 9189, 11759, 9690, 1087, 3113, 2681, 9500, 2380, 10776, 9394, 7544, 6313, 10377, 1085, 9692, 7076, 6946, 1889, 4464, 8184, 12555, 11669, 964, 3233, 4646, 3956, 4350, 9433, 12184, 6731, 11442, 8474, 3181, 6936, 9183, 5595, 6755, 2283, 1383, 241, 213, 5314, 6014, 3454, 2457, 804, 3117, 11781, 9755, 2585, 10856, 9559, 4327, 2611, 5392, 4701, 11901, 3055, 11142, 528, 10235, 10196, 12417, 3395, 1395, 3301, 5517, 6332, 10380, 9282, 9936, 2204, 10252, 4894, 7808, 6295, 9821, 11638, 274, 8400, 6021, 4947, 3700, 10918, 3352, 2069, 6890, 11178, 6197, 5143, 8404, 3507, 31, 8614, 2294, 11457, 9142, 2106, 9413, 5484, 6384, 3238, 5534, 11293, 6833, 11381, 756, 8965, 11789, 12316, 1411, 4543, 1376, 6146, 4290, 9476, 5520, 1423, 3924, 8027, 2072, 8598, 382, 834, 5200, 9725, 3861, 6291, 8445, 11318, 9416, 457, 308, 1199, 7774, 10715, 8980, 1102, 7789, 3614, 8047, 4642, 4058, 10663, 1695, 17, 8228, 11944, 6747, 588, 629, 8127, 9114, 6604, 11662, 8687, 7830, 6654, 9916, 10906, 9338, 842, 11643, 8711, 10755, 6813, 4792, 4971, 759, 12648, 10368, 11647, 324, 3965, 6918, 7983, 3531, 5453, 5961, 3570, 2947, 3328, 6454, 10042, 9012, 1905, 6522, 6877, 4374, 11596, 3792, 1105, 4627, 6217, 5151, 5064, 3720, 12363, 8102, 10774, 2382, 1886, 12533, 3039, 9862, 7859, 8459, 2856, 505, 3325, 3164, 12269, 2264, 8453, 2279, 6590, 247, 9318, 11322, 9635, 6945, 7282, 9693, 4561, 8272, 4983, 8411, 2044, 7845, 11041, 6138, 8264, 9246, 6353, 9083, 11920, 3561, 1123, 10349, 8558, 9588, 8537, 6599, 6791, 6161, 9236, 9066, 6050, 479, 4567, 6989, 10092, 1656, 501, 205, 8498, 12528, 10516, 6101, 823, 10815, 357, 4026, 4887, 10098, 5024, 10430, 11334, 9221, 9595, 846, 7741, 3753, 11045, 10116, 5377, 1553, 4357, 4796, 1945, 6584, 6121, 6372, 4513, 9960, 10286, 4203, 3547, 12353, 7877, 10052, 2128, 9710, 2813, 6067, 6106, 12309, 5383, 6303, 8913, 6770, 2231, 3780, 11965, 8483, 6082, 8871, 10091, 7047, 4568, 9200, 11025, 1561, 11811, 2694, 12144, 8738, 11989, 8132, 7889, 10077, 5746, 6270, 5146, 9244, 8266, 3990, 2637, 5739, 6446, 6394, 680, 12285, 2705, 10163, 8592, 1128, 2628, 3277, 11846, 2832, 617, 8182, 4466, 7537, 12575, 6727, 1975, 8222, 12531, 1888, 7281, 7077, 9636, 10141, 175, 9228, 4737, 8582, 439, 9182, 7264, 3182, 6782, 5380, 6186, 7682, 5819, 546, 3611, 2903, 9505, 2566, 7934, 10938, 10552, 1208, 7674, 7982, 7123, 3966, 5134, 2555, 8819, 11112, 4552, 11623, 9251, 7585, 1606, 9984, 10628, 3008, 4165, 11607, 5301, 6223, 6668, 8042, 10456, 5032, 5785, 12170, 10842, 11159, 9729, 11177, 7211, 2070, 8029, 5091, 4824, 2640, 12219, 8057, 10375, 6315, 10877, 10520, 4373, 7110, 6523, 6683, 8062, 3170, 6166, 11080, 5942, 10154, 8219, 7524, 51, 2744, 8309, 7747, 12651, 8409, 4985, 11700, 8561, 2228, 2564, 9507, 10768, 6133, 9359, 2371, 4699, 5394, 636, 10896, 2122, 2009, 10728, 5369, 8988, 8954, 6509, 1836, 2197, 6616, 2525, 10837, 11380, 7193, 11294, 3290, 6714, 11986, 7364, 2614, 7409, 1687, 10929, 793, 9156, 12522, 11051, 11254, 4777, 167, 611, 4850, 4791, 7132, 10756, 3393, 12419, 11461, 10146, 7609, 7711, 3822, 5966, 12129, 4334, 12671, 3937, 8078, 7649, 8997, 3625, 6234, 12248, 2818, 6160, 7054, 6600, 9974, 7679, 12566, 10207, 3406, 1551, 5379, 6934, 3183, 1340, 1871, 1558, 1789, 6760, 10415, 1634, 5845, 2562, 2230, 6997, 8914, 12203, 4813, 10660, 5055, 10947, 1161, 221, 10414, 6776, 1790, 10492, 1433, 2282, 7261, 5596, 9146, 2144, 12294, 8892, 5911, 587, 7149, 11945, 1707, 9803, 8971, 11937, 11388, 10537, 8082, 8287, 12580, 9943, 1668, 2601, 7534, 11441, 7268, 12185, 2482, 1974, 6951, 12576, 8632, 1111, 11914, 11999, 10703, 11469, 8617, 10651, 2388, 923, 11985, 6830, 3291, 3892, 2932, 3319, 5173, 7763, 12132, 3503, 7391, 1065, 3607, 7400, 5460, 9262, 2216, 4276, 1218, 6442, 4314, 5498, 7769, 20, 10808, 6195, 11180, 10733, 4901, 775, 855, 8061, 6875, 6524, 2241, 3332, 11330, 12476, 7780, 8004, 982, 8637, 3829, 3538, 1177, 3642, 8041, 6900, 6224, 3648, 5665, 12237, 9697, 335, 7478, 9541, 4070, 4147, 3227, 7369, 9915, 7140, 7831, 10275, 1582, 11823, 9901, 5712, 6610, 10709, 9486, 5348, 7326, 7955, 2714, 91, 8943, 2811, 9712, 7784, 1467, 4231, 5723, 3845, 11366, 1144, 3747, 12620, 1369, 10607, 3304, 11426, 6561, 11969, 1762, 1914, 633, 4320, 2524, 6837, 2198, 5676, 11893, 10591, 10708, 6647, 5713, 407, 3313, 2738, 11661, 7144, 9115, 12662, 9973, 6790, 7055, 8538, 9131, 12101, 6130, 5699, 6344, 10681, 246, 7082, 2280, 1435, 4848, 613, 6120, 7017, 1946, 5862, 3357, 11257, 3416, 1673, 5648, 4452, 10639, 4728, 8437, 11499, 1311, 11338, 5531, 8426, 7647, 8080, 10539, 4803, 2723, 11968, 6623, 11427, 348, 9829, 1849, 9896, 5923, 5662, 3480, 2256, 1315, 9544, 5843, 1636, 3087, 7386, 10307, 11896, 1029, 9441, 4816, 9022, 3188, 11411, 4640, 8049, 8918, 2558, 11229, 6230, 404, 7334, 5783, 5034, 151, 10526, 2240, 6682, 6876, 7111, 1906, 6025, 1536, 5506, 7573, 8864, 7427, 7840, 7359, 12138, 1616, 1835, 6840, 8955, 10418, 10959, 11809, 1563, 11316, 8447, 10322, 10216, 8087, 5611, 7565, 4820, 8276, 1724, 7413, 5814, 6048, 9068, 6430, 5018, 10407, 1485, 6183, 12312, 7801, 9089, 5920, 468, 10569, 423, 2767, 9871, 9955, 10968, 3193, 3665, 113, 227, 58, 8112, 2323, 7910, 9994, 10625, 483, 3529, 7985, 4280, 1003, 12208, 9392, 10778, 10041, 7115, 3329, 8140, 8431, 4399, 11533, 11239, 6393, 6968, 5740, 7570, 4313, 6696, 1219, 9555, 12558, 8450, 10875, 6317, 8531, 1829, 8336, 10069, 5017, 6489, 9069, 3878, 11525, 8167, 8853, 5545, 4271, 3943, 4906, 5493, 2895, 9562, 11432, 8259, 9287, 451, 7331, 5716, 3803, 9566, 10986, 7805, 7449, 8520, 5220, 9980, 5170, 5429, 2339, 5834, 1839, 6279, 4185, 9577, 679, 6967, 6447, 11240, 11196, 4695, 11705, 9171, 8189, 224, 3237, 7197, 5485, 2336, 11632, 1131, 11827, 8683, 12062, 9278, 3270, 9632, 4512, 7015, 6122, 2035, 8292, 9687, 670, 3740, 3391, 10758, 3468, 5651, 3633, 10171, 4238, 12712, 3, 8477, 2544, 9082, 7064, 9247, 1957, 9324, 8975, 12045, 3028, 4423, 10680, 6593, 5700, 8203, 3083, 9445, 3437, 653, 4032, 888, 11584, 1083, 10379, 7230, 5518, 9478, 12491, 4526, 3544, 1010, 8020, 1519, 1475, 6268, 5748, 12036, 3138, 8530, 6436, 10876, 6881, 10376, 7286, 7545, 2735, 7495, 4195, 5266, 4910, 1729, 3149, 8912, 6999, 5384, 12264, 3428, 4456, 1283, 3153, 9820, 7222, 7809, 8772, 8444, 7170, 3862, 4548, 1190, 8837, 3646, 6226, 7698, 2646, 4379, 10886, 4184, 6398, 1840, 4265, 157, 3160, 11496, 6019, 8402, 5145, 6975, 5747, 6322, 1476, 1182, 8316, 4284, 4575, 9386, 5600, 2674, 1937, 3323, 507, 11712, 8435, 4730, 9186, 12232, 2090, 2721, 4805, 10392, 4603, 12657, 12488, 12602, 9050, 9522, 1747, 2760, 2844, 9948, 12292, 2146, 12247, 6795, 3626, 4914, 403, 6532, 11230, 2308, 7697, 6285, 3647, 6667, 6901, 5302, 10991, 4439, 7895, 5150, 7104, 4628, 2499, 2393, 4268, 1399, 11152, 906, 1756, 2297, 3760, 5875, 10880, 11099, 577, 5356, 4875, 5288, 3851, 5142, 7209, 11179, 6690, 10809, 5604, 5839, 6033, 10475, 2189, 12564, 7681, 6932, 5381, 12311, 6485, 1486, 10157, 3797, 4666, 8075, 1304, 9527, 3693, 7899, 3274, 11686, 819, 2408, 5329, 9628, 11079, 6872, 3171, 11400, 10459, 9235, 7053, 6792, 2819, 10866, 2886, 12367, 1288, 6092, 747, 9992, 7912, 2176, 4635, 5068, 4289, 7184, 1377, 11404, 1216, 4278, 7987, 2076, 8263, 7067, 11042, 9299, 1458, 9358, 6853, 10769, 5698, 6595, 12102, 7867, 11280, 10435, 5633, 12469, 2034, 6371, 7016, 6585, 614, 3584, 4177, 5660, 5925, 2742, 53, 3600, 5571, 1054, 9977, 9402, 12308, 7002, 6068, 2007, 2124, 822, 7039, 10517, 5878, 10191, 8395, 12082, 10801, 10953, 746, 6154, 1289, 9411, 2108, 11346, 95, 8968, 11571, 1349, 8870, 6992, 8484, 11248, 4931, 3003, 9904, 3772, 12624, 10001, 4760, 5389, 7367, 3229, 2006, 6105, 7003, 2814, 892, 11133, 2440, 4884, 5575, 2800, 5346, 9488, 8568, 8645, 3174, 5237, 12380, 3018, 478, 7050, 9067, 6491, 5815, 4674, 9073, 11538, 9177, 8886, 4078, 11733, 4711, 4935, 239, 1385, 9383, 10474, 6191, 5840, 4654, 11860, 11940, 7814, 1982, 1535, 6520, 1907, 12695, 4946, 7217, 8401, 6273, 11497, 8439, 10499, 3453, 7255, 5315, 9108, 11650, 5324, 9212, 583, 4952, 7542, 9396, 9783, 8823, 9424, 5885, 730, 11792, 10327, 2064, 4098, 1246, 2012, 716, 801, 11604, 4083, 139, 5764, 10741, 10233, 530, 5447, 1274, 5181, 10114, 11047, 2772, 135, 4428, 4633, 2178, 1327, 778, 3744, 2912, 11008, 770, 5566, 12128, 6804, 3823, 421, 10571, 3569, 7119, 5454, 10433, 11282, 2223, 10925, 5939, 2301, 12494, 11554, 1768, 7660, 2055, 7902, 512, 3801, 5718, 10485, 10153, 6870, 11081, 2300, 5955, 10926, 11157, 10844, 11375, 9532, 5781, 7336, 11164, 9309, 2508, 149, 5036, 2741, 6115, 5661, 6555, 9897, 467, 6481, 9090, 3718, 5066, 4637, 8778, 44, 8381, 586, 6749, 8893, 5004, 5106, 2569, 1254, 296, 9322, 1959, 5583, 7924, 7865, 12104, 12548, 7938, 1461, 1664, 193, 3559, 11922, 1786, 11028, 5306, 10101, 5351, 729, 6001, 9425, 1421, 5522, 1335, 1878, 10190, 6099, 10518, 10879, 6206, 3761, 3727, 7346, 1987, 10706, 10593, 1819, 12079, 7321, 8016, 10344, 3356, 6582, 1947, 3208, 10151, 10487, 4154, 1015, 7730, 4306, 64, 4968, 4406, 9971, 12664, 5191, 4496, 2561, 6773, 1635, 6549, 9545, 4653, 6032, 6192, 5605, 8342, 2195, 1838, 6400, 2340, 4658, 496, 10075, 7891, 7624, 4686, 10645, 5504, 1538, 2986, 1556, 1873, 545, 6930, 7683, 2259, 4673, 6047, 6492, 7414, 1108, 8550, 9707, 2087, 2731, 11109, 5130, 3464, 1092, 8163, 1603, 3896, 10160, 7581, 8749, 5592, 4733, 5041, 11507, 2163, 1777, 4781, 10149, 3210, 9812, 9104, 12169, 6896, 5033, 6529, 7335, 5933, 9533, 5451, 3533, 12276, 4133, 7978, 3487, 12540, 2574, 3079, 5638, 5434, 10827, 184, 4493, 10740, 5988, 140, 5178, 8249, 4533, 12098, 9883, 869, 9438, 10087, 11587, 4123, 2552, 10010, 430, 12035, 6321, 6269, 6976, 10078, 8725, 4449, 3471, 7569, 6445, 6969, 2638, 4826, 4583, 726, 3977, 571, 10021, 904, 11154, 1690, 3515, 8147, 5668, 2624, 3844, 6633, 4232, 750, 8935, 10484, 5945, 3802, 6412, 7332, 406, 6609, 6648, 9902, 3005, 10587, 2663, 4838, 362, 9168, 8512, 2429, 2755, 8202, 6343, 6594, 6131, 10770, 7919, 8358, 11162, 7338, 2599, 1670, 8962, 4974, 11869, 3120, 3494, 1381, 2285, 7691, 2617, 7828, 8689, 12358, 1900, 11892, 6614, 2199, 187, 4217, 12510, 12214, 11059, 2623, 5726, 8148, 12236, 6665, 3649, 3479, 6554, 5924, 6116, 4178, 3127, 4157, 2366, 11592, 9154, 795, 3632, 6362, 3469, 4451, 6577, 1674, 4870, 10671, 4304, 7732, 4443, 8154, 3022, 5433, 5770, 3080, 1393, 3397, 12468, 6125, 10436, 4262, 10451, 446, 9551, 9390, 12210, 9859, 4256, 4856, 2853, 9676, 182, 10829, 10333, 1941, 4613, 352, 8995, 7651, 7564, 6498, 8088, 11610, 8923, 1119, 8341, 5838, 6193, 10810, 3703, 2673, 6261, 9387, 9768, 9145, 6754, 7262, 9184, 4732, 5797, 8750, 12391, 1068, 2347, 67, 11956, 7744, 7923, 5902, 1960, 4004, 1072, 11873, 3377, 1809, 2799, 6061, 4885, 4028, 1053, 6111, 3601, 4588, 12086, 12127, 5968, 771, 4487, 12698, 11020, 2052, 8657, 8073, 4668, 9101, 4926, 11613, 3735, 2000, 4941, 11516, 12407, 12258, 3299, 1397, 4270, 6424, 8854, 2990, 7515, 11881, 12333, 4117, 10643, 4688, 8791, 11292, 7195, 3239, 8425, 6569, 11339, 8172, 11304, 399, 926, 3750, 11959, 1334, 5882, 1422, 7181, 9477, 6331, 7231, 3302, 10609, 3573, 1258, 10421, 4101, 12684, 9208, 4311, 7572, 6518, 1537, 5825, 10646, 9363, 1797, 9015, 7768, 6694, 4315, 12441, 1077, 2894, 6420, 4907, 7821, 2463, 10511, 2779, 3433, 2335, 6383, 7198, 9414, 11320, 9320, 298, 2519, 2480, 12187, 1573, 9660, 814, 8014, 7323, 10104, 8388, 3156, 1859, 10130, 2960, 934, 9598, 11911, 10258, 9261, 6701, 7401, 12502, 12474, 11332, 10432, 5960, 7120, 3532, 5779, 9534, 4241, 1273, 5984, 531, 3282, 8365, 8759, 8069, 9482, 11751, 1046, 160, 4531, 8251, 10826, 5769, 5639, 3023, 11630, 2338, 6402, 5171, 3321, 1939, 10335, 3215, 10034, 9602, 11628, 3025, 956, 3526, 12322, 4619, 11237, 11535, 3790, 11598, 11438, 4469, 9839, 1360, 12500, 7403, 12387, 41, 4343, 1571, 12189, 9003, 10121, 4274, 2218, 4318, 635, 6849, 4700, 7243, 2612, 7366, 6072, 4761, 3492, 3122, 12263, 6302, 7000, 12310, 6185, 6933, 6783, 1552, 7022, 10117, 3954, 4648, 7510, 12456, 11973, 8987, 6843, 10729, 662, 4899, 10735, 4019, 4750, 4758, 10003, 2174, 7914, 1610, 4874, 6202, 578, 8470, 3975, 728, 5887, 10102, 7325, 6644, 9487, 6059, 2801, 8907, 8209, 10567, 470, 8847, 3833, 3929, 1471, 11289, 7778, 12478, 7738, 1594, 10107, 9627, 6169, 2409, 2419, 722, 9211, 6010, 11651, 11075, 11512, 436, 8662, 3884, 673, 9107, 6013, 7256, 214, 7309, 329, 3557, 195, 5022, 10100, 5889, 11029, 538, 10990, 6222, 6902, 11608, 8090, 13, 11737, 510, 7904, 11417, 8546, 9057, 3142, 12452, 3850, 6200, 4876, 11925, 244, 10683, 8851, 8169, 12466, 3399, 3443, 10182, 2413, 9164, 9226, 177, 9842, 3819, 1996, 416, 766, 7819, 4909, 6308, 4196, 4477, 303, 9778, 8743, 9042, 12199, 12344, 7995, 10977, 9837, 4471, 565, 47, 12174, 12031, 1922, 551, 2863, 3581, 2835, 11715, 11887, 5158, 8000, 4415, 2081, 12379, 6054, 3175, 3914, 4663, 9198, 4570, 10203, 12325, 10061, 3372, 3414, 11259, 3683, 12142, 2696, 9400, 9979, 6405, 8521, 12251, 11917, 9952, 10049, 379, 1545, 2487, 11023, 9202, 5198, 836, 443, 8066, 7342, 260, 3767, 10167, 9724, 7173, 835, 5209, 9203, 9611, 3670, 3421, 10738, 4495, 5848, 12665, 1856, 1050, 10015, 8281, 10578, 12584, 10744, 10113, 5982, 1275, 8248, 5762, 141, 8297, 1404, 7762, 6709, 3320, 5428, 6403, 9981, 10849, 11235, 4621, 10294, 11995, 8377, 7716, 4182, 10888, 7999, 5242, 11888, 9217, 8464, 376, 7880, 5063, 7103, 6218, 7896, 11274, 9243, 6974, 6271, 8403, 7208, 6198, 3852, 8177, 627, 590, 2954, 10008, 2554, 6916, 3967, 9161, 3463, 5806, 11110, 8821, 9785, 4409, 1115, 1279, 9743, 3268, 9280, 10382, 2249, 1760, 11971, 12458, 9624, 3385, 4460, 9856, 10766, 9509, 3458, 7932, 2568, 5908, 5005, 858, 9233, 10461, 8419, 9029, 12118, 7758, 4474, 12195, 3757, 11084, 7853, 4823, 6887, 8030, 4541, 1413, 3178, 6, 10596, 10403, 2385, 1212, 2446, 7793, 12361, 3722, 11885, 11717, 11579, 2502, 10210, 9312, 1172, 9732, 4288, 6148, 4636, 5917, 3719, 7102, 5152, 7881, 10797, 2039, 10751, 9378, 10363, 10946, 6765, 10661, 4060, 1934, 11775, 10045, 9775, 4394, 3309, 1266, 2161, 11509, 2061, 11506, 5795, 4734, 1240, 11659, 2740, 5927, 150, 6528, 5784, 6897, 10457, 11402, 1379, 3496, 4253, 3042, 10429, 7032, 10099, 5308, 196, 1883, 10406, 6488, 6431, 10070, 2965, 9615, 11012, 10144, 11463, 2270, 10178, 10373, 8059, 857, 5105, 5909, 8894, 10721, 12147, 4337, 7553, 8534, 3108, 1495, 2315, 9129, 8540, 3213, 10337, 10441, 12217, 2642, 488, 11699, 6860, 8410, 7072, 8273, 7856, 9027, 8421, 236, 7382, 11122, 11868, 5689, 8963, 758, 7130, 4793, 4405, 5852, 65, 2349, 987, 1187, 3365, 1823, 12450, 3144, 9096, 596, 7617, 8242, 12152, 11310, 7541, 6007, 584, 8383, 11843, 3699, 7216, 6022, 12696, 4489, 8719, 11515, 5552, 2001, 3922, 1425, 7380, 238, 6038, 4712, 11768, 3002, 6079, 11249, 8816, 8921, 11612, 5556, 9102, 9814, 10268, 7635, 355, 10817, 10509, 2465, 12158, 11982, 402, 6232, 3627, 12028, 1728, 6307, 5267, 7820, 5492, 6421, 3944, 1243, 10424, 774, 6687, 10734, 5366, 663, 11948, 7447, 7807, 7224, 10253, 12007, 2541, 4770, 607, 10097, 7034, 4027, 5574, 6062, 2441, 4882, 2442, 11148, 3032, 1784, 11924, 5287, 6201, 5357, 1611, 10245, 10670, 5646, 1675, 9125, 8573, 2345, 1070, 4006, 1630, 7622, 7893, 4441, 7734, 3689, 2852, 5623, 4257, 11619, 339, 77, 4790, 6815, 612, 6587, 1436, 2171, 10806, 22, 4047, 2958, 10132, 8676, 361, 5707, 2664, 12338, 7562, 7653, 1919, 4222, 1625, 3147, 1731, 10262, 4582, 5737, 2639, 6886, 5092, 7854, 8275, 6496, 7566, 1442, 9021, 6541, 9442, 10659, 6767, 12204, 7420, 1299, 11384, 10027, 10410, 10391, 6249, 2722, 6564, 10540, 7356, 11106, 1869, 1342, 1944, 7019, 4358, 4404, 4970, 7131, 6814, 4851, 78, 12552, 2134, 2796, 9464, 9256, 7607, 10148, 5791, 1778, 10620, 166, 6818, 11255, 3359, 4521, 11683, 2631, 606, 4890, 2542, 8479, 11559, 10038, 943, 12351, 3549, 3491, 5388, 6073, 10002, 5362, 4751, 8348, 10219, 996, 1138, 8347, 4757, 5363, 4020, 625, 8179, 12572, 4420, 10693, 8706, 10786, 3426, 12266, 11037, 8581, 6940, 9229, 1239, 5040, 5796, 5593, 9185, 6254, 8436, 6574, 10640, 12114, 11102, 2472, 12679, 8602, 370, 7458, 1739, 11326, 1826, 7556, 7474, 8301, 11767, 4934, 6039, 11734, 911, 9924, 1684, 12179, 8025, 3926, 10186, 11900, 7242, 5393, 6850, 2372, 8840, 11704, 6390, 11197, 9151, 12069, 535, 8010, 8790, 5537, 10644, 5827, 7625, 8175, 3854, 11003, 2329, 990, 2917, 3676, 3201, 10340, 9072, 6046, 5816, 2260, 9548, 1681, 9100, 5558, 8074, 6179, 3798, 9197, 5234, 3915, 593, 9928, 495, 5832, 2341, 7708, 11859, 6031, 5841, 9546, 2262, 12271, 7509, 5374, 3955, 7273, 3234, 116, 4057, 7156, 8048, 6537, 11412, 8777, 5916, 5067, 6149, 2177, 5976, 4429, 10921, 4365, 2498, 6216, 7105, 1106, 7416, 12703, 3816, 10293, 5166, 11236, 5416, 12323, 10205, 12568, 9471, 351, 5616, 1942, 1344, 2660, 10311, 219, 1163, 10649, 8619, 12656, 6247, 10393, 9334, 9137, 9327, 1027, 11898, 10188, 1880, 11748, 9461, 1812, 879, 4500, 12085, 5569, 3602, 62, 4308, 725, 5736, 4827, 10263, 12056, 12328, 1587, 10472, 9385, 6263, 4285, 11193, 4209, 10202, 5232, 9199, 6988, 7048, 480, 9987, 11190, 9735, 8271, 7074, 9694, 3295, 492, 3542, 4528, 10584, 10631, 11622, 6912, 11113, 3363, 1189, 6289, 3863, 7433, 250, 1375, 7186, 1412, 5089, 8031, 8862, 7575, 12089, 7968, 144, 12097, 5760, 8250, 5437, 161, 10583, 4556, 3543, 6328, 12492, 2303, 2326, 11682, 4774, 3360, 8693, 12092, 2909, 1147, 10199, 9959, 7014, 6373, 9633, 11324, 1741, 10999, 3807, 7372, 2149, 8290, 2037, 10799, 12084, 4590, 880, 11227, 2560, 5847, 5192, 10739, 5766, 185, 2201, 8718, 4944, 12697, 5564, 772, 10426, 191, 1666, 9945, 3341, 1037, 3263, 302, 5264, 4197, 12194, 5097, 7759, 564, 5254, 9838, 5410, 11439, 7536, 6954, 8183, 7279, 1890, 11215, 9855, 5113, 3386, 11690, 1282, 6299, 3429, 10687, 10638, 6576, 5649, 3470, 5743, 8726, 11819, 11876, 2979, 8153, 5642, 7733, 4860, 7894, 6220, 10992, 2159, 1268, 2699, 7529, 2138, 2434, 3350, 10920, 4632, 5977, 136, 10565, 8211, 10679, 6346, 3029, 10692, 4745, 12573, 7539, 11312, 2080, 5240, 8001, 949, 12005, 10255, 1114, 5126, 9786, 9970, 5851, 4969, 4794, 4359, 9886, 2246, 11532, 6450, 8432, 2838, 11071, 3308, 5048, 9776, 305, 919, 85, 9275, 11210, 4172, 2906, 2115, 555, 735, 10674, 1966, 10885, 6282, 2647, 3095, 12066, 11595, 7109, 6878, 10521, 8487, 11262, 11576, 7963, 7959, 2497, 4630, 10922, 11487, 9656, 867, 9885, 4403, 4795, 7020, 1554, 2988, 8856, 8674, 10134, 9432, 7271, 3957, 3218, 9037, 9516, 11359, 1570, 5403, 42, 8780, 461, 719, 7552, 5000, 12148, 12670, 6802, 12130, 7765, 873, 12482, 11119, 2610, 7245, 9560, 2897, 10082, 12111, 4120, 2523, 6618, 634, 5396, 2219, 12440, 5497, 6695, 6443, 7571, 5508, 9209, 724, 4585, 63, 5854, 7731, 5644, 10672, 737, 12646, 761, 4145, 4072, 2253, 7614, 3687, 7736, 12480, 875, 9475, 7183, 6147, 5069, 9733, 11192, 4574, 6264, 8317, 9878, 1002, 6460, 7986, 6142, 1217, 6698, 2217, 5398, 10122, 3942, 6423, 5546, 1398, 6213, 2394, 156, 6277, 1841, 10450, 5631, 10437, 2186, 1043, 11618, 4855, 5624, 9860, 3041, 5027, 3497, 7560, 12340, 411, 1363, 3052, 12136, 7361, 8741, 9780, 1272, 5449, 9535, 12711, 6359, 10172, 7947, 1157, 9990, 749, 5722, 6634, 1468, 2193, 8344, 1454, 9034, 12404, 290, 1624, 4832, 1920, 12033, 432, 12509, 5673, 188, 3045, 2578, 11063, 10966, 9957, 10201, 4572, 11194, 11242, 1428, 1008, 3546, 7011, 10287, 12039, 549, 1924, 12193, 4476, 5265, 6309, 7496, 465, 9899, 11825, 1133, 10325, 11794, 12632, 9576, 6397, 6280, 10887, 5161, 7717, 9608, 3126, 5659, 6117, 3585, 7722, 9503, 2905, 4387, 11211, 1297, 7422, 3659, 4081, 11606, 6904, 3009, 12546, 12106, 2620, 3287, 8565, 2365, 5657, 3128, 1014, 5857, 10488, 1419, 9427, 8556, 10351, 3226, 6658, 4071, 4299, 762, 3589, 7848, 10371, 10180, 3445, 9641, 9963, 9123, 1677, 7977, 5776, 12277, 4055, 118, 2049, 2490, 2999, 10871, 11521, 2551, 5753, 11588, 2522, 4322, 12112, 10642, 5539, 12334, 11172, 35, 7993, 12346, 3951, 1022, 2975, 3536, 3831, 8849, 10685, 3431, 2781, 12683, 5511, 10422, 1245, 5996, 2065, 8110, 60, 3604, 12394, 8929, 1235, 9493, 10279, 9367, 9892, 9966, 10563, 138, 5990, 11605, 4167, 3660, 11732, 6041, 8887, 3049, 11756, 11453, 2252, 4298, 4146, 6659, 9542, 1317, 3062, 11266, 12592, 1578, 3716, 9092, 1933, 5053, 10662, 7155, 4643, 117, 4131, 12278, 7396, 8832, 12014, 293, 783, 2957, 4843, 23, 10504, 284, 3986, 3858, 8362, 2582, 7875, 12355, 11117, 12484, 10883, 1968, 887, 6337, 654, 10013, 1052, 5573, 4886, 7035, 358, 1600, 9354, 8196, 624, 4749, 5364, 10736, 3423, 9079, 1062, 1642, 9409, 1291, 3035, 2021, 7972, 1930, 1629, 4864, 1071, 5581, 1961, 2848, 8827, 10317, 2777, 10513, 8225, 7772, 1201, 12281, 208, 1530, 2636, 6971, 8267, 897, 3857, 4043, 285, 11466, 1990, 8735, 10724, 8733, 1992, 570, 5734, 727, 5353, 8471, 2936, 7454, 3674, 2919, 12384, 9160, 5133, 6917, 7124, 325, 3014, 11167, 3908, 11391, 10032, 3217, 4349, 7272, 4647, 5375, 10118, 1021, 4111, 12347, 9832, 12437, 9721, 11657, 1242, 4905, 6422, 4272, 10123, 753, 1302, 8077, 6800, 12672, 8374, 12255, 11799, 12562, 2191, 1470, 5338, 3834, 10185, 4704, 8026, 7179, 1424, 4939, 2002, 2142, 9148, 3133, 2952, 592, 4662, 5235, 3176, 1415, 10981, 10535, 11390, 3961, 11168, 10230, 12587, 9789, 102, 1373, 252, 1465, 7786, 3795, 10159, 5801, 1604, 7587, 2931, 6712, 3292, 12240, 9866, 8714, 2399, 3738, 672, 5318, 8663, 702, 2809, 8945, 11524, 6428, 9070, 10342, 8018, 1012, 3130, 11200, 1338, 3185, 12244, 7375, 8883, 8609, 2031, 7432, 4547, 6290, 7171, 9726, 8361, 4042, 3987, 898, 11002, 4683, 8176, 5141, 6199, 5289, 12453, 8950, 2100, 11365, 6632, 5724, 2625, 11635, 12373, 862, 2111, 3248, 2417, 2411, 10184, 3928, 5339, 8848, 4107, 3537, 6673, 8638, 9667, 11225, 882, 420, 5965, 6805, 7712, 1995, 5272, 9843, 10292, 4623, 12704, 9890, 9369, 3070, 3261, 1039, 9913, 7371, 4507, 11000, 900, 9565, 6411, 5717, 5946, 513, 9196, 4665, 6180, 10158, 3898, 7787, 1104, 7107, 11597, 5413, 11536, 9075, 320, 8623, 11481, 2881, 280, 2590, 11964, 6995, 2232, 3653, 9997, 1439, 3474, 3731, 12623, 6076, 9905, 8835, 1192, 10166, 5203, 261, 8867, 10616, 99, 3726, 5874, 6207, 2298, 11083, 5095, 12196, 9297, 11044, 7025, 7742, 11958, 5525, 927, 12619, 6629, 1145, 2911, 5972, 779, 3576, 3390, 6366, 671, 3886, 2400, 1999, 5554, 11614, 1367, 12622, 3774, 3475, 741, 7345, 5873, 3762, 100, 9791, 11884, 5078, 12362, 7101, 5065, 5918, 9091, 4063, 1579, 316, 525, 7315, 2595, 11696, 12690, 2213, 272, 11640, 938, 2672, 5602, 10811, 10917, 7215, 4948, 11844, 3279, 696, 11272, 7898, 6175, 9528, 473, 2851, 4858, 7735, 4295, 7615, 598, 12141, 5225, 11260, 8489, 312, 9496, 8368, 3200, 4678, 2918, 3971, 7455, 517, 3420, 5195, 9612, 11563, 809, 112, 6472, 3194, 10697, 10943, 11731, 4080, 4168, 7423, 9574, 12634, 10623, 9996, 3778, 2233, 2359, 3478, 5664, 6666, 6225, 6286, 8838, 2374, 8040, 6670, 1178, 8927, 12396, 1927, 9291, 8699, 11654, 10170, 6361, 5652, 796, 2765, 425, 12027, 4913, 6233, 6796, 8998, 8653, 10783, 11088, 9570, 7756, 12120, 2789, 11033, 8046, 7158, 7790, 2902, 6928, 547, 12041, 7399, 6703, 1066, 12393, 4094, 61, 4587, 5570, 6112, 54, 11067, 952, 1511, 10864, 2821, 2751, 8579, 11039, 7847, 4143, 763, 10399, 7721, 4176, 6118, 615, 2834, 5246, 2864, 3380, 8115, 3389, 3742, 780, 1257, 5514, 10610, 2946, 7118, 5962, 10572, 8796, 9583, 1517, 8022, 647, 1122, 7061, 11921, 5893, 194, 5310, 330, 8747, 7583, 9253, 10301, 7439, 3490, 4763, 12352, 7010, 4204, 1009, 6327, 4527, 4557, 493, 9930, 1176, 6672, 3830, 4108, 2976, 12275, 5778, 5452, 7121, 7984, 6462, 484, 12321, 5418, 957, 1264, 3311, 409, 12342, 12201, 8916, 8051, 7482, 8146, 5728, 1691, 7505, 7518, 3105, 9591, 454, 30, 7206, 8405, 11992, 7390, 6706, 12133, 11904, 12605, 826, 7559, 4252, 5028, 1380, 5686, 3121, 5387, 4762, 3550, 7440, 12539, 5774, 7979, 11477, 74, 11856, 7612, 2255, 6553, 5663, 3650, 2360, 740, 3730, 3775, 1440, 7568, 5742, 4450, 5650, 6363, 10759, 2650, 1091, 5805, 5131, 9162, 2415, 3250, 7931, 5109, 9510, 10532, 2456, 7254, 6015, 10500, 12445, 3370, 10063, 11626, 9604, 9640, 4139, 10181, 5279, 3400, 12629, 8326, 1506, 652, 6339, 9446, 7594, 2334, 5487, 2780, 4104, 10686, 4455, 6300, 12265, 4741, 10787, 9078, 4017, 10737, 5194, 3671, 518, 8960, 1672, 6579, 11258, 5227, 3373, 1585, 12330, 9794, 333, 9699, 1550, 6785, 10208, 2504, 7643, 11544, 12628, 3442, 5280, 12467, 5635, 1394, 7234, 12418, 6811, 10757, 6365, 3741, 3577, 8116, 11689, 4459, 5114, 9625, 10109, 2321, 8114, 3579, 2865, 1808, 5578, 11874, 11821, 1584, 3413, 5228, 10062, 3450, 12446, 3335, 2354, 1822, 4963, 1188, 4550, 11114, 8692, 4520, 4775, 11256, 6581, 5863, 10345, 11550, 2068, 7213, 10919, 4431, 2435, 8627, 2824, 8902, 9646, 9801, 1709, 1036, 4481, 9946, 2846, 1963, 7657, 2353, 3368, 12447, 11329, 6680, 2242, 8139, 6453, 7116, 2948, 3163, 7088, 506, 6258, 1938, 5427, 5172, 6710, 2933, 11445, 10018, 7493, 2737, 6607, 408, 3523, 1265, 5047, 4395, 11072, 8702, 11425, 6625, 10608, 5516, 7232, 1396, 5548, 12259, 12687, 491, 4559, 9695, 12239, 3891, 6713, 6831, 11295, 8564, 4160, 2621, 11061, 2580, 8364, 5445, 532, 695, 3697, 11845, 6959, 2629, 11685, 6173, 7900, 2057, 9631, 6375, 9279, 5122, 9744, 807, 11565, 301, 4479, 1038, 3811, 3071, 2432, 2140, 2004, 3231, 966, 8122, 10904, 9918, 7930, 3460, 2416, 3838, 2112, 12095, 146, 8100, 12365, 2888, 11839, 8424, 5533, 7196, 6385, 225, 115, 4645, 7274, 965, 3256, 2005, 6070, 7368, 6657, 4148, 10352, 72, 11479, 8625, 2437, 12402, 9036, 4348, 3958, 10033, 5424, 10336, 4992, 8541, 9811, 5789, 10150, 5860, 1948, 7605, 9258, 2184, 10439, 10339, 4677, 3677, 8369, 1357, 180, 9678, 10696, 3664, 6473, 10969, 10550, 10940, 11410, 6539, 9023, 12243, 3870, 1339, 6781, 6935, 7265, 8475, 5, 5087, 1414, 3913, 5236, 6055, 8646, 11399, 6165, 6873, 8063, 10454, 8044, 11035, 12268, 7087, 3326, 2949, 11495, 6275, 158, 1048, 1858, 5469, 8389, 9819, 6297, 1284, 11814, 8911, 6305, 1730, 4830, 1626, 9095, 4960, 12451, 5291, 9058, 82, 8529, 6319, 12037, 10289, 11493, 2951, 3918, 9149, 11199, 3873, 1013, 4156, 5658, 4179, 9609, 9205, 12262, 5386, 3493, 5687, 11870, 11780, 7251, 805, 9746, 2680, 7293, 1088, 9268, 3076, 1494, 4997, 8535, 9590, 3511, 7519, 9046, 1153, 9749, 7701, 1704, 666, 11207, 12065, 4377, 2648, 10761, 256, 7600, 9331, 2607, 7385, 6547, 1637, 10657, 9444, 6341, 8204, 1392, 5637, 5771, 2575, 1493, 3110, 9269, 8577, 2753, 2431, 3260, 3812, 9370, 2915, 992, 11395, 11490, 9846, 11265, 4067, 1318, 1227, 8353, 11849, 105, 11141, 7240, 11902, 12135, 4247, 1364, 11755, 4076, 8888, 1491, 2577, 4215, 189, 10428, 5026, 4254, 9861, 7094, 12534, 9519, 2020, 4011, 1292, 1783, 4879, 11149, 10691, 4422, 6347, 12046, 955, 5420, 11629, 5432, 5640, 8155, 9421, 477, 6052, 12381, 9307, 11166, 3963, 326, 12676, 1720, 12545, 4164, 6905, 10629, 10586, 5710, 9903, 6078, 4932, 11769, 10870, 4127, 2491, 1431, 10494, 277, 8768, 1059, 2547, 7514, 5543, 8855, 4355, 1555, 5823, 1539, 11542, 7645, 8428, 1524, 8152, 4445, 11877, 12274, 3535, 4109, 1023, 11435, 7592, 9448, 11909, 9600, 10036, 11561, 9614, 5015, 10071, 12229, 396, 933, 5466, 10131, 4842, 4048, 784, 10007, 5137, 591, 3917, 3134, 11494, 3162, 3327, 7117, 3571, 10611, 10701, 12001, 2841, 2669, 7666, 8322, 12411, 7453, 3973, 8472, 11444, 3318, 6711, 3893, 7588, 8307, 2746, 127, 8811, 12614, 8991, 832, 384, 9305, 12383, 3970, 3675, 4679, 991, 3068, 9371, 11007, 5971, 3745, 1146, 4517, 12093, 2114, 4386, 4173, 9504, 6927, 3612, 7791, 2448, 11183, 10081, 4325, 9561, 6419, 5494, 1078, 344, 11865, 10901, 11838, 3242, 12366, 6157, 10867, 367, 8766, 279, 3784, 11482, 1737, 7460, 8245, 7306, 11356, 12537, 7442, 8897, 2424, 1224, 9651, 1451, 1141, 1807, 3379, 3580, 5247, 552, 1499, 8254, 7603, 1950, 504, 7090, 8460, 9675, 5622, 4857, 3690, 474, 8826, 4002, 1962, 3339, 9947, 6239, 2761, 2668, 2942, 12002, 11070, 4397, 8433, 11714, 5245, 3582, 616, 6957, 11847, 8355, 8313, 10470, 1589, 10, 8901, 3347, 8628, 2750, 3594, 10865, 6159, 6793, 12249, 8523, 891, 6066, 7004, 9711, 6638, 8944, 3881, 703, 2588, 282, 10506, 2237, 11675, 8906, 5345, 6060, 5576, 1810, 9463, 4786, 2135, 133, 2774, 11803, 8007, 11032, 3617, 12121, 8055, 12221, 9175, 11540, 1541, 12682, 4103, 3432, 5488, 10512, 3999, 10318, 11802, 2793, 134, 5979, 11048, 8233, 9375, 9870, 6477, 424, 3630, 797, 7499, 2667, 2843, 6240, 1748, 8504, 2515, 8201, 5702, 2430, 3073, 8578, 3593, 2822, 8629, 2153, 126, 2928, 8308, 6865, 52, 6114, 5926, 5037, 11660, 6606, 3314, 7494, 6311, 7546, 1867, 11108, 5808, 2088, 12234, 8150, 1526, 11557, 8481, 11967, 6563, 4804, 6250, 2091, 9061, 8938, 11277, 10546, 90, 6641, 7956, 7354, 10542, 1911, 11930, 9760, 7579, 10162, 6964, 12286, 12060, 8685, 11664, 7528, 4435, 1269, 9399, 5223, 12143, 6983, 11812, 1286, 12369, 852, 1330, 7907, 2306, 11232, 972, 1323, 8756, 9499, 7292, 3114, 9747, 1155, 7949, 11773, 1936, 6260, 5601, 3704, 939, 7665, 2941, 2842, 2762, 7500, 12337, 4837, 5708, 10588, 10310, 4610, 1345, 12025, 427, 657, 389, 7486, 9344, 9266, 1090, 3466, 10760, 3094, 4378, 6283, 7699, 9751, 487, 4988, 12218, 6885, 4825, 5738, 6970, 3991, 1531, 9817, 8391, 605, 4772, 11684, 3276, 6960, 1129, 11634, 3843, 5725, 5669, 11060, 3286, 4161, 12107, 7827, 5682, 7692, 7408, 6827, 7365, 5391, 7244, 4328, 11120, 7384, 3089, 9332, 10395, 885, 1970, 7533, 6734, 1669, 5692, 7339, 8762, 11695, 3711, 7316, 8442, 8774, 11963, 3782, 281, 2807, 704, 10855, 7248, 9756, 7874, 4040, 8363, 3284, 11062, 4214, 3046, 1492, 3078, 5772, 12541, 1702, 7703, 1253, 5907, 5107, 7933, 6925, 9506, 6856, 2229, 6772, 5846, 4497, 11228, 6534, 8919, 8818, 6915, 5135, 10009, 5752, 4124, 11522, 8947, 7513, 2992, 1060, 9081, 6355, 8478, 4769, 4891, 12008, 11056, 10444, 7706, 2343, 8575, 9271, 7437, 10303, 8880, 8788, 8012, 816, 8119, 10836, 6836, 6617, 4321, 4121, 11589, 2479, 5479, 299, 11567, 8200, 2757, 8505, 8144, 7484, 391, 8098, 148, 5929, 9310, 10212, 7642, 3404, 10209, 5074, 11580, 2392, 6215, 4629, 4366, 7960, 11720, 975, 1006, 1430, 2998, 4128, 2050, 11022, 5212, 1546, 8809, 129, 1973, 6729, 12186, 5478, 2520, 11590, 2368, 1167, 10972, 1718, 12678, 4724, 11103, 7843, 2046, 12075, 10822, 12157, 4918, 10510, 5490, 7822, 709, 8304, 11602, 803, 7253, 3455, 10533, 10983, 7887, 8134, 660, 10731, 11182, 2900, 7792, 5081, 1213, 1354, 11147, 4881, 4883, 6063, 11134, 12401, 3221, 8626, 3349, 4432, 2139, 3259, 3072, 2754, 5703, 8513, 677, 9579, 1223, 2871, 8898, 8093, 7550, 721, 5327, 2410, 3837, 3249, 3461, 9163, 5277, 10183, 3836, 2418, 5328, 6170, 820, 2126, 10054, 8106, 12497, 414, 1998, 3737, 3887, 8715, 9939, 914, 155, 4267, 6214, 2500, 11581, 8526, 922, 6717, 10652, 1211, 5083, 10404, 1885, 7097, 10775, 7290, 9501, 7724, 2275, 9513, 8039, 3644, 8839, 4698, 6851, 9360, 1166, 2477, 11591, 5656, 4158, 8566, 9490, 12644, 739, 3477, 3651, 2234, 10820, 12077, 1821, 3367, 3336, 7658, 1770, 986, 4966, 66, 5588, 1069, 4866, 8574, 2536, 7707, 4657, 5833, 6401, 5430, 11631, 6382, 5486, 3434, 7595, 10467, 1185, 989, 4681, 11004, 11681, 4523, 2304, 7909, 6467, 8113, 3382, 10110, 11831, 12297, 11951, 9128, 4995, 1496, 2118, 7631, 10331, 10831, 7696, 6228, 11231, 2687, 7908, 2325, 4524, 12493, 5954, 5940, 11082, 3759, 6208, 1757, 11456, 7203, 8615, 11471, 7812, 11942, 8230, 12525, 9672, 7690, 5684, 1382, 7260, 6756, 1434, 6589, 7083, 8454, 10530, 9512, 2377, 7725, 499, 1658, 10177, 5010, 11464, 287, 11519, 10873, 8452, 7085, 12270, 4651, 9547, 4672, 5817, 7684, 1314, 6552, 3481, 7613, 4297, 4073, 11454, 1759, 5119, 10383, 11531, 4401, 9887, 11127, 8138, 3331, 6681, 6525, 10527, 11674, 2804, 10507, 10819, 2358, 3652, 3779, 6996, 6771, 2563, 6857, 8562, 11297, 11485, 10924, 5957, 11283, 9719, 12439, 4317, 5397, 4275, 6699, 9263, 271, 3708, 12691, 8670, 12432, 9910, 10479, 1897, 7796, 10251, 7226, 9937, 8717, 4491, 186, 5675, 6615, 6838, 1837, 5836, 8343, 4229, 1469, 3931, 12563, 6189, 10476, 1042, 4260, 10438, 3204, 9259, 10260, 1733, 8805, 1326, 5975, 4634, 6150, 7913, 5360, 10004, 10805, 4846, 1437, 9999, 12626, 11546, 1745, 9524, 1776, 5793, 11508, 5045, 1267, 4437, 10993, 172, 11015, 1447, 125, 2748, 8630, 12578, 8289, 4505, 7373, 12246, 6236, 12293, 6752, 9147, 3920, 2003, 3258, 2433, 4433, 7530, 132, 2795, 4787, 12553, 8186, 8160, 2085, 9709, 7006, 10053, 2406, 821, 6103, 2008, 6846, 10897, 12708, 7630, 2313, 1497, 554, 4385, 2907, 12094, 3247, 3839, 863, 11345, 6089, 9412, 7200, 9143, 9770, 2015, 1308, 11364, 3847, 8951, 12617, 929, 10936, 7936, 12550, 80, 9060, 2720, 6251, 12233, 2730, 5809, 9708, 2130, 8161, 1094, 12378, 5239, 4416, 11313, 2027, 8262, 6140, 7988, 602, 8597, 7177, 8028, 6889, 7212, 3353, 11551, 8109, 4097, 5997, 10328, 11505, 5043, 11510, 11077, 9630, 3272, 7901, 5949, 7661, 8656, 5561, 11021, 2489, 4129, 119, 12074, 2469, 7844, 7070, 8412, 11979, 8333, 10750, 5060, 10798, 4503, 8291, 6370, 6123, 12470, 7431, 3865, 8610, 9285, 8261, 2078, 11314, 1565, 9685, 8294, 7971, 4010, 3036, 9520, 9052, 1773, 1307, 2103, 9771, 715, 5994, 1247, 10727, 6845, 2123, 6104, 6069, 3230, 3257, 2141, 3921, 4940, 5553, 3736, 2401, 415, 5271, 3820, 7713, 569, 3979, 8734, 3983, 11467, 10705, 5871, 7347, 12054, 10265, 1534, 6027, 7815, 7350, 8697, 9293, 7522, 8221, 6950, 6728, 2483, 130, 7532, 2603, 886, 4034, 10884, 4381, 10675, 7656, 3338, 2847, 4003, 5582, 5903, 9323, 6351, 9248, 10066, 9622, 12460, 203, 503, 2858, 7604, 3207, 5861, 6583, 7018, 4797, 1343, 4612, 5617, 10334, 5426, 3322, 6259, 2675, 11774, 5052, 4061, 9093, 1628, 4008, 7973, 9290, 3638, 12397, 12192, 4199, 550, 5249, 12032, 4221, 4833, 7654, 10677, 8213, 632, 6620, 1763, 11929, 2710, 10543, 7870, 12694, 6024, 6521, 7112, 9013, 1799, 108, 11891, 5678, 12359, 7795, 2207, 10480, 10358, 639, 10248, 559, 11214, 4463, 7280, 6947, 12532, 7096, 2383, 10405, 5020, 197, 11747, 4595, 10189, 5880, 1336, 11202, 1853, 544, 5821, 1557, 6779, 1341, 4799, 11107, 2733, 7547, 1481, 11745, 199, 11054, 12010, 10129, 5468, 3157, 1049, 5189, 12666, 543, 1875, 11203, 9120, 9895, 6557, 9830, 12349, 945, 9715, 8589, 1195, 10449, 4264, 6278, 6399, 5835, 2196, 6839, 6510, 1617, 230, 8680, 10748, 8335, 6434, 8532, 7555, 4717, 11327, 12449, 4962, 3366, 2355, 12078, 5868, 10594, 8, 1591, 849, 9825, 878, 4592, 9462, 2798, 5577, 3378, 2866, 1142, 11368, 692, 12072, 121, 11139, 107, 1903, 9014, 5501, 9364, 8285, 8084, 8351, 1229, 10491, 6759, 6777, 1559, 11027, 5891, 11923, 4878, 3033, 1293, 1408, 11785, 10619, 4780, 5792, 2164, 9525, 1306, 2017, 9053, 985, 2351, 7659, 5951, 11555, 1528, 210, 11928, 1913, 6621, 11970, 5118, 2250, 11455, 2296, 6209, 907, 1698, 11270, 698, 11094, 1651, 8503, 2759, 6241, 9523, 2166, 11547, 10240, 10998, 4509, 11325, 4719, 7459, 2879, 11483, 11299, 8804, 2181, 10261, 4829, 3148, 6306, 4911, 12029, 12176, 7412, 6494, 8277, 10557, 12544, 3011, 12677, 2474, 10973, 8207, 8909, 11816, 8860, 8033, 10387, 1035, 3343, 9802, 6745, 11946, 665, 3099, 7702, 2572, 12542, 10559, 11269, 1754, 908, 16, 7153, 10664, 10227, 7504, 3514, 5729, 11155, 10928, 6825, 7410, 12178, 4707, 9925, 9099, 4670, 9549, 448, 7976, 4135, 9124, 4869, 5647, 6578, 3417, 8961, 5691, 2600, 6735, 9944, 4483, 192, 5895, 1462, 12515, 10853, 706, 10176, 2272, 500, 7045, 10093, 9430, 10136, 8502, 1750, 11095, 12660, 9117, 11764, 712, 9876, 8319, 9408, 4014, 1063, 7393, 1204, 10656, 3086, 6548, 5844, 6774, 10416, 8957, 7621, 4863, 4007, 1931, 9094, 3146, 4831, 4223, 291, 12016, 10964, 11065, 56, 229, 1834, 6511, 12139, 600, 7990, 10244, 4873, 5358, 7915, 10847, 9983, 6908, 7586, 3895, 5802, 8164, 9353, 4024, 359, 8678, 232, 8386, 10106, 5332, 7739, 848, 1816, 9, 2827, 10471, 4578, 12329, 3412, 3374, 11822, 6651, 10276, 315, 3715, 4064, 12593, 10914, 12609, 9659, 5476, 12188, 5402, 4344, 11360, 10272, 7835, 9684, 2025, 11315, 6504, 11810, 6985, 11026, 1788, 6778, 1872, 5822, 2987, 4356, 7021, 5378, 6784, 3407, 9700, 8753, 8808, 2486, 5213, 380, 8600, 12681, 2783, 11541, 2985, 5824, 5505, 6519, 6026, 1983, 10266, 9816, 2635, 3992, 209, 1766, 11556, 2727, 8151, 2981, 8429, 8142, 8507, 1474, 6324, 8021, 3565, 9584, 8843, 11378, 10839, 10863, 3596, 953, 12048, 9618, 651, 3439, 8327, 8544, 11419, 12155, 10824, 8253, 2861, 553, 2117, 2314, 4996, 3109, 3077, 2576, 3047, 8889, 11834, 8217, 10156, 6182, 6486, 10408, 10029, 11744, 1865, 7548, 8095, 7300, 1181, 6267, 6323, 1520, 8508, 11288, 5337, 3930, 2192, 4230, 6635, 7785, 3900, 253, 12514, 1663, 5896, 7939, 9357, 6135, 9300, 7489, 9033, 4227, 8345, 1140, 2868, 9652, 8649, 124, 2155, 11016, 10962, 12018, 9020, 4818, 7567, 3473, 3776, 9998, 2170, 4847, 6588, 2281, 6757, 10493, 2997, 2492, 1007, 4206, 11243, 7379, 4938, 3923, 7180, 5521, 5883, 9426, 4152, 10489, 1231, 10980, 3912, 3177, 5088, 4542, 7187, 12317, 11784, 1781, 1294, 562, 7761, 5175, 8298, 10636, 10689, 11151, 6212, 4269, 5547, 3300, 7233, 3396, 5636, 3081, 8205, 10975, 7997, 10890, 267, 9382, 6036, 240, 7259, 2284, 5685, 3495, 5029, 11403, 6145, 7185, 4544, 251, 3902, 103, 11851, 10606, 6627, 12621, 3733, 11615, 11754, 3051, 4248, 412, 12499, 5408, 9840, 179, 3198, 8370, 11146, 2444, 1214, 11406, 10614, 8869, 6084, 11572, 10910, 12024, 2659, 4611, 1943, 4798, 1870, 6780, 3184, 3871, 11201, 1877, 5881, 5523, 11960, 11415, 7906, 2689, 853, 777, 5974, 2179, 8806, 8755, 2684, 973, 11722, 9649, 1226, 3061, 4068, 9543, 6551, 2257, 7685, 11337, 6571, 11500, 11363, 2102, 2016, 1774, 9526, 6177, 8076, 3939, 754, 11383, 4810, 7421, 4170, 11212, 561, 1407, 1782, 3034, 4012, 9410, 6091, 6155, 12368, 2692, 11813, 3152, 6298, 4457, 11691, 9742, 5124, 1116, 7304, 8247, 5180, 5983, 5448, 4242, 9781, 9398, 2698, 4436, 2160, 5046, 3310, 3524, 958, 8641, 10464, 10957, 10420, 5513, 3574, 781, 295, 5906, 2570, 7704, 10446, 12429, 8731, 10726, 2011, 5995, 4099, 10423, 4904, 3945, 11658, 5039, 4735, 9230, 12642, 9492, 4091, 8930, 9835, 10979, 1417, 10490, 1792, 8352, 3060, 1319, 9650, 2870, 2425, 9580, 9765, 9554, 6441, 6697, 4277, 6143, 11405, 1353, 2445, 5082, 2386, 10653, 7673, 6921, 10553, 7671, 10655, 1639, 7394, 12280, 3995, 7773, 7164, 309, 12427, 10448, 1843, 8590, 10165, 3769, 8836, 6288, 4549, 3364, 4964, 988, 2331, 10468, 8315, 6266, 1477, 7301, 8926, 3641, 6671, 3539, 9931, 11175, 9731, 5071, 9313, 88, 10548, 10971, 2476, 2369, 9361, 10648, 4607, 220, 6763, 10948, 11188, 9989, 4235, 7948, 2678, 9748, 3102, 9047, 11907, 9450, 12415, 10198, 4516, 2910, 3746, 6630, 11367, 1806, 2867, 1452, 8346, 4753, 997, 7640, 10214, 10324, 4190, 11826, 6380, 11633, 2627, 6961, 8593, 10194, 10237, 10348, 7060, 3562, 648, 8340, 5607, 8924, 7303, 1278, 5125, 4410, 10256, 11913, 6724, 8633, 8549, 5812, 7415, 4626, 7106, 3793, 7788, 7160, 8981, 11349, 962, 11671, 8457, 7861, 12377, 2083, 8162, 5804, 3465, 2651, 9267, 3112, 7294, 9691, 7284, 10378, 6334, 11585, 10089, 8873, 343, 2893, 5495, 12442, 9009, 11778, 11872, 5580, 4005, 4865, 2346, 5589, 12392, 3606, 6704, 7392, 1641, 4015, 9080, 2546, 2993, 8769, 11474, 7677, 9976, 6110, 5572, 4029, 10014, 5188, 1857, 3158, 159, 5439, 11752, 11617, 4259, 2187, 10477, 9912, 3810, 3262, 4480, 3342, 1710, 10388, 8193, 7942, 10085, 9440, 6543, 11897, 4598, 9328, 8257, 11434, 2974, 4110, 3952, 10119, 9005, 26, 12226, 7729, 5856, 4155, 3129, 3874, 8019, 6326, 3545, 4205, 1429, 2493, 976, 12207, 6459, 4281, 9879, 7471, 829, 7639, 1137, 4754, 10220, 11741, 11394, 3067, 2916, 4680, 2330, 1186, 4965, 2350, 1771, 9054, 8636, 6675, 8005, 11805, 12701, 7418, 12206, 1005, 2494, 11721, 1322, 2685, 11233, 10851, 12517, 10834, 8121, 3255, 3232, 7275, 11670, 1099, 11350, 9665, 8640, 1263, 3525, 5419, 3026, 12047, 1510, 3597, 11068, 12004, 4413, 8002, 7782, 9714, 1846, 12350, 4765, 10039, 10780, 7664, 2671, 3705, 11641, 844, 9597, 5465, 2961, 397, 11306, 10935, 2097, 12618, 3749, 5526, 400, 11984, 6716, 2389, 8527, 84, 4391, 306, 459, 8782, 154, 2396, 9940, 9923, 4709, 11735, 15, 1697, 1755, 6210, 11153, 5731, 10022, 11430, 9564, 3805, 11001, 3856, 3988, 8268, 840, 9340, 11132, 6065, 2815, 8524, 11583, 6336, 4033, 1969, 2604, 10396, 419, 3825, 11226, 4499, 4591, 1813, 9826, 9474, 4292, 12481, 4331, 7766, 9017, 9437, 5757, 9884, 4361, 9657, 12611, 11344, 2110, 3840, 12374, 12640, 9232, 5104, 5006, 8060, 6685, 776, 1329, 2690, 12370, 9824, 1815, 1592, 7740, 7027, 9596, 936, 11642, 7136, 9339, 895, 8269, 9737, 442, 5208, 5199, 7174, 383, 2923, 8992, 7638, 999, 7472, 7558, 3499, 12606, 10814, 7038, 6102, 2125, 2407, 6171, 11687, 8118, 2528, 8013, 5474, 9661, 581, 9214, 111, 3667, 11564, 3266, 9745, 3116, 7252, 2458, 11603, 5992, 717, 463, 7498, 2764, 3631, 5653, 9155, 6823, 10930, 7838, 7429, 12472, 12504, 10951, 10803, 10006, 2956, 4049, 294, 1256, 3575, 3743, 5973, 1328, 854, 6686, 4902, 10425, 4486, 5565, 5969, 11009, 12051, 7818, 5269, 417, 10398, 3588, 4144, 4300, 12647, 7129, 4972, 8964, 7191, 11382, 1301, 3940, 10124, 8934, 5721, 4233, 9991, 6153, 6093, 10954, 7598, 258, 7344, 3729, 3476, 2361, 12645, 4302, 10673, 4383, 556, 7799, 12314, 11791, 6000, 5886, 5352, 3976, 5735, 4584, 4309, 9210, 5326, 2420, 7551, 4339, 462, 800, 5993, 2013, 9772, 9875, 1646, 11765, 8303, 2461, 7823, 10175, 1660, 10854, 2587, 2808, 3882, 8664, 12423, 11093, 1752, 11271, 3696, 3280, 533, 12071, 1804, 11369, 10057, 12289, 9087, 7803, 10988, 540, 7465, 10794, 8495, 12284, 6966, 6395, 9578, 2427, 8514, 12167, 9106, 5317, 3885, 3739, 6367, 9688, 11761, 11206, 3098, 1705, 11947, 4898, 5367, 10730, 2451, 8135, 388, 2656, 428, 10012, 4031, 6338, 3438, 1507, 9619, 8339, 1121, 3563, 8023, 12181, 12022, 10912, 12595, 10668, 10247, 1894, 10359, 10895, 6848, 5395, 4319, 6619, 1915, 8214, 8126, 7147, 589, 5139, 8178, 4748, 4021, 8197, 9807, 10602, 9469, 12570, 8181, 6956, 2833, 3583, 6119, 6586, 4849, 6816, 168, 8553, 10096, 4889, 4771, 2632, 8392, 8596, 2074, 7989, 1614, 12140, 3685, 7616, 4958, 9097, 9927, 4661, 3916, 2953, 5138, 628, 7148, 6748, 5912, 8382, 4951, 6008, 9213, 812, 9662, 8469, 5355, 6203, 11100, 12116, 9031, 7491, 10020, 5733, 3978, 1993, 7714, 8379, 46, 5253, 4472, 7760, 1406, 1295, 11213, 1892, 10249, 7798, 734, 4384, 2116, 1498, 2862, 5248, 1923, 4200, 12040, 3610, 6929, 5820, 1874, 1854, 12667, 7464, 685, 10989, 5304, 11030, 8009, 4691, 12070, 694, 3281, 5446, 5985, 10234, 7238, 11143, 7314, 3713, 317, 10790, 8517, 8240, 7619, 8959, 3419, 3672, 7456, 372, 9195, 3800, 5947, 7903, 5296, 11738, 11711, 6257, 3324, 7089, 2857, 1951, 204, 7044, 1657, 2273, 7726, 10074, 5831, 4659, 9929, 3541, 4558, 3296, 12688, 11698, 4987, 2643, 9752, 12320, 3528, 6463, 10626, 9986, 4566, 7049, 6051, 3019, 9422, 8825, 2850, 3691, 9529, 8846, 5341, 10568, 6480, 5921, 9898, 4193, 7497, 799, 718, 4340, 8781, 917, 307, 7166, 9417, 29, 3509, 9592, 7330, 6414, 9288, 7975, 1679, 9550, 5629, 10452, 8065, 5207, 837, 9738, 9181, 6938, 8583, 8661, 5320, 11513, 8721, 12508, 4219, 12034, 5750, 10011, 656, 2657, 12026, 3629, 2766, 6478, 10570, 5964, 3824, 883, 10397, 765, 5270, 1997, 2402, 12498, 1362, 4249, 12341, 3522, 3312, 6608, 5714, 7333, 6531, 6231, 4915, 11983, 925, 5527, 11305, 932, 2962, 12230, 9188, 7298, 8097, 2511, 7485, 2655, 658, 8136, 11129, 9304, 2922, 833, 7175, 8599, 1544, 5214, 10050, 7879, 5154, 8465, 12305, 9194, 515, 7457, 4721, 8603, 8765, 2884, 10868, 11771, 7951, 9167, 5706, 4839, 8677, 1599, 4025, 7036, 10816, 4921, 7636, 8994, 5615, 4614, 9472, 9828, 6559, 11428, 10024, 11864, 2892, 1079, 8874, 11854, 76, 4853, 11620, 10633, 7477, 6662, 9698, 3409, 9795, 8746, 3556, 5311, 7310, 12675, 3013, 3964, 7125, 11648, 9110, 8622, 3787, 9076, 10789, 524, 3714, 1580, 10277, 9495, 3680, 8490, 12426, 1198, 7165, 458, 918, 4392, 9777, 5263, 4478, 3264, 11566, 2518, 5480, 9321, 5905, 1255, 782, 4050, 12015, 1623, 4224, 12405, 11518, 2268, 11465, 3985, 4044, 10505, 2806, 2589, 3783, 2882, 8767, 2995, 10495, 8399, 7219, 11639, 3707, 2214, 9264, 9346, 9381, 1387, 10891, 7754, 9572, 7425, 8866, 3766, 5204, 7343, 743, 7599, 3092, 10762, 12513, 1464, 3901, 1374, 4545, 7434, 9317, 7081, 6591, 10682, 5285, 11926, 212, 7258, 1384, 6037, 4936, 7381, 4978, 8422, 11841, 8385, 1597, 8679, 1833, 1618, 57, 6470, 114, 3236, 6386, 8190, 10413, 6762, 1162, 4608, 10312, 12302, 11354, 7308, 5313, 7257, 242, 11927, 1765, 1529, 3993, 12282, 8497, 7043, 502, 1952, 12461, 11252, 11053, 1863, 11746, 1882, 5021, 5309, 3558, 5894, 1665, 4484, 10427, 3044, 4216, 5674, 2200, 4492, 5767, 10828, 5620, 9677, 3197, 1358, 9841, 5274, 9227, 6942, 10142, 11014, 2157, 10994, 9705, 8552, 610, 6817, 4778, 10621, 12636, 7927, 10582, 4530, 5438, 1047, 3159, 6276, 4266, 2395, 915, 8783, 10525, 6527, 5035, 5928, 2509, 8099, 3245, 12096, 4535, 7969, 8296, 5177, 5763, 5989, 4084, 10564, 4427, 5978, 2773, 2794, 2136, 7531, 1972, 2484, 8810, 2927, 2747, 2154, 1448, 8650, 11138, 1802, 12073, 2048, 4130, 4056, 4644, 3235, 226, 6471, 3666, 810, 9215, 11890, 1902, 1800, 11140, 3057, 11850, 1372, 3903, 9790, 3725, 3763, 10617, 11787, 8967, 6087, 11347, 8983, 8942, 6640, 2715, 10547, 1170, 9314, 9274, 4390, 920, 8528, 3140, 9059, 2093, 12551, 4789, 4852, 340, 11855, 3484, 11478, 3224, 10353, 11977, 8414, 11955, 5587, 2348, 4967, 5853, 4307, 4586, 3603, 4095, 8111, 6469, 228, 1619, 11066, 3599, 6113, 2743, 6866, 7525, 10860, 12173, 5252, 566, 8380, 5914, 8779, 4342, 5404, 12388, 9703, 10996, 10242, 7992, 4114, 11173, 9933, 8613, 7205, 3508, 455, 9418, 12225, 1018, 9006, 10503, 4046, 4844, 10807, 6692, 7770, 8227, 7152, 1696, 909, 11736, 5298, 8091, 8900, 2826, 1590, 1817, 10595, 5086, 3179, 8476, 6357, 12713]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-product-permutation-l6-s8/tests/check.py b/tasks/construct-rlve-prefix-product-permutation-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3d93850acd79cc0f8fff05cdbb0c63aabc484815 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l6-s8/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(), 1 + for v in p: + acc = acc * v % n + if acc in seen: + raise Invalid(f"prefix product residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-product-permutation-l6-s8/tests/instance.json b/tasks/construct-rlve-prefix-product-permutation-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d9352455711232780c22267dbeeba4dbcee94118 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 12713, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l6-s8/tests/run.py b/tasks/construct-rlve-prefix-product-permutation-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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-prefix-product-permutation-l6-s8/tests/test.sh b/tasks/construct-rlve-prefix-product-permutation-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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-prefix-sum-permutation-l2-s1/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-rlve-prefix-sum-permutation-l2-s1/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6d8b8507b2c038474c3a0fd0f35614856b9bdb17 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 94, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s1/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f9be310eff7ace9be481bb2dd7c1786d33b3c257 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [94, 1, 92, 3, 90, 5, 88, 7, 86, 9, 84, 11, 82, 13, 80, 15, 78, 17, 76, 19, 74, 21, 72, 23, 70, 25, 68, 27, 66, 29, 64, 31, 62, 33, 60, 35, 58, 37, 56, 39, 54, 41, 52, 43, 50, 45, 48, 47, 46, 49, 44, 51, 42, 53, 40, 55, 38, 57, 36, 59, 34, 61, 32, 63, 30, 65, 28, 67, 26, 69, 24, 71, 22, 73, 20, 75, 18, 77, 16, 79, 14, 81, 12, 83, 10, 85, 8, 87, 6, 89, 4, 91, 2, 93]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s1/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-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-l2-s1/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6d8b8507b2c038474c3a0fd0f35614856b9bdb17 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 94, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s1/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-rlve-prefix-sum-permutation-l2-s1/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-rlve-prefix-sum-permutation-l2-s8/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-rlve-prefix-sum-permutation-l2-s8/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..12babb100381cf5047a33d5b92f679ed1fe5303e --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 38, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s8/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ed19d23ed2b36d10268747a124b41e2c3212266 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [38, 1, 36, 3, 34, 5, 32, 7, 30, 9, 28, 11, 26, 13, 24, 15, 22, 17, 20, 19, 18, 21, 16, 23, 14, 25, 12, 27, 10, 29, 8, 31, 6, 33, 4, 35, 2, 37]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s8/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s8/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-s8/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..12babb100381cf5047a33d5b92f679ed1fe5303e --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 38, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s8/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-rlve-prefix-sum-permutation-l2-s8/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-rlve-prefix-sum-permutation-l6-s0/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l6-s0/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ea6d338aed5729025ba71c7f0b484249b47f9004 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 10770, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s0/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d2f34a14366ff623c8e7e06c49799c3ab798b631 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [10770, 1, 10768, 3, 10766, 5, 10764, 7, 10762, 9, 10760, 11, 10758, 13, 10756, 15, 10754, 17, 10752, 19, 10750, 21, 10748, 23, 10746, 25, 10744, 27, 10742, 29, 10740, 31, 10738, 33, 10736, 35, 10734, 37, 10732, 39, 10730, 41, 10728, 43, 10726, 45, 10724, 47, 10722, 49, 10720, 51, 10718, 53, 10716, 55, 10714, 57, 10712, 59, 10710, 61, 10708, 63, 10706, 65, 10704, 67, 10702, 69, 10700, 71, 10698, 73, 10696, 75, 10694, 77, 10692, 79, 10690, 81, 10688, 83, 10686, 85, 10684, 87, 10682, 89, 10680, 91, 10678, 93, 10676, 95, 10674, 97, 10672, 99, 10670, 101, 10668, 103, 10666, 105, 10664, 107, 10662, 109, 10660, 111, 10658, 113, 10656, 115, 10654, 117, 10652, 119, 10650, 121, 10648, 123, 10646, 125, 10644, 127, 10642, 129, 10640, 131, 10638, 133, 10636, 135, 10634, 137, 10632, 139, 10630, 141, 10628, 143, 10626, 145, 10624, 147, 10622, 149, 10620, 151, 10618, 153, 10616, 155, 10614, 157, 10612, 159, 10610, 161, 10608, 163, 10606, 165, 10604, 167, 10602, 169, 10600, 171, 10598, 173, 10596, 175, 10594, 177, 10592, 179, 10590, 181, 10588, 183, 10586, 185, 10584, 187, 10582, 189, 10580, 191, 10578, 193, 10576, 195, 10574, 197, 10572, 199, 10570, 201, 10568, 203, 10566, 205, 10564, 207, 10562, 209, 10560, 211, 10558, 213, 10556, 215, 10554, 217, 10552, 219, 10550, 221, 10548, 223, 10546, 225, 10544, 227, 10542, 229, 10540, 231, 10538, 233, 10536, 235, 10534, 237, 10532, 239, 10530, 241, 10528, 243, 10526, 245, 10524, 247, 10522, 249, 10520, 251, 10518, 253, 10516, 255, 10514, 257, 10512, 259, 10510, 261, 10508, 263, 10506, 265, 10504, 267, 10502, 269, 10500, 271, 10498, 273, 10496, 275, 10494, 277, 10492, 279, 10490, 281, 10488, 283, 10486, 285, 10484, 287, 10482, 289, 10480, 291, 10478, 293, 10476, 295, 10474, 297, 10472, 299, 10470, 301, 10468, 303, 10466, 305, 10464, 307, 10462, 309, 10460, 311, 10458, 313, 10456, 315, 10454, 317, 10452, 319, 10450, 321, 10448, 323, 10446, 325, 10444, 327, 10442, 329, 10440, 331, 10438, 333, 10436, 335, 10434, 337, 10432, 339, 10430, 341, 10428, 343, 10426, 345, 10424, 347, 10422, 349, 10420, 351, 10418, 353, 10416, 355, 10414, 357, 10412, 359, 10410, 361, 10408, 363, 10406, 365, 10404, 367, 10402, 369, 10400, 371, 10398, 373, 10396, 375, 10394, 377, 10392, 379, 10390, 381, 10388, 383, 10386, 385, 10384, 387, 10382, 389, 10380, 391, 10378, 393, 10376, 395, 10374, 397, 10372, 399, 10370, 401, 10368, 403, 10366, 405, 10364, 407, 10362, 409, 10360, 411, 10358, 413, 10356, 415, 10354, 417, 10352, 419, 10350, 421, 10348, 423, 10346, 425, 10344, 427, 10342, 429, 10340, 431, 10338, 433, 10336, 435, 10334, 437, 10332, 439, 10330, 441, 10328, 443, 10326, 445, 10324, 447, 10322, 449, 10320, 451, 10318, 453, 10316, 455, 10314, 457, 10312, 459, 10310, 461, 10308, 463, 10306, 465, 10304, 467, 10302, 469, 10300, 471, 10298, 473, 10296, 475, 10294, 477, 10292, 479, 10290, 481, 10288, 483, 10286, 485, 10284, 487, 10282, 489, 10280, 491, 10278, 493, 10276, 495, 10274, 497, 10272, 499, 10270, 501, 10268, 503, 10266, 505, 10264, 507, 10262, 509, 10260, 511, 10258, 513, 10256, 515, 10254, 517, 10252, 519, 10250, 521, 10248, 523, 10246, 525, 10244, 527, 10242, 529, 10240, 531, 10238, 533, 10236, 535, 10234, 537, 10232, 539, 10230, 541, 10228, 543, 10226, 545, 10224, 547, 10222, 549, 10220, 551, 10218, 553, 10216, 555, 10214, 557, 10212, 559, 10210, 561, 10208, 563, 10206, 565, 10204, 567, 10202, 569, 10200, 571, 10198, 573, 10196, 575, 10194, 577, 10192, 579, 10190, 581, 10188, 583, 10186, 585, 10184, 587, 10182, 589, 10180, 591, 10178, 593, 10176, 595, 10174, 597, 10172, 599, 10170, 601, 10168, 603, 10166, 605, 10164, 607, 10162, 609, 10160, 611, 10158, 613, 10156, 615, 10154, 617, 10152, 619, 10150, 621, 10148, 623, 10146, 625, 10144, 627, 10142, 629, 10140, 631, 10138, 633, 10136, 635, 10134, 637, 10132, 639, 10130, 641, 10128, 643, 10126, 645, 10124, 647, 10122, 649, 10120, 651, 10118, 653, 10116, 655, 10114, 657, 10112, 659, 10110, 661, 10108, 663, 10106, 665, 10104, 667, 10102, 669, 10100, 671, 10098, 673, 10096, 675, 10094, 677, 10092, 679, 10090, 681, 10088, 683, 10086, 685, 10084, 687, 10082, 689, 10080, 691, 10078, 693, 10076, 695, 10074, 697, 10072, 699, 10070, 701, 10068, 703, 10066, 705, 10064, 707, 10062, 709, 10060, 711, 10058, 713, 10056, 715, 10054, 717, 10052, 719, 10050, 721, 10048, 723, 10046, 725, 10044, 727, 10042, 729, 10040, 731, 10038, 733, 10036, 735, 10034, 737, 10032, 739, 10030, 741, 10028, 743, 10026, 745, 10024, 747, 10022, 749, 10020, 751, 10018, 753, 10016, 755, 10014, 757, 10012, 759, 10010, 761, 10008, 763, 10006, 765, 10004, 767, 10002, 769, 10000, 771, 9998, 773, 9996, 775, 9994, 777, 9992, 779, 9990, 781, 9988, 783, 9986, 785, 9984, 787, 9982, 789, 9980, 791, 9978, 793, 9976, 795, 9974, 797, 9972, 799, 9970, 801, 9968, 803, 9966, 805, 9964, 807, 9962, 809, 9960, 811, 9958, 813, 9956, 815, 9954, 817, 9952, 819, 9950, 821, 9948, 823, 9946, 825, 9944, 827, 9942, 829, 9940, 831, 9938, 833, 9936, 835, 9934, 837, 9932, 839, 9930, 841, 9928, 843, 9926, 845, 9924, 847, 9922, 849, 9920, 851, 9918, 853, 9916, 855, 9914, 857, 9912, 859, 9910, 861, 9908, 863, 9906, 865, 9904, 867, 9902, 869, 9900, 871, 9898, 873, 9896, 875, 9894, 877, 9892, 879, 9890, 881, 9888, 883, 9886, 885, 9884, 887, 9882, 889, 9880, 891, 9878, 893, 9876, 895, 9874, 897, 9872, 899, 9870, 901, 9868, 903, 9866, 905, 9864, 907, 9862, 909, 9860, 911, 9858, 913, 9856, 915, 9854, 917, 9852, 919, 9850, 921, 9848, 923, 9846, 925, 9844, 927, 9842, 929, 9840, 931, 9838, 933, 9836, 935, 9834, 937, 9832, 939, 9830, 941, 9828, 943, 9826, 945, 9824, 947, 9822, 949, 9820, 951, 9818, 953, 9816, 955, 9814, 957, 9812, 959, 9810, 961, 9808, 963, 9806, 965, 9804, 967, 9802, 969, 9800, 971, 9798, 973, 9796, 975, 9794, 977, 9792, 979, 9790, 981, 9788, 983, 9786, 985, 9784, 987, 9782, 989, 9780, 991, 9778, 993, 9776, 995, 9774, 997, 9772, 999, 9770, 1001, 9768, 1003, 9766, 1005, 9764, 1007, 9762, 1009, 9760, 1011, 9758, 1013, 9756, 1015, 9754, 1017, 9752, 1019, 9750, 1021, 9748, 1023, 9746, 1025, 9744, 1027, 9742, 1029, 9740, 1031, 9738, 1033, 9736, 1035, 9734, 1037, 9732, 1039, 9730, 1041, 9728, 1043, 9726, 1045, 9724, 1047, 9722, 1049, 9720, 1051, 9718, 1053, 9716, 1055, 9714, 1057, 9712, 1059, 9710, 1061, 9708, 1063, 9706, 1065, 9704, 1067, 9702, 1069, 9700, 1071, 9698, 1073, 9696, 1075, 9694, 1077, 9692, 1079, 9690, 1081, 9688, 1083, 9686, 1085, 9684, 1087, 9682, 1089, 9680, 1091, 9678, 1093, 9676, 1095, 9674, 1097, 9672, 1099, 9670, 1101, 9668, 1103, 9666, 1105, 9664, 1107, 9662, 1109, 9660, 1111, 9658, 1113, 9656, 1115, 9654, 1117, 9652, 1119, 9650, 1121, 9648, 1123, 9646, 1125, 9644, 1127, 9642, 1129, 9640, 1131, 9638, 1133, 9636, 1135, 9634, 1137, 9632, 1139, 9630, 1141, 9628, 1143, 9626, 1145, 9624, 1147, 9622, 1149, 9620, 1151, 9618, 1153, 9616, 1155, 9614, 1157, 9612, 1159, 9610, 1161, 9608, 1163, 9606, 1165, 9604, 1167, 9602, 1169, 9600, 1171, 9598, 1173, 9596, 1175, 9594, 1177, 9592, 1179, 9590, 1181, 9588, 1183, 9586, 1185, 9584, 1187, 9582, 1189, 9580, 1191, 9578, 1193, 9576, 1195, 9574, 1197, 9572, 1199, 9570, 1201, 9568, 1203, 9566, 1205, 9564, 1207, 9562, 1209, 9560, 1211, 9558, 1213, 9556, 1215, 9554, 1217, 9552, 1219, 9550, 1221, 9548, 1223, 9546, 1225, 9544, 1227, 9542, 1229, 9540, 1231, 9538, 1233, 9536, 1235, 9534, 1237, 9532, 1239, 9530, 1241, 9528, 1243, 9526, 1245, 9524, 1247, 9522, 1249, 9520, 1251, 9518, 1253, 9516, 1255, 9514, 1257, 9512, 1259, 9510, 1261, 9508, 1263, 9506, 1265, 9504, 1267, 9502, 1269, 9500, 1271, 9498, 1273, 9496, 1275, 9494, 1277, 9492, 1279, 9490, 1281, 9488, 1283, 9486, 1285, 9484, 1287, 9482, 1289, 9480, 1291, 9478, 1293, 9476, 1295, 9474, 1297, 9472, 1299, 9470, 1301, 9468, 1303, 9466, 1305, 9464, 1307, 9462, 1309, 9460, 1311, 9458, 1313, 9456, 1315, 9454, 1317, 9452, 1319, 9450, 1321, 9448, 1323, 9446, 1325, 9444, 1327, 9442, 1329, 9440, 1331, 9438, 1333, 9436, 1335, 9434, 1337, 9432, 1339, 9430, 1341, 9428, 1343, 9426, 1345, 9424, 1347, 9422, 1349, 9420, 1351, 9418, 1353, 9416, 1355, 9414, 1357, 9412, 1359, 9410, 1361, 9408, 1363, 9406, 1365, 9404, 1367, 9402, 1369, 9400, 1371, 9398, 1373, 9396, 1375, 9394, 1377, 9392, 1379, 9390, 1381, 9388, 1383, 9386, 1385, 9384, 1387, 9382, 1389, 9380, 1391, 9378, 1393, 9376, 1395, 9374, 1397, 9372, 1399, 9370, 1401, 9368, 1403, 9366, 1405, 9364, 1407, 9362, 1409, 9360, 1411, 9358, 1413, 9356, 1415, 9354, 1417, 9352, 1419, 9350, 1421, 9348, 1423, 9346, 1425, 9344, 1427, 9342, 1429, 9340, 1431, 9338, 1433, 9336, 1435, 9334, 1437, 9332, 1439, 9330, 1441, 9328, 1443, 9326, 1445, 9324, 1447, 9322, 1449, 9320, 1451, 9318, 1453, 9316, 1455, 9314, 1457, 9312, 1459, 9310, 1461, 9308, 1463, 9306, 1465, 9304, 1467, 9302, 1469, 9300, 1471, 9298, 1473, 9296, 1475, 9294, 1477, 9292, 1479, 9290, 1481, 9288, 1483, 9286, 1485, 9284, 1487, 9282, 1489, 9280, 1491, 9278, 1493, 9276, 1495, 9274, 1497, 9272, 1499, 9270, 1501, 9268, 1503, 9266, 1505, 9264, 1507, 9262, 1509, 9260, 1511, 9258, 1513, 9256, 1515, 9254, 1517, 9252, 1519, 9250, 1521, 9248, 1523, 9246, 1525, 9244, 1527, 9242, 1529, 9240, 1531, 9238, 1533, 9236, 1535, 9234, 1537, 9232, 1539, 9230, 1541, 9228, 1543, 9226, 1545, 9224, 1547, 9222, 1549, 9220, 1551, 9218, 1553, 9216, 1555, 9214, 1557, 9212, 1559, 9210, 1561, 9208, 1563, 9206, 1565, 9204, 1567, 9202, 1569, 9200, 1571, 9198, 1573, 9196, 1575, 9194, 1577, 9192, 1579, 9190, 1581, 9188, 1583, 9186, 1585, 9184, 1587, 9182, 1589, 9180, 1591, 9178, 1593, 9176, 1595, 9174, 1597, 9172, 1599, 9170, 1601, 9168, 1603, 9166, 1605, 9164, 1607, 9162, 1609, 9160, 1611, 9158, 1613, 9156, 1615, 9154, 1617, 9152, 1619, 9150, 1621, 9148, 1623, 9146, 1625, 9144, 1627, 9142, 1629, 9140, 1631, 9138, 1633, 9136, 1635, 9134, 1637, 9132, 1639, 9130, 1641, 9128, 1643, 9126, 1645, 9124, 1647, 9122, 1649, 9120, 1651, 9118, 1653, 9116, 1655, 9114, 1657, 9112, 1659, 9110, 1661, 9108, 1663, 9106, 1665, 9104, 1667, 9102, 1669, 9100, 1671, 9098, 1673, 9096, 1675, 9094, 1677, 9092, 1679, 9090, 1681, 9088, 1683, 9086, 1685, 9084, 1687, 9082, 1689, 9080, 1691, 9078, 1693, 9076, 1695, 9074, 1697, 9072, 1699, 9070, 1701, 9068, 1703, 9066, 1705, 9064, 1707, 9062, 1709, 9060, 1711, 9058, 1713, 9056, 1715, 9054, 1717, 9052, 1719, 9050, 1721, 9048, 1723, 9046, 1725, 9044, 1727, 9042, 1729, 9040, 1731, 9038, 1733, 9036, 1735, 9034, 1737, 9032, 1739, 9030, 1741, 9028, 1743, 9026, 1745, 9024, 1747, 9022, 1749, 9020, 1751, 9018, 1753, 9016, 1755, 9014, 1757, 9012, 1759, 9010, 1761, 9008, 1763, 9006, 1765, 9004, 1767, 9002, 1769, 9000, 1771, 8998, 1773, 8996, 1775, 8994, 1777, 8992, 1779, 8990, 1781, 8988, 1783, 8986, 1785, 8984, 1787, 8982, 1789, 8980, 1791, 8978, 1793, 8976, 1795, 8974, 1797, 8972, 1799, 8970, 1801, 8968, 1803, 8966, 1805, 8964, 1807, 8962, 1809, 8960, 1811, 8958, 1813, 8956, 1815, 8954, 1817, 8952, 1819, 8950, 1821, 8948, 1823, 8946, 1825, 8944, 1827, 8942, 1829, 8940, 1831, 8938, 1833, 8936, 1835, 8934, 1837, 8932, 1839, 8930, 1841, 8928, 1843, 8926, 1845, 8924, 1847, 8922, 1849, 8920, 1851, 8918, 1853, 8916, 1855, 8914, 1857, 8912, 1859, 8910, 1861, 8908, 1863, 8906, 1865, 8904, 1867, 8902, 1869, 8900, 1871, 8898, 1873, 8896, 1875, 8894, 1877, 8892, 1879, 8890, 1881, 8888, 1883, 8886, 1885, 8884, 1887, 8882, 1889, 8880, 1891, 8878, 1893, 8876, 1895, 8874, 1897, 8872, 1899, 8870, 1901, 8868, 1903, 8866, 1905, 8864, 1907, 8862, 1909, 8860, 1911, 8858, 1913, 8856, 1915, 8854, 1917, 8852, 1919, 8850, 1921, 8848, 1923, 8846, 1925, 8844, 1927, 8842, 1929, 8840, 1931, 8838, 1933, 8836, 1935, 8834, 1937, 8832, 1939, 8830, 1941, 8828, 1943, 8826, 1945, 8824, 1947, 8822, 1949, 8820, 1951, 8818, 1953, 8816, 1955, 8814, 1957, 8812, 1959, 8810, 1961, 8808, 1963, 8806, 1965, 8804, 1967, 8802, 1969, 8800, 1971, 8798, 1973, 8796, 1975, 8794, 1977, 8792, 1979, 8790, 1981, 8788, 1983, 8786, 1985, 8784, 1987, 8782, 1989, 8780, 1991, 8778, 1993, 8776, 1995, 8774, 1997, 8772, 1999, 8770, 2001, 8768, 2003, 8766, 2005, 8764, 2007, 8762, 2009, 8760, 2011, 8758, 2013, 8756, 2015, 8754, 2017, 8752, 2019, 8750, 2021, 8748, 2023, 8746, 2025, 8744, 2027, 8742, 2029, 8740, 2031, 8738, 2033, 8736, 2035, 8734, 2037, 8732, 2039, 8730, 2041, 8728, 2043, 8726, 2045, 8724, 2047, 8722, 2049, 8720, 2051, 8718, 2053, 8716, 2055, 8714, 2057, 8712, 2059, 8710, 2061, 8708, 2063, 8706, 2065, 8704, 2067, 8702, 2069, 8700, 2071, 8698, 2073, 8696, 2075, 8694, 2077, 8692, 2079, 8690, 2081, 8688, 2083, 8686, 2085, 8684, 2087, 8682, 2089, 8680, 2091, 8678, 2093, 8676, 2095, 8674, 2097, 8672, 2099, 8670, 2101, 8668, 2103, 8666, 2105, 8664, 2107, 8662, 2109, 8660, 2111, 8658, 2113, 8656, 2115, 8654, 2117, 8652, 2119, 8650, 2121, 8648, 2123, 8646, 2125, 8644, 2127, 8642, 2129, 8640, 2131, 8638, 2133, 8636, 2135, 8634, 2137, 8632, 2139, 8630, 2141, 8628, 2143, 8626, 2145, 8624, 2147, 8622, 2149, 8620, 2151, 8618, 2153, 8616, 2155, 8614, 2157, 8612, 2159, 8610, 2161, 8608, 2163, 8606, 2165, 8604, 2167, 8602, 2169, 8600, 2171, 8598, 2173, 8596, 2175, 8594, 2177, 8592, 2179, 8590, 2181, 8588, 2183, 8586, 2185, 8584, 2187, 8582, 2189, 8580, 2191, 8578, 2193, 8576, 2195, 8574, 2197, 8572, 2199, 8570, 2201, 8568, 2203, 8566, 2205, 8564, 2207, 8562, 2209, 8560, 2211, 8558, 2213, 8556, 2215, 8554, 2217, 8552, 2219, 8550, 2221, 8548, 2223, 8546, 2225, 8544, 2227, 8542, 2229, 8540, 2231, 8538, 2233, 8536, 2235, 8534, 2237, 8532, 2239, 8530, 2241, 8528, 2243, 8526, 2245, 8524, 2247, 8522, 2249, 8520, 2251, 8518, 2253, 8516, 2255, 8514, 2257, 8512, 2259, 8510, 2261, 8508, 2263, 8506, 2265, 8504, 2267, 8502, 2269, 8500, 2271, 8498, 2273, 8496, 2275, 8494, 2277, 8492, 2279, 8490, 2281, 8488, 2283, 8486, 2285, 8484, 2287, 8482, 2289, 8480, 2291, 8478, 2293, 8476, 2295, 8474, 2297, 8472, 2299, 8470, 2301, 8468, 2303, 8466, 2305, 8464, 2307, 8462, 2309, 8460, 2311, 8458, 2313, 8456, 2315, 8454, 2317, 8452, 2319, 8450, 2321, 8448, 2323, 8446, 2325, 8444, 2327, 8442, 2329, 8440, 2331, 8438, 2333, 8436, 2335, 8434, 2337, 8432, 2339, 8430, 2341, 8428, 2343, 8426, 2345, 8424, 2347, 8422, 2349, 8420, 2351, 8418, 2353, 8416, 2355, 8414, 2357, 8412, 2359, 8410, 2361, 8408, 2363, 8406, 2365, 8404, 2367, 8402, 2369, 8400, 2371, 8398, 2373, 8396, 2375, 8394, 2377, 8392, 2379, 8390, 2381, 8388, 2383, 8386, 2385, 8384, 2387, 8382, 2389, 8380, 2391, 8378, 2393, 8376, 2395, 8374, 2397, 8372, 2399, 8370, 2401, 8368, 2403, 8366, 2405, 8364, 2407, 8362, 2409, 8360, 2411, 8358, 2413, 8356, 2415, 8354, 2417, 8352, 2419, 8350, 2421, 8348, 2423, 8346, 2425, 8344, 2427, 8342, 2429, 8340, 2431, 8338, 2433, 8336, 2435, 8334, 2437, 8332, 2439, 8330, 2441, 8328, 2443, 8326, 2445, 8324, 2447, 8322, 2449, 8320, 2451, 8318, 2453, 8316, 2455, 8314, 2457, 8312, 2459, 8310, 2461, 8308, 2463, 8306, 2465, 8304, 2467, 8302, 2469, 8300, 2471, 8298, 2473, 8296, 2475, 8294, 2477, 8292, 2479, 8290, 2481, 8288, 2483, 8286, 2485, 8284, 2487, 8282, 2489, 8280, 2491, 8278, 2493, 8276, 2495, 8274, 2497, 8272, 2499, 8270, 2501, 8268, 2503, 8266, 2505, 8264, 2507, 8262, 2509, 8260, 2511, 8258, 2513, 8256, 2515, 8254, 2517, 8252, 2519, 8250, 2521, 8248, 2523, 8246, 2525, 8244, 2527, 8242, 2529, 8240, 2531, 8238, 2533, 8236, 2535, 8234, 2537, 8232, 2539, 8230, 2541, 8228, 2543, 8226, 2545, 8224, 2547, 8222, 2549, 8220, 2551, 8218, 2553, 8216, 2555, 8214, 2557, 8212, 2559, 8210, 2561, 8208, 2563, 8206, 2565, 8204, 2567, 8202, 2569, 8200, 2571, 8198, 2573, 8196, 2575, 8194, 2577, 8192, 2579, 8190, 2581, 8188, 2583, 8186, 2585, 8184, 2587, 8182, 2589, 8180, 2591, 8178, 2593, 8176, 2595, 8174, 2597, 8172, 2599, 8170, 2601, 8168, 2603, 8166, 2605, 8164, 2607, 8162, 2609, 8160, 2611, 8158, 2613, 8156, 2615, 8154, 2617, 8152, 2619, 8150, 2621, 8148, 2623, 8146, 2625, 8144, 2627, 8142, 2629, 8140, 2631, 8138, 2633, 8136, 2635, 8134, 2637, 8132, 2639, 8130, 2641, 8128, 2643, 8126, 2645, 8124, 2647, 8122, 2649, 8120, 2651, 8118, 2653, 8116, 2655, 8114, 2657, 8112, 2659, 8110, 2661, 8108, 2663, 8106, 2665, 8104, 2667, 8102, 2669, 8100, 2671, 8098, 2673, 8096, 2675, 8094, 2677, 8092, 2679, 8090, 2681, 8088, 2683, 8086, 2685, 8084, 2687, 8082, 2689, 8080, 2691, 8078, 2693, 8076, 2695, 8074, 2697, 8072, 2699, 8070, 2701, 8068, 2703, 8066, 2705, 8064, 2707, 8062, 2709, 8060, 2711, 8058, 2713, 8056, 2715, 8054, 2717, 8052, 2719, 8050, 2721, 8048, 2723, 8046, 2725, 8044, 2727, 8042, 2729, 8040, 2731, 8038, 2733, 8036, 2735, 8034, 2737, 8032, 2739, 8030, 2741, 8028, 2743, 8026, 2745, 8024, 2747, 8022, 2749, 8020, 2751, 8018, 2753, 8016, 2755, 8014, 2757, 8012, 2759, 8010, 2761, 8008, 2763, 8006, 2765, 8004, 2767, 8002, 2769, 8000, 2771, 7998, 2773, 7996, 2775, 7994, 2777, 7992, 2779, 7990, 2781, 7988, 2783, 7986, 2785, 7984, 2787, 7982, 2789, 7980, 2791, 7978, 2793, 7976, 2795, 7974, 2797, 7972, 2799, 7970, 2801, 7968, 2803, 7966, 2805, 7964, 2807, 7962, 2809, 7960, 2811, 7958, 2813, 7956, 2815, 7954, 2817, 7952, 2819, 7950, 2821, 7948, 2823, 7946, 2825, 7944, 2827, 7942, 2829, 7940, 2831, 7938, 2833, 7936, 2835, 7934, 2837, 7932, 2839, 7930, 2841, 7928, 2843, 7926, 2845, 7924, 2847, 7922, 2849, 7920, 2851, 7918, 2853, 7916, 2855, 7914, 2857, 7912, 2859, 7910, 2861, 7908, 2863, 7906, 2865, 7904, 2867, 7902, 2869, 7900, 2871, 7898, 2873, 7896, 2875, 7894, 2877, 7892, 2879, 7890, 2881, 7888, 2883, 7886, 2885, 7884, 2887, 7882, 2889, 7880, 2891, 7878, 2893, 7876, 2895, 7874, 2897, 7872, 2899, 7870, 2901, 7868, 2903, 7866, 2905, 7864, 2907, 7862, 2909, 7860, 2911, 7858, 2913, 7856, 2915, 7854, 2917, 7852, 2919, 7850, 2921, 7848, 2923, 7846, 2925, 7844, 2927, 7842, 2929, 7840, 2931, 7838, 2933, 7836, 2935, 7834, 2937, 7832, 2939, 7830, 2941, 7828, 2943, 7826, 2945, 7824, 2947, 7822, 2949, 7820, 2951, 7818, 2953, 7816, 2955, 7814, 2957, 7812, 2959, 7810, 2961, 7808, 2963, 7806, 2965, 7804, 2967, 7802, 2969, 7800, 2971, 7798, 2973, 7796, 2975, 7794, 2977, 7792, 2979, 7790, 2981, 7788, 2983, 7786, 2985, 7784, 2987, 7782, 2989, 7780, 2991, 7778, 2993, 7776, 2995, 7774, 2997, 7772, 2999, 7770, 3001, 7768, 3003, 7766, 3005, 7764, 3007, 7762, 3009, 7760, 3011, 7758, 3013, 7756, 3015, 7754, 3017, 7752, 3019, 7750, 3021, 7748, 3023, 7746, 3025, 7744, 3027, 7742, 3029, 7740, 3031, 7738, 3033, 7736, 3035, 7734, 3037, 7732, 3039, 7730, 3041, 7728, 3043, 7726, 3045, 7724, 3047, 7722, 3049, 7720, 3051, 7718, 3053, 7716, 3055, 7714, 3057, 7712, 3059, 7710, 3061, 7708, 3063, 7706, 3065, 7704, 3067, 7702, 3069, 7700, 3071, 7698, 3073, 7696, 3075, 7694, 3077, 7692, 3079, 7690, 3081, 7688, 3083, 7686, 3085, 7684, 3087, 7682, 3089, 7680, 3091, 7678, 3093, 7676, 3095, 7674, 3097, 7672, 3099, 7670, 3101, 7668, 3103, 7666, 3105, 7664, 3107, 7662, 3109, 7660, 3111, 7658, 3113, 7656, 3115, 7654, 3117, 7652, 3119, 7650, 3121, 7648, 3123, 7646, 3125, 7644, 3127, 7642, 3129, 7640, 3131, 7638, 3133, 7636, 3135, 7634, 3137, 7632, 3139, 7630, 3141, 7628, 3143, 7626, 3145, 7624, 3147, 7622, 3149, 7620, 3151, 7618, 3153, 7616, 3155, 7614, 3157, 7612, 3159, 7610, 3161, 7608, 3163, 7606, 3165, 7604, 3167, 7602, 3169, 7600, 3171, 7598, 3173, 7596, 3175, 7594, 3177, 7592, 3179, 7590, 3181, 7588, 3183, 7586, 3185, 7584, 3187, 7582, 3189, 7580, 3191, 7578, 3193, 7576, 3195, 7574, 3197, 7572, 3199, 7570, 3201, 7568, 3203, 7566, 3205, 7564, 3207, 7562, 3209, 7560, 3211, 7558, 3213, 7556, 3215, 7554, 3217, 7552, 3219, 7550, 3221, 7548, 3223, 7546, 3225, 7544, 3227, 7542, 3229, 7540, 3231, 7538, 3233, 7536, 3235, 7534, 3237, 7532, 3239, 7530, 3241, 7528, 3243, 7526, 3245, 7524, 3247, 7522, 3249, 7520, 3251, 7518, 3253, 7516, 3255, 7514, 3257, 7512, 3259, 7510, 3261, 7508, 3263, 7506, 3265, 7504, 3267, 7502, 3269, 7500, 3271, 7498, 3273, 7496, 3275, 7494, 3277, 7492, 3279, 7490, 3281, 7488, 3283, 7486, 3285, 7484, 3287, 7482, 3289, 7480, 3291, 7478, 3293, 7476, 3295, 7474, 3297, 7472, 3299, 7470, 3301, 7468, 3303, 7466, 3305, 7464, 3307, 7462, 3309, 7460, 3311, 7458, 3313, 7456, 3315, 7454, 3317, 7452, 3319, 7450, 3321, 7448, 3323, 7446, 3325, 7444, 3327, 7442, 3329, 7440, 3331, 7438, 3333, 7436, 3335, 7434, 3337, 7432, 3339, 7430, 3341, 7428, 3343, 7426, 3345, 7424, 3347, 7422, 3349, 7420, 3351, 7418, 3353, 7416, 3355, 7414, 3357, 7412, 3359, 7410, 3361, 7408, 3363, 7406, 3365, 7404, 3367, 7402, 3369, 7400, 3371, 7398, 3373, 7396, 3375, 7394, 3377, 7392, 3379, 7390, 3381, 7388, 3383, 7386, 3385, 7384, 3387, 7382, 3389, 7380, 3391, 7378, 3393, 7376, 3395, 7374, 3397, 7372, 3399, 7370, 3401, 7368, 3403, 7366, 3405, 7364, 3407, 7362, 3409, 7360, 3411, 7358, 3413, 7356, 3415, 7354, 3417, 7352, 3419, 7350, 3421, 7348, 3423, 7346, 3425, 7344, 3427, 7342, 3429, 7340, 3431, 7338, 3433, 7336, 3435, 7334, 3437, 7332, 3439, 7330, 3441, 7328, 3443, 7326, 3445, 7324, 3447, 7322, 3449, 7320, 3451, 7318, 3453, 7316, 3455, 7314, 3457, 7312, 3459, 7310, 3461, 7308, 3463, 7306, 3465, 7304, 3467, 7302, 3469, 7300, 3471, 7298, 3473, 7296, 3475, 7294, 3477, 7292, 3479, 7290, 3481, 7288, 3483, 7286, 3485, 7284, 3487, 7282, 3489, 7280, 3491, 7278, 3493, 7276, 3495, 7274, 3497, 7272, 3499, 7270, 3501, 7268, 3503, 7266, 3505, 7264, 3507, 7262, 3509, 7260, 3511, 7258, 3513, 7256, 3515, 7254, 3517, 7252, 3519, 7250, 3521, 7248, 3523, 7246, 3525, 7244, 3527, 7242, 3529, 7240, 3531, 7238, 3533, 7236, 3535, 7234, 3537, 7232, 3539, 7230, 3541, 7228, 3543, 7226, 3545, 7224, 3547, 7222, 3549, 7220, 3551, 7218, 3553, 7216, 3555, 7214, 3557, 7212, 3559, 7210, 3561, 7208, 3563, 7206, 3565, 7204, 3567, 7202, 3569, 7200, 3571, 7198, 3573, 7196, 3575, 7194, 3577, 7192, 3579, 7190, 3581, 7188, 3583, 7186, 3585, 7184, 3587, 7182, 3589, 7180, 3591, 7178, 3593, 7176, 3595, 7174, 3597, 7172, 3599, 7170, 3601, 7168, 3603, 7166, 3605, 7164, 3607, 7162, 3609, 7160, 3611, 7158, 3613, 7156, 3615, 7154, 3617, 7152, 3619, 7150, 3621, 7148, 3623, 7146, 3625, 7144, 3627, 7142, 3629, 7140, 3631, 7138, 3633, 7136, 3635, 7134, 3637, 7132, 3639, 7130, 3641, 7128, 3643, 7126, 3645, 7124, 3647, 7122, 3649, 7120, 3651, 7118, 3653, 7116, 3655, 7114, 3657, 7112, 3659, 7110, 3661, 7108, 3663, 7106, 3665, 7104, 3667, 7102, 3669, 7100, 3671, 7098, 3673, 7096, 3675, 7094, 3677, 7092, 3679, 7090, 3681, 7088, 3683, 7086, 3685, 7084, 3687, 7082, 3689, 7080, 3691, 7078, 3693, 7076, 3695, 7074, 3697, 7072, 3699, 7070, 3701, 7068, 3703, 7066, 3705, 7064, 3707, 7062, 3709, 7060, 3711, 7058, 3713, 7056, 3715, 7054, 3717, 7052, 3719, 7050, 3721, 7048, 3723, 7046, 3725, 7044, 3727, 7042, 3729, 7040, 3731, 7038, 3733, 7036, 3735, 7034, 3737, 7032, 3739, 7030, 3741, 7028, 3743, 7026, 3745, 7024, 3747, 7022, 3749, 7020, 3751, 7018, 3753, 7016, 3755, 7014, 3757, 7012, 3759, 7010, 3761, 7008, 3763, 7006, 3765, 7004, 3767, 7002, 3769, 7000, 3771, 6998, 3773, 6996, 3775, 6994, 3777, 6992, 3779, 6990, 3781, 6988, 3783, 6986, 3785, 6984, 3787, 6982, 3789, 6980, 3791, 6978, 3793, 6976, 3795, 6974, 3797, 6972, 3799, 6970, 3801, 6968, 3803, 6966, 3805, 6964, 3807, 6962, 3809, 6960, 3811, 6958, 3813, 6956, 3815, 6954, 3817, 6952, 3819, 6950, 3821, 6948, 3823, 6946, 3825, 6944, 3827, 6942, 3829, 6940, 3831, 6938, 3833, 6936, 3835, 6934, 3837, 6932, 3839, 6930, 3841, 6928, 3843, 6926, 3845, 6924, 3847, 6922, 3849, 6920, 3851, 6918, 3853, 6916, 3855, 6914, 3857, 6912, 3859, 6910, 3861, 6908, 3863, 6906, 3865, 6904, 3867, 6902, 3869, 6900, 3871, 6898, 3873, 6896, 3875, 6894, 3877, 6892, 3879, 6890, 3881, 6888, 3883, 6886, 3885, 6884, 3887, 6882, 3889, 6880, 3891, 6878, 3893, 6876, 3895, 6874, 3897, 6872, 3899, 6870, 3901, 6868, 3903, 6866, 3905, 6864, 3907, 6862, 3909, 6860, 3911, 6858, 3913, 6856, 3915, 6854, 3917, 6852, 3919, 6850, 3921, 6848, 3923, 6846, 3925, 6844, 3927, 6842, 3929, 6840, 3931, 6838, 3933, 6836, 3935, 6834, 3937, 6832, 3939, 6830, 3941, 6828, 3943, 6826, 3945, 6824, 3947, 6822, 3949, 6820, 3951, 6818, 3953, 6816, 3955, 6814, 3957, 6812, 3959, 6810, 3961, 6808, 3963, 6806, 3965, 6804, 3967, 6802, 3969, 6800, 3971, 6798, 3973, 6796, 3975, 6794, 3977, 6792, 3979, 6790, 3981, 6788, 3983, 6786, 3985, 6784, 3987, 6782, 3989, 6780, 3991, 6778, 3993, 6776, 3995, 6774, 3997, 6772, 3999, 6770, 4001, 6768, 4003, 6766, 4005, 6764, 4007, 6762, 4009, 6760, 4011, 6758, 4013, 6756, 4015, 6754, 4017, 6752, 4019, 6750, 4021, 6748, 4023, 6746, 4025, 6744, 4027, 6742, 4029, 6740, 4031, 6738, 4033, 6736, 4035, 6734, 4037, 6732, 4039, 6730, 4041, 6728, 4043, 6726, 4045, 6724, 4047, 6722, 4049, 6720, 4051, 6718, 4053, 6716, 4055, 6714, 4057, 6712, 4059, 6710, 4061, 6708, 4063, 6706, 4065, 6704, 4067, 6702, 4069, 6700, 4071, 6698, 4073, 6696, 4075, 6694, 4077, 6692, 4079, 6690, 4081, 6688, 4083, 6686, 4085, 6684, 4087, 6682, 4089, 6680, 4091, 6678, 4093, 6676, 4095, 6674, 4097, 6672, 4099, 6670, 4101, 6668, 4103, 6666, 4105, 6664, 4107, 6662, 4109, 6660, 4111, 6658, 4113, 6656, 4115, 6654, 4117, 6652, 4119, 6650, 4121, 6648, 4123, 6646, 4125, 6644, 4127, 6642, 4129, 6640, 4131, 6638, 4133, 6636, 4135, 6634, 4137, 6632, 4139, 6630, 4141, 6628, 4143, 6626, 4145, 6624, 4147, 6622, 4149, 6620, 4151, 6618, 4153, 6616, 4155, 6614, 4157, 6612, 4159, 6610, 4161, 6608, 4163, 6606, 4165, 6604, 4167, 6602, 4169, 6600, 4171, 6598, 4173, 6596, 4175, 6594, 4177, 6592, 4179, 6590, 4181, 6588, 4183, 6586, 4185, 6584, 4187, 6582, 4189, 6580, 4191, 6578, 4193, 6576, 4195, 6574, 4197, 6572, 4199, 6570, 4201, 6568, 4203, 6566, 4205, 6564, 4207, 6562, 4209, 6560, 4211, 6558, 4213, 6556, 4215, 6554, 4217, 6552, 4219, 6550, 4221, 6548, 4223, 6546, 4225, 6544, 4227, 6542, 4229, 6540, 4231, 6538, 4233, 6536, 4235, 6534, 4237, 6532, 4239, 6530, 4241, 6528, 4243, 6526, 4245, 6524, 4247, 6522, 4249, 6520, 4251, 6518, 4253, 6516, 4255, 6514, 4257, 6512, 4259, 6510, 4261, 6508, 4263, 6506, 4265, 6504, 4267, 6502, 4269, 6500, 4271, 6498, 4273, 6496, 4275, 6494, 4277, 6492, 4279, 6490, 4281, 6488, 4283, 6486, 4285, 6484, 4287, 6482, 4289, 6480, 4291, 6478, 4293, 6476, 4295, 6474, 4297, 6472, 4299, 6470, 4301, 6468, 4303, 6466, 4305, 6464, 4307, 6462, 4309, 6460, 4311, 6458, 4313, 6456, 4315, 6454, 4317, 6452, 4319, 6450, 4321, 6448, 4323, 6446, 4325, 6444, 4327, 6442, 4329, 6440, 4331, 6438, 4333, 6436, 4335, 6434, 4337, 6432, 4339, 6430, 4341, 6428, 4343, 6426, 4345, 6424, 4347, 6422, 4349, 6420, 4351, 6418, 4353, 6416, 4355, 6414, 4357, 6412, 4359, 6410, 4361, 6408, 4363, 6406, 4365, 6404, 4367, 6402, 4369, 6400, 4371, 6398, 4373, 6396, 4375, 6394, 4377, 6392, 4379, 6390, 4381, 6388, 4383, 6386, 4385, 6384, 4387, 6382, 4389, 6380, 4391, 6378, 4393, 6376, 4395, 6374, 4397, 6372, 4399, 6370, 4401, 6368, 4403, 6366, 4405, 6364, 4407, 6362, 4409, 6360, 4411, 6358, 4413, 6356, 4415, 6354, 4417, 6352, 4419, 6350, 4421, 6348, 4423, 6346, 4425, 6344, 4427, 6342, 4429, 6340, 4431, 6338, 4433, 6336, 4435, 6334, 4437, 6332, 4439, 6330, 4441, 6328, 4443, 6326, 4445, 6324, 4447, 6322, 4449, 6320, 4451, 6318, 4453, 6316, 4455, 6314, 4457, 6312, 4459, 6310, 4461, 6308, 4463, 6306, 4465, 6304, 4467, 6302, 4469, 6300, 4471, 6298, 4473, 6296, 4475, 6294, 4477, 6292, 4479, 6290, 4481, 6288, 4483, 6286, 4485, 6284, 4487, 6282, 4489, 6280, 4491, 6278, 4493, 6276, 4495, 6274, 4497, 6272, 4499, 6270, 4501, 6268, 4503, 6266, 4505, 6264, 4507, 6262, 4509, 6260, 4511, 6258, 4513, 6256, 4515, 6254, 4517, 6252, 4519, 6250, 4521, 6248, 4523, 6246, 4525, 6244, 4527, 6242, 4529, 6240, 4531, 6238, 4533, 6236, 4535, 6234, 4537, 6232, 4539, 6230, 4541, 6228, 4543, 6226, 4545, 6224, 4547, 6222, 4549, 6220, 4551, 6218, 4553, 6216, 4555, 6214, 4557, 6212, 4559, 6210, 4561, 6208, 4563, 6206, 4565, 6204, 4567, 6202, 4569, 6200, 4571, 6198, 4573, 6196, 4575, 6194, 4577, 6192, 4579, 6190, 4581, 6188, 4583, 6186, 4585, 6184, 4587, 6182, 4589, 6180, 4591, 6178, 4593, 6176, 4595, 6174, 4597, 6172, 4599, 6170, 4601, 6168, 4603, 6166, 4605, 6164, 4607, 6162, 4609, 6160, 4611, 6158, 4613, 6156, 4615, 6154, 4617, 6152, 4619, 6150, 4621, 6148, 4623, 6146, 4625, 6144, 4627, 6142, 4629, 6140, 4631, 6138, 4633, 6136, 4635, 6134, 4637, 6132, 4639, 6130, 4641, 6128, 4643, 6126, 4645, 6124, 4647, 6122, 4649, 6120, 4651, 6118, 4653, 6116, 4655, 6114, 4657, 6112, 4659, 6110, 4661, 6108, 4663, 6106, 4665, 6104, 4667, 6102, 4669, 6100, 4671, 6098, 4673, 6096, 4675, 6094, 4677, 6092, 4679, 6090, 4681, 6088, 4683, 6086, 4685, 6084, 4687, 6082, 4689, 6080, 4691, 6078, 4693, 6076, 4695, 6074, 4697, 6072, 4699, 6070, 4701, 6068, 4703, 6066, 4705, 6064, 4707, 6062, 4709, 6060, 4711, 6058, 4713, 6056, 4715, 6054, 4717, 6052, 4719, 6050, 4721, 6048, 4723, 6046, 4725, 6044, 4727, 6042, 4729, 6040, 4731, 6038, 4733, 6036, 4735, 6034, 4737, 6032, 4739, 6030, 4741, 6028, 4743, 6026, 4745, 6024, 4747, 6022, 4749, 6020, 4751, 6018, 4753, 6016, 4755, 6014, 4757, 6012, 4759, 6010, 4761, 6008, 4763, 6006, 4765, 6004, 4767, 6002, 4769, 6000, 4771, 5998, 4773, 5996, 4775, 5994, 4777, 5992, 4779, 5990, 4781, 5988, 4783, 5986, 4785, 5984, 4787, 5982, 4789, 5980, 4791, 5978, 4793, 5976, 4795, 5974, 4797, 5972, 4799, 5970, 4801, 5968, 4803, 5966, 4805, 5964, 4807, 5962, 4809, 5960, 4811, 5958, 4813, 5956, 4815, 5954, 4817, 5952, 4819, 5950, 4821, 5948, 4823, 5946, 4825, 5944, 4827, 5942, 4829, 5940, 4831, 5938, 4833, 5936, 4835, 5934, 4837, 5932, 4839, 5930, 4841, 5928, 4843, 5926, 4845, 5924, 4847, 5922, 4849, 5920, 4851, 5918, 4853, 5916, 4855, 5914, 4857, 5912, 4859, 5910, 4861, 5908, 4863, 5906, 4865, 5904, 4867, 5902, 4869, 5900, 4871, 5898, 4873, 5896, 4875, 5894, 4877, 5892, 4879, 5890, 4881, 5888, 4883, 5886, 4885, 5884, 4887, 5882, 4889, 5880, 4891, 5878, 4893, 5876, 4895, 5874, 4897, 5872, 4899, 5870, 4901, 5868, 4903, 5866, 4905, 5864, 4907, 5862, 4909, 5860, 4911, 5858, 4913, 5856, 4915, 5854, 4917, 5852, 4919, 5850, 4921, 5848, 4923, 5846, 4925, 5844, 4927, 5842, 4929, 5840, 4931, 5838, 4933, 5836, 4935, 5834, 4937, 5832, 4939, 5830, 4941, 5828, 4943, 5826, 4945, 5824, 4947, 5822, 4949, 5820, 4951, 5818, 4953, 5816, 4955, 5814, 4957, 5812, 4959, 5810, 4961, 5808, 4963, 5806, 4965, 5804, 4967, 5802, 4969, 5800, 4971, 5798, 4973, 5796, 4975, 5794, 4977, 5792, 4979, 5790, 4981, 5788, 4983, 5786, 4985, 5784, 4987, 5782, 4989, 5780, 4991, 5778, 4993, 5776, 4995, 5774, 4997, 5772, 4999, 5770, 5001, 5768, 5003, 5766, 5005, 5764, 5007, 5762, 5009, 5760, 5011, 5758, 5013, 5756, 5015, 5754, 5017, 5752, 5019, 5750, 5021, 5748, 5023, 5746, 5025, 5744, 5027, 5742, 5029, 5740, 5031, 5738, 5033, 5736, 5035, 5734, 5037, 5732, 5039, 5730, 5041, 5728, 5043, 5726, 5045, 5724, 5047, 5722, 5049, 5720, 5051, 5718, 5053, 5716, 5055, 5714, 5057, 5712, 5059, 5710, 5061, 5708, 5063, 5706, 5065, 5704, 5067, 5702, 5069, 5700, 5071, 5698, 5073, 5696, 5075, 5694, 5077, 5692, 5079, 5690, 5081, 5688, 5083, 5686, 5085, 5684, 5087, 5682, 5089, 5680, 5091, 5678, 5093, 5676, 5095, 5674, 5097, 5672, 5099, 5670, 5101, 5668, 5103, 5666, 5105, 5664, 5107, 5662, 5109, 5660, 5111, 5658, 5113, 5656, 5115, 5654, 5117, 5652, 5119, 5650, 5121, 5648, 5123, 5646, 5125, 5644, 5127, 5642, 5129, 5640, 5131, 5638, 5133, 5636, 5135, 5634, 5137, 5632, 5139, 5630, 5141, 5628, 5143, 5626, 5145, 5624, 5147, 5622, 5149, 5620, 5151, 5618, 5153, 5616, 5155, 5614, 5157, 5612, 5159, 5610, 5161, 5608, 5163, 5606, 5165, 5604, 5167, 5602, 5169, 5600, 5171, 5598, 5173, 5596, 5175, 5594, 5177, 5592, 5179, 5590, 5181, 5588, 5183, 5586, 5185, 5584, 5187, 5582, 5189, 5580, 5191, 5578, 5193, 5576, 5195, 5574, 5197, 5572, 5199, 5570, 5201, 5568, 5203, 5566, 5205, 5564, 5207, 5562, 5209, 5560, 5211, 5558, 5213, 5556, 5215, 5554, 5217, 5552, 5219, 5550, 5221, 5548, 5223, 5546, 5225, 5544, 5227, 5542, 5229, 5540, 5231, 5538, 5233, 5536, 5235, 5534, 5237, 5532, 5239, 5530, 5241, 5528, 5243, 5526, 5245, 5524, 5247, 5522, 5249, 5520, 5251, 5518, 5253, 5516, 5255, 5514, 5257, 5512, 5259, 5510, 5261, 5508, 5263, 5506, 5265, 5504, 5267, 5502, 5269, 5500, 5271, 5498, 5273, 5496, 5275, 5494, 5277, 5492, 5279, 5490, 5281, 5488, 5283, 5486, 5285, 5484, 5287, 5482, 5289, 5480, 5291, 5478, 5293, 5476, 5295, 5474, 5297, 5472, 5299, 5470, 5301, 5468, 5303, 5466, 5305, 5464, 5307, 5462, 5309, 5460, 5311, 5458, 5313, 5456, 5315, 5454, 5317, 5452, 5319, 5450, 5321, 5448, 5323, 5446, 5325, 5444, 5327, 5442, 5329, 5440, 5331, 5438, 5333, 5436, 5335, 5434, 5337, 5432, 5339, 5430, 5341, 5428, 5343, 5426, 5345, 5424, 5347, 5422, 5349, 5420, 5351, 5418, 5353, 5416, 5355, 5414, 5357, 5412, 5359, 5410, 5361, 5408, 5363, 5406, 5365, 5404, 5367, 5402, 5369, 5400, 5371, 5398, 5373, 5396, 5375, 5394, 5377, 5392, 5379, 5390, 5381, 5388, 5383, 5386, 5385, 5384, 5387, 5382, 5389, 5380, 5391, 5378, 5393, 5376, 5395, 5374, 5397, 5372, 5399, 5370, 5401, 5368, 5403, 5366, 5405, 5364, 5407, 5362, 5409, 5360, 5411, 5358, 5413, 5356, 5415, 5354, 5417, 5352, 5419, 5350, 5421, 5348, 5423, 5346, 5425, 5344, 5427, 5342, 5429, 5340, 5431, 5338, 5433, 5336, 5435, 5334, 5437, 5332, 5439, 5330, 5441, 5328, 5443, 5326, 5445, 5324, 5447, 5322, 5449, 5320, 5451, 5318, 5453, 5316, 5455, 5314, 5457, 5312, 5459, 5310, 5461, 5308, 5463, 5306, 5465, 5304, 5467, 5302, 5469, 5300, 5471, 5298, 5473, 5296, 5475, 5294, 5477, 5292, 5479, 5290, 5481, 5288, 5483, 5286, 5485, 5284, 5487, 5282, 5489, 5280, 5491, 5278, 5493, 5276, 5495, 5274, 5497, 5272, 5499, 5270, 5501, 5268, 5503, 5266, 5505, 5264, 5507, 5262, 5509, 5260, 5511, 5258, 5513, 5256, 5515, 5254, 5517, 5252, 5519, 5250, 5521, 5248, 5523, 5246, 5525, 5244, 5527, 5242, 5529, 5240, 5531, 5238, 5533, 5236, 5535, 5234, 5537, 5232, 5539, 5230, 5541, 5228, 5543, 5226, 5545, 5224, 5547, 5222, 5549, 5220, 5551, 5218, 5553, 5216, 5555, 5214, 5557, 5212, 5559, 5210, 5561, 5208, 5563, 5206, 5565, 5204, 5567, 5202, 5569, 5200, 5571, 5198, 5573, 5196, 5575, 5194, 5577, 5192, 5579, 5190, 5581, 5188, 5583, 5186, 5585, 5184, 5587, 5182, 5589, 5180, 5591, 5178, 5593, 5176, 5595, 5174, 5597, 5172, 5599, 5170, 5601, 5168, 5603, 5166, 5605, 5164, 5607, 5162, 5609, 5160, 5611, 5158, 5613, 5156, 5615, 5154, 5617, 5152, 5619, 5150, 5621, 5148, 5623, 5146, 5625, 5144, 5627, 5142, 5629, 5140, 5631, 5138, 5633, 5136, 5635, 5134, 5637, 5132, 5639, 5130, 5641, 5128, 5643, 5126, 5645, 5124, 5647, 5122, 5649, 5120, 5651, 5118, 5653, 5116, 5655, 5114, 5657, 5112, 5659, 5110, 5661, 5108, 5663, 5106, 5665, 5104, 5667, 5102, 5669, 5100, 5671, 5098, 5673, 5096, 5675, 5094, 5677, 5092, 5679, 5090, 5681, 5088, 5683, 5086, 5685, 5084, 5687, 5082, 5689, 5080, 5691, 5078, 5693, 5076, 5695, 5074, 5697, 5072, 5699, 5070, 5701, 5068, 5703, 5066, 5705, 5064, 5707, 5062, 5709, 5060, 5711, 5058, 5713, 5056, 5715, 5054, 5717, 5052, 5719, 5050, 5721, 5048, 5723, 5046, 5725, 5044, 5727, 5042, 5729, 5040, 5731, 5038, 5733, 5036, 5735, 5034, 5737, 5032, 5739, 5030, 5741, 5028, 5743, 5026, 5745, 5024, 5747, 5022, 5749, 5020, 5751, 5018, 5753, 5016, 5755, 5014, 5757, 5012, 5759, 5010, 5761, 5008, 5763, 5006, 5765, 5004, 5767, 5002, 5769, 5000, 5771, 4998, 5773, 4996, 5775, 4994, 5777, 4992, 5779, 4990, 5781, 4988, 5783, 4986, 5785, 4984, 5787, 4982, 5789, 4980, 5791, 4978, 5793, 4976, 5795, 4974, 5797, 4972, 5799, 4970, 5801, 4968, 5803, 4966, 5805, 4964, 5807, 4962, 5809, 4960, 5811, 4958, 5813, 4956, 5815, 4954, 5817, 4952, 5819, 4950, 5821, 4948, 5823, 4946, 5825, 4944, 5827, 4942, 5829, 4940, 5831, 4938, 5833, 4936, 5835, 4934, 5837, 4932, 5839, 4930, 5841, 4928, 5843, 4926, 5845, 4924, 5847, 4922, 5849, 4920, 5851, 4918, 5853, 4916, 5855, 4914, 5857, 4912, 5859, 4910, 5861, 4908, 5863, 4906, 5865, 4904, 5867, 4902, 5869, 4900, 5871, 4898, 5873, 4896, 5875, 4894, 5877, 4892, 5879, 4890, 5881, 4888, 5883, 4886, 5885, 4884, 5887, 4882, 5889, 4880, 5891, 4878, 5893, 4876, 5895, 4874, 5897, 4872, 5899, 4870, 5901, 4868, 5903, 4866, 5905, 4864, 5907, 4862, 5909, 4860, 5911, 4858, 5913, 4856, 5915, 4854, 5917, 4852, 5919, 4850, 5921, 4848, 5923, 4846, 5925, 4844, 5927, 4842, 5929, 4840, 5931, 4838, 5933, 4836, 5935, 4834, 5937, 4832, 5939, 4830, 5941, 4828, 5943, 4826, 5945, 4824, 5947, 4822, 5949, 4820, 5951, 4818, 5953, 4816, 5955, 4814, 5957, 4812, 5959, 4810, 5961, 4808, 5963, 4806, 5965, 4804, 5967, 4802, 5969, 4800, 5971, 4798, 5973, 4796, 5975, 4794, 5977, 4792, 5979, 4790, 5981, 4788, 5983, 4786, 5985, 4784, 5987, 4782, 5989, 4780, 5991, 4778, 5993, 4776, 5995, 4774, 5997, 4772, 5999, 4770, 6001, 4768, 6003, 4766, 6005, 4764, 6007, 4762, 6009, 4760, 6011, 4758, 6013, 4756, 6015, 4754, 6017, 4752, 6019, 4750, 6021, 4748, 6023, 4746, 6025, 4744, 6027, 4742, 6029, 4740, 6031, 4738, 6033, 4736, 6035, 4734, 6037, 4732, 6039, 4730, 6041, 4728, 6043, 4726, 6045, 4724, 6047, 4722, 6049, 4720, 6051, 4718, 6053, 4716, 6055, 4714, 6057, 4712, 6059, 4710, 6061, 4708, 6063, 4706, 6065, 4704, 6067, 4702, 6069, 4700, 6071, 4698, 6073, 4696, 6075, 4694, 6077, 4692, 6079, 4690, 6081, 4688, 6083, 4686, 6085, 4684, 6087, 4682, 6089, 4680, 6091, 4678, 6093, 4676, 6095, 4674, 6097, 4672, 6099, 4670, 6101, 4668, 6103, 4666, 6105, 4664, 6107, 4662, 6109, 4660, 6111, 4658, 6113, 4656, 6115, 4654, 6117, 4652, 6119, 4650, 6121, 4648, 6123, 4646, 6125, 4644, 6127, 4642, 6129, 4640, 6131, 4638, 6133, 4636, 6135, 4634, 6137, 4632, 6139, 4630, 6141, 4628, 6143, 4626, 6145, 4624, 6147, 4622, 6149, 4620, 6151, 4618, 6153, 4616, 6155, 4614, 6157, 4612, 6159, 4610, 6161, 4608, 6163, 4606, 6165, 4604, 6167, 4602, 6169, 4600, 6171, 4598, 6173, 4596, 6175, 4594, 6177, 4592, 6179, 4590, 6181, 4588, 6183, 4586, 6185, 4584, 6187, 4582, 6189, 4580, 6191, 4578, 6193, 4576, 6195, 4574, 6197, 4572, 6199, 4570, 6201, 4568, 6203, 4566, 6205, 4564, 6207, 4562, 6209, 4560, 6211, 4558, 6213, 4556, 6215, 4554, 6217, 4552, 6219, 4550, 6221, 4548, 6223, 4546, 6225, 4544, 6227, 4542, 6229, 4540, 6231, 4538, 6233, 4536, 6235, 4534, 6237, 4532, 6239, 4530, 6241, 4528, 6243, 4526, 6245, 4524, 6247, 4522, 6249, 4520, 6251, 4518, 6253, 4516, 6255, 4514, 6257, 4512, 6259, 4510, 6261, 4508, 6263, 4506, 6265, 4504, 6267, 4502, 6269, 4500, 6271, 4498, 6273, 4496, 6275, 4494, 6277, 4492, 6279, 4490, 6281, 4488, 6283, 4486, 6285, 4484, 6287, 4482, 6289, 4480, 6291, 4478, 6293, 4476, 6295, 4474, 6297, 4472, 6299, 4470, 6301, 4468, 6303, 4466, 6305, 4464, 6307, 4462, 6309, 4460, 6311, 4458, 6313, 4456, 6315, 4454, 6317, 4452, 6319, 4450, 6321, 4448, 6323, 4446, 6325, 4444, 6327, 4442, 6329, 4440, 6331, 4438, 6333, 4436, 6335, 4434, 6337, 4432, 6339, 4430, 6341, 4428, 6343, 4426, 6345, 4424, 6347, 4422, 6349, 4420, 6351, 4418, 6353, 4416, 6355, 4414, 6357, 4412, 6359, 4410, 6361, 4408, 6363, 4406, 6365, 4404, 6367, 4402, 6369, 4400, 6371, 4398, 6373, 4396, 6375, 4394, 6377, 4392, 6379, 4390, 6381, 4388, 6383, 4386, 6385, 4384, 6387, 4382, 6389, 4380, 6391, 4378, 6393, 4376, 6395, 4374, 6397, 4372, 6399, 4370, 6401, 4368, 6403, 4366, 6405, 4364, 6407, 4362, 6409, 4360, 6411, 4358, 6413, 4356, 6415, 4354, 6417, 4352, 6419, 4350, 6421, 4348, 6423, 4346, 6425, 4344, 6427, 4342, 6429, 4340, 6431, 4338, 6433, 4336, 6435, 4334, 6437, 4332, 6439, 4330, 6441, 4328, 6443, 4326, 6445, 4324, 6447, 4322, 6449, 4320, 6451, 4318, 6453, 4316, 6455, 4314, 6457, 4312, 6459, 4310, 6461, 4308, 6463, 4306, 6465, 4304, 6467, 4302, 6469, 4300, 6471, 4298, 6473, 4296, 6475, 4294, 6477, 4292, 6479, 4290, 6481, 4288, 6483, 4286, 6485, 4284, 6487, 4282, 6489, 4280, 6491, 4278, 6493, 4276, 6495, 4274, 6497, 4272, 6499, 4270, 6501, 4268, 6503, 4266, 6505, 4264, 6507, 4262, 6509, 4260, 6511, 4258, 6513, 4256, 6515, 4254, 6517, 4252, 6519, 4250, 6521, 4248, 6523, 4246, 6525, 4244, 6527, 4242, 6529, 4240, 6531, 4238, 6533, 4236, 6535, 4234, 6537, 4232, 6539, 4230, 6541, 4228, 6543, 4226, 6545, 4224, 6547, 4222, 6549, 4220, 6551, 4218, 6553, 4216, 6555, 4214, 6557, 4212, 6559, 4210, 6561, 4208, 6563, 4206, 6565, 4204, 6567, 4202, 6569, 4200, 6571, 4198, 6573, 4196, 6575, 4194, 6577, 4192, 6579, 4190, 6581, 4188, 6583, 4186, 6585, 4184, 6587, 4182, 6589, 4180, 6591, 4178, 6593, 4176, 6595, 4174, 6597, 4172, 6599, 4170, 6601, 4168, 6603, 4166, 6605, 4164, 6607, 4162, 6609, 4160, 6611, 4158, 6613, 4156, 6615, 4154, 6617, 4152, 6619, 4150, 6621, 4148, 6623, 4146, 6625, 4144, 6627, 4142, 6629, 4140, 6631, 4138, 6633, 4136, 6635, 4134, 6637, 4132, 6639, 4130, 6641, 4128, 6643, 4126, 6645, 4124, 6647, 4122, 6649, 4120, 6651, 4118, 6653, 4116, 6655, 4114, 6657, 4112, 6659, 4110, 6661, 4108, 6663, 4106, 6665, 4104, 6667, 4102, 6669, 4100, 6671, 4098, 6673, 4096, 6675, 4094, 6677, 4092, 6679, 4090, 6681, 4088, 6683, 4086, 6685, 4084, 6687, 4082, 6689, 4080, 6691, 4078, 6693, 4076, 6695, 4074, 6697, 4072, 6699, 4070, 6701, 4068, 6703, 4066, 6705, 4064, 6707, 4062, 6709, 4060, 6711, 4058, 6713, 4056, 6715, 4054, 6717, 4052, 6719, 4050, 6721, 4048, 6723, 4046, 6725, 4044, 6727, 4042, 6729, 4040, 6731, 4038, 6733, 4036, 6735, 4034, 6737, 4032, 6739, 4030, 6741, 4028, 6743, 4026, 6745, 4024, 6747, 4022, 6749, 4020, 6751, 4018, 6753, 4016, 6755, 4014, 6757, 4012, 6759, 4010, 6761, 4008, 6763, 4006, 6765, 4004, 6767, 4002, 6769, 4000, 6771, 3998, 6773, 3996, 6775, 3994, 6777, 3992, 6779, 3990, 6781, 3988, 6783, 3986, 6785, 3984, 6787, 3982, 6789, 3980, 6791, 3978, 6793, 3976, 6795, 3974, 6797, 3972, 6799, 3970, 6801, 3968, 6803, 3966, 6805, 3964, 6807, 3962, 6809, 3960, 6811, 3958, 6813, 3956, 6815, 3954, 6817, 3952, 6819, 3950, 6821, 3948, 6823, 3946, 6825, 3944, 6827, 3942, 6829, 3940, 6831, 3938, 6833, 3936, 6835, 3934, 6837, 3932, 6839, 3930, 6841, 3928, 6843, 3926, 6845, 3924, 6847, 3922, 6849, 3920, 6851, 3918, 6853, 3916, 6855, 3914, 6857, 3912, 6859, 3910, 6861, 3908, 6863, 3906, 6865, 3904, 6867, 3902, 6869, 3900, 6871, 3898, 6873, 3896, 6875, 3894, 6877, 3892, 6879, 3890, 6881, 3888, 6883, 3886, 6885, 3884, 6887, 3882, 6889, 3880, 6891, 3878, 6893, 3876, 6895, 3874, 6897, 3872, 6899, 3870, 6901, 3868, 6903, 3866, 6905, 3864, 6907, 3862, 6909, 3860, 6911, 3858, 6913, 3856, 6915, 3854, 6917, 3852, 6919, 3850, 6921, 3848, 6923, 3846, 6925, 3844, 6927, 3842, 6929, 3840, 6931, 3838, 6933, 3836, 6935, 3834, 6937, 3832, 6939, 3830, 6941, 3828, 6943, 3826, 6945, 3824, 6947, 3822, 6949, 3820, 6951, 3818, 6953, 3816, 6955, 3814, 6957, 3812, 6959, 3810, 6961, 3808, 6963, 3806, 6965, 3804, 6967, 3802, 6969, 3800, 6971, 3798, 6973, 3796, 6975, 3794, 6977, 3792, 6979, 3790, 6981, 3788, 6983, 3786, 6985, 3784, 6987, 3782, 6989, 3780, 6991, 3778, 6993, 3776, 6995, 3774, 6997, 3772, 6999, 3770, 7001, 3768, 7003, 3766, 7005, 3764, 7007, 3762, 7009, 3760, 7011, 3758, 7013, 3756, 7015, 3754, 7017, 3752, 7019, 3750, 7021, 3748, 7023, 3746, 7025, 3744, 7027, 3742, 7029, 3740, 7031, 3738, 7033, 3736, 7035, 3734, 7037, 3732, 7039, 3730, 7041, 3728, 7043, 3726, 7045, 3724, 7047, 3722, 7049, 3720, 7051, 3718, 7053, 3716, 7055, 3714, 7057, 3712, 7059, 3710, 7061, 3708, 7063, 3706, 7065, 3704, 7067, 3702, 7069, 3700, 7071, 3698, 7073, 3696, 7075, 3694, 7077, 3692, 7079, 3690, 7081, 3688, 7083, 3686, 7085, 3684, 7087, 3682, 7089, 3680, 7091, 3678, 7093, 3676, 7095, 3674, 7097, 3672, 7099, 3670, 7101, 3668, 7103, 3666, 7105, 3664, 7107, 3662, 7109, 3660, 7111, 3658, 7113, 3656, 7115, 3654, 7117, 3652, 7119, 3650, 7121, 3648, 7123, 3646, 7125, 3644, 7127, 3642, 7129, 3640, 7131, 3638, 7133, 3636, 7135, 3634, 7137, 3632, 7139, 3630, 7141, 3628, 7143, 3626, 7145, 3624, 7147, 3622, 7149, 3620, 7151, 3618, 7153, 3616, 7155, 3614, 7157, 3612, 7159, 3610, 7161, 3608, 7163, 3606, 7165, 3604, 7167, 3602, 7169, 3600, 7171, 3598, 7173, 3596, 7175, 3594, 7177, 3592, 7179, 3590, 7181, 3588, 7183, 3586, 7185, 3584, 7187, 3582, 7189, 3580, 7191, 3578, 7193, 3576, 7195, 3574, 7197, 3572, 7199, 3570, 7201, 3568, 7203, 3566, 7205, 3564, 7207, 3562, 7209, 3560, 7211, 3558, 7213, 3556, 7215, 3554, 7217, 3552, 7219, 3550, 7221, 3548, 7223, 3546, 7225, 3544, 7227, 3542, 7229, 3540, 7231, 3538, 7233, 3536, 7235, 3534, 7237, 3532, 7239, 3530, 7241, 3528, 7243, 3526, 7245, 3524, 7247, 3522, 7249, 3520, 7251, 3518, 7253, 3516, 7255, 3514, 7257, 3512, 7259, 3510, 7261, 3508, 7263, 3506, 7265, 3504, 7267, 3502, 7269, 3500, 7271, 3498, 7273, 3496, 7275, 3494, 7277, 3492, 7279, 3490, 7281, 3488, 7283, 3486, 7285, 3484, 7287, 3482, 7289, 3480, 7291, 3478, 7293, 3476, 7295, 3474, 7297, 3472, 7299, 3470, 7301, 3468, 7303, 3466, 7305, 3464, 7307, 3462, 7309, 3460, 7311, 3458, 7313, 3456, 7315, 3454, 7317, 3452, 7319, 3450, 7321, 3448, 7323, 3446, 7325, 3444, 7327, 3442, 7329, 3440, 7331, 3438, 7333, 3436, 7335, 3434, 7337, 3432, 7339, 3430, 7341, 3428, 7343, 3426, 7345, 3424, 7347, 3422, 7349, 3420, 7351, 3418, 7353, 3416, 7355, 3414, 7357, 3412, 7359, 3410, 7361, 3408, 7363, 3406, 7365, 3404, 7367, 3402, 7369, 3400, 7371, 3398, 7373, 3396, 7375, 3394, 7377, 3392, 7379, 3390, 7381, 3388, 7383, 3386, 7385, 3384, 7387, 3382, 7389, 3380, 7391, 3378, 7393, 3376, 7395, 3374, 7397, 3372, 7399, 3370, 7401, 3368, 7403, 3366, 7405, 3364, 7407, 3362, 7409, 3360, 7411, 3358, 7413, 3356, 7415, 3354, 7417, 3352, 7419, 3350, 7421, 3348, 7423, 3346, 7425, 3344, 7427, 3342, 7429, 3340, 7431, 3338, 7433, 3336, 7435, 3334, 7437, 3332, 7439, 3330, 7441, 3328, 7443, 3326, 7445, 3324, 7447, 3322, 7449, 3320, 7451, 3318, 7453, 3316, 7455, 3314, 7457, 3312, 7459, 3310, 7461, 3308, 7463, 3306, 7465, 3304, 7467, 3302, 7469, 3300, 7471, 3298, 7473, 3296, 7475, 3294, 7477, 3292, 7479, 3290, 7481, 3288, 7483, 3286, 7485, 3284, 7487, 3282, 7489, 3280, 7491, 3278, 7493, 3276, 7495, 3274, 7497, 3272, 7499, 3270, 7501, 3268, 7503, 3266, 7505, 3264, 7507, 3262, 7509, 3260, 7511, 3258, 7513, 3256, 7515, 3254, 7517, 3252, 7519, 3250, 7521, 3248, 7523, 3246, 7525, 3244, 7527, 3242, 7529, 3240, 7531, 3238, 7533, 3236, 7535, 3234, 7537, 3232, 7539, 3230, 7541, 3228, 7543, 3226, 7545, 3224, 7547, 3222, 7549, 3220, 7551, 3218, 7553, 3216, 7555, 3214, 7557, 3212, 7559, 3210, 7561, 3208, 7563, 3206, 7565, 3204, 7567, 3202, 7569, 3200, 7571, 3198, 7573, 3196, 7575, 3194, 7577, 3192, 7579, 3190, 7581, 3188, 7583, 3186, 7585, 3184, 7587, 3182, 7589, 3180, 7591, 3178, 7593, 3176, 7595, 3174, 7597, 3172, 7599, 3170, 7601, 3168, 7603, 3166, 7605, 3164, 7607, 3162, 7609, 3160, 7611, 3158, 7613, 3156, 7615, 3154, 7617, 3152, 7619, 3150, 7621, 3148, 7623, 3146, 7625, 3144, 7627, 3142, 7629, 3140, 7631, 3138, 7633, 3136, 7635, 3134, 7637, 3132, 7639, 3130, 7641, 3128, 7643, 3126, 7645, 3124, 7647, 3122, 7649, 3120, 7651, 3118, 7653, 3116, 7655, 3114, 7657, 3112, 7659, 3110, 7661, 3108, 7663, 3106, 7665, 3104, 7667, 3102, 7669, 3100, 7671, 3098, 7673, 3096, 7675, 3094, 7677, 3092, 7679, 3090, 7681, 3088, 7683, 3086, 7685, 3084, 7687, 3082, 7689, 3080, 7691, 3078, 7693, 3076, 7695, 3074, 7697, 3072, 7699, 3070, 7701, 3068, 7703, 3066, 7705, 3064, 7707, 3062, 7709, 3060, 7711, 3058, 7713, 3056, 7715, 3054, 7717, 3052, 7719, 3050, 7721, 3048, 7723, 3046, 7725, 3044, 7727, 3042, 7729, 3040, 7731, 3038, 7733, 3036, 7735, 3034, 7737, 3032, 7739, 3030, 7741, 3028, 7743, 3026, 7745, 3024, 7747, 3022, 7749, 3020, 7751, 3018, 7753, 3016, 7755, 3014, 7757, 3012, 7759, 3010, 7761, 3008, 7763, 3006, 7765, 3004, 7767, 3002, 7769, 3000, 7771, 2998, 7773, 2996, 7775, 2994, 7777, 2992, 7779, 2990, 7781, 2988, 7783, 2986, 7785, 2984, 7787, 2982, 7789, 2980, 7791, 2978, 7793, 2976, 7795, 2974, 7797, 2972, 7799, 2970, 7801, 2968, 7803, 2966, 7805, 2964, 7807, 2962, 7809, 2960, 7811, 2958, 7813, 2956, 7815, 2954, 7817, 2952, 7819, 2950, 7821, 2948, 7823, 2946, 7825, 2944, 7827, 2942, 7829, 2940, 7831, 2938, 7833, 2936, 7835, 2934, 7837, 2932, 7839, 2930, 7841, 2928, 7843, 2926, 7845, 2924, 7847, 2922, 7849, 2920, 7851, 2918, 7853, 2916, 7855, 2914, 7857, 2912, 7859, 2910, 7861, 2908, 7863, 2906, 7865, 2904, 7867, 2902, 7869, 2900, 7871, 2898, 7873, 2896, 7875, 2894, 7877, 2892, 7879, 2890, 7881, 2888, 7883, 2886, 7885, 2884, 7887, 2882, 7889, 2880, 7891, 2878, 7893, 2876, 7895, 2874, 7897, 2872, 7899, 2870, 7901, 2868, 7903, 2866, 7905, 2864, 7907, 2862, 7909, 2860, 7911, 2858, 7913, 2856, 7915, 2854, 7917, 2852, 7919, 2850, 7921, 2848, 7923, 2846, 7925, 2844, 7927, 2842, 7929, 2840, 7931, 2838, 7933, 2836, 7935, 2834, 7937, 2832, 7939, 2830, 7941, 2828, 7943, 2826, 7945, 2824, 7947, 2822, 7949, 2820, 7951, 2818, 7953, 2816, 7955, 2814, 7957, 2812, 7959, 2810, 7961, 2808, 7963, 2806, 7965, 2804, 7967, 2802, 7969, 2800, 7971, 2798, 7973, 2796, 7975, 2794, 7977, 2792, 7979, 2790, 7981, 2788, 7983, 2786, 7985, 2784, 7987, 2782, 7989, 2780, 7991, 2778, 7993, 2776, 7995, 2774, 7997, 2772, 7999, 2770, 8001, 2768, 8003, 2766, 8005, 2764, 8007, 2762, 8009, 2760, 8011, 2758, 8013, 2756, 8015, 2754, 8017, 2752, 8019, 2750, 8021, 2748, 8023, 2746, 8025, 2744, 8027, 2742, 8029, 2740, 8031, 2738, 8033, 2736, 8035, 2734, 8037, 2732, 8039, 2730, 8041, 2728, 8043, 2726, 8045, 2724, 8047, 2722, 8049, 2720, 8051, 2718, 8053, 2716, 8055, 2714, 8057, 2712, 8059, 2710, 8061, 2708, 8063, 2706, 8065, 2704, 8067, 2702, 8069, 2700, 8071, 2698, 8073, 2696, 8075, 2694, 8077, 2692, 8079, 2690, 8081, 2688, 8083, 2686, 8085, 2684, 8087, 2682, 8089, 2680, 8091, 2678, 8093, 2676, 8095, 2674, 8097, 2672, 8099, 2670, 8101, 2668, 8103, 2666, 8105, 2664, 8107, 2662, 8109, 2660, 8111, 2658, 8113, 2656, 8115, 2654, 8117, 2652, 8119, 2650, 8121, 2648, 8123, 2646, 8125, 2644, 8127, 2642, 8129, 2640, 8131, 2638, 8133, 2636, 8135, 2634, 8137, 2632, 8139, 2630, 8141, 2628, 8143, 2626, 8145, 2624, 8147, 2622, 8149, 2620, 8151, 2618, 8153, 2616, 8155, 2614, 8157, 2612, 8159, 2610, 8161, 2608, 8163, 2606, 8165, 2604, 8167, 2602, 8169, 2600, 8171, 2598, 8173, 2596, 8175, 2594, 8177, 2592, 8179, 2590, 8181, 2588, 8183, 2586, 8185, 2584, 8187, 2582, 8189, 2580, 8191, 2578, 8193, 2576, 8195, 2574, 8197, 2572, 8199, 2570, 8201, 2568, 8203, 2566, 8205, 2564, 8207, 2562, 8209, 2560, 8211, 2558, 8213, 2556, 8215, 2554, 8217, 2552, 8219, 2550, 8221, 2548, 8223, 2546, 8225, 2544, 8227, 2542, 8229, 2540, 8231, 2538, 8233, 2536, 8235, 2534, 8237, 2532, 8239, 2530, 8241, 2528, 8243, 2526, 8245, 2524, 8247, 2522, 8249, 2520, 8251, 2518, 8253, 2516, 8255, 2514, 8257, 2512, 8259, 2510, 8261, 2508, 8263, 2506, 8265, 2504, 8267, 2502, 8269, 2500, 8271, 2498, 8273, 2496, 8275, 2494, 8277, 2492, 8279, 2490, 8281, 2488, 8283, 2486, 8285, 2484, 8287, 2482, 8289, 2480, 8291, 2478, 8293, 2476, 8295, 2474, 8297, 2472, 8299, 2470, 8301, 2468, 8303, 2466, 8305, 2464, 8307, 2462, 8309, 2460, 8311, 2458, 8313, 2456, 8315, 2454, 8317, 2452, 8319, 2450, 8321, 2448, 8323, 2446, 8325, 2444, 8327, 2442, 8329, 2440, 8331, 2438, 8333, 2436, 8335, 2434, 8337, 2432, 8339, 2430, 8341, 2428, 8343, 2426, 8345, 2424, 8347, 2422, 8349, 2420, 8351, 2418, 8353, 2416, 8355, 2414, 8357, 2412, 8359, 2410, 8361, 2408, 8363, 2406, 8365, 2404, 8367, 2402, 8369, 2400, 8371, 2398, 8373, 2396, 8375, 2394, 8377, 2392, 8379, 2390, 8381, 2388, 8383, 2386, 8385, 2384, 8387, 2382, 8389, 2380, 8391, 2378, 8393, 2376, 8395, 2374, 8397, 2372, 8399, 2370, 8401, 2368, 8403, 2366, 8405, 2364, 8407, 2362, 8409, 2360, 8411, 2358, 8413, 2356, 8415, 2354, 8417, 2352, 8419, 2350, 8421, 2348, 8423, 2346, 8425, 2344, 8427, 2342, 8429, 2340, 8431, 2338, 8433, 2336, 8435, 2334, 8437, 2332, 8439, 2330, 8441, 2328, 8443, 2326, 8445, 2324, 8447, 2322, 8449, 2320, 8451, 2318, 8453, 2316, 8455, 2314, 8457, 2312, 8459, 2310, 8461, 2308, 8463, 2306, 8465, 2304, 8467, 2302, 8469, 2300, 8471, 2298, 8473, 2296, 8475, 2294, 8477, 2292, 8479, 2290, 8481, 2288, 8483, 2286, 8485, 2284, 8487, 2282, 8489, 2280, 8491, 2278, 8493, 2276, 8495, 2274, 8497, 2272, 8499, 2270, 8501, 2268, 8503, 2266, 8505, 2264, 8507, 2262, 8509, 2260, 8511, 2258, 8513, 2256, 8515, 2254, 8517, 2252, 8519, 2250, 8521, 2248, 8523, 2246, 8525, 2244, 8527, 2242, 8529, 2240, 8531, 2238, 8533, 2236, 8535, 2234, 8537, 2232, 8539, 2230, 8541, 2228, 8543, 2226, 8545, 2224, 8547, 2222, 8549, 2220, 8551, 2218, 8553, 2216, 8555, 2214, 8557, 2212, 8559, 2210, 8561, 2208, 8563, 2206, 8565, 2204, 8567, 2202, 8569, 2200, 8571, 2198, 8573, 2196, 8575, 2194, 8577, 2192, 8579, 2190, 8581, 2188, 8583, 2186, 8585, 2184, 8587, 2182, 8589, 2180, 8591, 2178, 8593, 2176, 8595, 2174, 8597, 2172, 8599, 2170, 8601, 2168, 8603, 2166, 8605, 2164, 8607, 2162, 8609, 2160, 8611, 2158, 8613, 2156, 8615, 2154, 8617, 2152, 8619, 2150, 8621, 2148, 8623, 2146, 8625, 2144, 8627, 2142, 8629, 2140, 8631, 2138, 8633, 2136, 8635, 2134, 8637, 2132, 8639, 2130, 8641, 2128, 8643, 2126, 8645, 2124, 8647, 2122, 8649, 2120, 8651, 2118, 8653, 2116, 8655, 2114, 8657, 2112, 8659, 2110, 8661, 2108, 8663, 2106, 8665, 2104, 8667, 2102, 8669, 2100, 8671, 2098, 8673, 2096, 8675, 2094, 8677, 2092, 8679, 2090, 8681, 2088, 8683, 2086, 8685, 2084, 8687, 2082, 8689, 2080, 8691, 2078, 8693, 2076, 8695, 2074, 8697, 2072, 8699, 2070, 8701, 2068, 8703, 2066, 8705, 2064, 8707, 2062, 8709, 2060, 8711, 2058, 8713, 2056, 8715, 2054, 8717, 2052, 8719, 2050, 8721, 2048, 8723, 2046, 8725, 2044, 8727, 2042, 8729, 2040, 8731, 2038, 8733, 2036, 8735, 2034, 8737, 2032, 8739, 2030, 8741, 2028, 8743, 2026, 8745, 2024, 8747, 2022, 8749, 2020, 8751, 2018, 8753, 2016, 8755, 2014, 8757, 2012, 8759, 2010, 8761, 2008, 8763, 2006, 8765, 2004, 8767, 2002, 8769, 2000, 8771, 1998, 8773, 1996, 8775, 1994, 8777, 1992, 8779, 1990, 8781, 1988, 8783, 1986, 8785, 1984, 8787, 1982, 8789, 1980, 8791, 1978, 8793, 1976, 8795, 1974, 8797, 1972, 8799, 1970, 8801, 1968, 8803, 1966, 8805, 1964, 8807, 1962, 8809, 1960, 8811, 1958, 8813, 1956, 8815, 1954, 8817, 1952, 8819, 1950, 8821, 1948, 8823, 1946, 8825, 1944, 8827, 1942, 8829, 1940, 8831, 1938, 8833, 1936, 8835, 1934, 8837, 1932, 8839, 1930, 8841, 1928, 8843, 1926, 8845, 1924, 8847, 1922, 8849, 1920, 8851, 1918, 8853, 1916, 8855, 1914, 8857, 1912, 8859, 1910, 8861, 1908, 8863, 1906, 8865, 1904, 8867, 1902, 8869, 1900, 8871, 1898, 8873, 1896, 8875, 1894, 8877, 1892, 8879, 1890, 8881, 1888, 8883, 1886, 8885, 1884, 8887, 1882, 8889, 1880, 8891, 1878, 8893, 1876, 8895, 1874, 8897, 1872, 8899, 1870, 8901, 1868, 8903, 1866, 8905, 1864, 8907, 1862, 8909, 1860, 8911, 1858, 8913, 1856, 8915, 1854, 8917, 1852, 8919, 1850, 8921, 1848, 8923, 1846, 8925, 1844, 8927, 1842, 8929, 1840, 8931, 1838, 8933, 1836, 8935, 1834, 8937, 1832, 8939, 1830, 8941, 1828, 8943, 1826, 8945, 1824, 8947, 1822, 8949, 1820, 8951, 1818, 8953, 1816, 8955, 1814, 8957, 1812, 8959, 1810, 8961, 1808, 8963, 1806, 8965, 1804, 8967, 1802, 8969, 1800, 8971, 1798, 8973, 1796, 8975, 1794, 8977, 1792, 8979, 1790, 8981, 1788, 8983, 1786, 8985, 1784, 8987, 1782, 8989, 1780, 8991, 1778, 8993, 1776, 8995, 1774, 8997, 1772, 8999, 1770, 9001, 1768, 9003, 1766, 9005, 1764, 9007, 1762, 9009, 1760, 9011, 1758, 9013, 1756, 9015, 1754, 9017, 1752, 9019, 1750, 9021, 1748, 9023, 1746, 9025, 1744, 9027, 1742, 9029, 1740, 9031, 1738, 9033, 1736, 9035, 1734, 9037, 1732, 9039, 1730, 9041, 1728, 9043, 1726, 9045, 1724, 9047, 1722, 9049, 1720, 9051, 1718, 9053, 1716, 9055, 1714, 9057, 1712, 9059, 1710, 9061, 1708, 9063, 1706, 9065, 1704, 9067, 1702, 9069, 1700, 9071, 1698, 9073, 1696, 9075, 1694, 9077, 1692, 9079, 1690, 9081, 1688, 9083, 1686, 9085, 1684, 9087, 1682, 9089, 1680, 9091, 1678, 9093, 1676, 9095, 1674, 9097, 1672, 9099, 1670, 9101, 1668, 9103, 1666, 9105, 1664, 9107, 1662, 9109, 1660, 9111, 1658, 9113, 1656, 9115, 1654, 9117, 1652, 9119, 1650, 9121, 1648, 9123, 1646, 9125, 1644, 9127, 1642, 9129, 1640, 9131, 1638, 9133, 1636, 9135, 1634, 9137, 1632, 9139, 1630, 9141, 1628, 9143, 1626, 9145, 1624, 9147, 1622, 9149, 1620, 9151, 1618, 9153, 1616, 9155, 1614, 9157, 1612, 9159, 1610, 9161, 1608, 9163, 1606, 9165, 1604, 9167, 1602, 9169, 1600, 9171, 1598, 9173, 1596, 9175, 1594, 9177, 1592, 9179, 1590, 9181, 1588, 9183, 1586, 9185, 1584, 9187, 1582, 9189, 1580, 9191, 1578, 9193, 1576, 9195, 1574, 9197, 1572, 9199, 1570, 9201, 1568, 9203, 1566, 9205, 1564, 9207, 1562, 9209, 1560, 9211, 1558, 9213, 1556, 9215, 1554, 9217, 1552, 9219, 1550, 9221, 1548, 9223, 1546, 9225, 1544, 9227, 1542, 9229, 1540, 9231, 1538, 9233, 1536, 9235, 1534, 9237, 1532, 9239, 1530, 9241, 1528, 9243, 1526, 9245, 1524, 9247, 1522, 9249, 1520, 9251, 1518, 9253, 1516, 9255, 1514, 9257, 1512, 9259, 1510, 9261, 1508, 9263, 1506, 9265, 1504, 9267, 1502, 9269, 1500, 9271, 1498, 9273, 1496, 9275, 1494, 9277, 1492, 9279, 1490, 9281, 1488, 9283, 1486, 9285, 1484, 9287, 1482, 9289, 1480, 9291, 1478, 9293, 1476, 9295, 1474, 9297, 1472, 9299, 1470, 9301, 1468, 9303, 1466, 9305, 1464, 9307, 1462, 9309, 1460, 9311, 1458, 9313, 1456, 9315, 1454, 9317, 1452, 9319, 1450, 9321, 1448, 9323, 1446, 9325, 1444, 9327, 1442, 9329, 1440, 9331, 1438, 9333, 1436, 9335, 1434, 9337, 1432, 9339, 1430, 9341, 1428, 9343, 1426, 9345, 1424, 9347, 1422, 9349, 1420, 9351, 1418, 9353, 1416, 9355, 1414, 9357, 1412, 9359, 1410, 9361, 1408, 9363, 1406, 9365, 1404, 9367, 1402, 9369, 1400, 9371, 1398, 9373, 1396, 9375, 1394, 9377, 1392, 9379, 1390, 9381, 1388, 9383, 1386, 9385, 1384, 9387, 1382, 9389, 1380, 9391, 1378, 9393, 1376, 9395, 1374, 9397, 1372, 9399, 1370, 9401, 1368, 9403, 1366, 9405, 1364, 9407, 1362, 9409, 1360, 9411, 1358, 9413, 1356, 9415, 1354, 9417, 1352, 9419, 1350, 9421, 1348, 9423, 1346, 9425, 1344, 9427, 1342, 9429, 1340, 9431, 1338, 9433, 1336, 9435, 1334, 9437, 1332, 9439, 1330, 9441, 1328, 9443, 1326, 9445, 1324, 9447, 1322, 9449, 1320, 9451, 1318, 9453, 1316, 9455, 1314, 9457, 1312, 9459, 1310, 9461, 1308, 9463, 1306, 9465, 1304, 9467, 1302, 9469, 1300, 9471, 1298, 9473, 1296, 9475, 1294, 9477, 1292, 9479, 1290, 9481, 1288, 9483, 1286, 9485, 1284, 9487, 1282, 9489, 1280, 9491, 1278, 9493, 1276, 9495, 1274, 9497, 1272, 9499, 1270, 9501, 1268, 9503, 1266, 9505, 1264, 9507, 1262, 9509, 1260, 9511, 1258, 9513, 1256, 9515, 1254, 9517, 1252, 9519, 1250, 9521, 1248, 9523, 1246, 9525, 1244, 9527, 1242, 9529, 1240, 9531, 1238, 9533, 1236, 9535, 1234, 9537, 1232, 9539, 1230, 9541, 1228, 9543, 1226, 9545, 1224, 9547, 1222, 9549, 1220, 9551, 1218, 9553, 1216, 9555, 1214, 9557, 1212, 9559, 1210, 9561, 1208, 9563, 1206, 9565, 1204, 9567, 1202, 9569, 1200, 9571, 1198, 9573, 1196, 9575, 1194, 9577, 1192, 9579, 1190, 9581, 1188, 9583, 1186, 9585, 1184, 9587, 1182, 9589, 1180, 9591, 1178, 9593, 1176, 9595, 1174, 9597, 1172, 9599, 1170, 9601, 1168, 9603, 1166, 9605, 1164, 9607, 1162, 9609, 1160, 9611, 1158, 9613, 1156, 9615, 1154, 9617, 1152, 9619, 1150, 9621, 1148, 9623, 1146, 9625, 1144, 9627, 1142, 9629, 1140, 9631, 1138, 9633, 1136, 9635, 1134, 9637, 1132, 9639, 1130, 9641, 1128, 9643, 1126, 9645, 1124, 9647, 1122, 9649, 1120, 9651, 1118, 9653, 1116, 9655, 1114, 9657, 1112, 9659, 1110, 9661, 1108, 9663, 1106, 9665, 1104, 9667, 1102, 9669, 1100, 9671, 1098, 9673, 1096, 9675, 1094, 9677, 1092, 9679, 1090, 9681, 1088, 9683, 1086, 9685, 1084, 9687, 1082, 9689, 1080, 9691, 1078, 9693, 1076, 9695, 1074, 9697, 1072, 9699, 1070, 9701, 1068, 9703, 1066, 9705, 1064, 9707, 1062, 9709, 1060, 9711, 1058, 9713, 1056, 9715, 1054, 9717, 1052, 9719, 1050, 9721, 1048, 9723, 1046, 9725, 1044, 9727, 1042, 9729, 1040, 9731, 1038, 9733, 1036, 9735, 1034, 9737, 1032, 9739, 1030, 9741, 1028, 9743, 1026, 9745, 1024, 9747, 1022, 9749, 1020, 9751, 1018, 9753, 1016, 9755, 1014, 9757, 1012, 9759, 1010, 9761, 1008, 9763, 1006, 9765, 1004, 9767, 1002, 9769, 1000, 9771, 998, 9773, 996, 9775, 994, 9777, 992, 9779, 990, 9781, 988, 9783, 986, 9785, 984, 9787, 982, 9789, 980, 9791, 978, 9793, 976, 9795, 974, 9797, 972, 9799, 970, 9801, 968, 9803, 966, 9805, 964, 9807, 962, 9809, 960, 9811, 958, 9813, 956, 9815, 954, 9817, 952, 9819, 950, 9821, 948, 9823, 946, 9825, 944, 9827, 942, 9829, 940, 9831, 938, 9833, 936, 9835, 934, 9837, 932, 9839, 930, 9841, 928, 9843, 926, 9845, 924, 9847, 922, 9849, 920, 9851, 918, 9853, 916, 9855, 914, 9857, 912, 9859, 910, 9861, 908, 9863, 906, 9865, 904, 9867, 902, 9869, 900, 9871, 898, 9873, 896, 9875, 894, 9877, 892, 9879, 890, 9881, 888, 9883, 886, 9885, 884, 9887, 882, 9889, 880, 9891, 878, 9893, 876, 9895, 874, 9897, 872, 9899, 870, 9901, 868, 9903, 866, 9905, 864, 9907, 862, 9909, 860, 9911, 858, 9913, 856, 9915, 854, 9917, 852, 9919, 850, 9921, 848, 9923, 846, 9925, 844, 9927, 842, 9929, 840, 9931, 838, 9933, 836, 9935, 834, 9937, 832, 9939, 830, 9941, 828, 9943, 826, 9945, 824, 9947, 822, 9949, 820, 9951, 818, 9953, 816, 9955, 814, 9957, 812, 9959, 810, 9961, 808, 9963, 806, 9965, 804, 9967, 802, 9969, 800, 9971, 798, 9973, 796, 9975, 794, 9977, 792, 9979, 790, 9981, 788, 9983, 786, 9985, 784, 9987, 782, 9989, 780, 9991, 778, 9993, 776, 9995, 774, 9997, 772, 9999, 770, 10001, 768, 10003, 766, 10005, 764, 10007, 762, 10009, 760, 10011, 758, 10013, 756, 10015, 754, 10017, 752, 10019, 750, 10021, 748, 10023, 746, 10025, 744, 10027, 742, 10029, 740, 10031, 738, 10033, 736, 10035, 734, 10037, 732, 10039, 730, 10041, 728, 10043, 726, 10045, 724, 10047, 722, 10049, 720, 10051, 718, 10053, 716, 10055, 714, 10057, 712, 10059, 710, 10061, 708, 10063, 706, 10065, 704, 10067, 702, 10069, 700, 10071, 698, 10073, 696, 10075, 694, 10077, 692, 10079, 690, 10081, 688, 10083, 686, 10085, 684, 10087, 682, 10089, 680, 10091, 678, 10093, 676, 10095, 674, 10097, 672, 10099, 670, 10101, 668, 10103, 666, 10105, 664, 10107, 662, 10109, 660, 10111, 658, 10113, 656, 10115, 654, 10117, 652, 10119, 650, 10121, 648, 10123, 646, 10125, 644, 10127, 642, 10129, 640, 10131, 638, 10133, 636, 10135, 634, 10137, 632, 10139, 630, 10141, 628, 10143, 626, 10145, 624, 10147, 622, 10149, 620, 10151, 618, 10153, 616, 10155, 614, 10157, 612, 10159, 610, 10161, 608, 10163, 606, 10165, 604, 10167, 602, 10169, 600, 10171, 598, 10173, 596, 10175, 594, 10177, 592, 10179, 590, 10181, 588, 10183, 586, 10185, 584, 10187, 582, 10189, 580, 10191, 578, 10193, 576, 10195, 574, 10197, 572, 10199, 570, 10201, 568, 10203, 566, 10205, 564, 10207, 562, 10209, 560, 10211, 558, 10213, 556, 10215, 554, 10217, 552, 10219, 550, 10221, 548, 10223, 546, 10225, 544, 10227, 542, 10229, 540, 10231, 538, 10233, 536, 10235, 534, 10237, 532, 10239, 530, 10241, 528, 10243, 526, 10245, 524, 10247, 522, 10249, 520, 10251, 518, 10253, 516, 10255, 514, 10257, 512, 10259, 510, 10261, 508, 10263, 506, 10265, 504, 10267, 502, 10269, 500, 10271, 498, 10273, 496, 10275, 494, 10277, 492, 10279, 490, 10281, 488, 10283, 486, 10285, 484, 10287, 482, 10289, 480, 10291, 478, 10293, 476, 10295, 474, 10297, 472, 10299, 470, 10301, 468, 10303, 466, 10305, 464, 10307, 462, 10309, 460, 10311, 458, 10313, 456, 10315, 454, 10317, 452, 10319, 450, 10321, 448, 10323, 446, 10325, 444, 10327, 442, 10329, 440, 10331, 438, 10333, 436, 10335, 434, 10337, 432, 10339, 430, 10341, 428, 10343, 426, 10345, 424, 10347, 422, 10349, 420, 10351, 418, 10353, 416, 10355, 414, 10357, 412, 10359, 410, 10361, 408, 10363, 406, 10365, 404, 10367, 402, 10369, 400, 10371, 398, 10373, 396, 10375, 394, 10377, 392, 10379, 390, 10381, 388, 10383, 386, 10385, 384, 10387, 382, 10389, 380, 10391, 378, 10393, 376, 10395, 374, 10397, 372, 10399, 370, 10401, 368, 10403, 366, 10405, 364, 10407, 362, 10409, 360, 10411, 358, 10413, 356, 10415, 354, 10417, 352, 10419, 350, 10421, 348, 10423, 346, 10425, 344, 10427, 342, 10429, 340, 10431, 338, 10433, 336, 10435, 334, 10437, 332, 10439, 330, 10441, 328, 10443, 326, 10445, 324, 10447, 322, 10449, 320, 10451, 318, 10453, 316, 10455, 314, 10457, 312, 10459, 310, 10461, 308, 10463, 306, 10465, 304, 10467, 302, 10469, 300, 10471, 298, 10473, 296, 10475, 294, 10477, 292, 10479, 290, 10481, 288, 10483, 286, 10485, 284, 10487, 282, 10489, 280, 10491, 278, 10493, 276, 10495, 274, 10497, 272, 10499, 270, 10501, 268, 10503, 266, 10505, 264, 10507, 262, 10509, 260, 10511, 258, 10513, 256, 10515, 254, 10517, 252, 10519, 250, 10521, 248, 10523, 246, 10525, 244, 10527, 242, 10529, 240, 10531, 238, 10533, 236, 10535, 234, 10537, 232, 10539, 230, 10541, 228, 10543, 226, 10545, 224, 10547, 222, 10549, 220, 10551, 218, 10553, 216, 10555, 214, 10557, 212, 10559, 210, 10561, 208, 10563, 206, 10565, 204, 10567, 202, 10569, 200, 10571, 198, 10573, 196, 10575, 194, 10577, 192, 10579, 190, 10581, 188, 10583, 186, 10585, 184, 10587, 182, 10589, 180, 10591, 178, 10593, 176, 10595, 174, 10597, 172, 10599, 170, 10601, 168, 10603, 166, 10605, 164, 10607, 162, 10609, 160, 10611, 158, 10613, 156, 10615, 154, 10617, 152, 10619, 150, 10621, 148, 10623, 146, 10625, 144, 10627, 142, 10629, 140, 10631, 138, 10633, 136, 10635, 134, 10637, 132, 10639, 130, 10641, 128, 10643, 126, 10645, 124, 10647, 122, 10649, 120, 10651, 118, 10653, 116, 10655, 114, 10657, 112, 10659, 110, 10661, 108, 10663, 106, 10665, 104, 10667, 102, 10669, 100, 10671, 98, 10673, 96, 10675, 94, 10677, 92, 10679, 90, 10681, 88, 10683, 86, 10685, 84, 10687, 82, 10689, 80, 10691, 78, 10693, 76, 10695, 74, 10697, 72, 10699, 70, 10701, 68, 10703, 66, 10705, 64, 10707, 62, 10709, 60, 10711, 58, 10713, 56, 10715, 54, 10717, 52, 10719, 50, 10721, 48, 10723, 46, 10725, 44, 10727, 42, 10729, 40, 10731, 38, 10733, 36, 10735, 34, 10737, 32, 10739, 30, 10741, 28, 10743, 26, 10745, 24, 10747, 22, 10749, 20, 10751, 18, 10753, 16, 10755, 14, 10757, 12, 10759, 10, 10761, 8, 10763, 6, 10765, 4, 10767, 2, 10769]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s0/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-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-l6-s0/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ea6d338aed5729025ba71c7f0b484249b47f9004 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 10770, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s0/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l6-s0/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l6-s7/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l6-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-rlve-prefix-sum-permutation-l6-s7/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d97054ac60de89ea98e865b98909d1f3012c0da9 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 16524, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s7/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..25505760116536baf37217b14876fdfc9d21506c --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [16524, 1, 16522, 3, 16520, 5, 16518, 7, 16516, 9, 16514, 11, 16512, 13, 16510, 15, 16508, 17, 16506, 19, 16504, 21, 16502, 23, 16500, 25, 16498, 27, 16496, 29, 16494, 31, 16492, 33, 16490, 35, 16488, 37, 16486, 39, 16484, 41, 16482, 43, 16480, 45, 16478, 47, 16476, 49, 16474, 51, 16472, 53, 16470, 55, 16468, 57, 16466, 59, 16464, 61, 16462, 63, 16460, 65, 16458, 67, 16456, 69, 16454, 71, 16452, 73, 16450, 75, 16448, 77, 16446, 79, 16444, 81, 16442, 83, 16440, 85, 16438, 87, 16436, 89, 16434, 91, 16432, 93, 16430, 95, 16428, 97, 16426, 99, 16424, 101, 16422, 103, 16420, 105, 16418, 107, 16416, 109, 16414, 111, 16412, 113, 16410, 115, 16408, 117, 16406, 119, 16404, 121, 16402, 123, 16400, 125, 16398, 127, 16396, 129, 16394, 131, 16392, 133, 16390, 135, 16388, 137, 16386, 139, 16384, 141, 16382, 143, 16380, 145, 16378, 147, 16376, 149, 16374, 151, 16372, 153, 16370, 155, 16368, 157, 16366, 159, 16364, 161, 16362, 163, 16360, 165, 16358, 167, 16356, 169, 16354, 171, 16352, 173, 16350, 175, 16348, 177, 16346, 179, 16344, 181, 16342, 183, 16340, 185, 16338, 187, 16336, 189, 16334, 191, 16332, 193, 16330, 195, 16328, 197, 16326, 199, 16324, 201, 16322, 203, 16320, 205, 16318, 207, 16316, 209, 16314, 211, 16312, 213, 16310, 215, 16308, 217, 16306, 219, 16304, 221, 16302, 223, 16300, 225, 16298, 227, 16296, 229, 16294, 231, 16292, 233, 16290, 235, 16288, 237, 16286, 239, 16284, 241, 16282, 243, 16280, 245, 16278, 247, 16276, 249, 16274, 251, 16272, 253, 16270, 255, 16268, 257, 16266, 259, 16264, 261, 16262, 263, 16260, 265, 16258, 267, 16256, 269, 16254, 271, 16252, 273, 16250, 275, 16248, 277, 16246, 279, 16244, 281, 16242, 283, 16240, 285, 16238, 287, 16236, 289, 16234, 291, 16232, 293, 16230, 295, 16228, 297, 16226, 299, 16224, 301, 16222, 303, 16220, 305, 16218, 307, 16216, 309, 16214, 311, 16212, 313, 16210, 315, 16208, 317, 16206, 319, 16204, 321, 16202, 323, 16200, 325, 16198, 327, 16196, 329, 16194, 331, 16192, 333, 16190, 335, 16188, 337, 16186, 339, 16184, 341, 16182, 343, 16180, 345, 16178, 347, 16176, 349, 16174, 351, 16172, 353, 16170, 355, 16168, 357, 16166, 359, 16164, 361, 16162, 363, 16160, 365, 16158, 367, 16156, 369, 16154, 371, 16152, 373, 16150, 375, 16148, 377, 16146, 379, 16144, 381, 16142, 383, 16140, 385, 16138, 387, 16136, 389, 16134, 391, 16132, 393, 16130, 395, 16128, 397, 16126, 399, 16124, 401, 16122, 403, 16120, 405, 16118, 407, 16116, 409, 16114, 411, 16112, 413, 16110, 415, 16108, 417, 16106, 419, 16104, 421, 16102, 423, 16100, 425, 16098, 427, 16096, 429, 16094, 431, 16092, 433, 16090, 435, 16088, 437, 16086, 439, 16084, 441, 16082, 443, 16080, 445, 16078, 447, 16076, 449, 16074, 451, 16072, 453, 16070, 455, 16068, 457, 16066, 459, 16064, 461, 16062, 463, 16060, 465, 16058, 467, 16056, 469, 16054, 471, 16052, 473, 16050, 475, 16048, 477, 16046, 479, 16044, 481, 16042, 483, 16040, 485, 16038, 487, 16036, 489, 16034, 491, 16032, 493, 16030, 495, 16028, 497, 16026, 499, 16024, 501, 16022, 503, 16020, 505, 16018, 507, 16016, 509, 16014, 511, 16012, 513, 16010, 515, 16008, 517, 16006, 519, 16004, 521, 16002, 523, 16000, 525, 15998, 527, 15996, 529, 15994, 531, 15992, 533, 15990, 535, 15988, 537, 15986, 539, 15984, 541, 15982, 543, 15980, 545, 15978, 547, 15976, 549, 15974, 551, 15972, 553, 15970, 555, 15968, 557, 15966, 559, 15964, 561, 15962, 563, 15960, 565, 15958, 567, 15956, 569, 15954, 571, 15952, 573, 15950, 575, 15948, 577, 15946, 579, 15944, 581, 15942, 583, 15940, 585, 15938, 587, 15936, 589, 15934, 591, 15932, 593, 15930, 595, 15928, 597, 15926, 599, 15924, 601, 15922, 603, 15920, 605, 15918, 607, 15916, 609, 15914, 611, 15912, 613, 15910, 615, 15908, 617, 15906, 619, 15904, 621, 15902, 623, 15900, 625, 15898, 627, 15896, 629, 15894, 631, 15892, 633, 15890, 635, 15888, 637, 15886, 639, 15884, 641, 15882, 643, 15880, 645, 15878, 647, 15876, 649, 15874, 651, 15872, 653, 15870, 655, 15868, 657, 15866, 659, 15864, 661, 15862, 663, 15860, 665, 15858, 667, 15856, 669, 15854, 671, 15852, 673, 15850, 675, 15848, 677, 15846, 679, 15844, 681, 15842, 683, 15840, 685, 15838, 687, 15836, 689, 15834, 691, 15832, 693, 15830, 695, 15828, 697, 15826, 699, 15824, 701, 15822, 703, 15820, 705, 15818, 707, 15816, 709, 15814, 711, 15812, 713, 15810, 715, 15808, 717, 15806, 719, 15804, 721, 15802, 723, 15800, 725, 15798, 727, 15796, 729, 15794, 731, 15792, 733, 15790, 735, 15788, 737, 15786, 739, 15784, 741, 15782, 743, 15780, 745, 15778, 747, 15776, 749, 15774, 751, 15772, 753, 15770, 755, 15768, 757, 15766, 759, 15764, 761, 15762, 763, 15760, 765, 15758, 767, 15756, 769, 15754, 771, 15752, 773, 15750, 775, 15748, 777, 15746, 779, 15744, 781, 15742, 783, 15740, 785, 15738, 787, 15736, 789, 15734, 791, 15732, 793, 15730, 795, 15728, 797, 15726, 799, 15724, 801, 15722, 803, 15720, 805, 15718, 807, 15716, 809, 15714, 811, 15712, 813, 15710, 815, 15708, 817, 15706, 819, 15704, 821, 15702, 823, 15700, 825, 15698, 827, 15696, 829, 15694, 831, 15692, 833, 15690, 835, 15688, 837, 15686, 839, 15684, 841, 15682, 843, 15680, 845, 15678, 847, 15676, 849, 15674, 851, 15672, 853, 15670, 855, 15668, 857, 15666, 859, 15664, 861, 15662, 863, 15660, 865, 15658, 867, 15656, 869, 15654, 871, 15652, 873, 15650, 875, 15648, 877, 15646, 879, 15644, 881, 15642, 883, 15640, 885, 15638, 887, 15636, 889, 15634, 891, 15632, 893, 15630, 895, 15628, 897, 15626, 899, 15624, 901, 15622, 903, 15620, 905, 15618, 907, 15616, 909, 15614, 911, 15612, 913, 15610, 915, 15608, 917, 15606, 919, 15604, 921, 15602, 923, 15600, 925, 15598, 927, 15596, 929, 15594, 931, 15592, 933, 15590, 935, 15588, 937, 15586, 939, 15584, 941, 15582, 943, 15580, 945, 15578, 947, 15576, 949, 15574, 951, 15572, 953, 15570, 955, 15568, 957, 15566, 959, 15564, 961, 15562, 963, 15560, 965, 15558, 967, 15556, 969, 15554, 971, 15552, 973, 15550, 975, 15548, 977, 15546, 979, 15544, 981, 15542, 983, 15540, 985, 15538, 987, 15536, 989, 15534, 991, 15532, 993, 15530, 995, 15528, 997, 15526, 999, 15524, 1001, 15522, 1003, 15520, 1005, 15518, 1007, 15516, 1009, 15514, 1011, 15512, 1013, 15510, 1015, 15508, 1017, 15506, 1019, 15504, 1021, 15502, 1023, 15500, 1025, 15498, 1027, 15496, 1029, 15494, 1031, 15492, 1033, 15490, 1035, 15488, 1037, 15486, 1039, 15484, 1041, 15482, 1043, 15480, 1045, 15478, 1047, 15476, 1049, 15474, 1051, 15472, 1053, 15470, 1055, 15468, 1057, 15466, 1059, 15464, 1061, 15462, 1063, 15460, 1065, 15458, 1067, 15456, 1069, 15454, 1071, 15452, 1073, 15450, 1075, 15448, 1077, 15446, 1079, 15444, 1081, 15442, 1083, 15440, 1085, 15438, 1087, 15436, 1089, 15434, 1091, 15432, 1093, 15430, 1095, 15428, 1097, 15426, 1099, 15424, 1101, 15422, 1103, 15420, 1105, 15418, 1107, 15416, 1109, 15414, 1111, 15412, 1113, 15410, 1115, 15408, 1117, 15406, 1119, 15404, 1121, 15402, 1123, 15400, 1125, 15398, 1127, 15396, 1129, 15394, 1131, 15392, 1133, 15390, 1135, 15388, 1137, 15386, 1139, 15384, 1141, 15382, 1143, 15380, 1145, 15378, 1147, 15376, 1149, 15374, 1151, 15372, 1153, 15370, 1155, 15368, 1157, 15366, 1159, 15364, 1161, 15362, 1163, 15360, 1165, 15358, 1167, 15356, 1169, 15354, 1171, 15352, 1173, 15350, 1175, 15348, 1177, 15346, 1179, 15344, 1181, 15342, 1183, 15340, 1185, 15338, 1187, 15336, 1189, 15334, 1191, 15332, 1193, 15330, 1195, 15328, 1197, 15326, 1199, 15324, 1201, 15322, 1203, 15320, 1205, 15318, 1207, 15316, 1209, 15314, 1211, 15312, 1213, 15310, 1215, 15308, 1217, 15306, 1219, 15304, 1221, 15302, 1223, 15300, 1225, 15298, 1227, 15296, 1229, 15294, 1231, 15292, 1233, 15290, 1235, 15288, 1237, 15286, 1239, 15284, 1241, 15282, 1243, 15280, 1245, 15278, 1247, 15276, 1249, 15274, 1251, 15272, 1253, 15270, 1255, 15268, 1257, 15266, 1259, 15264, 1261, 15262, 1263, 15260, 1265, 15258, 1267, 15256, 1269, 15254, 1271, 15252, 1273, 15250, 1275, 15248, 1277, 15246, 1279, 15244, 1281, 15242, 1283, 15240, 1285, 15238, 1287, 15236, 1289, 15234, 1291, 15232, 1293, 15230, 1295, 15228, 1297, 15226, 1299, 15224, 1301, 15222, 1303, 15220, 1305, 15218, 1307, 15216, 1309, 15214, 1311, 15212, 1313, 15210, 1315, 15208, 1317, 15206, 1319, 15204, 1321, 15202, 1323, 15200, 1325, 15198, 1327, 15196, 1329, 15194, 1331, 15192, 1333, 15190, 1335, 15188, 1337, 15186, 1339, 15184, 1341, 15182, 1343, 15180, 1345, 15178, 1347, 15176, 1349, 15174, 1351, 15172, 1353, 15170, 1355, 15168, 1357, 15166, 1359, 15164, 1361, 15162, 1363, 15160, 1365, 15158, 1367, 15156, 1369, 15154, 1371, 15152, 1373, 15150, 1375, 15148, 1377, 15146, 1379, 15144, 1381, 15142, 1383, 15140, 1385, 15138, 1387, 15136, 1389, 15134, 1391, 15132, 1393, 15130, 1395, 15128, 1397, 15126, 1399, 15124, 1401, 15122, 1403, 15120, 1405, 15118, 1407, 15116, 1409, 15114, 1411, 15112, 1413, 15110, 1415, 15108, 1417, 15106, 1419, 15104, 1421, 15102, 1423, 15100, 1425, 15098, 1427, 15096, 1429, 15094, 1431, 15092, 1433, 15090, 1435, 15088, 1437, 15086, 1439, 15084, 1441, 15082, 1443, 15080, 1445, 15078, 1447, 15076, 1449, 15074, 1451, 15072, 1453, 15070, 1455, 15068, 1457, 15066, 1459, 15064, 1461, 15062, 1463, 15060, 1465, 15058, 1467, 15056, 1469, 15054, 1471, 15052, 1473, 15050, 1475, 15048, 1477, 15046, 1479, 15044, 1481, 15042, 1483, 15040, 1485, 15038, 1487, 15036, 1489, 15034, 1491, 15032, 1493, 15030, 1495, 15028, 1497, 15026, 1499, 15024, 1501, 15022, 1503, 15020, 1505, 15018, 1507, 15016, 1509, 15014, 1511, 15012, 1513, 15010, 1515, 15008, 1517, 15006, 1519, 15004, 1521, 15002, 1523, 15000, 1525, 14998, 1527, 14996, 1529, 14994, 1531, 14992, 1533, 14990, 1535, 14988, 1537, 14986, 1539, 14984, 1541, 14982, 1543, 14980, 1545, 14978, 1547, 14976, 1549, 14974, 1551, 14972, 1553, 14970, 1555, 14968, 1557, 14966, 1559, 14964, 1561, 14962, 1563, 14960, 1565, 14958, 1567, 14956, 1569, 14954, 1571, 14952, 1573, 14950, 1575, 14948, 1577, 14946, 1579, 14944, 1581, 14942, 1583, 14940, 1585, 14938, 1587, 14936, 1589, 14934, 1591, 14932, 1593, 14930, 1595, 14928, 1597, 14926, 1599, 14924, 1601, 14922, 1603, 14920, 1605, 14918, 1607, 14916, 1609, 14914, 1611, 14912, 1613, 14910, 1615, 14908, 1617, 14906, 1619, 14904, 1621, 14902, 1623, 14900, 1625, 14898, 1627, 14896, 1629, 14894, 1631, 14892, 1633, 14890, 1635, 14888, 1637, 14886, 1639, 14884, 1641, 14882, 1643, 14880, 1645, 14878, 1647, 14876, 1649, 14874, 1651, 14872, 1653, 14870, 1655, 14868, 1657, 14866, 1659, 14864, 1661, 14862, 1663, 14860, 1665, 14858, 1667, 14856, 1669, 14854, 1671, 14852, 1673, 14850, 1675, 14848, 1677, 14846, 1679, 14844, 1681, 14842, 1683, 14840, 1685, 14838, 1687, 14836, 1689, 14834, 1691, 14832, 1693, 14830, 1695, 14828, 1697, 14826, 1699, 14824, 1701, 14822, 1703, 14820, 1705, 14818, 1707, 14816, 1709, 14814, 1711, 14812, 1713, 14810, 1715, 14808, 1717, 14806, 1719, 14804, 1721, 14802, 1723, 14800, 1725, 14798, 1727, 14796, 1729, 14794, 1731, 14792, 1733, 14790, 1735, 14788, 1737, 14786, 1739, 14784, 1741, 14782, 1743, 14780, 1745, 14778, 1747, 14776, 1749, 14774, 1751, 14772, 1753, 14770, 1755, 14768, 1757, 14766, 1759, 14764, 1761, 14762, 1763, 14760, 1765, 14758, 1767, 14756, 1769, 14754, 1771, 14752, 1773, 14750, 1775, 14748, 1777, 14746, 1779, 14744, 1781, 14742, 1783, 14740, 1785, 14738, 1787, 14736, 1789, 14734, 1791, 14732, 1793, 14730, 1795, 14728, 1797, 14726, 1799, 14724, 1801, 14722, 1803, 14720, 1805, 14718, 1807, 14716, 1809, 14714, 1811, 14712, 1813, 14710, 1815, 14708, 1817, 14706, 1819, 14704, 1821, 14702, 1823, 14700, 1825, 14698, 1827, 14696, 1829, 14694, 1831, 14692, 1833, 14690, 1835, 14688, 1837, 14686, 1839, 14684, 1841, 14682, 1843, 14680, 1845, 14678, 1847, 14676, 1849, 14674, 1851, 14672, 1853, 14670, 1855, 14668, 1857, 14666, 1859, 14664, 1861, 14662, 1863, 14660, 1865, 14658, 1867, 14656, 1869, 14654, 1871, 14652, 1873, 14650, 1875, 14648, 1877, 14646, 1879, 14644, 1881, 14642, 1883, 14640, 1885, 14638, 1887, 14636, 1889, 14634, 1891, 14632, 1893, 14630, 1895, 14628, 1897, 14626, 1899, 14624, 1901, 14622, 1903, 14620, 1905, 14618, 1907, 14616, 1909, 14614, 1911, 14612, 1913, 14610, 1915, 14608, 1917, 14606, 1919, 14604, 1921, 14602, 1923, 14600, 1925, 14598, 1927, 14596, 1929, 14594, 1931, 14592, 1933, 14590, 1935, 14588, 1937, 14586, 1939, 14584, 1941, 14582, 1943, 14580, 1945, 14578, 1947, 14576, 1949, 14574, 1951, 14572, 1953, 14570, 1955, 14568, 1957, 14566, 1959, 14564, 1961, 14562, 1963, 14560, 1965, 14558, 1967, 14556, 1969, 14554, 1971, 14552, 1973, 14550, 1975, 14548, 1977, 14546, 1979, 14544, 1981, 14542, 1983, 14540, 1985, 14538, 1987, 14536, 1989, 14534, 1991, 14532, 1993, 14530, 1995, 14528, 1997, 14526, 1999, 14524, 2001, 14522, 2003, 14520, 2005, 14518, 2007, 14516, 2009, 14514, 2011, 14512, 2013, 14510, 2015, 14508, 2017, 14506, 2019, 14504, 2021, 14502, 2023, 14500, 2025, 14498, 2027, 14496, 2029, 14494, 2031, 14492, 2033, 14490, 2035, 14488, 2037, 14486, 2039, 14484, 2041, 14482, 2043, 14480, 2045, 14478, 2047, 14476, 2049, 14474, 2051, 14472, 2053, 14470, 2055, 14468, 2057, 14466, 2059, 14464, 2061, 14462, 2063, 14460, 2065, 14458, 2067, 14456, 2069, 14454, 2071, 14452, 2073, 14450, 2075, 14448, 2077, 14446, 2079, 14444, 2081, 14442, 2083, 14440, 2085, 14438, 2087, 14436, 2089, 14434, 2091, 14432, 2093, 14430, 2095, 14428, 2097, 14426, 2099, 14424, 2101, 14422, 2103, 14420, 2105, 14418, 2107, 14416, 2109, 14414, 2111, 14412, 2113, 14410, 2115, 14408, 2117, 14406, 2119, 14404, 2121, 14402, 2123, 14400, 2125, 14398, 2127, 14396, 2129, 14394, 2131, 14392, 2133, 14390, 2135, 14388, 2137, 14386, 2139, 14384, 2141, 14382, 2143, 14380, 2145, 14378, 2147, 14376, 2149, 14374, 2151, 14372, 2153, 14370, 2155, 14368, 2157, 14366, 2159, 14364, 2161, 14362, 2163, 14360, 2165, 14358, 2167, 14356, 2169, 14354, 2171, 14352, 2173, 14350, 2175, 14348, 2177, 14346, 2179, 14344, 2181, 14342, 2183, 14340, 2185, 14338, 2187, 14336, 2189, 14334, 2191, 14332, 2193, 14330, 2195, 14328, 2197, 14326, 2199, 14324, 2201, 14322, 2203, 14320, 2205, 14318, 2207, 14316, 2209, 14314, 2211, 14312, 2213, 14310, 2215, 14308, 2217, 14306, 2219, 14304, 2221, 14302, 2223, 14300, 2225, 14298, 2227, 14296, 2229, 14294, 2231, 14292, 2233, 14290, 2235, 14288, 2237, 14286, 2239, 14284, 2241, 14282, 2243, 14280, 2245, 14278, 2247, 14276, 2249, 14274, 2251, 14272, 2253, 14270, 2255, 14268, 2257, 14266, 2259, 14264, 2261, 14262, 2263, 14260, 2265, 14258, 2267, 14256, 2269, 14254, 2271, 14252, 2273, 14250, 2275, 14248, 2277, 14246, 2279, 14244, 2281, 14242, 2283, 14240, 2285, 14238, 2287, 14236, 2289, 14234, 2291, 14232, 2293, 14230, 2295, 14228, 2297, 14226, 2299, 14224, 2301, 14222, 2303, 14220, 2305, 14218, 2307, 14216, 2309, 14214, 2311, 14212, 2313, 14210, 2315, 14208, 2317, 14206, 2319, 14204, 2321, 14202, 2323, 14200, 2325, 14198, 2327, 14196, 2329, 14194, 2331, 14192, 2333, 14190, 2335, 14188, 2337, 14186, 2339, 14184, 2341, 14182, 2343, 14180, 2345, 14178, 2347, 14176, 2349, 14174, 2351, 14172, 2353, 14170, 2355, 14168, 2357, 14166, 2359, 14164, 2361, 14162, 2363, 14160, 2365, 14158, 2367, 14156, 2369, 14154, 2371, 14152, 2373, 14150, 2375, 14148, 2377, 14146, 2379, 14144, 2381, 14142, 2383, 14140, 2385, 14138, 2387, 14136, 2389, 14134, 2391, 14132, 2393, 14130, 2395, 14128, 2397, 14126, 2399, 14124, 2401, 14122, 2403, 14120, 2405, 14118, 2407, 14116, 2409, 14114, 2411, 14112, 2413, 14110, 2415, 14108, 2417, 14106, 2419, 14104, 2421, 14102, 2423, 14100, 2425, 14098, 2427, 14096, 2429, 14094, 2431, 14092, 2433, 14090, 2435, 14088, 2437, 14086, 2439, 14084, 2441, 14082, 2443, 14080, 2445, 14078, 2447, 14076, 2449, 14074, 2451, 14072, 2453, 14070, 2455, 14068, 2457, 14066, 2459, 14064, 2461, 14062, 2463, 14060, 2465, 14058, 2467, 14056, 2469, 14054, 2471, 14052, 2473, 14050, 2475, 14048, 2477, 14046, 2479, 14044, 2481, 14042, 2483, 14040, 2485, 14038, 2487, 14036, 2489, 14034, 2491, 14032, 2493, 14030, 2495, 14028, 2497, 14026, 2499, 14024, 2501, 14022, 2503, 14020, 2505, 14018, 2507, 14016, 2509, 14014, 2511, 14012, 2513, 14010, 2515, 14008, 2517, 14006, 2519, 14004, 2521, 14002, 2523, 14000, 2525, 13998, 2527, 13996, 2529, 13994, 2531, 13992, 2533, 13990, 2535, 13988, 2537, 13986, 2539, 13984, 2541, 13982, 2543, 13980, 2545, 13978, 2547, 13976, 2549, 13974, 2551, 13972, 2553, 13970, 2555, 13968, 2557, 13966, 2559, 13964, 2561, 13962, 2563, 13960, 2565, 13958, 2567, 13956, 2569, 13954, 2571, 13952, 2573, 13950, 2575, 13948, 2577, 13946, 2579, 13944, 2581, 13942, 2583, 13940, 2585, 13938, 2587, 13936, 2589, 13934, 2591, 13932, 2593, 13930, 2595, 13928, 2597, 13926, 2599, 13924, 2601, 13922, 2603, 13920, 2605, 13918, 2607, 13916, 2609, 13914, 2611, 13912, 2613, 13910, 2615, 13908, 2617, 13906, 2619, 13904, 2621, 13902, 2623, 13900, 2625, 13898, 2627, 13896, 2629, 13894, 2631, 13892, 2633, 13890, 2635, 13888, 2637, 13886, 2639, 13884, 2641, 13882, 2643, 13880, 2645, 13878, 2647, 13876, 2649, 13874, 2651, 13872, 2653, 13870, 2655, 13868, 2657, 13866, 2659, 13864, 2661, 13862, 2663, 13860, 2665, 13858, 2667, 13856, 2669, 13854, 2671, 13852, 2673, 13850, 2675, 13848, 2677, 13846, 2679, 13844, 2681, 13842, 2683, 13840, 2685, 13838, 2687, 13836, 2689, 13834, 2691, 13832, 2693, 13830, 2695, 13828, 2697, 13826, 2699, 13824, 2701, 13822, 2703, 13820, 2705, 13818, 2707, 13816, 2709, 13814, 2711, 13812, 2713, 13810, 2715, 13808, 2717, 13806, 2719, 13804, 2721, 13802, 2723, 13800, 2725, 13798, 2727, 13796, 2729, 13794, 2731, 13792, 2733, 13790, 2735, 13788, 2737, 13786, 2739, 13784, 2741, 13782, 2743, 13780, 2745, 13778, 2747, 13776, 2749, 13774, 2751, 13772, 2753, 13770, 2755, 13768, 2757, 13766, 2759, 13764, 2761, 13762, 2763, 13760, 2765, 13758, 2767, 13756, 2769, 13754, 2771, 13752, 2773, 13750, 2775, 13748, 2777, 13746, 2779, 13744, 2781, 13742, 2783, 13740, 2785, 13738, 2787, 13736, 2789, 13734, 2791, 13732, 2793, 13730, 2795, 13728, 2797, 13726, 2799, 13724, 2801, 13722, 2803, 13720, 2805, 13718, 2807, 13716, 2809, 13714, 2811, 13712, 2813, 13710, 2815, 13708, 2817, 13706, 2819, 13704, 2821, 13702, 2823, 13700, 2825, 13698, 2827, 13696, 2829, 13694, 2831, 13692, 2833, 13690, 2835, 13688, 2837, 13686, 2839, 13684, 2841, 13682, 2843, 13680, 2845, 13678, 2847, 13676, 2849, 13674, 2851, 13672, 2853, 13670, 2855, 13668, 2857, 13666, 2859, 13664, 2861, 13662, 2863, 13660, 2865, 13658, 2867, 13656, 2869, 13654, 2871, 13652, 2873, 13650, 2875, 13648, 2877, 13646, 2879, 13644, 2881, 13642, 2883, 13640, 2885, 13638, 2887, 13636, 2889, 13634, 2891, 13632, 2893, 13630, 2895, 13628, 2897, 13626, 2899, 13624, 2901, 13622, 2903, 13620, 2905, 13618, 2907, 13616, 2909, 13614, 2911, 13612, 2913, 13610, 2915, 13608, 2917, 13606, 2919, 13604, 2921, 13602, 2923, 13600, 2925, 13598, 2927, 13596, 2929, 13594, 2931, 13592, 2933, 13590, 2935, 13588, 2937, 13586, 2939, 13584, 2941, 13582, 2943, 13580, 2945, 13578, 2947, 13576, 2949, 13574, 2951, 13572, 2953, 13570, 2955, 13568, 2957, 13566, 2959, 13564, 2961, 13562, 2963, 13560, 2965, 13558, 2967, 13556, 2969, 13554, 2971, 13552, 2973, 13550, 2975, 13548, 2977, 13546, 2979, 13544, 2981, 13542, 2983, 13540, 2985, 13538, 2987, 13536, 2989, 13534, 2991, 13532, 2993, 13530, 2995, 13528, 2997, 13526, 2999, 13524, 3001, 13522, 3003, 13520, 3005, 13518, 3007, 13516, 3009, 13514, 3011, 13512, 3013, 13510, 3015, 13508, 3017, 13506, 3019, 13504, 3021, 13502, 3023, 13500, 3025, 13498, 3027, 13496, 3029, 13494, 3031, 13492, 3033, 13490, 3035, 13488, 3037, 13486, 3039, 13484, 3041, 13482, 3043, 13480, 3045, 13478, 3047, 13476, 3049, 13474, 3051, 13472, 3053, 13470, 3055, 13468, 3057, 13466, 3059, 13464, 3061, 13462, 3063, 13460, 3065, 13458, 3067, 13456, 3069, 13454, 3071, 13452, 3073, 13450, 3075, 13448, 3077, 13446, 3079, 13444, 3081, 13442, 3083, 13440, 3085, 13438, 3087, 13436, 3089, 13434, 3091, 13432, 3093, 13430, 3095, 13428, 3097, 13426, 3099, 13424, 3101, 13422, 3103, 13420, 3105, 13418, 3107, 13416, 3109, 13414, 3111, 13412, 3113, 13410, 3115, 13408, 3117, 13406, 3119, 13404, 3121, 13402, 3123, 13400, 3125, 13398, 3127, 13396, 3129, 13394, 3131, 13392, 3133, 13390, 3135, 13388, 3137, 13386, 3139, 13384, 3141, 13382, 3143, 13380, 3145, 13378, 3147, 13376, 3149, 13374, 3151, 13372, 3153, 13370, 3155, 13368, 3157, 13366, 3159, 13364, 3161, 13362, 3163, 13360, 3165, 13358, 3167, 13356, 3169, 13354, 3171, 13352, 3173, 13350, 3175, 13348, 3177, 13346, 3179, 13344, 3181, 13342, 3183, 13340, 3185, 13338, 3187, 13336, 3189, 13334, 3191, 13332, 3193, 13330, 3195, 13328, 3197, 13326, 3199, 13324, 3201, 13322, 3203, 13320, 3205, 13318, 3207, 13316, 3209, 13314, 3211, 13312, 3213, 13310, 3215, 13308, 3217, 13306, 3219, 13304, 3221, 13302, 3223, 13300, 3225, 13298, 3227, 13296, 3229, 13294, 3231, 13292, 3233, 13290, 3235, 13288, 3237, 13286, 3239, 13284, 3241, 13282, 3243, 13280, 3245, 13278, 3247, 13276, 3249, 13274, 3251, 13272, 3253, 13270, 3255, 13268, 3257, 13266, 3259, 13264, 3261, 13262, 3263, 13260, 3265, 13258, 3267, 13256, 3269, 13254, 3271, 13252, 3273, 13250, 3275, 13248, 3277, 13246, 3279, 13244, 3281, 13242, 3283, 13240, 3285, 13238, 3287, 13236, 3289, 13234, 3291, 13232, 3293, 13230, 3295, 13228, 3297, 13226, 3299, 13224, 3301, 13222, 3303, 13220, 3305, 13218, 3307, 13216, 3309, 13214, 3311, 13212, 3313, 13210, 3315, 13208, 3317, 13206, 3319, 13204, 3321, 13202, 3323, 13200, 3325, 13198, 3327, 13196, 3329, 13194, 3331, 13192, 3333, 13190, 3335, 13188, 3337, 13186, 3339, 13184, 3341, 13182, 3343, 13180, 3345, 13178, 3347, 13176, 3349, 13174, 3351, 13172, 3353, 13170, 3355, 13168, 3357, 13166, 3359, 13164, 3361, 13162, 3363, 13160, 3365, 13158, 3367, 13156, 3369, 13154, 3371, 13152, 3373, 13150, 3375, 13148, 3377, 13146, 3379, 13144, 3381, 13142, 3383, 13140, 3385, 13138, 3387, 13136, 3389, 13134, 3391, 13132, 3393, 13130, 3395, 13128, 3397, 13126, 3399, 13124, 3401, 13122, 3403, 13120, 3405, 13118, 3407, 13116, 3409, 13114, 3411, 13112, 3413, 13110, 3415, 13108, 3417, 13106, 3419, 13104, 3421, 13102, 3423, 13100, 3425, 13098, 3427, 13096, 3429, 13094, 3431, 13092, 3433, 13090, 3435, 13088, 3437, 13086, 3439, 13084, 3441, 13082, 3443, 13080, 3445, 13078, 3447, 13076, 3449, 13074, 3451, 13072, 3453, 13070, 3455, 13068, 3457, 13066, 3459, 13064, 3461, 13062, 3463, 13060, 3465, 13058, 3467, 13056, 3469, 13054, 3471, 13052, 3473, 13050, 3475, 13048, 3477, 13046, 3479, 13044, 3481, 13042, 3483, 13040, 3485, 13038, 3487, 13036, 3489, 13034, 3491, 13032, 3493, 13030, 3495, 13028, 3497, 13026, 3499, 13024, 3501, 13022, 3503, 13020, 3505, 13018, 3507, 13016, 3509, 13014, 3511, 13012, 3513, 13010, 3515, 13008, 3517, 13006, 3519, 13004, 3521, 13002, 3523, 13000, 3525, 12998, 3527, 12996, 3529, 12994, 3531, 12992, 3533, 12990, 3535, 12988, 3537, 12986, 3539, 12984, 3541, 12982, 3543, 12980, 3545, 12978, 3547, 12976, 3549, 12974, 3551, 12972, 3553, 12970, 3555, 12968, 3557, 12966, 3559, 12964, 3561, 12962, 3563, 12960, 3565, 12958, 3567, 12956, 3569, 12954, 3571, 12952, 3573, 12950, 3575, 12948, 3577, 12946, 3579, 12944, 3581, 12942, 3583, 12940, 3585, 12938, 3587, 12936, 3589, 12934, 3591, 12932, 3593, 12930, 3595, 12928, 3597, 12926, 3599, 12924, 3601, 12922, 3603, 12920, 3605, 12918, 3607, 12916, 3609, 12914, 3611, 12912, 3613, 12910, 3615, 12908, 3617, 12906, 3619, 12904, 3621, 12902, 3623, 12900, 3625, 12898, 3627, 12896, 3629, 12894, 3631, 12892, 3633, 12890, 3635, 12888, 3637, 12886, 3639, 12884, 3641, 12882, 3643, 12880, 3645, 12878, 3647, 12876, 3649, 12874, 3651, 12872, 3653, 12870, 3655, 12868, 3657, 12866, 3659, 12864, 3661, 12862, 3663, 12860, 3665, 12858, 3667, 12856, 3669, 12854, 3671, 12852, 3673, 12850, 3675, 12848, 3677, 12846, 3679, 12844, 3681, 12842, 3683, 12840, 3685, 12838, 3687, 12836, 3689, 12834, 3691, 12832, 3693, 12830, 3695, 12828, 3697, 12826, 3699, 12824, 3701, 12822, 3703, 12820, 3705, 12818, 3707, 12816, 3709, 12814, 3711, 12812, 3713, 12810, 3715, 12808, 3717, 12806, 3719, 12804, 3721, 12802, 3723, 12800, 3725, 12798, 3727, 12796, 3729, 12794, 3731, 12792, 3733, 12790, 3735, 12788, 3737, 12786, 3739, 12784, 3741, 12782, 3743, 12780, 3745, 12778, 3747, 12776, 3749, 12774, 3751, 12772, 3753, 12770, 3755, 12768, 3757, 12766, 3759, 12764, 3761, 12762, 3763, 12760, 3765, 12758, 3767, 12756, 3769, 12754, 3771, 12752, 3773, 12750, 3775, 12748, 3777, 12746, 3779, 12744, 3781, 12742, 3783, 12740, 3785, 12738, 3787, 12736, 3789, 12734, 3791, 12732, 3793, 12730, 3795, 12728, 3797, 12726, 3799, 12724, 3801, 12722, 3803, 12720, 3805, 12718, 3807, 12716, 3809, 12714, 3811, 12712, 3813, 12710, 3815, 12708, 3817, 12706, 3819, 12704, 3821, 12702, 3823, 12700, 3825, 12698, 3827, 12696, 3829, 12694, 3831, 12692, 3833, 12690, 3835, 12688, 3837, 12686, 3839, 12684, 3841, 12682, 3843, 12680, 3845, 12678, 3847, 12676, 3849, 12674, 3851, 12672, 3853, 12670, 3855, 12668, 3857, 12666, 3859, 12664, 3861, 12662, 3863, 12660, 3865, 12658, 3867, 12656, 3869, 12654, 3871, 12652, 3873, 12650, 3875, 12648, 3877, 12646, 3879, 12644, 3881, 12642, 3883, 12640, 3885, 12638, 3887, 12636, 3889, 12634, 3891, 12632, 3893, 12630, 3895, 12628, 3897, 12626, 3899, 12624, 3901, 12622, 3903, 12620, 3905, 12618, 3907, 12616, 3909, 12614, 3911, 12612, 3913, 12610, 3915, 12608, 3917, 12606, 3919, 12604, 3921, 12602, 3923, 12600, 3925, 12598, 3927, 12596, 3929, 12594, 3931, 12592, 3933, 12590, 3935, 12588, 3937, 12586, 3939, 12584, 3941, 12582, 3943, 12580, 3945, 12578, 3947, 12576, 3949, 12574, 3951, 12572, 3953, 12570, 3955, 12568, 3957, 12566, 3959, 12564, 3961, 12562, 3963, 12560, 3965, 12558, 3967, 12556, 3969, 12554, 3971, 12552, 3973, 12550, 3975, 12548, 3977, 12546, 3979, 12544, 3981, 12542, 3983, 12540, 3985, 12538, 3987, 12536, 3989, 12534, 3991, 12532, 3993, 12530, 3995, 12528, 3997, 12526, 3999, 12524, 4001, 12522, 4003, 12520, 4005, 12518, 4007, 12516, 4009, 12514, 4011, 12512, 4013, 12510, 4015, 12508, 4017, 12506, 4019, 12504, 4021, 12502, 4023, 12500, 4025, 12498, 4027, 12496, 4029, 12494, 4031, 12492, 4033, 12490, 4035, 12488, 4037, 12486, 4039, 12484, 4041, 12482, 4043, 12480, 4045, 12478, 4047, 12476, 4049, 12474, 4051, 12472, 4053, 12470, 4055, 12468, 4057, 12466, 4059, 12464, 4061, 12462, 4063, 12460, 4065, 12458, 4067, 12456, 4069, 12454, 4071, 12452, 4073, 12450, 4075, 12448, 4077, 12446, 4079, 12444, 4081, 12442, 4083, 12440, 4085, 12438, 4087, 12436, 4089, 12434, 4091, 12432, 4093, 12430, 4095, 12428, 4097, 12426, 4099, 12424, 4101, 12422, 4103, 12420, 4105, 12418, 4107, 12416, 4109, 12414, 4111, 12412, 4113, 12410, 4115, 12408, 4117, 12406, 4119, 12404, 4121, 12402, 4123, 12400, 4125, 12398, 4127, 12396, 4129, 12394, 4131, 12392, 4133, 12390, 4135, 12388, 4137, 12386, 4139, 12384, 4141, 12382, 4143, 12380, 4145, 12378, 4147, 12376, 4149, 12374, 4151, 12372, 4153, 12370, 4155, 12368, 4157, 12366, 4159, 12364, 4161, 12362, 4163, 12360, 4165, 12358, 4167, 12356, 4169, 12354, 4171, 12352, 4173, 12350, 4175, 12348, 4177, 12346, 4179, 12344, 4181, 12342, 4183, 12340, 4185, 12338, 4187, 12336, 4189, 12334, 4191, 12332, 4193, 12330, 4195, 12328, 4197, 12326, 4199, 12324, 4201, 12322, 4203, 12320, 4205, 12318, 4207, 12316, 4209, 12314, 4211, 12312, 4213, 12310, 4215, 12308, 4217, 12306, 4219, 12304, 4221, 12302, 4223, 12300, 4225, 12298, 4227, 12296, 4229, 12294, 4231, 12292, 4233, 12290, 4235, 12288, 4237, 12286, 4239, 12284, 4241, 12282, 4243, 12280, 4245, 12278, 4247, 12276, 4249, 12274, 4251, 12272, 4253, 12270, 4255, 12268, 4257, 12266, 4259, 12264, 4261, 12262, 4263, 12260, 4265, 12258, 4267, 12256, 4269, 12254, 4271, 12252, 4273, 12250, 4275, 12248, 4277, 12246, 4279, 12244, 4281, 12242, 4283, 12240, 4285, 12238, 4287, 12236, 4289, 12234, 4291, 12232, 4293, 12230, 4295, 12228, 4297, 12226, 4299, 12224, 4301, 12222, 4303, 12220, 4305, 12218, 4307, 12216, 4309, 12214, 4311, 12212, 4313, 12210, 4315, 12208, 4317, 12206, 4319, 12204, 4321, 12202, 4323, 12200, 4325, 12198, 4327, 12196, 4329, 12194, 4331, 12192, 4333, 12190, 4335, 12188, 4337, 12186, 4339, 12184, 4341, 12182, 4343, 12180, 4345, 12178, 4347, 12176, 4349, 12174, 4351, 12172, 4353, 12170, 4355, 12168, 4357, 12166, 4359, 12164, 4361, 12162, 4363, 12160, 4365, 12158, 4367, 12156, 4369, 12154, 4371, 12152, 4373, 12150, 4375, 12148, 4377, 12146, 4379, 12144, 4381, 12142, 4383, 12140, 4385, 12138, 4387, 12136, 4389, 12134, 4391, 12132, 4393, 12130, 4395, 12128, 4397, 12126, 4399, 12124, 4401, 12122, 4403, 12120, 4405, 12118, 4407, 12116, 4409, 12114, 4411, 12112, 4413, 12110, 4415, 12108, 4417, 12106, 4419, 12104, 4421, 12102, 4423, 12100, 4425, 12098, 4427, 12096, 4429, 12094, 4431, 12092, 4433, 12090, 4435, 12088, 4437, 12086, 4439, 12084, 4441, 12082, 4443, 12080, 4445, 12078, 4447, 12076, 4449, 12074, 4451, 12072, 4453, 12070, 4455, 12068, 4457, 12066, 4459, 12064, 4461, 12062, 4463, 12060, 4465, 12058, 4467, 12056, 4469, 12054, 4471, 12052, 4473, 12050, 4475, 12048, 4477, 12046, 4479, 12044, 4481, 12042, 4483, 12040, 4485, 12038, 4487, 12036, 4489, 12034, 4491, 12032, 4493, 12030, 4495, 12028, 4497, 12026, 4499, 12024, 4501, 12022, 4503, 12020, 4505, 12018, 4507, 12016, 4509, 12014, 4511, 12012, 4513, 12010, 4515, 12008, 4517, 12006, 4519, 12004, 4521, 12002, 4523, 12000, 4525, 11998, 4527, 11996, 4529, 11994, 4531, 11992, 4533, 11990, 4535, 11988, 4537, 11986, 4539, 11984, 4541, 11982, 4543, 11980, 4545, 11978, 4547, 11976, 4549, 11974, 4551, 11972, 4553, 11970, 4555, 11968, 4557, 11966, 4559, 11964, 4561, 11962, 4563, 11960, 4565, 11958, 4567, 11956, 4569, 11954, 4571, 11952, 4573, 11950, 4575, 11948, 4577, 11946, 4579, 11944, 4581, 11942, 4583, 11940, 4585, 11938, 4587, 11936, 4589, 11934, 4591, 11932, 4593, 11930, 4595, 11928, 4597, 11926, 4599, 11924, 4601, 11922, 4603, 11920, 4605, 11918, 4607, 11916, 4609, 11914, 4611, 11912, 4613, 11910, 4615, 11908, 4617, 11906, 4619, 11904, 4621, 11902, 4623, 11900, 4625, 11898, 4627, 11896, 4629, 11894, 4631, 11892, 4633, 11890, 4635, 11888, 4637, 11886, 4639, 11884, 4641, 11882, 4643, 11880, 4645, 11878, 4647, 11876, 4649, 11874, 4651, 11872, 4653, 11870, 4655, 11868, 4657, 11866, 4659, 11864, 4661, 11862, 4663, 11860, 4665, 11858, 4667, 11856, 4669, 11854, 4671, 11852, 4673, 11850, 4675, 11848, 4677, 11846, 4679, 11844, 4681, 11842, 4683, 11840, 4685, 11838, 4687, 11836, 4689, 11834, 4691, 11832, 4693, 11830, 4695, 11828, 4697, 11826, 4699, 11824, 4701, 11822, 4703, 11820, 4705, 11818, 4707, 11816, 4709, 11814, 4711, 11812, 4713, 11810, 4715, 11808, 4717, 11806, 4719, 11804, 4721, 11802, 4723, 11800, 4725, 11798, 4727, 11796, 4729, 11794, 4731, 11792, 4733, 11790, 4735, 11788, 4737, 11786, 4739, 11784, 4741, 11782, 4743, 11780, 4745, 11778, 4747, 11776, 4749, 11774, 4751, 11772, 4753, 11770, 4755, 11768, 4757, 11766, 4759, 11764, 4761, 11762, 4763, 11760, 4765, 11758, 4767, 11756, 4769, 11754, 4771, 11752, 4773, 11750, 4775, 11748, 4777, 11746, 4779, 11744, 4781, 11742, 4783, 11740, 4785, 11738, 4787, 11736, 4789, 11734, 4791, 11732, 4793, 11730, 4795, 11728, 4797, 11726, 4799, 11724, 4801, 11722, 4803, 11720, 4805, 11718, 4807, 11716, 4809, 11714, 4811, 11712, 4813, 11710, 4815, 11708, 4817, 11706, 4819, 11704, 4821, 11702, 4823, 11700, 4825, 11698, 4827, 11696, 4829, 11694, 4831, 11692, 4833, 11690, 4835, 11688, 4837, 11686, 4839, 11684, 4841, 11682, 4843, 11680, 4845, 11678, 4847, 11676, 4849, 11674, 4851, 11672, 4853, 11670, 4855, 11668, 4857, 11666, 4859, 11664, 4861, 11662, 4863, 11660, 4865, 11658, 4867, 11656, 4869, 11654, 4871, 11652, 4873, 11650, 4875, 11648, 4877, 11646, 4879, 11644, 4881, 11642, 4883, 11640, 4885, 11638, 4887, 11636, 4889, 11634, 4891, 11632, 4893, 11630, 4895, 11628, 4897, 11626, 4899, 11624, 4901, 11622, 4903, 11620, 4905, 11618, 4907, 11616, 4909, 11614, 4911, 11612, 4913, 11610, 4915, 11608, 4917, 11606, 4919, 11604, 4921, 11602, 4923, 11600, 4925, 11598, 4927, 11596, 4929, 11594, 4931, 11592, 4933, 11590, 4935, 11588, 4937, 11586, 4939, 11584, 4941, 11582, 4943, 11580, 4945, 11578, 4947, 11576, 4949, 11574, 4951, 11572, 4953, 11570, 4955, 11568, 4957, 11566, 4959, 11564, 4961, 11562, 4963, 11560, 4965, 11558, 4967, 11556, 4969, 11554, 4971, 11552, 4973, 11550, 4975, 11548, 4977, 11546, 4979, 11544, 4981, 11542, 4983, 11540, 4985, 11538, 4987, 11536, 4989, 11534, 4991, 11532, 4993, 11530, 4995, 11528, 4997, 11526, 4999, 11524, 5001, 11522, 5003, 11520, 5005, 11518, 5007, 11516, 5009, 11514, 5011, 11512, 5013, 11510, 5015, 11508, 5017, 11506, 5019, 11504, 5021, 11502, 5023, 11500, 5025, 11498, 5027, 11496, 5029, 11494, 5031, 11492, 5033, 11490, 5035, 11488, 5037, 11486, 5039, 11484, 5041, 11482, 5043, 11480, 5045, 11478, 5047, 11476, 5049, 11474, 5051, 11472, 5053, 11470, 5055, 11468, 5057, 11466, 5059, 11464, 5061, 11462, 5063, 11460, 5065, 11458, 5067, 11456, 5069, 11454, 5071, 11452, 5073, 11450, 5075, 11448, 5077, 11446, 5079, 11444, 5081, 11442, 5083, 11440, 5085, 11438, 5087, 11436, 5089, 11434, 5091, 11432, 5093, 11430, 5095, 11428, 5097, 11426, 5099, 11424, 5101, 11422, 5103, 11420, 5105, 11418, 5107, 11416, 5109, 11414, 5111, 11412, 5113, 11410, 5115, 11408, 5117, 11406, 5119, 11404, 5121, 11402, 5123, 11400, 5125, 11398, 5127, 11396, 5129, 11394, 5131, 11392, 5133, 11390, 5135, 11388, 5137, 11386, 5139, 11384, 5141, 11382, 5143, 11380, 5145, 11378, 5147, 11376, 5149, 11374, 5151, 11372, 5153, 11370, 5155, 11368, 5157, 11366, 5159, 11364, 5161, 11362, 5163, 11360, 5165, 11358, 5167, 11356, 5169, 11354, 5171, 11352, 5173, 11350, 5175, 11348, 5177, 11346, 5179, 11344, 5181, 11342, 5183, 11340, 5185, 11338, 5187, 11336, 5189, 11334, 5191, 11332, 5193, 11330, 5195, 11328, 5197, 11326, 5199, 11324, 5201, 11322, 5203, 11320, 5205, 11318, 5207, 11316, 5209, 11314, 5211, 11312, 5213, 11310, 5215, 11308, 5217, 11306, 5219, 11304, 5221, 11302, 5223, 11300, 5225, 11298, 5227, 11296, 5229, 11294, 5231, 11292, 5233, 11290, 5235, 11288, 5237, 11286, 5239, 11284, 5241, 11282, 5243, 11280, 5245, 11278, 5247, 11276, 5249, 11274, 5251, 11272, 5253, 11270, 5255, 11268, 5257, 11266, 5259, 11264, 5261, 11262, 5263, 11260, 5265, 11258, 5267, 11256, 5269, 11254, 5271, 11252, 5273, 11250, 5275, 11248, 5277, 11246, 5279, 11244, 5281, 11242, 5283, 11240, 5285, 11238, 5287, 11236, 5289, 11234, 5291, 11232, 5293, 11230, 5295, 11228, 5297, 11226, 5299, 11224, 5301, 11222, 5303, 11220, 5305, 11218, 5307, 11216, 5309, 11214, 5311, 11212, 5313, 11210, 5315, 11208, 5317, 11206, 5319, 11204, 5321, 11202, 5323, 11200, 5325, 11198, 5327, 11196, 5329, 11194, 5331, 11192, 5333, 11190, 5335, 11188, 5337, 11186, 5339, 11184, 5341, 11182, 5343, 11180, 5345, 11178, 5347, 11176, 5349, 11174, 5351, 11172, 5353, 11170, 5355, 11168, 5357, 11166, 5359, 11164, 5361, 11162, 5363, 11160, 5365, 11158, 5367, 11156, 5369, 11154, 5371, 11152, 5373, 11150, 5375, 11148, 5377, 11146, 5379, 11144, 5381, 11142, 5383, 11140, 5385, 11138, 5387, 11136, 5389, 11134, 5391, 11132, 5393, 11130, 5395, 11128, 5397, 11126, 5399, 11124, 5401, 11122, 5403, 11120, 5405, 11118, 5407, 11116, 5409, 11114, 5411, 11112, 5413, 11110, 5415, 11108, 5417, 11106, 5419, 11104, 5421, 11102, 5423, 11100, 5425, 11098, 5427, 11096, 5429, 11094, 5431, 11092, 5433, 11090, 5435, 11088, 5437, 11086, 5439, 11084, 5441, 11082, 5443, 11080, 5445, 11078, 5447, 11076, 5449, 11074, 5451, 11072, 5453, 11070, 5455, 11068, 5457, 11066, 5459, 11064, 5461, 11062, 5463, 11060, 5465, 11058, 5467, 11056, 5469, 11054, 5471, 11052, 5473, 11050, 5475, 11048, 5477, 11046, 5479, 11044, 5481, 11042, 5483, 11040, 5485, 11038, 5487, 11036, 5489, 11034, 5491, 11032, 5493, 11030, 5495, 11028, 5497, 11026, 5499, 11024, 5501, 11022, 5503, 11020, 5505, 11018, 5507, 11016, 5509, 11014, 5511, 11012, 5513, 11010, 5515, 11008, 5517, 11006, 5519, 11004, 5521, 11002, 5523, 11000, 5525, 10998, 5527, 10996, 5529, 10994, 5531, 10992, 5533, 10990, 5535, 10988, 5537, 10986, 5539, 10984, 5541, 10982, 5543, 10980, 5545, 10978, 5547, 10976, 5549, 10974, 5551, 10972, 5553, 10970, 5555, 10968, 5557, 10966, 5559, 10964, 5561, 10962, 5563, 10960, 5565, 10958, 5567, 10956, 5569, 10954, 5571, 10952, 5573, 10950, 5575, 10948, 5577, 10946, 5579, 10944, 5581, 10942, 5583, 10940, 5585, 10938, 5587, 10936, 5589, 10934, 5591, 10932, 5593, 10930, 5595, 10928, 5597, 10926, 5599, 10924, 5601, 10922, 5603, 10920, 5605, 10918, 5607, 10916, 5609, 10914, 5611, 10912, 5613, 10910, 5615, 10908, 5617, 10906, 5619, 10904, 5621, 10902, 5623, 10900, 5625, 10898, 5627, 10896, 5629, 10894, 5631, 10892, 5633, 10890, 5635, 10888, 5637, 10886, 5639, 10884, 5641, 10882, 5643, 10880, 5645, 10878, 5647, 10876, 5649, 10874, 5651, 10872, 5653, 10870, 5655, 10868, 5657, 10866, 5659, 10864, 5661, 10862, 5663, 10860, 5665, 10858, 5667, 10856, 5669, 10854, 5671, 10852, 5673, 10850, 5675, 10848, 5677, 10846, 5679, 10844, 5681, 10842, 5683, 10840, 5685, 10838, 5687, 10836, 5689, 10834, 5691, 10832, 5693, 10830, 5695, 10828, 5697, 10826, 5699, 10824, 5701, 10822, 5703, 10820, 5705, 10818, 5707, 10816, 5709, 10814, 5711, 10812, 5713, 10810, 5715, 10808, 5717, 10806, 5719, 10804, 5721, 10802, 5723, 10800, 5725, 10798, 5727, 10796, 5729, 10794, 5731, 10792, 5733, 10790, 5735, 10788, 5737, 10786, 5739, 10784, 5741, 10782, 5743, 10780, 5745, 10778, 5747, 10776, 5749, 10774, 5751, 10772, 5753, 10770, 5755, 10768, 5757, 10766, 5759, 10764, 5761, 10762, 5763, 10760, 5765, 10758, 5767, 10756, 5769, 10754, 5771, 10752, 5773, 10750, 5775, 10748, 5777, 10746, 5779, 10744, 5781, 10742, 5783, 10740, 5785, 10738, 5787, 10736, 5789, 10734, 5791, 10732, 5793, 10730, 5795, 10728, 5797, 10726, 5799, 10724, 5801, 10722, 5803, 10720, 5805, 10718, 5807, 10716, 5809, 10714, 5811, 10712, 5813, 10710, 5815, 10708, 5817, 10706, 5819, 10704, 5821, 10702, 5823, 10700, 5825, 10698, 5827, 10696, 5829, 10694, 5831, 10692, 5833, 10690, 5835, 10688, 5837, 10686, 5839, 10684, 5841, 10682, 5843, 10680, 5845, 10678, 5847, 10676, 5849, 10674, 5851, 10672, 5853, 10670, 5855, 10668, 5857, 10666, 5859, 10664, 5861, 10662, 5863, 10660, 5865, 10658, 5867, 10656, 5869, 10654, 5871, 10652, 5873, 10650, 5875, 10648, 5877, 10646, 5879, 10644, 5881, 10642, 5883, 10640, 5885, 10638, 5887, 10636, 5889, 10634, 5891, 10632, 5893, 10630, 5895, 10628, 5897, 10626, 5899, 10624, 5901, 10622, 5903, 10620, 5905, 10618, 5907, 10616, 5909, 10614, 5911, 10612, 5913, 10610, 5915, 10608, 5917, 10606, 5919, 10604, 5921, 10602, 5923, 10600, 5925, 10598, 5927, 10596, 5929, 10594, 5931, 10592, 5933, 10590, 5935, 10588, 5937, 10586, 5939, 10584, 5941, 10582, 5943, 10580, 5945, 10578, 5947, 10576, 5949, 10574, 5951, 10572, 5953, 10570, 5955, 10568, 5957, 10566, 5959, 10564, 5961, 10562, 5963, 10560, 5965, 10558, 5967, 10556, 5969, 10554, 5971, 10552, 5973, 10550, 5975, 10548, 5977, 10546, 5979, 10544, 5981, 10542, 5983, 10540, 5985, 10538, 5987, 10536, 5989, 10534, 5991, 10532, 5993, 10530, 5995, 10528, 5997, 10526, 5999, 10524, 6001, 10522, 6003, 10520, 6005, 10518, 6007, 10516, 6009, 10514, 6011, 10512, 6013, 10510, 6015, 10508, 6017, 10506, 6019, 10504, 6021, 10502, 6023, 10500, 6025, 10498, 6027, 10496, 6029, 10494, 6031, 10492, 6033, 10490, 6035, 10488, 6037, 10486, 6039, 10484, 6041, 10482, 6043, 10480, 6045, 10478, 6047, 10476, 6049, 10474, 6051, 10472, 6053, 10470, 6055, 10468, 6057, 10466, 6059, 10464, 6061, 10462, 6063, 10460, 6065, 10458, 6067, 10456, 6069, 10454, 6071, 10452, 6073, 10450, 6075, 10448, 6077, 10446, 6079, 10444, 6081, 10442, 6083, 10440, 6085, 10438, 6087, 10436, 6089, 10434, 6091, 10432, 6093, 10430, 6095, 10428, 6097, 10426, 6099, 10424, 6101, 10422, 6103, 10420, 6105, 10418, 6107, 10416, 6109, 10414, 6111, 10412, 6113, 10410, 6115, 10408, 6117, 10406, 6119, 10404, 6121, 10402, 6123, 10400, 6125, 10398, 6127, 10396, 6129, 10394, 6131, 10392, 6133, 10390, 6135, 10388, 6137, 10386, 6139, 10384, 6141, 10382, 6143, 10380, 6145, 10378, 6147, 10376, 6149, 10374, 6151, 10372, 6153, 10370, 6155, 10368, 6157, 10366, 6159, 10364, 6161, 10362, 6163, 10360, 6165, 10358, 6167, 10356, 6169, 10354, 6171, 10352, 6173, 10350, 6175, 10348, 6177, 10346, 6179, 10344, 6181, 10342, 6183, 10340, 6185, 10338, 6187, 10336, 6189, 10334, 6191, 10332, 6193, 10330, 6195, 10328, 6197, 10326, 6199, 10324, 6201, 10322, 6203, 10320, 6205, 10318, 6207, 10316, 6209, 10314, 6211, 10312, 6213, 10310, 6215, 10308, 6217, 10306, 6219, 10304, 6221, 10302, 6223, 10300, 6225, 10298, 6227, 10296, 6229, 10294, 6231, 10292, 6233, 10290, 6235, 10288, 6237, 10286, 6239, 10284, 6241, 10282, 6243, 10280, 6245, 10278, 6247, 10276, 6249, 10274, 6251, 10272, 6253, 10270, 6255, 10268, 6257, 10266, 6259, 10264, 6261, 10262, 6263, 10260, 6265, 10258, 6267, 10256, 6269, 10254, 6271, 10252, 6273, 10250, 6275, 10248, 6277, 10246, 6279, 10244, 6281, 10242, 6283, 10240, 6285, 10238, 6287, 10236, 6289, 10234, 6291, 10232, 6293, 10230, 6295, 10228, 6297, 10226, 6299, 10224, 6301, 10222, 6303, 10220, 6305, 10218, 6307, 10216, 6309, 10214, 6311, 10212, 6313, 10210, 6315, 10208, 6317, 10206, 6319, 10204, 6321, 10202, 6323, 10200, 6325, 10198, 6327, 10196, 6329, 10194, 6331, 10192, 6333, 10190, 6335, 10188, 6337, 10186, 6339, 10184, 6341, 10182, 6343, 10180, 6345, 10178, 6347, 10176, 6349, 10174, 6351, 10172, 6353, 10170, 6355, 10168, 6357, 10166, 6359, 10164, 6361, 10162, 6363, 10160, 6365, 10158, 6367, 10156, 6369, 10154, 6371, 10152, 6373, 10150, 6375, 10148, 6377, 10146, 6379, 10144, 6381, 10142, 6383, 10140, 6385, 10138, 6387, 10136, 6389, 10134, 6391, 10132, 6393, 10130, 6395, 10128, 6397, 10126, 6399, 10124, 6401, 10122, 6403, 10120, 6405, 10118, 6407, 10116, 6409, 10114, 6411, 10112, 6413, 10110, 6415, 10108, 6417, 10106, 6419, 10104, 6421, 10102, 6423, 10100, 6425, 10098, 6427, 10096, 6429, 10094, 6431, 10092, 6433, 10090, 6435, 10088, 6437, 10086, 6439, 10084, 6441, 10082, 6443, 10080, 6445, 10078, 6447, 10076, 6449, 10074, 6451, 10072, 6453, 10070, 6455, 10068, 6457, 10066, 6459, 10064, 6461, 10062, 6463, 10060, 6465, 10058, 6467, 10056, 6469, 10054, 6471, 10052, 6473, 10050, 6475, 10048, 6477, 10046, 6479, 10044, 6481, 10042, 6483, 10040, 6485, 10038, 6487, 10036, 6489, 10034, 6491, 10032, 6493, 10030, 6495, 10028, 6497, 10026, 6499, 10024, 6501, 10022, 6503, 10020, 6505, 10018, 6507, 10016, 6509, 10014, 6511, 10012, 6513, 10010, 6515, 10008, 6517, 10006, 6519, 10004, 6521, 10002, 6523, 10000, 6525, 9998, 6527, 9996, 6529, 9994, 6531, 9992, 6533, 9990, 6535, 9988, 6537, 9986, 6539, 9984, 6541, 9982, 6543, 9980, 6545, 9978, 6547, 9976, 6549, 9974, 6551, 9972, 6553, 9970, 6555, 9968, 6557, 9966, 6559, 9964, 6561, 9962, 6563, 9960, 6565, 9958, 6567, 9956, 6569, 9954, 6571, 9952, 6573, 9950, 6575, 9948, 6577, 9946, 6579, 9944, 6581, 9942, 6583, 9940, 6585, 9938, 6587, 9936, 6589, 9934, 6591, 9932, 6593, 9930, 6595, 9928, 6597, 9926, 6599, 9924, 6601, 9922, 6603, 9920, 6605, 9918, 6607, 9916, 6609, 9914, 6611, 9912, 6613, 9910, 6615, 9908, 6617, 9906, 6619, 9904, 6621, 9902, 6623, 9900, 6625, 9898, 6627, 9896, 6629, 9894, 6631, 9892, 6633, 9890, 6635, 9888, 6637, 9886, 6639, 9884, 6641, 9882, 6643, 9880, 6645, 9878, 6647, 9876, 6649, 9874, 6651, 9872, 6653, 9870, 6655, 9868, 6657, 9866, 6659, 9864, 6661, 9862, 6663, 9860, 6665, 9858, 6667, 9856, 6669, 9854, 6671, 9852, 6673, 9850, 6675, 9848, 6677, 9846, 6679, 9844, 6681, 9842, 6683, 9840, 6685, 9838, 6687, 9836, 6689, 9834, 6691, 9832, 6693, 9830, 6695, 9828, 6697, 9826, 6699, 9824, 6701, 9822, 6703, 9820, 6705, 9818, 6707, 9816, 6709, 9814, 6711, 9812, 6713, 9810, 6715, 9808, 6717, 9806, 6719, 9804, 6721, 9802, 6723, 9800, 6725, 9798, 6727, 9796, 6729, 9794, 6731, 9792, 6733, 9790, 6735, 9788, 6737, 9786, 6739, 9784, 6741, 9782, 6743, 9780, 6745, 9778, 6747, 9776, 6749, 9774, 6751, 9772, 6753, 9770, 6755, 9768, 6757, 9766, 6759, 9764, 6761, 9762, 6763, 9760, 6765, 9758, 6767, 9756, 6769, 9754, 6771, 9752, 6773, 9750, 6775, 9748, 6777, 9746, 6779, 9744, 6781, 9742, 6783, 9740, 6785, 9738, 6787, 9736, 6789, 9734, 6791, 9732, 6793, 9730, 6795, 9728, 6797, 9726, 6799, 9724, 6801, 9722, 6803, 9720, 6805, 9718, 6807, 9716, 6809, 9714, 6811, 9712, 6813, 9710, 6815, 9708, 6817, 9706, 6819, 9704, 6821, 9702, 6823, 9700, 6825, 9698, 6827, 9696, 6829, 9694, 6831, 9692, 6833, 9690, 6835, 9688, 6837, 9686, 6839, 9684, 6841, 9682, 6843, 9680, 6845, 9678, 6847, 9676, 6849, 9674, 6851, 9672, 6853, 9670, 6855, 9668, 6857, 9666, 6859, 9664, 6861, 9662, 6863, 9660, 6865, 9658, 6867, 9656, 6869, 9654, 6871, 9652, 6873, 9650, 6875, 9648, 6877, 9646, 6879, 9644, 6881, 9642, 6883, 9640, 6885, 9638, 6887, 9636, 6889, 9634, 6891, 9632, 6893, 9630, 6895, 9628, 6897, 9626, 6899, 9624, 6901, 9622, 6903, 9620, 6905, 9618, 6907, 9616, 6909, 9614, 6911, 9612, 6913, 9610, 6915, 9608, 6917, 9606, 6919, 9604, 6921, 9602, 6923, 9600, 6925, 9598, 6927, 9596, 6929, 9594, 6931, 9592, 6933, 9590, 6935, 9588, 6937, 9586, 6939, 9584, 6941, 9582, 6943, 9580, 6945, 9578, 6947, 9576, 6949, 9574, 6951, 9572, 6953, 9570, 6955, 9568, 6957, 9566, 6959, 9564, 6961, 9562, 6963, 9560, 6965, 9558, 6967, 9556, 6969, 9554, 6971, 9552, 6973, 9550, 6975, 9548, 6977, 9546, 6979, 9544, 6981, 9542, 6983, 9540, 6985, 9538, 6987, 9536, 6989, 9534, 6991, 9532, 6993, 9530, 6995, 9528, 6997, 9526, 6999, 9524, 7001, 9522, 7003, 9520, 7005, 9518, 7007, 9516, 7009, 9514, 7011, 9512, 7013, 9510, 7015, 9508, 7017, 9506, 7019, 9504, 7021, 9502, 7023, 9500, 7025, 9498, 7027, 9496, 7029, 9494, 7031, 9492, 7033, 9490, 7035, 9488, 7037, 9486, 7039, 9484, 7041, 9482, 7043, 9480, 7045, 9478, 7047, 9476, 7049, 9474, 7051, 9472, 7053, 9470, 7055, 9468, 7057, 9466, 7059, 9464, 7061, 9462, 7063, 9460, 7065, 9458, 7067, 9456, 7069, 9454, 7071, 9452, 7073, 9450, 7075, 9448, 7077, 9446, 7079, 9444, 7081, 9442, 7083, 9440, 7085, 9438, 7087, 9436, 7089, 9434, 7091, 9432, 7093, 9430, 7095, 9428, 7097, 9426, 7099, 9424, 7101, 9422, 7103, 9420, 7105, 9418, 7107, 9416, 7109, 9414, 7111, 9412, 7113, 9410, 7115, 9408, 7117, 9406, 7119, 9404, 7121, 9402, 7123, 9400, 7125, 9398, 7127, 9396, 7129, 9394, 7131, 9392, 7133, 9390, 7135, 9388, 7137, 9386, 7139, 9384, 7141, 9382, 7143, 9380, 7145, 9378, 7147, 9376, 7149, 9374, 7151, 9372, 7153, 9370, 7155, 9368, 7157, 9366, 7159, 9364, 7161, 9362, 7163, 9360, 7165, 9358, 7167, 9356, 7169, 9354, 7171, 9352, 7173, 9350, 7175, 9348, 7177, 9346, 7179, 9344, 7181, 9342, 7183, 9340, 7185, 9338, 7187, 9336, 7189, 9334, 7191, 9332, 7193, 9330, 7195, 9328, 7197, 9326, 7199, 9324, 7201, 9322, 7203, 9320, 7205, 9318, 7207, 9316, 7209, 9314, 7211, 9312, 7213, 9310, 7215, 9308, 7217, 9306, 7219, 9304, 7221, 9302, 7223, 9300, 7225, 9298, 7227, 9296, 7229, 9294, 7231, 9292, 7233, 9290, 7235, 9288, 7237, 9286, 7239, 9284, 7241, 9282, 7243, 9280, 7245, 9278, 7247, 9276, 7249, 9274, 7251, 9272, 7253, 9270, 7255, 9268, 7257, 9266, 7259, 9264, 7261, 9262, 7263, 9260, 7265, 9258, 7267, 9256, 7269, 9254, 7271, 9252, 7273, 9250, 7275, 9248, 7277, 9246, 7279, 9244, 7281, 9242, 7283, 9240, 7285, 9238, 7287, 9236, 7289, 9234, 7291, 9232, 7293, 9230, 7295, 9228, 7297, 9226, 7299, 9224, 7301, 9222, 7303, 9220, 7305, 9218, 7307, 9216, 7309, 9214, 7311, 9212, 7313, 9210, 7315, 9208, 7317, 9206, 7319, 9204, 7321, 9202, 7323, 9200, 7325, 9198, 7327, 9196, 7329, 9194, 7331, 9192, 7333, 9190, 7335, 9188, 7337, 9186, 7339, 9184, 7341, 9182, 7343, 9180, 7345, 9178, 7347, 9176, 7349, 9174, 7351, 9172, 7353, 9170, 7355, 9168, 7357, 9166, 7359, 9164, 7361, 9162, 7363, 9160, 7365, 9158, 7367, 9156, 7369, 9154, 7371, 9152, 7373, 9150, 7375, 9148, 7377, 9146, 7379, 9144, 7381, 9142, 7383, 9140, 7385, 9138, 7387, 9136, 7389, 9134, 7391, 9132, 7393, 9130, 7395, 9128, 7397, 9126, 7399, 9124, 7401, 9122, 7403, 9120, 7405, 9118, 7407, 9116, 7409, 9114, 7411, 9112, 7413, 9110, 7415, 9108, 7417, 9106, 7419, 9104, 7421, 9102, 7423, 9100, 7425, 9098, 7427, 9096, 7429, 9094, 7431, 9092, 7433, 9090, 7435, 9088, 7437, 9086, 7439, 9084, 7441, 9082, 7443, 9080, 7445, 9078, 7447, 9076, 7449, 9074, 7451, 9072, 7453, 9070, 7455, 9068, 7457, 9066, 7459, 9064, 7461, 9062, 7463, 9060, 7465, 9058, 7467, 9056, 7469, 9054, 7471, 9052, 7473, 9050, 7475, 9048, 7477, 9046, 7479, 9044, 7481, 9042, 7483, 9040, 7485, 9038, 7487, 9036, 7489, 9034, 7491, 9032, 7493, 9030, 7495, 9028, 7497, 9026, 7499, 9024, 7501, 9022, 7503, 9020, 7505, 9018, 7507, 9016, 7509, 9014, 7511, 9012, 7513, 9010, 7515, 9008, 7517, 9006, 7519, 9004, 7521, 9002, 7523, 9000, 7525, 8998, 7527, 8996, 7529, 8994, 7531, 8992, 7533, 8990, 7535, 8988, 7537, 8986, 7539, 8984, 7541, 8982, 7543, 8980, 7545, 8978, 7547, 8976, 7549, 8974, 7551, 8972, 7553, 8970, 7555, 8968, 7557, 8966, 7559, 8964, 7561, 8962, 7563, 8960, 7565, 8958, 7567, 8956, 7569, 8954, 7571, 8952, 7573, 8950, 7575, 8948, 7577, 8946, 7579, 8944, 7581, 8942, 7583, 8940, 7585, 8938, 7587, 8936, 7589, 8934, 7591, 8932, 7593, 8930, 7595, 8928, 7597, 8926, 7599, 8924, 7601, 8922, 7603, 8920, 7605, 8918, 7607, 8916, 7609, 8914, 7611, 8912, 7613, 8910, 7615, 8908, 7617, 8906, 7619, 8904, 7621, 8902, 7623, 8900, 7625, 8898, 7627, 8896, 7629, 8894, 7631, 8892, 7633, 8890, 7635, 8888, 7637, 8886, 7639, 8884, 7641, 8882, 7643, 8880, 7645, 8878, 7647, 8876, 7649, 8874, 7651, 8872, 7653, 8870, 7655, 8868, 7657, 8866, 7659, 8864, 7661, 8862, 7663, 8860, 7665, 8858, 7667, 8856, 7669, 8854, 7671, 8852, 7673, 8850, 7675, 8848, 7677, 8846, 7679, 8844, 7681, 8842, 7683, 8840, 7685, 8838, 7687, 8836, 7689, 8834, 7691, 8832, 7693, 8830, 7695, 8828, 7697, 8826, 7699, 8824, 7701, 8822, 7703, 8820, 7705, 8818, 7707, 8816, 7709, 8814, 7711, 8812, 7713, 8810, 7715, 8808, 7717, 8806, 7719, 8804, 7721, 8802, 7723, 8800, 7725, 8798, 7727, 8796, 7729, 8794, 7731, 8792, 7733, 8790, 7735, 8788, 7737, 8786, 7739, 8784, 7741, 8782, 7743, 8780, 7745, 8778, 7747, 8776, 7749, 8774, 7751, 8772, 7753, 8770, 7755, 8768, 7757, 8766, 7759, 8764, 7761, 8762, 7763, 8760, 7765, 8758, 7767, 8756, 7769, 8754, 7771, 8752, 7773, 8750, 7775, 8748, 7777, 8746, 7779, 8744, 7781, 8742, 7783, 8740, 7785, 8738, 7787, 8736, 7789, 8734, 7791, 8732, 7793, 8730, 7795, 8728, 7797, 8726, 7799, 8724, 7801, 8722, 7803, 8720, 7805, 8718, 7807, 8716, 7809, 8714, 7811, 8712, 7813, 8710, 7815, 8708, 7817, 8706, 7819, 8704, 7821, 8702, 7823, 8700, 7825, 8698, 7827, 8696, 7829, 8694, 7831, 8692, 7833, 8690, 7835, 8688, 7837, 8686, 7839, 8684, 7841, 8682, 7843, 8680, 7845, 8678, 7847, 8676, 7849, 8674, 7851, 8672, 7853, 8670, 7855, 8668, 7857, 8666, 7859, 8664, 7861, 8662, 7863, 8660, 7865, 8658, 7867, 8656, 7869, 8654, 7871, 8652, 7873, 8650, 7875, 8648, 7877, 8646, 7879, 8644, 7881, 8642, 7883, 8640, 7885, 8638, 7887, 8636, 7889, 8634, 7891, 8632, 7893, 8630, 7895, 8628, 7897, 8626, 7899, 8624, 7901, 8622, 7903, 8620, 7905, 8618, 7907, 8616, 7909, 8614, 7911, 8612, 7913, 8610, 7915, 8608, 7917, 8606, 7919, 8604, 7921, 8602, 7923, 8600, 7925, 8598, 7927, 8596, 7929, 8594, 7931, 8592, 7933, 8590, 7935, 8588, 7937, 8586, 7939, 8584, 7941, 8582, 7943, 8580, 7945, 8578, 7947, 8576, 7949, 8574, 7951, 8572, 7953, 8570, 7955, 8568, 7957, 8566, 7959, 8564, 7961, 8562, 7963, 8560, 7965, 8558, 7967, 8556, 7969, 8554, 7971, 8552, 7973, 8550, 7975, 8548, 7977, 8546, 7979, 8544, 7981, 8542, 7983, 8540, 7985, 8538, 7987, 8536, 7989, 8534, 7991, 8532, 7993, 8530, 7995, 8528, 7997, 8526, 7999, 8524, 8001, 8522, 8003, 8520, 8005, 8518, 8007, 8516, 8009, 8514, 8011, 8512, 8013, 8510, 8015, 8508, 8017, 8506, 8019, 8504, 8021, 8502, 8023, 8500, 8025, 8498, 8027, 8496, 8029, 8494, 8031, 8492, 8033, 8490, 8035, 8488, 8037, 8486, 8039, 8484, 8041, 8482, 8043, 8480, 8045, 8478, 8047, 8476, 8049, 8474, 8051, 8472, 8053, 8470, 8055, 8468, 8057, 8466, 8059, 8464, 8061, 8462, 8063, 8460, 8065, 8458, 8067, 8456, 8069, 8454, 8071, 8452, 8073, 8450, 8075, 8448, 8077, 8446, 8079, 8444, 8081, 8442, 8083, 8440, 8085, 8438, 8087, 8436, 8089, 8434, 8091, 8432, 8093, 8430, 8095, 8428, 8097, 8426, 8099, 8424, 8101, 8422, 8103, 8420, 8105, 8418, 8107, 8416, 8109, 8414, 8111, 8412, 8113, 8410, 8115, 8408, 8117, 8406, 8119, 8404, 8121, 8402, 8123, 8400, 8125, 8398, 8127, 8396, 8129, 8394, 8131, 8392, 8133, 8390, 8135, 8388, 8137, 8386, 8139, 8384, 8141, 8382, 8143, 8380, 8145, 8378, 8147, 8376, 8149, 8374, 8151, 8372, 8153, 8370, 8155, 8368, 8157, 8366, 8159, 8364, 8161, 8362, 8163, 8360, 8165, 8358, 8167, 8356, 8169, 8354, 8171, 8352, 8173, 8350, 8175, 8348, 8177, 8346, 8179, 8344, 8181, 8342, 8183, 8340, 8185, 8338, 8187, 8336, 8189, 8334, 8191, 8332, 8193, 8330, 8195, 8328, 8197, 8326, 8199, 8324, 8201, 8322, 8203, 8320, 8205, 8318, 8207, 8316, 8209, 8314, 8211, 8312, 8213, 8310, 8215, 8308, 8217, 8306, 8219, 8304, 8221, 8302, 8223, 8300, 8225, 8298, 8227, 8296, 8229, 8294, 8231, 8292, 8233, 8290, 8235, 8288, 8237, 8286, 8239, 8284, 8241, 8282, 8243, 8280, 8245, 8278, 8247, 8276, 8249, 8274, 8251, 8272, 8253, 8270, 8255, 8268, 8257, 8266, 8259, 8264, 8261, 8262, 8263, 8260, 8265, 8258, 8267, 8256, 8269, 8254, 8271, 8252, 8273, 8250, 8275, 8248, 8277, 8246, 8279, 8244, 8281, 8242, 8283, 8240, 8285, 8238, 8287, 8236, 8289, 8234, 8291, 8232, 8293, 8230, 8295, 8228, 8297, 8226, 8299, 8224, 8301, 8222, 8303, 8220, 8305, 8218, 8307, 8216, 8309, 8214, 8311, 8212, 8313, 8210, 8315, 8208, 8317, 8206, 8319, 8204, 8321, 8202, 8323, 8200, 8325, 8198, 8327, 8196, 8329, 8194, 8331, 8192, 8333, 8190, 8335, 8188, 8337, 8186, 8339, 8184, 8341, 8182, 8343, 8180, 8345, 8178, 8347, 8176, 8349, 8174, 8351, 8172, 8353, 8170, 8355, 8168, 8357, 8166, 8359, 8164, 8361, 8162, 8363, 8160, 8365, 8158, 8367, 8156, 8369, 8154, 8371, 8152, 8373, 8150, 8375, 8148, 8377, 8146, 8379, 8144, 8381, 8142, 8383, 8140, 8385, 8138, 8387, 8136, 8389, 8134, 8391, 8132, 8393, 8130, 8395, 8128, 8397, 8126, 8399, 8124, 8401, 8122, 8403, 8120, 8405, 8118, 8407, 8116, 8409, 8114, 8411, 8112, 8413, 8110, 8415, 8108, 8417, 8106, 8419, 8104, 8421, 8102, 8423, 8100, 8425, 8098, 8427, 8096, 8429, 8094, 8431, 8092, 8433, 8090, 8435, 8088, 8437, 8086, 8439, 8084, 8441, 8082, 8443, 8080, 8445, 8078, 8447, 8076, 8449, 8074, 8451, 8072, 8453, 8070, 8455, 8068, 8457, 8066, 8459, 8064, 8461, 8062, 8463, 8060, 8465, 8058, 8467, 8056, 8469, 8054, 8471, 8052, 8473, 8050, 8475, 8048, 8477, 8046, 8479, 8044, 8481, 8042, 8483, 8040, 8485, 8038, 8487, 8036, 8489, 8034, 8491, 8032, 8493, 8030, 8495, 8028, 8497, 8026, 8499, 8024, 8501, 8022, 8503, 8020, 8505, 8018, 8507, 8016, 8509, 8014, 8511, 8012, 8513, 8010, 8515, 8008, 8517, 8006, 8519, 8004, 8521, 8002, 8523, 8000, 8525, 7998, 8527, 7996, 8529, 7994, 8531, 7992, 8533, 7990, 8535, 7988, 8537, 7986, 8539, 7984, 8541, 7982, 8543, 7980, 8545, 7978, 8547, 7976, 8549, 7974, 8551, 7972, 8553, 7970, 8555, 7968, 8557, 7966, 8559, 7964, 8561, 7962, 8563, 7960, 8565, 7958, 8567, 7956, 8569, 7954, 8571, 7952, 8573, 7950, 8575, 7948, 8577, 7946, 8579, 7944, 8581, 7942, 8583, 7940, 8585, 7938, 8587, 7936, 8589, 7934, 8591, 7932, 8593, 7930, 8595, 7928, 8597, 7926, 8599, 7924, 8601, 7922, 8603, 7920, 8605, 7918, 8607, 7916, 8609, 7914, 8611, 7912, 8613, 7910, 8615, 7908, 8617, 7906, 8619, 7904, 8621, 7902, 8623, 7900, 8625, 7898, 8627, 7896, 8629, 7894, 8631, 7892, 8633, 7890, 8635, 7888, 8637, 7886, 8639, 7884, 8641, 7882, 8643, 7880, 8645, 7878, 8647, 7876, 8649, 7874, 8651, 7872, 8653, 7870, 8655, 7868, 8657, 7866, 8659, 7864, 8661, 7862, 8663, 7860, 8665, 7858, 8667, 7856, 8669, 7854, 8671, 7852, 8673, 7850, 8675, 7848, 8677, 7846, 8679, 7844, 8681, 7842, 8683, 7840, 8685, 7838, 8687, 7836, 8689, 7834, 8691, 7832, 8693, 7830, 8695, 7828, 8697, 7826, 8699, 7824, 8701, 7822, 8703, 7820, 8705, 7818, 8707, 7816, 8709, 7814, 8711, 7812, 8713, 7810, 8715, 7808, 8717, 7806, 8719, 7804, 8721, 7802, 8723, 7800, 8725, 7798, 8727, 7796, 8729, 7794, 8731, 7792, 8733, 7790, 8735, 7788, 8737, 7786, 8739, 7784, 8741, 7782, 8743, 7780, 8745, 7778, 8747, 7776, 8749, 7774, 8751, 7772, 8753, 7770, 8755, 7768, 8757, 7766, 8759, 7764, 8761, 7762, 8763, 7760, 8765, 7758, 8767, 7756, 8769, 7754, 8771, 7752, 8773, 7750, 8775, 7748, 8777, 7746, 8779, 7744, 8781, 7742, 8783, 7740, 8785, 7738, 8787, 7736, 8789, 7734, 8791, 7732, 8793, 7730, 8795, 7728, 8797, 7726, 8799, 7724, 8801, 7722, 8803, 7720, 8805, 7718, 8807, 7716, 8809, 7714, 8811, 7712, 8813, 7710, 8815, 7708, 8817, 7706, 8819, 7704, 8821, 7702, 8823, 7700, 8825, 7698, 8827, 7696, 8829, 7694, 8831, 7692, 8833, 7690, 8835, 7688, 8837, 7686, 8839, 7684, 8841, 7682, 8843, 7680, 8845, 7678, 8847, 7676, 8849, 7674, 8851, 7672, 8853, 7670, 8855, 7668, 8857, 7666, 8859, 7664, 8861, 7662, 8863, 7660, 8865, 7658, 8867, 7656, 8869, 7654, 8871, 7652, 8873, 7650, 8875, 7648, 8877, 7646, 8879, 7644, 8881, 7642, 8883, 7640, 8885, 7638, 8887, 7636, 8889, 7634, 8891, 7632, 8893, 7630, 8895, 7628, 8897, 7626, 8899, 7624, 8901, 7622, 8903, 7620, 8905, 7618, 8907, 7616, 8909, 7614, 8911, 7612, 8913, 7610, 8915, 7608, 8917, 7606, 8919, 7604, 8921, 7602, 8923, 7600, 8925, 7598, 8927, 7596, 8929, 7594, 8931, 7592, 8933, 7590, 8935, 7588, 8937, 7586, 8939, 7584, 8941, 7582, 8943, 7580, 8945, 7578, 8947, 7576, 8949, 7574, 8951, 7572, 8953, 7570, 8955, 7568, 8957, 7566, 8959, 7564, 8961, 7562, 8963, 7560, 8965, 7558, 8967, 7556, 8969, 7554, 8971, 7552, 8973, 7550, 8975, 7548, 8977, 7546, 8979, 7544, 8981, 7542, 8983, 7540, 8985, 7538, 8987, 7536, 8989, 7534, 8991, 7532, 8993, 7530, 8995, 7528, 8997, 7526, 8999, 7524, 9001, 7522, 9003, 7520, 9005, 7518, 9007, 7516, 9009, 7514, 9011, 7512, 9013, 7510, 9015, 7508, 9017, 7506, 9019, 7504, 9021, 7502, 9023, 7500, 9025, 7498, 9027, 7496, 9029, 7494, 9031, 7492, 9033, 7490, 9035, 7488, 9037, 7486, 9039, 7484, 9041, 7482, 9043, 7480, 9045, 7478, 9047, 7476, 9049, 7474, 9051, 7472, 9053, 7470, 9055, 7468, 9057, 7466, 9059, 7464, 9061, 7462, 9063, 7460, 9065, 7458, 9067, 7456, 9069, 7454, 9071, 7452, 9073, 7450, 9075, 7448, 9077, 7446, 9079, 7444, 9081, 7442, 9083, 7440, 9085, 7438, 9087, 7436, 9089, 7434, 9091, 7432, 9093, 7430, 9095, 7428, 9097, 7426, 9099, 7424, 9101, 7422, 9103, 7420, 9105, 7418, 9107, 7416, 9109, 7414, 9111, 7412, 9113, 7410, 9115, 7408, 9117, 7406, 9119, 7404, 9121, 7402, 9123, 7400, 9125, 7398, 9127, 7396, 9129, 7394, 9131, 7392, 9133, 7390, 9135, 7388, 9137, 7386, 9139, 7384, 9141, 7382, 9143, 7380, 9145, 7378, 9147, 7376, 9149, 7374, 9151, 7372, 9153, 7370, 9155, 7368, 9157, 7366, 9159, 7364, 9161, 7362, 9163, 7360, 9165, 7358, 9167, 7356, 9169, 7354, 9171, 7352, 9173, 7350, 9175, 7348, 9177, 7346, 9179, 7344, 9181, 7342, 9183, 7340, 9185, 7338, 9187, 7336, 9189, 7334, 9191, 7332, 9193, 7330, 9195, 7328, 9197, 7326, 9199, 7324, 9201, 7322, 9203, 7320, 9205, 7318, 9207, 7316, 9209, 7314, 9211, 7312, 9213, 7310, 9215, 7308, 9217, 7306, 9219, 7304, 9221, 7302, 9223, 7300, 9225, 7298, 9227, 7296, 9229, 7294, 9231, 7292, 9233, 7290, 9235, 7288, 9237, 7286, 9239, 7284, 9241, 7282, 9243, 7280, 9245, 7278, 9247, 7276, 9249, 7274, 9251, 7272, 9253, 7270, 9255, 7268, 9257, 7266, 9259, 7264, 9261, 7262, 9263, 7260, 9265, 7258, 9267, 7256, 9269, 7254, 9271, 7252, 9273, 7250, 9275, 7248, 9277, 7246, 9279, 7244, 9281, 7242, 9283, 7240, 9285, 7238, 9287, 7236, 9289, 7234, 9291, 7232, 9293, 7230, 9295, 7228, 9297, 7226, 9299, 7224, 9301, 7222, 9303, 7220, 9305, 7218, 9307, 7216, 9309, 7214, 9311, 7212, 9313, 7210, 9315, 7208, 9317, 7206, 9319, 7204, 9321, 7202, 9323, 7200, 9325, 7198, 9327, 7196, 9329, 7194, 9331, 7192, 9333, 7190, 9335, 7188, 9337, 7186, 9339, 7184, 9341, 7182, 9343, 7180, 9345, 7178, 9347, 7176, 9349, 7174, 9351, 7172, 9353, 7170, 9355, 7168, 9357, 7166, 9359, 7164, 9361, 7162, 9363, 7160, 9365, 7158, 9367, 7156, 9369, 7154, 9371, 7152, 9373, 7150, 9375, 7148, 9377, 7146, 9379, 7144, 9381, 7142, 9383, 7140, 9385, 7138, 9387, 7136, 9389, 7134, 9391, 7132, 9393, 7130, 9395, 7128, 9397, 7126, 9399, 7124, 9401, 7122, 9403, 7120, 9405, 7118, 9407, 7116, 9409, 7114, 9411, 7112, 9413, 7110, 9415, 7108, 9417, 7106, 9419, 7104, 9421, 7102, 9423, 7100, 9425, 7098, 9427, 7096, 9429, 7094, 9431, 7092, 9433, 7090, 9435, 7088, 9437, 7086, 9439, 7084, 9441, 7082, 9443, 7080, 9445, 7078, 9447, 7076, 9449, 7074, 9451, 7072, 9453, 7070, 9455, 7068, 9457, 7066, 9459, 7064, 9461, 7062, 9463, 7060, 9465, 7058, 9467, 7056, 9469, 7054, 9471, 7052, 9473, 7050, 9475, 7048, 9477, 7046, 9479, 7044, 9481, 7042, 9483, 7040, 9485, 7038, 9487, 7036, 9489, 7034, 9491, 7032, 9493, 7030, 9495, 7028, 9497, 7026, 9499, 7024, 9501, 7022, 9503, 7020, 9505, 7018, 9507, 7016, 9509, 7014, 9511, 7012, 9513, 7010, 9515, 7008, 9517, 7006, 9519, 7004, 9521, 7002, 9523, 7000, 9525, 6998, 9527, 6996, 9529, 6994, 9531, 6992, 9533, 6990, 9535, 6988, 9537, 6986, 9539, 6984, 9541, 6982, 9543, 6980, 9545, 6978, 9547, 6976, 9549, 6974, 9551, 6972, 9553, 6970, 9555, 6968, 9557, 6966, 9559, 6964, 9561, 6962, 9563, 6960, 9565, 6958, 9567, 6956, 9569, 6954, 9571, 6952, 9573, 6950, 9575, 6948, 9577, 6946, 9579, 6944, 9581, 6942, 9583, 6940, 9585, 6938, 9587, 6936, 9589, 6934, 9591, 6932, 9593, 6930, 9595, 6928, 9597, 6926, 9599, 6924, 9601, 6922, 9603, 6920, 9605, 6918, 9607, 6916, 9609, 6914, 9611, 6912, 9613, 6910, 9615, 6908, 9617, 6906, 9619, 6904, 9621, 6902, 9623, 6900, 9625, 6898, 9627, 6896, 9629, 6894, 9631, 6892, 9633, 6890, 9635, 6888, 9637, 6886, 9639, 6884, 9641, 6882, 9643, 6880, 9645, 6878, 9647, 6876, 9649, 6874, 9651, 6872, 9653, 6870, 9655, 6868, 9657, 6866, 9659, 6864, 9661, 6862, 9663, 6860, 9665, 6858, 9667, 6856, 9669, 6854, 9671, 6852, 9673, 6850, 9675, 6848, 9677, 6846, 9679, 6844, 9681, 6842, 9683, 6840, 9685, 6838, 9687, 6836, 9689, 6834, 9691, 6832, 9693, 6830, 9695, 6828, 9697, 6826, 9699, 6824, 9701, 6822, 9703, 6820, 9705, 6818, 9707, 6816, 9709, 6814, 9711, 6812, 9713, 6810, 9715, 6808, 9717, 6806, 9719, 6804, 9721, 6802, 9723, 6800, 9725, 6798, 9727, 6796, 9729, 6794, 9731, 6792, 9733, 6790, 9735, 6788, 9737, 6786, 9739, 6784, 9741, 6782, 9743, 6780, 9745, 6778, 9747, 6776, 9749, 6774, 9751, 6772, 9753, 6770, 9755, 6768, 9757, 6766, 9759, 6764, 9761, 6762, 9763, 6760, 9765, 6758, 9767, 6756, 9769, 6754, 9771, 6752, 9773, 6750, 9775, 6748, 9777, 6746, 9779, 6744, 9781, 6742, 9783, 6740, 9785, 6738, 9787, 6736, 9789, 6734, 9791, 6732, 9793, 6730, 9795, 6728, 9797, 6726, 9799, 6724, 9801, 6722, 9803, 6720, 9805, 6718, 9807, 6716, 9809, 6714, 9811, 6712, 9813, 6710, 9815, 6708, 9817, 6706, 9819, 6704, 9821, 6702, 9823, 6700, 9825, 6698, 9827, 6696, 9829, 6694, 9831, 6692, 9833, 6690, 9835, 6688, 9837, 6686, 9839, 6684, 9841, 6682, 9843, 6680, 9845, 6678, 9847, 6676, 9849, 6674, 9851, 6672, 9853, 6670, 9855, 6668, 9857, 6666, 9859, 6664, 9861, 6662, 9863, 6660, 9865, 6658, 9867, 6656, 9869, 6654, 9871, 6652, 9873, 6650, 9875, 6648, 9877, 6646, 9879, 6644, 9881, 6642, 9883, 6640, 9885, 6638, 9887, 6636, 9889, 6634, 9891, 6632, 9893, 6630, 9895, 6628, 9897, 6626, 9899, 6624, 9901, 6622, 9903, 6620, 9905, 6618, 9907, 6616, 9909, 6614, 9911, 6612, 9913, 6610, 9915, 6608, 9917, 6606, 9919, 6604, 9921, 6602, 9923, 6600, 9925, 6598, 9927, 6596, 9929, 6594, 9931, 6592, 9933, 6590, 9935, 6588, 9937, 6586, 9939, 6584, 9941, 6582, 9943, 6580, 9945, 6578, 9947, 6576, 9949, 6574, 9951, 6572, 9953, 6570, 9955, 6568, 9957, 6566, 9959, 6564, 9961, 6562, 9963, 6560, 9965, 6558, 9967, 6556, 9969, 6554, 9971, 6552, 9973, 6550, 9975, 6548, 9977, 6546, 9979, 6544, 9981, 6542, 9983, 6540, 9985, 6538, 9987, 6536, 9989, 6534, 9991, 6532, 9993, 6530, 9995, 6528, 9997, 6526, 9999, 6524, 10001, 6522, 10003, 6520, 10005, 6518, 10007, 6516, 10009, 6514, 10011, 6512, 10013, 6510, 10015, 6508, 10017, 6506, 10019, 6504, 10021, 6502, 10023, 6500, 10025, 6498, 10027, 6496, 10029, 6494, 10031, 6492, 10033, 6490, 10035, 6488, 10037, 6486, 10039, 6484, 10041, 6482, 10043, 6480, 10045, 6478, 10047, 6476, 10049, 6474, 10051, 6472, 10053, 6470, 10055, 6468, 10057, 6466, 10059, 6464, 10061, 6462, 10063, 6460, 10065, 6458, 10067, 6456, 10069, 6454, 10071, 6452, 10073, 6450, 10075, 6448, 10077, 6446, 10079, 6444, 10081, 6442, 10083, 6440, 10085, 6438, 10087, 6436, 10089, 6434, 10091, 6432, 10093, 6430, 10095, 6428, 10097, 6426, 10099, 6424, 10101, 6422, 10103, 6420, 10105, 6418, 10107, 6416, 10109, 6414, 10111, 6412, 10113, 6410, 10115, 6408, 10117, 6406, 10119, 6404, 10121, 6402, 10123, 6400, 10125, 6398, 10127, 6396, 10129, 6394, 10131, 6392, 10133, 6390, 10135, 6388, 10137, 6386, 10139, 6384, 10141, 6382, 10143, 6380, 10145, 6378, 10147, 6376, 10149, 6374, 10151, 6372, 10153, 6370, 10155, 6368, 10157, 6366, 10159, 6364, 10161, 6362, 10163, 6360, 10165, 6358, 10167, 6356, 10169, 6354, 10171, 6352, 10173, 6350, 10175, 6348, 10177, 6346, 10179, 6344, 10181, 6342, 10183, 6340, 10185, 6338, 10187, 6336, 10189, 6334, 10191, 6332, 10193, 6330, 10195, 6328, 10197, 6326, 10199, 6324, 10201, 6322, 10203, 6320, 10205, 6318, 10207, 6316, 10209, 6314, 10211, 6312, 10213, 6310, 10215, 6308, 10217, 6306, 10219, 6304, 10221, 6302, 10223, 6300, 10225, 6298, 10227, 6296, 10229, 6294, 10231, 6292, 10233, 6290, 10235, 6288, 10237, 6286, 10239, 6284, 10241, 6282, 10243, 6280, 10245, 6278, 10247, 6276, 10249, 6274, 10251, 6272, 10253, 6270, 10255, 6268, 10257, 6266, 10259, 6264, 10261, 6262, 10263, 6260, 10265, 6258, 10267, 6256, 10269, 6254, 10271, 6252, 10273, 6250, 10275, 6248, 10277, 6246, 10279, 6244, 10281, 6242, 10283, 6240, 10285, 6238, 10287, 6236, 10289, 6234, 10291, 6232, 10293, 6230, 10295, 6228, 10297, 6226, 10299, 6224, 10301, 6222, 10303, 6220, 10305, 6218, 10307, 6216, 10309, 6214, 10311, 6212, 10313, 6210, 10315, 6208, 10317, 6206, 10319, 6204, 10321, 6202, 10323, 6200, 10325, 6198, 10327, 6196, 10329, 6194, 10331, 6192, 10333, 6190, 10335, 6188, 10337, 6186, 10339, 6184, 10341, 6182, 10343, 6180, 10345, 6178, 10347, 6176, 10349, 6174, 10351, 6172, 10353, 6170, 10355, 6168, 10357, 6166, 10359, 6164, 10361, 6162, 10363, 6160, 10365, 6158, 10367, 6156, 10369, 6154, 10371, 6152, 10373, 6150, 10375, 6148, 10377, 6146, 10379, 6144, 10381, 6142, 10383, 6140, 10385, 6138, 10387, 6136, 10389, 6134, 10391, 6132, 10393, 6130, 10395, 6128, 10397, 6126, 10399, 6124, 10401, 6122, 10403, 6120, 10405, 6118, 10407, 6116, 10409, 6114, 10411, 6112, 10413, 6110, 10415, 6108, 10417, 6106, 10419, 6104, 10421, 6102, 10423, 6100, 10425, 6098, 10427, 6096, 10429, 6094, 10431, 6092, 10433, 6090, 10435, 6088, 10437, 6086, 10439, 6084, 10441, 6082, 10443, 6080, 10445, 6078, 10447, 6076, 10449, 6074, 10451, 6072, 10453, 6070, 10455, 6068, 10457, 6066, 10459, 6064, 10461, 6062, 10463, 6060, 10465, 6058, 10467, 6056, 10469, 6054, 10471, 6052, 10473, 6050, 10475, 6048, 10477, 6046, 10479, 6044, 10481, 6042, 10483, 6040, 10485, 6038, 10487, 6036, 10489, 6034, 10491, 6032, 10493, 6030, 10495, 6028, 10497, 6026, 10499, 6024, 10501, 6022, 10503, 6020, 10505, 6018, 10507, 6016, 10509, 6014, 10511, 6012, 10513, 6010, 10515, 6008, 10517, 6006, 10519, 6004, 10521, 6002, 10523, 6000, 10525, 5998, 10527, 5996, 10529, 5994, 10531, 5992, 10533, 5990, 10535, 5988, 10537, 5986, 10539, 5984, 10541, 5982, 10543, 5980, 10545, 5978, 10547, 5976, 10549, 5974, 10551, 5972, 10553, 5970, 10555, 5968, 10557, 5966, 10559, 5964, 10561, 5962, 10563, 5960, 10565, 5958, 10567, 5956, 10569, 5954, 10571, 5952, 10573, 5950, 10575, 5948, 10577, 5946, 10579, 5944, 10581, 5942, 10583, 5940, 10585, 5938, 10587, 5936, 10589, 5934, 10591, 5932, 10593, 5930, 10595, 5928, 10597, 5926, 10599, 5924, 10601, 5922, 10603, 5920, 10605, 5918, 10607, 5916, 10609, 5914, 10611, 5912, 10613, 5910, 10615, 5908, 10617, 5906, 10619, 5904, 10621, 5902, 10623, 5900, 10625, 5898, 10627, 5896, 10629, 5894, 10631, 5892, 10633, 5890, 10635, 5888, 10637, 5886, 10639, 5884, 10641, 5882, 10643, 5880, 10645, 5878, 10647, 5876, 10649, 5874, 10651, 5872, 10653, 5870, 10655, 5868, 10657, 5866, 10659, 5864, 10661, 5862, 10663, 5860, 10665, 5858, 10667, 5856, 10669, 5854, 10671, 5852, 10673, 5850, 10675, 5848, 10677, 5846, 10679, 5844, 10681, 5842, 10683, 5840, 10685, 5838, 10687, 5836, 10689, 5834, 10691, 5832, 10693, 5830, 10695, 5828, 10697, 5826, 10699, 5824, 10701, 5822, 10703, 5820, 10705, 5818, 10707, 5816, 10709, 5814, 10711, 5812, 10713, 5810, 10715, 5808, 10717, 5806, 10719, 5804, 10721, 5802, 10723, 5800, 10725, 5798, 10727, 5796, 10729, 5794, 10731, 5792, 10733, 5790, 10735, 5788, 10737, 5786, 10739, 5784, 10741, 5782, 10743, 5780, 10745, 5778, 10747, 5776, 10749, 5774, 10751, 5772, 10753, 5770, 10755, 5768, 10757, 5766, 10759, 5764, 10761, 5762, 10763, 5760, 10765, 5758, 10767, 5756, 10769, 5754, 10771, 5752, 10773, 5750, 10775, 5748, 10777, 5746, 10779, 5744, 10781, 5742, 10783, 5740, 10785, 5738, 10787, 5736, 10789, 5734, 10791, 5732, 10793, 5730, 10795, 5728, 10797, 5726, 10799, 5724, 10801, 5722, 10803, 5720, 10805, 5718, 10807, 5716, 10809, 5714, 10811, 5712, 10813, 5710, 10815, 5708, 10817, 5706, 10819, 5704, 10821, 5702, 10823, 5700, 10825, 5698, 10827, 5696, 10829, 5694, 10831, 5692, 10833, 5690, 10835, 5688, 10837, 5686, 10839, 5684, 10841, 5682, 10843, 5680, 10845, 5678, 10847, 5676, 10849, 5674, 10851, 5672, 10853, 5670, 10855, 5668, 10857, 5666, 10859, 5664, 10861, 5662, 10863, 5660, 10865, 5658, 10867, 5656, 10869, 5654, 10871, 5652, 10873, 5650, 10875, 5648, 10877, 5646, 10879, 5644, 10881, 5642, 10883, 5640, 10885, 5638, 10887, 5636, 10889, 5634, 10891, 5632, 10893, 5630, 10895, 5628, 10897, 5626, 10899, 5624, 10901, 5622, 10903, 5620, 10905, 5618, 10907, 5616, 10909, 5614, 10911, 5612, 10913, 5610, 10915, 5608, 10917, 5606, 10919, 5604, 10921, 5602, 10923, 5600, 10925, 5598, 10927, 5596, 10929, 5594, 10931, 5592, 10933, 5590, 10935, 5588, 10937, 5586, 10939, 5584, 10941, 5582, 10943, 5580, 10945, 5578, 10947, 5576, 10949, 5574, 10951, 5572, 10953, 5570, 10955, 5568, 10957, 5566, 10959, 5564, 10961, 5562, 10963, 5560, 10965, 5558, 10967, 5556, 10969, 5554, 10971, 5552, 10973, 5550, 10975, 5548, 10977, 5546, 10979, 5544, 10981, 5542, 10983, 5540, 10985, 5538, 10987, 5536, 10989, 5534, 10991, 5532, 10993, 5530, 10995, 5528, 10997, 5526, 10999, 5524, 11001, 5522, 11003, 5520, 11005, 5518, 11007, 5516, 11009, 5514, 11011, 5512, 11013, 5510, 11015, 5508, 11017, 5506, 11019, 5504, 11021, 5502, 11023, 5500, 11025, 5498, 11027, 5496, 11029, 5494, 11031, 5492, 11033, 5490, 11035, 5488, 11037, 5486, 11039, 5484, 11041, 5482, 11043, 5480, 11045, 5478, 11047, 5476, 11049, 5474, 11051, 5472, 11053, 5470, 11055, 5468, 11057, 5466, 11059, 5464, 11061, 5462, 11063, 5460, 11065, 5458, 11067, 5456, 11069, 5454, 11071, 5452, 11073, 5450, 11075, 5448, 11077, 5446, 11079, 5444, 11081, 5442, 11083, 5440, 11085, 5438, 11087, 5436, 11089, 5434, 11091, 5432, 11093, 5430, 11095, 5428, 11097, 5426, 11099, 5424, 11101, 5422, 11103, 5420, 11105, 5418, 11107, 5416, 11109, 5414, 11111, 5412, 11113, 5410, 11115, 5408, 11117, 5406, 11119, 5404, 11121, 5402, 11123, 5400, 11125, 5398, 11127, 5396, 11129, 5394, 11131, 5392, 11133, 5390, 11135, 5388, 11137, 5386, 11139, 5384, 11141, 5382, 11143, 5380, 11145, 5378, 11147, 5376, 11149, 5374, 11151, 5372, 11153, 5370, 11155, 5368, 11157, 5366, 11159, 5364, 11161, 5362, 11163, 5360, 11165, 5358, 11167, 5356, 11169, 5354, 11171, 5352, 11173, 5350, 11175, 5348, 11177, 5346, 11179, 5344, 11181, 5342, 11183, 5340, 11185, 5338, 11187, 5336, 11189, 5334, 11191, 5332, 11193, 5330, 11195, 5328, 11197, 5326, 11199, 5324, 11201, 5322, 11203, 5320, 11205, 5318, 11207, 5316, 11209, 5314, 11211, 5312, 11213, 5310, 11215, 5308, 11217, 5306, 11219, 5304, 11221, 5302, 11223, 5300, 11225, 5298, 11227, 5296, 11229, 5294, 11231, 5292, 11233, 5290, 11235, 5288, 11237, 5286, 11239, 5284, 11241, 5282, 11243, 5280, 11245, 5278, 11247, 5276, 11249, 5274, 11251, 5272, 11253, 5270, 11255, 5268, 11257, 5266, 11259, 5264, 11261, 5262, 11263, 5260, 11265, 5258, 11267, 5256, 11269, 5254, 11271, 5252, 11273, 5250, 11275, 5248, 11277, 5246, 11279, 5244, 11281, 5242, 11283, 5240, 11285, 5238, 11287, 5236, 11289, 5234, 11291, 5232, 11293, 5230, 11295, 5228, 11297, 5226, 11299, 5224, 11301, 5222, 11303, 5220, 11305, 5218, 11307, 5216, 11309, 5214, 11311, 5212, 11313, 5210, 11315, 5208, 11317, 5206, 11319, 5204, 11321, 5202, 11323, 5200, 11325, 5198, 11327, 5196, 11329, 5194, 11331, 5192, 11333, 5190, 11335, 5188, 11337, 5186, 11339, 5184, 11341, 5182, 11343, 5180, 11345, 5178, 11347, 5176, 11349, 5174, 11351, 5172, 11353, 5170, 11355, 5168, 11357, 5166, 11359, 5164, 11361, 5162, 11363, 5160, 11365, 5158, 11367, 5156, 11369, 5154, 11371, 5152, 11373, 5150, 11375, 5148, 11377, 5146, 11379, 5144, 11381, 5142, 11383, 5140, 11385, 5138, 11387, 5136, 11389, 5134, 11391, 5132, 11393, 5130, 11395, 5128, 11397, 5126, 11399, 5124, 11401, 5122, 11403, 5120, 11405, 5118, 11407, 5116, 11409, 5114, 11411, 5112, 11413, 5110, 11415, 5108, 11417, 5106, 11419, 5104, 11421, 5102, 11423, 5100, 11425, 5098, 11427, 5096, 11429, 5094, 11431, 5092, 11433, 5090, 11435, 5088, 11437, 5086, 11439, 5084, 11441, 5082, 11443, 5080, 11445, 5078, 11447, 5076, 11449, 5074, 11451, 5072, 11453, 5070, 11455, 5068, 11457, 5066, 11459, 5064, 11461, 5062, 11463, 5060, 11465, 5058, 11467, 5056, 11469, 5054, 11471, 5052, 11473, 5050, 11475, 5048, 11477, 5046, 11479, 5044, 11481, 5042, 11483, 5040, 11485, 5038, 11487, 5036, 11489, 5034, 11491, 5032, 11493, 5030, 11495, 5028, 11497, 5026, 11499, 5024, 11501, 5022, 11503, 5020, 11505, 5018, 11507, 5016, 11509, 5014, 11511, 5012, 11513, 5010, 11515, 5008, 11517, 5006, 11519, 5004, 11521, 5002, 11523, 5000, 11525, 4998, 11527, 4996, 11529, 4994, 11531, 4992, 11533, 4990, 11535, 4988, 11537, 4986, 11539, 4984, 11541, 4982, 11543, 4980, 11545, 4978, 11547, 4976, 11549, 4974, 11551, 4972, 11553, 4970, 11555, 4968, 11557, 4966, 11559, 4964, 11561, 4962, 11563, 4960, 11565, 4958, 11567, 4956, 11569, 4954, 11571, 4952, 11573, 4950, 11575, 4948, 11577, 4946, 11579, 4944, 11581, 4942, 11583, 4940, 11585, 4938, 11587, 4936, 11589, 4934, 11591, 4932, 11593, 4930, 11595, 4928, 11597, 4926, 11599, 4924, 11601, 4922, 11603, 4920, 11605, 4918, 11607, 4916, 11609, 4914, 11611, 4912, 11613, 4910, 11615, 4908, 11617, 4906, 11619, 4904, 11621, 4902, 11623, 4900, 11625, 4898, 11627, 4896, 11629, 4894, 11631, 4892, 11633, 4890, 11635, 4888, 11637, 4886, 11639, 4884, 11641, 4882, 11643, 4880, 11645, 4878, 11647, 4876, 11649, 4874, 11651, 4872, 11653, 4870, 11655, 4868, 11657, 4866, 11659, 4864, 11661, 4862, 11663, 4860, 11665, 4858, 11667, 4856, 11669, 4854, 11671, 4852, 11673, 4850, 11675, 4848, 11677, 4846, 11679, 4844, 11681, 4842, 11683, 4840, 11685, 4838, 11687, 4836, 11689, 4834, 11691, 4832, 11693, 4830, 11695, 4828, 11697, 4826, 11699, 4824, 11701, 4822, 11703, 4820, 11705, 4818, 11707, 4816, 11709, 4814, 11711, 4812, 11713, 4810, 11715, 4808, 11717, 4806, 11719, 4804, 11721, 4802, 11723, 4800, 11725, 4798, 11727, 4796, 11729, 4794, 11731, 4792, 11733, 4790, 11735, 4788, 11737, 4786, 11739, 4784, 11741, 4782, 11743, 4780, 11745, 4778, 11747, 4776, 11749, 4774, 11751, 4772, 11753, 4770, 11755, 4768, 11757, 4766, 11759, 4764, 11761, 4762, 11763, 4760, 11765, 4758, 11767, 4756, 11769, 4754, 11771, 4752, 11773, 4750, 11775, 4748, 11777, 4746, 11779, 4744, 11781, 4742, 11783, 4740, 11785, 4738, 11787, 4736, 11789, 4734, 11791, 4732, 11793, 4730, 11795, 4728, 11797, 4726, 11799, 4724, 11801, 4722, 11803, 4720, 11805, 4718, 11807, 4716, 11809, 4714, 11811, 4712, 11813, 4710, 11815, 4708, 11817, 4706, 11819, 4704, 11821, 4702, 11823, 4700, 11825, 4698, 11827, 4696, 11829, 4694, 11831, 4692, 11833, 4690, 11835, 4688, 11837, 4686, 11839, 4684, 11841, 4682, 11843, 4680, 11845, 4678, 11847, 4676, 11849, 4674, 11851, 4672, 11853, 4670, 11855, 4668, 11857, 4666, 11859, 4664, 11861, 4662, 11863, 4660, 11865, 4658, 11867, 4656, 11869, 4654, 11871, 4652, 11873, 4650, 11875, 4648, 11877, 4646, 11879, 4644, 11881, 4642, 11883, 4640, 11885, 4638, 11887, 4636, 11889, 4634, 11891, 4632, 11893, 4630, 11895, 4628, 11897, 4626, 11899, 4624, 11901, 4622, 11903, 4620, 11905, 4618, 11907, 4616, 11909, 4614, 11911, 4612, 11913, 4610, 11915, 4608, 11917, 4606, 11919, 4604, 11921, 4602, 11923, 4600, 11925, 4598, 11927, 4596, 11929, 4594, 11931, 4592, 11933, 4590, 11935, 4588, 11937, 4586, 11939, 4584, 11941, 4582, 11943, 4580, 11945, 4578, 11947, 4576, 11949, 4574, 11951, 4572, 11953, 4570, 11955, 4568, 11957, 4566, 11959, 4564, 11961, 4562, 11963, 4560, 11965, 4558, 11967, 4556, 11969, 4554, 11971, 4552, 11973, 4550, 11975, 4548, 11977, 4546, 11979, 4544, 11981, 4542, 11983, 4540, 11985, 4538, 11987, 4536, 11989, 4534, 11991, 4532, 11993, 4530, 11995, 4528, 11997, 4526, 11999, 4524, 12001, 4522, 12003, 4520, 12005, 4518, 12007, 4516, 12009, 4514, 12011, 4512, 12013, 4510, 12015, 4508, 12017, 4506, 12019, 4504, 12021, 4502, 12023, 4500, 12025, 4498, 12027, 4496, 12029, 4494, 12031, 4492, 12033, 4490, 12035, 4488, 12037, 4486, 12039, 4484, 12041, 4482, 12043, 4480, 12045, 4478, 12047, 4476, 12049, 4474, 12051, 4472, 12053, 4470, 12055, 4468, 12057, 4466, 12059, 4464, 12061, 4462, 12063, 4460, 12065, 4458, 12067, 4456, 12069, 4454, 12071, 4452, 12073, 4450, 12075, 4448, 12077, 4446, 12079, 4444, 12081, 4442, 12083, 4440, 12085, 4438, 12087, 4436, 12089, 4434, 12091, 4432, 12093, 4430, 12095, 4428, 12097, 4426, 12099, 4424, 12101, 4422, 12103, 4420, 12105, 4418, 12107, 4416, 12109, 4414, 12111, 4412, 12113, 4410, 12115, 4408, 12117, 4406, 12119, 4404, 12121, 4402, 12123, 4400, 12125, 4398, 12127, 4396, 12129, 4394, 12131, 4392, 12133, 4390, 12135, 4388, 12137, 4386, 12139, 4384, 12141, 4382, 12143, 4380, 12145, 4378, 12147, 4376, 12149, 4374, 12151, 4372, 12153, 4370, 12155, 4368, 12157, 4366, 12159, 4364, 12161, 4362, 12163, 4360, 12165, 4358, 12167, 4356, 12169, 4354, 12171, 4352, 12173, 4350, 12175, 4348, 12177, 4346, 12179, 4344, 12181, 4342, 12183, 4340, 12185, 4338, 12187, 4336, 12189, 4334, 12191, 4332, 12193, 4330, 12195, 4328, 12197, 4326, 12199, 4324, 12201, 4322, 12203, 4320, 12205, 4318, 12207, 4316, 12209, 4314, 12211, 4312, 12213, 4310, 12215, 4308, 12217, 4306, 12219, 4304, 12221, 4302, 12223, 4300, 12225, 4298, 12227, 4296, 12229, 4294, 12231, 4292, 12233, 4290, 12235, 4288, 12237, 4286, 12239, 4284, 12241, 4282, 12243, 4280, 12245, 4278, 12247, 4276, 12249, 4274, 12251, 4272, 12253, 4270, 12255, 4268, 12257, 4266, 12259, 4264, 12261, 4262, 12263, 4260, 12265, 4258, 12267, 4256, 12269, 4254, 12271, 4252, 12273, 4250, 12275, 4248, 12277, 4246, 12279, 4244, 12281, 4242, 12283, 4240, 12285, 4238, 12287, 4236, 12289, 4234, 12291, 4232, 12293, 4230, 12295, 4228, 12297, 4226, 12299, 4224, 12301, 4222, 12303, 4220, 12305, 4218, 12307, 4216, 12309, 4214, 12311, 4212, 12313, 4210, 12315, 4208, 12317, 4206, 12319, 4204, 12321, 4202, 12323, 4200, 12325, 4198, 12327, 4196, 12329, 4194, 12331, 4192, 12333, 4190, 12335, 4188, 12337, 4186, 12339, 4184, 12341, 4182, 12343, 4180, 12345, 4178, 12347, 4176, 12349, 4174, 12351, 4172, 12353, 4170, 12355, 4168, 12357, 4166, 12359, 4164, 12361, 4162, 12363, 4160, 12365, 4158, 12367, 4156, 12369, 4154, 12371, 4152, 12373, 4150, 12375, 4148, 12377, 4146, 12379, 4144, 12381, 4142, 12383, 4140, 12385, 4138, 12387, 4136, 12389, 4134, 12391, 4132, 12393, 4130, 12395, 4128, 12397, 4126, 12399, 4124, 12401, 4122, 12403, 4120, 12405, 4118, 12407, 4116, 12409, 4114, 12411, 4112, 12413, 4110, 12415, 4108, 12417, 4106, 12419, 4104, 12421, 4102, 12423, 4100, 12425, 4098, 12427, 4096, 12429, 4094, 12431, 4092, 12433, 4090, 12435, 4088, 12437, 4086, 12439, 4084, 12441, 4082, 12443, 4080, 12445, 4078, 12447, 4076, 12449, 4074, 12451, 4072, 12453, 4070, 12455, 4068, 12457, 4066, 12459, 4064, 12461, 4062, 12463, 4060, 12465, 4058, 12467, 4056, 12469, 4054, 12471, 4052, 12473, 4050, 12475, 4048, 12477, 4046, 12479, 4044, 12481, 4042, 12483, 4040, 12485, 4038, 12487, 4036, 12489, 4034, 12491, 4032, 12493, 4030, 12495, 4028, 12497, 4026, 12499, 4024, 12501, 4022, 12503, 4020, 12505, 4018, 12507, 4016, 12509, 4014, 12511, 4012, 12513, 4010, 12515, 4008, 12517, 4006, 12519, 4004, 12521, 4002, 12523, 4000, 12525, 3998, 12527, 3996, 12529, 3994, 12531, 3992, 12533, 3990, 12535, 3988, 12537, 3986, 12539, 3984, 12541, 3982, 12543, 3980, 12545, 3978, 12547, 3976, 12549, 3974, 12551, 3972, 12553, 3970, 12555, 3968, 12557, 3966, 12559, 3964, 12561, 3962, 12563, 3960, 12565, 3958, 12567, 3956, 12569, 3954, 12571, 3952, 12573, 3950, 12575, 3948, 12577, 3946, 12579, 3944, 12581, 3942, 12583, 3940, 12585, 3938, 12587, 3936, 12589, 3934, 12591, 3932, 12593, 3930, 12595, 3928, 12597, 3926, 12599, 3924, 12601, 3922, 12603, 3920, 12605, 3918, 12607, 3916, 12609, 3914, 12611, 3912, 12613, 3910, 12615, 3908, 12617, 3906, 12619, 3904, 12621, 3902, 12623, 3900, 12625, 3898, 12627, 3896, 12629, 3894, 12631, 3892, 12633, 3890, 12635, 3888, 12637, 3886, 12639, 3884, 12641, 3882, 12643, 3880, 12645, 3878, 12647, 3876, 12649, 3874, 12651, 3872, 12653, 3870, 12655, 3868, 12657, 3866, 12659, 3864, 12661, 3862, 12663, 3860, 12665, 3858, 12667, 3856, 12669, 3854, 12671, 3852, 12673, 3850, 12675, 3848, 12677, 3846, 12679, 3844, 12681, 3842, 12683, 3840, 12685, 3838, 12687, 3836, 12689, 3834, 12691, 3832, 12693, 3830, 12695, 3828, 12697, 3826, 12699, 3824, 12701, 3822, 12703, 3820, 12705, 3818, 12707, 3816, 12709, 3814, 12711, 3812, 12713, 3810, 12715, 3808, 12717, 3806, 12719, 3804, 12721, 3802, 12723, 3800, 12725, 3798, 12727, 3796, 12729, 3794, 12731, 3792, 12733, 3790, 12735, 3788, 12737, 3786, 12739, 3784, 12741, 3782, 12743, 3780, 12745, 3778, 12747, 3776, 12749, 3774, 12751, 3772, 12753, 3770, 12755, 3768, 12757, 3766, 12759, 3764, 12761, 3762, 12763, 3760, 12765, 3758, 12767, 3756, 12769, 3754, 12771, 3752, 12773, 3750, 12775, 3748, 12777, 3746, 12779, 3744, 12781, 3742, 12783, 3740, 12785, 3738, 12787, 3736, 12789, 3734, 12791, 3732, 12793, 3730, 12795, 3728, 12797, 3726, 12799, 3724, 12801, 3722, 12803, 3720, 12805, 3718, 12807, 3716, 12809, 3714, 12811, 3712, 12813, 3710, 12815, 3708, 12817, 3706, 12819, 3704, 12821, 3702, 12823, 3700, 12825, 3698, 12827, 3696, 12829, 3694, 12831, 3692, 12833, 3690, 12835, 3688, 12837, 3686, 12839, 3684, 12841, 3682, 12843, 3680, 12845, 3678, 12847, 3676, 12849, 3674, 12851, 3672, 12853, 3670, 12855, 3668, 12857, 3666, 12859, 3664, 12861, 3662, 12863, 3660, 12865, 3658, 12867, 3656, 12869, 3654, 12871, 3652, 12873, 3650, 12875, 3648, 12877, 3646, 12879, 3644, 12881, 3642, 12883, 3640, 12885, 3638, 12887, 3636, 12889, 3634, 12891, 3632, 12893, 3630, 12895, 3628, 12897, 3626, 12899, 3624, 12901, 3622, 12903, 3620, 12905, 3618, 12907, 3616, 12909, 3614, 12911, 3612, 12913, 3610, 12915, 3608, 12917, 3606, 12919, 3604, 12921, 3602, 12923, 3600, 12925, 3598, 12927, 3596, 12929, 3594, 12931, 3592, 12933, 3590, 12935, 3588, 12937, 3586, 12939, 3584, 12941, 3582, 12943, 3580, 12945, 3578, 12947, 3576, 12949, 3574, 12951, 3572, 12953, 3570, 12955, 3568, 12957, 3566, 12959, 3564, 12961, 3562, 12963, 3560, 12965, 3558, 12967, 3556, 12969, 3554, 12971, 3552, 12973, 3550, 12975, 3548, 12977, 3546, 12979, 3544, 12981, 3542, 12983, 3540, 12985, 3538, 12987, 3536, 12989, 3534, 12991, 3532, 12993, 3530, 12995, 3528, 12997, 3526, 12999, 3524, 13001, 3522, 13003, 3520, 13005, 3518, 13007, 3516, 13009, 3514, 13011, 3512, 13013, 3510, 13015, 3508, 13017, 3506, 13019, 3504, 13021, 3502, 13023, 3500, 13025, 3498, 13027, 3496, 13029, 3494, 13031, 3492, 13033, 3490, 13035, 3488, 13037, 3486, 13039, 3484, 13041, 3482, 13043, 3480, 13045, 3478, 13047, 3476, 13049, 3474, 13051, 3472, 13053, 3470, 13055, 3468, 13057, 3466, 13059, 3464, 13061, 3462, 13063, 3460, 13065, 3458, 13067, 3456, 13069, 3454, 13071, 3452, 13073, 3450, 13075, 3448, 13077, 3446, 13079, 3444, 13081, 3442, 13083, 3440, 13085, 3438, 13087, 3436, 13089, 3434, 13091, 3432, 13093, 3430, 13095, 3428, 13097, 3426, 13099, 3424, 13101, 3422, 13103, 3420, 13105, 3418, 13107, 3416, 13109, 3414, 13111, 3412, 13113, 3410, 13115, 3408, 13117, 3406, 13119, 3404, 13121, 3402, 13123, 3400, 13125, 3398, 13127, 3396, 13129, 3394, 13131, 3392, 13133, 3390, 13135, 3388, 13137, 3386, 13139, 3384, 13141, 3382, 13143, 3380, 13145, 3378, 13147, 3376, 13149, 3374, 13151, 3372, 13153, 3370, 13155, 3368, 13157, 3366, 13159, 3364, 13161, 3362, 13163, 3360, 13165, 3358, 13167, 3356, 13169, 3354, 13171, 3352, 13173, 3350, 13175, 3348, 13177, 3346, 13179, 3344, 13181, 3342, 13183, 3340, 13185, 3338, 13187, 3336, 13189, 3334, 13191, 3332, 13193, 3330, 13195, 3328, 13197, 3326, 13199, 3324, 13201, 3322, 13203, 3320, 13205, 3318, 13207, 3316, 13209, 3314, 13211, 3312, 13213, 3310, 13215, 3308, 13217, 3306, 13219, 3304, 13221, 3302, 13223, 3300, 13225, 3298, 13227, 3296, 13229, 3294, 13231, 3292, 13233, 3290, 13235, 3288, 13237, 3286, 13239, 3284, 13241, 3282, 13243, 3280, 13245, 3278, 13247, 3276, 13249, 3274, 13251, 3272, 13253, 3270, 13255, 3268, 13257, 3266, 13259, 3264, 13261, 3262, 13263, 3260, 13265, 3258, 13267, 3256, 13269, 3254, 13271, 3252, 13273, 3250, 13275, 3248, 13277, 3246, 13279, 3244, 13281, 3242, 13283, 3240, 13285, 3238, 13287, 3236, 13289, 3234, 13291, 3232, 13293, 3230, 13295, 3228, 13297, 3226, 13299, 3224, 13301, 3222, 13303, 3220, 13305, 3218, 13307, 3216, 13309, 3214, 13311, 3212, 13313, 3210, 13315, 3208, 13317, 3206, 13319, 3204, 13321, 3202, 13323, 3200, 13325, 3198, 13327, 3196, 13329, 3194, 13331, 3192, 13333, 3190, 13335, 3188, 13337, 3186, 13339, 3184, 13341, 3182, 13343, 3180, 13345, 3178, 13347, 3176, 13349, 3174, 13351, 3172, 13353, 3170, 13355, 3168, 13357, 3166, 13359, 3164, 13361, 3162, 13363, 3160, 13365, 3158, 13367, 3156, 13369, 3154, 13371, 3152, 13373, 3150, 13375, 3148, 13377, 3146, 13379, 3144, 13381, 3142, 13383, 3140, 13385, 3138, 13387, 3136, 13389, 3134, 13391, 3132, 13393, 3130, 13395, 3128, 13397, 3126, 13399, 3124, 13401, 3122, 13403, 3120, 13405, 3118, 13407, 3116, 13409, 3114, 13411, 3112, 13413, 3110, 13415, 3108, 13417, 3106, 13419, 3104, 13421, 3102, 13423, 3100, 13425, 3098, 13427, 3096, 13429, 3094, 13431, 3092, 13433, 3090, 13435, 3088, 13437, 3086, 13439, 3084, 13441, 3082, 13443, 3080, 13445, 3078, 13447, 3076, 13449, 3074, 13451, 3072, 13453, 3070, 13455, 3068, 13457, 3066, 13459, 3064, 13461, 3062, 13463, 3060, 13465, 3058, 13467, 3056, 13469, 3054, 13471, 3052, 13473, 3050, 13475, 3048, 13477, 3046, 13479, 3044, 13481, 3042, 13483, 3040, 13485, 3038, 13487, 3036, 13489, 3034, 13491, 3032, 13493, 3030, 13495, 3028, 13497, 3026, 13499, 3024, 13501, 3022, 13503, 3020, 13505, 3018, 13507, 3016, 13509, 3014, 13511, 3012, 13513, 3010, 13515, 3008, 13517, 3006, 13519, 3004, 13521, 3002, 13523, 3000, 13525, 2998, 13527, 2996, 13529, 2994, 13531, 2992, 13533, 2990, 13535, 2988, 13537, 2986, 13539, 2984, 13541, 2982, 13543, 2980, 13545, 2978, 13547, 2976, 13549, 2974, 13551, 2972, 13553, 2970, 13555, 2968, 13557, 2966, 13559, 2964, 13561, 2962, 13563, 2960, 13565, 2958, 13567, 2956, 13569, 2954, 13571, 2952, 13573, 2950, 13575, 2948, 13577, 2946, 13579, 2944, 13581, 2942, 13583, 2940, 13585, 2938, 13587, 2936, 13589, 2934, 13591, 2932, 13593, 2930, 13595, 2928, 13597, 2926, 13599, 2924, 13601, 2922, 13603, 2920, 13605, 2918, 13607, 2916, 13609, 2914, 13611, 2912, 13613, 2910, 13615, 2908, 13617, 2906, 13619, 2904, 13621, 2902, 13623, 2900, 13625, 2898, 13627, 2896, 13629, 2894, 13631, 2892, 13633, 2890, 13635, 2888, 13637, 2886, 13639, 2884, 13641, 2882, 13643, 2880, 13645, 2878, 13647, 2876, 13649, 2874, 13651, 2872, 13653, 2870, 13655, 2868, 13657, 2866, 13659, 2864, 13661, 2862, 13663, 2860, 13665, 2858, 13667, 2856, 13669, 2854, 13671, 2852, 13673, 2850, 13675, 2848, 13677, 2846, 13679, 2844, 13681, 2842, 13683, 2840, 13685, 2838, 13687, 2836, 13689, 2834, 13691, 2832, 13693, 2830, 13695, 2828, 13697, 2826, 13699, 2824, 13701, 2822, 13703, 2820, 13705, 2818, 13707, 2816, 13709, 2814, 13711, 2812, 13713, 2810, 13715, 2808, 13717, 2806, 13719, 2804, 13721, 2802, 13723, 2800, 13725, 2798, 13727, 2796, 13729, 2794, 13731, 2792, 13733, 2790, 13735, 2788, 13737, 2786, 13739, 2784, 13741, 2782, 13743, 2780, 13745, 2778, 13747, 2776, 13749, 2774, 13751, 2772, 13753, 2770, 13755, 2768, 13757, 2766, 13759, 2764, 13761, 2762, 13763, 2760, 13765, 2758, 13767, 2756, 13769, 2754, 13771, 2752, 13773, 2750, 13775, 2748, 13777, 2746, 13779, 2744, 13781, 2742, 13783, 2740, 13785, 2738, 13787, 2736, 13789, 2734, 13791, 2732, 13793, 2730, 13795, 2728, 13797, 2726, 13799, 2724, 13801, 2722, 13803, 2720, 13805, 2718, 13807, 2716, 13809, 2714, 13811, 2712, 13813, 2710, 13815, 2708, 13817, 2706, 13819, 2704, 13821, 2702, 13823, 2700, 13825, 2698, 13827, 2696, 13829, 2694, 13831, 2692, 13833, 2690, 13835, 2688, 13837, 2686, 13839, 2684, 13841, 2682, 13843, 2680, 13845, 2678, 13847, 2676, 13849, 2674, 13851, 2672, 13853, 2670, 13855, 2668, 13857, 2666, 13859, 2664, 13861, 2662, 13863, 2660, 13865, 2658, 13867, 2656, 13869, 2654, 13871, 2652, 13873, 2650, 13875, 2648, 13877, 2646, 13879, 2644, 13881, 2642, 13883, 2640, 13885, 2638, 13887, 2636, 13889, 2634, 13891, 2632, 13893, 2630, 13895, 2628, 13897, 2626, 13899, 2624, 13901, 2622, 13903, 2620, 13905, 2618, 13907, 2616, 13909, 2614, 13911, 2612, 13913, 2610, 13915, 2608, 13917, 2606, 13919, 2604, 13921, 2602, 13923, 2600, 13925, 2598, 13927, 2596, 13929, 2594, 13931, 2592, 13933, 2590, 13935, 2588, 13937, 2586, 13939, 2584, 13941, 2582, 13943, 2580, 13945, 2578, 13947, 2576, 13949, 2574, 13951, 2572, 13953, 2570, 13955, 2568, 13957, 2566, 13959, 2564, 13961, 2562, 13963, 2560, 13965, 2558, 13967, 2556, 13969, 2554, 13971, 2552, 13973, 2550, 13975, 2548, 13977, 2546, 13979, 2544, 13981, 2542, 13983, 2540, 13985, 2538, 13987, 2536, 13989, 2534, 13991, 2532, 13993, 2530, 13995, 2528, 13997, 2526, 13999, 2524, 14001, 2522, 14003, 2520, 14005, 2518, 14007, 2516, 14009, 2514, 14011, 2512, 14013, 2510, 14015, 2508, 14017, 2506, 14019, 2504, 14021, 2502, 14023, 2500, 14025, 2498, 14027, 2496, 14029, 2494, 14031, 2492, 14033, 2490, 14035, 2488, 14037, 2486, 14039, 2484, 14041, 2482, 14043, 2480, 14045, 2478, 14047, 2476, 14049, 2474, 14051, 2472, 14053, 2470, 14055, 2468, 14057, 2466, 14059, 2464, 14061, 2462, 14063, 2460, 14065, 2458, 14067, 2456, 14069, 2454, 14071, 2452, 14073, 2450, 14075, 2448, 14077, 2446, 14079, 2444, 14081, 2442, 14083, 2440, 14085, 2438, 14087, 2436, 14089, 2434, 14091, 2432, 14093, 2430, 14095, 2428, 14097, 2426, 14099, 2424, 14101, 2422, 14103, 2420, 14105, 2418, 14107, 2416, 14109, 2414, 14111, 2412, 14113, 2410, 14115, 2408, 14117, 2406, 14119, 2404, 14121, 2402, 14123, 2400, 14125, 2398, 14127, 2396, 14129, 2394, 14131, 2392, 14133, 2390, 14135, 2388, 14137, 2386, 14139, 2384, 14141, 2382, 14143, 2380, 14145, 2378, 14147, 2376, 14149, 2374, 14151, 2372, 14153, 2370, 14155, 2368, 14157, 2366, 14159, 2364, 14161, 2362, 14163, 2360, 14165, 2358, 14167, 2356, 14169, 2354, 14171, 2352, 14173, 2350, 14175, 2348, 14177, 2346, 14179, 2344, 14181, 2342, 14183, 2340, 14185, 2338, 14187, 2336, 14189, 2334, 14191, 2332, 14193, 2330, 14195, 2328, 14197, 2326, 14199, 2324, 14201, 2322, 14203, 2320, 14205, 2318, 14207, 2316, 14209, 2314, 14211, 2312, 14213, 2310, 14215, 2308, 14217, 2306, 14219, 2304, 14221, 2302, 14223, 2300, 14225, 2298, 14227, 2296, 14229, 2294, 14231, 2292, 14233, 2290, 14235, 2288, 14237, 2286, 14239, 2284, 14241, 2282, 14243, 2280, 14245, 2278, 14247, 2276, 14249, 2274, 14251, 2272, 14253, 2270, 14255, 2268, 14257, 2266, 14259, 2264, 14261, 2262, 14263, 2260, 14265, 2258, 14267, 2256, 14269, 2254, 14271, 2252, 14273, 2250, 14275, 2248, 14277, 2246, 14279, 2244, 14281, 2242, 14283, 2240, 14285, 2238, 14287, 2236, 14289, 2234, 14291, 2232, 14293, 2230, 14295, 2228, 14297, 2226, 14299, 2224, 14301, 2222, 14303, 2220, 14305, 2218, 14307, 2216, 14309, 2214, 14311, 2212, 14313, 2210, 14315, 2208, 14317, 2206, 14319, 2204, 14321, 2202, 14323, 2200, 14325, 2198, 14327, 2196, 14329, 2194, 14331, 2192, 14333, 2190, 14335, 2188, 14337, 2186, 14339, 2184, 14341, 2182, 14343, 2180, 14345, 2178, 14347, 2176, 14349, 2174, 14351, 2172, 14353, 2170, 14355, 2168, 14357, 2166, 14359, 2164, 14361, 2162, 14363, 2160, 14365, 2158, 14367, 2156, 14369, 2154, 14371, 2152, 14373, 2150, 14375, 2148, 14377, 2146, 14379, 2144, 14381, 2142, 14383, 2140, 14385, 2138, 14387, 2136, 14389, 2134, 14391, 2132, 14393, 2130, 14395, 2128, 14397, 2126, 14399, 2124, 14401, 2122, 14403, 2120, 14405, 2118, 14407, 2116, 14409, 2114, 14411, 2112, 14413, 2110, 14415, 2108, 14417, 2106, 14419, 2104, 14421, 2102, 14423, 2100, 14425, 2098, 14427, 2096, 14429, 2094, 14431, 2092, 14433, 2090, 14435, 2088, 14437, 2086, 14439, 2084, 14441, 2082, 14443, 2080, 14445, 2078, 14447, 2076, 14449, 2074, 14451, 2072, 14453, 2070, 14455, 2068, 14457, 2066, 14459, 2064, 14461, 2062, 14463, 2060, 14465, 2058, 14467, 2056, 14469, 2054, 14471, 2052, 14473, 2050, 14475, 2048, 14477, 2046, 14479, 2044, 14481, 2042, 14483, 2040, 14485, 2038, 14487, 2036, 14489, 2034, 14491, 2032, 14493, 2030, 14495, 2028, 14497, 2026, 14499, 2024, 14501, 2022, 14503, 2020, 14505, 2018, 14507, 2016, 14509, 2014, 14511, 2012, 14513, 2010, 14515, 2008, 14517, 2006, 14519, 2004, 14521, 2002, 14523, 2000, 14525, 1998, 14527, 1996, 14529, 1994, 14531, 1992, 14533, 1990, 14535, 1988, 14537, 1986, 14539, 1984, 14541, 1982, 14543, 1980, 14545, 1978, 14547, 1976, 14549, 1974, 14551, 1972, 14553, 1970, 14555, 1968, 14557, 1966, 14559, 1964, 14561, 1962, 14563, 1960, 14565, 1958, 14567, 1956, 14569, 1954, 14571, 1952, 14573, 1950, 14575, 1948, 14577, 1946, 14579, 1944, 14581, 1942, 14583, 1940, 14585, 1938, 14587, 1936, 14589, 1934, 14591, 1932, 14593, 1930, 14595, 1928, 14597, 1926, 14599, 1924, 14601, 1922, 14603, 1920, 14605, 1918, 14607, 1916, 14609, 1914, 14611, 1912, 14613, 1910, 14615, 1908, 14617, 1906, 14619, 1904, 14621, 1902, 14623, 1900, 14625, 1898, 14627, 1896, 14629, 1894, 14631, 1892, 14633, 1890, 14635, 1888, 14637, 1886, 14639, 1884, 14641, 1882, 14643, 1880, 14645, 1878, 14647, 1876, 14649, 1874, 14651, 1872, 14653, 1870, 14655, 1868, 14657, 1866, 14659, 1864, 14661, 1862, 14663, 1860, 14665, 1858, 14667, 1856, 14669, 1854, 14671, 1852, 14673, 1850, 14675, 1848, 14677, 1846, 14679, 1844, 14681, 1842, 14683, 1840, 14685, 1838, 14687, 1836, 14689, 1834, 14691, 1832, 14693, 1830, 14695, 1828, 14697, 1826, 14699, 1824, 14701, 1822, 14703, 1820, 14705, 1818, 14707, 1816, 14709, 1814, 14711, 1812, 14713, 1810, 14715, 1808, 14717, 1806, 14719, 1804, 14721, 1802, 14723, 1800, 14725, 1798, 14727, 1796, 14729, 1794, 14731, 1792, 14733, 1790, 14735, 1788, 14737, 1786, 14739, 1784, 14741, 1782, 14743, 1780, 14745, 1778, 14747, 1776, 14749, 1774, 14751, 1772, 14753, 1770, 14755, 1768, 14757, 1766, 14759, 1764, 14761, 1762, 14763, 1760, 14765, 1758, 14767, 1756, 14769, 1754, 14771, 1752, 14773, 1750, 14775, 1748, 14777, 1746, 14779, 1744, 14781, 1742, 14783, 1740, 14785, 1738, 14787, 1736, 14789, 1734, 14791, 1732, 14793, 1730, 14795, 1728, 14797, 1726, 14799, 1724, 14801, 1722, 14803, 1720, 14805, 1718, 14807, 1716, 14809, 1714, 14811, 1712, 14813, 1710, 14815, 1708, 14817, 1706, 14819, 1704, 14821, 1702, 14823, 1700, 14825, 1698, 14827, 1696, 14829, 1694, 14831, 1692, 14833, 1690, 14835, 1688, 14837, 1686, 14839, 1684, 14841, 1682, 14843, 1680, 14845, 1678, 14847, 1676, 14849, 1674, 14851, 1672, 14853, 1670, 14855, 1668, 14857, 1666, 14859, 1664, 14861, 1662, 14863, 1660, 14865, 1658, 14867, 1656, 14869, 1654, 14871, 1652, 14873, 1650, 14875, 1648, 14877, 1646, 14879, 1644, 14881, 1642, 14883, 1640, 14885, 1638, 14887, 1636, 14889, 1634, 14891, 1632, 14893, 1630, 14895, 1628, 14897, 1626, 14899, 1624, 14901, 1622, 14903, 1620, 14905, 1618, 14907, 1616, 14909, 1614, 14911, 1612, 14913, 1610, 14915, 1608, 14917, 1606, 14919, 1604, 14921, 1602, 14923, 1600, 14925, 1598, 14927, 1596, 14929, 1594, 14931, 1592, 14933, 1590, 14935, 1588, 14937, 1586, 14939, 1584, 14941, 1582, 14943, 1580, 14945, 1578, 14947, 1576, 14949, 1574, 14951, 1572, 14953, 1570, 14955, 1568, 14957, 1566, 14959, 1564, 14961, 1562, 14963, 1560, 14965, 1558, 14967, 1556, 14969, 1554, 14971, 1552, 14973, 1550, 14975, 1548, 14977, 1546, 14979, 1544, 14981, 1542, 14983, 1540, 14985, 1538, 14987, 1536, 14989, 1534, 14991, 1532, 14993, 1530, 14995, 1528, 14997, 1526, 14999, 1524, 15001, 1522, 15003, 1520, 15005, 1518, 15007, 1516, 15009, 1514, 15011, 1512, 15013, 1510, 15015, 1508, 15017, 1506, 15019, 1504, 15021, 1502, 15023, 1500, 15025, 1498, 15027, 1496, 15029, 1494, 15031, 1492, 15033, 1490, 15035, 1488, 15037, 1486, 15039, 1484, 15041, 1482, 15043, 1480, 15045, 1478, 15047, 1476, 15049, 1474, 15051, 1472, 15053, 1470, 15055, 1468, 15057, 1466, 15059, 1464, 15061, 1462, 15063, 1460, 15065, 1458, 15067, 1456, 15069, 1454, 15071, 1452, 15073, 1450, 15075, 1448, 15077, 1446, 15079, 1444, 15081, 1442, 15083, 1440, 15085, 1438, 15087, 1436, 15089, 1434, 15091, 1432, 15093, 1430, 15095, 1428, 15097, 1426, 15099, 1424, 15101, 1422, 15103, 1420, 15105, 1418, 15107, 1416, 15109, 1414, 15111, 1412, 15113, 1410, 15115, 1408, 15117, 1406, 15119, 1404, 15121, 1402, 15123, 1400, 15125, 1398, 15127, 1396, 15129, 1394, 15131, 1392, 15133, 1390, 15135, 1388, 15137, 1386, 15139, 1384, 15141, 1382, 15143, 1380, 15145, 1378, 15147, 1376, 15149, 1374, 15151, 1372, 15153, 1370, 15155, 1368, 15157, 1366, 15159, 1364, 15161, 1362, 15163, 1360, 15165, 1358, 15167, 1356, 15169, 1354, 15171, 1352, 15173, 1350, 15175, 1348, 15177, 1346, 15179, 1344, 15181, 1342, 15183, 1340, 15185, 1338, 15187, 1336, 15189, 1334, 15191, 1332, 15193, 1330, 15195, 1328, 15197, 1326, 15199, 1324, 15201, 1322, 15203, 1320, 15205, 1318, 15207, 1316, 15209, 1314, 15211, 1312, 15213, 1310, 15215, 1308, 15217, 1306, 15219, 1304, 15221, 1302, 15223, 1300, 15225, 1298, 15227, 1296, 15229, 1294, 15231, 1292, 15233, 1290, 15235, 1288, 15237, 1286, 15239, 1284, 15241, 1282, 15243, 1280, 15245, 1278, 15247, 1276, 15249, 1274, 15251, 1272, 15253, 1270, 15255, 1268, 15257, 1266, 15259, 1264, 15261, 1262, 15263, 1260, 15265, 1258, 15267, 1256, 15269, 1254, 15271, 1252, 15273, 1250, 15275, 1248, 15277, 1246, 15279, 1244, 15281, 1242, 15283, 1240, 15285, 1238, 15287, 1236, 15289, 1234, 15291, 1232, 15293, 1230, 15295, 1228, 15297, 1226, 15299, 1224, 15301, 1222, 15303, 1220, 15305, 1218, 15307, 1216, 15309, 1214, 15311, 1212, 15313, 1210, 15315, 1208, 15317, 1206, 15319, 1204, 15321, 1202, 15323, 1200, 15325, 1198, 15327, 1196, 15329, 1194, 15331, 1192, 15333, 1190, 15335, 1188, 15337, 1186, 15339, 1184, 15341, 1182, 15343, 1180, 15345, 1178, 15347, 1176, 15349, 1174, 15351, 1172, 15353, 1170, 15355, 1168, 15357, 1166, 15359, 1164, 15361, 1162, 15363, 1160, 15365, 1158, 15367, 1156, 15369, 1154, 15371, 1152, 15373, 1150, 15375, 1148, 15377, 1146, 15379, 1144, 15381, 1142, 15383, 1140, 15385, 1138, 15387, 1136, 15389, 1134, 15391, 1132, 15393, 1130, 15395, 1128, 15397, 1126, 15399, 1124, 15401, 1122, 15403, 1120, 15405, 1118, 15407, 1116, 15409, 1114, 15411, 1112, 15413, 1110, 15415, 1108, 15417, 1106, 15419, 1104, 15421, 1102, 15423, 1100, 15425, 1098, 15427, 1096, 15429, 1094, 15431, 1092, 15433, 1090, 15435, 1088, 15437, 1086, 15439, 1084, 15441, 1082, 15443, 1080, 15445, 1078, 15447, 1076, 15449, 1074, 15451, 1072, 15453, 1070, 15455, 1068, 15457, 1066, 15459, 1064, 15461, 1062, 15463, 1060, 15465, 1058, 15467, 1056, 15469, 1054, 15471, 1052, 15473, 1050, 15475, 1048, 15477, 1046, 15479, 1044, 15481, 1042, 15483, 1040, 15485, 1038, 15487, 1036, 15489, 1034, 15491, 1032, 15493, 1030, 15495, 1028, 15497, 1026, 15499, 1024, 15501, 1022, 15503, 1020, 15505, 1018, 15507, 1016, 15509, 1014, 15511, 1012, 15513, 1010, 15515, 1008, 15517, 1006, 15519, 1004, 15521, 1002, 15523, 1000, 15525, 998, 15527, 996, 15529, 994, 15531, 992, 15533, 990, 15535, 988, 15537, 986, 15539, 984, 15541, 982, 15543, 980, 15545, 978, 15547, 976, 15549, 974, 15551, 972, 15553, 970, 15555, 968, 15557, 966, 15559, 964, 15561, 962, 15563, 960, 15565, 958, 15567, 956, 15569, 954, 15571, 952, 15573, 950, 15575, 948, 15577, 946, 15579, 944, 15581, 942, 15583, 940, 15585, 938, 15587, 936, 15589, 934, 15591, 932, 15593, 930, 15595, 928, 15597, 926, 15599, 924, 15601, 922, 15603, 920, 15605, 918, 15607, 916, 15609, 914, 15611, 912, 15613, 910, 15615, 908, 15617, 906, 15619, 904, 15621, 902, 15623, 900, 15625, 898, 15627, 896, 15629, 894, 15631, 892, 15633, 890, 15635, 888, 15637, 886, 15639, 884, 15641, 882, 15643, 880, 15645, 878, 15647, 876, 15649, 874, 15651, 872, 15653, 870, 15655, 868, 15657, 866, 15659, 864, 15661, 862, 15663, 860, 15665, 858, 15667, 856, 15669, 854, 15671, 852, 15673, 850, 15675, 848, 15677, 846, 15679, 844, 15681, 842, 15683, 840, 15685, 838, 15687, 836, 15689, 834, 15691, 832, 15693, 830, 15695, 828, 15697, 826, 15699, 824, 15701, 822, 15703, 820, 15705, 818, 15707, 816, 15709, 814, 15711, 812, 15713, 810, 15715, 808, 15717, 806, 15719, 804, 15721, 802, 15723, 800, 15725, 798, 15727, 796, 15729, 794, 15731, 792, 15733, 790, 15735, 788, 15737, 786, 15739, 784, 15741, 782, 15743, 780, 15745, 778, 15747, 776, 15749, 774, 15751, 772, 15753, 770, 15755, 768, 15757, 766, 15759, 764, 15761, 762, 15763, 760, 15765, 758, 15767, 756, 15769, 754, 15771, 752, 15773, 750, 15775, 748, 15777, 746, 15779, 744, 15781, 742, 15783, 740, 15785, 738, 15787, 736, 15789, 734, 15791, 732, 15793, 730, 15795, 728, 15797, 726, 15799, 724, 15801, 722, 15803, 720, 15805, 718, 15807, 716, 15809, 714, 15811, 712, 15813, 710, 15815, 708, 15817, 706, 15819, 704, 15821, 702, 15823, 700, 15825, 698, 15827, 696, 15829, 694, 15831, 692, 15833, 690, 15835, 688, 15837, 686, 15839, 684, 15841, 682, 15843, 680, 15845, 678, 15847, 676, 15849, 674, 15851, 672, 15853, 670, 15855, 668, 15857, 666, 15859, 664, 15861, 662, 15863, 660, 15865, 658, 15867, 656, 15869, 654, 15871, 652, 15873, 650, 15875, 648, 15877, 646, 15879, 644, 15881, 642, 15883, 640, 15885, 638, 15887, 636, 15889, 634, 15891, 632, 15893, 630, 15895, 628, 15897, 626, 15899, 624, 15901, 622, 15903, 620, 15905, 618, 15907, 616, 15909, 614, 15911, 612, 15913, 610, 15915, 608, 15917, 606, 15919, 604, 15921, 602, 15923, 600, 15925, 598, 15927, 596, 15929, 594, 15931, 592, 15933, 590, 15935, 588, 15937, 586, 15939, 584, 15941, 582, 15943, 580, 15945, 578, 15947, 576, 15949, 574, 15951, 572, 15953, 570, 15955, 568, 15957, 566, 15959, 564, 15961, 562, 15963, 560, 15965, 558, 15967, 556, 15969, 554, 15971, 552, 15973, 550, 15975, 548, 15977, 546, 15979, 544, 15981, 542, 15983, 540, 15985, 538, 15987, 536, 15989, 534, 15991, 532, 15993, 530, 15995, 528, 15997, 526, 15999, 524, 16001, 522, 16003, 520, 16005, 518, 16007, 516, 16009, 514, 16011, 512, 16013, 510, 16015, 508, 16017, 506, 16019, 504, 16021, 502, 16023, 500, 16025, 498, 16027, 496, 16029, 494, 16031, 492, 16033, 490, 16035, 488, 16037, 486, 16039, 484, 16041, 482, 16043, 480, 16045, 478, 16047, 476, 16049, 474, 16051, 472, 16053, 470, 16055, 468, 16057, 466, 16059, 464, 16061, 462, 16063, 460, 16065, 458, 16067, 456, 16069, 454, 16071, 452, 16073, 450, 16075, 448, 16077, 446, 16079, 444, 16081, 442, 16083, 440, 16085, 438, 16087, 436, 16089, 434, 16091, 432, 16093, 430, 16095, 428, 16097, 426, 16099, 424, 16101, 422, 16103, 420, 16105, 418, 16107, 416, 16109, 414, 16111, 412, 16113, 410, 16115, 408, 16117, 406, 16119, 404, 16121, 402, 16123, 400, 16125, 398, 16127, 396, 16129, 394, 16131, 392, 16133, 390, 16135, 388, 16137, 386, 16139, 384, 16141, 382, 16143, 380, 16145, 378, 16147, 376, 16149, 374, 16151, 372, 16153, 370, 16155, 368, 16157, 366, 16159, 364, 16161, 362, 16163, 360, 16165, 358, 16167, 356, 16169, 354, 16171, 352, 16173, 350, 16175, 348, 16177, 346, 16179, 344, 16181, 342, 16183, 340, 16185, 338, 16187, 336, 16189, 334, 16191, 332, 16193, 330, 16195, 328, 16197, 326, 16199, 324, 16201, 322, 16203, 320, 16205, 318, 16207, 316, 16209, 314, 16211, 312, 16213, 310, 16215, 308, 16217, 306, 16219, 304, 16221, 302, 16223, 300, 16225, 298, 16227, 296, 16229, 294, 16231, 292, 16233, 290, 16235, 288, 16237, 286, 16239, 284, 16241, 282, 16243, 280, 16245, 278, 16247, 276, 16249, 274, 16251, 272, 16253, 270, 16255, 268, 16257, 266, 16259, 264, 16261, 262, 16263, 260, 16265, 258, 16267, 256, 16269, 254, 16271, 252, 16273, 250, 16275, 248, 16277, 246, 16279, 244, 16281, 242, 16283, 240, 16285, 238, 16287, 236, 16289, 234, 16291, 232, 16293, 230, 16295, 228, 16297, 226, 16299, 224, 16301, 222, 16303, 220, 16305, 218, 16307, 216, 16309, 214, 16311, 212, 16313, 210, 16315, 208, 16317, 206, 16319, 204, 16321, 202, 16323, 200, 16325, 198, 16327, 196, 16329, 194, 16331, 192, 16333, 190, 16335, 188, 16337, 186, 16339, 184, 16341, 182, 16343, 180, 16345, 178, 16347, 176, 16349, 174, 16351, 172, 16353, 170, 16355, 168, 16357, 166, 16359, 164, 16361, 162, 16363, 160, 16365, 158, 16367, 156, 16369, 154, 16371, 152, 16373, 150, 16375, 148, 16377, 146, 16379, 144, 16381, 142, 16383, 140, 16385, 138, 16387, 136, 16389, 134, 16391, 132, 16393, 130, 16395, 128, 16397, 126, 16399, 124, 16401, 122, 16403, 120, 16405, 118, 16407, 116, 16409, 114, 16411, 112, 16413, 110, 16415, 108, 16417, 106, 16419, 104, 16421, 102, 16423, 100, 16425, 98, 16427, 96, 16429, 94, 16431, 92, 16433, 90, 16435, 88, 16437, 86, 16439, 84, 16441, 82, 16443, 80, 16445, 78, 16447, 76, 16449, 74, 16451, 72, 16453, 70, 16455, 68, 16457, 66, 16459, 64, 16461, 62, 16463, 60, 16465, 58, 16467, 56, 16469, 54, 16471, 52, 16473, 50, 16475, 48, 16477, 46, 16479, 44, 16481, 42, 16483, 40, 16485, 38, 16487, 36, 16489, 34, 16491, 32, 16493, 30, 16495, 28, 16497, 26, 16499, 24, 16501, 22, 16503, 20, 16505, 18, 16507, 16, 16509, 14, 16511, 12, 16513, 10, 16515, 8, 16517, 6, 16519, 4, 16521, 2, 16523]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s7/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-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-l6-s7/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d97054ac60de89ea98e865b98909d1f3012c0da9 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 16524, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s7/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-rlve-prefix-sum-permutation-l6-s7/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-rlve-prime-graph-coloring-l3-s7/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l3-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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-prime-graph-coloring-l3-s7/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8acc96bb582cc69227f10ef487931081cc922212 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 67, "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-s7/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..60b9b4c7bd2d5158edac5e64c1f4ec2d0747347b --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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' +{"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]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s7/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l3-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s7/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-s7/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8acc96bb582cc69227f10ef487931081cc922212 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 67, "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-s7/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l3-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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-prime-graph-coloring-l3-s7/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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-prime-graph-coloring-l3-s9/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l3-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-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-prime-graph-coloring-l3-s9/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c726f4a124f45e756c9683e9d02424f3c6841252 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 42, "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-s9/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4946f8a82c105ea778690b8a6c756573a30867e6 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-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' +{"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]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s9/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l3-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s9/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-s9/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c726f4a124f45e756c9683e9d02424f3c6841252 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 42, "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-s9/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l3-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-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-prime-graph-coloring-l3-s9/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-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-recursive-sequence-sum-l4-s2/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l4-s2/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..043be261caa74e29d10fde98a3ca92a275f9c859 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"F0": 128, "A": 7, "B": 7023, "S": 15110584069633972810, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l4-s2/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..374e6bd87a2db462d1082e00d7ff952a97e5b0a5 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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' +{"indices": [3, 5, 6, 11, 14, 15, 17, 19]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l4-s2/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l4-s2/tests/check.py @@ -0,0 +1,29 @@ +from run import Invalid, int_list + + +def F(inst, n): + F0, A, B = inst["F0"], inst["A"], inst["B"] + if A == 1: + return F0 + n * B + An = A ** n + return An * F0 + B * (An - 1) // (A - 1) + + +def check(inst, ans): + S = inst["S"] + idx = int_list(ans.get("indices"), None, 1, None, "indices") + if not idx: + raise Invalid("need at least one index") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + total = 0 + for n in idx: + # F is strictly increasing with F(n) >= n and, when A >= 2, F(n) >= 2^(n-1); bail out before big powers + if n > S or (inst["A"] >= 2 and n - 1 > S.bit_length()): + raise Invalid(f"F({n}) exceeds S") + total += F(inst, n) + if total > S: + raise Invalid("sum exceeds S") + if total != S: + raise Invalid(f"sum is {total}, need {S}") + return None, {} diff --git a/tasks/construct-rlve-recursive-sequence-sum-l4-s2/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..043be261caa74e29d10fde98a3ca92a275f9c859 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"F0": 128, "A": 7, "B": 7023, "S": 15110584069633972810, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l4-s2/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l4-s2/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l4-s5/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l4-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l4-s5/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l4-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6285decc4e4af1cbbe391c43dfcd786e0e7272d0 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l4-s5/environment/instance.json @@ -0,0 +1 @@ +{"F0": 54, "A": 1, "B": 1695, "S": 131001, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l4-s5/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l4-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f072346ad11c5b04d30828b46e1b5c1649586d80 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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' +{"indices": [1, 2, 3, 5, 9, 11, 13, 16, 17]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l4-s5/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l4-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l4-s5/tests/check.py @@ -0,0 +1,29 @@ +from run import Invalid, int_list + + +def F(inst, n): + F0, A, B = inst["F0"], inst["A"], inst["B"] + if A == 1: + return F0 + n * B + An = A ** n + return An * F0 + B * (An - 1) // (A - 1) + + +def check(inst, ans): + S = inst["S"] + idx = int_list(ans.get("indices"), None, 1, None, "indices") + if not idx: + raise Invalid("need at least one index") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + total = 0 + for n in idx: + # F is strictly increasing with F(n) >= n and, when A >= 2, F(n) >= 2^(n-1); bail out before big powers + if n > S or (inst["A"] >= 2 and n - 1 > S.bit_length()): + raise Invalid(f"F({n}) exceeds S") + total += F(inst, n) + if total > S: + raise Invalid("sum exceeds S") + if total != S: + raise Invalid(f"sum is {total}, need {S}") + return None, {} diff --git a/tasks/construct-rlve-recursive-sequence-sum-l4-s5/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l4-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6285decc4e4af1cbbe391c43dfcd786e0e7272d0 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l4-s5/tests/instance.json @@ -0,0 +1 @@ +{"F0": 54, "A": 1, "B": 1695, "S": 131001, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l4-s5/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l4-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l4-s5/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l4-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-round-robin-scores-l1-s0/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s0/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fad9f58c594120868cd1b41040083c78b0e75eec --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"W": [3, 2, 4, 5], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s0/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..70ec4fb3142940741b6326d0442294b436204c31 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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' +{"A": ["0111", "1001", "1200", "1120"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l1-s0/tests/check.py b/tasks/construct-rlve-round-robin-scores-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-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-l1-s0/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fad9f58c594120868cd1b41040083c78b0e75eec --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"W": [3, 2, 4, 5], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s0/tests/run.py b/tasks/construct-rlve-round-robin-scores-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s0/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s9/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l1-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s9/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..62080f897d5624c0cefdd2a2a1d1a8a41e89cded --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s9/environment/instance.json @@ -0,0 +1 @@ +{"W": [9, 2, 2, 2], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s9/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l1-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fd3fe13dce04d8977e79bdd4a4bee79e4befc4bb --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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' +{"A": ["0222", "0011", "0101", "0110"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l1-s9/tests/check.py b/tasks/construct-rlve-round-robin-scores-l1-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-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-l1-s9/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..62080f897d5624c0cefdd2a2a1d1a8a41e89cded --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s9/tests/instance.json @@ -0,0 +1 @@ +{"W": [9, 2, 2, 2], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s9/tests/run.py b/tasks/construct-rlve-round-robin-scores-l1-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s9/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l1-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l5-s1/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l5-s1/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b255b856bf2dca3a757c89c233d81f7564ece47b --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"W": [17, 14, 18, 31, 27, 18, 18, 22, 19, 17, 21, 19, 30, 19, 20, 22, 27, 27], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s1/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3122e600952eb2e86034c5927ff503f9d844b60f --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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' +{"A": ["011101112120011110", "101012101121000001", "110110211101111210", "121021112222021102", "211002010110212222", "102100011101011212", "110122002201010001", "121111201210012101", "011021010201100212", "111011000012221010", "002012212101201010", "211021121010011110", "221202221002012200", "121011112021101001", "121101202111010111", "120100210221021011", "121201221111221100", "212000110222211120"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l5-s1/tests/check.py b/tasks/construct-rlve-round-robin-scores-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-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-l5-s1/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b255b856bf2dca3a757c89c233d81f7564ece47b --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"W": [17, 14, 18, 31, 27, 18, 18, 22, 19, 17, 21, 19, 30, 19, 20, 22, 27, 27], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s1/tests/run.py b/tasks/construct-rlve-round-robin-scores-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l5-s1/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l5-s6/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l5-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l5-s6/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..baca887a61a5e1498b3bf550eb3b5746a0c11e30 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s6/environment/instance.json @@ -0,0 +1 @@ +{"W": [24, 23, 19, 22, 13, 24, 13, 18, 21, 18, 17, 19, 19, 18, 17, 22, 15, 20], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s6/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l5-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7d6a192adc78d91cf9f59b98ae6b7fae24f32967 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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' +{"A": ["012120112111211111", "102111211111112111", "000111121112111111", "111021212111111011", "011001111110011111", "211110110122121111", "101011011101110111", "110111100111012121", "011012120221111010", "111111110011111121", "111110210101111111", "110120111110111211", "011121121111010111", "111110111111102111", "101111201111200110", "111211112110111012", "111111101011111101", "111111112111112010"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l5-s6/tests/check.py b/tasks/construct-rlve-round-robin-scores-l5-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s6/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-s6/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..baca887a61a5e1498b3bf550eb3b5746a0c11e30 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s6/tests/instance.json @@ -0,0 +1 @@ +{"W": [24, 23, 19, 22, 13, 24, 13, 18, 21, 18, 17, 19, 19, 18, 17, 22, 15, 20], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s6/tests/run.py b/tasks/construct-rlve-round-robin-scores-l5-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l5-s6/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l5-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-shortest-path-count-l2-s3/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s3/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0af5d3bd2d2189e6510d4164fbf8aa8e85ecaaa1 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"K": 393, "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-s3/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bcd727181299a9032d03073ac08f9acd9583c525 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 27, "adj": ["NNYYNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNYNNNNN", "NNNNYYNNYYNNNNNNNNNNNYNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNYN", "NNNNNNNNNNNNYYNNYYNNNNNNNYN", "NNNNNNNNNNNNNNYYNNNNNNNNNNY", "NNNNNNNNNNNNNNYYNNNNNNNNNNY", "YNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNYYNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNYYNNNNNNNNYNY", "NYNNNNNNNNNNNNNNYYNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l2-s3/tests/check.py b/tasks/construct-rlve-shortest-path-count-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-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-l2-s3/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0af5d3bd2d2189e6510d4164fbf8aa8e85ecaaa1 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"K": 393, "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-s3/tests/run.py b/tasks/construct-rlve-shortest-path-count-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s3/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s4/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s4/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b1e705961f45a9a63a1be79ae0da33c18375782b --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"K": 58, "n_max": 39, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s4/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0795265c8c2533017e1f37d5fc396d9dc373ce2c --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 18, "adj": ["NNYYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNYNNNN", "YNNNYYNNNNNNNYNNNN", "NNYYNNYYNNNNNNNNNN", "NNYYNNYYNNNNNNNNNN", "NNNNYYNNYYNNNNNYNN", "NNNNYYNNYYNNNNNYNN", "NNNNNNYYNNYYNNNNYN", "NNNNNNYYNNYYNNNNYN", "NNNNNNNNYYNNNNNNNY", "NNNNNNNNYYNNNNNNNY", "NNNNNNNNNNNNNYNNNN", "NNYYNNNNNNNNYNYNNN", "NNNNNNNNNNNNNYNYNN", "NNNNNNYYNNNNNNYNYN", "NNNNNNNNYYNNNNNYNY", "NYNNNNNNNNYYNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l2-s4/tests/check.py b/tasks/construct-rlve-shortest-path-count-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s4/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-s4/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b1e705961f45a9a63a1be79ae0da33c18375782b --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"K": 58, "n_max": 39, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s4/tests/run.py b/tasks/construct-rlve-shortest-path-count-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s4/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l6-s5/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-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-l6-s5/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..69c684f1aceebf80d902566f82661fca07c28fa9 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"K": 163750090544363596, "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-s5/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..43eb6815edf66387c4ddd8fb3261911d621cc9f3 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-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": 174, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l6-s5/tests/check.py b/tasks/construct-rlve-shortest-path-count-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-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-l6-s5/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..69c684f1aceebf80d902566f82661fca07c28fa9 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"K": 163750090544363596, "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-s5/tests/run.py b/tasks/construct-rlve-shortest-path-count-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-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-l6-s5/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-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-smallest-enclosing-circle-l1-s8/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l1-s8/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5d4a092da7e260c8fd3e776bbbba20e121e3de6f --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"points": [[1, 0], [2, 0], [4, 6], [6, 3]], "r_opt": 3.3579026495837594, "r2_num": 1105, "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-s8/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c8f72c68cda4ede0a098e65c8b6272a38d9b7f62 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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' +{"x": 2.642857142857143, "y": 2.9285714285714284, "r": 3.3579026505837595} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s8/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-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-l1-s8/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5d4a092da7e260c8fd3e776bbbba20e121e3de6f --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"points": [[1, 0], [2, 0], [4, 6], [6, 3]], "r_opt": 3.3579026495837594, "r2_num": 1105, "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-s8/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l1-s8/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s0/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s0/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ea267201ea3bb7919744c66576b8d6c24c6153f3 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"points": [[0, 57], [4, 36], [4, 42], [5, 69], [10, 60], [10, 75], [13, 86], [14, 32], [16, 53], [18, 66], [19, 103], [19, 113], [20, 29], [20, 116], [25, 96], [28, 92], [29, 8], [32, 9], [34, 51], [36, 87], [37, 116], [37, 120], [41, 1], [45, 11], [45, 68], [48, 72], [50, 81], [52, 97], [52, 117], [53, 42], [56, 50], [59, 64], [59, 93], [60, 112], [61, 33], [62, 101], [64, 45], [66, 71], [71, 71], [71, 83], [72, 45], [74, 21], [76, 50], [78, 57], [79, 36], [80, 24], [81, 10], [82, 67], [87, 21], [90, 37], [98, 104], [103, 26], [103, 49], [106, 97], [108, 89], [111, 34], [111, 66], [112, 13], [116, 94], [117, 65]], "r_opt": 69.05251624669444, "r2_num": 19073, "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-l5-s0/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..775f42d1bc27575f97c5d339f1c70ad9dad3c7c5 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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": 66.0, "y": 64.5, "r": 69.05251624769444} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s0/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-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-l5-s0/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ea267201ea3bb7919744c66576b8d6c24c6153f3 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"points": [[0, 57], [4, 36], [4, 42], [5, 69], [10, 60], [10, 75], [13, 86], [14, 32], [16, 53], [18, 66], [19, 103], [19, 113], [20, 29], [20, 116], [25, 96], [28, 92], [29, 8], [32, 9], [34, 51], [36, 87], [37, 116], [37, 120], [41, 1], [45, 11], [45, 68], [48, 72], [50, 81], [52, 97], [52, 117], [53, 42], [56, 50], [59, 64], [59, 93], [60, 112], [61, 33], [62, 101], [64, 45], [66, 71], [71, 71], [71, 83], [72, 45], [74, 21], [76, 50], [78, 57], [79, 36], [80, 24], [81, 10], [82, 67], [87, 21], [90, 37], [98, 104], [103, 26], [103, 49], [106, 97], [108, 89], [111, 34], [111, 66], [112, 13], [116, 94], [117, 65]], "r_opt": 69.05251624669444, "r2_num": 19073, "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-l5-s0/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s0/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s7/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s7/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9a2eea268ab795309c436f0c95a960e43a29ac87 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"points": [[6, 85], [8, 19], [11, 62], [11, 103], [12, 113], [15, 74], [15, 97], [20, 47], [20, 106], [23, 103], [24, 46], [25, 97], [26, 90], [27, 9], [31, 75], [32, 1], [32, 88], [34, 105], [35, 14], [36, 81], [38, 59], [39, 8], [43, 95], [47, 44], [50, 62], [51, 94], [52, 111], [52, 117], [54, 1], [60, 64], [67, 27], [69, 56], [70, 26], [70, 52], [72, 74], [75, 25], [76, 25], [77, 110], [78, 2], [79, 20], [81, 61], [83, 32], [84, 105], [85, 98], [88, 85], [91, 65], [94, 14], [94, 112], [98, 0], [99, 67], [101, 31], [103, 73], [110, 84], [110, 117], [113, 27], [115, 101], [117, 0], [117, 41], [118, 31], [118, 114]], "r_opt": 77.13930245665392, "r2_num": 1737524597233, "r2_den": 291997778, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s7/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5e79bae320fc9e88ca2b87aea93683f5b3481d2a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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' +{"x": 65.52871803360092, "y": 57.45588843830175, "r": 77.13930245765393} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s7/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-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-l5-s7/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9a2eea268ab795309c436f0c95a960e43a29ac87 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"points": [[6, 85], [8, 19], [11, 62], [11, 103], [12, 113], [15, 74], [15, 97], [20, 47], [20, 106], [23, 103], [24, 46], [25, 97], [26, 90], [27, 9], [31, 75], [32, 1], [32, 88], [34, 105], [35, 14], [36, 81], [38, 59], [39, 8], [43, 95], [47, 44], [50, 62], [51, 94], [52, 111], [52, 117], [54, 1], [60, 64], [67, 27], [69, 56], [70, 26], [70, 52], [72, 74], [75, 25], [76, 25], [77, 110], [78, 2], [79, 20], [81, 61], [83, 32], [84, 105], [85, 98], [88, 85], [91, 65], [94, 14], [94, 112], [98, 0], [99, 67], [101, 31], [103, 73], [110, 84], [110, 117], [113, 27], [115, 101], [117, 0], [117, 41], [118, 31], [118, 114]], "r_opt": 77.13930245665392, "r2_num": 1737524597233, "r2_den": 291997778, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s7/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s7/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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/optimize-ae-p1-ff-kakeya-d3-p31/environment/Dockerfile b/tasks/optimize-ae-p1-ff-kakeya-d3-p31/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p31/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-p1-ff-kakeya-d3-p31/environment/instance.json b/tasks/optimize-ae-p1-ff-kakeya-d3-p31/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bc2bb78de5a95127ced7a6ec7020199cb896553e --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p31/environment/instance.json @@ -0,0 +1 @@ +{"p": 31, "d": 3, "direction": "minimize", "family": "ae_p1_ff_kakeya", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p31/solution/solve.sh b/tasks/optimize-ae-p1-ff-kakeya-d3-p31/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9f0cf1e870e7c26054d53a69eac2b5a65f3d3701 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p31/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, 0], [0, 0, 1], [0, 0, 2], [0, 0, 3], [0, 0, 4], [0, 0, 5], [0, 0, 6], [0, 0, 7], [0, 0, 8], [0, 0, 9], [0, 0, 10], [0, 0, 11], [0, 0, 12], [0, 0, 13], [0, 0, 14], [0, 0, 15], [0, 0, 16], [0, 0, 17], [0, 0, 18], [0, 0, 19], [0, 0, 20], [0, 0, 21], [0, 0, 22], [0, 0, 23], [0, 0, 24], [0, 0, 25], [0, 0, 26], [0, 0, 27], [0, 0, 28], [0, 0, 29], [0, 0, 30], [0, 1, 1], [0, 1, 2], [0, 1, 3], [0, 1, 4], [0, 1, 6], [0, 1, 9], [0, 1, 12], [0, 1, 14], [0, 1, 15], [0, 1, 16], [0, 1, 18], [0, 1, 20], [0, 1, 21], [0, 1, 24], [0, 1, 25], [0, 1, 26], [0, 1, 27], [0, 1, 29], [0, 1, 30], [0, 2, 0], [0, 2, 2], [0, 2, 3], [0, 2, 4], [0, 2, 5], [0, 2, 6], [0, 2, 7], [0, 2, 8], [0, 2, 10], [0, 2, 11], [0, 2, 13], [0, 2, 17], [0, 2, 18], [0, 2, 19], [0, 2, 20], [0, 2, 22], [0, 2, 24], [0, 2, 28], [0, 2, 29], [0, 2, 30], [0, 3, 3], [0, 3, 4], [0, 3, 5], [0, 3, 6], [0, 3, 8], [0, 3, 9], [0, 3, 11], [0, 3, 12], [0, 3, 13], [0, 3, 16], [0, 3, 19], [0, 3, 24], [0, 3, 25], [0, 3, 26], [0, 3, 28], [0, 3, 30], [0, 4, 1], [0, 4, 2], [0, 4, 3], [0, 4, 5], [0, 4, 6], [0, 4, 7], [0, 4, 9], [0, 4, 11], [0, 4, 12], [0, 4, 13], [0, 4, 14], [0, 4, 15], [0, 4, 16], [0, 4, 17], [0, 4, 19], [0, 4, 20], [0, 4, 21], [0, 4, 24], [0, 4, 25], [0, 4, 27], [0, 4, 30], [0, 5, 0], [0, 5, 3], [0, 5, 6], [0, 5, 8], [0, 5, 11], [0, 5, 12], [0, 5, 13], [0, 5, 14], [0, 5, 15], [0, 5, 17], [0, 5, 21], [0, 5, 22], [0, 5, 23], [0, 5, 24], [0, 5, 25], [0, 5, 26], [0, 5, 27], [0, 5, 29], [0, 5, 30], [0, 6, 1], [0, 6, 2], [0, 6, 3], [0, 6, 4], [0, 6, 5], [0, 6, 7], [0, 6, 8], [0, 6, 10], [0, 6, 11], [0, 6, 12], [0, 6, 14], [0, 6, 15], [0, 6, 16], [0, 6, 18], [0, 6, 23], [0, 6, 24], [0, 6, 25], [0, 6, 27], [0, 6, 29], [0, 7, 1], [0, 7, 6], [0, 7, 7], [0, 7, 8], [0, 7, 10], [0, 7, 12], [0, 7, 13], [0, 7, 15], [0, 7, 16], [0, 7, 17], [0, 7, 18], [0, 7, 19], [0, 7, 21], [0, 7, 22], [0, 7, 24], [0, 7, 25], [0, 7, 26], [0, 7, 27], [0, 7, 29], [0, 8, 1], [0, 8, 2], [0, 8, 3], [0, 8, 4], [0, 8, 6], [0, 8, 7], [0, 8, 9], [0, 8, 10], [0, 8, 11], [0, 8, 14], [0, 8, 16], [0, 8, 17], [0, 8, 22], [0, 8, 23], [0, 8, 24], [0, 8, 25], [0, 8, 26], [0, 8, 28], [0, 8, 29], [0, 9, 1], [0, 9, 4], [0, 9, 9], [0, 9, 10], [0, 9, 11], [0, 9, 13], [0, 9, 15], [0, 9, 19], [0, 9, 20], [0, 9, 21], [0, 9, 22], [0, 9, 24], [0, 9, 25], [0, 9, 27], [0, 9, 28], [0, 9, 29], [0, 10, 0], [0, 10, 2], [0, 10, 4], [0, 10, 8], [0, 10, 9], [0, 10, 10], [0, 10, 11], [0, 10, 12], [0, 10, 13], [0, 10, 14], [0, 10, 16], [0, 10, 17], [0, 10, 18], [0, 10, 19], [0, 10, 20], [0, 10, 21], [0, 10, 24], [0, 10, 27], [0, 10, 29], [0, 10, 30], [0, 11, 0], [0, 11, 1], [0, 11, 2], [0, 11, 4], [0, 11, 5], [0, 11, 7], [0, 11, 8], [0, 11, 9], [0, 11, 12], [0, 11, 13], [0, 11, 15], [0, 11, 17], [0, 11, 19], [0, 11, 20], [0, 11, 21], [0, 11, 22], [0, 11, 24], [0, 11, 26], [0, 11, 30], [0, 12, 0], [0, 12, 1], [0, 12, 2], [0, 12, 5], [0, 12, 7], [0, 12, 8], [0, 12, 10], [0, 12, 13], [0, 12, 14], [0, 12, 15], [0, 12, 17], [0, 12, 18], [0, 12, 19], [0, 12, 21], [0, 12, 22], [0, 12, 23], [0, 12, 24], [0, 12, 25], [0, 12, 26], [0, 12, 28], [0, 12, 29], [0, 13, 0], [0, 13, 3], [0, 13, 8], [0, 13, 9], [0, 13, 10], [0, 13, 11], [0, 13, 12], [0, 13, 14], [0, 13, 15], [0, 13, 16], [0, 13, 18], [0, 13, 19], [0, 13, 20], [0, 13, 21], [0, 13, 23], [0, 13, 24], [0, 13, 26], [0, 13, 27], [0, 13, 28], [0, 14, 0], [0, 14, 4], [0, 14, 5], [0, 14, 6], [0, 14, 7], [0, 14, 9], [0, 14, 11], [0, 14, 15], [0, 14, 16], [0, 14, 17], [0, 14, 18], [0, 14, 19], [0, 14, 20], [0, 14, 21], [0, 14, 22], [0, 14, 23], [0, 14, 24], [0, 14, 25], [0, 14, 28], [0, 15, 3], [0, 15, 4], [0, 15, 5], [0, 15, 6], [0, 15, 8], [0, 15, 10], [0, 15, 13], [0, 15, 14], [0, 15, 15], [0, 15, 16], [0, 15, 17], [0, 15, 18], [0, 15, 19], [0, 15, 20], [0, 15, 21], [0, 15, 22], [0, 15, 23], [0, 15, 24], [0, 15, 26], [0, 15, 27], [0, 15, 30], [0, 16, 0], [0, 16, 2], [0, 16, 4], [0, 16, 5], [0, 16, 6], [0, 16, 7], [0, 16, 9], [0, 16, 11], [0, 16, 14], [0, 16, 15], [0, 16, 16], [0, 16, 17], [0, 16, 18], [0, 16, 20], [0, 16, 21], [0, 16, 22], [0, 16, 23], [0, 16, 24], [0, 16, 25], [0, 16, 28], [0, 17, 0], [0, 17, 1], [0, 17, 3], [0, 17, 5], [0, 17, 7], [0, 17, 8], [0, 17, 9], [0, 17, 10], [0, 17, 12], [0, 17, 14], [0, 17, 18], [0, 17, 19], [0, 17, 20], [0, 17, 21], [0, 17, 23], [0, 17, 24], [0, 17, 26], [0, 17, 27], [0, 17, 28], [0, 18, 0], [0, 18, 1], [0, 18, 2], [0, 18, 4], [0, 18, 5], [0, 18, 6], [0, 18, 8], [0, 18, 13], [0, 18, 14], [0, 18, 15], [0, 18, 16], [0, 18, 17], [0, 18, 19], [0, 18, 20], [0, 18, 23], [0, 18, 24], [0, 18, 25], [0, 18, 26], [0, 18, 28], [0, 18, 29], [0, 19, 0], [0, 19, 1], [0, 19, 2], [0, 19, 3], [0, 19, 4], [0, 19, 5], [0, 19, 7], [0, 19, 8], [0, 19, 9], [0, 19, 12], [0, 19, 14], [0, 19, 15], [0, 19, 17], [0, 19, 20], [0, 19, 21], [0, 19, 22], [0, 19, 24], [0, 19, 25], [0, 19, 26], [0, 19, 30], [0, 20, 0], [0, 20, 2], [0, 20, 4], [0, 20, 8], [0, 20, 9], [0, 20, 10], [0, 20, 11], [0, 20, 13], [0, 20, 14], [0, 20, 16], [0, 20, 17], [0, 20, 18], [0, 20, 21], [0, 20, 24], [0, 20, 29], [0, 20, 30], [0, 21, 1], [0, 21, 4], [0, 21, 7], [0, 21, 9], [0, 21, 10], [0, 21, 11], [0, 21, 13], [0, 21, 15], [0, 21, 16], [0, 21, 19], [0, 21, 20], [0, 21, 21], [0, 21, 22], [0, 21, 23], [0, 21, 24], [0, 21, 25], [0, 21, 27], [0, 21, 28], [0, 21, 29], [0, 21, 30], [0, 22, 0], [0, 22, 1], [0, 22, 2], [0, 22, 3], [0, 22, 4], [0, 22, 6], [0, 22, 7], [0, 22, 8], [0, 22, 9], [0, 22, 10], [0, 22, 11], [0, 22, 12], [0, 22, 14], [0, 22, 17], [0, 22, 22], [0, 22, 23], [0, 22, 24], [0, 22, 26], [0, 22, 27], [0, 22, 28], [0, 23, 1], [0, 23, 6], [0, 23, 7], [0, 23, 8], [0, 23, 10], [0, 23, 11], [0, 23, 12], [0, 23, 13], [0, 23, 16], [0, 23, 17], [0, 23, 18], [0, 23, 19], [0, 23, 21], [0, 23, 22], [0, 23, 24], [0, 23, 25], [0, 23, 26], [0, 23, 28], [0, 23, 29], [0, 24, 2], [0, 24, 3], [0, 24, 4], [0, 24, 5], [0, 24, 7], [0, 24, 8], [0, 24, 10], [0, 24, 11], [0, 24, 12], [0, 24, 13], [0, 24, 14], [0, 24, 15], [0, 24, 18], [0, 24, 23], [0, 24, 24], [0, 24, 25], [0, 24, 26], [0, 24, 27], [0, 24, 29], [0, 25, 0], [0, 25, 3], [0, 25, 4], [0, 25, 5], [0, 25, 6], [0, 25, 9], [0, 25, 11], [0, 25, 12], [0, 25, 13], [0, 25, 15], [0, 25, 17], [0, 25, 21], [0, 25, 22], [0, 25, 23], [0, 25, 24], [0, 25, 26], [0, 25, 27], [0, 25, 28], [0, 25, 29], [0, 25, 30], [0, 26, 1], [0, 26, 2], [0, 26, 3], [0, 26, 4], [0, 26, 5], [0, 26, 7], [0, 26, 10], [0, 26, 11], [0, 26, 12], [0, 26, 13], [0, 26, 14], [0, 26, 15], [0, 26, 16], [0, 26, 17], [0, 26, 19], [0, 26, 20], [0, 26, 21], [0, 26, 24], [0, 26, 27], [0, 26, 29], [0, 27, 1], [0, 27, 2], [0, 27, 3], [0, 27, 4], [0, 27, 5], [0, 27, 6], [0, 27, 7], [0, 27, 8], [0, 27, 9], [0, 27, 11], [0, 27, 12], [0, 27, 13], [0, 27, 16], [0, 27, 17], [0, 27, 19], [0, 27, 22], [0, 27, 24], [0, 27, 25], [0, 27, 26], [0, 27, 28], [0, 27, 30], [0, 28, 0], [0, 28, 2], [0, 28, 3], [0, 28, 5], [0, 28, 6], [0, 28, 7], [0, 28, 8], [0, 28, 10], [0, 28, 13], [0, 28, 16], [0, 28, 18], [0, 28, 19], [0, 28, 20], [0, 28, 22], [0, 28, 23], [0, 28, 24], [0, 28, 28], [0, 28, 29], [0, 28, 30], [0, 29, 0], [0, 29, 1], [0, 29, 2], [0, 29, 3], [0, 29, 4], [0, 29, 6], [0, 29, 7], [0, 29, 8], [0, 29, 9], [0, 29, 14], [0, 29, 15], [0, 29, 16], [0, 29, 18], [0, 29, 20], [0, 29, 24], [0, 29, 25], [0, 29, 26], [0, 29, 27], [0, 29, 29], [0, 29, 30], [0, 30, 0], [0, 30, 1], [0, 30, 4], [0, 30, 7], [0, 30, 8], [0, 30, 12], [0, 30, 13], [0, 30, 14], [0, 30, 16], [0, 30, 18], [0, 30, 19], [0, 30, 20], [0, 30, 22], [0, 30, 23], [0, 30, 24], [0, 30, 25], [0, 30, 27], [0, 30, 28], [0, 30, 30], [1, 0, 0], [1, 0, 1], [1, 0, 3], [1, 0, 6], [1, 0, 8], [1, 0, 9], [1, 0, 13], [1, 0, 27], [1, 1, 0], [1, 1, 1], [1, 1, 2], [1, 1, 4], [1, 1, 5], [1, 1, 7], [1, 1, 8], [1, 1, 9], [1, 1, 20], [1, 2, 1], [1, 2, 3], [1, 2, 6], [1, 2, 8], [1, 2, 11], [1, 2, 19], [1, 2, 20], [1, 2, 21], [1, 2, 29], [1, 3, 2], [1, 3, 3], [1, 3, 6], [1, 3, 7], [1, 3, 10], [1, 3, 18], [1, 3, 20], [1, 3, 22], [1, 3, 30], [1, 4, 4], [1, 4, 5], [1, 4, 12], [1, 4, 17], [1, 4, 19], [1, 4, 21], [1, 4, 23], [1, 4, 28], [1, 5, 1], [1, 5, 4], [1, 5, 5], [1, 5, 8], [1, 5, 11], [1, 5, 18], [1, 5, 20], [1, 5, 22], [1, 5, 29], [1, 6, 2], [1, 6, 7], [1, 6, 10], [1, 6, 15], [1, 6, 19], [1, 6, 21], [1, 6, 25], [1, 6, 30], [1, 7, 3], [1, 7, 6], [1, 7, 14], [1, 7, 15], [1, 7, 16], [1, 7, 20], [1, 7, 24], [1, 7, 25], [1, 7, 26], [1, 8, 1], [1, 8, 8], [1, 8, 14], [1, 8, 15], [1, 8, 17], [1, 8, 23], [1, 8, 25], [1, 8, 26], [1, 9, 12], [1, 9, 13], [1, 9, 16], [1, 9, 18], [1, 9, 22], [1, 9, 24], [1, 9, 27], [1, 9, 28], [1, 10, 3], [1, 10, 6], [1, 10, 11], [1, 10, 13], [1, 10, 17], [1, 10, 23], [1, 10, 27], [1, 10, 29], [1, 11, 10], [1, 11, 11], [1, 11, 12], [1, 11, 14], [1, 11, 20], [1, 11, 26], [1, 11, 28], [1, 11, 29], [1, 11, 30], [1, 12, 11], [1, 12, 13], [1, 12, 15], [1, 12, 19], [1, 12, 20], [1, 12, 21], [1, 12, 25], [1, 12, 27], [1, 12, 29], [1, 13, 0], [1, 13, 9], [1, 13, 12], [1, 13, 14], [1, 13, 19], [1, 13, 20], [1, 13, 21], [1, 13, 26], [1, 13, 28], [1, 14, 2], [1, 14, 7], [1, 14, 13], [1, 14, 17], [1, 14, 18], [1, 14, 20], [1, 14, 22], [1, 14, 23], [1, 14, 27], [1, 15, 1], [1, 15, 8], [1, 15, 16], [1, 15, 18], [1, 15, 19], [1, 15, 21], [1, 15, 22], [1, 15, 24], [1, 16, 0], [1, 16, 9], [1, 16, 15], [1, 16, 16], [1, 16, 17], [1, 16, 20], [1, 16, 23], [1, 16, 24], [1, 16, 25], [1, 17, 4], [1, 17, 5], [1, 17, 10], [1, 17, 16], [1, 17, 17], [1, 17, 20], [1, 17, 23], [1, 17, 24], [1, 17, 30], [1, 18, 4], [1, 18, 5], [1, 18, 14], [1, 18, 18], [1, 18, 19], [1, 18, 21], [1, 18, 22], [1, 18, 26], [1, 19, 3], [1, 19, 6], [1, 19, 12], [1, 19, 15], [1, 19, 18], [1, 19, 20], [1, 19, 22], [1, 19, 25], [1, 19, 28], [1, 20, 2], [1, 20, 7], [1, 20, 13], [1, 20, 16], [1, 20, 19], [1, 20, 20], [1, 20, 21], [1, 20, 24], [1, 20, 27], [1, 21, 20], [1, 22, 0], [1, 22, 9], [1, 22, 10], [1, 22, 15], [1, 22, 18], [1, 22, 22], [1, 22, 25], [1, 22, 30], [1, 23, 0], [1, 23, 9], [1, 23, 10], [1, 23, 11], [1, 23, 16], [1, 23, 24], [1, 23, 29], [1, 23, 30], [1, 24, 1], [1, 24, 8], [1, 24, 10], [1, 24, 12], [1, 24, 17], [1, 24, 20], [1, 24, 23], [1, 24, 28], [1, 24, 30], [1, 25, 0], [1, 25, 2], [1, 25, 7], [1, 25, 9], [1, 25, 11], [1, 25, 12], [1, 25, 28], [1, 25, 29], [1, 26, 1], [1, 26, 8], [1, 26, 10], [1, 26, 13], [1, 26, 14], [1, 26, 26], [1, 26, 27], [1, 26, 30], [1, 27, 0], [1, 27, 4], [1, 27, 5], [1, 27, 9], [1, 27, 13], [1, 27, 14], [1, 27, 20], [1, 27, 26], [1, 27, 27], [1, 28, 3], [1, 28, 4], [1, 28, 5], [1, 28, 6], [1, 28, 12], [1, 28, 16], [1, 28, 24], [1, 28, 28], [1, 29, 2], [1, 29, 4], [1, 29, 5], [1, 29, 7], [1, 29, 11], [1, 29, 15], [1, 29, 25], [1, 29, 29], [1, 30, 2], [1, 30, 3], [1, 30, 6], [1, 30, 7], [1, 30, 14], [1, 30, 17], [1, 30, 23], [1, 30, 26], [2, 0, 5], [2, 0, 11], [2, 0, 13], [2, 0, 14], [2, 0, 15], [2, 0, 26], [2, 0, 27], [2, 0, 28], [2, 0, 30], [2, 1, 0], [2, 1, 4], [2, 1, 5], [2, 1, 6], [2, 1, 10], [2, 1, 12], [2, 1, 14], [2, 1, 27], [2, 1, 29], [2, 2, 4], [2, 2, 5], [2, 2, 6], [2, 2, 11], [2, 2, 13], [2, 2, 16], [2, 2, 25], [2, 2, 28], [2, 2, 30], [2, 3, 2], [2, 3, 3], [2, 3, 5], [2, 3, 7], [2, 3, 8], [2, 3, 12], [2, 3, 18], [2, 3, 23], [2, 3, 29], [2, 4, 1], [2, 4, 3], [2, 4, 4], [2, 4, 6], [2, 4, 7], [2, 4, 9], [2, 4, 17], [2, 4, 24], [2, 5, 0], [2, 5, 1], [2, 5, 2], [2, 5, 5], [2, 5, 8], [2, 5, 9], [2, 5, 10], [2, 5, 16], [2, 5, 25], [2, 6, 1], [2, 6, 2], [2, 6, 5], [2, 6, 8], [2, 6, 9], [2, 6, 15], [2, 6, 20], [2, 6, 21], [2, 6, 26], [2, 7, 3], [2, 7, 4], [2, 7, 6], [2, 7, 7], [2, 7, 11], [2, 7, 20], [2, 7, 21], [2, 7, 30], [2, 8, 0], [2, 8, 3], [2, 8, 5], [2, 8, 7], [2, 8, 10], [2, 8, 13], [2, 8, 19], [2, 8, 22], [2, 8, 28], [2, 9, 1], [2, 9, 4], [2, 9, 5], [2, 9, 6], [2, 9, 9], [2, 9, 12], [2, 9, 18], [2, 9, 23], [2, 9, 29], [2, 10, 5], [2, 11, 0], [2, 11, 3], [2, 11, 7], [2, 11, 10], [2, 11, 15], [2, 11, 16], [2, 11, 25], [2, 11, 26], [2, 12, 1], [2, 12, 9], [2, 12, 14], [2, 12, 15], [2, 12, 16], [2, 12, 25], [2, 12, 26], [2, 12, 27], [2, 13, 2], [2, 13, 5], [2, 13, 8], [2, 13, 13], [2, 13, 15], [2, 13, 17], [2, 13, 24], [2, 13, 26], [2, 13, 28], [2, 14, 13], [2, 14, 14], [2, 14, 16], [2, 14, 18], [2, 14, 23], [2, 14, 25], [2, 14, 27], [2, 14, 28], [2, 15, 11], [2, 15, 12], [2, 15, 15], [2, 15, 17], [2, 15, 24], [2, 15, 26], [2, 15, 29], [2, 15, 30], [2, 16, 5], [2, 16, 11], [2, 16, 12], [2, 16, 16], [2, 16, 20], [2, 16, 21], [2, 16, 25], [2, 16, 29], [2, 16, 30], [2, 17, 1], [2, 17, 9], [2, 17, 13], [2, 17, 19], [2, 17, 20], [2, 17, 21], [2, 17, 22], [2, 17, 28], [2, 18, 0], [2, 18, 10], [2, 18, 14], [2, 18, 18], [2, 18, 20], [2, 18, 21], [2, 18, 23], [2, 18, 27], [2, 19, 2], [2, 19, 8], [2, 19, 11], [2, 19, 18], [2, 19, 19], [2, 19, 22], [2, 19, 23], [2, 19, 30], [2, 20, 12], [2, 20, 16], [2, 20, 17], [2, 20, 19], [2, 20, 22], [2, 20, 24], [2, 20, 25], [2, 20, 29], [2, 21, 5], [2, 21, 16], [2, 21, 17], [2, 21, 18], [2, 21, 20], [2, 21, 21], [2, 21, 23], [2, 21, 24], [2, 21, 25], [2, 22, 4], [2, 22, 5], [2, 22, 6], [2, 22, 14], [2, 22, 17], [2, 22, 19], [2, 22, 22], [2, 22, 24], [2, 22, 27], [2, 23, 3], [2, 23, 5], [2, 23, 7], [2, 23, 15], [2, 23, 18], [2, 23, 19], [2, 23, 22], [2, 23, 23], [2, 23, 26], [2, 24, 2], [2, 24, 4], [2, 24, 6], [2, 24, 8], [2, 24, 13], [2, 24, 20], [2, 24, 21], [2, 24, 28], [2, 25, 3], [2, 25, 5], [2, 25, 7], [2, 25, 14], [2, 25, 17], [2, 25, 20], [2, 25, 21], [2, 25, 24], [2, 25, 27], [2, 26, 0], [2, 26, 4], [2, 26, 6], [2, 26, 10], [2, 26, 15], [2, 26, 18], [2, 26, 23], [2, 26, 26], [2, 27, 0], [2, 27, 1], [2, 27, 5], [2, 27, 9], [2, 27, 10], [2, 27, 11], [2, 27, 19], [2, 27, 22], [2, 27, 30], [2, 28, 0], [2, 28, 2], [2, 28, 8], [2, 28, 10], [2, 28, 11], [2, 28, 17], [2, 28, 24], [2, 28, 30], [2, 29, 1], [2, 29, 3], [2, 29, 7], [2, 29, 9], [2, 29, 12], [2, 29, 13], [2, 29, 28], [2, 29, 29], [2, 30, 2], [2, 30, 8], [2, 30, 12], [2, 30, 14], [2, 30, 19], [2, 30, 22], [2, 30, 27], [2, 30, 29], [3, 0, 3], [3, 0, 8], [3, 0, 14], [3, 0, 17], [3, 0, 20], [3, 0, 21], [3, 0, 22], [3, 0, 25], [3, 0, 28], [3, 1, 21], [3, 2, 0], [3, 2, 1], [3, 2, 10], [3, 2, 11], [3, 2, 16], [3, 2, 19], [3, 2, 23], [3, 2, 26], [3, 3, 0], [3, 3, 1], [3, 3, 10], [3, 3, 11], [3, 3, 12], [3, 3, 17], [3, 3, 25], [3, 3, 30], [3, 4, 0], [3, 4, 2], [3, 4, 9], [3, 4, 11], [3, 4, 13], [3, 4, 18], [3, 4, 21], [3, 4, 24], [3, 4, 29], [3, 5, 1], [3, 5, 3], [3, 5, 8], [3, 5, 10], [3, 5, 12], [3, 5, 13], [3, 5, 29], [3, 5, 30], [3, 6, 0], [3, 6, 2], [3, 6, 9], [3, 6, 11], [3, 6, 14], [3, 6, 15], [3, 6, 27], [3, 6, 28], [3, 7, 1], [3, 7, 5], [3, 7, 6], [3, 7, 10], [3, 7, 14], [3, 7, 15], [3, 7, 21], [3, 7, 27], [3, 7, 28], [3, 8, 4], [3, 8, 5], [3, 8, 6], [3, 8, 7], [3, 8, 13], [3, 8, 17], [3, 8, 25], [3, 8, 29], [3, 9, 3], [3, 9, 5], [3, 9, 6], [3, 9, 8], [3, 9, 12], [3, 9, 16], [3, 9, 26], [3, 9, 30], [3, 10, 3], [3, 10, 4], [3, 10, 7], [3, 10, 8], [3, 10, 15], [3, 10, 18], [3, 10, 24], [3, 10, 27], [3, 11, 1], [3, 11, 2], [3, 11, 4], [3, 11, 7], [3, 11, 9], [3, 11, 10], [3, 11, 14], [3, 11, 28], [3, 12, 1], [3, 12, 2], [3, 12, 3], [3, 12, 5], [3, 12, 6], [3, 12, 8], [3, 12, 9], [3, 12, 10], [3, 12, 21], [3, 13, 2], [3, 13, 4], [3, 13, 7], [3, 13, 9], [3, 13, 12], [3, 13, 20], [3, 13, 21], [3, 13, 22], [3, 13, 30], [3, 14, 0], [3, 14, 3], [3, 14, 4], [3, 14, 7], [3, 14, 8], [3, 14, 11], [3, 14, 19], [3, 14, 21], [3, 14, 23], [3, 15, 5], [3, 15, 6], [3, 15, 13], [3, 15, 18], [3, 15, 20], [3, 15, 22], [3, 15, 24], [3, 15, 29], [3, 16, 2], [3, 16, 5], [3, 16, 6], [3, 16, 9], [3, 16, 12], [3, 16, 19], [3, 16, 21], [3, 16, 23], [3, 16, 30], [3, 17, 0], [3, 17, 3], [3, 17, 8], [3, 17, 11], [3, 17, 16], [3, 17, 20], [3, 17, 22], [3, 17, 26], [3, 18, 4], [3, 18, 7], [3, 18, 15], [3, 18, 16], [3, 18, 17], [3, 18, 21], [3, 18, 25], [3, 18, 26], [3, 18, 27], [3, 19, 2], [3, 19, 9], [3, 19, 15], [3, 19, 16], [3, 19, 18], [3, 19, 24], [3, 19, 26], [3, 19, 27], [3, 20, 13], [3, 20, 14], [3, 20, 17], [3, 20, 19], [3, 20, 23], [3, 20, 25], [3, 20, 28], [3, 20, 29], [3, 21, 4], [3, 21, 7], [3, 21, 12], [3, 21, 14], [3, 21, 18], [3, 21, 24], [3, 21, 28], [3, 21, 30], [3, 22, 0], [3, 22, 11], [3, 22, 12], [3, 22, 13], [3, 22, 15], [3, 22, 21], [3, 22, 27], [3, 22, 29], [3, 22, 30], [3, 23, 12], [3, 23, 14], [3, 23, 16], [3, 23, 20], [3, 23, 21], [3, 23, 22], [3, 23, 26], [3, 23, 28], [3, 23, 30], [3, 24, 1], [3, 24, 10], [3, 24, 13], [3, 24, 15], [3, 24, 20], [3, 24, 21], [3, 24, 22], [3, 24, 27], [3, 24, 29], [3, 25, 3], [3, 25, 8], [3, 25, 14], [3, 25, 18], [3, 25, 19], [3, 25, 21], [3, 25, 23], [3, 25, 24], [3, 25, 28], [3, 26, 2], [3, 26, 9], [3, 26, 17], [3, 26, 19], [3, 26, 20], [3, 26, 22], [3, 26, 23], [3, 26, 25], [3, 27, 1], [3, 27, 10], [3, 27, 16], [3, 27, 17], [3, 27, 18], [3, 27, 21], [3, 27, 24], [3, 27, 25], [3, 27, 26], [3, 28, 0], [3, 28, 5], [3, 28, 6], [3, 28, 11], [3, 28, 17], [3, 28, 18], [3, 28, 21], [3, 28, 24], [3, 28, 25], [3, 29, 5], [3, 29, 6], [3, 29, 15], [3, 29, 19], [3, 29, 20], [3, 29, 22], [3, 29, 23], [3, 29, 27], [3, 30, 4], [3, 30, 7], [3, 30, 13], [3, 30, 16], [3, 30, 19], [3, 30, 21], [3, 30, 23], [3, 30, 26], [3, 30, 29], [4, 0, 0], [4, 0, 6], [4, 0, 12], [4, 0, 13], [4, 0, 17], [4, 0, 21], [4, 0, 22], [4, 0, 26], [4, 0, 30], [4, 1, 2], [4, 1, 10], [4, 1, 14], [4, 1, 20], [4, 1, 21], [4, 1, 22], [4, 1, 23], [4, 1, 29], [4, 2, 1], [4, 2, 11], [4, 2, 15], [4, 2, 19], [4, 2, 21], [4, 2, 22], [4, 2, 24], [4, 2, 28], [4, 3, 0], [4, 3, 3], [4, 3, 9], [4, 3, 12], [4, 3, 19], [4, 3, 20], [4, 3, 23], [4, 3, 24], [4, 4, 13], [4, 4, 17], [4, 4, 18], [4, 4, 20], [4, 4, 23], [4, 4, 25], [4, 4, 26], [4, 4, 30], [4, 5, 6], [4, 5, 17], [4, 5, 18], [4, 5, 19], [4, 5, 21], [4, 5, 22], [4, 5, 24], [4, 5, 25], [4, 5, 26], [4, 6, 5], [4, 6, 6], [4, 6, 7], [4, 6, 15], [4, 6, 18], [4, 6, 20], [4, 6, 23], [4, 6, 25], [4, 6, 28], [4, 7, 4], [4, 7, 6], [4, 7, 8], [4, 7, 16], [4, 7, 19], [4, 7, 20], [4, 7, 23], [4, 7, 24], [4, 7, 27], [4, 8, 3], [4, 8, 5], [4, 8, 7], [4, 8, 9], [4, 8, 14], [4, 8, 21], [4, 8, 22], [4, 8, 29], [4, 9, 4], [4, 9, 6], [4, 9, 8], [4, 9, 15], [4, 9, 18], [4, 9, 21], [4, 9, 22], [4, 9, 25], [4, 9, 28], [4, 10, 1], [4, 10, 5], [4, 10, 7], [4, 10, 11], [4, 10, 16], [4, 10, 19], [4, 10, 24], [4, 10, 27], [4, 11, 0], [4, 11, 1], [4, 11, 2], [4, 11, 6], [4, 11, 10], [4, 11, 11], [4, 11, 12], [4, 11, 20], [4, 11, 23], [4, 12, 0], [4, 12, 1], [4, 12, 3], [4, 12, 9], [4, 12, 11], [4, 12, 12], [4, 12, 18], [4, 12, 25], [4, 13, 2], [4, 13, 4], [4, 13, 8], [4, 13, 10], [4, 13, 13], [4, 13, 14], [4, 13, 29], [4, 13, 30], [4, 14, 3], [4, 14, 9], [4, 14, 13], [4, 14, 15], [4, 14, 20], [4, 14, 23], [4, 14, 28], [4, 14, 30], [4, 15, 0], [4, 15, 6], [4, 15, 12], [4, 15, 14], [4, 15, 15], [4, 15, 16], [4, 15, 27], [4, 15, 28], [4, 15, 29], [4, 16, 1], [4, 16, 5], [4, 16, 6], [4, 16, 7], [4, 16, 11], [4, 16, 13], [4, 16, 15], [4, 16, 28], [4, 16, 30], [4, 17, 0], [4, 17, 5], [4, 17, 6], [4, 17, 7], [4, 17, 12], [4, 17, 14], [4, 17, 17], [4, 17, 26], [4, 17, 29], [4, 18, 3], [4, 18, 4], [4, 18, 6], [4, 18, 8], [4, 18, 9], [4, 18, 13], [4, 18, 19], [4, 18, 24], [4, 18, 30], [4, 19, 2], [4, 19, 4], [4, 19, 5], [4, 19, 7], [4, 19, 8], [4, 19, 10], [4, 19, 18], [4, 19, 25], [4, 20, 1], [4, 20, 2], [4, 20, 3], [4, 20, 6], [4, 20, 9], [4, 20, 10], [4, 20, 11], [4, 20, 17], [4, 20, 26], [4, 21, 2], [4, 21, 3], [4, 21, 6], [4, 21, 9], [4, 21, 10], [4, 21, 16], [4, 21, 21], [4, 21, 22], [4, 21, 27], [4, 22, 0], [4, 22, 4], [4, 22, 5], [4, 22, 7], [4, 22, 8], [4, 22, 12], [4, 22, 21], [4, 22, 22], [4, 23, 1], [4, 23, 4], [4, 23, 6], [4, 23, 8], [4, 23, 11], [4, 23, 14], [4, 23, 20], [4, 23, 23], [4, 23, 29], [4, 24, 2], [4, 24, 5], [4, 24, 6], [4, 24, 7], [4, 24, 10], [4, 24, 13], [4, 24, 19], [4, 24, 24], [4, 24, 30], [4, 25, 6], [4, 26, 1], [4, 26, 4], [4, 26, 8], [4, 26, 11], [4, 26, 16], [4, 26, 17], [4, 26, 26], [4, 26, 27], [4, 27, 2], [4, 27, 10], [4, 27, 15], [4, 27, 16], [4, 27, 17], [4, 27, 26], [4, 27, 27], [4, 27, 28], [4, 28, 3], [4, 28, 6], [4, 28, 9], [4, 28, 14], [4, 28, 16], [4, 28, 18], [4, 28, 25], [4, 28, 27], [4, 28, 29], [4, 29, 14], [4, 29, 15], [4, 29, 17], [4, 29, 19], [4, 29, 24], [4, 29, 26], [4, 29, 28], [4, 29, 29], [4, 30, 0], [4, 30, 12], [4, 30, 13], [4, 30, 16], [4, 30, 18], [4, 30, 25], [4, 30, 27], [4, 30, 30], [5, 0, 2], [5, 0, 3], [5, 0, 4], [5, 0, 6], [5, 0, 7], [5, 0, 9], [5, 0, 10], [5, 0, 11], [5, 0, 22], [5, 1, 0], [5, 1, 3], [5, 1, 5], [5, 1, 8], [5, 1, 10], [5, 1, 13], [5, 1, 21], [5, 1, 22], [5, 1, 23], [5, 2, 1], [5, 2, 4], [5, 2, 5], [5, 2, 8], [5, 2, 9], [5, 2, 12], [5, 2, 20], [5, 2, 22], [5, 2, 24], [5, 3, 6], [5, 3, 7], [5, 3, 14], [5, 3, 19], [5, 3, 21], [5, 3, 23], [5, 3, 25], [5, 3, 30], [5, 4, 0], [5, 4, 3], [5, 4, 6], [5, 4, 7], [5, 4, 10], [5, 4, 13], [5, 4, 20], [5, 4, 22], [5, 4, 24], [5, 5, 1], [5, 5, 4], [5, 5, 9], [5, 5, 12], [5, 5, 17], [5, 5, 21], [5, 5, 23], [5, 5, 27], [5, 6, 5], [5, 6, 8], [5, 6, 16], [5, 6, 17], [5, 6, 18], [5, 6, 22], [5, 6, 26], [5, 6, 27], [5, 6, 28], [5, 7, 3], [5, 7, 10], [5, 7, 16], [5, 7, 17], [5, 7, 19], [5, 7, 25], [5, 7, 27], [5, 7, 28], [5, 8, 14], [5, 8, 15], [5, 8, 18], [5, 8, 20], [5, 8, 24], [5, 8, 26], [5, 8, 29], [5, 8, 30], [5, 9, 0], [5, 9, 5], [5, 9, 8], [5, 9, 13], [5, 9, 15], [5, 9, 19], [5, 9, 25], [5, 9, 29], [5, 10, 0], [5, 10, 1], [5, 10, 12], [5, 10, 13], [5, 10, 14], [5, 10, 16], [5, 10, 22], [5, 10, 28], [5, 10, 30], [5, 11, 0], [5, 11, 13], [5, 11, 15], [5, 11, 17], [5, 11, 21], [5, 11, 22], [5, 11, 23], [5, 11, 27], [5, 11, 29], [5, 12, 2], [5, 12, 11], [5, 12, 14], [5, 12, 16], [5, 12, 21], [5, 12, 22], [5, 12, 23], [5, 12, 28], [5, 12, 30], [5, 13, 4], [5, 13, 9], [5, 13, 15], [5, 13, 19], [5, 13, 20], [5, 13, 22], [5, 13, 24], [5, 13, 25], [5, 13, 29], [5, 14, 3], [5, 14, 10], [5, 14, 18], [5, 14, 20], [5, 14, 21], [5, 14, 23], [5, 14, 24], [5, 14, 26], [5, 15, 2], [5, 15, 11], [5, 15, 17], [5, 15, 18], [5, 15, 19], [5, 15, 22], [5, 15, 25], [5, 15, 26], [5, 15, 27], [5, 16, 1], [5, 16, 6], [5, 16, 7], [5, 16, 12], [5, 16, 18], [5, 16, 19], [5, 16, 22], [5, 16, 25], [5, 16, 26], [5, 17, 6], [5, 17, 7], [5, 17, 16], [5, 17, 20], [5, 17, 21], [5, 17, 23], [5, 17, 24], [5, 17, 28], [5, 18, 5], [5, 18, 8], [5, 18, 14], [5, 18, 17], [5, 18, 20], [5, 18, 22], [5, 18, 24], [5, 18, 27], [5, 18, 30], [5, 19, 4], [5, 19, 9], [5, 19, 15], [5, 19, 18], [5, 19, 21], [5, 19, 22], [5, 19, 23], [5, 19, 26], [5, 19, 29], [5, 20, 22], [5, 21, 1], [5, 21, 2], [5, 21, 11], [5, 21, 12], [5, 21, 17], [5, 21, 20], [5, 21, 24], [5, 21, 27], [5, 22, 0], [5, 22, 1], [5, 22, 2], [5, 22, 11], [5, 22, 12], [5, 22, 13], [5, 22, 18], [5, 22, 26], [5, 23, 1], [5, 23, 3], [5, 23, 10], [5, 23, 12], [5, 23, 14], [5, 23, 19], [5, 23, 22], [5, 23, 25], [5, 23, 30], [5, 24, 0], [5, 24, 2], [5, 24, 4], [5, 24, 9], [5, 24, 11], [5, 24, 13], [5, 24, 14], [5, 24, 30], [5, 25, 1], [5, 25, 3], [5, 25, 10], [5, 25, 12], [5, 25, 15], [5, 25, 16], [5, 25, 28], [5, 25, 29], [5, 26, 2], [5, 26, 6], [5, 26, 7], [5, 26, 11], [5, 26, 15], [5, 26, 16], [5, 26, 22], [5, 26, 28], [5, 26, 29], [5, 27, 5], [5, 27, 6], [5, 27, 7], [5, 27, 8], [5, 27, 14], [5, 27, 18], [5, 27, 26], [5, 27, 30], [5, 28, 0], [5, 28, 4], [5, 28, 6], [5, 28, 7], [5, 28, 9], [5, 28, 13], [5, 28, 17], [5, 28, 27], [5, 29, 4], [5, 29, 5], [5, 29, 8], [5, 29, 9], [5, 29, 16], [5, 29, 19], [5, 29, 25], [5, 29, 28], [5, 30, 2], [5, 30, 3], [5, 30, 5], [5, 30, 8], [5, 30, 10], [5, 30, 11], [5, 30, 15], [5, 30, 29], [6, 0, 4], [6, 0, 6], [6, 0, 8], [6, 0, 10], [6, 0, 15], [6, 0, 22], [6, 0, 23], [6, 0, 30], [6, 1, 5], [6, 1, 7], [6, 1, 9], [6, 1, 16], [6, 1, 19], [6, 1, 22], [6, 1, 23], [6, 1, 26], [6, 1, 29], [6, 2, 2], [6, 2, 6], [6, 2, 8], [6, 2, 12], [6, 2, 17], [6, 2, 20], [6, 2, 25], [6, 2, 28], [6, 3, 1], [6, 3, 2], [6, 3, 3], [6, 3, 7], [6, 3, 11], [6, 3, 12], [6, 3, 13], [6, 3, 21], [6, 3, 24], [6, 4, 1], [6, 4, 2], [6, 4, 4], [6, 4, 10], [6, 4, 12], [6, 4, 13], [6, 4, 19], [6, 4, 26], [6, 5, 0], [6, 5, 3], [6, 5, 5], [6, 5, 9], [6, 5, 11], [6, 5, 14], [6, 5, 15], [6, 5, 30], [6, 6, 0], [6, 6, 4], [6, 6, 10], [6, 6, 14], [6, 6, 16], [6, 6, 21], [6, 6, 24], [6, 6, 29], [6, 7, 1], [6, 7, 7], [6, 7, 13], [6, 7, 15], [6, 7, 16], [6, 7, 17], [6, 7, 28], [6, 7, 29], [6, 7, 30], [6, 8, 0], [6, 8, 2], [6, 8, 6], [6, 8, 7], [6, 8, 8], [6, 8, 12], [6, 8, 14], [6, 8, 16], [6, 8, 29], [6, 9, 1], [6, 9, 6], [6, 9, 7], [6, 9, 8], [6, 9, 13], [6, 9, 15], [6, 9, 18], [6, 9, 27], [6, 9, 30], [6, 10, 0], [6, 10, 4], [6, 10, 5], [6, 10, 7], [6, 10, 9], [6, 10, 10], [6, 10, 14], [6, 10, 20], [6, 10, 25], [6, 11, 3], [6, 11, 5], [6, 11, 6], [6, 11, 8], [6, 11, 9], [6, 11, 11], [6, 11, 19], [6, 11, 26], [6, 12, 2], [6, 12, 3], [6, 12, 4], [6, 12, 7], [6, 12, 10], [6, 12, 11], [6, 12, 12], [6, 12, 18], [6, 12, 27], [6, 13, 3], [6, 13, 4], [6, 13, 7], [6, 13, 10], [6, 13, 11], [6, 13, 17], [6, 13, 22], [6, 13, 23], [6, 13, 28], [6, 14, 1], [6, 14, 5], [6, 14, 6], [6, 14, 8], [6, 14, 9], [6, 14, 13], [6, 14, 22], [6, 14, 23], [6, 15, 2], [6, 15, 5], [6, 15, 7], [6, 15, 9], [6, 15, 12], [6, 15, 15], [6, 15, 21], [6, 15, 24], [6, 15, 30], [6, 16, 0], [6, 16, 3], [6, 16, 6], [6, 16, 7], [6, 16, 8], [6, 16, 11], [6, 16, 14], [6, 16, 20], [6, 16, 25], [6, 17, 7], [6, 18, 2], [6, 18, 5], [6, 18, 9], [6, 18, 12], [6, 18, 17], [6, 18, 18], [6, 18, 27], [6, 18, 28], [6, 19, 3], [6, 19, 11], [6, 19, 16], [6, 19, 17], [6, 19, 18], [6, 19, 27], [6, 19, 28], [6, 19, 29], [6, 20, 4], [6, 20, 7], [6, 20, 10], [6, 20, 15], [6, 20, 17], [6, 20, 19], [6, 20, 26], [6, 20, 28], [6, 20, 30], [6, 21, 15], [6, 21, 16], [6, 21, 18], [6, 21, 20], [6, 21, 25], [6, 21, 27], [6, 21, 29], [6, 21, 30], [6, 22, 0], [6, 22, 1], [6, 22, 13], [6, 22, 14], [6, 22, 17], [6, 22, 19], [6, 22, 26], [6, 22, 28], [6, 23, 0], [6, 23, 1], [6, 23, 7], [6, 23, 13], [6, 23, 14], [6, 23, 18], [6, 23, 22], [6, 23, 23], [6, 23, 27], [6, 24, 3], [6, 24, 11], [6, 24, 15], [6, 24, 21], [6, 24, 22], [6, 24, 23], [6, 24, 24], [6, 24, 30], [6, 25, 2], [6, 25, 12], [6, 25, 16], [6, 25, 20], [6, 25, 22], [6, 25, 23], [6, 25, 25], [6, 25, 29], [6, 26, 1], [6, 26, 4], [6, 26, 10], [6, 26, 13], [6, 26, 20], [6, 26, 21], [6, 26, 24], [6, 26, 25], [6, 27, 0], [6, 27, 14], [6, 27, 18], [6, 27, 19], [6, 27, 21], [6, 27, 24], [6, 27, 26], [6, 27, 27], [6, 28, 7], [6, 28, 18], [6, 28, 19], [6, 28, 20], [6, 28, 22], [6, 28, 23], [6, 28, 25], [6, 28, 26], [6, 28, 27], [6, 29, 6], [6, 29, 7], [6, 29, 8], [6, 29, 16], [6, 29, 19], [6, 29, 21], [6, 29, 24], [6, 29, 26], [6, 29, 29], [6, 30, 5], [6, 30, 7], [6, 30, 9], [6, 30, 17], [6, 30, 20], [6, 30, 21], [6, 30, 24], [6, 30, 25], [6, 30, 28], [7, 0, 1], [7, 0, 4], [7, 0, 7], [7, 0, 8], [7, 0, 11], [7, 0, 14], [7, 0, 21], [7, 0, 23], [7, 0, 25], [7, 1, 2], [7, 1, 5], [7, 1, 10], [7, 1, 13], [7, 1, 18], [7, 1, 22], [7, 1, 24], [7, 1, 28], [7, 2, 6], [7, 2, 9], [7, 2, 17], [7, 2, 18], [7, 2, 19], [7, 2, 23], [7, 2, 27], [7, 2, 28], [7, 2, 29], [7, 3, 4], [7, 3, 11], [7, 3, 17], [7, 3, 18], [7, 3, 20], [7, 3, 26], [7, 3, 28], [7, 3, 29], [7, 4, 0], [7, 4, 15], [7, 4, 16], [7, 4, 19], [7, 4, 21], [7, 4, 25], [7, 4, 27], [7, 4, 30], [7, 5, 1], [7, 5, 6], [7, 5, 9], [7, 5, 14], [7, 5, 16], [7, 5, 20], [7, 5, 26], [7, 5, 30], [7, 6, 0], [7, 6, 1], [7, 6, 2], [7, 6, 13], [7, 6, 14], [7, 6, 15], [7, 6, 17], [7, 6, 23], [7, 6, 29], [7, 7, 1], [7, 7, 14], [7, 7, 16], [7, 7, 18], [7, 7, 22], [7, 7, 23], [7, 7, 24], [7, 7, 28], [7, 7, 30], [7, 8, 0], [7, 8, 3], [7, 8, 12], [7, 8, 15], [7, 8, 17], [7, 8, 22], [7, 8, 23], [7, 8, 24], [7, 8, 29], [7, 9, 5], [7, 9, 10], [7, 9, 16], [7, 9, 20], [7, 9, 21], [7, 9, 23], [7, 9, 25], [7, 9, 26], [7, 9, 30], [7, 10, 4], [7, 10, 11], [7, 10, 19], [7, 10, 21], [7, 10, 22], [7, 10, 24], [7, 10, 25], [7, 10, 27], [7, 11, 3], [7, 11, 12], [7, 11, 18], [7, 11, 19], [7, 11, 20], [7, 11, 23], [7, 11, 26], [7, 11, 27], [7, 11, 28], [7, 12, 2], [7, 12, 7], [7, 12, 8], [7, 12, 13], [7, 12, 19], [7, 12, 20], [7, 12, 23], [7, 12, 26], [7, 12, 27], [7, 13, 7], [7, 13, 8], [7, 13, 17], [7, 13, 21], [7, 13, 22], [7, 13, 24], [7, 13, 25], [7, 13, 29], [7, 14, 0], [7, 14, 6], [7, 14, 9], [7, 14, 15], [7, 14, 18], [7, 14, 21], [7, 14, 23], [7, 14, 25], [7, 14, 28], [7, 15, 5], [7, 15, 10], [7, 15, 16], [7, 15, 19], [7, 15, 22], [7, 15, 23], [7, 15, 24], [7, 15, 27], [7, 15, 30], [7, 16, 23], [7, 17, 2], [7, 17, 3], [7, 17, 12], [7, 17, 13], [7, 17, 18], [7, 17, 21], [7, 17, 25], [7, 17, 28], [7, 18, 1], [7, 18, 2], [7, 18, 3], [7, 18, 12], [7, 18, 13], [7, 18, 14], [7, 18, 19], [7, 18, 27], [7, 19, 0], [7, 19, 2], [7, 19, 4], [7, 19, 11], [7, 19, 13], [7, 19, 15], [7, 19, 20], [7, 19, 23], [7, 19, 26], [7, 20, 0], [7, 20, 1], [7, 20, 3], [7, 20, 5], [7, 20, 10], [7, 20, 12], [7, 20, 14], [7, 20, 15], [7, 21, 2], [7, 21, 4], [7, 21, 11], [7, 21, 13], [7, 21, 16], [7, 21, 17], [7, 21, 29], [7, 21, 30], [7, 22, 3], [7, 22, 7], [7, 22, 8], [7, 22, 12], [7, 22, 16], [7, 22, 17], [7, 22, 23], [7, 22, 29], [7, 22, 30], [7, 23, 0], [7, 23, 6], [7, 23, 7], [7, 23, 8], [7, 23, 9], [7, 23, 15], [7, 23, 19], [7, 23, 27], [7, 24, 1], [7, 24, 5], [7, 24, 7], [7, 24, 8], [7, 24, 10], [7, 24, 14], [7, 24, 18], [7, 24, 28], [7, 25, 5], [7, 25, 6], [7, 25, 9], [7, 25, 10], [7, 25, 17], [7, 25, 20], [7, 25, 26], [7, 25, 29], [7, 26, 3], [7, 26, 4], [7, 26, 6], [7, 26, 9], [7, 26, 11], [7, 26, 12], [7, 26, 16], [7, 26, 30], [7, 27, 3], [7, 27, 4], [7, 27, 5], [7, 27, 7], [7, 27, 8], [7, 27, 10], [7, 27, 11], [7, 27, 12], [7, 27, 23], [7, 28, 1], [7, 28, 4], [7, 28, 6], [7, 28, 9], [7, 28, 11], [7, 28, 14], [7, 28, 22], [7, 28, 23], [7, 28, 24], [7, 29, 2], [7, 29, 5], [7, 29, 6], [7, 29, 9], [7, 29, 10], [7, 29, 13], [7, 29, 21], [7, 29, 23], [7, 29, 25], [7, 30, 0], [7, 30, 7], [7, 30, 8], [7, 30, 15], [7, 30, 20], [7, 30, 22], [7, 30, 24], [7, 30, 26], [8, 0, 0], [8, 0, 5], [8, 0, 7], [8, 0, 9], [8, 0, 11], [8, 0, 16], [8, 0, 23], [8, 0, 24], [8, 1, 6], [8, 1, 8], [8, 1, 10], [8, 1, 17], [8, 1, 20], [8, 1, 23], [8, 1, 24], [8, 1, 27], [8, 1, 30], [8, 2, 3], [8, 2, 7], [8, 2, 9], [8, 2, 13], [8, 2, 18], [8, 2, 21], [8, 2, 26], [8, 2, 29], [8, 3, 2], [8, 3, 3], [8, 3, 4], [8, 3, 8], [8, 3, 12], [8, 3, 13], [8, 3, 14], [8, 3, 22], [8, 3, 25], [8, 4, 2], [8, 4, 3], [8, 4, 5], [8, 4, 11], [8, 4, 13], [8, 4, 14], [8, 4, 20], [8, 4, 27], [8, 5, 0], [8, 5, 1], [8, 5, 4], [8, 5, 6], [8, 5, 10], [8, 5, 12], [8, 5, 15], [8, 5, 16], [8, 6, 1], [8, 6, 5], [8, 6, 11], [8, 6, 15], [8, 6, 17], [8, 6, 22], [8, 6, 25], [8, 6, 30], [8, 7, 0], [8, 7, 2], [8, 7, 8], [8, 7, 14], [8, 7, 16], [8, 7, 17], [8, 7, 18], [8, 7, 29], [8, 7, 30], [8, 8, 1], [8, 8, 3], [8, 8, 7], [8, 8, 8], [8, 8, 9], [8, 8, 13], [8, 8, 15], [8, 8, 17], [8, 8, 30], [8, 9, 0], [8, 9, 2], [8, 9, 7], [8, 9, 8], [8, 9, 9], [8, 9, 14], [8, 9, 16], [8, 9, 19], [8, 9, 28], [8, 10, 1], [8, 10, 5], [8, 10, 6], [8, 10, 8], [8, 10, 10], [8, 10, 11], [8, 10, 15], [8, 10, 21], [8, 10, 26], [8, 11, 4], [8, 11, 6], [8, 11, 7], [8, 11, 9], [8, 11, 10], [8, 11, 12], [8, 11, 20], [8, 11, 27], [8, 12, 3], [8, 12, 4], [8, 12, 5], [8, 12, 8], [8, 12, 11], [8, 12, 12], [8, 12, 13], [8, 12, 19], [8, 12, 28], [8, 13, 4], [8, 13, 5], [8, 13, 8], [8, 13, 11], [8, 13, 12], [8, 13, 18], [8, 13, 23], [8, 13, 24], [8, 13, 29], [8, 14, 2], [8, 14, 6], [8, 14, 7], [8, 14, 9], [8, 14, 10], [8, 14, 14], [8, 14, 23], [8, 14, 24], [8, 15, 0], [8, 15, 3], [8, 15, 6], [8, 15, 8], [8, 15, 10], [8, 15, 13], [8, 15, 16], [8, 15, 22], [8, 15, 25], [8, 16, 1], [8, 16, 4], [8, 16, 7], [8, 16, 8], [8, 16, 9], [8, 16, 12], [8, 16, 15], [8, 16, 21], [8, 16, 26], [8, 17, 8], [8, 18, 3], [8, 18, 6], [8, 18, 10], [8, 18, 13], [8, 18, 18], [8, 18, 19], [8, 18, 28], [8, 18, 29], [8, 19, 4], [8, 19, 12], [8, 19, 17], [8, 19, 18], [8, 19, 19], [8, 19, 28], [8, 19, 29], [8, 19, 30], [8, 20, 0], [8, 20, 5], [8, 20, 8], [8, 20, 11], [8, 20, 16], [8, 20, 18], [8, 20, 20], [8, 20, 27], [8, 20, 29], [8, 21, 0], [8, 21, 16], [8, 21, 17], [8, 21, 19], [8, 21, 21], [8, 21, 26], [8, 21, 28], [8, 21, 30], [8, 22, 1], [8, 22, 2], [8, 22, 14], [8, 22, 15], [8, 22, 18], [8, 22, 20], [8, 22, 27], [8, 22, 29], [8, 23, 1], [8, 23, 2], [8, 23, 8], [8, 23, 14], [8, 23, 15], [8, 23, 19], [8, 23, 23], [8, 23, 24], [8, 23, 28], [8, 24, 0], [8, 24, 4], [8, 24, 12], [8, 24, 16], [8, 24, 22], [8, 24, 23], [8, 24, 24], [8, 24, 25], [8, 25, 3], [8, 25, 13], [8, 25, 17], [8, 25, 21], [8, 25, 23], [8, 25, 24], [8, 25, 26], [8, 25, 30], [8, 26, 2], [8, 26, 5], [8, 26, 11], [8, 26, 14], [8, 26, 21], [8, 26, 22], [8, 26, 25], [8, 26, 26], [8, 27, 1], [8, 27, 15], [8, 27, 19], [8, 27, 20], [8, 27, 22], [8, 27, 25], [8, 27, 27], [8, 27, 28], [8, 28, 8], [8, 28, 19], [8, 28, 20], [8, 28, 21], [8, 28, 23], [8, 28, 24], [8, 28, 26], [8, 28, 27], [8, 28, 28], [8, 29, 7], [8, 29, 8], [8, 29, 9], [8, 29, 17], [8, 29, 20], [8, 29, 22], [8, 29, 25], [8, 29, 27], [8, 29, 30], [8, 30, 6], [8, 30, 8], [8, 30, 10], [8, 30, 18], [8, 30, 21], [8, 30, 22], [8, 30, 25], [8, 30, 26], [8, 30, 29], [9, 0, 4], [9, 0, 5], [9, 0, 6], [9, 0, 8], [9, 0, 9], [9, 0, 11], [9, 0, 12], [9, 0, 13], [9, 0, 24], [9, 1, 2], [9, 1, 5], [9, 1, 7], [9, 1, 10], [9, 1, 12], [9, 1, 15], [9, 1, 23], [9, 1, 24], [9, 1, 25], [9, 2, 3], [9, 2, 6], [9, 2, 7], [9, 2, 10], [9, 2, 11], [9, 2, 14], [9, 2, 22], [9, 2, 24], [9, 2, 26], [9, 3, 1], [9, 3, 8], [9, 3, 9], [9, 3, 16], [9, 3, 21], [9, 3, 23], [9, 3, 25], [9, 3, 27], [9, 4, 2], [9, 4, 5], [9, 4, 8], [9, 4, 9], [9, 4, 12], [9, 4, 15], [9, 4, 22], [9, 4, 24], [9, 4, 26], [9, 5, 3], [9, 5, 6], [9, 5, 11], [9, 5, 14], [9, 5, 19], [9, 5, 23], [9, 5, 25], [9, 5, 29], [9, 6, 7], [9, 6, 10], [9, 6, 18], [9, 6, 19], [9, 6, 20], [9, 6, 24], [9, 6, 28], [9, 6, 29], [9, 6, 30], [9, 7, 5], [9, 7, 12], [9, 7, 18], [9, 7, 19], [9, 7, 21], [9, 7, 27], [9, 7, 29], [9, 7, 30], [9, 8, 0], [9, 8, 1], [9, 8, 16], [9, 8, 17], [9, 8, 20], [9, 8, 22], [9, 8, 26], [9, 8, 28], [9, 9, 0], [9, 9, 2], [9, 9, 7], [9, 9, 10], [9, 9, 15], [9, 9, 17], [9, 9, 21], [9, 9, 27], [9, 10, 1], [9, 10, 2], [9, 10, 3], [9, 10, 14], [9, 10, 15], [9, 10, 16], [9, 10, 18], [9, 10, 24], [9, 10, 30], [9, 11, 0], [9, 11, 2], [9, 11, 15], [9, 11, 17], [9, 11, 19], [9, 11, 23], [9, 11, 24], [9, 11, 25], [9, 11, 29], [9, 12, 1], [9, 12, 4], [9, 12, 13], [9, 12, 16], [9, 12, 18], [9, 12, 23], [9, 12, 24], [9, 12, 25], [9, 12, 30], [9, 13, 0], [9, 13, 6], [9, 13, 11], [9, 13, 17], [9, 13, 21], [9, 13, 22], [9, 13, 24], [9, 13, 26], [9, 13, 27], [9, 14, 5], [9, 14, 12], [9, 14, 20], [9, 14, 22], [9, 14, 23], [9, 14, 25], [9, 14, 26], [9, 14, 28], [9, 15, 4], [9, 15, 13], [9, 15, 19], [9, 15, 20], [9, 15, 21], [9, 15, 24], [9, 15, 27], [9, 15, 28], [9, 15, 29], [9, 16, 3], [9, 16, 8], [9, 16, 9], [9, 16, 14], [9, 16, 20], [9, 16, 21], [9, 16, 24], [9, 16, 27], [9, 16, 28], [9, 17, 8], [9, 17, 9], [9, 17, 18], [9, 17, 22], [9, 17, 23], [9, 17, 25], [9, 17, 26], [9, 17, 30], [9, 18, 1], [9, 18, 7], [9, 18, 10], [9, 18, 16], [9, 18, 19], [9, 18, 22], [9, 18, 24], [9, 18, 26], [9, 18, 29], [9, 19, 0], [9, 19, 6], [9, 19, 11], [9, 19, 17], [9, 19, 20], [9, 19, 23], [9, 19, 24], [9, 19, 25], [9, 19, 28], [9, 20, 24], [9, 21, 3], [9, 21, 4], [9, 21, 13], [9, 21, 14], [9, 21, 19], [9, 21, 22], [9, 21, 26], [9, 21, 29], [9, 22, 2], [9, 22, 3], [9, 22, 4], [9, 22, 13], [9, 22, 14], [9, 22, 15], [9, 22, 20], [9, 22, 28], [9, 23, 1], [9, 23, 3], [9, 23, 5], [9, 23, 12], [9, 23, 14], [9, 23, 16], [9, 23, 21], [9, 23, 24], [9, 23, 27], [9, 24, 1], [9, 24, 2], [9, 24, 4], [9, 24, 6], [9, 24, 11], [9, 24, 13], [9, 24, 15], [9, 24, 16], [9, 25, 0], [9, 25, 3], [9, 25, 5], [9, 25, 12], [9, 25, 14], [9, 25, 17], [9, 25, 18], [9, 25, 30], [9, 26, 0], [9, 26, 4], [9, 26, 8], [9, 26, 9], [9, 26, 13], [9, 26, 17], [9, 26, 18], [9, 26, 24], [9, 26, 30], [9, 27, 1], [9, 27, 7], [9, 27, 8], [9, 27, 9], [9, 27, 10], [9, 27, 16], [9, 27, 20], [9, 27, 28], [9, 28, 2], [9, 28, 6], [9, 28, 8], [9, 28, 9], [9, 28, 11], [9, 28, 15], [9, 28, 19], [9, 28, 29], [9, 29, 6], [9, 29, 7], [9, 29, 10], [9, 29, 11], [9, 29, 18], [9, 29, 21], [9, 29, 27], [9, 29, 30], [9, 30, 0], [9, 30, 4], [9, 30, 5], [9, 30, 7], [9, 30, 10], [9, 30, 12], [9, 30, 13], [9, 30, 17], [10, 0, 2], [10, 0, 3], [10, 0, 9], [10, 0, 15], [10, 0, 16], [10, 0, 20], [10, 0, 24], [10, 0, 25], [10, 0, 29], [10, 1, 1], [10, 1, 5], [10, 1, 13], [10, 1, 17], [10, 1, 23], [10, 1, 24], [10, 1, 25], [10, 1, 26], [10, 2, 0], [10, 2, 4], [10, 2, 14], [10, 2, 18], [10, 2, 22], [10, 2, 24], [10, 2, 25], [10, 2, 27], [10, 3, 3], [10, 3, 6], [10, 3, 12], [10, 3, 15], [10, 3, 22], [10, 3, 23], [10, 3, 26], [10, 3, 27], [10, 4, 2], [10, 4, 16], [10, 4, 20], [10, 4, 21], [10, 4, 23], [10, 4, 26], [10, 4, 28], [10, 4, 29], [10, 5, 9], [10, 5, 20], [10, 5, 21], [10, 5, 22], [10, 5, 24], [10, 5, 25], [10, 5, 27], [10, 5, 28], [10, 5, 29], [10, 6, 0], [10, 6, 8], [10, 6, 9], [10, 6, 10], [10, 6, 18], [10, 6, 21], [10, 6, 23], [10, 6, 26], [10, 6, 28], [10, 7, 7], [10, 7, 9], [10, 7, 11], [10, 7, 19], [10, 7, 22], [10, 7, 23], [10, 7, 26], [10, 7, 27], [10, 7, 30], [10, 8, 1], [10, 8, 6], [10, 8, 8], [10, 8, 10], [10, 8, 12], [10, 8, 17], [10, 8, 24], [10, 8, 25], [10, 9, 0], [10, 9, 7], [10, 9, 9], [10, 9, 11], [10, 9, 18], [10, 9, 21], [10, 9, 24], [10, 9, 25], [10, 9, 28], [10, 10, 4], [10, 10, 8], [10, 10, 10], [10, 10, 14], [10, 10, 19], [10, 10, 22], [10, 10, 27], [10, 10, 30], [10, 11, 3], [10, 11, 4], [10, 11, 5], [10, 11, 9], [10, 11, 13], [10, 11, 14], [10, 11, 15], [10, 11, 23], [10, 11, 26], [10, 12, 3], [10, 12, 4], [10, 12, 6], [10, 12, 12], [10, 12, 14], [10, 12, 15], [10, 12, 21], [10, 12, 28], [10, 13, 1], [10, 13, 2], [10, 13, 5], [10, 13, 7], [10, 13, 11], [10, 13, 13], [10, 13, 16], [10, 13, 17], [10, 14, 0], [10, 14, 2], [10, 14, 6], [10, 14, 12], [10, 14, 16], [10, 14, 18], [10, 14, 23], [10, 14, 26], [10, 15, 0], [10, 15, 1], [10, 15, 3], [10, 15, 9], [10, 15, 15], [10, 15, 17], [10, 15, 18], [10, 15, 19], [10, 15, 30], [10, 16, 0], [10, 16, 2], [10, 16, 4], [10, 16, 8], [10, 16, 9], [10, 16, 10], [10, 16, 14], [10, 16, 16], [10, 16, 18], [10, 17, 1], [10, 17, 3], [10, 17, 8], [10, 17, 9], [10, 17, 10], [10, 17, 15], [10, 17, 17], [10, 17, 20], [10, 17, 29], [10, 18, 2], [10, 18, 6], [10, 18, 7], [10, 18, 9], [10, 18, 11], [10, 18, 12], [10, 18, 16], [10, 18, 22], [10, 18, 27], [10, 19, 5], [10, 19, 7], [10, 19, 8], [10, 19, 10], [10, 19, 11], [10, 19, 13], [10, 19, 21], [10, 19, 28], [10, 20, 4], [10, 20, 5], [10, 20, 6], [10, 20, 9], [10, 20, 12], [10, 20, 13], [10, 20, 14], [10, 20, 20], [10, 20, 29], [10, 21, 5], [10, 21, 6], [10, 21, 9], [10, 21, 12], [10, 21, 13], [10, 21, 19], [10, 21, 24], [10, 21, 25], [10, 21, 30], [10, 22, 3], [10, 22, 7], [10, 22, 8], [10, 22, 10], [10, 22, 11], [10, 22, 15], [10, 22, 24], [10, 22, 25], [10, 23, 1], [10, 23, 4], [10, 23, 7], [10, 23, 9], [10, 23, 11], [10, 23, 14], [10, 23, 17], [10, 23, 23], [10, 23, 26], [10, 24, 2], [10, 24, 5], [10, 24, 8], [10, 24, 9], [10, 24, 10], [10, 24, 13], [10, 24, 16], [10, 24, 22], [10, 24, 27], [10, 25, 9], [10, 26, 4], [10, 26, 7], [10, 26, 11], [10, 26, 14], [10, 26, 19], [10, 26, 20], [10, 26, 29], [10, 26, 30], [10, 27, 0], [10, 27, 5], [10, 27, 13], [10, 27, 18], [10, 27, 19], [10, 27, 20], [10, 27, 29], [10, 27, 30], [10, 28, 1], [10, 28, 6], [10, 28, 9], [10, 28, 12], [10, 28, 17], [10, 28, 19], [10, 28, 21], [10, 28, 28], [10, 28, 30], [10, 29, 0], [10, 29, 1], [10, 29, 17], [10, 29, 18], [10, 29, 20], [10, 29, 22], [10, 29, 27], [10, 29, 29], [10, 30, 2], [10, 30, 3], [10, 30, 15], [10, 30, 16], [10, 30, 19], [10, 30, 21], [10, 30, 28], [10, 30, 30], [11, 0, 1], [11, 0, 7], [11, 0, 12], [11, 0, 18], [11, 0, 21], [11, 0, 24], [11, 0, 25], [11, 0, 26], [11, 0, 29], [11, 1, 25], [11, 2, 4], [11, 2, 5], [11, 2, 14], [11, 2, 15], [11, 2, 20], [11, 2, 23], [11, 2, 27], [11, 2, 30], [11, 3, 3], [11, 3, 4], [11, 3, 5], [11, 3, 14], [11, 3, 15], [11, 3, 16], [11, 3, 21], [11, 3, 29], [11, 4, 2], [11, 4, 4], [11, 4, 6], [11, 4, 13], [11, 4, 15], [11, 4, 17], [11, 4, 22], [11, 4, 25], [11, 4, 28], [11, 5, 2], [11, 5, 3], [11, 5, 5], [11, 5, 7], [11, 5, 12], [11, 5, 14], [11, 5, 16], [11, 5, 17], [11, 6, 0], [11, 6, 1], [11, 6, 4], [11, 6, 6], [11, 6, 13], [11, 6, 15], [11, 6, 18], [11, 6, 19], [11, 7, 0], [11, 7, 1], [11, 7, 5], [11, 7, 9], [11, 7, 10], [11, 7, 14], [11, 7, 18], [11, 7, 19], [11, 7, 25], [11, 8, 2], [11, 8, 8], [11, 8, 9], [11, 8, 10], [11, 8, 11], [11, 8, 17], [11, 8, 21], [11, 8, 29], [11, 9, 3], [11, 9, 7], [11, 9, 9], [11, 9, 10], [11, 9, 12], [11, 9, 16], [11, 9, 20], [11, 9, 30], [11, 10, 0], [11, 10, 7], [11, 10, 8], [11, 10, 11], [11, 10, 12], [11, 10, 19], [11, 10, 22], [11, 10, 28], [11, 11, 1], [11, 11, 5], [11, 11, 6], [11, 11, 8], [11, 11, 11], [11, 11, 13], [11, 11, 14], [11, 11, 18], [11, 12, 5], [11, 12, 6], [11, 12, 7], [11, 12, 9], [11, 12, 10], [11, 12, 12], [11, 12, 13], [11, 12, 14], [11, 12, 25], [11, 13, 3], [11, 13, 6], [11, 13, 8], [11, 13, 11], [11, 13, 13], [11, 13, 16], [11, 13, 24], [11, 13, 25], [11, 13, 26], [11, 14, 4], [11, 14, 7], [11, 14, 8], [11, 14, 11], [11, 14, 12], [11, 14, 15], [11, 14, 23], [11, 14, 25], [11, 14, 27], [11, 15, 2], [11, 15, 9], [11, 15, 10], [11, 15, 17], [11, 15, 22], [11, 15, 24], [11, 15, 26], [11, 15, 28], [11, 16, 3], [11, 16, 6], [11, 16, 9], [11, 16, 10], [11, 16, 13], [11, 16, 16], [11, 16, 23], [11, 16, 25], [11, 16, 27], [11, 17, 4], [11, 17, 7], [11, 17, 12], [11, 17, 15], [11, 17, 20], [11, 17, 24], [11, 17, 26], [11, 17, 30], [11, 18, 0], [11, 18, 8], [11, 18, 11], [11, 18, 19], [11, 18, 20], [11, 18, 21], [11, 18, 25], [11, 18, 29], [11, 18, 30], [11, 19, 0], [11, 19, 6], [11, 19, 13], [11, 19, 19], [11, 19, 20], [11, 19, 22], [11, 19, 28], [11, 19, 30], [11, 20, 1], [11, 20, 2], [11, 20, 17], [11, 20, 18], [11, 20, 21], [11, 20, 23], [11, 20, 27], [11, 20, 29], [11, 21, 1], [11, 21, 3], [11, 21, 8], [11, 21, 11], [11, 21, 16], [11, 21, 18], [11, 21, 22], [11, 21, 28], [11, 22, 0], [11, 22, 2], [11, 22, 3], [11, 22, 4], [11, 22, 15], [11, 22, 16], [11, 22, 17], [11, 22, 19], [11, 22, 25], [11, 23, 1], [11, 23, 3], [11, 23, 16], [11, 23, 18], [11, 23, 20], [11, 23, 24], [11, 23, 25], [11, 23, 26], [11, 23, 30], [11, 24, 0], [11, 24, 2], [11, 24, 5], [11, 24, 14], [11, 24, 17], [11, 24, 19], [11, 24, 24], [11, 24, 25], [11, 24, 26], [11, 25, 1], [11, 25, 7], [11, 25, 12], [11, 25, 18], [11, 25, 22], [11, 25, 23], [11, 25, 25], [11, 25, 27], [11, 25, 28], [11, 26, 6], [11, 26, 13], [11, 26, 21], [11, 26, 23], [11, 26, 24], [11, 26, 26], [11, 26, 27], [11, 26, 29], [11, 27, 5], [11, 27, 14], [11, 27, 20], [11, 27, 21], [11, 27, 22], [11, 27, 25], [11, 27, 28], [11, 27, 29], [11, 27, 30], [11, 28, 4], [11, 28, 9], [11, 28, 10], [11, 28, 15], [11, 28, 21], [11, 28, 22], [11, 28, 25], [11, 28, 28], [11, 28, 29], [11, 29, 0], [11, 29, 9], [11, 29, 10], [11, 29, 19], [11, 29, 23], [11, 29, 24], [11, 29, 26], [11, 29, 27], [11, 30, 2], [11, 30, 8], [11, 30, 11], [11, 30, 17], [11, 30, 20], [11, 30, 23], [11, 30, 25], [11, 30, 27], [11, 30, 30], [12, 0, 0], [12, 0, 1], [12, 0, 2], [12, 0, 4], [12, 0, 10], [12, 0, 16], [12, 0, 18], [12, 0, 19], [12, 0, 20], [12, 1, 1], [12, 1, 3], [12, 1, 5], [12, 1, 9], [12, 1, 10], [12, 1, 11], [12, 1, 15], [12, 1, 17], [12, 1, 19], [12, 2, 2], [12, 2, 4], [12, 2, 9], [12, 2, 10], [12, 2, 11], [12, 2, 16], [12, 2, 18], [12, 2, 21], [12, 2, 30], [12, 3, 3], [12, 3, 7], [12, 3, 8], [12, 3, 10], [12, 3, 12], [12, 3, 13], [12, 3, 17], [12, 3, 23], [12, 3, 28], [12, 4, 6], [12, 4, 8], [12, 4, 9], [12, 4, 11], [12, 4, 12], [12, 4, 14], [12, 4, 22], [12, 4, 29], [12, 5, 5], [12, 5, 6], [12, 5, 7], [12, 5, 10], [12, 5, 13], [12, 5, 14], [12, 5, 15], [12, 5, 21], [12, 5, 30], [12, 6, 0], [12, 6, 6], [12, 6, 7], [12, 6, 10], [12, 6, 13], [12, 6, 14], [12, 6, 20], [12, 6, 25], [12, 6, 26], [12, 7, 4], [12, 7, 8], [12, 7, 9], [12, 7, 11], [12, 7, 12], [12, 7, 16], [12, 7, 25], [12, 7, 26], [12, 8, 2], [12, 8, 5], [12, 8, 8], [12, 8, 10], [12, 8, 12], [12, 8, 15], [12, 8, 18], [12, 8, 24], [12, 8, 27], [12, 9, 3], [12, 9, 6], [12, 9, 9], [12, 9, 10], [12, 9, 11], [12, 9, 14], [12, 9, 17], [12, 9, 23], [12, 9, 28], [12, 10, 10], [12, 11, 0], [12, 11, 5], [12, 11, 8], [12, 11, 12], [12, 11, 15], [12, 11, 20], [12, 11, 21], [12, 11, 30], [12, 12, 0], [12, 12, 1], [12, 12, 6], [12, 12, 14], [12, 12, 19], [12, 12, 20], [12, 12, 21], [12, 12, 30], [12, 13, 0], [12, 13, 2], [12, 13, 7], [12, 13, 10], [12, 13, 13], [12, 13, 18], [12, 13, 20], [12, 13, 22], [12, 13, 29], [12, 14, 1], [12, 14, 2], [12, 14, 18], [12, 14, 19], [12, 14, 21], [12, 14, 23], [12, 14, 28], [12, 14, 30], [12, 15, 0], [12, 15, 3], [12, 15, 4], [12, 15, 16], [12, 15, 17], [12, 15, 20], [12, 15, 22], [12, 15, 29], [12, 16, 3], [12, 16, 4], [12, 16, 10], [12, 16, 16], [12, 16, 17], [12, 16, 21], [12, 16, 25], [12, 16, 26], [12, 16, 30], [12, 17, 2], [12, 17, 6], [12, 17, 14], [12, 17, 18], [12, 17, 24], [12, 17, 25], [12, 17, 26], [12, 17, 27], [12, 18, 1], [12, 18, 5], [12, 18, 15], [12, 18, 19], [12, 18, 23], [12, 18, 25], [12, 18, 26], [12, 18, 28], [12, 19, 4], [12, 19, 7], [12, 19, 13], [12, 19, 16], [12, 19, 23], [12, 19, 24], [12, 19, 27], [12, 19, 28], [12, 20, 3], [12, 20, 17], [12, 20, 21], [12, 20, 22], [12, 20, 24], [12, 20, 27], [12, 20, 29], [12, 20, 30], [12, 21, 10], [12, 21, 21], [12, 21, 22], [12, 21, 23], [12, 21, 25], [12, 21, 26], [12, 21, 28], [12, 21, 29], [12, 21, 30], [12, 22, 1], [12, 22, 9], [12, 22, 10], [12, 22, 11], [12, 22, 19], [12, 22, 22], [12, 22, 24], [12, 22, 27], [12, 22, 29], [12, 23, 0], [12, 23, 8], [12, 23, 10], [12, 23, 12], [12, 23, 20], [12, 23, 23], [12, 23, 24], [12, 23, 27], [12, 23, 28], [12, 24, 2], [12, 24, 7], [12, 24, 9], [12, 24, 11], [12, 24, 13], [12, 24, 18], [12, 24, 25], [12, 24, 26], [12, 25, 1], [12, 25, 8], [12, 25, 10], [12, 25, 12], [12, 25, 19], [12, 25, 22], [12, 25, 25], [12, 25, 26], [12, 25, 29], [12, 26, 0], [12, 26, 5], [12, 26, 9], [12, 26, 11], [12, 26, 15], [12, 26, 20], [12, 26, 23], [12, 26, 28], [12, 27, 4], [12, 27, 5], [12, 27, 6], [12, 27, 10], [12, 27, 14], [12, 27, 15], [12, 27, 16], [12, 27, 24], [12, 27, 27], [12, 28, 4], [12, 28, 5], [12, 28, 7], [12, 28, 13], [12, 28, 15], [12, 28, 16], [12, 28, 22], [12, 28, 29], [12, 29, 2], [12, 29, 3], [12, 29, 6], [12, 29, 8], [12, 29, 12], [12, 29, 14], [12, 29, 17], [12, 29, 18], [12, 30, 1], [12, 30, 3], [12, 30, 7], [12, 30, 13], [12, 30, 17], [12, 30, 19], [12, 30, 24], [12, 30, 27], [13, 0, 2], [13, 0, 6], [13, 0, 7], [13, 0, 9], [13, 0, 12], [13, 0, 14], [13, 0, 15], [13, 0, 19], [13, 1, 6], [13, 1, 7], [13, 1, 8], [13, 1, 10], [13, 1, 11], [13, 1, 13], [13, 1, 14], [13, 1, 15], [13, 1, 26], [13, 2, 4], [13, 2, 7], [13, 2, 9], [13, 2, 12], [13, 2, 14], [13, 2, 17], [13, 2, 25], [13, 2, 26], [13, 2, 27], [13, 3, 5], [13, 3, 8], [13, 3, 9], [13, 3, 12], [13, 3, 13], [13, 3, 16], [13, 3, 24], [13, 3, 26], [13, 3, 28], [13, 4, 3], [13, 4, 10], [13, 4, 11], [13, 4, 18], [13, 4, 23], [13, 4, 25], [13, 4, 27], [13, 4, 29], [13, 5, 4], [13, 5, 7], [13, 5, 10], [13, 5, 11], [13, 5, 14], [13, 5, 17], [13, 5, 24], [13, 5, 26], [13, 5, 28], [13, 6, 0], [13, 6, 5], [13, 6, 8], [13, 6, 13], [13, 6, 16], [13, 6, 21], [13, 6, 25], [13, 6, 27], [13, 7, 0], [13, 7, 1], [13, 7, 9], [13, 7, 12], [13, 7, 20], [13, 7, 21], [13, 7, 22], [13, 7, 26], [13, 7, 30], [13, 8, 0], [13, 8, 1], [13, 8, 7], [13, 8, 14], [13, 8, 20], [13, 8, 21], [13, 8, 23], [13, 8, 29], [13, 9, 2], [13, 9, 3], [13, 9, 18], [13, 9, 19], [13, 9, 22], [13, 9, 24], [13, 9, 28], [13, 9, 30], [13, 10, 2], [13, 10, 4], [13, 10, 9], [13, 10, 12], [13, 10, 17], [13, 10, 19], [13, 10, 23], [13, 10, 29], [13, 11, 1], [13, 11, 3], [13, 11, 4], [13, 11, 5], [13, 11, 16], [13, 11, 17], [13, 11, 18], [13, 11, 20], [13, 11, 26], [13, 12, 0], [13, 12, 2], [13, 12, 4], [13, 12, 17], [13, 12, 19], [13, 12, 21], [13, 12, 25], [13, 12, 26], [13, 12, 27], [13, 13, 1], [13, 13, 3], [13, 13, 6], [13, 13, 15], [13, 13, 18], [13, 13, 20], [13, 13, 25], [13, 13, 26], [13, 13, 27], [13, 14, 2], [13, 14, 8], [13, 14, 13], [13, 14, 19], [13, 14, 23], [13, 14, 24], [13, 14, 26], [13, 14, 28], [13, 14, 29], [13, 15, 7], [13, 15, 14], [13, 15, 22], [13, 15, 24], [13, 15, 25], [13, 15, 27], [13, 15, 28], [13, 15, 30], [13, 16, 0], [13, 16, 6], [13, 16, 15], [13, 16, 21], [13, 16, 22], [13, 16, 23], [13, 16, 26], [13, 16, 29], [13, 16, 30], [13, 17, 5], [13, 17, 10], [13, 17, 11], [13, 17, 16], [13, 17, 22], [13, 17, 23], [13, 17, 26], [13, 17, 29], [13, 17, 30], [13, 18, 1], [13, 18, 10], [13, 18, 11], [13, 18, 20], [13, 18, 24], [13, 18, 25], [13, 18, 27], [13, 18, 28], [13, 19, 0], [13, 19, 3], [13, 19, 9], [13, 19, 12], [13, 19, 18], [13, 19, 21], [13, 19, 24], [13, 19, 26], [13, 19, 28], [13, 20, 2], [13, 20, 8], [13, 20, 13], [13, 20, 19], [13, 20, 22], [13, 20, 25], [13, 20, 26], [13, 20, 27], [13, 20, 30], [13, 21, 26], [13, 22, 0], [13, 22, 5], [13, 22, 6], [13, 22, 15], [13, 22, 16], [13, 22, 21], [13, 22, 24], [13, 22, 28], [13, 23, 4], [13, 23, 5], [13, 23, 6], [13, 23, 15], [13, 23, 16], [13, 23, 17], [13, 23, 22], [13, 23, 30], [13, 24, 3], [13, 24, 5], [13, 24, 7], [13, 24, 14], [13, 24, 16], [13, 24, 18], [13, 24, 23], [13, 24, 26], [13, 24, 29], [13, 25, 3], [13, 25, 4], [13, 25, 6], [13, 25, 8], [13, 25, 13], [13, 25, 15], [13, 25, 17], [13, 25, 18], [13, 26, 1], [13, 26, 2], [13, 26, 5], [13, 26, 7], [13, 26, 14], [13, 26, 16], [13, 26, 19], [13, 26, 20], [13, 27, 1], [13, 27, 2], [13, 27, 6], [13, 27, 10], [13, 27, 11], [13, 27, 15], [13, 27, 19], [13, 27, 20], [13, 27, 26], [13, 28, 3], [13, 28, 9], [13, 28, 10], [13, 28, 11], [13, 28, 12], [13, 28, 18], [13, 28, 22], [13, 28, 30], [13, 29, 0], [13, 29, 4], [13, 29, 8], [13, 29, 10], [13, 29, 11], [13, 29, 13], [13, 29, 17], [13, 29, 21], [13, 30, 1], [13, 30, 8], [13, 30, 9], [13, 30, 12], [13, 30, 13], [13, 30, 20], [13, 30, 23], [13, 30, 29], [14, 0, 5], [14, 0, 9], [14, 0, 10], [14, 0, 12], [14, 0, 13], [14, 0, 17], [14, 0, 26], [14, 0, 27], [14, 1, 3], [14, 1, 6], [14, 1, 9], [14, 1, 11], [14, 1, 13], [14, 1, 16], [14, 1, 19], [14, 1, 25], [14, 1, 28], [14, 2, 4], [14, 2, 7], [14, 2, 10], [14, 2, 11], [14, 2, 12], [14, 2, 15], [14, 2, 18], [14, 2, 24], [14, 2, 29], [14, 3, 11], [14, 4, 0], [14, 4, 1], [14, 4, 6], [14, 4, 9], [14, 4, 13], [14, 4, 16], [14, 4, 21], [14, 4, 22], [14, 5, 0], [14, 5, 1], [14, 5, 2], [14, 5, 7], [14, 5, 15], [14, 5, 20], [14, 5, 21], [14, 5, 22], [14, 6, 1], [14, 6, 3], [14, 6, 8], [14, 6, 11], [14, 6, 14], [14, 6, 19], [14, 6, 21], [14, 6, 23], [14, 6, 30], [14, 7, 0], [14, 7, 2], [14, 7, 3], [14, 7, 19], [14, 7, 20], [14, 7, 22], [14, 7, 24], [14, 7, 29], [14, 8, 1], [14, 8, 4], [14, 8, 5], [14, 8, 17], [14, 8, 18], [14, 8, 21], [14, 8, 23], [14, 8, 30], [14, 9, 0], [14, 9, 4], [14, 9, 5], [14, 9, 11], [14, 9, 17], [14, 9, 18], [14, 9, 22], [14, 9, 26], [14, 9, 27], [14, 10, 3], [14, 10, 7], [14, 10, 15], [14, 10, 19], [14, 10, 25], [14, 10, 26], [14, 10, 27], [14, 10, 28], [14, 11, 2], [14, 11, 6], [14, 11, 16], [14, 11, 20], [14, 11, 24], [14, 11, 26], [14, 11, 27], [14, 11, 29], [14, 12, 5], [14, 12, 8], [14, 12, 14], [14, 12, 17], [14, 12, 24], [14, 12, 25], [14, 12, 28], [14, 12, 29], [14, 13, 0], [14, 13, 4], [14, 13, 18], [14, 13, 22], [14, 13, 23], [14, 13, 25], [14, 13, 28], [14, 13, 30], [14, 14, 0], [14, 14, 11], [14, 14, 22], [14, 14, 23], [14, 14, 24], [14, 14, 26], [14, 14, 27], [14, 14, 29], [14, 14, 30], [14, 15, 2], [14, 15, 10], [14, 15, 11], [14, 15, 12], [14, 15, 20], [14, 15, 23], [14, 15, 25], [14, 15, 28], [14, 15, 30], [14, 16, 1], [14, 16, 9], [14, 16, 11], [14, 16, 13], [14, 16, 21], [14, 16, 24], [14, 16, 25], [14, 16, 28], [14, 16, 29], [14, 17, 3], [14, 17, 8], [14, 17, 10], [14, 17, 12], [14, 17, 14], [14, 17, 19], [14, 17, 26], [14, 17, 27], [14, 18, 2], [14, 18, 9], [14, 18, 11], [14, 18, 13], [14, 18, 20], [14, 18, 23], [14, 18, 26], [14, 18, 27], [14, 18, 30], [14, 19, 1], [14, 19, 6], [14, 19, 10], [14, 19, 12], [14, 19, 16], [14, 19, 21], [14, 19, 24], [14, 19, 29], [14, 20, 5], [14, 20, 6], [14, 20, 7], [14, 20, 11], [14, 20, 15], [14, 20, 16], [14, 20, 17], [14, 20, 25], [14, 20, 28], [14, 21, 5], [14, 21, 6], [14, 21, 8], [14, 21, 14], [14, 21, 16], [14, 21, 17], [14, 21, 23], [14, 21, 30], [14, 22, 3], [14, 22, 4], [14, 22, 7], [14, 22, 9], [14, 22, 13], [14, 22, 15], [14, 22, 18], [14, 22, 19], [14, 23, 2], [14, 23, 4], [14, 23, 8], [14, 23, 14], [14, 23, 18], [14, 23, 20], [14, 23, 25], [14, 23, 28], [14, 24, 1], [14, 24, 2], [14, 24, 3], [14, 24, 5], [14, 24, 11], [14, 24, 17], [14, 24, 19], [14, 24, 20], [14, 24, 21], [14, 25, 2], [14, 25, 4], [14, 25, 6], [14, 25, 10], [14, 25, 11], [14, 25, 12], [14, 25, 16], [14, 25, 18], [14, 25, 20], [14, 26, 0], [14, 26, 3], [14, 26, 5], [14, 26, 10], [14, 26, 11], [14, 26, 12], [14, 26, 17], [14, 26, 19], [14, 26, 22], [14, 27, 4], [14, 27, 8], [14, 27, 9], [14, 27, 11], [14, 27, 13], [14, 27, 14], [14, 27, 18], [14, 27, 24], [14, 27, 29], [14, 28, 7], [14, 28, 9], [14, 28, 10], [14, 28, 12], [14, 28, 13], [14, 28, 15], [14, 28, 23], [14, 28, 30], [14, 29, 0], [14, 29, 6], [14, 29, 7], [14, 29, 8], [14, 29, 11], [14, 29, 14], [14, 29, 15], [14, 29, 16], [14, 29, 22], [14, 30, 1], [14, 30, 7], [14, 30, 8], [14, 30, 11], [14, 30, 14], [14, 30, 15], [14, 30, 21], [14, 30, 26], [14, 30, 27], [15, 0, 6], [15, 0, 9], [15, 0, 10], [15, 0, 13], [15, 0, 14], [15, 0, 17], [15, 0, 25], [15, 0, 27], [15, 0, 29], [15, 1, 4], [15, 1, 11], [15, 1, 12], [15, 1, 19], [15, 1, 24], [15, 1, 26], [15, 1, 28], [15, 1, 30], [15, 2, 5], [15, 2, 8], [15, 2, 11], [15, 2, 12], [15, 2, 15], [15, 2, 18], [15, 2, 25], [15, 2, 27], [15, 2, 29], [15, 3, 1], [15, 3, 6], [15, 3, 9], [15, 3, 14], [15, 3, 17], [15, 3, 22], [15, 3, 26], [15, 3, 28], [15, 4, 0], [15, 4, 1], [15, 4, 2], [15, 4, 10], [15, 4, 13], [15, 4, 21], [15, 4, 22], [15, 4, 23], [15, 4, 27], [15, 5, 1], [15, 5, 2], [15, 5, 8], [15, 5, 15], [15, 5, 21], [15, 5, 22], [15, 5, 24], [15, 5, 30], [15, 6, 0], [15, 6, 3], [15, 6, 4], [15, 6, 19], [15, 6, 20], [15, 6, 23], [15, 6, 25], [15, 6, 29], [15, 7, 3], [15, 7, 5], [15, 7, 10], [15, 7, 13], [15, 7, 18], [15, 7, 20], [15, 7, 24], [15, 7, 30], [15, 8, 2], [15, 8, 4], [15, 8, 5], [15, 8, 6], [15, 8, 17], [15, 8, 18], [15, 8, 19], [15, 8, 21], [15, 8, 27], [15, 9, 1], [15, 9, 3], [15, 9, 5], [15, 9, 18], [15, 9, 20], [15, 9, 22], [15, 9, 26], [15, 9, 27], [15, 9, 28], [15, 10, 2], [15, 10, 4], [15, 10, 7], [15, 10, 16], [15, 10, 19], [15, 10, 21], [15, 10, 26], [15, 10, 27], [15, 10, 28], [15, 11, 3], [15, 11, 9], [15, 11, 14], [15, 11, 20], [15, 11, 24], [15, 11, 25], [15, 11, 27], [15, 11, 29], [15, 11, 30], [15, 12, 0], [15, 12, 8], [15, 12, 15], [15, 12, 23], [15, 12, 25], [15, 12, 26], [15, 12, 28], [15, 12, 29], [15, 13, 0], [15, 13, 1], [15, 13, 7], [15, 13, 16], [15, 13, 22], [15, 13, 23], [15, 13, 24], [15, 13, 27], [15, 13, 30], [15, 14, 0], [15, 14, 6], [15, 14, 11], [15, 14, 12], [15, 14, 17], [15, 14, 23], [15, 14, 24], [15, 14, 27], [15, 14, 30], [15, 15, 2], [15, 15, 11], [15, 15, 12], [15, 15, 21], [15, 15, 25], [15, 15, 26], [15, 15, 28], [15, 15, 29], [15, 16, 1], [15, 16, 4], [15, 16, 10], [15, 16, 13], [15, 16, 19], [15, 16, 22], [15, 16, 25], [15, 16, 27], [15, 16, 29], [15, 17, 0], [15, 17, 3], [15, 17, 9], [15, 17, 14], [15, 17, 20], [15, 17, 23], [15, 17, 26], [15, 17, 27], [15, 17, 28], [15, 18, 27], [15, 19, 1], [15, 19, 6], [15, 19, 7], [15, 19, 16], [15, 19, 17], [15, 19, 22], [15, 19, 25], [15, 19, 29], [15, 20, 0], [15, 20, 5], [15, 20, 6], [15, 20, 7], [15, 20, 16], [15, 20, 17], [15, 20, 18], [15, 20, 23], [15, 21, 4], [15, 21, 6], [15, 21, 8], [15, 21, 15], [15, 21, 17], [15, 21, 19], [15, 21, 24], [15, 21, 27], [15, 21, 30], [15, 22, 4], [15, 22, 5], [15, 22, 7], [15, 22, 9], [15, 22, 14], [15, 22, 16], [15, 22, 18], [15, 22, 19], [15, 23, 2], [15, 23, 3], [15, 23, 6], [15, 23, 8], [15, 23, 15], [15, 23, 17], [15, 23, 20], [15, 23, 21], [15, 24, 2], [15, 24, 3], [15, 24, 7], [15, 24, 11], [15, 24, 12], [15, 24, 16], [15, 24, 20], [15, 24, 21], [15, 24, 27], [15, 25, 0], [15, 25, 4], [15, 25, 10], [15, 25, 11], [15, 25, 12], [15, 25, 13], [15, 25, 19], [15, 25, 23], [15, 26, 1], [15, 26, 5], [15, 26, 9], [15, 26, 11], [15, 26, 12], [15, 26, 14], [15, 26, 18], [15, 26, 22], [15, 27, 2], [15, 27, 9], [15, 27, 10], [15, 27, 13], [15, 27, 14], [15, 27, 21], [15, 27, 24], [15, 27, 30], [15, 28, 3], [15, 28, 7], [15, 28, 8], [15, 28, 10], [15, 28, 13], [15, 28, 15], [15, 28, 16], [15, 28, 20], [15, 29, 7], [15, 29, 8], [15, 29, 9], [15, 29, 11], [15, 29, 12], [15, 29, 14], [15, 29, 15], [15, 29, 16], [15, 29, 27], [15, 30, 5], [15, 30, 8], [15, 30, 10], [15, 30, 13], [15, 30, 15], [15, 30, 18], [15, 30, 26], [15, 30, 27], [15, 30, 28], [16, 0, 2], [16, 0, 8], [16, 0, 9], [16, 0, 12], [16, 0, 15], [16, 0, 16], [16, 0, 22], [16, 0, 27], [16, 0, 28], [16, 1, 6], [16, 1, 10], [16, 1, 11], [16, 1, 13], [16, 1, 14], [16, 1, 18], [16, 1, 27], [16, 1, 28], [16, 2, 4], [16, 2, 7], [16, 2, 10], [16, 2, 12], [16, 2, 14], [16, 2, 17], [16, 2, 20], [16, 2, 26], [16, 2, 29], [16, 3, 5], [16, 3, 8], [16, 3, 11], [16, 3, 12], [16, 3, 13], [16, 3, 16], [16, 3, 19], [16, 3, 25], [16, 3, 30], [16, 4, 12], [16, 5, 1], [16, 5, 2], [16, 5, 7], [16, 5, 10], [16, 5, 14], [16, 5, 17], [16, 5, 22], [16, 5, 23], [16, 6, 1], [16, 6, 2], [16, 6, 3], [16, 6, 8], [16, 6, 16], [16, 6, 21], [16, 6, 22], [16, 6, 23], [16, 7, 0], [16, 7, 2], [16, 7, 4], [16, 7, 9], [16, 7, 12], [16, 7, 15], [16, 7, 20], [16, 7, 22], [16, 7, 24], [16, 8, 1], [16, 8, 3], [16, 8, 4], [16, 8, 20], [16, 8, 21], [16, 8, 23], [16, 8, 25], [16, 8, 30], [16, 9, 0], [16, 9, 2], [16, 9, 5], [16, 9, 6], [16, 9, 18], [16, 9, 19], [16, 9, 22], [16, 9, 24], [16, 10, 1], [16, 10, 5], [16, 10, 6], [16, 10, 12], [16, 10, 18], [16, 10, 19], [16, 10, 23], [16, 10, 27], [16, 10, 28], [16, 11, 4], [16, 11, 8], [16, 11, 16], [16, 11, 20], [16, 11, 26], [16, 11, 27], [16, 11, 28], [16, 11, 29], [16, 12, 3], [16, 12, 7], [16, 12, 17], [16, 12, 21], [16, 12, 25], [16, 12, 27], [16, 12, 28], [16, 12, 30], [16, 13, 6], [16, 13, 9], [16, 13, 15], [16, 13, 18], [16, 13, 25], [16, 13, 26], [16, 13, 29], [16, 13, 30], [16, 14, 0], [16, 14, 1], [16, 14, 5], [16, 14, 19], [16, 14, 23], [16, 14, 24], [16, 14, 26], [16, 14, 29], [16, 15, 0], [16, 15, 1], [16, 15, 12], [16, 15, 23], [16, 15, 24], [16, 15, 25], [16, 15, 27], [16, 15, 28], [16, 15, 30], [16, 16, 0], [16, 16, 3], [16, 16, 11], [16, 16, 12], [16, 16, 13], [16, 16, 21], [16, 16, 24], [16, 16, 26], [16, 16, 29], [16, 17, 2], [16, 17, 10], [16, 17, 12], [16, 17, 14], [16, 17, 22], [16, 17, 25], [16, 17, 26], [16, 17, 29], [16, 17, 30], [16, 18, 4], [16, 18, 9], [16, 18, 11], [16, 18, 13], [16, 18, 15], [16, 18, 20], [16, 18, 27], [16, 18, 28], [16, 19, 0], [16, 19, 3], [16, 19, 10], [16, 19, 12], [16, 19, 14], [16, 19, 21], [16, 19, 24], [16, 19, 27], [16, 19, 28], [16, 20, 2], [16, 20, 7], [16, 20, 11], [16, 20, 13], [16, 20, 17], [16, 20, 22], [16, 20, 25], [16, 20, 30], [16, 21, 6], [16, 21, 7], [16, 21, 8], [16, 21, 12], [16, 21, 16], [16, 21, 17], [16, 21, 18], [16, 21, 26], [16, 21, 29], [16, 22, 0], [16, 22, 6], [16, 22, 7], [16, 22, 9], [16, 22, 15], [16, 22, 17], [16, 22, 18], [16, 22, 24], [16, 23, 4], [16, 23, 5], [16, 23, 8], [16, 23, 10], [16, 23, 14], [16, 23, 16], [16, 23, 19], [16, 23, 20], [16, 24, 3], [16, 24, 5], [16, 24, 9], [16, 24, 15], [16, 24, 19], [16, 24, 21], [16, 24, 26], [16, 24, 29], [16, 25, 2], [16, 25, 3], [16, 25, 4], [16, 25, 6], [16, 25, 12], [16, 25, 18], [16, 25, 20], [16, 25, 21], [16, 25, 22], [16, 26, 3], [16, 26, 5], [16, 26, 7], [16, 26, 11], [16, 26, 12], [16, 26, 13], [16, 26, 17], [16, 26, 19], [16, 26, 21], [16, 27, 1], [16, 27, 4], [16, 27, 6], [16, 27, 11], [16, 27, 12], [16, 27, 13], [16, 27, 18], [16, 27, 20], [16, 27, 23], [16, 28, 5], [16, 28, 9], [16, 28, 10], [16, 28, 12], [16, 28, 14], [16, 28, 15], [16, 28, 19], [16, 28, 25], [16, 28, 30], [16, 29, 0], [16, 29, 8], [16, 29, 10], [16, 29, 11], [16, 29, 13], [16, 29, 14], [16, 29, 16], [16, 29, 24], [16, 30, 1], [16, 30, 7], [16, 30, 8], [16, 30, 9], [16, 30, 12], [16, 30, 15], [16, 30, 16], [16, 30, 17], [16, 30, 23], [17, 0, 2], [17, 0, 6], [17, 0, 10], [17, 0, 12], [17, 0, 13], [17, 0, 15], [17, 0, 19], [17, 0, 23], [17, 1, 0], [17, 1, 3], [17, 1, 10], [17, 1, 11], [17, 1, 14], [17, 1, 15], [17, 1, 22], [17, 1, 25], [17, 2, 4], [17, 2, 8], [17, 2, 9], [17, 2, 11], [17, 2, 14], [17, 2, 16], [17, 2, 17], [17, 2, 21], [17, 3, 8], [17, 3, 9], [17, 3, 10], [17, 3, 12], [17, 3, 13], [17, 3, 15], [17, 3, 16], [17, 3, 17], [17, 3, 28], [17, 4, 6], [17, 4, 9], [17, 4, 11], [17, 4, 14], [17, 4, 16], [17, 4, 19], [17, 4, 27], [17, 4, 28], [17, 4, 29], [17, 5, 7], [17, 5, 10], [17, 5, 11], [17, 5, 14], [17, 5, 15], [17, 5, 18], [17, 5, 26], [17, 5, 28], [17, 5, 30], [17, 6, 0], [17, 6, 5], [17, 6, 12], [17, 6, 13], [17, 6, 20], [17, 6, 25], [17, 6, 27], [17, 6, 29], [17, 7, 6], [17, 7, 9], [17, 7, 12], [17, 7, 13], [17, 7, 16], [17, 7, 19], [17, 7, 26], [17, 7, 28], [17, 7, 30], [17, 8, 2], [17, 8, 7], [17, 8, 10], [17, 8, 15], [17, 8, 18], [17, 8, 23], [17, 8, 27], [17, 8, 29], [17, 9, 1], [17, 9, 2], [17, 9, 3], [17, 9, 11], [17, 9, 14], [17, 9, 22], [17, 9, 23], [17, 9, 24], [17, 9, 28], [17, 10, 0], [17, 10, 2], [17, 10, 3], [17, 10, 9], [17, 10, 16], [17, 10, 22], [17, 10, 23], [17, 10, 25], [17, 11, 1], [17, 11, 4], [17, 11, 5], [17, 11, 20], [17, 11, 21], [17, 11, 24], [17, 11, 26], [17, 11, 30], [17, 12, 0], [17, 12, 4], [17, 12, 6], [17, 12, 11], [17, 12, 14], [17, 12, 19], [17, 12, 21], [17, 12, 25], [17, 13, 3], [17, 13, 5], [17, 13, 6], [17, 13, 7], [17, 13, 18], [17, 13, 19], [17, 13, 20], [17, 13, 22], [17, 13, 28], [17, 14, 2], [17, 14, 4], [17, 14, 6], [17, 14, 19], [17, 14, 21], [17, 14, 23], [17, 14, 27], [17, 14, 28], [17, 14, 29], [17, 15, 3], [17, 15, 5], [17, 15, 8], [17, 15, 17], [17, 15, 20], [17, 15, 22], [17, 15, 27], [17, 15, 28], [17, 15, 29], [17, 16, 0], [17, 16, 4], [17, 16, 10], [17, 16, 15], [17, 16, 21], [17, 16, 25], [17, 16, 26], [17, 16, 28], [17, 16, 30], [17, 17, 1], [17, 17, 9], [17, 17, 16], [17, 17, 24], [17, 17, 26], [17, 17, 27], [17, 17, 29], [17, 17, 30], [17, 18, 0], [17, 18, 1], [17, 18, 2], [17, 18, 8], [17, 18, 17], [17, 18, 23], [17, 18, 24], [17, 18, 25], [17, 18, 28], [17, 19, 0], [17, 19, 1], [17, 19, 7], [17, 19, 12], [17, 19, 13], [17, 19, 18], [17, 19, 24], [17, 19, 25], [17, 19, 28], [17, 20, 3], [17, 20, 12], [17, 20, 13], [17, 20, 22], [17, 20, 26], [17, 20, 27], [17, 20, 29], [17, 20, 30], [17, 21, 2], [17, 21, 5], [17, 21, 11], [17, 21, 14], [17, 21, 20], [17, 21, 23], [17, 21, 26], [17, 21, 28], [17, 21, 30], [17, 22, 1], [17, 22, 4], [17, 22, 10], [17, 22, 15], [17, 22, 21], [17, 22, 24], [17, 22, 27], [17, 22, 28], [17, 22, 29], [17, 23, 28], [17, 24, 2], [17, 24, 7], [17, 24, 8], [17, 24, 17], [17, 24, 18], [17, 24, 23], [17, 24, 26], [17, 24, 30], [17, 25, 1], [17, 25, 6], [17, 25, 7], [17, 25, 8], [17, 25, 17], [17, 25, 18], [17, 25, 19], [17, 25, 24], [17, 26, 0], [17, 26, 5], [17, 26, 7], [17, 26, 9], [17, 26, 16], [17, 26, 18], [17, 26, 20], [17, 26, 25], [17, 26, 28], [17, 27, 5], [17, 27, 6], [17, 27, 8], [17, 27, 10], [17, 27, 15], [17, 27, 17], [17, 27, 19], [17, 27, 20], [17, 28, 3], [17, 28, 4], [17, 28, 7], [17, 28, 9], [17, 28, 16], [17, 28, 18], [17, 28, 21], [17, 28, 22], [17, 29, 3], [17, 29, 4], [17, 29, 8], [17, 29, 12], [17, 29, 13], [17, 29, 17], [17, 29, 21], [17, 29, 22], [17, 29, 28], [17, 30, 1], [17, 30, 5], [17, 30, 11], [17, 30, 12], [17, 30, 13], [17, 30, 14], [17, 30, 20], [17, 30, 24], [18, 0, 1], [18, 0, 7], [18, 0, 8], [18, 0, 10], [18, 0, 16], [18, 0, 18], [18, 0, 19], [18, 0, 25], [18, 1, 5], [18, 1, 6], [18, 1, 9], [18, 1, 11], [18, 1, 15], [18, 1, 17], [18, 1, 20], [18, 1, 21], [18, 2, 4], [18, 2, 6], [18, 2, 10], [18, 2, 16], [18, 2, 20], [18, 2, 22], [18, 2, 27], [18, 2, 30], [18, 3, 3], [18, 3, 4], [18, 3, 5], [18, 3, 7], [18, 3, 13], [18, 3, 19], [18, 3, 21], [18, 3, 22], [18, 3, 23], [18, 4, 4], [18, 4, 6], [18, 4, 8], [18, 4, 12], [18, 4, 13], [18, 4, 14], [18, 4, 18], [18, 4, 20], [18, 4, 22], [18, 5, 2], [18, 5, 5], [18, 5, 7], [18, 5, 12], [18, 5, 13], [18, 5, 14], [18, 5, 19], [18, 5, 21], [18, 5, 24], [18, 6, 0], [18, 6, 6], [18, 6, 10], [18, 6, 11], [18, 6, 13], [18, 6, 15], [18, 6, 16], [18, 6, 20], [18, 6, 26], [18, 7, 1], [18, 7, 9], [18, 7, 11], [18, 7, 12], [18, 7, 14], [18, 7, 15], [18, 7, 17], [18, 7, 25], [18, 8, 2], [18, 8, 8], [18, 8, 9], [18, 8, 10], [18, 8, 13], [18, 8, 16], [18, 8, 17], [18, 8, 18], [18, 8, 24], [18, 9, 3], [18, 9, 9], [18, 9, 10], [18, 9, 13], [18, 9, 16], [18, 9, 17], [18, 9, 23], [18, 9, 28], [18, 9, 29], [18, 10, 7], [18, 10, 11], [18, 10, 12], [18, 10, 14], [18, 10, 15], [18, 10, 19], [18, 10, 28], [18, 10, 29], [18, 11, 5], [18, 11, 8], [18, 11, 11], [18, 11, 13], [18, 11, 15], [18, 11, 18], [18, 11, 21], [18, 11, 27], [18, 11, 30], [18, 12, 0], [18, 12, 6], [18, 12, 9], [18, 12, 12], [18, 12, 13], [18, 12, 14], [18, 12, 17], [18, 12, 20], [18, 12, 26], [18, 13, 13], [18, 14, 2], [18, 14, 3], [18, 14, 8], [18, 14, 11], [18, 14, 15], [18, 14, 18], [18, 14, 23], [18, 14, 24], [18, 15, 2], [18, 15, 3], [18, 15, 4], [18, 15, 9], [18, 15, 17], [18, 15, 22], [18, 15, 23], [18, 15, 24], [18, 16, 1], [18, 16, 3], [18, 16, 5], [18, 16, 10], [18, 16, 13], [18, 16, 16], [18, 16, 21], [18, 16, 23], [18, 16, 25], [18, 17, 0], [18, 17, 2], [18, 17, 4], [18, 17, 5], [18, 17, 21], [18, 17, 22], [18, 17, 24], [18, 17, 26], [18, 18, 1], [18, 18, 3], [18, 18, 6], [18, 18, 7], [18, 18, 19], [18, 18, 20], [18, 18, 23], [18, 18, 25], [18, 19, 2], [18, 19, 6], [18, 19, 7], [18, 19, 13], [18, 19, 19], [18, 19, 20], [18, 19, 24], [18, 19, 28], [18, 19, 29], [18, 20, 5], [18, 20, 9], [18, 20, 17], [18, 20, 21], [18, 20, 27], [18, 20, 28], [18, 20, 29], [18, 20, 30], [18, 21, 0], [18, 21, 4], [18, 21, 8], [18, 21, 18], [18, 21, 22], [18, 21, 26], [18, 21, 28], [18, 21, 29], [18, 22, 0], [18, 22, 7], [18, 22, 10], [18, 22, 16], [18, 22, 19], [18, 22, 26], [18, 22, 27], [18, 22, 30], [18, 23, 1], [18, 23, 2], [18, 23, 6], [18, 23, 20], [18, 23, 24], [18, 23, 25], [18, 23, 27], [18, 23, 30], [18, 24, 0], [18, 24, 1], [18, 24, 2], [18, 24, 13], [18, 24, 24], [18, 24, 25], [18, 24, 26], [18, 24, 28], [18, 24, 29], [18, 25, 1], [18, 25, 4], [18, 25, 12], [18, 25, 13], [18, 25, 14], [18, 25, 22], [18, 25, 25], [18, 25, 27], [18, 25, 30], [18, 26, 0], [18, 26, 3], [18, 26, 11], [18, 26, 13], [18, 26, 15], [18, 26, 23], [18, 26, 26], [18, 26, 27], [18, 26, 30], [18, 27, 5], [18, 27, 10], [18, 27, 12], [18, 27, 14], [18, 27, 16], [18, 27, 21], [18, 27, 28], [18, 27, 29], [18, 28, 1], [18, 28, 4], [18, 28, 11], [18, 28, 13], [18, 28, 15], [18, 28, 22], [18, 28, 25], [18, 28, 28], [18, 28, 29], [18, 29, 0], [18, 29, 3], [18, 29, 8], [18, 29, 12], [18, 29, 14], [18, 29, 18], [18, 29, 23], [18, 29, 26], [18, 30, 7], [18, 30, 8], [18, 30, 9], [18, 30, 13], [18, 30, 17], [18, 30, 18], [18, 30, 19], [18, 30, 27], [18, 30, 30], [19, 0, 1], [19, 0, 2], [19, 0, 3], [19, 0, 9], [19, 0, 18], [19, 0, 24], [19, 0, 25], [19, 0, 26], [19, 0, 29], [19, 1, 1], [19, 1, 2], [19, 1, 8], [19, 1, 13], [19, 1, 14], [19, 1, 19], [19, 1, 25], [19, 1, 26], [19, 1, 29], [19, 2, 0], [19, 2, 4], [19, 2, 13], [19, 2, 14], [19, 2, 23], [19, 2, 27], [19, 2, 28], [19, 2, 30], [19, 3, 0], [19, 3, 3], [19, 3, 6], [19, 3, 12], [19, 3, 15], [19, 3, 21], [19, 3, 24], [19, 3, 27], [19, 3, 29], [19, 4, 2], [19, 4, 5], [19, 4, 11], [19, 4, 16], [19, 4, 22], [19, 4, 25], [19, 4, 28], [19, 4, 29], [19, 4, 30], [19, 5, 29], [19, 6, 0], [19, 6, 3], [19, 6, 8], [19, 6, 9], [19, 6, 18], [19, 6, 19], [19, 6, 24], [19, 6, 27], [19, 7, 2], [19, 7, 7], [19, 7, 8], [19, 7, 9], [19, 7, 18], [19, 7, 19], [19, 7, 20], [19, 7, 25], [19, 8, 1], [19, 8, 6], [19, 8, 8], [19, 8, 10], [19, 8, 17], [19, 8, 19], [19, 8, 21], [19, 8, 26], [19, 8, 29], [19, 9, 6], [19, 9, 7], [19, 9, 9], [19, 9, 11], [19, 9, 16], [19, 9, 18], [19, 9, 20], [19, 9, 21], [19, 10, 4], [19, 10, 5], [19, 10, 8], [19, 10, 10], [19, 10, 17], [19, 10, 19], [19, 10, 22], [19, 10, 23], [19, 11, 4], [19, 11, 5], [19, 11, 9], [19, 11, 13], [19, 11, 14], [19, 11, 18], [19, 11, 22], [19, 11, 23], [19, 11, 29], [19, 12, 2], [19, 12, 6], [19, 12, 12], [19, 12, 13], [19, 12, 14], [19, 12, 15], [19, 12, 21], [19, 12, 25], [19, 13, 3], [19, 13, 7], [19, 13, 11], [19, 13, 13], [19, 13, 14], [19, 13, 16], [19, 13, 20], [19, 13, 24], [19, 14, 1], [19, 14, 4], [19, 14, 11], [19, 14, 12], [19, 14, 15], [19, 14, 16], [19, 14, 23], [19, 14, 26], [19, 15, 5], [19, 15, 9], [19, 15, 10], [19, 15, 12], [19, 15, 15], [19, 15, 17], [19, 15, 18], [19, 15, 22], [19, 16, 9], [19, 16, 10], [19, 16, 11], [19, 16, 13], [19, 16, 14], [19, 16, 16], [19, 16, 17], [19, 16, 18], [19, 16, 29], [19, 17, 7], [19, 17, 10], [19, 17, 12], [19, 17, 15], [19, 17, 17], [19, 17, 20], [19, 17, 28], [19, 17, 29], [19, 17, 30], [19, 18, 0], [19, 18, 8], [19, 18, 11], [19, 18, 12], [19, 18, 15], [19, 18, 16], [19, 18, 19], [19, 18, 27], [19, 18, 29], [19, 19, 1], [19, 19, 6], [19, 19, 13], [19, 19, 14], [19, 19, 21], [19, 19, 26], [19, 19, 28], [19, 19, 30], [19, 20, 0], [19, 20, 7], [19, 20, 10], [19, 20, 13], [19, 20, 14], [19, 20, 17], [19, 20, 20], [19, 20, 27], [19, 20, 29], [19, 21, 3], [19, 21, 8], [19, 21, 11], [19, 21, 16], [19, 21, 19], [19, 21, 24], [19, 21, 28], [19, 21, 30], [19, 22, 2], [19, 22, 3], [19, 22, 4], [19, 22, 12], [19, 22, 15], [19, 22, 23], [19, 22, 24], [19, 22, 25], [19, 22, 29], [19, 23, 1], [19, 23, 3], [19, 23, 4], [19, 23, 10], [19, 23, 17], [19, 23, 23], [19, 23, 24], [19, 23, 26], [19, 24, 0], [19, 24, 2], [19, 24, 5], [19, 24, 6], [19, 24, 21], [19, 24, 22], [19, 24, 25], [19, 24, 27], [19, 25, 1], [19, 25, 5], [19, 25, 7], [19, 25, 12], [19, 25, 15], [19, 25, 20], [19, 25, 22], [19, 25, 26], [19, 26, 4], [19, 26, 6], [19, 26, 7], [19, 26, 8], [19, 26, 19], [19, 26, 20], [19, 26, 21], [19, 26, 23], [19, 26, 29], [19, 27, 3], [19, 27, 5], [19, 27, 7], [19, 27, 20], [19, 27, 22], [19, 27, 24], [19, 27, 28], [19, 27, 29], [19, 27, 30], [19, 28, 4], [19, 28, 6], [19, 28, 9], [19, 28, 18], [19, 28, 21], [19, 28, 23], [19, 28, 28], [19, 28, 29], [19, 28, 30], [19, 29, 0], [19, 29, 1], [19, 29, 5], [19, 29, 11], [19, 29, 16], [19, 29, 22], [19, 29, 26], [19, 29, 27], [19, 29, 29], [19, 30, 0], [19, 30, 2], [19, 30, 10], [19, 30, 17], [19, 30, 25], [19, 30, 27], [19, 30, 28], [19, 30, 30], [20, 0, 3], [20, 0, 4], [20, 0, 9], [20, 0, 12], [20, 0, 16], [20, 0, 19], [20, 0, 24], [20, 0, 25], [20, 1, 3], [20, 1, 4], [20, 1, 5], [20, 1, 10], [20, 1, 18], [20, 1, 23], [20, 1, 24], [20, 1, 25], [20, 2, 2], [20, 2, 4], [20, 2, 6], [20, 2, 11], [20, 2, 14], [20, 2, 17], [20, 2, 22], [20, 2, 24], [20, 2, 26], [20, 3, 1], [20, 3, 3], [20, 3, 5], [20, 3, 6], [20, 3, 22], [20, 3, 23], [20, 3, 25], [20, 3, 27], [20, 4, 2], [20, 4, 4], [20, 4, 7], [20, 4, 8], [20, 4, 20], [20, 4, 21], [20, 4, 24], [20, 4, 26], [20, 5, 3], [20, 5, 7], [20, 5, 8], [20, 5, 14], [20, 5, 20], [20, 5, 21], [20, 5, 25], [20, 5, 29], [20, 5, 30], [20, 6, 0], [20, 6, 6], [20, 6, 10], [20, 6, 18], [20, 6, 22], [20, 6, 28], [20, 6, 29], [20, 6, 30], [20, 7, 1], [20, 7, 5], [20, 7, 9], [20, 7, 19], [20, 7, 23], [20, 7, 27], [20, 7, 29], [20, 7, 30], [20, 8, 0], [20, 8, 1], [20, 8, 8], [20, 8, 11], [20, 8, 17], [20, 8, 20], [20, 8, 27], [20, 8, 28], [20, 9, 0], [20, 9, 2], [20, 9, 3], [20, 9, 7], [20, 9, 21], [20, 9, 25], [20, 9, 26], [20, 9, 28], [20, 10, 1], [20, 10, 2], [20, 10, 3], [20, 10, 14], [20, 10, 25], [20, 10, 26], [20, 10, 27], [20, 10, 29], [20, 10, 30], [20, 11, 0], [20, 11, 2], [20, 11, 5], [20, 11, 13], [20, 11, 14], [20, 11, 15], [20, 11, 23], [20, 11, 26], [20, 11, 28], [20, 12, 0], [20, 12, 1], [20, 12, 4], [20, 12, 12], [20, 12, 14], [20, 12, 16], [20, 12, 24], [20, 12, 27], [20, 12, 28], [20, 13, 6], [20, 13, 11], [20, 13, 13], [20, 13, 15], [20, 13, 17], [20, 13, 22], [20, 13, 29], [20, 13, 30], [20, 14, 2], [20, 14, 5], [20, 14, 12], [20, 14, 14], [20, 14, 16], [20, 14, 23], [20, 14, 26], [20, 14, 29], [20, 14, 30], [20, 15, 1], [20, 15, 4], [20, 15, 9], [20, 15, 13], [20, 15, 15], [20, 15, 19], [20, 15, 24], [20, 15, 27], [20, 16, 0], [20, 16, 8], [20, 16, 9], [20, 16, 10], [20, 16, 14], [20, 16, 18], [20, 16, 19], [20, 16, 20], [20, 16, 28], [20, 17, 2], [20, 17, 8], [20, 17, 9], [20, 17, 11], [20, 17, 17], [20, 17, 19], [20, 17, 20], [20, 17, 26], [20, 18, 6], [20, 18, 7], [20, 18, 10], [20, 18, 12], [20, 18, 16], [20, 18, 18], [20, 18, 21], [20, 18, 22], [20, 19, 0], [20, 19, 5], [20, 19, 7], [20, 19, 11], [20, 19, 17], [20, 19, 21], [20, 19, 23], [20, 19, 28], [20, 20, 4], [20, 20, 5], [20, 20, 6], [20, 20, 8], [20, 20, 14], [20, 20, 20], [20, 20, 22], [20, 20, 23], [20, 20, 24], [20, 21, 5], [20, 21, 7], [20, 21, 9], [20, 21, 13], [20, 21, 14], [20, 21, 15], [20, 21, 19], [20, 21, 21], [20, 21, 23], [20, 22, 3], [20, 22, 6], [20, 22, 8], [20, 22, 13], [20, 22, 14], [20, 22, 15], [20, 22, 20], [20, 22, 22], [20, 22, 25], [20, 23, 1], [20, 23, 7], [20, 23, 11], [20, 23, 12], [20, 23, 14], [20, 23, 16], [20, 23, 17], [20, 23, 21], [20, 23, 27], [20, 24, 2], [20, 24, 10], [20, 24, 12], [20, 24, 13], [20, 24, 15], [20, 24, 16], [20, 24, 18], [20, 24, 26], [20, 25, 3], [20, 25, 9], [20, 25, 10], [20, 25, 11], [20, 25, 14], [20, 25, 17], [20, 25, 18], [20, 25, 19], [20, 25, 25], [20, 26, 4], [20, 26, 10], [20, 26, 11], [20, 26, 14], [20, 26, 17], [20, 26, 18], [20, 26, 24], [20, 26, 29], [20, 26, 30], [20, 27, 8], [20, 27, 12], [20, 27, 13], [20, 27, 15], [20, 27, 16], [20, 27, 20], [20, 27, 29], [20, 27, 30], [20, 28, 0], [20, 28, 6], [20, 28, 9], [20, 28, 12], [20, 28, 14], [20, 28, 16], [20, 28, 19], [20, 28, 22], [20, 28, 28], [20, 29, 1], [20, 29, 7], [20, 29, 10], [20, 29, 13], [20, 29, 14], [20, 29, 15], [20, 29, 18], [20, 29, 21], [20, 29, 27], [20, 30, 14], [21, 0, 5], [21, 0, 6], [21, 0, 9], [21, 0, 11], [21, 0, 18], [21, 0, 20], [21, 0, 23], [21, 0, 24], [21, 1, 5], [21, 1, 6], [21, 1, 10], [21, 1, 14], [21, 1, 15], [21, 1, 19], [21, 1, 23], [21, 1, 24], [21, 1, 30], [21, 2, 3], [21, 2, 7], [21, 2, 13], [21, 2, 14], [21, 2, 15], [21, 2, 16], [21, 2, 22], [21, 2, 26], [21, 3, 4], [21, 3, 8], [21, 3, 12], [21, 3, 14], [21, 3, 15], [21, 3, 17], [21, 3, 21], [21, 3, 25], [21, 4, 2], [21, 4, 5], [21, 4, 12], [21, 4, 13], [21, 4, 16], [21, 4, 17], [21, 4, 24], [21, 4, 27], [21, 5, 6], [21, 5, 10], [21, 5, 11], [21, 5, 13], [21, 5, 16], [21, 5, 18], [21, 5, 19], [21, 5, 23], [21, 6, 10], [21, 6, 11], [21, 6, 12], [21, 6, 14], [21, 6, 15], [21, 6, 17], [21, 6, 18], [21, 6, 19], [21, 6, 30], [21, 7, 0], [21, 7, 8], [21, 7, 11], [21, 7, 13], [21, 7, 16], [21, 7, 18], [21, 7, 21], [21, 7, 29], [21, 7, 30], [21, 8, 1], [21, 8, 9], [21, 8, 12], [21, 8, 13], [21, 8, 16], [21, 8, 17], [21, 8, 20], [21, 8, 28], [21, 8, 30], [21, 9, 0], [21, 9, 2], [21, 9, 7], [21, 9, 14], [21, 9, 15], [21, 9, 22], [21, 9, 27], [21, 9, 29], [21, 10, 1], [21, 10, 8], [21, 10, 11], [21, 10, 14], [21, 10, 15], [21, 10, 18], [21, 10, 21], [21, 10, 28], [21, 10, 30], [21, 11, 0], [21, 11, 4], [21, 11, 9], [21, 11, 12], [21, 11, 17], [21, 11, 20], [21, 11, 25], [21, 11, 29], [21, 12, 3], [21, 12, 4], [21, 12, 5], [21, 12, 13], [21, 12, 16], [21, 12, 24], [21, 12, 25], [21, 12, 26], [21, 12, 30], [21, 13, 2], [21, 13, 4], [21, 13, 5], [21, 13, 11], [21, 13, 18], [21, 13, 24], [21, 13, 25], [21, 13, 27], [21, 14, 1], [21, 14, 3], [21, 14, 6], [21, 14, 7], [21, 14, 22], [21, 14, 23], [21, 14, 26], [21, 14, 28], [21, 15, 2], [21, 15, 6], [21, 15, 8], [21, 15, 13], [21, 15, 16], [21, 15, 21], [21, 15, 23], [21, 15, 27], [21, 16, 5], [21, 16, 7], [21, 16, 8], [21, 16, 9], [21, 16, 20], [21, 16, 21], [21, 16, 22], [21, 16, 24], [21, 16, 30], [21, 17, 0], [21, 17, 4], [21, 17, 6], [21, 17, 8], [21, 17, 21], [21, 17, 23], [21, 17, 25], [21, 17, 29], [21, 17, 30], [21, 18, 0], [21, 18, 5], [21, 18, 7], [21, 18, 10], [21, 18, 19], [21, 18, 22], [21, 18, 24], [21, 18, 29], [21, 18, 30], [21, 19, 1], [21, 19, 2], [21, 19, 6], [21, 19, 12], [21, 19, 17], [21, 19, 23], [21, 19, 27], [21, 19, 28], [21, 19, 30], [21, 20, 0], [21, 20, 1], [21, 20, 3], [21, 20, 11], [21, 20, 18], [21, 20, 26], [21, 20, 28], [21, 20, 29], [21, 21, 2], [21, 21, 3], [21, 21, 4], [21, 21, 10], [21, 21, 19], [21, 21, 25], [21, 21, 26], [21, 21, 27], [21, 21, 30], [21, 22, 2], [21, 22, 3], [21, 22, 9], [21, 22, 14], [21, 22, 15], [21, 22, 20], [21, 22, 26], [21, 22, 27], [21, 22, 30], [21, 23, 0], [21, 23, 1], [21, 23, 5], [21, 23, 14], [21, 23, 15], [21, 23, 24], [21, 23, 28], [21, 23, 29], [21, 24, 1], [21, 24, 4], [21, 24, 7], [21, 24, 13], [21, 24, 16], [21, 24, 22], [21, 24, 25], [21, 24, 28], [21, 24, 30], [21, 25, 0], [21, 25, 3], [21, 25, 6], [21, 25, 12], [21, 25, 17], [21, 25, 23], [21, 25, 26], [21, 25, 29], [21, 25, 30], [21, 26, 30], [21, 27, 1], [21, 27, 4], [21, 27, 9], [21, 27, 10], [21, 27, 19], [21, 27, 20], [21, 27, 25], [21, 27, 28], [21, 28, 3], [21, 28, 8], [21, 28, 9], [21, 28, 10], [21, 28, 19], [21, 28, 20], [21, 28, 21], [21, 28, 26], [21, 29, 2], [21, 29, 7], [21, 29, 9], [21, 29, 11], [21, 29, 18], [21, 29, 20], [21, 29, 22], [21, 29, 27], [21, 29, 30], [21, 30, 7], [21, 30, 8], [21, 30, 10], [21, 30, 12], [21, 30, 17], [21, 30, 19], [21, 30, 21], [21, 30, 22], [22, 0, 0], [22, 0, 1], [22, 0, 7], [22, 0, 11], [22, 0, 19], [22, 0, 23], [22, 0, 29], [22, 0, 30], [22, 1, 0], [22, 1, 2], [22, 1, 6], [22, 1, 10], [22, 1, 20], [22, 1, 24], [22, 1, 28], [22, 1, 30], [22, 2, 1], [22, 2, 2], [22, 2, 9], [22, 2, 12], [22, 2, 18], [22, 2, 21], [22, 2, 28], [22, 2, 29], [22, 3, 1], [22, 3, 3], [22, 3, 4], [22, 3, 8], [22, 3, 22], [22, 3, 26], [22, 3, 27], [22, 3, 29], [22, 4, 0], [22, 4, 2], [22, 4, 3], [22, 4, 4], [22, 4, 15], [22, 4, 26], [22, 4, 27], [22, 4, 28], [22, 4, 30], [22, 5, 1], [22, 5, 3], [22, 5, 6], [22, 5, 14], [22, 5, 15], [22, 5, 16], [22, 5, 24], [22, 5, 27], [22, 5, 29], [22, 6, 1], [22, 6, 2], [22, 6, 5], [22, 6, 13], [22, 6, 15], [22, 6, 17], [22, 6, 25], [22, 6, 28], [22, 6, 29], [22, 7, 0], [22, 7, 7], [22, 7, 12], [22, 7, 14], [22, 7, 16], [22, 7, 18], [22, 7, 23], [22, 7, 30], [22, 8, 0], [22, 8, 3], [22, 8, 6], [22, 8, 13], [22, 8, 15], [22, 8, 17], [22, 8, 24], [22, 8, 27], [22, 8, 30], [22, 9, 2], [22, 9, 5], [22, 9, 10], [22, 9, 14], [22, 9, 16], [22, 9, 20], [22, 9, 25], [22, 9, 28], [22, 10, 1], [22, 10, 9], [22, 10, 10], [22, 10, 11], [22, 10, 15], [22, 10, 19], [22, 10, 20], [22, 10, 21], [22, 10, 29], [22, 11, 3], [22, 11, 9], [22, 11, 10], [22, 11, 12], [22, 11, 18], [22, 11, 20], [22, 11, 21], [22, 11, 27], [22, 12, 7], [22, 12, 8], [22, 12, 11], [22, 12, 13], [22, 12, 17], [22, 12, 19], [22, 12, 22], [22, 12, 23], [22, 13, 1], [22, 13, 6], [22, 13, 8], [22, 13, 12], [22, 13, 18], [22, 13, 22], [22, 13, 24], [22, 13, 29], [22, 14, 5], [22, 14, 6], [22, 14, 7], [22, 14, 9], [22, 14, 15], [22, 14, 21], [22, 14, 23], [22, 14, 24], [22, 14, 25], [22, 15, 6], [22, 15, 8], [22, 15, 10], [22, 15, 14], [22, 15, 15], [22, 15, 16], [22, 15, 20], [22, 15, 22], [22, 15, 24], [22, 16, 4], [22, 16, 7], [22, 16, 9], [22, 16, 14], [22, 16, 15], [22, 16, 16], [22, 16, 21], [22, 16, 23], [22, 16, 26], [22, 17, 2], [22, 17, 8], [22, 17, 12], [22, 17, 13], [22, 17, 15], [22, 17, 17], [22, 17, 18], [22, 17, 22], [22, 17, 28], [22, 18, 3], [22, 18, 11], [22, 18, 13], [22, 18, 14], [22, 18, 16], [22, 18, 17], [22, 18, 19], [22, 18, 27], [22, 19, 4], [22, 19, 10], [22, 19, 11], [22, 19, 12], [22, 19, 15], [22, 19, 18], [22, 19, 19], [22, 19, 20], [22, 19, 26], [22, 20, 0], [22, 20, 5], [22, 20, 11], [22, 20, 12], [22, 20, 15], [22, 20, 18], [22, 20, 19], [22, 20, 25], [22, 20, 30], [22, 21, 0], [22, 21, 9], [22, 21, 13], [22, 21, 14], [22, 21, 16], [22, 21, 17], [22, 21, 21], [22, 21, 30], [22, 22, 1], [22, 22, 7], [22, 22, 10], [22, 22, 13], [22, 22, 15], [22, 22, 17], [22, 22, 20], [22, 22, 23], [22, 22, 29], [22, 23, 2], [22, 23, 8], [22, 23, 11], [22, 23, 14], [22, 23, 15], [22, 23, 16], [22, 23, 19], [22, 23, 22], [22, 23, 28], [22, 24, 15], [22, 25, 4], [22, 25, 5], [22, 25, 10], [22, 25, 13], [22, 25, 17], [22, 25, 20], [22, 25, 25], [22, 25, 26], [22, 26, 4], [22, 26, 5], [22, 26, 6], [22, 26, 11], [22, 26, 19], [22, 26, 24], [22, 26, 25], [22, 26, 26], [22, 27, 3], [22, 27, 5], [22, 27, 7], [22, 27, 12], [22, 27, 15], [22, 27, 18], [22, 27, 23], [22, 27, 25], [22, 27, 27], [22, 28, 2], [22, 28, 4], [22, 28, 6], [22, 28, 7], [22, 28, 23], [22, 28, 24], [22, 28, 26], [22, 28, 28], [22, 29, 3], [22, 29, 5], [22, 29, 8], [22, 29, 9], [22, 29, 21], [22, 29, 22], [22, 29, 25], [22, 29, 27], [22, 30, 0], [22, 30, 4], [22, 30, 8], [22, 30, 9], [22, 30, 15], [22, 30, 21], [22, 30, 22], [22, 30, 26], [22, 30, 30], [23, 0, 4], [23, 0, 8], [23, 0, 14], [23, 0, 15], [23, 0, 16], [23, 0, 17], [23, 0, 23], [23, 0, 27], [23, 1, 5], [23, 1, 9], [23, 1, 13], [23, 1, 15], [23, 1, 16], [23, 1, 18], [23, 1, 22], [23, 1, 26], [23, 2, 3], [23, 2, 6], [23, 2, 13], [23, 2, 14], [23, 2, 17], [23, 2, 18], [23, 2, 25], [23, 2, 28], [23, 3, 7], [23, 3, 11], [23, 3, 12], [23, 3, 14], [23, 3, 17], [23, 3, 19], [23, 3, 20], [23, 3, 24], [23, 4, 0], [23, 4, 11], [23, 4, 12], [23, 4, 13], [23, 4, 15], [23, 4, 16], [23, 4, 18], [23, 4, 19], [23, 4, 20], [23, 5, 0], [23, 5, 1], [23, 5, 9], [23, 5, 12], [23, 5, 14], [23, 5, 17], [23, 5, 19], [23, 5, 22], [23, 5, 30], [23, 6, 0], [23, 6, 2], [23, 6, 10], [23, 6, 13], [23, 6, 14], [23, 6, 17], [23, 6, 18], [23, 6, 21], [23, 6, 29], [23, 7, 1], [23, 7, 3], [23, 7, 8], [23, 7, 15], [23, 7, 16], [23, 7, 23], [23, 7, 28], [23, 7, 30], [23, 8, 0], [23, 8, 2], [23, 8, 9], [23, 8, 12], [23, 8, 15], [23, 8, 16], [23, 8, 19], [23, 8, 22], [23, 8, 29], [23, 9, 1], [23, 9, 5], [23, 9, 10], [23, 9, 13], [23, 9, 18], [23, 9, 21], [23, 9, 26], [23, 9, 30], [23, 10, 0], [23, 10, 4], [23, 10, 5], [23, 10, 6], [23, 10, 14], [23, 10, 17], [23, 10, 25], [23, 10, 26], [23, 10, 27], [23, 11, 3], [23, 11, 5], [23, 11, 6], [23, 11, 12], [23, 11, 19], [23, 11, 25], [23, 11, 26], [23, 11, 28], [23, 12, 2], [23, 12, 4], [23, 12, 7], [23, 12, 8], [23, 12, 23], [23, 12, 24], [23, 12, 27], [23, 12, 29], [23, 13, 3], [23, 13, 7], [23, 13, 9], [23, 13, 14], [23, 13, 17], [23, 13, 22], [23, 13, 24], [23, 13, 28], [23, 14, 0], [23, 14, 6], [23, 14, 8], [23, 14, 9], [23, 14, 10], [23, 14, 21], [23, 14, 22], [23, 14, 23], [23, 14, 25], [23, 15, 0], [23, 15, 1], [23, 15, 5], [23, 15, 7], [23, 15, 9], [23, 15, 22], [23, 15, 24], [23, 15, 26], [23, 15, 30], [23, 16, 0], [23, 16, 1], [23, 16, 6], [23, 16, 8], [23, 16, 11], [23, 16, 20], [23, 16, 23], [23, 16, 25], [23, 16, 30], [23, 17, 0], [23, 17, 2], [23, 17, 3], [23, 17, 7], [23, 17, 13], [23, 17, 18], [23, 17, 24], [23, 17, 28], [23, 17, 29], [23, 18, 1], [23, 18, 2], [23, 18, 4], [23, 18, 12], [23, 18, 19], [23, 18, 27], [23, 18, 29], [23, 18, 30], [23, 19, 0], [23, 19, 3], [23, 19, 4], [23, 19, 5], [23, 19, 11], [23, 19, 20], [23, 19, 26], [23, 19, 27], [23, 19, 28], [23, 20, 0], [23, 20, 3], [23, 20, 4], [23, 20, 10], [23, 20, 15], [23, 20, 16], [23, 20, 21], [23, 20, 27], [23, 20, 28], [23, 21, 1], [23, 21, 2], [23, 21, 6], [23, 21, 15], [23, 21, 16], [23, 21, 25], [23, 21, 29], [23, 21, 30], [23, 22, 0], [23, 22, 2], [23, 22, 5], [23, 22, 8], [23, 22, 14], [23, 22, 17], [23, 22, 23], [23, 22, 26], [23, 22, 29], [23, 23, 0], [23, 23, 1], [23, 23, 4], [23, 23, 7], [23, 23, 13], [23, 23, 18], [23, 23, 24], [23, 23, 27], [23, 23, 30], [23, 24, 0], [23, 25, 2], [23, 25, 5], [23, 25, 10], [23, 25, 11], [23, 25, 20], [23, 25, 21], [23, 25, 26], [23, 25, 29], [23, 26, 4], [23, 26, 9], [23, 26, 10], [23, 26, 11], [23, 26, 20], [23, 26, 21], [23, 26, 22], [23, 26, 27], [23, 27, 0], [23, 27, 3], [23, 27, 8], [23, 27, 10], [23, 27, 12], [23, 27, 19], [23, 27, 21], [23, 27, 23], [23, 27, 28], [23, 28, 8], [23, 28, 9], [23, 28, 11], [23, 28, 13], [23, 28, 18], [23, 28, 20], [23, 28, 22], [23, 28, 23], [23, 29, 6], [23, 29, 7], [23, 29, 10], [23, 29, 12], [23, 29, 19], [23, 29, 21], [23, 29, 24], [23, 29, 25], [23, 30, 0], [23, 30, 6], [23, 30, 7], [23, 30, 11], [23, 30, 15], [23, 30, 16], [23, 30, 20], [23, 30, 24], [23, 30, 25], [24, 0, 4], [24, 0, 6], [24, 0, 9], [24, 0, 10], [24, 0, 22], [24, 0, 23], [24, 0, 26], [24, 0, 28], [24, 1, 0], [24, 1, 1], [24, 1, 5], [24, 1, 9], [24, 1, 10], [24, 1, 16], [24, 1, 22], [24, 1, 23], [24, 1, 27], [24, 2, 0], [24, 2, 1], [24, 2, 2], [24, 2, 8], [24, 2, 12], [24, 2, 20], [24, 2, 24], [24, 2, 30], [24, 3, 0], [24, 3, 1], [24, 3, 3], [24, 3, 7], [24, 3, 11], [24, 3, 21], [24, 3, 25], [24, 3, 29], [24, 4, 2], [24, 4, 3], [24, 4, 10], [24, 4, 13], [24, 4, 19], [24, 4, 22], [24, 4, 29], [24, 4, 30], [24, 5, 2], [24, 5, 4], [24, 5, 5], [24, 5, 9], [24, 5, 23], [24, 5, 27], [24, 5, 28], [24, 5, 30], [24, 6, 0], [24, 6, 1], [24, 6, 3], [24, 6, 4], [24, 6, 5], [24, 6, 16], [24, 6, 27], [24, 6, 28], [24, 6, 29], [24, 7, 2], [24, 7, 4], [24, 7, 7], [24, 7, 15], [24, 7, 16], [24, 7, 17], [24, 7, 25], [24, 7, 28], [24, 7, 30], [24, 8, 2], [24, 8, 3], [24, 8, 6], [24, 8, 14], [24, 8, 16], [24, 8, 18], [24, 8, 26], [24, 8, 29], [24, 8, 30], [24, 9, 0], [24, 9, 1], [24, 9, 8], [24, 9, 13], [24, 9, 15], [24, 9, 17], [24, 9, 19], [24, 9, 24], [24, 10, 0], [24, 10, 1], [24, 10, 4], [24, 10, 7], [24, 10, 14], [24, 10, 16], [24, 10, 18], [24, 10, 25], [24, 10, 28], [24, 11, 3], [24, 11, 6], [24, 11, 11], [24, 11, 15], [24, 11, 17], [24, 11, 21], [24, 11, 26], [24, 11, 29], [24, 12, 2], [24, 12, 10], [24, 12, 11], [24, 12, 12], [24, 12, 16], [24, 12, 20], [24, 12, 21], [24, 12, 22], [24, 12, 30], [24, 13, 4], [24, 13, 10], [24, 13, 11], [24, 13, 13], [24, 13, 19], [24, 13, 21], [24, 13, 22], [24, 13, 28], [24, 14, 8], [24, 14, 9], [24, 14, 12], [24, 14, 14], [24, 14, 18], [24, 14, 20], [24, 14, 23], [24, 14, 24], [24, 15, 2], [24, 15, 7], [24, 15, 9], [24, 15, 13], [24, 15, 19], [24, 15, 23], [24, 15, 25], [24, 15, 30], [24, 16, 6], [24, 16, 7], [24, 16, 8], [24, 16, 10], [24, 16, 16], [24, 16, 22], [24, 16, 24], [24, 16, 25], [24, 16, 26], [24, 17, 7], [24, 17, 9], [24, 17, 11], [24, 17, 15], [24, 17, 16], [24, 17, 17], [24, 17, 21], [24, 17, 23], [24, 17, 25], [24, 18, 5], [24, 18, 8], [24, 18, 10], [24, 18, 15], [24, 18, 16], [24, 18, 17], [24, 18, 22], [24, 18, 24], [24, 18, 27], [24, 19, 3], [24, 19, 9], [24, 19, 13], [24, 19, 14], [24, 19, 16], [24, 19, 18], [24, 19, 19], [24, 19, 23], [24, 19, 29], [24, 20, 4], [24, 20, 12], [24, 20, 14], [24, 20, 15], [24, 20, 17], [24, 20, 18], [24, 20, 20], [24, 20, 28], [24, 21, 5], [24, 21, 11], [24, 21, 12], [24, 21, 13], [24, 21, 16], [24, 21, 19], [24, 21, 20], [24, 21, 21], [24, 21, 27], [24, 22, 0], [24, 22, 1], [24, 22, 6], [24, 22, 12], [24, 22, 13], [24, 22, 16], [24, 22, 19], [24, 22, 20], [24, 22, 26], [24, 23, 0], [24, 23, 1], [24, 23, 10], [24, 23, 14], [24, 23, 15], [24, 23, 17], [24, 23, 18], [24, 23, 22], [24, 24, 2], [24, 24, 8], [24, 24, 11], [24, 24, 14], [24, 24, 16], [24, 24, 18], [24, 24, 21], [24, 24, 24], [24, 24, 30], [24, 25, 3], [24, 25, 9], [24, 25, 12], [24, 25, 15], [24, 25, 16], [24, 25, 17], [24, 25, 20], [24, 25, 23], [24, 25, 29], [24, 26, 16], [24, 27, 5], [24, 27, 6], [24, 27, 11], [24, 27, 14], [24, 27, 18], [24, 27, 21], [24, 27, 26], [24, 27, 27], [24, 28, 5], [24, 28, 6], [24, 28, 7], [24, 28, 12], [24, 28, 20], [24, 28, 25], [24, 28, 26], [24, 28, 27], [24, 29, 4], [24, 29, 6], [24, 29, 8], [24, 29, 13], [24, 29, 16], [24, 29, 19], [24, 29, 24], [24, 29, 26], [24, 29, 28], [24, 30, 3], [24, 30, 5], [24, 30, 7], [24, 30, 8], [24, 30, 24], [24, 30, 25], [24, 30, 27], [24, 30, 29], [25, 0, 3], [25, 0, 6], [25, 0, 11], [25, 0, 12], [25, 0, 21], [25, 0, 22], [25, 0, 27], [25, 0, 30], [25, 1, 5], [25, 1, 10], [25, 1, 11], [25, 1, 12], [25, 1, 21], [25, 1, 22], [25, 1, 23], [25, 1, 28], [25, 2, 1], [25, 2, 4], [25, 2, 9], [25, 2, 11], [25, 2, 13], [25, 2, 20], [25, 2, 22], [25, 2, 24], [25, 2, 29], [25, 3, 9], [25, 3, 10], [25, 3, 12], [25, 3, 14], [25, 3, 19], [25, 3, 21], [25, 3, 23], [25, 3, 24], [25, 4, 7], [25, 4, 8], [25, 4, 11], [25, 4, 13], [25, 4, 20], [25, 4, 22], [25, 4, 25], [25, 4, 26], [25, 5, 1], [25, 5, 7], [25, 5, 8], [25, 5, 12], [25, 5, 16], [25, 5, 17], [25, 5, 21], [25, 5, 25], [25, 5, 26], [25, 6, 5], [25, 6, 9], [25, 6, 15], [25, 6, 16], [25, 6, 17], [25, 6, 18], [25, 6, 24], [25, 6, 28], [25, 7, 6], [25, 7, 10], [25, 7, 14], [25, 7, 16], [25, 7, 17], [25, 7, 19], [25, 7, 23], [25, 7, 27], [25, 8, 4], [25, 8, 7], [25, 8, 14], [25, 8, 15], [25, 8, 18], [25, 8, 19], [25, 8, 26], [25, 8, 29], [25, 9, 8], [25, 9, 12], [25, 9, 13], [25, 9, 15], [25, 9, 18], [25, 9, 20], [25, 9, 21], [25, 9, 25], [25, 10, 1], [25, 10, 12], [25, 10, 13], [25, 10, 14], [25, 10, 16], [25, 10, 17], [25, 10, 19], [25, 10, 20], [25, 10, 21], [25, 11, 0], [25, 11, 1], [25, 11, 2], [25, 11, 10], [25, 11, 13], [25, 11, 15], [25, 11, 18], [25, 11, 20], [25, 11, 23], [25, 12, 1], [25, 12, 3], [25, 12, 11], [25, 12, 14], [25, 12, 15], [25, 12, 18], [25, 12, 19], [25, 12, 22], [25, 12, 30], [25, 13, 0], [25, 13, 2], [25, 13, 4], [25, 13, 9], [25, 13, 16], [25, 13, 17], [25, 13, 24], [25, 13, 29], [25, 14, 1], [25, 14, 3], [25, 14, 10], [25, 14, 13], [25, 14, 16], [25, 14, 17], [25, 14, 20], [25, 14, 23], [25, 14, 30], [25, 15, 0], [25, 15, 2], [25, 15, 6], [25, 15, 11], [25, 15, 14], [25, 15, 19], [25, 15, 22], [25, 15, 27], [25, 16, 1], [25, 16, 5], [25, 16, 6], [25, 16, 7], [25, 16, 15], [25, 16, 18], [25, 16, 26], [25, 16, 27], [25, 16, 28], [25, 17, 4], [25, 17, 6], [25, 17, 7], [25, 17, 13], [25, 17, 20], [25, 17, 26], [25, 17, 27], [25, 17, 29], [25, 18, 3], [25, 18, 5], [25, 18, 8], [25, 18, 9], [25, 18, 24], [25, 18, 25], [25, 18, 28], [25, 18, 30], [25, 19, 4], [25, 19, 8], [25, 19, 10], [25, 19, 15], [25, 19, 18], [25, 19, 23], [25, 19, 25], [25, 19, 29], [25, 20, 1], [25, 20, 7], [25, 20, 9], [25, 20, 10], [25, 20, 11], [25, 20, 22], [25, 20, 23], [25, 20, 24], [25, 20, 26], [25, 21, 0], [25, 21, 1], [25, 21, 2], [25, 21, 6], [25, 21, 8], [25, 21, 10], [25, 21, 23], [25, 21, 25], [25, 21, 27], [25, 22, 0], [25, 22, 1], [25, 22, 2], [25, 22, 7], [25, 22, 9], [25, 22, 12], [25, 22, 21], [25, 22, 24], [25, 22, 26], [25, 23, 1], [25, 23, 3], [25, 23, 4], [25, 23, 8], [25, 23, 14], [25, 23, 19], [25, 23, 25], [25, 23, 29], [25, 23, 30], [25, 24, 0], [25, 24, 2], [25, 24, 3], [25, 24, 5], [25, 24, 13], [25, 24, 20], [25, 24, 28], [25, 24, 30], [25, 25, 1], [25, 25, 4], [25, 25, 5], [25, 25, 6], [25, 25, 12], [25, 25, 21], [25, 25, 27], [25, 25, 28], [25, 25, 29], [25, 26, 1], [25, 26, 4], [25, 26, 5], [25, 26, 11], [25, 26, 16], [25, 26, 17], [25, 26, 22], [25, 26, 28], [25, 26, 29], [25, 27, 0], [25, 27, 2], [25, 27, 3], [25, 27, 7], [25, 27, 16], [25, 27, 17], [25, 27, 26], [25, 27, 30], [25, 28, 1], [25, 28, 3], [25, 28, 6], [25, 28, 9], [25, 28, 15], [25, 28, 18], [25, 28, 24], [25, 28, 27], [25, 28, 30], [25, 29, 0], [25, 29, 1], [25, 29, 2], [25, 29, 5], [25, 29, 8], [25, 29, 14], [25, 29, 19], [25, 29, 25], [25, 29, 28], [25, 30, 1], [26, 0, 6], [26, 0, 12], [26, 0, 13], [26, 0, 14], [26, 0, 17], [26, 0, 20], [26, 0, 21], [26, 0, 22], [26, 0, 28], [26, 1, 1], [26, 1, 2], [26, 1, 7], [26, 1, 13], [26, 1, 14], [26, 1, 17], [26, 1, 20], [26, 1, 21], [26, 1, 27], [26, 2, 1], [26, 2, 2], [26, 2, 11], [26, 2, 15], [26, 2, 16], [26, 2, 18], [26, 2, 19], [26, 2, 23], [26, 3, 0], [26, 3, 3], [26, 3, 9], [26, 3, 12], [26, 3, 15], [26, 3, 17], [26, 3, 19], [26, 3, 22], [26, 3, 25], [26, 4, 4], [26, 4, 10], [26, 4, 13], [26, 4, 16], [26, 4, 17], [26, 4, 18], [26, 4, 21], [26, 4, 24], [26, 4, 30], [26, 5, 17], [26, 6, 6], [26, 6, 7], [26, 6, 12], [26, 6, 15], [26, 6, 19], [26, 6, 22], [26, 6, 27], [26, 6, 28], [26, 7, 6], [26, 7, 7], [26, 7, 8], [26, 7, 13], [26, 7, 21], [26, 7, 26], [26, 7, 27], [26, 7, 28], [26, 8, 5], [26, 8, 7], [26, 8, 9], [26, 8, 14], [26, 8, 17], [26, 8, 20], [26, 8, 25], [26, 8, 27], [26, 8, 29], [26, 9, 4], [26, 9, 6], [26, 9, 8], [26, 9, 9], [26, 9, 25], [26, 9, 26], [26, 9, 28], [26, 9, 30], [26, 10, 5], [26, 10, 7], [26, 10, 10], [26, 10, 11], [26, 10, 23], [26, 10, 24], [26, 10, 27], [26, 10, 29], [26, 11, 1], [26, 11, 2], [26, 11, 6], [26, 11, 10], [26, 11, 11], [26, 11, 17], [26, 11, 23], [26, 11, 24], [26, 11, 28], [26, 12, 0], [26, 12, 1], [26, 12, 2], [26, 12, 3], [26, 12, 9], [26, 12, 13], [26, 12, 21], [26, 12, 25], [26, 13, 1], [26, 13, 2], [26, 13, 4], [26, 13, 8], [26, 13, 12], [26, 13, 22], [26, 13, 26], [26, 13, 30], [26, 14, 0], [26, 14, 3], [26, 14, 4], [26, 14, 11], [26, 14, 14], [26, 14, 20], [26, 14, 23], [26, 14, 30], [26, 15, 0], [26, 15, 3], [26, 15, 5], [26, 15, 6], [26, 15, 10], [26, 15, 24], [26, 15, 28], [26, 15, 29], [26, 16, 1], [26, 16, 2], [26, 16, 4], [26, 16, 5], [26, 16, 6], [26, 16, 17], [26, 16, 28], [26, 16, 29], [26, 16, 30], [26, 17, 0], [26, 17, 3], [26, 17, 5], [26, 17, 8], [26, 17, 16], [26, 17, 17], [26, 17, 18], [26, 17, 26], [26, 17, 29], [26, 18, 0], [26, 18, 3], [26, 18, 4], [26, 18, 7], [26, 18, 15], [26, 18, 17], [26, 18, 19], [26, 18, 27], [26, 18, 30], [26, 19, 1], [26, 19, 2], [26, 19, 9], [26, 19, 14], [26, 19, 16], [26, 19, 18], [26, 19, 20], [26, 19, 25], [26, 20, 1], [26, 20, 2], [26, 20, 5], [26, 20, 8], [26, 20, 15], [26, 20, 17], [26, 20, 19], [26, 20, 26], [26, 20, 29], [26, 21, 4], [26, 21, 7], [26, 21, 12], [26, 21, 16], [26, 21, 18], [26, 21, 22], [26, 21, 27], [26, 21, 30], [26, 22, 0], [26, 22, 3], [26, 22, 11], [26, 22, 12], [26, 22, 13], [26, 22, 17], [26, 22, 21], [26, 22, 22], [26, 22, 23], [26, 23, 5], [26, 23, 11], [26, 23, 12], [26, 23, 14], [26, 23, 20], [26, 23, 22], [26, 23, 23], [26, 23, 29], [26, 24, 9], [26, 24, 10], [26, 24, 13], [26, 24, 15], [26, 24, 19], [26, 24, 21], [26, 24, 24], [26, 24, 25], [26, 25, 0], [26, 25, 3], [26, 25, 8], [26, 25, 10], [26, 25, 14], [26, 25, 20], [26, 25, 24], [26, 25, 26], [26, 26, 7], [26, 26, 8], [26, 26, 9], [26, 26, 11], [26, 26, 17], [26, 26, 23], [26, 26, 25], [26, 26, 26], [26, 26, 27], [26, 27, 8], [26, 27, 10], [26, 27, 12], [26, 27, 16], [26, 27, 17], [26, 27, 18], [26, 27, 22], [26, 27, 24], [26, 27, 26], [26, 28, 6], [26, 28, 9], [26, 28, 11], [26, 28, 16], [26, 28, 17], [26, 28, 18], [26, 28, 23], [26, 28, 25], [26, 28, 28], [26, 29, 4], [26, 29, 10], [26, 29, 14], [26, 29, 15], [26, 29, 17], [26, 29, 19], [26, 29, 20], [26, 29, 24], [26, 29, 30], [26, 30, 5], [26, 30, 13], [26, 30, 15], [26, 30, 16], [26, 30, 18], [26, 30, 19], [26, 30, 21], [26, 30, 29], [27, 0, 5], [27, 0, 7], [27, 0, 8], [27, 0, 14], [27, 0, 21], [27, 0, 27], [27, 0, 28], [27, 0, 30], [27, 1, 0], [27, 1, 4], [27, 1, 6], [27, 1, 9], [27, 1, 10], [27, 1, 25], [27, 1, 26], [27, 1, 29], [27, 2, 5], [27, 2, 9], [27, 2, 11], [27, 2, 16], [27, 2, 19], [27, 2, 24], [27, 2, 26], [27, 2, 30], [27, 3, 2], [27, 3, 8], [27, 3, 10], [27, 3, 11], [27, 3, 12], [27, 3, 23], [27, 3, 24], [27, 3, 25], [27, 3, 27], [27, 4, 1], [27, 4, 2], [27, 4, 3], [27, 4, 7], [27, 4, 9], [27, 4, 11], [27, 4, 24], [27, 4, 26], [27, 4, 28], [27, 5, 1], [27, 5, 2], [27, 5, 3], [27, 5, 8], [27, 5, 10], [27, 5, 13], [27, 5, 22], [27, 5, 25], [27, 5, 27], [27, 6, 0], [27, 6, 2], [27, 6, 4], [27, 6, 5], [27, 6, 9], [27, 6, 15], [27, 6, 20], [27, 6, 26], [27, 6, 30], [27, 7, 0], [27, 7, 1], [27, 7, 3], [27, 7, 4], [27, 7, 6], [27, 7, 14], [27, 7, 21], [27, 7, 29], [27, 8, 2], [27, 8, 5], [27, 8, 6], [27, 8, 7], [27, 8, 13], [27, 8, 22], [27, 8, 28], [27, 8, 29], [27, 8, 30], [27, 9, 2], [27, 9, 5], [27, 9, 6], [27, 9, 12], [27, 9, 17], [27, 9, 18], [27, 9, 23], [27, 9, 29], [27, 9, 30], [27, 10, 0], [27, 10, 1], [27, 10, 3], [27, 10, 4], [27, 10, 8], [27, 10, 17], [27, 10, 18], [27, 10, 27], [27, 11, 0], [27, 11, 2], [27, 11, 4], [27, 11, 7], [27, 11, 10], [27, 11, 16], [27, 11, 19], [27, 11, 25], [27, 11, 28], [27, 12, 1], [27, 12, 2], [27, 12, 3], [27, 12, 6], [27, 12, 9], [27, 12, 15], [27, 12, 20], [27, 12, 26], [27, 12, 29], [27, 13, 2], [27, 14, 0], [27, 14, 4], [27, 14, 7], [27, 14, 12], [27, 14, 13], [27, 14, 22], [27, 14, 23], [27, 14, 28], [27, 15, 6], [27, 15, 11], [27, 15, 12], [27, 15, 13], [27, 15, 22], [27, 15, 23], [27, 15, 24], [27, 15, 29], [27, 16, 2], [27, 16, 5], [27, 16, 10], [27, 16, 12], [27, 16, 14], [27, 16, 21], [27, 16, 23], [27, 16, 25], [27, 16, 30], [27, 17, 10], [27, 17, 11], [27, 17, 13], [27, 17, 15], [27, 17, 20], [27, 17, 22], [27, 17, 24], [27, 17, 25], [27, 18, 8], [27, 18, 9], [27, 18, 12], [27, 18, 14], [27, 18, 21], [27, 18, 23], [27, 18, 26], [27, 18, 27], [27, 19, 2], [27, 19, 8], [27, 19, 9], [27, 19, 13], [27, 19, 17], [27, 19, 18], [27, 19, 22], [27, 19, 26], [27, 19, 27], [27, 20, 6], [27, 20, 10], [27, 20, 16], [27, 20, 17], [27, 20, 18], [27, 20, 19], [27, 20, 25], [27, 20, 29], [27, 21, 7], [27, 21, 11], [27, 21, 15], [27, 21, 17], [27, 21, 18], [27, 21, 20], [27, 21, 24], [27, 21, 28], [27, 22, 5], [27, 22, 8], [27, 22, 15], [27, 22, 16], [27, 22, 19], [27, 22, 20], [27, 22, 27], [27, 22, 30], [27, 23, 9], [27, 23, 13], [27, 23, 14], [27, 23, 16], [27, 23, 19], [27, 23, 21], [27, 23, 22], [27, 23, 26], [27, 24, 2], [27, 24, 13], [27, 24, 14], [27, 24, 15], [27, 24, 17], [27, 24, 18], [27, 24, 20], [27, 24, 21], [27, 24, 22], [27, 25, 1], [27, 25, 2], [27, 25, 3], [27, 25, 11], [27, 25, 14], [27, 25, 16], [27, 25, 19], [27, 25, 21], [27, 25, 24], [27, 26, 0], [27, 26, 2], [27, 26, 4], [27, 26, 12], [27, 26, 15], [27, 26, 16], [27, 26, 19], [27, 26, 20], [27, 26, 23], [27, 27, 1], [27, 27, 3], [27, 27, 5], [27, 27, 10], [27, 27, 17], [27, 27, 18], [27, 27, 25], [27, 27, 30], [27, 28, 0], [27, 28, 2], [27, 28, 4], [27, 28, 11], [27, 28, 14], [27, 28, 17], [27, 28, 18], [27, 28, 21], [27, 28, 24], [27, 29, 1], [27, 29, 3], [27, 29, 7], [27, 29, 12], [27, 29, 15], [27, 29, 20], [27, 29, 23], [27, 29, 28], [27, 30, 2], [27, 30, 6], [27, 30, 7], [27, 30, 8], [27, 30, 16], [27, 30, 19], [27, 30, 27], [27, 30, 28], [27, 30, 29], [28, 0, 0], [28, 0, 2], [28, 0, 3], [28, 0, 5], [28, 0, 9], [28, 0, 13], [28, 0, 23], [28, 0, 27], [28, 1, 0], [28, 1, 1], [28, 1, 4], [28, 1, 5], [28, 1, 12], [28, 1, 15], [28, 1, 21], [28, 1, 24], [28, 2, 1], [28, 2, 4], [28, 2, 6], [28, 2, 7], [28, 2, 11], [28, 2, 25], [28, 2, 29], [28, 2, 30], [28, 3, 0], [28, 3, 2], [28, 3, 3], [28, 3, 5], [28, 3, 6], [28, 3, 7], [28, 3, 18], [28, 3, 29], [28, 3, 30], [28, 4, 1], [28, 4, 4], [28, 4, 6], [28, 4, 9], [28, 4, 17], [28, 4, 18], [28, 4, 19], [28, 4, 27], [28, 4, 30], [28, 5, 0], [28, 5, 1], [28, 5, 4], [28, 5, 5], [28, 5, 8], [28, 5, 16], [28, 5, 18], [28, 5, 20], [28, 5, 28], [28, 6, 2], [28, 6, 3], [28, 6, 10], [28, 6, 15], [28, 6, 17], [28, 6, 19], [28, 6, 21], [28, 6, 26], [28, 7, 2], [28, 7, 3], [28, 7, 6], [28, 7, 9], [28, 7, 16], [28, 7, 18], [28, 7, 20], [28, 7, 27], [28, 7, 30], [28, 8, 0], [28, 8, 5], [28, 8, 8], [28, 8, 13], [28, 8, 17], [28, 8, 19], [28, 8, 23], [28, 8, 28], [28, 9, 1], [28, 9, 4], [28, 9, 12], [28, 9, 13], [28, 9, 14], [28, 9, 18], [28, 9, 22], [28, 9, 23], [28, 9, 24], [28, 10, 6], [28, 10, 12], [28, 10, 13], [28, 10, 15], [28, 10, 21], [28, 10, 23], [28, 10, 24], [28, 10, 30], [28, 11, 10], [28, 11, 11], [28, 11, 14], [28, 11, 16], [28, 11, 20], [28, 11, 22], [28, 11, 25], [28, 11, 26], [28, 12, 1], [28, 12, 4], [28, 12, 9], [28, 12, 11], [28, 12, 15], [28, 12, 21], [28, 12, 25], [28, 12, 27], [28, 13, 8], [28, 13, 9], [28, 13, 10], [28, 13, 12], [28, 13, 18], [28, 13, 24], [28, 13, 26], [28, 13, 27], [28, 13, 28], [28, 14, 9], [28, 14, 11], [28, 14, 13], [28, 14, 17], [28, 14, 18], [28, 14, 19], [28, 14, 23], [28, 14, 25], [28, 14, 27], [28, 15, 7], [28, 15, 10], [28, 15, 12], [28, 15, 17], [28, 15, 18], [28, 15, 19], [28, 15, 24], [28, 15, 26], [28, 15, 29], [28, 16, 0], [28, 16, 5], [28, 16, 11], [28, 16, 15], [28, 16, 16], [28, 16, 18], [28, 16, 20], [28, 16, 21], [28, 16, 25], [28, 17, 6], [28, 17, 14], [28, 17, 16], [28, 17, 17], [28, 17, 19], [28, 17, 20], [28, 17, 22], [28, 17, 30], [28, 18, 7], [28, 18, 13], [28, 18, 14], [28, 18, 15], [28, 18, 18], [28, 18, 21], [28, 18, 22], [28, 18, 23], [28, 18, 29], [28, 19, 2], [28, 19, 3], [28, 19, 8], [28, 19, 14], [28, 19, 15], [28, 19, 18], [28, 19, 21], [28, 19, 22], [28, 19, 28], [28, 20, 2], [28, 20, 3], [28, 20, 12], [28, 20, 16], [28, 20, 17], [28, 20, 19], [28, 20, 20], [28, 20, 24], [28, 21, 1], [28, 21, 4], [28, 21, 10], [28, 21, 13], [28, 21, 16], [28, 21, 18], [28, 21, 20], [28, 21, 23], [28, 21, 26], [28, 22, 0], [28, 22, 5], [28, 22, 11], [28, 22, 14], [28, 22, 17], [28, 22, 18], [28, 22, 19], [28, 22, 22], [28, 22, 25], [28, 23, 18], [28, 24, 7], [28, 24, 8], [28, 24, 13], [28, 24, 16], [28, 24, 20], [28, 24, 23], [28, 24, 28], [28, 24, 29], [28, 25, 7], [28, 25, 8], [28, 25, 9], [28, 25, 14], [28, 25, 22], [28, 25, 27], [28, 25, 28], [28, 25, 29], [28, 26, 6], [28, 26, 8], [28, 26, 10], [28, 26, 15], [28, 26, 18], [28, 26, 21], [28, 26, 26], [28, 26, 28], [28, 26, 30], [28, 27, 0], [28, 27, 5], [28, 27, 7], [28, 27, 9], [28, 27, 10], [28, 27, 26], [28, 27, 27], [28, 27, 29], [28, 28, 6], [28, 28, 8], [28, 28, 11], [28, 28, 12], [28, 28, 24], [28, 28, 25], [28, 28, 28], [28, 28, 30], [28, 29, 2], [28, 29, 3], [28, 29, 7], [28, 29, 11], [28, 29, 12], [28, 29, 18], [28, 29, 24], [28, 29, 25], [28, 29, 29], [28, 30, 1], [28, 30, 2], [28, 30, 3], [28, 30, 4], [28, 30, 10], [28, 30, 14], [28, 30, 22], [28, 30, 26], [29, 0, 0], [29, 0, 3], [29, 0, 6], [29, 0, 7], [29, 0, 13], [29, 0, 18], [29, 0, 19], [29, 0, 24], [29, 0, 30], [29, 1, 1], [29, 1, 2], [29, 1, 4], [29, 1, 5], [29, 1, 9], [29, 1, 18], [29, 1, 19], [29, 1, 28], [29, 2, 1], [29, 2, 3], [29, 2, 5], [29, 2, 8], [29, 2, 11], [29, 2, 17], [29, 2, 20], [29, 2, 26], [29, 2, 29], [29, 3, 2], [29, 3, 3], [29, 3, 4], [29, 3, 7], [29, 3, 10], [29, 3, 16], [29, 3, 21], [29, 3, 27], [29, 3, 30], [29, 4, 3], [29, 5, 1], [29, 5, 5], [29, 5, 8], [29, 5, 13], [29, 5, 14], [29, 5, 23], [29, 5, 24], [29, 5, 29], [29, 6, 7], [29, 6, 12], [29, 6, 13], [29, 6, 14], [29, 6, 23], [29, 6, 24], [29, 6, 25], [29, 6, 30], [29, 7, 0], [29, 7, 3], [29, 7, 6], [29, 7, 11], [29, 7, 13], [29, 7, 15], [29, 7, 22], [29, 7, 24], [29, 7, 26], [29, 8, 11], [29, 8, 12], [29, 8, 14], [29, 8, 16], [29, 8, 21], [29, 8, 23], [29, 8, 25], [29, 8, 26], [29, 9, 9], [29, 9, 10], [29, 9, 13], [29, 9, 15], [29, 9, 22], [29, 9, 24], [29, 9, 27], [29, 9, 28], [29, 10, 3], [29, 10, 9], [29, 10, 10], [29, 10, 14], [29, 10, 18], [29, 10, 19], [29, 10, 23], [29, 10, 27], [29, 10, 28], [29, 11, 7], [29, 11, 11], [29, 11, 17], [29, 11, 18], [29, 11, 19], [29, 11, 20], [29, 11, 26], [29, 11, 30], [29, 12, 8], [29, 12, 12], [29, 12, 16], [29, 12, 18], [29, 12, 19], [29, 12, 21], [29, 12, 25], [29, 12, 29], [29, 13, 0], [29, 13, 6], [29, 13, 9], [29, 13, 16], [29, 13, 17], [29, 13, 20], [29, 13, 21], [29, 13, 28], [29, 14, 10], [29, 14, 14], [29, 14, 15], [29, 14, 17], [29, 14, 20], [29, 14, 22], [29, 14, 23], [29, 14, 27], [29, 15, 3], [29, 15, 14], [29, 15, 15], [29, 15, 16], [29, 15, 18], [29, 15, 19], [29, 15, 21], [29, 15, 22], [29, 15, 23], [29, 16, 2], [29, 16, 3], [29, 16, 4], [29, 16, 12], [29, 16, 15], [29, 16, 17], [29, 16, 20], [29, 16, 22], [29, 16, 25], [29, 17, 1], [29, 17, 3], [29, 17, 5], [29, 17, 13], [29, 17, 16], [29, 17, 17], [29, 17, 20], [29, 17, 21], [29, 17, 24], [29, 18, 0], [29, 18, 2], [29, 18, 4], [29, 18, 6], [29, 18, 11], [29, 18, 18], [29, 18, 19], [29, 18, 26], [29, 19, 1], [29, 19, 3], [29, 19, 5], [29, 19, 12], [29, 19, 15], [29, 19, 18], [29, 19, 19], [29, 19, 22], [29, 19, 25], [29, 20, 2], [29, 20, 4], [29, 20, 8], [29, 20, 13], [29, 20, 16], [29, 20, 21], [29, 20, 24], [29, 20, 29], [29, 21, 3], [29, 21, 7], [29, 21, 8], [29, 21, 9], [29, 21, 17], [29, 21, 20], [29, 21, 28], [29, 21, 29], [29, 21, 30], [29, 22, 0], [29, 22, 6], [29, 22, 8], [29, 22, 9], [29, 22, 15], [29, 22, 22], [29, 22, 28], [29, 22, 29], [29, 23, 1], [29, 23, 5], [29, 23, 7], [29, 23, 10], [29, 23, 11], [29, 23, 26], [29, 23, 27], [29, 23, 30], [29, 24, 0], [29, 24, 6], [29, 24, 10], [29, 24, 12], [29, 24, 17], [29, 24, 20], [29, 24, 25], [29, 24, 27], [29, 25, 3], [29, 25, 9], [29, 25, 11], [29, 25, 12], [29, 25, 13], [29, 25, 24], [29, 25, 25], [29, 25, 26], [29, 25, 28], [29, 26, 2], [29, 26, 3], [29, 26, 4], [29, 26, 8], [29, 26, 10], [29, 26, 12], [29, 26, 25], [29, 26, 27], [29, 26, 29], [29, 27, 2], [29, 27, 3], [29, 27, 4], [29, 27, 9], [29, 27, 11], [29, 27, 14], [29, 27, 23], [29, 27, 26], [29, 27, 28], [29, 28, 0], [29, 28, 1], [29, 28, 3], [29, 28, 5], [29, 28, 6], [29, 28, 10], [29, 28, 16], [29, 28, 21], [29, 28, 27], [29, 29, 1], [29, 29, 2], [29, 29, 4], [29, 29, 5], [29, 29, 7], [29, 29, 15], [29, 29, 22], [29, 29, 30], [29, 30, 0], [29, 30, 3], [29, 30, 6], [29, 30, 7], [29, 30, 8], [29, 30, 14], [29, 30, 23], [29, 30, 29], [29, 30, 30], [30, 0, 1], [30, 0, 2], [30, 0, 5], [30, 0, 6], [30, 0, 9], [30, 0, 17], [30, 0, 19], [30, 0, 21], [30, 0, 29], [30, 1, 3], [30, 1, 4], [30, 1, 11], [30, 1, 16], [30, 1, 18], [30, 1, 20], [30, 1, 22], [30, 1, 27], [30, 2, 0], [30, 2, 3], [30, 2, 4], [30, 2, 7], [30, 2, 10], [30, 2, 17], [30, 2, 19], [30, 2, 21], [30, 2, 28], [30, 3, 1], [30, 3, 6], [30, 3, 9], [30, 3, 14], [30, 3, 18], [30, 3, 20], [30, 3, 24], [30, 3, 29], [30, 4, 2], [30, 4, 5], [30, 4, 13], [30, 4, 14], [30, 4, 15], [30, 4, 19], [30, 4, 23], [30, 4, 24], [30, 4, 25], [30, 5, 0], [30, 5, 7], [30, 5, 13], [30, 5, 14], [30, 5, 16], [30, 5, 22], [30, 5, 24], [30, 5, 25], [30, 6, 11], [30, 6, 12], [30, 6, 15], [30, 6, 17], [30, 6, 21], [30, 6, 23], [30, 6, 26], [30, 6, 27], [30, 7, 2], [30, 7, 5], [30, 7, 10], [30, 7, 12], [30, 7, 16], [30, 7, 22], [30, 7, 26], [30, 7, 28], [30, 8, 9], [30, 8, 10], [30, 8, 11], [30, 8, 13], [30, 8, 19], [30, 8, 25], [30, 8, 27], [30, 8, 28], [30, 8, 29], [30, 9, 10], [30, 9, 12], [30, 9, 14], [30, 9, 18], [30, 9, 19], [30, 9, 20], [30, 9, 24], [30, 9, 26], [30, 9, 28], [30, 10, 8], [30, 10, 11], [30, 10, 13], [30, 10, 18], [30, 10, 19], [30, 10, 20], [30, 10, 25], [30, 10, 27], [30, 10, 30], [30, 11, 1], [30, 11, 6], [30, 11, 12], [30, 11, 16], [30, 11, 17], [30, 11, 19], [30, 11, 21], [30, 11, 22], [30, 11, 26], [30, 12, 0], [30, 12, 7], [30, 12, 15], [30, 12, 17], [30, 12, 18], [30, 12, 20], [30, 12, 21], [30, 12, 23], [30, 13, 8], [30, 13, 14], [30, 13, 15], [30, 13, 16], [30, 13, 19], [30, 13, 22], [30, 13, 23], [30, 13, 24], [30, 13, 30], [30, 14, 3], [30, 14, 4], [30, 14, 9], [30, 14, 15], [30, 14, 16], [30, 14, 19], [30, 14, 22], [30, 14, 23], [30, 14, 29], [30, 15, 3], [30, 15, 4], [30, 15, 13], [30, 15, 17], [30, 15, 18], [30, 15, 20], [30, 15, 21], [30, 15, 25], [30, 16, 2], [30, 16, 5], [30, 16, 11], [30, 16, 14], [30, 16, 17], [30, 16, 19], [30, 16, 21], [30, 16, 24], [30, 16, 27], [30, 17, 1], [30, 17, 6], [30, 17, 12], [30, 17, 15], [30, 17, 18], [30, 17, 19], [30, 17, 20], [30, 17, 23], [30, 17, 26], [30, 18, 19], [30, 19, 8], [30, 19, 9], [30, 19, 14], [30, 19, 17], [30, 19, 21], [30, 19, 24], [30, 19, 29], [30, 19, 30], [30, 20, 8], [30, 20, 9], [30, 20, 10], [30, 20, 15], [30, 20, 23], [30, 20, 28], [30, 20, 29], [30, 20, 30], [30, 21, 0], [30, 21, 7], [30, 21, 9], [30, 21, 11], [30, 21, 16], [30, 21, 19], [30, 21, 22], [30, 21, 27], [30, 21, 29], [30, 22, 1], [30, 22, 6], [30, 22, 8], [30, 22, 10], [30, 22, 11], [30, 22, 27], [30, 22, 28], [30, 22, 30], [30, 23, 0], [30, 23, 7], [30, 23, 9], [30, 23, 12], [30, 23, 13], [30, 23, 25], [30, 23, 26], [30, 23, 29], [30, 24, 3], [30, 24, 4], [30, 24, 8], [30, 24, 12], [30, 24, 13], [30, 24, 19], [30, 24, 25], [30, 24, 26], [30, 24, 30], [30, 25, 2], [30, 25, 3], [30, 25, 4], [30, 25, 5], [30, 25, 11], [30, 25, 15], [30, 25, 23], [30, 25, 27], [30, 26, 1], [30, 26, 3], [30, 26, 4], [30, 26, 6], [30, 26, 10], [30, 26, 14], [30, 26, 24], [30, 26, 28], [30, 27, 1], [30, 27, 2], [30, 27, 5], [30, 27, 6], [30, 27, 13], [30, 27, 16], [30, 27, 22], [30, 27, 25], [30, 28, 0], [30, 28, 2], [30, 28, 5], [30, 28, 7], [30, 28, 8], [30, 28, 12], [30, 28, 26], [30, 28, 30], [30, 29, 0], [30, 29, 1], [30, 29, 3], [30, 29, 4], [30, 29, 6], [30, 29, 7], [30, 29, 8], [30, 29, 19], [30, 29, 30], [30, 30, 0], [30, 30, 2], [30, 30, 5], [30, 30, 7], [30, 30, 10], [30, 30, 18], [30, 30, 19], [30, 30, 20], [30, 30, 28]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p31/tests/check.py b/tasks/optimize-ae-p1-ff-kakeya-d3-p31/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..dac5049b59a505ff843bc5e086d0c1c303695b2a --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p31/tests/check.py @@ -0,0 +1,32 @@ +"""Finite-field Kakeya set in F_p^d: every direction contains a full line. Score = |K| (minimize). + +Upstream (AlphaEvolve notebook `finite_field_kakeya.ipynb`) silently deduplicated points and only checked +d in {3, 4}; here duplicates, out-of-range or non-integer coordinates are rejected and every projective +direction (first non-zero coordinate = 1) is checked for any d. +""" +import itertools + +import numpy as np + +from run import Invalid, int_list + + +def check(inst, ans): + p, d = inst["p"], inst["d"] + pts = ans.get("points") + if not isinstance(pts, list) or not pts: + raise Invalid("points must be a non-empty list") + if len(pts) > p ** d: + raise Invalid("more points than the whole space") + K = np.array([int_list(x, d, 0, p - 1, "point") for x in pts], dtype=np.int64) + w = p ** np.arange(d - 1, -1, -1, dtype=np.int64) + codes = K @ w + if len(np.unique(codes)) != len(codes): + raise Invalid("duplicate points") + for i in range(d): # directions v = (0,..,0,1,*,..,*) with the 1 in position i + for tail in itertools.product(range(p), repeat=d - 1 - i): + v = np.array([0] * i + [1] + list(tail), dtype=np.int64) + base = (K - K[:, i:i + 1] * v) % p # canonical point of the line through x with direction v + if np.bincount(base @ w, minlength=p ** d).max() < p: + raise Invalid(f"no full line in direction {v.tolist()}") + return len(pts), {"size": len(pts)} diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p31/tests/instance.json b/tasks/optimize-ae-p1-ff-kakeya-d3-p31/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..444ebf62b820509d99cc5b4746d58ee6009ed19c --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p31/tests/instance.json @@ -0,0 +1 @@ +{"p": 31, "d": 3, "direction": "minimize", "best_known": 8290, "baseline": 29791, "family": "ae_p1_ff_kakeya", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p31/tests/run.py b/tasks/optimize-ae-p1-ff-kakeya-d3-p31/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p31/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-p1-ff-kakeya-d3-p31/tests/test.sh b/tasks/optimize-ae-p1-ff-kakeya-d3-p31/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p31/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-p35-cubes-in-cube-n11/environment/Dockerfile b/tasks/optimize-ae-p35-cubes-in-cube-n11/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p35-cubes-in-cube-n11/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-p35-cubes-in-cube-n11/environment/instance.json b/tasks/optimize-ae-p35-cubes-in-cube-n11/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0cdc7132d4d482905c13055d5b1fa73587afb997 --- /dev/null +++ b/tasks/optimize-ae-p35-cubes-in-cube-n11/environment/instance.json @@ -0,0 +1 @@ +{"n": 11, "tol": 1e-09, "direction": "minimize", "family": "ae_p35_cubes_in_cube", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p35-cubes-in-cube-n11/solution/solve.sh b/tasks/optimize-ae-p35-cubes-in-cube-n11/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7569554dd8e1ce1e7fdc17dd3bfd664acaa0abeb --- /dev/null +++ b/tasks/optimize-ae-p35-cubes-in-cube-n11/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' +{"cubes": [[-0.877779155, -0.877126384, -1.01671182, 0, 0, 0], [-0.877779155, -0.877126384, 0.877819332, 0, 0, 0], [-0.877779155, 1.01740471, -1.01671182, 0, 0, 0], [-0.877779155, 1.01740471, 0.877819332, 0, 0, 0], [1.01675167, -0.877126384, -1.01671182, 0, 0, 0], [1.01675167, -0.877126384, 0.877819332, 0, 0, 0], [1.01675167, 1.01740471, -1.01671182, 0, 0, 0], [1.01675167, 1.01740471, 0.877819332, 0, 0, 0], [0.201013926, 0.11525216, 0.877806873, 6.76458206, 89.9998576, 160.681931], [0.11336823, -0.877124005, -0.208800374, 207.520455, 359.999904, 90.0002316], [-0.87775203, 0.204448607, -0.114126641, 180.000883, 26.5856303, 270.001203]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p35-cubes-in-cube-n11/tests/check.py b/tasks/optimize-ae-p35-cubes-in-cube-n11/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..385bbee4f715ce70a2fb41197a6955e11d4ac10a --- /dev/null +++ b/tasks/optimize-ae-p35-cubes-in-cube-n11/tests/check.py @@ -0,0 +1,51 @@ +"""Packing n unit cubes (arbitrary orientation) in the smallest axis-aligned cube (AlphaEvolve problem 35). + +Cube = centre + Euler angles in degrees, R = Rz(rz) Ry(ry) Rx(rx) (upstream convention). Disjoint interiors are +checked with the separating-axis theorem over the 15 candidate axes; projections may overlap by at most +inst["tol"] (floating-point slack). Score = largest side of the axis-aligned bounding box (minimize).""" +import itertools +import math + +import numpy as np + +from run import Invalid, float_matrix + + +def rot(rx, ry, rz): + x, y, z = map(math.radians, (rx, ry, rz)) + cx, sx, cy, sy, cz, sz = math.cos(x), math.sin(x), math.cos(y), math.sin(y), math.cos(z), math.sin(z) + mx = np.array([[1, 0, 0], [0, cx, -sx], [0, sx, cx]]) + my = np.array([[cy, 0, sy], [0, 1, 0], [-sy, 0, cy]]) + mz = np.array([[cz, -sz, 0], [sz, cz, 0], [0, 0, 1]]) + return mz @ my @ mx + + +LOCAL = np.array(list(itertools.product((-0.5, 0.5), repeat=3))) + + +def check(inst, ans): + n, tol = inst["n"], inst["tol"] + rows = float_matrix(ans.get("cubes"), n, 6, "cubes") + cubes = [] + for r in rows: + if max(abs(v) for v in r[:3]) > 1e3 or max(abs(v) for v in r[3:]) > 1e4: + raise Invalid("coordinates or angles out of range") + m = rot(*r[3:]) + cubes.append((m, LOCAL @ m.T + np.array(r[:3]))) + for (m1, v1), (m2, v2) in itertools.combinations(cubes, 2): + axes = [m1[:, i] for i in range(3)] + [m2[:, i] for i in range(3)] + axes += [np.cross(m1[:, i], m2[:, j]) for i in range(3) for j in range(3)] + separated = False + for a in axes: + na = np.linalg.norm(a) + if na < 1e-9: + continue + a = a / na + p1, p2 = v1 @ a, v2 @ a + if min(p1.max(), p2.max()) - max(p1.min(), p2.min()) <= tol: + separated = True + break + if not separated: + raise Invalid("two cubes overlap") + allv = np.vstack([v for _, v in cubes]) + return float((allv.max(0) - allv.min(0)).max()), {} diff --git a/tasks/optimize-ae-p35-cubes-in-cube-n11/tests/instance.json b/tasks/optimize-ae-p35-cubes-in-cube-n11/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e951c2a0307014c30cbb4cb2b623f905710277cc --- /dev/null +++ b/tasks/optimize-ae-p35-cubes-in-cube-n11/tests/instance.json @@ -0,0 +1 @@ +{"n": 11, "tol": 1e-09, "direction": "minimize", "best_known": 2.894531152, "baseline": 3.0, "family": "ae_p35_cubes_in_cube", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p35-cubes-in-cube-n11/tests/run.py b/tasks/optimize-ae-p35-cubes-in-cube-n11/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p35-cubes-in-cube-n11/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-p35-cubes-in-cube-n11/tests/test.sh b/tasks/optimize-ae-p35-cubes-in-cube-n11/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p35-cubes-in-cube-n11/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-ring-loading-m15/environment/Dockerfile b/tasks/optimize-ea-ring-loading-m15/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ea-ring-loading-m15/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-ring-loading-m15/environment/instance.json b/tasks/optimize-ea-ring-loading-m15/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e8ac599bbee8ba2c18fcdedf1e3a8a6102185512 --- /dev/null +++ b/tasks/optimize-ea-ring-loading-m15/environment/instance.json @@ -0,0 +1 @@ +{"pairs": 15, "direction": "maximize", "family": "ea_ring_loading_15", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ea-ring-loading-m15/solution/solve.sh b/tasks/optimize-ea-ring-loading-m15/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1f121eb97ae027948dcce131a678b37c1040d6f --- /dev/null +++ b/tasks/optimize-ea-ring-loading-m15/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' +{"pairs": [["4021070878350065/4503599627370496", "2144571633141253/36028797018963968"], ["4015980079781185/9007199254740992", "4991219174959807/9007199254740992"], ["4347848093698155/9007199254740992", "3801522565438597/9007199254740992"], ["1501199713179029/4503599627370496", "6004799828382933/9007199254740992"], ["73719639262837/281474976710656", "1072285570860771/4503599627370496"], ["45230154090605/140737488355328", "95507334264723/140737488355328"], ["415538270686595/562949953421312", "5145206110093983/36028797018963968"], ["4503599559277793/9007199254740992", "4503599559277793/9007199254740992"], ["5145206110093983/36028797018963968", "415538270686595/562949953421312"], ["95507334264723/140737488355328", "45230154090605/140737488355328"], ["1072285570860771/4503599627370496", "73719639262837/281474976710656"], ["6004799828382933/9007199254740992", "1501199713179029/4503599627370496"], ["3801522565438597/9007199254740992", "4347848093698155/9007199254740992"], ["4991219174959807/9007199254740992", "4015980079781185/9007199254740992"], ["2144571633141253/36028797018963968", "4021070878350065/4503599627370496"]]} +RLMATH_EOF diff --git a/tasks/optimize-ea-ring-loading-m15/tests/check.py b/tasks/optimize-ea-ring-loading-m15/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..df8d98093f8e743e0e107cfa81dc20d09a34b880 --- /dev/null +++ b/tasks/optimize-ea-ring-loading-m15/tests/check.py @@ -0,0 +1,53 @@ +"""Ring loading problem with 15 pairs (EinsteinArena ring-loading-15, MIT). + +A(u, v) = min over z_i in {v_i, -u_i} of max_k |sum_{i<=k} z_i - sum_{i>k} z_i| (maximize). +Audit: upstream verifier parses exact rationals and enumerates all 2^15 adversary choices; sound. +Re-implemented over a common denominator with Python integers (same exact value, faster).""" +import math +import re +from fractions import Fraction + +from run import Invalid + +PAT = re.compile(r"^(?:0|[1-9]\d*)(?:(?:\.\d+)|(?:/[1-9]\d*))?$") + + +def _rat(s): + if not isinstance(s, str) or not 1 <= len(s) <= 80 or PAT.fullmatch(s) is None: + raise Invalid("values must be nonnegative decimal or fraction strings such as '0.25' or '3/7'") + r = Fraction(s) + if r.numerator.bit_length() > 64 or r.denominator.bit_length() > 64: + raise Invalid("reduced numerator and denominator must fit in 64 bits") + return r + + +def check(inst, ans): + k = inst["pairs"] + p = ans.get("pairs") + if not isinstance(p, list) or len(p) != k: + raise Invalid(f"pairs must be a list of exactly {k} pairs") + uv = [] + for q in p: + if not isinstance(q, list) or len(q) != 2: + raise Invalid("each entry must be a pair [u, v]") + u, v = _rat(q[0]), _rat(q[1]) + if u + v > 1: + raise Invalid("every pair must satisfy u + v <= 1") + uv.append((u, v)) + den = 1 + for u, v in uv: + for r in (u, v): + den = den * r.denominator // math.gcd(den, r.denominator) + U = [int(u * den) for u, _ in uv] + V = [int(v * den) for _, v in uv] + best = None + for mask in range(1 << k): + z = [-U[i] if mask >> i & 1 else V[i] for i in range(k)] + tot = sum(z) + pre, worst = 0, 0 + for x in z: + pre += x + worst = max(worst, abs(2 * pre - tot)) + if best is None or worst < best: + best = worst + return float(Fraction(best, den)), {"exact": str(Fraction(best, den))} diff --git a/tasks/optimize-ea-ring-loading-m15/tests/instance.json b/tasks/optimize-ea-ring-loading-m15/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3ba98de863a2fed03f11490738cf7070b958889d --- /dev/null +++ b/tasks/optimize-ea-ring-loading-m15/tests/instance.json @@ -0,0 +1 @@ +{"pairs": 15, "direction": "maximize", "best_known": 1.1190475684692773, "baseline": 0.5, "family": "ea_ring_loading_15", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ea-ring-loading-m15/tests/run.py b/tasks/optimize-ea-ring-loading-m15/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ea-ring-loading-m15/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-ring-loading-m15/tests/test.sh b/tasks/optimize-ea-ring-loading-m15/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ea-ring-loading-m15/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