diff --git a/tasks/construct-ae-p32-spherical-design-l2-s0/environment/Dockerfile b/tasks/construct-ae-p32-spherical-design-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p32-spherical-design-l2-s0/environment/instance.json b/tasks/construct-ae-p32-spherical-design-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b3eef95fffb70805a4acea24922ff9faee03cc86 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"t": 9, "N": 50, "family": "ae_p32_spherical_designs", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p32-spherical-design-l2-s0/solution/solve.sh b/tasks/construct-ae-p32-spherical-design-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d86752c47dd9dc677020418747c2ec4c47159d51 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-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' +{"points": [[0.16922693235862724, -0.20103306308114954, 0.9648564416081281], [-0.1444229652425299, 0.2171017544618927, 0.9654060468632476], [0.43300572300753354, 0.1842363624211028, 0.8823621742825126], [-0.19147178208270688, -0.49237023697924936, 0.8490642534008073], [-0.22349668833015543, 0.654913436090283, 0.721898622753827], [0.509349725181736, -0.48747070583171115, 0.7091792216451518], [-0.5010978490747997, 0.010483814311278454, 0.8653271261725799], [0.24876393702178104, 0.6230484503603421, 0.7415707195817536], [0.11017735532114167, -0.789114607647768, 0.6042839451543852], [-0.6259822804516245, 0.5732550669608374, 0.528701061815001], [0.7788755690243261, -0.12267885978214361, 0.6150632043453627], [-0.5891511128467095, -0.47905866047914647, 0.6506948332754837], [-0.016695443993852827, 0.9528854955655701, 0.30287042524915847], [0.5407559471861028, -0.7929901743066108, 0.2806235717754869], [-0.8251784644619647, 0.15320132073006773, 0.5437001536828521], [0.7124586326151269, 0.45642389870115885, 0.532991483521658], [-0.22269034288283843, -0.923864952976812, 0.3112596341446746], [-0.4543114368765767, 0.8793540951400043, 0.14260958482389796], [0.879158654622741, -0.4323212436111242, 0.200445509614117], [-0.9084927271844558, -0.26483920744792966, 0.32326638991906104], [0.427297066668364, 0.8589888181329067, 0.28205571637398835], [0.1961893863097625, -0.9805489439583888, -0.00578733111955302], [-0.857145477834502, 0.5136591874435725, 0.038155851224578145], [0.9586050155477033, 0.1556611835675878, 0.23842403422709968], [-0.6142666385010677, -0.7554667855527417, 0.22791760079293177], [-0.0155637262224955, 0.9730617521599628, -0.23001868817436164], [0.6594894609245198, -0.7146834747996651, -0.23302613968772445], [-0.9911784740660611, 0.12490321144879198, -0.04432178152842118], [0.7595848547022219, 0.650346280343838, 0.008975753446838262], [-0.19239158832539777, -0.9401443999828325, -0.2812720816621348], [-0.5493237657071705, 0.7684883626128087, -0.3281296039036676], [0.9597106060330255, -0.2029747309534766, -0.1943111197592324], [-0.8993738834391455, -0.4116803712793469, -0.1471254216336844], [0.39694316381332434, 0.8636637640928422, -0.31067833412526835], [0.28194190675210307, -0.7999712477604357, -0.5296742055014574], [-0.7405127465242392, 0.38771659281208454, -0.5489232331513362], [0.9165935591083989, 0.2895023545404387, -0.27576191563836383], [-0.5995263440379107, -0.7399920453612981, -0.3049261149959761], [-0.16390601707444988, 0.7392262392691027, -0.6532069999187466], [0.6921511051059226, -0.3855341733830527, -0.6101559217564771], [-0.8431809667785208, -0.06568581398919036, -0.5336021280907868], [0.577385115183291, 0.5515742456878375, -0.6019902659168757], [-0.18446726227062835, -0.6452617852184889, -0.7413562286020318], [-0.39553800855591986, 0.2992876105478974, -0.8683182653613519], [0.7058490124467708, 0.06764158430076028, -0.7051253702010739], [-0.575791553313456, -0.3787738467798754, -0.7245650144248292], [0.1583560597911477, 0.5038111183495314, -0.8491747260457161], [0.23218864269517328, -0.4140489499039636, -0.8801431140938377], [-0.24187888829836107, -0.08364147113872686, -0.9666947334610334], [0.2629790029566971, 0.05171375215262599, -0.9634146209406407]]} +RLMATH_EOF diff --git a/tasks/construct-ae-p32-spherical-design-l2-s0/tests/check.py b/tasks/construct-ae-p32-spherical-design-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..5973c15b3df2d6228d713d9b186ced8e47dcbb48 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l2-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-l2-s0/tests/instance.json b/tasks/construct-ae-p32-spherical-design-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b3eef95fffb70805a4acea24922ff9faee03cc86 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"t": 9, "N": 50, "family": "ae_p32_spherical_designs", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p32-spherical-design-l2-s0/tests/run.py b/tasks/construct-ae-p32-spherical-design-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p32-spherical-design-l2-s0/tests/test.sh b/tasks/construct-ae-p32-spherical-design-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p32-spherical-design-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p38-factorial-factors-l1-s1/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l1-s1/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f2341e17bfcf70ab27c4f5006c6d6dc579cc33e7 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"N": 37, "t": 10, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l1-s1/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7f5fabe853388a63651a772fe8dec9968094eec2 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [60, 10, 10, 10, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 17, 17, 19, 23, 29, 31, 37]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l1-s1/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l1-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-l1-s1/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f2341e17bfcf70ab27c4f5006c6d6dc579cc33e7 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"N": 37, "t": 10, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l1-s1/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l1-s1/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l1-s6/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l1-s6/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..019af6d9475170a5330f27b9cde3db0b2244ac4c --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"N": 54, "t": 15, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l1-s6/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..23e508d7e499e805e1499647d0b4979a8ec704d8 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [120, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 26, 26, 26, 26, 29, 31, 37, 41, 43, 47, 53]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l1-s6/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l1-s6/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l1-s6/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..019af6d9475170a5330f27b9cde3db0b2244ac4c --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"N": 54, "t": 15, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l1-s6/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l1-s6/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l1-s8/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l1-s8/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8412dd7c129b91c2ecd7d948d8a709909525aba6 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"N": 56, "t": 15, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l1-s8/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ae0f83e2bcf28a0c04b11222b1b0ceee08088a8b --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [60, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 18, 18, 19, 19, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 23, 23, 26, 26, 26, 26, 29, 31, 37, 41, 43, 47, 795]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l1-s8/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l1-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-l1-s8/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8412dd7c129b91c2ecd7d948d8a709909525aba6 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"N": 56, "t": 15, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l1-s8/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l1-s8/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l5-s0/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p38-factorial-factors-l5-s0/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9f183ad4b70f7e0c71708a9cfd2c6ba9101cf2f4 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"N": 1632, "t": 515, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l5-s0/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..59f97fe112e19b772859bc8c011d6f63f66a55a3 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 516, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 517, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 518, 519, 519, 519, 519, 519, 519, 519, 519, 519, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, 521, 521, 521, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 522, 523, 523, 523, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 524, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 525, 526, 526, 526, 526, 526, 526, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 527, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 529, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 530, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 531, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 532, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 534, 534, 534, 534, 534, 534, 534, 534, 534, 534, 534, 534, 534, 534, 534, 534, 534, 534, 535, 535, 535, 535, 535, 535, 535, 535, 535, 535, 535, 535, 535, 535, 535, 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, 536, 537, 537, 537, 537, 537, 537, 537, 537, 537, 538, 538, 538, 538, 538, 538, 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, 539, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 541, 541, 541, 542, 542, 542, 542, 542, 542, 543, 543, 543, 543, 543, 543, 543, 543, 543, 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, 547, 547, 548, 548, 548, 548, 548, 548, 548, 548, 548, 548, 548, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 549, 552, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 553, 554, 554, 554, 554, 554, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 557, 557, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 561, 562, 562, 562, 562, 562, 563, 563, 565, 565, 565, 565, 565, 565, 565, 565, 565, 565, 565, 565, 565, 565, 566, 566, 566, 566, 566, 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, 568, 569, 569, 571, 571, 573, 573, 573, 573, 573, 573, 573, 573, 577, 577, 579, 579, 579, 579, 579, 579, 579, 579, 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, 581, 582, 582, 582, 582, 582, 582, 582, 582, 582, 582, 582, 582, 582, 582, 582, 582, 584, 584, 584, 584, 584, 584, 584, 584, 584, 584, 584, 584, 584, 584, 584, 584, 584, 584, 584, 584, 584, 586, 586, 586, 586, 586, 587, 587, 591, 591, 591, 591, 591, 591, 591, 591, 593, 593, 594, 594, 594, 596, 596, 596, 596, 596, 596, 596, 596, 596, 596, 597, 597, 597, 597, 597, 597, 597, 597, 599, 599, 601, 601, 604, 604, 604, 604, 604, 604, 604, 604, 604, 604, 606, 606, 606, 606, 606, 606, 606, 606, 606, 606, 606, 606, 606, 606, 606, 606, 607, 607, 613, 613, 614, 614, 614, 614, 614, 617, 617, 619, 619, 622, 622, 622, 622, 622, 626, 626, 626, 626, 626, 628, 628, 628, 628, 628, 628, 628, 628, 628, 628, 631, 631, 633, 633, 633, 633, 633, 633, 633, 634, 634, 634, 634, 634, 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, 635, 641, 641, 643, 643, 647, 647, 652, 652, 652, 652, 652, 652, 652, 652, 652, 652, 653, 653, 659, 659, 661, 661, 662, 662, 662, 662, 668, 668, 668, 668, 668, 668, 668, 668, 668, 669, 669, 669, 669, 669, 669, 669, 673, 673, 674, 674, 674, 674, 677, 677, 681, 681, 681, 681, 681, 681, 681, 683, 683, 687, 687, 687, 687, 687, 687, 687, 691, 691, 694, 694, 694, 694, 698, 698, 698, 698, 699, 699, 699, 699, 699, 699, 699, 701, 701, 706, 706, 706, 706, 709, 709, 717, 717, 717, 717, 717, 717, 718, 718, 718, 718, 719, 719, 722, 722, 723, 723, 723, 723, 723, 723, 727, 727, 733, 733, 734, 734, 734, 734, 739, 739, 743, 743, 746, 746, 746, 746, 751, 751, 753, 753, 753, 753, 753, 753, 757, 757, 758, 758, 758, 758, 761, 761, 766, 766, 766, 766, 769, 769, 771, 771, 771, 771, 771, 771, 773, 773, 778, 778, 778, 778, 787, 787, 794, 794, 794, 794, 797, 797, 802, 802, 802, 802, 803, 809, 809, 811, 811, 818, 818, 818, 821, 823, 827, 829, 838, 838, 838, 839, 842, 842, 842, 853, 857, 859, 862, 862, 862, 863, 866, 866, 866, 877, 878, 878, 878, 881, 883, 886, 886, 886, 887, 898, 898, 898, 907, 911, 914, 914, 914, 919, 922, 922, 922, 926, 926, 926, 929, 934, 934, 934, 937, 941, 947, 953, 958, 958, 958, 967, 971, 974, 974, 974, 977, 982, 982, 982, 983, 991, 997, 998, 998, 998, 1006, 1006, 1006, 1009, 1013, 1018, 1018, 1018, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l5-s0/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l5-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-l5-s0/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9f183ad4b70f7e0c71708a9cfd2c6ba9101cf2f4 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"N": 1632, "t": 515, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l5-s0/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p38-factorial-factors-l5-s0/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p38-factorial-factors-l5-s9/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l5-s9/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..26c51bf46098f8c5b2b721462bf477173958e3f4 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"N": 3574, "t": 1147, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l5-s9/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4d73f744db3108ab9f02f81391f4c4463a7aa7cf --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [2294, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1147, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1148, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1150, 1151, 1151, 1151, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1152, 1153, 1153, 1153, 1154, 1154, 1154, 1154, 1154, 1154, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1155, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1156, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1157, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1159, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1160, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1161, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1163, 1163, 1163, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1164, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1166, 1167, 1167, 1167, 1167, 1167, 1167, 1167, 1167, 1167, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1169, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1170, 1171, 1171, 1171, 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1173, 1174, 1174, 1174, 1174, 1174, 1174, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1175, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1177, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1178, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1179, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1180, 1181, 1181, 1181, 1182, 1182, 1182, 1182, 1182, 1182, 1182, 1182, 1182, 1182, 1182, 1182, 1182, 1182, 1182, 1182, 1182, 1182, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1183, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1184, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1185, 1186, 1186, 1186, 1186, 1186, 1186, 1187, 1187, 1187, 1191, 1191, 1191, 1191, 1191, 1191, 1191, 1191, 1191, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1192, 1193, 1193, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1194, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1197, 1198, 1198, 1198, 1198, 1198, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1199, 1201, 1201, 1202, 1202, 1202, 1202, 1202, 1203, 1203, 1203, 1203, 1203, 1203, 1203, 1203, 1205, 1205, 1205, 1205, 1205, 1205, 1205, 1205, 1205, 1205, 1205, 1205, 1205, 1205, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1206, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1207, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1208, 1211, 1211, 1211, 1211, 1211, 1211, 1211, 1211, 1211, 1211, 1211, 1211, 1211, 1211, 1211, 1211, 1211, 1211, 1211, 1211, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1212, 1213, 1213, 1214, 1214, 1214, 1214, 1214, 1216, 1217, 1217, 1223, 1223, 1226, 1226, 1226, 1226, 1226, 1227, 1227, 1227, 1227, 1227, 1227, 1227, 1227, 1228, 1228, 1228, 1228, 1228, 1228, 1228, 1228, 1228, 1228, 1228, 1229, 1229, 1231, 1231, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1233, 1234, 1234, 1234, 1234, 1234, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1236, 1237, 1237, 1238, 1238, 1238, 1238, 1238, 1241, 1241, 1241, 1241, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1243, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1249, 1249, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1251, 1252, 1252, 1252, 1252, 1252, 1252, 1252, 1252, 1252, 1252, 1252, 1253, 1253, 1253, 1253, 1253, 1253, 1253, 1253, 1253, 1253, 1253, 1253, 1253, 1253, 1253, 1253, 1253, 1253, 1253, 1255, 1255, 1255, 1255, 1255, 1255, 1255, 1255, 1255, 1255, 1255, 1255, 1255, 1255, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1256, 1257, 1257, 1257, 1257, 1257, 1257, 1257, 1257, 1259, 1259, 1262, 1262, 1262, 1262, 1262, 1263, 1263, 1263, 1263, 1263, 1263, 1263, 1263, 1266, 1266, 1266, 1266, 1266, 1266, 1266, 1266, 1266, 1266, 1266, 1266, 1266, 1266, 1266, 1266, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1267, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1277, 1277, 1279, 1279, 1280, 1282, 1282, 1282, 1282, 1282, 1283, 1283, 1285, 1285, 1285, 1285, 1285, 1285, 1285, 1285, 1285, 1285, 1285, 1285, 1285, 1286, 1286, 1286, 1286, 1286, 1289, 1289, 1291, 1291, 1293, 1293, 1293, 1293, 1293, 1293, 1293, 1293, 1294, 1294, 1294, 1294, 1294, 1297, 1297, 1299, 1299, 1299, 1299, 1299, 1299, 1299, 1299, 1301, 1301, 1303, 1303, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1304, 1306, 1306, 1306, 1306, 1306, 1307, 1307, 1315, 1315, 1315, 1315, 1315, 1315, 1315, 1315, 1315, 1315, 1315, 1315, 1315, 1317, 1317, 1317, 1317, 1317, 1317, 1317, 1317, 1318, 1318, 1318, 1318, 1318, 1319, 1319, 1321, 1321, 1322, 1322, 1322, 1322, 1322, 1324, 1324, 1324, 1324, 1324, 1324, 1324, 1324, 1324, 1324, 1327, 1327, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1329, 1331, 1331, 1331, 1331, 1333, 1336, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1337, 1338, 1338, 1338, 1338, 1338, 1338, 1338, 1338, 1338, 1338, 1338, 1338, 1338, 1338, 1338, 1338, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1346, 1346, 1346, 1346, 1346, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1354, 1354, 1354, 1354, 1354, 1355, 1355, 1355, 1355, 1355, 1355, 1355, 1355, 1355, 1355, 1355, 1355, 1355, 1361, 1361, 1362, 1362, 1362, 1362, 1362, 1362, 1362, 1362, 1362, 1362, 1362, 1362, 1362, 1362, 1362, 1366, 1366, 1366, 1366, 1366, 1367, 1367, 1369, 1371, 1371, 1371, 1371, 1371, 1371, 1371, 1373, 1373, 1374, 1374, 1374, 1374, 1374, 1374, 1374, 1374, 1374, 1374, 1374, 1374, 1374, 1374, 1374, 1381, 1381, 1382, 1382, 1382, 1382, 1382, 1383, 1383, 1383, 1383, 1383, 1383, 1383, 1385, 1385, 1385, 1385, 1385, 1385, 1385, 1385, 1385, 1385, 1385, 1385, 1388, 1388, 1388, 1388, 1388, 1388, 1388, 1388, 1388, 1388, 1389, 1389, 1389, 1389, 1389, 1389, 1389, 1396, 1396, 1396, 1396, 1396, 1396, 1396, 1396, 1396, 1396, 1399, 1399, 1401, 1401, 1401, 1401, 1401, 1401, 1401, 1402, 1402, 1402, 1402, 1402, 1405, 1405, 1405, 1405, 1405, 1405, 1405, 1405, 1405, 1405, 1405, 1405, 1409, 1409, 1412, 1412, 1412, 1412, 1412, 1412, 1412, 1412, 1412, 1412, 1415, 1415, 1415, 1415, 1415, 1415, 1415, 1415, 1415, 1415, 1415, 1415, 1418, 1418, 1418, 1418, 1418, 1423, 1423, 1427, 1427, 1429, 1429, 1433, 1433, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1436, 1437, 1437, 1437, 1437, 1437, 1437, 1437, 1438, 1438, 1438, 1438, 1439, 1439, 1447, 1447, 1451, 1451, 1453, 1453, 1454, 1454, 1454, 1454, 1459, 1459, 1461, 1461, 1461, 1461, 1461, 1461, 1461, 1466, 1466, 1466, 1466, 1468, 1468, 1468, 1468, 1468, 1468, 1468, 1468, 1468, 1471, 1471, 1473, 1473, 1473, 1473, 1473, 1473, 1473, 1478, 1478, 1478, 1478, 1481, 1481, 1483, 1483, 1486, 1486, 1486, 1486, 1487, 1487, 1489, 1489, 1492, 1492, 1492, 1492, 1492, 1492, 1492, 1492, 1492, 1493, 1493, 1497, 1497, 1497, 1497, 1497, 1497, 1497, 1499, 1499, 1502, 1502, 1502, 1502, 1509, 1509, 1509, 1509, 1509, 1509, 1509, 1511, 1511, 1514, 1514, 1514, 1514, 1516, 1516, 1516, 1516, 1516, 1516, 1516, 1516, 1516, 1522, 1522, 1522, 1522, 1523, 1523, 1527, 1527, 1527, 1527, 1527, 1527, 1527, 1531, 1531, 1538, 1538, 1538, 1538, 1543, 1543, 1546, 1546, 1546, 1546, 1549, 1549, 1553, 1553, 1559, 1559, 1563, 1563, 1563, 1563, 1563, 1563, 1567, 1567, 1569, 1569, 1569, 1569, 1569, 1569, 1571, 1571, 1574, 1574, 1574, 1574, 1579, 1579, 1583, 1583, 1594, 1594, 1594, 1594, 1597, 1597, 1601, 1601, 1607, 1607, 1609, 1609, 1613, 1613, 1618, 1618, 1618, 1618, 1619, 1619, 1621, 1621, 1622, 1622, 1622, 1622, 1623, 1623, 1623, 1623, 1623, 1623, 1627, 1627, 1637, 1637, 1641, 1641, 1641, 1641, 1641, 1641, 1642, 1642, 1642, 1642, 1646, 1646, 1646, 1646, 1654, 1654, 1654, 1654, 1657, 1657, 1658, 1658, 1658, 1658, 1663, 1663, 1667, 1667, 1669, 1669, 1671, 1671, 1671, 1671, 1671, 1671, 1678, 1678, 1678, 1678, 1689, 1689, 1689, 1689, 1689, 1689, 1693, 1693, 1697, 1697, 1699, 1699, 1706, 1706, 1706, 1706, 1707, 1707, 1707, 1707, 1707, 1707, 1709, 1709, 1713, 1713, 1713, 1713, 1713, 1713, 1714, 1714, 1714, 1714, 1718, 1718, 1718, 1718, 1721, 1721, 1723, 1723, 1726, 1726, 1726, 1726, 1733, 1733, 1741, 1741, 1747, 1747, 1753, 1753, 1754, 1754, 1754, 1754, 1759, 1759, 1762, 1762, 1762, 1762, 1766, 1766, 1766, 1766, 1774, 1774, 1774, 1774, 1777, 1777, 1783, 1783, 1787, 1787, 1789, 1801, 1811, 1814, 1814, 1814, 1822, 1822, 1822, 1823, 1831, 1838, 1838, 1838, 1847, 1858, 1858, 1858, 1861, 1867, 1871, 1873, 1874, 1874, 1874, 1877, 1879, 1882, 1882, 1882, 1889, 1894, 1894, 1894, 1901, 1906, 1906, 1906, 1907, 1913, 1931, 1933, 1934, 1934, 1934, 1942, 1942, 1942, 1949, 1951, 1954, 1954, 1954, 1966, 1966, 1966, 1973, 1979, 1982, 1982, 1982, 1987, 1993, 1994, 1994, 1994, 1997, 1999, 2003, 2011, 2017, 2018, 2018, 2018, 2026, 2026, 2026, 2027, 2029, 2038, 2038, 2038, 2039, 2042, 2042, 2042, 2053, 2062, 2062, 2062, 2063, 2066, 2066, 2066, 2069, 2078, 2078, 2078, 2081, 2083, 2087, 2089, 2098, 2098, 2098, 2099, 2102, 2102, 2102, 2111, 2113, 2122, 2122, 2122, 2126, 2126, 2126, 2129, 2131, 2137, 2138, 2138, 2138, 2141, 2143, 2153, 2161, 2174, 2174, 2174, 2179, 2182, 2182, 2182, 2186, 2186, 2186, 2194, 2194, 2194, 2203, 2206, 2206, 2206, 2207, 2213, 2218, 2218, 2218, 2221, 2234, 2234, 2234, 2237, 2239, 2243, 2246, 2246, 2246, 2251, 2258, 2258, 2258, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 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]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l5-s9/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l5-s9/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l5-s9/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..26c51bf46098f8c5b2b721462bf477173958e3f4 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"N": 3574, "t": 1147, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l5-s9/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l5-s9/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s5/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s5/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0c24dff3f026501476361293f69b386a83731890 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"N": 7712, "t": 2510, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s5/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3d79990fd243fc8c032b90055f72c7caafe222f4 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [22590, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2516, 2517, 2517, 2517, 2517, 2517, 2517, 2517, 2517, 2517, 2518, 2518, 2518, 2518, 2518, 2518, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2520, 2521, 2521, 2521, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2523, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2527, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2528, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2531, 2531, 2531, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2535, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2537, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2538, 2539, 2539, 2539, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2541, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2542, 2543, 2543, 2543, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2546, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2548, 2549, 2549, 2549, 2550, 2550, 2550, 2551, 2551, 2551, 2552, 2554, 2554, 2554, 2554, 2554, 2554, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2555, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2556, 2557, 2557, 2557, 2558, 2558, 2558, 2558, 2558, 2558, 2559, 2559, 2559, 2559, 2559, 2559, 2559, 2559, 2559, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2562, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2566, 2566, 2566, 2566, 2566, 2566, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2568, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2571, 2571, 2571, 2571, 2571, 2571, 2571, 2571, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2573, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2575, 2577, 2577, 2577, 2577, 2577, 2577, 2577, 2577, 2578, 2578, 2578, 2578, 2578, 2579, 2579, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2580, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2581, 2582, 2582, 2582, 2582, 2582, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2583, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2589, 2589, 2589, 2589, 2589, 2589, 2589, 2589, 2591, 2591, 2593, 2593, 2594, 2594, 2594, 2594, 2594, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2599, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2601, 2602, 2602, 2602, 2602, 2602, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2603, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2606, 2606, 2606, 2606, 2606, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2608, 2609, 2609, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2614, 2614, 2614, 2614, 2614, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2616, 2617, 2617, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2620, 2621, 2621, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2624, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2631, 2631, 2631, 2631, 2631, 2631, 2631, 2631, 2633, 2633, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2638, 2638, 2638, 2638, 2638, 2639, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2641, 2642, 2642, 2642, 2642, 2642, 2643, 2643, 2643, 2643, 2643, 2643, 2643, 2643, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2647, 2647, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2649, 2649, 2649, 2649, 2649, 2649, 2649, 2649, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2654, 2654, 2654, 2654, 2654, 2657, 2657, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2659, 2659, 2661, 2661, 2661, 2661, 2661, 2661, 2661, 2661, 2662, 2663, 2663, 2671, 2671, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2672, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2674, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2676, 2677, 2677, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2683, 2683, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2685, 2687, 2687, 2689, 2689, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2693, 2693, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2699, 2699, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2702, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2707, 2707, 2708, 2708, 2708, 2708, 2708, 2708, 2708, 2708, 2708, 2708, 2708, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2710, 2711, 2711, 2713, 2713, 2719, 2719, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2722, 2722, 2722, 2722, 2722, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2724, 2729, 2729, 2731, 2731, 2732, 2732, 2732, 2732, 2732, 2732, 2732, 2732, 2732, 2732, 2732, 2733, 2733, 2733, 2733, 2733, 2733, 2733, 2733, 2734, 2734, 2734, 2734, 2734, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2741, 2741, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2746, 2746, 2746, 2746, 2746, 2749, 2749, 2753, 2753, 2757, 2757, 2757, 2757, 2757, 2757, 2757, 2757, 2762, 2762, 2762, 2762, 2762, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2763, 2764, 2764, 2764, 2764, 2764, 2764, 2764, 2764, 2764, 2764, 2764, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2767, 2767, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2770, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2776, 2777, 2777, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2787, 2787, 2787, 2787, 2787, 2787, 2787, 2787, 2789, 2789, 2791, 2791, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2792, 2797, 2797, 2798, 2798, 2798, 2798, 2798, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2799, 2801, 2801, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2803, 2803, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2817, 2818, 2818, 2818, 2818, 2818, 2819, 2819, 2823, 2823, 2823, 2823, 2823, 2823, 2823, 2823, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2824, 2833, 2833, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2837, 2837, 2841, 2841, 2841, 2841, 2841, 2841, 2841, 2841, 2843, 2843, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2846, 2846, 2846, 2846, 2846, 2851, 2851, 2854, 2854, 2854, 2854, 2854, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2857, 2857, 2858, 2858, 2858, 2858, 2858, 2859, 2859, 2859, 2859, 2859, 2859, 2859, 2859, 2861, 2861, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2863, 2866, 2866, 2866, 2866, 2866, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2878, 2878, 2878, 2878, 2878, 2879, 2879, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2887, 2887, 2894, 2894, 2894, 2894, 2894, 2897, 2897, 2901, 2901, 2901, 2901, 2901, 2901, 2901, 2902, 2902, 2902, 2902, 2902, 2903, 2903, 2906, 2906, 2906, 2906, 2906, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2909, 2909, 2913, 2913, 2913, 2913, 2913, 2913, 2913, 2917, 2917, 2918, 2918, 2918, 2918, 2918, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2927, 2927, 2931, 2931, 2931, 2931, 2931, 2931, 2931, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2939, 2939, 2942, 2942, 2942, 2942, 2942, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2949, 2949, 2949, 2949, 2949, 2949, 2949, 2953, 2953, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2957, 2957, 2962, 2962, 2962, 2962, 2962, 2963, 2963, 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, 2973, 2973, 2973, 2973, 2973, 2973, 2973, 2974, 2974, 2974, 2974, 2974, 2978, 2978, 2978, 2978, 2978, 2986, 2986, 2986, 2986, 2986, 2991, 2991, 2991, 2991, 2991, 2991, 2991, 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, 2998, 2998, 2998, 2998, 2998, 2999, 2999, 3001, 3001, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3011, 3011, 3019, 3019, 3022, 3022, 3022, 3022, 3022, 3023, 3023, 3027, 3027, 3027, 3027, 3027, 3027, 3027, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3037, 3037, 3039, 3039, 3039, 3039, 3039, 3039, 3039, 3041, 3041, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3046, 3046, 3046, 3046, 3046, 3049, 3049, 3057, 3057, 3057, 3057, 3057, 3057, 3057, 3061, 3061, 3062, 3062, 3062, 3062, 3062, 3063, 3063, 3063, 3063, 3063, 3063, 3063, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3067, 3067, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3079, 3079, 3083, 3083, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3086, 3086, 3086, 3086, 3089, 3089, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3093, 3093, 3093, 3093, 3093, 3093, 3093, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3098, 3098, 3098, 3098, 3099, 3099, 3099, 3099, 3099, 3099, 3099, 3106, 3106, 3106, 3106, 3109, 3109, 3117, 3117, 3117, 3117, 3117, 3117, 3117, 3118, 3118, 3118, 3118, 3119, 3119, 3121, 3121, 3134, 3134, 3134, 3134, 3137, 3137, 3142, 3142, 3142, 3142, 3147, 3147, 3147, 3147, 3147, 3147, 3147, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3153, 3153, 3153, 3153, 3153, 3153, 3153, 3158, 3158, 3158, 3158, 3163, 3163, 3166, 3166, 3166, 3166, 3167, 3167, 3169, 3169, 3181, 3181, 3183, 3183, 3183, 3183, 3183, 3183, 3183, 3187, 3187, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3189, 3189, 3189, 3189, 3189, 3189, 3189, 3191, 3191, 3194, 3194, 3194, 3194, 3202, 3202, 3202, 3202, 3203, 3203, 3207, 3207, 3207, 3207, 3207, 3207, 3207, 3209, 3209, 3214, 3214, 3214, 3214, 3217, 3217, 3218, 3218, 3218, 3218, 3221, 3221, 3226, 3226, 3226, 3226, 3229, 3229, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3238, 3238, 3238, 3238, 3242, 3242, 3242, 3242, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3251, 3251, 3253, 3253, 3254, 3254, 3254, 3254, 3257, 3257, 3259, 3259, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3271, 3271, 3273, 3273, 3273, 3273, 3273, 3273, 3273, 3274, 3274, 3274, 3274, 3279, 3279, 3279, 3279, 3279, 3279, 3279, 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, 3299, 3299, 3301, 3301, 3307, 3307, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3309, 3309, 3309, 3309, 3309, 3309, 3313, 3313, 3314, 3314, 3314, 3314, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3319, 3319, 3323, 3323, 3326, 3326, 3326, 3326, 3327, 3327, 3327, 3327, 3327, 3327, 3329, 3329, 3331, 3331, 3334, 3334, 3334, 3334, 3338, 3338, 3338, 3338, 3343, 3343, 3347, 3347, 3351, 3351, 3351, 3351, 3351, 3351, 3359, 3359, 3361, 3361, 3369, 3369, 3369, 3369, 3369, 3369, 3371, 3371, 3373, 3373, 3386, 3386, 3386, 3386, 3387, 3387, 3387, 3387, 3387, 3387, 3389, 3389, 3391, 3391, 3394, 3394, 3394, 3394, 3398, 3398, 3398, 3398, 3407, 3407, 3413, 3413, 3418, 3418, 3418, 3418, 3433, 3433, 3442, 3442, 3442, 3442, 3446, 3446, 3446, 3446, 3449, 3449, 3453, 3453, 3453, 3453, 3453, 3453, 3457, 3457, 3459, 3459, 3459, 3459, 3459, 3459, 3461, 3461, 3463, 3463, 3466, 3466, 3466, 3466, 3467, 3467, 3469, 3469, 3482, 3482, 3482, 3482, 3489, 3489, 3489, 3489, 3489, 3489, 3491, 3491, 3494, 3494, 3494, 3494, 3499, 3499, 3506, 3506, 3506, 3506, 3511, 3511, 3513, 3513, 3513, 3513, 3513, 3513, 3517, 3517, 3518, 3518, 3518, 3518, 3527, 3527, 3529, 3529, 3533, 3533, 3539, 3539, 3541, 3541, 3543, 3543, 3543, 3543, 3543, 3543, 3547, 3547, 3554, 3554, 3554, 3554, 3557, 3557, 3559, 3559, 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, 3581, 3581, 3583, 3583, 3593, 3593, 3602, 3602, 3602, 3602, 3603, 3603, 3603, 3603, 3603, 3603, 3607, 3607, 3613, 3613, 3617, 3617, 3622, 3622, 3622, 3622, 3623, 3623, 3631, 3631, 3637, 3637, 3639, 3639, 3639, 3639, 3639, 3639, 3643, 3643, 3646, 3646, 3646, 3646, 3651, 3651, 3651, 3651, 3651, 3651, 3659, 3659, 3662, 3662, 3662, 3662, 3669, 3669, 3669, 3669, 3669, 3669, 3671, 3671, 3673, 3673, 3677, 3677, 3687, 3687, 3687, 3687, 3687, 3687, 3691, 3691, 3693, 3693, 3693, 3693, 3693, 3693, 3694, 3694, 3694, 3694, 3697, 3697, 3701, 3701, 3709, 3709, 3711, 3711, 3711, 3711, 3711, 3711, 3719, 3719, 3722, 3722, 3722, 3722, 3727, 3727, 3733, 3733, 3734, 3734, 3734, 3734, 3739, 3739, 3742, 3742, 3742, 3742, 3746, 3746, 3746, 3746, 3747, 3747, 3747, 3747, 3747, 3747, 3754, 3754, 3754, 3754, 3758, 3758, 3758, 3758, 3761, 3761, 3767, 3767, 3769, 3769, 3778, 3778, 3778, 3778, 3779, 3779, 3793, 3793, 3797, 3797, 3802, 3802, 3802, 3802, 3803, 3803, 3814, 3814, 3814, 3814, 3821, 3821, 3823, 3823, 3826, 3826, 3826, 3826, 3833, 3833, 3847, 3847, 3851, 3851, 3853, 3853, 3862, 3862, 3862, 3863, 3866, 3866, 3866, 3877, 3881, 3889, 3898, 3898, 3898, 3902, 3902, 3902, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3946, 3946, 3946, 3947, 3958, 3958, 3958, 3967, 3974, 3974, 3974, 3986, 3986, 3986, 3989, 3994, 3994, 3994, 3998, 3998, 3998, 4001, 4003, 4006, 4006, 4006, 4007, 4013, 4019, 4021, 4022, 4022, 4022, 4027, 4034, 4034, 4034, 4049, 4051, 4054, 4054, 4054, 4057, 4058, 4058, 4058, 4073, 4078, 4078, 4078, 4079, 4091, 4093, 4099, 4106, 4106, 4106, 4111, 4126, 4126, 4126, 4127, 4129, 4133, 4138, 4138, 4138, 4139, 4153, 4157, 4159, 4162, 4162, 4162, 4166, 4166, 4166, 4174, 4174, 4174, 4177, 4178, 4178, 4178, 4198, 4198, 4198, 4201, 4211, 4217, 4219, 4222, 4222, 4222, 4226, 4226, 4226, 4229, 4231, 4241, 4243, 4253, 4258, 4258, 4258, 4259, 4261, 4262, 4262, 4262, 4271, 4273, 4274, 4274, 4274, 4282, 4282, 4282, 4283, 4286, 4286, 4286, 4289, 4297, 4306, 4306, 4306, 4322, 4322, 4322, 4327, 4337, 4339, 4349, 4357, 4358, 4358, 4358, 4363, 4373, 4391, 4397, 4406, 4406, 4406, 4409, 4414, 4414, 4414, 4421, 4423, 4426, 4426, 4426, 4441, 4442, 4442, 4442, 4447, 4451, 4457, 4463, 4474, 4474, 4474, 4478, 4478, 4478, 4481, 4483, 4486, 4486, 4486, 4493, 4502, 4502, 4502, 4507, 4513, 4517, 4519, 4523, 4534, 4534, 4534, 4538, 4538, 4538, 4546, 4546, 4546, 4547, 4549, 4561, 4562, 4562, 4562, 4567, 4574, 4574, 4574, 4583, 4586, 4586, 4586, 4591, 4594, 4594, 4594, 4597, 4603, 4618, 4618, 4618, 4621, 4622, 4622, 4622, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4666, 4666, 4666, 4673, 4678, 4678, 4678, 4679, 4682, 4682, 4682, 4691, 4694, 4694, 4694, 4702, 4702, 4702, 4703, 4714, 4714, 4714, 4721, 4723, 4729, 4733, 4742, 4742, 4742, 4751, 4754, 4754, 4754, 4759, 4762, 4762, 4762, 4766, 4766, 4766, 4778, 4778, 4778, 4783, 4786, 4786, 4786, 4787, 4789, 4793, 4798, 4798, 4798, 4799, 4801, 4813, 4817, 4822, 4822, 4822, 4831, 4834, 4834, 4834, 4846, 4846, 4846, 4861, 4871, 4874, 4874, 4874, 4877, 4882, 4882, 4882, 4889, 4894, 4894, 4894, 4903, 4909, 4918, 4918, 4918, 4919, 4931, 4933, 4934, 4934, 4934, 4937, 4943, 4946, 4946, 4946, 4951, 4954, 4954, 4954, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5006, 5006, 5006, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 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]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s5/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s5/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-s5/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0c24dff3f026501476361293f69b386a83731890 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"N": 7712, "t": 2510, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s5/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s5/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p52-erdos-squarefree-l1-s3/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l1-s3/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..58ab9a279d649b8bfcfee7c2dc400fa490b14b0f --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"N": 39, "t": 2, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l1-s3/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..64edc60b2777c8ab206ef2453c453061679e49f0 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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' +{"A": [7, 32]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l1-s3/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l1-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-l1-s3/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..58ab9a279d649b8bfcfee7c2dc400fa490b14b0f --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"N": 39, "t": 2, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l1-s3/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l1-s3/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l2-s6/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l2-s6/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..830b908c8afe1bb9f86ae66a8e2fa5feae034e1c --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"N": 151, "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-s6/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6f3206b25fb9108a5347aaafc757373cd8f98f09 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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' +{"A": [7, 32, 57, 82, 107, 132]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s6/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s6/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-s6/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..830b908c8afe1bb9f86ae66a8e2fa5feae034e1c --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"N": 151, "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-s6/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l2-s6/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l5-s2/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l5-s2/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..da9de065f042cdce569bbe50ce8d3044b42dc3c7 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"N": 8705, "t": 348, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l5-s2/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..aa7bf5ee5627d6a7f4cfd2e580586e641b426d30 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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' +{"A": [7, 32, 57, 82, 107, 132, 157, 182, 207, 232, 257, 282, 307, 332, 357, 382, 407, 432, 457, 482, 507, 532, 557, 582, 607, 632, 657, 682, 707, 732, 757, 782, 807, 832, 857, 882, 907, 932, 957, 982, 1007, 1032, 1057, 1082, 1107, 1132, 1157, 1182, 1207, 1232, 1257, 1282, 1307, 1332, 1357, 1382, 1407, 1432, 1457, 1482, 1507, 1532, 1557, 1582, 1607, 1632, 1657, 1682, 1707, 1732, 1757, 1782, 1807, 1832, 1857, 1882, 1907, 1932, 1957, 1982, 2007, 2032, 2057, 2082, 2107, 2132, 2157, 2182, 2207, 2232, 2257, 2282, 2307, 2332, 2357, 2382, 2407, 2432, 2457, 2482, 2507, 2532, 2557, 2582, 2607, 2632, 2657, 2682, 2707, 2732, 2757, 2782, 2807, 2832, 2857, 2882, 2907, 2932, 2957, 2982, 3007, 3032, 3057, 3082, 3107, 3132, 3157, 3182, 3207, 3232, 3257, 3282, 3307, 3332, 3357, 3382, 3407, 3432, 3457, 3482, 3507, 3532, 3557, 3582, 3607, 3632, 3657, 3682, 3707, 3732, 3757, 3782, 3807, 3832, 3857, 3882, 3907, 3932, 3957, 3982, 4007, 4032, 4057, 4082, 4107, 4132, 4157, 4182, 4207, 4232, 4257, 4282, 4307, 4332, 4357, 4382, 4407, 4432, 4457, 4482, 4507, 4532, 4557, 4582, 4607, 4632, 4657, 4682, 4707, 4732, 4757, 4782, 4807, 4832, 4857, 4882, 4907, 4932, 4957, 4982, 5007, 5032, 5057, 5082, 5107, 5132, 5157, 5182, 5207, 5232, 5257, 5282, 5307, 5332, 5357, 5382, 5407, 5432, 5457, 5482, 5507, 5532, 5557, 5582, 5607, 5632, 5657, 5682, 5707, 5732, 5757, 5782, 5807, 5832, 5857, 5882, 5907, 5932, 5957, 5982, 6007, 6032, 6057, 6082, 6107, 6132, 6157, 6182, 6207, 6232, 6257, 6282, 6307, 6332, 6357, 6382, 6407, 6432, 6457, 6482, 6507, 6532, 6557, 6582, 6607, 6632, 6657, 6682, 6707, 6732, 6757, 6782, 6807, 6832, 6857, 6882, 6907, 6932, 6957, 6982, 7007, 7032, 7057, 7082, 7107, 7132, 7157, 7182, 7207, 7232, 7257, 7282, 7307, 7332, 7357, 7382, 7407, 7432, 7457, 7482, 7507, 7532, 7557, 7582, 7607, 7632, 7657, 7682, 7707, 7732, 7757, 7782, 7807, 7832, 7857, 7882, 7907, 7932, 7957, 7982, 8007, 8032, 8057, 8082, 8107, 8132, 8157, 8182, 8207, 8232, 8257, 8282, 8307, 8332, 8357, 8382, 8407, 8432, 8457, 8482, 8507, 8532, 8557, 8582, 8607, 8632, 8657, 8682]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l5-s2/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l5-s2/tests/check.py @@ -0,0 +1,38 @@ +"""Erdos squarefree problem (AlphaEvolve problem 52): A in [1, N], |A| >= t, ab+1 NOT squarefree for all a, b in A +(a = b included). The repo's problem page says "square-free"; the notebook and the Erdos problem ask for +"never squarefree", which is what we check. Exact: for every pair we find a prime p with p^2 | ab+1.""" +import numpy as np + +from run import Invalid, int_list + + +def _primes(n): + s = np.ones(n + 1, dtype=bool) + s[:2] = False + for i in range(2, int(n ** .5) + 1): + if s[i]: + s[i * i::i] = False + return np.nonzero(s)[0] + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + a = ans.get("A") + if not isinstance(a, list) or not (t <= len(a) <= 2 * t + 20): + raise Invalid(f"A must be a list of {t}..{2 * t + 20} integers") + int_list(a, None, 1, n, "A") + if len(set(a)) != len(a): + raise Invalid("A must consist of distinct integers") + x = np.array(sorted(a), dtype=np.int64) + iu, ju = np.triu_indices(len(x)) + va, vb = x[iu], x[ju] + left = np.ones(len(iu), dtype=bool) # pairs without a square divisor found yet + for p in _primes(int((n * n + 1) ** .5) + 1): + q = int(p) * int(p) + idx = np.nonzero(left)[0] + hit = ((va[idx] % q) * (vb[idx] % q) + 1) % q == 0 + left[idx[hit]] = False + if not left.any(): + return None, {"size": len(a)} + k = int(np.nonzero(left)[0][0]) + raise Invalid(f"{int(va[k])}*{int(vb[k])}+1 = {int(va[k]) * int(vb[k]) + 1} is squarefree") diff --git a/tasks/construct-ae-p52-erdos-squarefree-l5-s2/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..da9de065f042cdce569bbe50ce8d3044b42dc3c7 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"N": 8705, "t": 348, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l5-s2/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l5-s2/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l5-s5/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l5-s5/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ec9038058747da2feb50c0b8ea5c1de650cf4756 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"N": 9722, "t": 389, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l5-s5/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e7cb20101f3d0addd93a7054be46cdbf1e7100b7 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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' +{"A": [7, 32, 57, 82, 107, 132, 157, 182, 207, 232, 257, 282, 307, 332, 357, 382, 407, 432, 457, 482, 507, 532, 557, 582, 607, 632, 657, 682, 707, 732, 757, 782, 807, 832, 857, 882, 907, 932, 957, 982, 1007, 1032, 1057, 1082, 1107, 1132, 1157, 1182, 1207, 1232, 1257, 1282, 1307, 1332, 1357, 1382, 1407, 1432, 1457, 1482, 1507, 1532, 1557, 1582, 1607, 1632, 1657, 1682, 1707, 1732, 1757, 1782, 1807, 1832, 1857, 1882, 1907, 1932, 1957, 1982, 2007, 2032, 2057, 2082, 2107, 2132, 2157, 2182, 2207, 2232, 2257, 2282, 2307, 2332, 2357, 2382, 2407, 2432, 2457, 2482, 2507, 2532, 2557, 2582, 2607, 2632, 2657, 2682, 2707, 2732, 2757, 2782, 2807, 2832, 2857, 2882, 2907, 2932, 2957, 2982, 3007, 3032, 3057, 3082, 3107, 3132, 3157, 3182, 3207, 3232, 3257, 3282, 3307, 3332, 3357, 3382, 3407, 3432, 3457, 3482, 3507, 3532, 3557, 3582, 3607, 3632, 3657, 3682, 3707, 3732, 3757, 3782, 3807, 3832, 3857, 3882, 3907, 3932, 3957, 3982, 4007, 4032, 4057, 4082, 4107, 4132, 4157, 4182, 4207, 4232, 4257, 4282, 4307, 4332, 4357, 4382, 4407, 4432, 4457, 4482, 4507, 4532, 4557, 4582, 4607, 4632, 4657, 4682, 4707, 4732, 4757, 4782, 4807, 4832, 4857, 4882, 4907, 4932, 4957, 4982, 5007, 5032, 5057, 5082, 5107, 5132, 5157, 5182, 5207, 5232, 5257, 5282, 5307, 5332, 5357, 5382, 5407, 5432, 5457, 5482, 5507, 5532, 5557, 5582, 5607, 5632, 5657, 5682, 5707, 5732, 5757, 5782, 5807, 5832, 5857, 5882, 5907, 5932, 5957, 5982, 6007, 6032, 6057, 6082, 6107, 6132, 6157, 6182, 6207, 6232, 6257, 6282, 6307, 6332, 6357, 6382, 6407, 6432, 6457, 6482, 6507, 6532, 6557, 6582, 6607, 6632, 6657, 6682, 6707, 6732, 6757, 6782, 6807, 6832, 6857, 6882, 6907, 6932, 6957, 6982, 7007, 7032, 7057, 7082, 7107, 7132, 7157, 7182, 7207, 7232, 7257, 7282, 7307, 7332, 7357, 7382, 7407, 7432, 7457, 7482, 7507, 7532, 7557, 7582, 7607, 7632, 7657, 7682, 7707, 7732, 7757, 7782, 7807, 7832, 7857, 7882, 7907, 7932, 7957, 7982, 8007, 8032, 8057, 8082, 8107, 8132, 8157, 8182, 8207, 8232, 8257, 8282, 8307, 8332, 8357, 8382, 8407, 8432, 8457, 8482, 8507, 8532, 8557, 8582, 8607, 8632, 8657, 8682, 8707, 8732, 8757, 8782, 8807, 8832, 8857, 8882, 8907, 8932, 8957, 8982, 9007, 9032, 9057, 9082, 9107, 9132, 9157, 9182, 9207, 9232, 9257, 9282, 9307, 9332, 9357, 9382, 9407, 9432, 9457, 9482, 9507, 9532, 9557, 9582, 9607, 9632, 9657, 9682, 9707]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l5-s5/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l5-s5/tests/check.py @@ -0,0 +1,38 @@ +"""Erdos squarefree problem (AlphaEvolve problem 52): A in [1, N], |A| >= t, ab+1 NOT squarefree for all a, b in A +(a = b included). The repo's problem page says "square-free"; the notebook and the Erdos problem ask for +"never squarefree", which is what we check. Exact: for every pair we find a prime p with p^2 | ab+1.""" +import numpy as np + +from run import Invalid, int_list + + +def _primes(n): + s = np.ones(n + 1, dtype=bool) + s[:2] = False + for i in range(2, int(n ** .5) + 1): + if s[i]: + s[i * i::i] = False + return np.nonzero(s)[0] + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + a = ans.get("A") + if not isinstance(a, list) or not (t <= len(a) <= 2 * t + 20): + raise Invalid(f"A must be a list of {t}..{2 * t + 20} integers") + int_list(a, None, 1, n, "A") + if len(set(a)) != len(a): + raise Invalid("A must consist of distinct integers") + x = np.array(sorted(a), dtype=np.int64) + iu, ju = np.triu_indices(len(x)) + va, vb = x[iu], x[ju] + left = np.ones(len(iu), dtype=bool) # pairs without a square divisor found yet + for p in _primes(int((n * n + 1) ** .5) + 1): + q = int(p) * int(p) + idx = np.nonzero(left)[0] + hit = ((va[idx] % q) * (vb[idx] % q) + 1) % q == 0 + left[idx[hit]] = False + if not left.any(): + return None, {"size": len(a)} + k = int(np.nonzero(left)[0][0]) + raise Invalid(f"{int(va[k])}*{int(vb[k])}+1 = {int(va[k]) * int(vb[k]) + 1} is squarefree") diff --git a/tasks/construct-ae-p52-erdos-squarefree-l5-s5/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ec9038058747da2feb50c0b8ea5c1de650cf4756 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"N": 9722, "t": 389, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l5-s5/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l5-s5/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-mc-all-interval-l2-s4/environment/Dockerfile b/tasks/construct-mc-all-interval-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-mc-all-interval-l2-s4/environment/instance.json b/tasks/construct-mc-all-interval-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..594b2921242aed684d8c1769fbb6313bb148638d --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 10, "fixed": [["x", 0, 0], ["x", 3, 8], ["d", 1, 8]], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l2-s4/solution/solve.sh b/tasks/construct-mc-all-interval-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5526d2a3686e270c76b5cd282e8c70dbdd9c8090 --- /dev/null +++ b/tasks/construct-mc-all-interval-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": [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l2-s4/tests/check.py b/tasks/construct-mc-all-interval-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s4/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-s4/tests/instance.json b/tasks/construct-mc-all-interval-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..594b2921242aed684d8c1769fbb6313bb148638d --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 10, "fixed": [["x", 0, 0], ["x", 3, 8], ["d", 1, 8]], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l2-s4/tests/run.py b/tasks/construct-mc-all-interval-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-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-mc-all-interval-l2-s4/tests/test.sh b/tasks/construct-mc-all-interval-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-l5-s0/environment/Dockerfile b/tasks/construct-mc-all-interval-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-all-interval-l5-s0/environment/instance.json b/tasks/construct-mc-all-interval-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1ed69eece5ca5708907ee5fdc95bc243acd4b0cd --- /dev/null +++ b/tasks/construct-mc-all-interval-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 44, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l5-s0/solution/solve.sh b/tasks/construct-mc-all-interval-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..abca0da1597102d4300dd33101217e4130e49e84 --- /dev/null +++ b/tasks/construct-mc-all-interval-l5-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [0, 43, 1, 42, 2, 41, 3, 40, 4, 39, 5, 38, 6, 37, 7, 36, 8, 35, 9, 34, 10, 33, 11, 32, 12, 31, 13, 30, 14, 29, 15, 28, 16, 27, 17, 26, 18, 25, 19, 24, 20, 23, 21, 22]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l5-s0/tests/check.py b/tasks/construct-mc-all-interval-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l5-s0/tests/check.py @@ -0,0 +1,17 @@ +"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + d = [abs(x[i + 1] - x[i]) for i in range(n - 1)] + if sorted(d) != list(range(1, n)): + raise Invalid("consecutive differences are not a permutation of 1..n-1") + seqs = {"x": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-all-interval-l5-s0/tests/instance.json b/tasks/construct-mc-all-interval-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1ed69eece5ca5708907ee5fdc95bc243acd4b0cd --- /dev/null +++ b/tasks/construct-mc-all-interval-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 44, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l5-s0/tests/run.py b/tasks/construct-mc-all-interval-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-all-interval-l5-s0/tests/test.sh b/tasks/construct-mc-all-interval-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-costas-array-l4-s2/environment/Dockerfile b/tasks/construct-mc-costas-array-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-costas-array-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-mc-costas-array-l4-s2/environment/instance.json b/tasks/construct-mc-costas-array-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9b864fde1b9491783f2bc47ec7e2148ddd738222 --- /dev/null +++ b/tasks/construct-mc-costas-array-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "fixed": [], "family": "mc_costas_array", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-costas-array-l4-s2/solution/solve.sh b/tasks/construct-mc-costas-array-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..621512f03fea2cbdcbb3234e13559457e0bc5700 --- /dev/null +++ b/tasks/construct-mc-costas-array-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' +{"x": [0, 13, 5, 7, 16, 9, 6, 2, 3, 17, 4, 12, 10, 1, 8, 11, 15, 14]} +RLMATH_EOF diff --git a/tasks/construct-mc-costas-array-l4-s2/tests/check.py b/tasks/construct-mc-costas-array-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c86323a5b639b23787ecd4d5f358b986bbd91b6c --- /dev/null +++ b/tasks/construct-mc-costas-array-l4-s2/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-s2/tests/instance.json b/tasks/construct-mc-costas-array-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9b864fde1b9491783f2bc47ec7e2148ddd738222 --- /dev/null +++ b/tasks/construct-mc-costas-array-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "fixed": [], "family": "mc_costas_array", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-costas-array-l4-s2/tests/run.py b/tasks/construct-mc-costas-array-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-costas-array-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-mc-costas-array-l4-s2/tests/test.sh b/tasks/construct-mc-costas-array-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-costas-array-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-mc-graceful-graph-l1-s2/environment/Dockerfile b/tasks/construct-mc-graceful-graph-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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-graceful-graph-l1-s2/environment/instance.json b/tasks/construct-mc-graceful-graph-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5e034e2fd64826a01f65804f289b89240febbbce --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"k": 2, "p": 3, "num_vertices": 6, "edges": [[0, 1], [2, 3], [4, 5], [0, 2], [1, 3], [2, 4], [3, 5]], "fixed": [["labels", 2, 7], ["d", 6, 3]], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l1-s2/solution/solve.sh b/tasks/construct-mc-graceful-graph-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d41b0ee4944f012a5e5c5560bcfd0711790274e2 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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' +{"labels": [0, 2, 7, 3, 1, 6]} +RLMATH_EOF diff --git a/tasks/construct-mc-graceful-graph-l1-s2/tests/check.py b/tasks/construct-mc-graceful-graph-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f4d33af1d63c0495c3b32d34db6ae10f0fb45923 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l1-s2/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-s2/tests/instance.json b/tasks/construct-mc-graceful-graph-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5e034e2fd64826a01f65804f289b89240febbbce --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"k": 2, "p": 3, "num_vertices": 6, "edges": [[0, 1], [2, 3], [4, 5], [0, 2], [1, 3], [2, 4], [3, 5]], "fixed": [["labels", 2, 7], ["d", 6, 3]], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l1-s2/tests/run.py b/tasks/construct-mc-graceful-graph-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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-graceful-graph-l1-s2/tests/test.sh b/tasks/construct-mc-graceful-graph-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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-graph-k-coloring-l2-s1/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-graph-k-coloring-l2-s1/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..106f8ed35cd83984481f009bbe7cfac149488d10 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 34, "k": 4, "edges": [[0, 8], [0, 12], [0, 21], [0, 28], [0, 29], [0, 30], [0, 33], [1, 17], [1, 28], [1, 31], [2, 6], [2, 18], [2, 21], [2, 26], [3, 12], [3, 18], [3, 23], [3, 33], [4, 17], [4, 19], [4, 20], [4, 21], [4, 22], [4, 24], [4, 28], [4, 32], [5, 6], [5, 10], [5, 17], [5, 19], [5, 28], [6, 16], [6, 20], [6, 27], [7, 24], [7, 27], [8, 16], [8, 18], [8, 31], [9, 19], [9, 20], [9, 26], [10, 13], [10, 14], [10, 16], [10, 20], [10, 21], [10, 26], [10, 32], [11, 14], [11, 18], [11, 23], [11, 26], [11, 30], [11, 32], [12, 14], [12, 21], [12, 22], [12, 24], [12, 30], [13, 22], [13, 24], [13, 27], [14, 17], [14, 25], [14, 27], [14, 28], [14, 31], [15, 22], [15, 23], [15, 28], [15, 31], [16, 24], [16, 25], [16, 28], [16, 32], [17, 19], [17, 25], [17, 26], [17, 29], [17, 33], [18, 21], [18, 25], [18, 33], [19, 22], [19, 23], [19, 26], [19, 28], [19, 32], [20, 22], [20, 24], [20, 27], [20, 28], [21, 26], [21, 28], [22, 23], [22, 28], [23, 24], [23, 28], [23, 31], [25, 26], [25, 27], [25, 29], [25, 30], [25, 31], [25, 33], [26, 29], [26, 32], [29, 33], [30, 32], [31, 32]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l2-s1/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2d41fb1f29848baa5ee7d368d71be646aab8914e --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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": [0, 1, 2, 3, 1, 1, 0, 1, 3, 0, 2, 2, 2, 1, 1, 3, 1, 0, 0, 3, 3, 3, 0, 1, 0, 3, 1, 2, 2, 2, 1, 2, 0, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l2-s1/tests/check.py b/tasks/construct-mc-graph-k-coloring-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l2-s1/tests/check.py @@ -0,0 +1,11 @@ +"""Proper k-colouring of a given graph (MathConstraint graph_k_coloring, CC-BY-4.0). Any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-mc-graph-k-coloring-l2-s1/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..106f8ed35cd83984481f009bbe7cfac149488d10 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 34, "k": 4, "edges": [[0, 8], [0, 12], [0, 21], [0, 28], [0, 29], [0, 30], [0, 33], [1, 17], [1, 28], [1, 31], [2, 6], [2, 18], [2, 21], [2, 26], [3, 12], [3, 18], [3, 23], [3, 33], [4, 17], [4, 19], [4, 20], [4, 21], [4, 22], [4, 24], [4, 28], [4, 32], [5, 6], [5, 10], [5, 17], [5, 19], [5, 28], [6, 16], [6, 20], [6, 27], [7, 24], [7, 27], [8, 16], [8, 18], [8, 31], [9, 19], [9, 20], [9, 26], [10, 13], [10, 14], [10, 16], [10, 20], [10, 21], [10, 26], [10, 32], [11, 14], [11, 18], [11, 23], [11, 26], [11, 30], [11, 32], [12, 14], [12, 21], [12, 22], [12, 24], [12, 30], [13, 22], [13, 24], [13, 27], [14, 17], [14, 25], [14, 27], [14, 28], [14, 31], [15, 22], [15, 23], [15, 28], [15, 31], [16, 24], [16, 25], [16, 28], [16, 32], [17, 19], [17, 25], [17, 26], [17, 29], [17, 33], [18, 21], [18, 25], [18, 33], [19, 22], [19, 23], [19, 26], [19, 28], [19, 32], [20, 22], [20, 24], [20, 27], [20, 28], [21, 26], [21, 28], [22, 23], [22, 28], [23, 24], [23, 28], [23, 31], [25, 26], [25, 27], [25, 29], [25, 30], [25, 31], [25, 33], [26, 29], [26, 32], [29, 33], [30, 32], [31, 32]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l2-s1/tests/run.py b/tasks/construct-mc-graph-k-coloring-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-graph-k-coloring-l2-s1/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-graph-k-coloring-l6-s9/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-mc-graph-k-coloring-l6-s9/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e7b8272c47c3df25cdadb765c7260f47a915ef99 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 250, "k": 4, "edges": [[0, 7], [0, 31], [0, 75], [0, 99], [0, 104], [0, 126], [0, 136], [0, 139], [0, 204], [0, 207], [0, 209], [1, 2], [1, 14], [1, 19], [1, 110], [1, 135], [2, 12], [2, 23], [2, 25], [2, 57], [2, 61], [2, 96], [2, 100], [2, 131], [2, 203], [2, 226], [2, 227], [3, 52], [3, 53], [3, 74], [3, 126], [3, 153], [4, 62], [4, 84], [4, 100], [4, 149], [4, 158], [4, 159], [5, 19], [5, 76], [5, 112], [5, 119], [5, 123], [5, 187], [5, 220], [5, 242], [6, 45], [6, 86], [6, 118], [6, 125], [6, 132], [6, 133], [6, 172], [6, 176], [6, 187], [6, 191], [6, 198], [6, 218], [6, 222], [7, 52], [7, 114], [7, 157], [7, 200], [7, 225], [7, 234], [7, 249], [8, 19], [8, 39], [8, 40], [8, 42], [8, 51], [8, 65], [8, 82], [8, 84], [8, 86], [8, 107], [9, 20], [9, 37], [9, 55], [9, 56], [9, 64], [9, 75], [9, 156], [9, 246], [10, 12], [10, 17], [10, 32], [10, 46], [10, 48], [10, 83], [10, 88], [10, 248], [11, 41], [11, 71], [11, 80], [11, 96], [11, 107], [11, 130], [11, 147], [11, 150], [11, 211], [11, 228], [11, 244], [12, 30], [12, 34], [12, 53], [12, 87], [12, 92], [12, 157], [12, 169], [12, 247], [13, 140], [13, 163], [13, 191], [13, 192], [13, 222], [14, 18], [14, 42], [14, 45], [14, 46], [14, 113], [14, 123], [14, 158], [14, 207], [14, 212], [15, 19], [15, 43], [15, 114], [15, 129], [15, 152], [15, 198], [15, 210], [16, 36], [16, 54], [16, 68], [16, 117], [16, 139], [16, 142], [16, 156], [16, 160], [16, 181], [16, 206], [16, 215], [16, 230], [17, 43], [17, 65], [17, 90], [17, 95], [17, 217], [17, 223], [17, 231], [17, 246], [18, 84], [18, 102], [18, 110], [18, 199], [18, 244], [18, 247], [19, 48], [19, 98], [19, 156], [19, 165], [19, 237], [20, 31], [20, 99], [20, 138], [20, 142], [20, 161], [20, 172], [20, 175], [20, 222], [20, 244], [20, 248], [21, 49], [21, 50], [21, 54], [21, 108], [21, 110], [21, 132], [21, 155], [21, 224], [21, 234], [22, 72], [22, 81], [22, 114], [22, 115], [22, 144], [22, 233], [23, 37], [23, 48], [23, 79], [23, 116], [23, 120], [23, 187], [23, 203], [23, 217], [24, 48], [24, 111], [24, 120], [24, 138], [24, 144], [24, 190], [24, 192], [24, 202], [24, 241], [25, 40], [25, 53], [25, 158], [25, 189], [26, 31], [26, 32], [26, 100], [26, 122], [26, 145], [26, 179], [26, 204], [26, 211], [26, 239], [27, 81], [27, 121], [27, 148], [27, 160], [27, 169], [27, 225], [27, 247], [28, 42], [28, 64], [28, 74], [28, 90], [28, 131], [28, 133], [28, 134], [28, 210], [28, 236], [28, 249], [29, 52], [29, 83], [29, 101], [29, 215], [29, 223], [29, 231], [30, 33], [30, 38], [30, 61], [30, 63], [30, 95], [30, 99], [30, 107], [30, 227], [31, 43], [31, 73], [31, 86], [31, 87], [31, 89], [31, 93], [31, 114], [31, 155], [31, 169], [31, 173], [31, 174], [31, 233], [31, 246], [32, 41], [32, 71], [32, 137], [32, 226], [32, 241], [33, 48], [33, 51], [33, 76], [33, 89], [33, 93], [33, 139], [33, 217], [34, 35], [34, 57], [34, 107], [34, 114], [34, 164], [34, 172], [35, 50], [35, 54], [35, 71], [35, 83], [35, 86], [35, 91], [35, 140], [35, 234], [36, 56], [36, 64], [36, 81], [36, 109], [36, 134], [36, 176], [36, 182], [36, 186], [36, 187], [36, 191], [36, 197], [36, 220], [36, 222], [36, 239], [37, 80], [37, 89], [37, 139], [37, 154], [37, 202], [37, 227], [37, 230], [37, 240], [37, 243], [38, 72], [38, 95], [38, 98], [38, 201], [39, 49], [39, 54], [39, 67], [39, 78], [39, 180], [39, 194], [39, 240], [40, 43], [40, 67], [40, 95], [40, 113], [40, 122], [40, 154], [40, 185], [40, 191], [40, 249], [41, 55], [41, 57], [41, 60], [41, 109], [41, 115], [41, 123], [41, 209], [41, 215], [41, 217], [41, 232], [41, 240], [42, 78], [42, 81], [42, 126], [42, 127], [42, 175], [42, 203], [42, 219], [42, 222], [42, 227], [42, 237], [43, 126], [43, 180], [43, 187], [43, 197], [43, 198], [43, 235], [43, 237], [44, 56], [44, 87], [44, 154], [44, 158], [44, 172], [44, 207], [45, 62], [45, 92], [45, 128], [45, 159], [45, 168], [45, 198], [45, 208], [45, 219], [45, 231], [45, 243], [46, 63], [46, 113], [46, 117], [46, 127], [46, 132], [46, 150], [46, 171], [46, 229], [46, 248], [47, 57], [47, 62], [47, 122], [47, 192], [47, 196], [47, 198], [47, 234], [47, 236], [48, 49], [48, 111], [48, 119], [48, 128], [48, 155], [48, 184], [48, 190], [48, 198], [49, 143], [49, 144], [49, 195], [49, 220], [50, 86], [50, 93], [50, 120], [50, 146], [50, 158], [50, 166], [51, 66], [51, 80], [51, 109], [51, 112], [51, 114], [51, 185], [51, 186], [51, 223], [51, 233], [51, 237], [52, 87], [52, 97], [52, 105], [52, 158], [52, 208], [52, 214], [52, 222], [53, 59], [53, 110], [53, 116], [53, 140], [53, 146], [53, 168], [53, 234], [53, 246], [54, 75], [54, 106], [54, 166], [54, 236], [54, 241], [54, 243], [55, 83], [55, 176], [55, 186], [55, 201], [55, 227], [56, 60], [56, 137], [56, 152], [56, 169], [56, 183], [56, 249], [57, 152], [57, 188], [57, 233], [58, 68], [58, 106], [58, 129], [58, 135], [58, 139], [58, 155], [58, 172], [58, 175], [58, 243], [59, 96], [59, 98], [59, 159], [59, 196], [60, 66], [60, 74], [60, 78], [60, 130], [60, 236], [61, 82], [61, 98], [61, 123], [61, 170], [61, 224], [62, 99], [62, 145], [62, 160], [62, 214], [62, 234], [63, 75], [63, 123], [63, 160], [63, 184], [63, 204], [63, 218], [64, 96], [64, 145], [64, 191], [65, 88], [65, 109], [65, 131], [65, 133], [65, 185], [65, 194], [65, 196], [65, 218], [65, 231], [65, 245], [66, 86], [66, 118], [66, 158], [66, 238], [67, 76], [67, 79], [67, 85], [67, 143], [67, 163], [67, 176], [67, 204], [67, 208], [67, 217], [67, 220], [67, 242], [67, 249], [68, 85], [68, 137], [68, 148], [68, 210], [68, 235], [68, 236], [68, 244], [68, 245], [69, 75], [69, 101], [69, 142], [69, 212], [69, 233], [69, 249], [70, 84], [70, 109], [70, 181], [70, 206], [70, 231], [71, 102], [71, 103], [71, 104], [71, 120], [71, 133], [71, 181], [71, 186], [71, 195], [71, 218], [71, 228], [72, 91], [72, 152], [72, 153], [72, 165], [72, 173], [72, 215], [72, 242], [73, 102], [73, 112], [73, 123], [73, 149], [73, 196], [73, 227], [73, 240], [74, 86], [74, 99], [74, 101], [74, 102], [74, 164], [74, 171], [74, 195], [74, 229], [75, 205], [75, 208], [75, 227], [76, 96], [76, 107], [76, 149], [76, 204], [76, 215], [76, 229], [77, 84], [77, 141], [77, 145], [77, 213], [78, 92], [78, 105], [78, 125], [78, 149], [78, 188], [78, 204], [78, 222], [78, 229], [78, 249], [79, 160], [80, 103], [80, 114], [80, 142], [80, 190], [80, 191], [80, 200], [81, 114], [81, 151], [81, 198], [81, 226], [81, 241], [81, 242], [82, 105], [82, 185], [82, 232], [83, 98], [83, 123], [83, 126], [83, 161], [83, 207], [83, 234], [84, 124], [84, 139], [84, 141], [84, 169], [84, 181], [84, 188], [84, 228], [84, 245], [85, 114], [85, 125], [85, 131], [85, 155], [85, 220], [85, 238], [86, 191], [86, 198], [87, 145], [87, 207], [87, 232], [88, 140], [88, 157], [88, 168], [88, 183], [89, 225], [89, 237], [90, 93], [90, 111], [90, 243], [91, 92], [91, 149], [91, 154], [91, 184], [91, 187], [91, 206], [91, 235], [92, 113], [92, 150], [92, 171], [92, 192], [93, 99], [93, 108], [93, 121], [93, 140], [93, 150], [93, 160], [93, 171], [93, 223], [93, 230], [93, 237], [93, 243], [94, 112], [94, 129], [94, 144], [94, 156], [94, 165], [94, 172], [94, 189], [94, 231], [95, 101], [95, 122], [95, 127], [95, 129], [95, 140], [95, 159], [95, 215], [96, 105], [96, 121], [96, 203], [96, 220], [96, 222], [96, 246], [97, 127], [97, 144], [97, 147], [97, 197], [97, 228], [98, 127], [98, 137], [98, 182], [98, 208], [98, 233], [99, 106], [99, 113], [99, 126], [99, 174], [99, 179], [99, 209], [99, 221], [99, 236], [99, 240], [99, 241], [100, 118], [100, 169], [100, 199], [100, 204], [100, 221], [100, 247], [101, 122], [101, 152], [101, 161], [101, 220], [102, 136], [102, 242], [103, 114], [103, 186], [103, 201], [103, 229], [104, 110], [104, 160], [104, 172], [104, 192], [104, 223], [105, 114], [105, 148], [105, 191], [106, 214], [106, 234], [106, 249], [107, 134], [107, 141], [107, 154], [107, 168], [107, 169], [107, 175], [108, 127], [108, 140], [108, 161], [108, 197], [108, 204], [108, 205], [109, 111], [109, 143], [109, 168], [109, 180], [109, 225], [109, 243], [110, 119], [110, 149], [110, 153], [110, 212], [110, 244], [111, 143], [111, 181], [111, 216], [112, 150], [112, 162], [112, 191], [112, 201], [112, 206], [113, 115], [113, 122], [113, 150], [113, 191], [113, 201], [113, 230], [113, 243], [114, 124], [114, 176], [114, 244], [115, 119], [115, 123], [115, 138], [115, 180], [115, 200], [115, 214], [115, 218], [115, 231], [116, 147], [116, 176], [116, 191], [116, 192], [116, 234], [116, 243], [117, 208], [117, 220], [118, 132], [118, 191], [118, 206], [118, 207], [118, 248], [120, 148], [120, 162], [120, 175], [120, 226], [120, 241], [121, 131], [121, 180], [121, 209], [121, 243], [122, 163], [122, 190], [122, 191], [122, 200], [122, 205], [122, 212], [122, 238], [122, 245], [123, 141], [123, 151], [123, 174], [124, 204], [124, 205], [124, 210], [125, 140], [125, 170], [125, 188], [126, 132], [126, 148], [126, 173], [126, 180], [127, 145], [127, 150], [127, 202], [127, 220], [128, 134], [128, 138], [128, 153], [129, 132], [129, 148], [129, 211], [129, 225], [130, 135], [130, 149], [130, 150], [130, 161], [130, 169], [130, 198], [131, 134], [131, 184], [131, 212], [131, 236], [132, 169], [132, 175], [132, 219], [132, 240], [133, 143], [133, 198], [133, 217], [133, 225], [134, 168], [134, 175], [134, 194], [134, 202], [134, 224], [135, 140], [135, 206], [136, 158], [136, 196], [136, 201], [136, 204], [137, 161], [137, 162], [137, 231], [137, 239], [137, 240], [138, 163], [138, 165], [138, 205], [138, 216], [138, 223], [138, 232], [139, 152], [139, 160], [139, 220], [140, 161], [140, 163], [140, 171], [140, 241], [141, 143], [141, 207], [141, 249], [142, 215], [142, 221], [142, 226], [143, 149], [143, 180], [143, 187], [143, 215], [143, 233], [144, 154], [144, 163], [144, 169], [144, 170], [144, 174], [144, 179], [145, 161], [145, 231], [146, 220], [147, 148], [147, 162], [147, 201], [147, 225], [147, 239], [148, 166], [148, 194], [148, 219], [149, 152], [149, 207], [150, 181], [150, 193], [150, 197], [150, 219], [150, 221], [150, 232], [150, 244], [151, 173], [151, 177], [151, 186], [151, 202], [151, 228], [152, 167], [152, 177], [152, 202], [152, 219], [152, 238], [153, 181], [153, 209], [153, 215], [154, 158], [154, 168], [154, 190], [154, 236], [155, 211], [155, 232], [155, 237], [156, 168], [156, 171], [156, 183], [156, 187], [156, 219], [156, 229], [156, 246], [157, 180], [157, 181], [158, 169], [158, 198], [158, 225], [158, 231], [158, 249], [159, 161], [159, 167], [159, 172], [159, 186], [159, 189], [160, 232], [162, 164], [162, 195], [162, 206], [162, 218], [163, 167], [164, 187], [164, 201], [165, 202], [165, 236], [165, 245], [166, 169], [166, 245], [166, 249], [167, 171], [167, 178], [167, 215], [167, 230], [168, 200], [168, 244], [168, 248], [169, 187], [169, 199], [170, 192], [170, 206], [170, 208], [170, 218], [170, 222], [171, 200], [171, 212], [171, 215], [172, 187], [173, 176], [173, 209], [173, 222], [174, 200], [174, 244], [175, 218], [176, 178], [176, 208], [176, 226], [177, 181], [177, 215], [178, 188], [178, 204], [178, 211], [178, 249], [179, 186], [179, 231], [179, 235], [179, 241], [180, 227], [180, 228], [180, 238], [183, 190], [183, 245], [184, 193], [184, 248], [185, 186], [186, 193], [186, 234], [187, 218], [187, 230], [188, 207], [188, 231], [188, 239], [189, 191], [189, 203], [189, 207], [189, 231], [189, 234], [190, 219], [190, 226], [191, 223], [192, 195], [192, 218], [192, 232], [192, 235], [193, 203], [193, 209], [194, 202], [194, 218], [194, 244], [196, 243], [197, 215], [197, 221], [200, 208], [200, 213], [201, 223], [202, 209], [202, 220], [202, 232], [204, 229], [205, 219], [205, 225], [205, 229], [206, 223], [207, 229], [208, 241], [209, 217], [209, 221], [209, 249], [210, 217], [210, 218], [211, 216], [212, 244], [214, 238], [215, 238], [217, 223], [221, 223], [224, 226], [224, 249], [230, 247], [231, 244], [234, 246], [235, 237], [235, 240], [244, 248]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l6-s9/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ada1236298e4b9744b5a2653288ec34ade4df7db --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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": [0, 1, 0, 1, 3, 2, 2, 3, 2, 1, 0, 3, 2, 3, 2, 1, 0, 1, 3, 3, 0, 3, 3, 2, 2, 2, 0, 0, 3, 0, 3, 1, 3, 0, 1, 3, 3, 0, 2, 0, 3, 0, 0, 0, 2, 1, 3, 1, 1, 2, 1, 3, 2, 0, 1, 2, 0, 3, 1, 1, 3, 1, 0, 0, 0, 0, 2, 2, 3, 0, 2, 0, 1, 2, 2, 2, 3, 1, 2, 0, 2, 1, 0, 1, 0, 1, 0, 0, 1, 3, 0, 2, 3, 3, 1, 0, 2, 3, 0, 1, 2, 1, 1, 3, 1, 3, 0, 0, 0, 1, 2, 3, 0, 0, 0, 2, 3, 2, 0, 3, 3, 1, 2, 3, 2, 3, 2, 1, 0, 3, 0, 2, 1, 1, 1, 3, 2, 1, 3, 3, 2, 2, 1, 0, 0, 2, 3, 0, 1, 1, 2, 2, 2, 3, 1, 0, 2, 0, 0, 2, 2, 3, 2, 1, 0, 2, 2, 3, 3, 3, 2, 0, 3, 3, 2, 2, 1, 3, 0, 2, 3, 1, 1, 3, 3, 2, 1, 1, 1, 0, 0, 1, 0, 0, 2, 1, 3, 1, 3, 0, 1, 1, 3, 3, 1, 1, 1, 3, 3, 2, 0, 1, 3, 0, 1, 2, 0, 3, 3, 3, 0, 3, 1, 2, 0, 2, 2, 1, 1, 0, 2, 3, 1, 2, 2, 1, 0, 2, 0, 2, 3, 0, 0, 2, 1, 1, 3, 1, 2, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l6-s9/tests/check.py b/tasks/construct-mc-graph-k-coloring-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l6-s9/tests/check.py @@ -0,0 +1,11 @@ +"""Proper k-colouring of a given graph (MathConstraint graph_k_coloring, CC-BY-4.0). Any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-mc-graph-k-coloring-l6-s9/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e7b8272c47c3df25cdadb765c7260f47a915ef99 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 250, "k": 4, "edges": [[0, 7], [0, 31], [0, 75], [0, 99], [0, 104], [0, 126], [0, 136], [0, 139], [0, 204], [0, 207], [0, 209], [1, 2], [1, 14], [1, 19], [1, 110], [1, 135], [2, 12], [2, 23], [2, 25], [2, 57], [2, 61], [2, 96], [2, 100], [2, 131], [2, 203], [2, 226], [2, 227], [3, 52], [3, 53], [3, 74], [3, 126], [3, 153], [4, 62], [4, 84], [4, 100], [4, 149], [4, 158], [4, 159], [5, 19], [5, 76], [5, 112], [5, 119], [5, 123], [5, 187], [5, 220], [5, 242], [6, 45], [6, 86], [6, 118], [6, 125], [6, 132], [6, 133], [6, 172], [6, 176], [6, 187], [6, 191], [6, 198], [6, 218], [6, 222], [7, 52], [7, 114], [7, 157], [7, 200], [7, 225], [7, 234], [7, 249], [8, 19], [8, 39], [8, 40], [8, 42], [8, 51], [8, 65], [8, 82], [8, 84], [8, 86], [8, 107], [9, 20], [9, 37], [9, 55], [9, 56], [9, 64], [9, 75], [9, 156], [9, 246], [10, 12], [10, 17], [10, 32], [10, 46], [10, 48], [10, 83], [10, 88], [10, 248], [11, 41], [11, 71], [11, 80], [11, 96], [11, 107], [11, 130], [11, 147], [11, 150], [11, 211], [11, 228], [11, 244], [12, 30], [12, 34], [12, 53], [12, 87], [12, 92], [12, 157], [12, 169], [12, 247], [13, 140], [13, 163], [13, 191], [13, 192], [13, 222], [14, 18], [14, 42], [14, 45], [14, 46], [14, 113], [14, 123], [14, 158], [14, 207], [14, 212], [15, 19], [15, 43], [15, 114], [15, 129], [15, 152], [15, 198], [15, 210], [16, 36], [16, 54], [16, 68], [16, 117], [16, 139], [16, 142], [16, 156], [16, 160], [16, 181], [16, 206], [16, 215], [16, 230], [17, 43], [17, 65], [17, 90], [17, 95], [17, 217], [17, 223], [17, 231], [17, 246], [18, 84], [18, 102], [18, 110], [18, 199], [18, 244], [18, 247], [19, 48], [19, 98], [19, 156], [19, 165], [19, 237], [20, 31], [20, 99], [20, 138], [20, 142], [20, 161], [20, 172], [20, 175], [20, 222], [20, 244], [20, 248], [21, 49], [21, 50], [21, 54], [21, 108], [21, 110], [21, 132], [21, 155], [21, 224], [21, 234], [22, 72], [22, 81], [22, 114], [22, 115], [22, 144], [22, 233], [23, 37], [23, 48], [23, 79], [23, 116], [23, 120], [23, 187], [23, 203], [23, 217], [24, 48], [24, 111], [24, 120], [24, 138], [24, 144], [24, 190], [24, 192], [24, 202], [24, 241], [25, 40], [25, 53], [25, 158], [25, 189], [26, 31], [26, 32], [26, 100], [26, 122], [26, 145], [26, 179], [26, 204], [26, 211], [26, 239], [27, 81], [27, 121], [27, 148], [27, 160], [27, 169], [27, 225], [27, 247], [28, 42], [28, 64], [28, 74], [28, 90], [28, 131], [28, 133], [28, 134], [28, 210], [28, 236], [28, 249], [29, 52], [29, 83], [29, 101], [29, 215], [29, 223], [29, 231], [30, 33], [30, 38], [30, 61], [30, 63], [30, 95], [30, 99], [30, 107], [30, 227], [31, 43], [31, 73], [31, 86], [31, 87], [31, 89], [31, 93], [31, 114], [31, 155], [31, 169], [31, 173], [31, 174], [31, 233], [31, 246], [32, 41], [32, 71], [32, 137], [32, 226], [32, 241], [33, 48], [33, 51], [33, 76], [33, 89], [33, 93], [33, 139], [33, 217], [34, 35], [34, 57], [34, 107], [34, 114], [34, 164], [34, 172], [35, 50], [35, 54], [35, 71], [35, 83], [35, 86], [35, 91], [35, 140], [35, 234], [36, 56], [36, 64], [36, 81], [36, 109], [36, 134], [36, 176], [36, 182], [36, 186], [36, 187], [36, 191], [36, 197], [36, 220], [36, 222], [36, 239], [37, 80], [37, 89], [37, 139], [37, 154], [37, 202], [37, 227], [37, 230], [37, 240], [37, 243], [38, 72], [38, 95], [38, 98], [38, 201], [39, 49], [39, 54], [39, 67], [39, 78], [39, 180], [39, 194], [39, 240], [40, 43], [40, 67], [40, 95], [40, 113], [40, 122], [40, 154], [40, 185], [40, 191], [40, 249], [41, 55], [41, 57], [41, 60], [41, 109], [41, 115], [41, 123], [41, 209], [41, 215], [41, 217], [41, 232], [41, 240], [42, 78], [42, 81], [42, 126], [42, 127], [42, 175], [42, 203], [42, 219], [42, 222], [42, 227], [42, 237], [43, 126], [43, 180], [43, 187], [43, 197], [43, 198], [43, 235], [43, 237], [44, 56], [44, 87], [44, 154], [44, 158], [44, 172], [44, 207], [45, 62], [45, 92], [45, 128], [45, 159], [45, 168], [45, 198], [45, 208], [45, 219], [45, 231], [45, 243], [46, 63], [46, 113], [46, 117], [46, 127], [46, 132], [46, 150], [46, 171], [46, 229], [46, 248], [47, 57], [47, 62], [47, 122], [47, 192], [47, 196], [47, 198], [47, 234], [47, 236], [48, 49], [48, 111], [48, 119], [48, 128], [48, 155], [48, 184], [48, 190], [48, 198], [49, 143], [49, 144], [49, 195], [49, 220], [50, 86], [50, 93], [50, 120], [50, 146], [50, 158], [50, 166], [51, 66], [51, 80], [51, 109], [51, 112], [51, 114], [51, 185], [51, 186], [51, 223], [51, 233], [51, 237], [52, 87], [52, 97], [52, 105], [52, 158], [52, 208], [52, 214], [52, 222], [53, 59], [53, 110], [53, 116], [53, 140], [53, 146], [53, 168], [53, 234], [53, 246], [54, 75], [54, 106], [54, 166], [54, 236], [54, 241], [54, 243], [55, 83], [55, 176], [55, 186], [55, 201], [55, 227], [56, 60], [56, 137], [56, 152], [56, 169], [56, 183], [56, 249], [57, 152], [57, 188], [57, 233], [58, 68], [58, 106], [58, 129], [58, 135], [58, 139], [58, 155], [58, 172], [58, 175], [58, 243], [59, 96], [59, 98], [59, 159], [59, 196], [60, 66], [60, 74], [60, 78], [60, 130], [60, 236], [61, 82], [61, 98], [61, 123], [61, 170], [61, 224], [62, 99], [62, 145], [62, 160], [62, 214], [62, 234], [63, 75], [63, 123], [63, 160], [63, 184], [63, 204], [63, 218], [64, 96], [64, 145], [64, 191], [65, 88], [65, 109], [65, 131], [65, 133], [65, 185], [65, 194], [65, 196], [65, 218], [65, 231], [65, 245], [66, 86], [66, 118], [66, 158], [66, 238], [67, 76], [67, 79], [67, 85], [67, 143], [67, 163], [67, 176], [67, 204], [67, 208], [67, 217], [67, 220], [67, 242], [67, 249], [68, 85], [68, 137], [68, 148], [68, 210], [68, 235], [68, 236], [68, 244], [68, 245], [69, 75], [69, 101], [69, 142], [69, 212], [69, 233], [69, 249], [70, 84], [70, 109], [70, 181], [70, 206], [70, 231], [71, 102], [71, 103], [71, 104], [71, 120], [71, 133], [71, 181], [71, 186], [71, 195], [71, 218], [71, 228], [72, 91], [72, 152], [72, 153], [72, 165], [72, 173], [72, 215], [72, 242], [73, 102], [73, 112], [73, 123], [73, 149], [73, 196], [73, 227], [73, 240], [74, 86], [74, 99], [74, 101], [74, 102], [74, 164], [74, 171], [74, 195], [74, 229], [75, 205], [75, 208], [75, 227], [76, 96], [76, 107], [76, 149], [76, 204], [76, 215], [76, 229], [77, 84], [77, 141], [77, 145], [77, 213], [78, 92], [78, 105], [78, 125], [78, 149], [78, 188], [78, 204], [78, 222], [78, 229], [78, 249], [79, 160], [80, 103], [80, 114], [80, 142], [80, 190], [80, 191], [80, 200], [81, 114], [81, 151], [81, 198], [81, 226], [81, 241], [81, 242], [82, 105], [82, 185], [82, 232], [83, 98], [83, 123], [83, 126], [83, 161], [83, 207], [83, 234], [84, 124], [84, 139], [84, 141], [84, 169], [84, 181], [84, 188], [84, 228], [84, 245], [85, 114], [85, 125], [85, 131], [85, 155], [85, 220], [85, 238], [86, 191], [86, 198], [87, 145], [87, 207], [87, 232], [88, 140], [88, 157], [88, 168], [88, 183], [89, 225], [89, 237], [90, 93], [90, 111], [90, 243], [91, 92], [91, 149], [91, 154], [91, 184], [91, 187], [91, 206], [91, 235], [92, 113], [92, 150], [92, 171], [92, 192], [93, 99], [93, 108], [93, 121], [93, 140], [93, 150], [93, 160], [93, 171], [93, 223], [93, 230], [93, 237], [93, 243], [94, 112], [94, 129], [94, 144], [94, 156], [94, 165], [94, 172], [94, 189], [94, 231], [95, 101], [95, 122], [95, 127], [95, 129], [95, 140], [95, 159], [95, 215], [96, 105], [96, 121], [96, 203], [96, 220], [96, 222], [96, 246], [97, 127], [97, 144], [97, 147], [97, 197], [97, 228], [98, 127], [98, 137], [98, 182], [98, 208], [98, 233], [99, 106], [99, 113], [99, 126], [99, 174], [99, 179], [99, 209], [99, 221], [99, 236], [99, 240], [99, 241], [100, 118], [100, 169], [100, 199], [100, 204], [100, 221], [100, 247], [101, 122], [101, 152], [101, 161], [101, 220], [102, 136], [102, 242], [103, 114], [103, 186], [103, 201], [103, 229], [104, 110], [104, 160], [104, 172], [104, 192], [104, 223], [105, 114], [105, 148], [105, 191], [106, 214], [106, 234], [106, 249], [107, 134], [107, 141], [107, 154], [107, 168], [107, 169], [107, 175], [108, 127], [108, 140], [108, 161], [108, 197], [108, 204], [108, 205], [109, 111], [109, 143], [109, 168], [109, 180], [109, 225], [109, 243], [110, 119], [110, 149], [110, 153], [110, 212], [110, 244], [111, 143], [111, 181], [111, 216], [112, 150], [112, 162], [112, 191], [112, 201], [112, 206], [113, 115], [113, 122], [113, 150], [113, 191], [113, 201], [113, 230], [113, 243], [114, 124], [114, 176], [114, 244], [115, 119], [115, 123], [115, 138], [115, 180], [115, 200], [115, 214], [115, 218], [115, 231], [116, 147], [116, 176], [116, 191], [116, 192], [116, 234], [116, 243], [117, 208], [117, 220], [118, 132], [118, 191], [118, 206], [118, 207], [118, 248], [120, 148], [120, 162], [120, 175], [120, 226], [120, 241], [121, 131], [121, 180], [121, 209], [121, 243], [122, 163], [122, 190], [122, 191], [122, 200], [122, 205], [122, 212], [122, 238], [122, 245], [123, 141], [123, 151], [123, 174], [124, 204], [124, 205], [124, 210], [125, 140], [125, 170], [125, 188], [126, 132], [126, 148], [126, 173], [126, 180], [127, 145], [127, 150], [127, 202], [127, 220], [128, 134], [128, 138], [128, 153], [129, 132], [129, 148], [129, 211], [129, 225], [130, 135], [130, 149], [130, 150], [130, 161], [130, 169], [130, 198], [131, 134], [131, 184], [131, 212], [131, 236], [132, 169], [132, 175], [132, 219], [132, 240], [133, 143], [133, 198], [133, 217], [133, 225], [134, 168], [134, 175], [134, 194], [134, 202], [134, 224], [135, 140], [135, 206], [136, 158], [136, 196], [136, 201], [136, 204], [137, 161], [137, 162], [137, 231], [137, 239], [137, 240], [138, 163], [138, 165], [138, 205], [138, 216], [138, 223], [138, 232], [139, 152], [139, 160], [139, 220], [140, 161], [140, 163], [140, 171], [140, 241], [141, 143], [141, 207], [141, 249], [142, 215], [142, 221], [142, 226], [143, 149], [143, 180], [143, 187], [143, 215], [143, 233], [144, 154], [144, 163], [144, 169], [144, 170], [144, 174], [144, 179], [145, 161], [145, 231], [146, 220], [147, 148], [147, 162], [147, 201], [147, 225], [147, 239], [148, 166], [148, 194], [148, 219], [149, 152], [149, 207], [150, 181], [150, 193], [150, 197], [150, 219], [150, 221], [150, 232], [150, 244], [151, 173], [151, 177], [151, 186], [151, 202], [151, 228], [152, 167], [152, 177], [152, 202], [152, 219], [152, 238], [153, 181], [153, 209], [153, 215], [154, 158], [154, 168], [154, 190], [154, 236], [155, 211], [155, 232], [155, 237], [156, 168], [156, 171], [156, 183], [156, 187], [156, 219], [156, 229], [156, 246], [157, 180], [157, 181], [158, 169], [158, 198], [158, 225], [158, 231], [158, 249], [159, 161], [159, 167], [159, 172], [159, 186], [159, 189], [160, 232], [162, 164], [162, 195], [162, 206], [162, 218], [163, 167], [164, 187], [164, 201], [165, 202], [165, 236], [165, 245], [166, 169], [166, 245], [166, 249], [167, 171], [167, 178], [167, 215], [167, 230], [168, 200], [168, 244], [168, 248], [169, 187], [169, 199], [170, 192], [170, 206], [170, 208], [170, 218], [170, 222], [171, 200], [171, 212], [171, 215], [172, 187], [173, 176], [173, 209], [173, 222], [174, 200], [174, 244], [175, 218], [176, 178], [176, 208], [176, 226], [177, 181], [177, 215], [178, 188], [178, 204], [178, 211], [178, 249], [179, 186], [179, 231], [179, 235], [179, 241], [180, 227], [180, 228], [180, 238], [183, 190], [183, 245], [184, 193], [184, 248], [185, 186], [186, 193], [186, 234], [187, 218], [187, 230], [188, 207], [188, 231], [188, 239], [189, 191], [189, 203], [189, 207], [189, 231], [189, 234], [190, 219], [190, 226], [191, 223], [192, 195], [192, 218], [192, 232], [192, 235], [193, 203], [193, 209], [194, 202], [194, 218], [194, 244], [196, 243], [197, 215], [197, 221], [200, 208], [200, 213], [201, 223], [202, 209], [202, 220], [202, 232], [204, 229], [205, 219], [205, 225], [205, 229], [206, 223], [207, 229], [208, 241], [209, 217], [209, 221], [209, 249], [210, 217], [210, 218], [211, 216], [212, 244], [214, 238], [215, 238], [217, 223], [221, 223], [224, 226], [224, 249], [230, 247], [231, 244], [234, 246], [235, 237], [235, 240], [244, 248]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l6-s9/tests/run.py b/tasks/construct-mc-graph-k-coloring-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-mc-graph-k-coloring-l6-s9/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-mc-hadamard-l1-s2/environment/Dockerfile b/tasks/construct-mc-hadamard-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-hadamard-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-hadamard-l1-s2/environment/instance.json b/tasks/construct-mc-hadamard-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9e2ce5604649ac04fb5638511565bc05708d13a5 --- /dev/null +++ b/tasks/construct-mc-hadamard-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 5, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l1-s2/solution/solve.sh b/tasks/construct-mc-hadamard-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..056b805375997f332c4d770e9190a5845ff57de3 --- /dev/null +++ b/tasks/construct-mc-hadamard-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": [1, 1, -1, -1, 1], "y": [1, -1, 1, 1, -1]} +RLMATH_EOF diff --git a/tasks/construct-mc-hadamard-l1-s2/tests/check.py b/tasks/construct-mc-hadamard-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..fc4b93160fd7473dd14935db9d712e52abdd00c2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l1-s2/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-s2/tests/instance.json b/tasks/construct-mc-hadamard-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9e2ce5604649ac04fb5638511565bc05708d13a5 --- /dev/null +++ b/tasks/construct-mc-hadamard-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 5, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l1-s2/tests/run.py b/tasks/construct-mc-hadamard-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-hadamard-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-hadamard-l1-s2/tests/test.sh b/tasks/construct-mc-hadamard-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-hadamard-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-hadamard-l6-s1/environment/Dockerfile b/tasks/construct-mc-hadamard-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-hadamard-l6-s1/environment/instance.json b/tasks/construct-mc-hadamard-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..952b68f9a31a7c6a08b32681f4f5b9e0a25bd3fd --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 79, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l6-s1/solution/solve.sh b/tasks/construct-mc-hadamard-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..00427cb77a4af7c46a5ad88469467c70fcdf0f2f --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [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, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1], "y": [1, 1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -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-hadamard-l6-s1/tests/check.py b/tasks/construct-mc-hadamard-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..fc4b93160fd7473dd14935db9d712e52abdd00c2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s1/tests/check.py @@ -0,0 +1,18 @@ +"""Legendre pair of odd length n (MathConstraint hadamard, CC-BY-4.0): x, y in {-1,+1}^n with +sum(x) = sum(y) = 1 and PAF_x(k) + PAF_y(k) = -2 for k = 1..(n-1)/2 (periodic autocorrelation).""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, -1, 1, "x") + y = int_list(ans.get("y"), n, -1, 1, "y") + if 0 in x or 0 in y: + raise Invalid("entries must be -1 or +1") + if sum(x) != 1 or sum(y) != 1: + raise Invalid("sum(x) and sum(y) must both equal 1") + for k in range(1, (n - 1) // 2 + 1): + p = sum(x[i] * x[(i + k) % n] for i in range(n)) + sum(y[i] * y[(i + k) % n] for i in range(n)) + if p != -2: + raise Invalid(f"PAF_x({k}) + PAF_y({k}) = {p}, need -2") + return None, {} diff --git a/tasks/construct-mc-hadamard-l6-s1/tests/instance.json b/tasks/construct-mc-hadamard-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..952b68f9a31a7c6a08b32681f4f5b9e0a25bd3fd --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 79, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l6-s1/tests/run.py b/tasks/construct-mc-hadamard-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-hadamard-l6-s1/tests/test.sh b/tasks/construct-mc-hadamard-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-hadamard-l6-s6/environment/Dockerfile b/tasks/construct-mc-hadamard-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-hadamard-l6-s6/environment/instance.json b/tasks/construct-mc-hadamard-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d573212f7f29175ba8b96f14b01f5e120fb2b2e1 --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 61, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l6-s6/solution/solve.sh b/tasks/construct-mc-hadamard-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7d9a823b840291efe3aec5136544b50213d6caa2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [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, 1], "y": [1, -1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, -1]} +RLMATH_EOF diff --git a/tasks/construct-mc-hadamard-l6-s6/tests/check.py b/tasks/construct-mc-hadamard-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..fc4b93160fd7473dd14935db9d712e52abdd00c2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s6/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-l6-s6/tests/instance.json b/tasks/construct-mc-hadamard-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d573212f7f29175ba8b96f14b01f5e120fb2b2e1 --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 61, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l6-s6/tests/run.py b/tasks/construct-mc-hadamard-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-hadamard-l6-s6/tests/test.sh b/tasks/construct-mc-hadamard-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-langford-l2-s1/environment/Dockerfile b/tasks/construct-mc-langford-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-langford-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-langford-l2-s1/environment/instance.json b/tasks/construct-mc-langford-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fcd78ddf06b6e4c5adfc4b91b9f61a423211b248 --- /dev/null +++ b/tasks/construct-mc-langford-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l2-s1/solution/solve.sh b/tasks/construct-mc-langford-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ff59d263617676d084784804bafbcc46853590e4 --- /dev/null +++ b/tasks/construct-mc-langford-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' +{"seq": [4, 2, 7, 11, 2, 4, 5, 10, 8, 12, 7, 9, 5, 6, 1, 11, 1, 8, 10, 3, 6, 9, 12, 3]} +RLMATH_EOF diff --git a/tasks/construct-mc-langford-l2-s1/tests/check.py b/tasks/construct-mc-langford-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4672d7eacf321991933cb280d6c940f1c4a67935 --- /dev/null +++ b/tasks/construct-mc-langford-l2-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-l2-s1/tests/instance.json b/tasks/construct-mc-langford-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fcd78ddf06b6e4c5adfc4b91b9f61a423211b248 --- /dev/null +++ b/tasks/construct-mc-langford-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l2-s1/tests/run.py b/tasks/construct-mc-langford-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-langford-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-langford-l2-s1/tests/test.sh b/tasks/construct-mc-langford-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-langford-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-langford-l6-s0/environment/Dockerfile b/tasks/construct-mc-langford-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-langford-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-mc-langford-l6-s0/environment/instance.json b/tasks/construct-mc-langford-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fe816569bad7de09fb0700f7a0704bc8a3454883 --- /dev/null +++ b/tasks/construct-mc-langford-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 39, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l6-s0/solution/solve.sh b/tasks/construct-mc-langford-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c45bd923c7342c431d314ba1a668c165da67bdc3 --- /dev/null +++ b/tasks/construct-mc-langford-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' +{"seq": [28, 38, 39, 13, 5, 20, 17, 11, 30, 36, 5, 21, 24, 1, 8, 1, 3, 13, 26, 11, 3, 37, 27, 8, 17, 22, 20, 19, 29, 28, 34, 2, 35, 21, 2, 31, 16, 24, 33, 30, 38, 14, 39, 32, 25, 26, 36, 19, 22, 7, 27, 23, 10, 16, 9, 18, 14, 7, 29, 37, 12, 15, 6, 10, 9, 34, 4, 31, 35, 6, 25, 4, 33, 12, 18, 23, 32, 15]} +RLMATH_EOF diff --git a/tasks/construct-mc-langford-l6-s0/tests/check.py b/tasks/construct-mc-langford-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4672d7eacf321991933cb280d6c940f1c4a67935 --- /dev/null +++ b/tasks/construct-mc-langford-l6-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-l6-s0/tests/instance.json b/tasks/construct-mc-langford-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fe816569bad7de09fb0700f7a0704bc8a3454883 --- /dev/null +++ b/tasks/construct-mc-langford-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 39, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l6-s0/tests/run.py b/tasks/construct-mc-langford-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-langford-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-langford-l6-s0/tests/test.sh b/tasks/construct-mc-langford-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-langford-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-mc-max-clique-l4-s2/environment/Dockerfile b/tasks/construct-mc-max-clique-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-clique-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-mc-max-clique-l4-s2/environment/instance.json b/tasks/construct-mc-max-clique-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..56125723f874c0d32a705ba165709771c9bf55da --- /dev/null +++ b/tasks/construct-mc-max-clique-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 69, "k": 9, "edges": [[0, 2], [0, 3], [0, 4], [0, 8], [0, 9], [0, 10], [0, 12], [0, 16], [0, 17], [0, 18], [0, 20], [0, 21], [0, 22], [0, 27], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 36], [0, 37], [0, 38], [0, 39], [0, 42], [0, 43], [0, 46], [0, 47], [0, 49], [0, 50], [0, 53], [0, 54], [0, 56], [0, 57], [0, 58], [0, 62], [0, 63], [0, 65], [0, 67], [1, 7], [1, 9], [1, 10], [1, 13], [1, 17], [1, 18], [1, 19], [1, 20], [1, 23], [1, 25], [1, 29], [1, 35], [1, 36], [1, 41], [1, 42], [1, 43], [1, 44], [1, 47], [1, 48], [1, 51], [1, 52], [1, 53], [1, 55], [1, 58], [1, 60], [1, 61], [1, 62], [1, 64], [1, 65], [1, 66], [1, 68], [2, 3], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 14], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 23], [2, 24], [2, 25], [2, 26], [2, 28], [2, 29], [2, 30], [2, 34], [2, 35], [2, 39], [2, 41], [2, 43], [2, 45], [2, 46], [2, 50], [2, 53], [2, 55], [2, 56], [2, 57], [2, 58], [2, 59], [2, 60], [2, 62], [2, 64], [2, 66], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 10], [3, 11], [3, 14], [3, 17], [3, 20], [3, 23], [3, 25], [3, 28], [3, 29], [3, 31], [3, 33], [3, 37], [3, 40], [3, 42], [3, 43], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 52], [3, 56], [3, 57], [3, 59], [3, 63], [3, 65], [3, 66], [4, 7], [4, 9], [4, 13], [4, 15], [4, 17], [4, 18], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 28], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 39], [4, 40], [4, 41], [4, 43], [4, 45], [4, 47], [4, 48], [4, 50], [4, 51], [4, 52], [4, 53], [4, 55], [4, 56], [4, 57], [4, 59], [4, 63], [4, 64], [4, 65], [4, 66], [4, 67], [5, 8], [5, 11], [5, 12], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 21], [5, 23], [5, 25], [5, 28], [5, 29], [5, 30], [5, 31], [5, 32], [5, 34], [5, 35], [5, 37], [5, 39], [5, 40], [5, 43], [5, 46], [5, 49], [5, 50], [5, 51], [5, 52], [5, 53], [5, 54], [5, 56], [5, 57], [5, 60], [5, 61], [5, 64], [5, 66], [5, 67], [5, 68], [6, 7], [6, 8], [6, 9], [6, 10], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 20], [6, 21], [6, 22], [6, 26], [6, 27], [6, 30], [6, 31], [6, 33], [6, 36], [6, 37], [6, 38], [6, 39], [6, 42], [6, 43], [6, 44], [6, 45], [6, 46], [6, 47], [6, 48], [6, 50], [6, 51], [6, 52], [6, 53], [6, 54], [6, 59], [6, 61], [6, 65], [6, 66], [6, 67], [7, 10], [7, 13], [7, 15], [7, 17], [7, 19], [7, 20], [7, 21], [7, 27], [7, 28], [7, 30], [7, 33], [7, 36], [7, 37], [7, 38], [7, 40], [7, 41], [7, 45], [7, 48], [7, 49], [7, 51], [7, 52], [7, 53], [7, 54], [7, 55], [7, 56], [7, 58], [7, 59], [7, 60], [7, 61], [7, 63], [7, 64], [7, 66], [7, 67], [7, 68], [8, 10], [8, 11], [8, 15], [8, 16], [8, 17], [8, 19], [8, 20], [8, 21], [8, 23], [8, 24], [8, 27], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 36], [8, 37], [8, 38], [8, 39], [8, 40], [8, 41], [8, 46], [8, 47], [8, 49], [8, 50], [8, 51], [8, 53], [8, 54], [8, 55], [8, 56], [8, 59], [8, 60], [8, 61], [8, 62], [8, 64], [8, 65], [8, 66], [8, 67], [8, 68], [9, 10], [9, 12], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 24], [9, 26], [9, 27], [9, 28], [9, 31], [9, 32], [9, 33], [9, 38], [9, 39], [9, 40], [9, 43], [9, 44], [9, 45], [9, 46], [9, 47], [9, 48], [9, 51], [9, 52], [9, 53], [9, 54], [9, 57], [9, 58], [9, 61], [9, 62], [9, 67], [9, 68], [10, 16], [10, 18], [10, 19], [10, 21], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 34], [10, 35], [10, 36], [10, 38], [10, 39], [10, 40], [10, 41], [10, 43], [10, 45], [10, 47], [10, 48], [10, 50], [10, 51], [10, 52], [10, 53], [10, 54], [10, 55], [10, 56], [10, 57], [10, 58], [10, 59], [10, 60], [10, 61], [10, 62], [10, 63], [10, 65], [10, 66], [10, 67], [10, 68], [11, 12], [11, 13], [11, 14], [11, 16], [11, 17], [11, 18], [11, 19], [11, 21], [11, 22], [11, 24], [11, 25], [11, 27], [11, 28], [11, 29], [11, 31], [11, 33], [11, 34], [11, 35], [11, 38], [11, 39], [11, 40], [11, 41], [11, 42], [11, 44], [11, 46], [11, 47], [11, 49], [11, 50], [11, 52], [11, 53], [11, 54], [11, 57], [11, 58], [11, 60], [11, 62], [11, 65], [12, 13], [12, 14], [12, 15], [12, 16], [12, 19], [12, 20], [12, 21], [12, 22], [12, 25], [12, 28], [12, 30], [12, 31], [12, 32], [12, 33], [12, 35], [12, 41], [12, 42], [12, 43], [12, 46], [12, 47], [12, 48], [12, 49], [12, 51], [12, 54], [12, 56], [12, 58], [12, 60], [12, 61], [12, 62], [12, 64], [12, 65], [12, 67], [12, 68], [13, 14], [13, 18], [13, 22], [13, 24], [13, 26], [13, 28], [13, 29], [13, 31], [13, 34], [13, 35], [13, 36], [13, 37], [13, 39], [13, 43], [13, 44], [13, 47], [13, 48], [13, 49], [13, 50], [13, 51], [13, 52], [13, 55], [13, 56], [13, 57], [13, 58], [13, 61], [13, 62], [13, 63], [13, 64], [13, 65], [13, 66], [13, 68], [14, 18], [14, 22], [14, 23], [14, 27], [14, 29], [14, 36], [14, 38], [14, 39], [14, 40], [14, 41], [14, 42], [14, 43], [14, 44], [14, 46], [14, 47], [14, 48], [14, 49], [14, 50], [14, 53], [14, 54], [14, 55], [14, 57], [14, 58], [14, 59], [14, 61], [14, 64], [14, 65], [14, 66], [14, 67], [14, 68], [15, 16], [15, 20], [15, 22], [15, 23], [15, 25], [15, 27], [15, 28], [15, 31], [15, 32], [15, 34], [15, 35], [15, 36], [15, 38], [15, 40], [15, 42], [15, 43], [15, 44], [15, 48], [15, 52], [15, 53], [15, 54], [15, 55], [15, 57], [15, 60], [15, 61], [15, 62], [15, 63], [15, 64], [15, 65], [15, 67], [15, 68], [16, 17], [16, 18], [16, 19], [16, 22], [16, 27], [16, 28], [16, 29], [16, 33], [16, 34], [16, 35], [16, 39], [16, 40], [16, 41], [16, 44], [16, 45], [16, 46], [16, 47], [16, 49], [16, 50], [16, 51], [16, 54], [16, 55], [16, 56], [16, 58], [16, 59], [16, 61], [16, 62], [16, 65], [16, 67], [16, 68], [17, 23], [17, 26], [17, 29], [17, 30], [17, 32], [17, 33], [17, 35], [17, 36], [17, 38], [17, 42], [17, 43], [17, 44], [17, 45], [17, 51], [17, 52], [17, 53], [17, 54], [17, 55], [17, 57], [17, 58], [17, 61], [17, 62], [17, 63], [17, 64], [17, 65], [17, 67], [17, 68], [18, 19], [18, 20], [18, 21], [18, 23], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 32], [18, 35], [18, 36], [18, 39], [18, 41], [18, 44], [18, 45], [18, 46], [18, 47], [18, 48], [18, 49], [18, 50], [18, 51], [18, 52], [18, 54], [18, 55], [18, 57], [18, 59], [18, 60], [18, 61], [18, 62], [18, 63], [18, 64], [18, 65], [18, 67], [18, 68], [19, 20], [19, 22], [19, 23], [19, 24], [19, 27], [19, 29], [19, 31], [19, 32], [19, 33], [19, 36], [19, 37], [19, 39], [19, 40], [19, 42], [19, 43], [19, 45], [19, 49], [19, 50], [19, 51], [19, 52], [19, 53], [19, 54], [19, 55], [19, 56], [19, 58], [19, 60], [19, 64], [19, 65], [19, 66], [20, 24], [20, 26], [20, 28], [20, 29], [20, 30], [20, 31], [20, 33], [20, 34], [20, 36], [20, 37], [20, 38], [20, 39], [20, 41], [20, 42], [20, 43], [20, 44], [20, 46], [20, 47], [20, 50], [20, 52], [20, 55], [20, 56], [20, 57], [20, 58], [20, 60], [20, 63], [20, 64], [20, 66], [21, 22], [21, 23], [21, 24], [21, 27], [21, 28], [21, 30], [21, 31], [21, 34], [21, 35], [21, 39], [21, 40], [21, 41], [21, 42], [21, 43], [21, 44], [21, 46], [21, 47], [21, 50], [21, 52], [21, 54], [21, 56], [21, 58], [21, 60], [21, 65], [21, 66], [21, 67], [22, 24], [22, 25], [22, 28], [22, 29], [22, 33], [22, 35], [22, 37], [22, 38], [22, 41], [22, 42], [22, 43], [22, 44], [22, 45], [22, 46], [22, 49], [22, 51], [22, 52], [22, 53], [22, 54], [22, 56], [22, 58], [22, 59], [22, 60], [22, 63], [22, 64], [22, 65], [22, 66], [22, 68], [23, 26], [23, 28], [23, 30], [23, 31], [23, 38], [23, 40], [23, 41], [23, 42], [23, 45], [23, 46], [23, 47], [23, 49], [23, 50], [23, 52], [23, 53], [23, 54], [23, 55], [23, 56], [23, 60], [23, 62], [23, 63], [23, 64], [23, 65], [23, 66], [23, 67], [23, 68], [24, 25], [24, 26], [24, 27], [24, 30], [24, 31], [24, 32], [24, 34], [24, 35], [24, 38], [24, 41], [24, 42], [24, 45], [24, 52], [24, 53], [24, 54], [24, 55], [24, 58], [24, 59], [24, 61], [24, 62], [24, 64], [24, 65], [24, 66], [24, 67], [24, 68], [25, 26], [25, 27], [25, 28], [25, 30], [25, 31], [25, 33], [25, 34], [25, 36], [25, 39], [25, 40], [25, 41], [25, 42], [25, 44], [25, 45], [25, 46], [25, 47], [25, 48], [25, 49], [25, 50], [25, 56], [25, 59], [25, 60], [25, 61], [25, 62], [25, 63], [25, 64], [25, 65], [25, 66], [25, 67], [26, 28], [26, 30], [26, 31], [26, 33], [26, 36], [26, 37], [26, 41], [26, 44], [26, 45], [26, 46], [26, 50], [26, 51], [26, 53], [26, 54], [26, 56], [26, 58], [26, 60], [26, 62], [26, 63], [26, 64], [26, 65], [26, 67], [26, 68], [27, 28], [27, 29], [27, 32], [27, 33], [27, 35], [27, 36], [27, 37], [27, 38], [27, 39], [27, 42], [27, 45], [27, 46], [27, 49], [27, 50], [27, 51], [27, 52], [27, 53], [27, 55], [27, 56], [27, 57], [27, 58], [27, 59], [27, 60], [27, 61], [27, 63], [27, 65], [27, 67], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [28, 38], [28, 39], [28, 42], [28, 43], [28, 45], [28, 46], [28, 50], [28, 53], [28, 55], [28, 57], [28, 58], [28, 61], [28, 64], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 37], [29, 39], [29, 41], [29, 42], [29, 45], [29, 46], [29, 47], [29, 50], [29, 51], [29, 52], [29, 53], [29, 54], [29, 55], [29, 57], [29, 58], [29, 59], [29, 60], [29, 61], [29, 62], [29, 64], [29, 66], [29, 67], [29, 68], [30, 31], [30, 32], [30, 33], [30, 35], [30, 38], [30, 40], [30, 42], [30, 43], [30, 44], [30, 45], [30, 46], [30, 48], [30, 50], [30, 53], [30, 54], [30, 56], [30, 58], [30, 60], [30, 61], [30, 62], [30, 63], [30, 67], [30, 68], [31, 32], [31, 33], [31, 35], [31, 39], [31, 40], [31, 41], [31, 42], [31, 44], [31, 45], [31, 46], [31, 48], [31, 49], [31, 50], [31, 52], [31, 53], [31, 56], [31, 57], [31, 58], [31, 59], [31, 60], [31, 61], [31, 62], [31, 63], [31, 65], [31, 67], [31, 68], [32, 37], [32, 38], [32, 39], [32, 40], [32, 41], [32, 42], [32, 43], [32, 46], [32, 50], [32, 51], [32, 52], [32, 53], [32, 54], [32, 56], [32, 59], [32, 60], [32, 67], [32, 68], [33, 36], [33, 39], [33, 42], [33, 43], [33, 44], [33, 45], [33, 46], [33, 48], [33, 49], [33, 51], [33, 52], [33, 54], [33, 57], [33, 58], [33, 59], [33, 60], [33, 61], [33, 63], [33, 64], [33, 65], [33, 67], [33, 68], [34, 35], [34, 36], [34, 37], [34, 40], [34, 41], [34, 43], [34, 44], [34, 46], [34, 47], [34, 50], [34, 51], [34, 55], [34, 56], [34, 58], [34, 59], [34, 60], [34, 62], [34, 63], [34, 65], [34, 67], [35, 41], [35, 42], [35, 43], [35, 44], [35, 45], [35, 46], [35, 47], [35, 49], [35, 50], [35, 51], [35, 52], [35, 53], [35, 54], [35, 56], [35, 58], [35, 60], [35, 61], [35, 63], [35, 64], [35, 65], [35, 66], [36, 38], [36, 40], [36, 42], [36, 43], [36, 45], [36, 46], [36, 48], [36, 49], [36, 50], [36, 51], [36, 52], [36, 54], [36, 56], [36, 57], [36, 58], [36, 59], [36, 61], [36, 62], [36, 65], [36, 66], [37, 39], [37, 41], [37, 42], [37, 43], [37, 48], [37, 49], [37, 51], [37, 52], [37, 54], [37, 55], [37, 64], [37, 65], [37, 66], [37, 67], [37, 68], [38, 39], [38, 40], [38, 43], [38, 46], [38, 47], [38, 50], [38, 51], [38, 52], [38, 53], [38, 54], [38, 55], [38, 56], [38, 57], [38, 58], [38, 59], [38, 61], [38, 65], [38, 66], [38, 67], [38, 68], [39, 40], [39, 42], [39, 43], [39, 44], [39, 45], [39, 47], [39, 48], [39, 49], [39, 50], [39, 51], [39, 53], [39, 54], [39, 55], [39, 56], [39, 57], [39, 58], [39, 59], [39, 61], [39, 63], [39, 64], [39, 67], [39, 68], [40, 41], [40, 43], [40, 48], [40, 50], [40, 51], [40, 54], [40, 55], [40, 56], [40, 58], [40, 59], [40, 60], [40, 63], [40, 64], [40, 67], [41, 42], [41, 47], [41, 48], [41, 50], [41, 52], [41, 53], [41, 54], [41, 55], [41, 56], [41, 58], [41, 59], [41, 61], [41, 62], [41, 63], [41, 66], [41, 67], [42, 44], [42, 48], [42, 49], [42, 50], [42, 51], [42, 54], [42, 56], [42, 57], [42, 58], [42, 59], [42, 60], [42, 64], [42, 66], [42, 67], [43, 47], [43, 49], [43, 52], [43, 53], [43, 57], [43, 59], [43, 60], [43, 61], [43, 62], [43, 64], [43, 65], [43, 68], [44, 46], [44, 47], [44, 48], [44, 50], [44, 53], [44, 55], [44, 58], [44, 59], [44, 60], [44, 62], [44, 64], [44, 65], [44, 66], [44, 67], [44, 68], [45, 46], [45, 47], [45, 48], [45, 53], [45, 54], [45, 56], [45, 58], [45, 60], [45, 62], [45, 63], [45, 64], [45, 65], [45, 66], [45, 67], [45, 68], [46, 48], [46, 49], [46, 50], [46, 52], [46, 54], [46, 55], [46, 56], [46, 59], [46, 60], [46, 61], [46, 62], [46, 63], [46, 65], [47, 48], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [47, 54], [47, 57], [47, 58], [47, 60], [47, 64], [47, 65], [47, 67], [47, 68], [48, 50], [48, 52], [48, 54], [48, 56], [48, 57], [48, 58], [48, 59], [48, 61], [48, 62], [48, 63], [48, 66], [48, 67], [48, 68], [49, 51], [49, 52], [49, 54], [49, 55], [49, 56], [49, 58], [49, 60], [49, 62], [49, 63], [49, 66], [49, 67], [49, 68], [50, 51], [50, 55], [50, 56], [50, 59], [50, 60], [50, 61], [50, 62], [50, 63], [50, 64], [50, 65], [50, 68], [51, 54], [51, 55], [51, 56], [51, 57], [51, 58], [51, 60], [51, 61], [51, 62], [51, 63], [51, 64], [51, 65], [51, 66], [51, 68], [52, 55], [52, 56], [52, 57], [52, 58], [52, 59], [52, 60], [52, 62], [52, 63], [52, 65], [52, 66], [52, 67], [53, 55], [53, 57], [53, 58], [53, 61], [53, 62], [53, 64], [53, 65], [53, 66], [53, 68], [54, 56], [54, 57], [54, 58], [54, 59], [54, 60], [54, 61], [54, 62], [54, 64], [54, 65], [54, 66], [54, 67], [54, 68], [55, 58], [55, 59], [55, 60], [55, 61], [55, 62], [55, 66], [56, 57], [56, 58], [56, 59], [56, 60], [56, 61], [56, 66], [57, 59], [57, 60], [57, 61], [57, 62], [57, 64], [57, 65], [57, 67], [57, 68], [58, 61], [58, 62], [58, 63], [58, 64], [58, 65], [58, 66], [59, 60], [59, 61], [59, 62], [59, 64], [59, 65], [59, 66], [60, 61], [60, 62], [60, 63], [60, 64], [60, 67], [60, 68], [61, 62], [61, 63], [61, 64], [61, 66], [61, 67], [61, 68], [62, 63], [62, 64], [62, 65], [62, 67], [63, 64], [63, 65], [63, 66], [63, 67], [63, 68], [64, 65], [64, 66], [64, 67], [64, 68], [65, 66], [65, 67], [65, 68], [66, 67], [67, 68]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l4-s2/solution/solve.sh b/tasks/construct-mc-max-clique-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..da4bae17b56a3fe0ea56644beef8c781172adf85 --- /dev/null +++ b/tasks/construct-mc-max-clique-l4-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [2, 5, 8, 21, 30, 46, 50, 56, 60]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-clique-l4-s2/tests/check.py b/tasks/construct-mc-max-clique-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3f70dbd5b155a3514c2102aa4ad460201495210 --- /dev/null +++ b/tasks/construct-mc-max-clique-l4-s2/tests/check.py @@ -0,0 +1,18 @@ +"""Clique of size >= k in a given graph (MathConstraint max_clique decision version, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"clique has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) not in E: + raise Invalid(f"vertices {u} and {v} are not adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-clique-l4-s2/tests/instance.json b/tasks/construct-mc-max-clique-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..56125723f874c0d32a705ba165709771c9bf55da --- /dev/null +++ b/tasks/construct-mc-max-clique-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 69, "k": 9, "edges": [[0, 2], [0, 3], [0, 4], [0, 8], [0, 9], [0, 10], [0, 12], [0, 16], [0, 17], [0, 18], [0, 20], [0, 21], [0, 22], [0, 27], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 36], [0, 37], [0, 38], [0, 39], [0, 42], [0, 43], [0, 46], [0, 47], [0, 49], [0, 50], [0, 53], [0, 54], [0, 56], [0, 57], [0, 58], [0, 62], [0, 63], [0, 65], [0, 67], [1, 7], [1, 9], [1, 10], [1, 13], [1, 17], [1, 18], [1, 19], [1, 20], [1, 23], [1, 25], [1, 29], [1, 35], [1, 36], [1, 41], [1, 42], [1, 43], [1, 44], [1, 47], [1, 48], [1, 51], [1, 52], [1, 53], [1, 55], [1, 58], [1, 60], [1, 61], [1, 62], [1, 64], [1, 65], [1, 66], [1, 68], [2, 3], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 14], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 23], [2, 24], [2, 25], [2, 26], [2, 28], [2, 29], [2, 30], [2, 34], [2, 35], [2, 39], [2, 41], [2, 43], [2, 45], [2, 46], [2, 50], [2, 53], [2, 55], [2, 56], [2, 57], [2, 58], [2, 59], [2, 60], [2, 62], [2, 64], [2, 66], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 10], [3, 11], [3, 14], [3, 17], [3, 20], [3, 23], [3, 25], [3, 28], [3, 29], [3, 31], [3, 33], [3, 37], [3, 40], [3, 42], [3, 43], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 52], [3, 56], [3, 57], [3, 59], [3, 63], [3, 65], [3, 66], [4, 7], [4, 9], [4, 13], [4, 15], [4, 17], [4, 18], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 28], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 39], [4, 40], [4, 41], [4, 43], [4, 45], [4, 47], [4, 48], [4, 50], [4, 51], [4, 52], [4, 53], [4, 55], [4, 56], [4, 57], [4, 59], [4, 63], [4, 64], [4, 65], [4, 66], [4, 67], [5, 8], [5, 11], [5, 12], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 21], [5, 23], [5, 25], [5, 28], [5, 29], [5, 30], [5, 31], [5, 32], [5, 34], [5, 35], [5, 37], [5, 39], [5, 40], [5, 43], [5, 46], [5, 49], [5, 50], [5, 51], [5, 52], [5, 53], [5, 54], [5, 56], [5, 57], [5, 60], [5, 61], [5, 64], [5, 66], [5, 67], [5, 68], [6, 7], [6, 8], [6, 9], [6, 10], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 20], [6, 21], [6, 22], [6, 26], [6, 27], [6, 30], [6, 31], [6, 33], [6, 36], [6, 37], [6, 38], [6, 39], [6, 42], [6, 43], [6, 44], [6, 45], [6, 46], [6, 47], [6, 48], [6, 50], [6, 51], [6, 52], [6, 53], [6, 54], [6, 59], [6, 61], [6, 65], [6, 66], [6, 67], [7, 10], [7, 13], [7, 15], [7, 17], [7, 19], [7, 20], [7, 21], [7, 27], [7, 28], [7, 30], [7, 33], [7, 36], [7, 37], [7, 38], [7, 40], [7, 41], [7, 45], [7, 48], [7, 49], [7, 51], [7, 52], [7, 53], [7, 54], [7, 55], [7, 56], [7, 58], [7, 59], [7, 60], [7, 61], [7, 63], [7, 64], [7, 66], [7, 67], [7, 68], [8, 10], [8, 11], [8, 15], [8, 16], [8, 17], [8, 19], [8, 20], [8, 21], [8, 23], [8, 24], [8, 27], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 36], [8, 37], [8, 38], [8, 39], [8, 40], [8, 41], [8, 46], [8, 47], [8, 49], [8, 50], [8, 51], [8, 53], [8, 54], [8, 55], [8, 56], [8, 59], [8, 60], [8, 61], [8, 62], [8, 64], [8, 65], [8, 66], [8, 67], [8, 68], [9, 10], [9, 12], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 24], [9, 26], [9, 27], [9, 28], [9, 31], [9, 32], [9, 33], [9, 38], [9, 39], [9, 40], [9, 43], [9, 44], [9, 45], [9, 46], [9, 47], [9, 48], [9, 51], [9, 52], [9, 53], [9, 54], [9, 57], [9, 58], [9, 61], [9, 62], [9, 67], [9, 68], [10, 16], [10, 18], [10, 19], [10, 21], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 34], [10, 35], [10, 36], [10, 38], [10, 39], [10, 40], [10, 41], [10, 43], [10, 45], [10, 47], [10, 48], [10, 50], [10, 51], [10, 52], [10, 53], [10, 54], [10, 55], [10, 56], [10, 57], [10, 58], [10, 59], [10, 60], [10, 61], [10, 62], [10, 63], [10, 65], [10, 66], [10, 67], [10, 68], [11, 12], [11, 13], [11, 14], [11, 16], [11, 17], [11, 18], [11, 19], [11, 21], [11, 22], [11, 24], [11, 25], [11, 27], [11, 28], [11, 29], [11, 31], [11, 33], [11, 34], [11, 35], [11, 38], [11, 39], [11, 40], [11, 41], [11, 42], [11, 44], [11, 46], [11, 47], [11, 49], [11, 50], [11, 52], [11, 53], [11, 54], [11, 57], [11, 58], [11, 60], [11, 62], [11, 65], [12, 13], [12, 14], [12, 15], [12, 16], [12, 19], [12, 20], [12, 21], [12, 22], [12, 25], [12, 28], [12, 30], [12, 31], [12, 32], [12, 33], [12, 35], [12, 41], [12, 42], [12, 43], [12, 46], [12, 47], [12, 48], [12, 49], [12, 51], [12, 54], [12, 56], [12, 58], [12, 60], [12, 61], [12, 62], [12, 64], [12, 65], [12, 67], [12, 68], [13, 14], [13, 18], [13, 22], [13, 24], [13, 26], [13, 28], [13, 29], [13, 31], [13, 34], [13, 35], [13, 36], [13, 37], [13, 39], [13, 43], [13, 44], [13, 47], [13, 48], [13, 49], [13, 50], [13, 51], [13, 52], [13, 55], [13, 56], [13, 57], [13, 58], [13, 61], [13, 62], [13, 63], [13, 64], [13, 65], [13, 66], [13, 68], [14, 18], [14, 22], [14, 23], [14, 27], [14, 29], [14, 36], [14, 38], [14, 39], [14, 40], [14, 41], [14, 42], [14, 43], [14, 44], [14, 46], [14, 47], [14, 48], [14, 49], [14, 50], [14, 53], [14, 54], [14, 55], [14, 57], [14, 58], [14, 59], [14, 61], [14, 64], [14, 65], [14, 66], [14, 67], [14, 68], [15, 16], [15, 20], [15, 22], [15, 23], [15, 25], [15, 27], [15, 28], [15, 31], [15, 32], [15, 34], [15, 35], [15, 36], [15, 38], [15, 40], [15, 42], [15, 43], [15, 44], [15, 48], [15, 52], [15, 53], [15, 54], [15, 55], [15, 57], [15, 60], [15, 61], [15, 62], [15, 63], [15, 64], [15, 65], [15, 67], [15, 68], [16, 17], [16, 18], [16, 19], [16, 22], [16, 27], [16, 28], [16, 29], [16, 33], [16, 34], [16, 35], [16, 39], [16, 40], [16, 41], [16, 44], [16, 45], [16, 46], [16, 47], [16, 49], [16, 50], [16, 51], [16, 54], [16, 55], [16, 56], [16, 58], [16, 59], [16, 61], [16, 62], [16, 65], [16, 67], [16, 68], [17, 23], [17, 26], [17, 29], [17, 30], [17, 32], [17, 33], [17, 35], [17, 36], [17, 38], [17, 42], [17, 43], [17, 44], [17, 45], [17, 51], [17, 52], [17, 53], [17, 54], [17, 55], [17, 57], [17, 58], [17, 61], [17, 62], [17, 63], [17, 64], [17, 65], [17, 67], [17, 68], [18, 19], [18, 20], [18, 21], [18, 23], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 32], [18, 35], [18, 36], [18, 39], [18, 41], [18, 44], [18, 45], [18, 46], [18, 47], [18, 48], [18, 49], [18, 50], [18, 51], [18, 52], [18, 54], [18, 55], [18, 57], [18, 59], [18, 60], [18, 61], [18, 62], [18, 63], [18, 64], [18, 65], [18, 67], [18, 68], [19, 20], [19, 22], [19, 23], [19, 24], [19, 27], [19, 29], [19, 31], [19, 32], [19, 33], [19, 36], [19, 37], [19, 39], [19, 40], [19, 42], [19, 43], [19, 45], [19, 49], [19, 50], [19, 51], [19, 52], [19, 53], [19, 54], [19, 55], [19, 56], [19, 58], [19, 60], [19, 64], [19, 65], [19, 66], [20, 24], [20, 26], [20, 28], [20, 29], [20, 30], [20, 31], [20, 33], [20, 34], [20, 36], [20, 37], [20, 38], [20, 39], [20, 41], [20, 42], [20, 43], [20, 44], [20, 46], [20, 47], [20, 50], [20, 52], [20, 55], [20, 56], [20, 57], [20, 58], [20, 60], [20, 63], [20, 64], [20, 66], [21, 22], [21, 23], [21, 24], [21, 27], [21, 28], [21, 30], [21, 31], [21, 34], [21, 35], [21, 39], [21, 40], [21, 41], [21, 42], [21, 43], [21, 44], [21, 46], [21, 47], [21, 50], [21, 52], [21, 54], [21, 56], [21, 58], [21, 60], [21, 65], [21, 66], [21, 67], [22, 24], [22, 25], [22, 28], [22, 29], [22, 33], [22, 35], [22, 37], [22, 38], [22, 41], [22, 42], [22, 43], [22, 44], [22, 45], [22, 46], [22, 49], [22, 51], [22, 52], [22, 53], [22, 54], [22, 56], [22, 58], [22, 59], [22, 60], [22, 63], [22, 64], [22, 65], [22, 66], [22, 68], [23, 26], [23, 28], [23, 30], [23, 31], [23, 38], [23, 40], [23, 41], [23, 42], [23, 45], [23, 46], [23, 47], [23, 49], [23, 50], [23, 52], [23, 53], [23, 54], [23, 55], [23, 56], [23, 60], [23, 62], [23, 63], [23, 64], [23, 65], [23, 66], [23, 67], [23, 68], [24, 25], [24, 26], [24, 27], [24, 30], [24, 31], [24, 32], [24, 34], [24, 35], [24, 38], [24, 41], [24, 42], [24, 45], [24, 52], [24, 53], [24, 54], [24, 55], [24, 58], [24, 59], [24, 61], [24, 62], [24, 64], [24, 65], [24, 66], [24, 67], [24, 68], [25, 26], [25, 27], [25, 28], [25, 30], [25, 31], [25, 33], [25, 34], [25, 36], [25, 39], [25, 40], [25, 41], [25, 42], [25, 44], [25, 45], [25, 46], [25, 47], [25, 48], [25, 49], [25, 50], [25, 56], [25, 59], [25, 60], [25, 61], [25, 62], [25, 63], [25, 64], [25, 65], [25, 66], [25, 67], [26, 28], [26, 30], [26, 31], [26, 33], [26, 36], [26, 37], [26, 41], [26, 44], [26, 45], [26, 46], [26, 50], [26, 51], [26, 53], [26, 54], [26, 56], [26, 58], [26, 60], [26, 62], [26, 63], [26, 64], [26, 65], [26, 67], [26, 68], [27, 28], [27, 29], [27, 32], [27, 33], [27, 35], [27, 36], [27, 37], [27, 38], [27, 39], [27, 42], [27, 45], [27, 46], [27, 49], [27, 50], [27, 51], [27, 52], [27, 53], [27, 55], [27, 56], [27, 57], [27, 58], [27, 59], [27, 60], [27, 61], [27, 63], [27, 65], [27, 67], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [28, 38], [28, 39], [28, 42], [28, 43], [28, 45], [28, 46], [28, 50], [28, 53], [28, 55], [28, 57], [28, 58], [28, 61], [28, 64], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 37], [29, 39], [29, 41], [29, 42], [29, 45], [29, 46], [29, 47], [29, 50], [29, 51], [29, 52], [29, 53], [29, 54], [29, 55], [29, 57], [29, 58], [29, 59], [29, 60], [29, 61], [29, 62], [29, 64], [29, 66], [29, 67], [29, 68], [30, 31], [30, 32], [30, 33], [30, 35], [30, 38], [30, 40], [30, 42], [30, 43], [30, 44], [30, 45], [30, 46], [30, 48], [30, 50], [30, 53], [30, 54], [30, 56], [30, 58], [30, 60], [30, 61], [30, 62], [30, 63], [30, 67], [30, 68], [31, 32], [31, 33], [31, 35], [31, 39], [31, 40], [31, 41], [31, 42], [31, 44], [31, 45], [31, 46], [31, 48], [31, 49], [31, 50], [31, 52], [31, 53], [31, 56], [31, 57], [31, 58], [31, 59], [31, 60], [31, 61], [31, 62], [31, 63], [31, 65], [31, 67], [31, 68], [32, 37], [32, 38], [32, 39], [32, 40], [32, 41], [32, 42], [32, 43], [32, 46], [32, 50], [32, 51], [32, 52], [32, 53], [32, 54], [32, 56], [32, 59], [32, 60], [32, 67], [32, 68], [33, 36], [33, 39], [33, 42], [33, 43], [33, 44], [33, 45], [33, 46], [33, 48], [33, 49], [33, 51], [33, 52], [33, 54], [33, 57], [33, 58], [33, 59], [33, 60], [33, 61], [33, 63], [33, 64], [33, 65], [33, 67], [33, 68], [34, 35], [34, 36], [34, 37], [34, 40], [34, 41], [34, 43], [34, 44], [34, 46], [34, 47], [34, 50], [34, 51], [34, 55], [34, 56], [34, 58], [34, 59], [34, 60], [34, 62], [34, 63], [34, 65], [34, 67], [35, 41], [35, 42], [35, 43], [35, 44], [35, 45], [35, 46], [35, 47], [35, 49], [35, 50], [35, 51], [35, 52], [35, 53], [35, 54], [35, 56], [35, 58], [35, 60], [35, 61], [35, 63], [35, 64], [35, 65], [35, 66], [36, 38], [36, 40], [36, 42], [36, 43], [36, 45], [36, 46], [36, 48], [36, 49], [36, 50], [36, 51], [36, 52], [36, 54], [36, 56], [36, 57], [36, 58], [36, 59], [36, 61], [36, 62], [36, 65], [36, 66], [37, 39], [37, 41], [37, 42], [37, 43], [37, 48], [37, 49], [37, 51], [37, 52], [37, 54], [37, 55], [37, 64], [37, 65], [37, 66], [37, 67], [37, 68], [38, 39], [38, 40], [38, 43], [38, 46], [38, 47], [38, 50], [38, 51], [38, 52], [38, 53], [38, 54], [38, 55], [38, 56], [38, 57], [38, 58], [38, 59], [38, 61], [38, 65], [38, 66], [38, 67], [38, 68], [39, 40], [39, 42], [39, 43], [39, 44], [39, 45], [39, 47], [39, 48], [39, 49], [39, 50], [39, 51], [39, 53], [39, 54], [39, 55], [39, 56], [39, 57], [39, 58], [39, 59], [39, 61], [39, 63], [39, 64], [39, 67], [39, 68], [40, 41], [40, 43], [40, 48], [40, 50], [40, 51], [40, 54], [40, 55], [40, 56], [40, 58], [40, 59], [40, 60], [40, 63], [40, 64], [40, 67], [41, 42], [41, 47], [41, 48], [41, 50], [41, 52], [41, 53], [41, 54], [41, 55], [41, 56], [41, 58], [41, 59], [41, 61], [41, 62], [41, 63], [41, 66], [41, 67], [42, 44], [42, 48], [42, 49], [42, 50], [42, 51], [42, 54], [42, 56], [42, 57], [42, 58], [42, 59], [42, 60], [42, 64], [42, 66], [42, 67], [43, 47], [43, 49], [43, 52], [43, 53], [43, 57], [43, 59], [43, 60], [43, 61], [43, 62], [43, 64], [43, 65], [43, 68], [44, 46], [44, 47], [44, 48], [44, 50], [44, 53], [44, 55], [44, 58], [44, 59], [44, 60], [44, 62], [44, 64], [44, 65], [44, 66], [44, 67], [44, 68], [45, 46], [45, 47], [45, 48], [45, 53], [45, 54], [45, 56], [45, 58], [45, 60], [45, 62], [45, 63], [45, 64], [45, 65], [45, 66], [45, 67], [45, 68], [46, 48], [46, 49], [46, 50], [46, 52], [46, 54], [46, 55], [46, 56], [46, 59], [46, 60], [46, 61], [46, 62], [46, 63], [46, 65], [47, 48], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [47, 54], [47, 57], [47, 58], [47, 60], [47, 64], [47, 65], [47, 67], [47, 68], [48, 50], [48, 52], [48, 54], [48, 56], [48, 57], [48, 58], [48, 59], [48, 61], [48, 62], [48, 63], [48, 66], [48, 67], [48, 68], [49, 51], [49, 52], [49, 54], [49, 55], [49, 56], [49, 58], [49, 60], [49, 62], [49, 63], [49, 66], [49, 67], [49, 68], [50, 51], [50, 55], [50, 56], [50, 59], [50, 60], [50, 61], [50, 62], [50, 63], [50, 64], [50, 65], [50, 68], [51, 54], [51, 55], [51, 56], [51, 57], [51, 58], [51, 60], [51, 61], [51, 62], [51, 63], [51, 64], [51, 65], [51, 66], [51, 68], [52, 55], [52, 56], [52, 57], [52, 58], [52, 59], [52, 60], [52, 62], [52, 63], [52, 65], [52, 66], [52, 67], [53, 55], [53, 57], [53, 58], [53, 61], [53, 62], [53, 64], [53, 65], [53, 66], [53, 68], [54, 56], [54, 57], [54, 58], [54, 59], [54, 60], [54, 61], [54, 62], [54, 64], [54, 65], [54, 66], [54, 67], [54, 68], [55, 58], [55, 59], [55, 60], [55, 61], [55, 62], [55, 66], [56, 57], [56, 58], [56, 59], [56, 60], [56, 61], [56, 66], [57, 59], [57, 60], [57, 61], [57, 62], [57, 64], [57, 65], [57, 67], [57, 68], [58, 61], [58, 62], [58, 63], [58, 64], [58, 65], [58, 66], [59, 60], [59, 61], [59, 62], [59, 64], [59, 65], [59, 66], [60, 61], [60, 62], [60, 63], [60, 64], [60, 67], [60, 68], [61, 62], [61, 63], [61, 64], [61, 66], [61, 67], [61, 68], [62, 63], [62, 64], [62, 65], [62, 67], [63, 64], [63, 65], [63, 66], [63, 67], [63, 68], [64, 65], [64, 66], [64, 67], [64, 68], [65, 66], [65, 67], [65, 68], [66, 67], [67, 68]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l4-s2/tests/run.py b/tasks/construct-mc-max-clique-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-clique-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-mc-max-clique-l4-s2/tests/test.sh b/tasks/construct-mc-max-clique-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-clique-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-mc-max-clique-l4-s5/environment/Dockerfile b/tasks/construct-mc-max-clique-l4-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-clique-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-mc-max-clique-l4-s5/environment/instance.json b/tasks/construct-mc-max-clique-l4-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..00d4062e62abe237e8d54b1e9caecb8c36ac0d64 --- /dev/null +++ b/tasks/construct-mc-max-clique-l4-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 55, "k": 7, "edges": [[0, 2], [0, 6], [0, 7], [0, 8], [0, 11], [0, 21], [0, 26], [0, 28], [0, 29], [0, 30], [0, 33], [0, 35], [0, 44], [0, 45], [0, 46], [0, 48], [0, 49], [0, 50], [0, 52], [0, 53], [1, 2], [1, 3], [1, 5], [1, 8], [1, 13], [1, 14], [1, 16], [1, 17], [1, 19], [1, 20], [1, 21], [1, 23], [1, 24], [1, 25], [1, 31], [1, 32], [1, 34], [1, 35], [1, 37], [1, 39], [1, 42], [1, 46], [1, 48], [1, 49], [1, 51], [2, 3], [2, 8], [2, 16], [2, 19], [2, 22], [2, 24], [2, 25], [2, 27], [2, 30], [2, 32], [2, 33], [2, 34], [2, 36], [2, 37], [2, 41], [2, 43], [2, 47], [2, 50], [2, 52], [2, 53], [3, 6], [3, 8], [3, 9], [3, 11], [3, 14], [3, 16], [3, 17], [3, 19], [3, 21], [3, 23], [3, 24], [3, 33], [3, 34], [3, 36], [3, 37], [3, 38], [3, 39], [3, 42], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 51], [3, 52], [3, 53], [3, 54], [4, 5], [4, 6], [4, 7], [4, 9], [4, 13], [4, 15], [4, 17], [4, 20], [4, 21], [4, 22], [4, 24], [4, 25], [4, 29], [4, 31], [4, 33], [4, 35], [4, 36], [4, 37], [4, 42], [4, 43], [4, 44], [4, 45], [4, 47], [4, 48], [4, 49], [4, 50], [4, 53], [4, 54], [5, 6], [5, 7], [5, 11], [5, 12], [5, 14], [5, 15], [5, 17], [5, 20], [5, 22], [5, 24], [5, 25], [5, 27], [5, 30], [5, 32], [5, 34], [5, 40], [5, 42], [5, 43], [5, 45], [5, 46], [5, 47], [5, 50], [5, 51], [5, 52], [5, 53], [5, 54], [6, 7], [6, 8], [6, 9], [6, 11], [6, 17], [6, 21], [6, 24], [6, 25], [6, 26], [6, 28], [6, 29], [6, 31], [6, 32], [6, 33], [6, 34], [6, 35], [6, 37], [6, 38], [6, 39], [6, 40], [6, 42], [6, 47], [6, 50], [6, 51], [6, 54], [7, 11], [7, 13], [7, 14], [7, 17], [7, 19], [7, 21], [7, 23], [7, 25], [7, 29], [7, 33], [7, 36], [7, 38], [7, 39], [7, 40], [7, 41], [7, 42], [7, 46], [7, 49], [8, 9], [8, 10], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 19], [8, 20], [8, 21], [8, 22], [8, 25], [8, 28], [8, 33], [8, 34], [8, 35], [8, 43], [8, 44], [8, 45], [8, 46], [8, 47], [8, 50], [8, 51], [8, 52], [9, 10], [9, 15], [9, 16], [9, 18], [9, 24], [9, 26], [9, 30], [9, 35], [9, 47], [9, 49], [9, 50], [9, 52], [9, 54], [10, 17], [10, 18], [10, 19], [10, 21], [10, 22], [10, 23], [10, 25], [10, 26], [10, 27], [10, 29], [10, 30], [10, 31], [10, 32], [10, 33], [10, 34], [10, 36], [10, 43], [10, 47], [10, 51], [10, 52], [11, 14], [11, 16], [11, 17], [11, 18], [11, 19], [11, 27], [11, 31], [11, 33], [11, 34], [11, 35], [11, 36], [11, 37], [11, 41], [11, 42], [11, 44], [11, 45], [11, 46], [11, 50], [11, 51], [11, 52], [11, 54], [12, 14], [12, 15], [12, 16], [12, 17], [12, 19], [12, 22], [12, 24], [12, 26], [12, 29], [12, 30], [12, 34], [12, 36], [12, 41], [12, 44], [12, 45], [12, 48], [12, 49], [12, 51], [12, 52], [13, 16], [13, 18], [13, 20], [13, 21], [13, 24], [13, 25], [13, 31], [13, 34], [13, 36], [13, 40], [13, 41], [13, 43], [13, 46], [13, 47], [13, 49], [13, 53], [13, 54], [14, 15], [14, 24], [14, 25], [14, 28], [14, 36], [14, 37], [14, 38], [14, 41], [14, 43], [14, 44], [14, 46], [14, 47], [14, 50], [14, 52], [14, 53], [14, 54], [15, 18], [15, 19], [15, 21], [15, 23], [15, 24], [15, 28], [15, 29], [15, 31], [15, 32], [15, 33], [15, 34], [15, 38], [15, 39], [15, 41], [15, 42], [15, 49], [15, 52], [15, 53], [15, 54], [16, 18], [16, 19], [16, 21], [16, 22], [16, 24], [16, 28], [16, 29], [16, 30], [16, 35], [16, 37], [16, 38], [16, 39], [16, 40], [16, 41], [16, 44], [16, 47], [16, 50], [16, 51], [16, 52], [16, 53], [17, 18], [17, 20], [17, 23], [17, 25], [17, 26], [17, 27], [17, 30], [17, 33], [17, 34], [17, 35], [17, 39], [17, 44], [17, 46], [17, 48], [17, 50], [17, 52], [17, 53], [17, 54], [18, 19], [18, 20], [18, 21], [18, 22], [18, 26], [18, 28], [18, 29], [18, 32], [18, 35], [18, 36], [18, 38], [18, 40], [18, 45], [18, 46], [18, 47], [18, 48], [18, 49], [18, 52], [19, 20], [19, 24], [19, 30], [19, 32], [19, 33], [19, 34], [19, 35], [19, 40], [19, 41], [19, 43], [19, 44], [19, 46], [19, 47], [19, 48], [19, 49], [19, 52], [20, 21], [20, 22], [20, 23], [20, 24], [20, 29], [20, 30], [20, 31], [20, 33], [20, 34], [20, 37], [20, 38], [20, 39], [20, 40], [20, 43], [20, 45], [20, 46], [20, 47], [20, 49], [20, 50], [20, 52], [21, 23], [21, 24], [21, 28], [21, 32], [21, 33], [21, 36], [21, 37], [21, 38], [21, 39], [21, 42], [21, 49], [21, 51], [21, 54], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 32], [22, 33], [22, 35], [22, 38], [22, 40], [22, 42], [22, 43], [22, 46], [22, 47], [22, 48], [22, 50], [22, 53], [22, 54], [23, 25], [23, 29], [23, 31], [23, 32], [23, 34], [23, 35], [23, 36], [23, 39], [23, 40], [23, 43], [23, 44], [23, 46], [23, 47], [23, 48], [23, 50], [23, 51], [23, 52], [23, 53], [24, 25], [24, 28], [24, 30], [24, 31], [24, 37], [24, 38], [24, 41], [24, 43], [24, 44], [24, 45], [24, 49], [24, 51], [24, 53], [24, 54], [25, 29], [25, 32], [25, 34], [25, 35], [25, 40], [25, 42], [25, 45], [25, 46], [25, 47], [25, 49], [25, 51], [26, 29], [26, 30], [26, 31], [26, 32], [26, 38], [26, 43], [26, 46], [26, 47], [26, 50], [26, 53], [27, 28], [27, 32], [27, 33], [27, 34], [27, 36], [27, 37], [27, 42], [27, 44], [27, 45], [27, 46], [27, 47], [27, 52], [27, 53], [28, 30], [28, 34], [28, 37], [28, 40], [28, 41], [28, 45], [28, 46], [28, 53], [29, 32], [29, 33], [29, 34], [29, 36], [29, 37], [29, 42], [29, 43], [29, 44], [29, 45], [29, 52], [29, 53], [29, 54], [30, 31], [30, 32], [30, 33], [30, 34], [30, 36], [30, 39], [30, 41], [30, 42], [30, 52], [30, 54], [31, 33], [31, 36], [31, 37], [31, 38], [31, 40], [31, 43], [31, 45], [31, 51], [31, 52], [31, 54], [32, 33], [32, 34], [32, 41], [32, 42], [32, 43], [32, 45], [32, 47], [32, 49], [32, 52], [33, 35], [33, 36], [33, 39], [33, 40], [33, 41], [33, 42], [33, 43], [33, 44], [33, 47], [33, 48], [33, 49], [33, 50], [33, 51], [33, 53], [34, 38], [34, 39], [34, 41], [34, 42], [34, 43], [34, 44], [34, 46], [34, 49], [34, 53], [35, 37], [35, 39], [35, 40], [35, 41], [35, 43], [35, 45], [35, 47], [35, 48], [35, 50], [35, 51], [36, 37], [36, 38], [36, 39], [36, 45], [36, 47], [36, 48], [36, 49], [36, 52], [36, 53], [36, 54], [37, 38], [37, 44], [37, 47], [37, 48], [37, 52], [37, 53], [37, 54], [38, 39], [38, 40], [38, 42], [38, 49], [38, 50], [38, 53], [39, 40], [39, 41], [39, 45], [39, 46], [39, 51], [39, 54], [40, 42], [40, 43], [40, 44], [40, 46], [40, 47], [40, 49], [40, 50], [40, 51], [41, 42], [41, 47], [41, 48], [41, 53], [42, 44], [42, 45], [42, 48], [42, 49], [42, 53], [42, 54], [43, 46], [43, 47], [43, 54], [44, 46], [44, 48], [44, 50], [44, 51], [44, 52], [45, 47], [45, 50], [45, 54], [46, 47], [46, 49], [46, 50], [46, 54], [47, 51], [47, 54], [48, 50], [48, 52], [48, 54], [49, 52], [50, 51], [50, 52], [52, 53], [52, 54]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l4-s5/solution/solve.sh b/tasks/construct-mc-max-clique-l4-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..acbf28d7cc9a768f26d0f2dcd09189ced5eff72e --- /dev/null +++ b/tasks/construct-mc-max-clique-l4-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [1, 3, 17, 23, 34, 39, 46]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-clique-l4-s5/tests/check.py b/tasks/construct-mc-max-clique-l4-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3f70dbd5b155a3514c2102aa4ad460201495210 --- /dev/null +++ b/tasks/construct-mc-max-clique-l4-s5/tests/check.py @@ -0,0 +1,18 @@ +"""Clique of size >= k in a given graph (MathConstraint max_clique decision version, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"clique has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) not in E: + raise Invalid(f"vertices {u} and {v} are not adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-clique-l4-s5/tests/instance.json b/tasks/construct-mc-max-clique-l4-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..00d4062e62abe237e8d54b1e9caecb8c36ac0d64 --- /dev/null +++ b/tasks/construct-mc-max-clique-l4-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 55, "k": 7, "edges": [[0, 2], [0, 6], [0, 7], [0, 8], [0, 11], [0, 21], [0, 26], [0, 28], [0, 29], [0, 30], [0, 33], [0, 35], [0, 44], [0, 45], [0, 46], [0, 48], [0, 49], [0, 50], [0, 52], [0, 53], [1, 2], [1, 3], [1, 5], [1, 8], [1, 13], [1, 14], [1, 16], [1, 17], [1, 19], [1, 20], [1, 21], [1, 23], [1, 24], [1, 25], [1, 31], [1, 32], [1, 34], [1, 35], [1, 37], [1, 39], [1, 42], [1, 46], [1, 48], [1, 49], [1, 51], [2, 3], [2, 8], [2, 16], [2, 19], [2, 22], [2, 24], [2, 25], [2, 27], [2, 30], [2, 32], [2, 33], [2, 34], [2, 36], [2, 37], [2, 41], [2, 43], [2, 47], [2, 50], [2, 52], [2, 53], [3, 6], [3, 8], [3, 9], [3, 11], [3, 14], [3, 16], [3, 17], [3, 19], [3, 21], [3, 23], [3, 24], [3, 33], [3, 34], [3, 36], [3, 37], [3, 38], [3, 39], [3, 42], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 51], [3, 52], [3, 53], [3, 54], [4, 5], [4, 6], [4, 7], [4, 9], [4, 13], [4, 15], [4, 17], [4, 20], [4, 21], [4, 22], [4, 24], [4, 25], [4, 29], [4, 31], [4, 33], [4, 35], [4, 36], [4, 37], [4, 42], [4, 43], [4, 44], [4, 45], [4, 47], [4, 48], [4, 49], [4, 50], [4, 53], [4, 54], [5, 6], [5, 7], [5, 11], [5, 12], [5, 14], [5, 15], [5, 17], [5, 20], [5, 22], [5, 24], [5, 25], [5, 27], [5, 30], [5, 32], [5, 34], [5, 40], [5, 42], [5, 43], [5, 45], [5, 46], [5, 47], [5, 50], [5, 51], [5, 52], [5, 53], [5, 54], [6, 7], [6, 8], [6, 9], [6, 11], [6, 17], [6, 21], [6, 24], [6, 25], [6, 26], [6, 28], [6, 29], [6, 31], [6, 32], [6, 33], [6, 34], [6, 35], [6, 37], [6, 38], [6, 39], [6, 40], [6, 42], [6, 47], [6, 50], [6, 51], [6, 54], [7, 11], [7, 13], [7, 14], [7, 17], [7, 19], [7, 21], [7, 23], [7, 25], [7, 29], [7, 33], [7, 36], [7, 38], [7, 39], [7, 40], [7, 41], [7, 42], [7, 46], [7, 49], [8, 9], [8, 10], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 19], [8, 20], [8, 21], [8, 22], [8, 25], [8, 28], [8, 33], [8, 34], [8, 35], [8, 43], [8, 44], [8, 45], [8, 46], [8, 47], [8, 50], [8, 51], [8, 52], [9, 10], [9, 15], [9, 16], [9, 18], [9, 24], [9, 26], [9, 30], [9, 35], [9, 47], [9, 49], [9, 50], [9, 52], [9, 54], [10, 17], [10, 18], [10, 19], [10, 21], [10, 22], [10, 23], [10, 25], [10, 26], [10, 27], [10, 29], [10, 30], [10, 31], [10, 32], [10, 33], [10, 34], [10, 36], [10, 43], [10, 47], [10, 51], [10, 52], [11, 14], [11, 16], [11, 17], [11, 18], [11, 19], [11, 27], [11, 31], [11, 33], [11, 34], [11, 35], [11, 36], [11, 37], [11, 41], [11, 42], [11, 44], [11, 45], [11, 46], [11, 50], [11, 51], [11, 52], [11, 54], [12, 14], [12, 15], [12, 16], [12, 17], [12, 19], [12, 22], [12, 24], [12, 26], [12, 29], [12, 30], [12, 34], [12, 36], [12, 41], [12, 44], [12, 45], [12, 48], [12, 49], [12, 51], [12, 52], [13, 16], [13, 18], [13, 20], [13, 21], [13, 24], [13, 25], [13, 31], [13, 34], [13, 36], [13, 40], [13, 41], [13, 43], [13, 46], [13, 47], [13, 49], [13, 53], [13, 54], [14, 15], [14, 24], [14, 25], [14, 28], [14, 36], [14, 37], [14, 38], [14, 41], [14, 43], [14, 44], [14, 46], [14, 47], [14, 50], [14, 52], [14, 53], [14, 54], [15, 18], [15, 19], [15, 21], [15, 23], [15, 24], [15, 28], [15, 29], [15, 31], [15, 32], [15, 33], [15, 34], [15, 38], [15, 39], [15, 41], [15, 42], [15, 49], [15, 52], [15, 53], [15, 54], [16, 18], [16, 19], [16, 21], [16, 22], [16, 24], [16, 28], [16, 29], [16, 30], [16, 35], [16, 37], [16, 38], [16, 39], [16, 40], [16, 41], [16, 44], [16, 47], [16, 50], [16, 51], [16, 52], [16, 53], [17, 18], [17, 20], [17, 23], [17, 25], [17, 26], [17, 27], [17, 30], [17, 33], [17, 34], [17, 35], [17, 39], [17, 44], [17, 46], [17, 48], [17, 50], [17, 52], [17, 53], [17, 54], [18, 19], [18, 20], [18, 21], [18, 22], [18, 26], [18, 28], [18, 29], [18, 32], [18, 35], [18, 36], [18, 38], [18, 40], [18, 45], [18, 46], [18, 47], [18, 48], [18, 49], [18, 52], [19, 20], [19, 24], [19, 30], [19, 32], [19, 33], [19, 34], [19, 35], [19, 40], [19, 41], [19, 43], [19, 44], [19, 46], [19, 47], [19, 48], [19, 49], [19, 52], [20, 21], [20, 22], [20, 23], [20, 24], [20, 29], [20, 30], [20, 31], [20, 33], [20, 34], [20, 37], [20, 38], [20, 39], [20, 40], [20, 43], [20, 45], [20, 46], [20, 47], [20, 49], [20, 50], [20, 52], [21, 23], [21, 24], [21, 28], [21, 32], [21, 33], [21, 36], [21, 37], [21, 38], [21, 39], [21, 42], [21, 49], [21, 51], [21, 54], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 32], [22, 33], [22, 35], [22, 38], [22, 40], [22, 42], [22, 43], [22, 46], [22, 47], [22, 48], [22, 50], [22, 53], [22, 54], [23, 25], [23, 29], [23, 31], [23, 32], [23, 34], [23, 35], [23, 36], [23, 39], [23, 40], [23, 43], [23, 44], [23, 46], [23, 47], [23, 48], [23, 50], [23, 51], [23, 52], [23, 53], [24, 25], [24, 28], [24, 30], [24, 31], [24, 37], [24, 38], [24, 41], [24, 43], [24, 44], [24, 45], [24, 49], [24, 51], [24, 53], [24, 54], [25, 29], [25, 32], [25, 34], [25, 35], [25, 40], [25, 42], [25, 45], [25, 46], [25, 47], [25, 49], [25, 51], [26, 29], [26, 30], [26, 31], [26, 32], [26, 38], [26, 43], [26, 46], [26, 47], [26, 50], [26, 53], [27, 28], [27, 32], [27, 33], [27, 34], [27, 36], [27, 37], [27, 42], [27, 44], [27, 45], [27, 46], [27, 47], [27, 52], [27, 53], [28, 30], [28, 34], [28, 37], [28, 40], [28, 41], [28, 45], [28, 46], [28, 53], [29, 32], [29, 33], [29, 34], [29, 36], [29, 37], [29, 42], [29, 43], [29, 44], [29, 45], [29, 52], [29, 53], [29, 54], [30, 31], [30, 32], [30, 33], [30, 34], [30, 36], [30, 39], [30, 41], [30, 42], [30, 52], [30, 54], [31, 33], [31, 36], [31, 37], [31, 38], [31, 40], [31, 43], [31, 45], [31, 51], [31, 52], [31, 54], [32, 33], [32, 34], [32, 41], [32, 42], [32, 43], [32, 45], [32, 47], [32, 49], [32, 52], [33, 35], [33, 36], [33, 39], [33, 40], [33, 41], [33, 42], [33, 43], [33, 44], [33, 47], [33, 48], [33, 49], [33, 50], [33, 51], [33, 53], [34, 38], [34, 39], [34, 41], [34, 42], [34, 43], [34, 44], [34, 46], [34, 49], [34, 53], [35, 37], [35, 39], [35, 40], [35, 41], [35, 43], [35, 45], [35, 47], [35, 48], [35, 50], [35, 51], [36, 37], [36, 38], [36, 39], [36, 45], [36, 47], [36, 48], [36, 49], [36, 52], [36, 53], [36, 54], [37, 38], [37, 44], [37, 47], [37, 48], [37, 52], [37, 53], [37, 54], [38, 39], [38, 40], [38, 42], [38, 49], [38, 50], [38, 53], [39, 40], [39, 41], [39, 45], [39, 46], [39, 51], [39, 54], [40, 42], [40, 43], [40, 44], [40, 46], [40, 47], [40, 49], [40, 50], [40, 51], [41, 42], [41, 47], [41, 48], [41, 53], [42, 44], [42, 45], [42, 48], [42, 49], [42, 53], [42, 54], [43, 46], [43, 47], [43, 54], [44, 46], [44, 48], [44, 50], [44, 51], [44, 52], [45, 47], [45, 50], [45, 54], [46, 47], [46, 49], [46, 50], [46, 54], [47, 51], [47, 54], [48, 50], [48, 52], [48, 54], [49, 52], [50, 51], [50, 52], [52, 53], [52, 54]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l4-s5/tests/run.py b/tasks/construct-mc-max-clique-l4-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-clique-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-mc-max-clique-l4-s5/tests/test.sh b/tasks/construct-mc-max-clique-l4-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-clique-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-mc-max-independent-set-l3-s6/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-max-independent-set-l3-s6/environment/instance.json b/tasks/construct-mc-max-independent-set-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d4bcfa245ddbff4cbda2023d3a8c0099c7ddc403 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 45, "k": 11, "edges": [[0, 2], [0, 6], [0, 9], [0, 11], [0, 12], [0, 14], [0, 15], [0, 17], [0, 18], [0, 22], [0, 25], [0, 33], [0, 36], [0, 37], [0, 39], [0, 40], [1, 3], [1, 10], [1, 17], [1, 20], [1, 22], [1, 23], [2, 5], [2, 6], [2, 10], [2, 11], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 19], [2, 21], [2, 22], [2, 23], [2, 25], [2, 30], [2, 31], [2, 36], [2, 39], [3, 9], [3, 20], [3, 22], [3, 23], [3, 28], [3, 31], [3, 32], [3, 37], [3, 38], [4, 7], [4, 9], [4, 11], [4, 15], [4, 24], [4, 26], [4, 35], [4, 42], [4, 43], [4, 44], [5, 7], [5, 13], [5, 15], [5, 17], [5, 26], [5, 31], [6, 8], [6, 9], [6, 10], [6, 15], [6, 16], [6, 17], [6, 19], [6, 20], [6, 23], [6, 24], [6, 28], [6, 32], [6, 35], [6, 36], [6, 41], [6, 44], [7, 10], [7, 12], [7, 15], [7, 17], [7, 31], [7, 33], [7, 43], [7, 44], [8, 10], [8, 26], [8, 27], [8, 32], [8, 33], [8, 34], [8, 37], [9, 10], [9, 15], [9, 16], [9, 21], [9, 27], [9, 30], [9, 35], [10, 14], [10, 15], [10, 16], [10, 18], [10, 21], [10, 22], [10, 32], [10, 34], [10, 37], [10, 38], [10, 41], [11, 12], [11, 15], [11, 21], [11, 22], [11, 28], [11, 33], [12, 21], [12, 23], [12, 24], [12, 25], [12, 28], [12, 29], [12, 30], [12, 36], [12, 40], [12, 43], [12, 44], [13, 17], [13, 20], [13, 26], [13, 29], [13, 36], [13, 40], [13, 42], [13, 43], [14, 15], [14, 18], [14, 19], [14, 20], [14, 21], [14, 24], [14, 25], [14, 31], [14, 36], [14, 37], [14, 41], [15, 16], [15, 27], [15, 28], [15, 29], [15, 34], [15, 41], [16, 21], [16, 31], [16, 32], [16, 33], [16, 35], [16, 37], [16, 39], [16, 43], [17, 26], [17, 31], [17, 32], [17, 33], [17, 39], [17, 43], [17, 44], [18, 20], [18, 21], [18, 23], [18, 27], [18, 30], [18, 37], [19, 20], [19, 25], [19, 28], [19, 33], [19, 34], [19, 38], [19, 42], [20, 30], [20, 31], [20, 32], [20, 42], [21, 23], [21, 25], [21, 27], [21, 33], [21, 36], [21, 38], [21, 39], [21, 40], [21, 42], [22, 25], [22, 33], [22, 35], [22, 36], [22, 38], [22, 39], [23, 24], [23, 28], [23, 29], [23, 32], [23, 34], [23, 35], [23, 36], [23, 38], [23, 40], [23, 41], [24, 25], [24, 28], [24, 30], [24, 33], [24, 37], [24, 42], [24, 43], [25, 26], [25, 29], [25, 30], [25, 32], [25, 33], [25, 36], [25, 37], [25, 38], [25, 40], [26, 29], [26, 30], [26, 36], [26, 38], [26, 39], [27, 28], [27, 31], [27, 33], [27, 35], [27, 39], [27, 42], [28, 29], [28, 31], [28, 34], [28, 36], [28, 37], [28, 38], [28, 44], [29, 32], [29, 36], [29, 37], [29, 38], [29, 39], [29, 40], [29, 43], [30, 32], [30, 33], [30, 34], [30, 35], [30, 38], [30, 41], [30, 43], [30, 44], [31, 34], [31, 40], [32, 36], [32, 37], [32, 40], [33, 34], [33, 35], [33, 37], [33, 39], [33, 42], [34, 42], [35, 36], [35, 38], [35, 41], [35, 42], [36, 38], [36, 40], [36, 44], [37, 43], [38, 41], [38, 43], [39, 40], [39, 42], [40, 41], [41, 43], [42, 44]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l3-s6/solution/solve.sh b/tasks/construct-mc-max-independent-set-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7d53404ade4a2fcf428851262e21452380c7330e --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"independent_set": [9, 11, 13, 18, 19, 24, 31, 32, 39, 41, 44]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l3-s6/tests/check.py b/tasks/construct-mc-max-independent-set-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s6/tests/check.py @@ -0,0 +1,18 @@ +"""Independent set of size >= k in a given graph (MathConstraint max_independent_set, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"set has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) in E: + raise Invalid(f"vertices {u} and {v} are adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-independent-set-l3-s6/tests/instance.json b/tasks/construct-mc-max-independent-set-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d4bcfa245ddbff4cbda2023d3a8c0099c7ddc403 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 45, "k": 11, "edges": [[0, 2], [0, 6], [0, 9], [0, 11], [0, 12], [0, 14], [0, 15], [0, 17], [0, 18], [0, 22], [0, 25], [0, 33], [0, 36], [0, 37], [0, 39], [0, 40], [1, 3], [1, 10], [1, 17], [1, 20], [1, 22], [1, 23], [2, 5], [2, 6], [2, 10], [2, 11], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 19], [2, 21], [2, 22], [2, 23], [2, 25], [2, 30], [2, 31], [2, 36], [2, 39], [3, 9], [3, 20], [3, 22], [3, 23], [3, 28], [3, 31], [3, 32], [3, 37], [3, 38], [4, 7], [4, 9], [4, 11], [4, 15], [4, 24], [4, 26], [4, 35], [4, 42], [4, 43], [4, 44], [5, 7], [5, 13], [5, 15], [5, 17], [5, 26], [5, 31], [6, 8], [6, 9], [6, 10], [6, 15], [6, 16], [6, 17], [6, 19], [6, 20], [6, 23], [6, 24], [6, 28], [6, 32], [6, 35], [6, 36], [6, 41], [6, 44], [7, 10], [7, 12], [7, 15], [7, 17], [7, 31], [7, 33], [7, 43], [7, 44], [8, 10], [8, 26], [8, 27], [8, 32], [8, 33], [8, 34], [8, 37], [9, 10], [9, 15], [9, 16], [9, 21], [9, 27], [9, 30], [9, 35], [10, 14], [10, 15], [10, 16], [10, 18], [10, 21], [10, 22], [10, 32], [10, 34], [10, 37], [10, 38], [10, 41], [11, 12], [11, 15], [11, 21], [11, 22], [11, 28], [11, 33], [12, 21], [12, 23], [12, 24], [12, 25], [12, 28], [12, 29], [12, 30], [12, 36], [12, 40], [12, 43], [12, 44], [13, 17], [13, 20], [13, 26], [13, 29], [13, 36], [13, 40], [13, 42], [13, 43], [14, 15], [14, 18], [14, 19], [14, 20], [14, 21], [14, 24], [14, 25], [14, 31], [14, 36], [14, 37], [14, 41], [15, 16], [15, 27], [15, 28], [15, 29], [15, 34], [15, 41], [16, 21], [16, 31], [16, 32], [16, 33], [16, 35], [16, 37], [16, 39], [16, 43], [17, 26], [17, 31], [17, 32], [17, 33], [17, 39], [17, 43], [17, 44], [18, 20], [18, 21], [18, 23], [18, 27], [18, 30], [18, 37], [19, 20], [19, 25], [19, 28], [19, 33], [19, 34], [19, 38], [19, 42], [20, 30], [20, 31], [20, 32], [20, 42], [21, 23], [21, 25], [21, 27], [21, 33], [21, 36], [21, 38], [21, 39], [21, 40], [21, 42], [22, 25], [22, 33], [22, 35], [22, 36], [22, 38], [22, 39], [23, 24], [23, 28], [23, 29], [23, 32], [23, 34], [23, 35], [23, 36], [23, 38], [23, 40], [23, 41], [24, 25], [24, 28], [24, 30], [24, 33], [24, 37], [24, 42], [24, 43], [25, 26], [25, 29], [25, 30], [25, 32], [25, 33], [25, 36], [25, 37], [25, 38], [25, 40], [26, 29], [26, 30], [26, 36], [26, 38], [26, 39], [27, 28], [27, 31], [27, 33], [27, 35], [27, 39], [27, 42], [28, 29], [28, 31], [28, 34], [28, 36], [28, 37], [28, 38], [28, 44], [29, 32], [29, 36], [29, 37], [29, 38], [29, 39], [29, 40], [29, 43], [30, 32], [30, 33], [30, 34], [30, 35], [30, 38], [30, 41], [30, 43], [30, 44], [31, 34], [31, 40], [32, 36], [32, 37], [32, 40], [33, 34], [33, 35], [33, 37], [33, 39], [33, 42], [34, 42], [35, 36], [35, 38], [35, 41], [35, 42], [36, 38], [36, 40], [36, 44], [37, 43], [38, 41], [38, 43], [39, 40], [39, 42], [40, 41], [41, 43], [42, 44]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l3-s6/tests/run.py b/tasks/construct-mc-max-independent-set-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-max-independent-set-l3-s6/tests/test.sh b/tasks/construct-mc-max-independent-set-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-max-independent-set-l3-s8/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l3-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-max-independent-set-l3-s8/environment/instance.json b/tasks/construct-mc-max-independent-set-l3-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..77f5919ca744577f87fc5e42471717c2ab636f5e --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 45, "k": 11, "edges": [[0, 9], [0, 12], [0, 13], [0, 15], [0, 17], [0, 19], [0, 20], [0, 23], [0, 27], [0, 30], [0, 32], [0, 40], [0, 43], [1, 7], [1, 10], [1, 13], [1, 18], [1, 22], [1, 23], [1, 25], [1, 27], [1, 28], [1, 30], [1, 32], [1, 33], [1, 36], [2, 6], [2, 8], [2, 10], [2, 12], [2, 15], [2, 33], [2, 34], [2, 38], [2, 40], [3, 6], [3, 16], [3, 18], [3, 21], [3, 23], [3, 25], [3, 29], [3, 31], [3, 32], [3, 33], [3, 35], [3, 40], [3, 44], [4, 5], [4, 6], [4, 10], [4, 13], [4, 14], [4, 15], [4, 20], [4, 25], [4, 36], [4, 37], [4, 38], [4, 42], [5, 7], [5, 9], [5, 12], [5, 17], [5, 22], [5, 37], [5, 40], [5, 43], [6, 8], [6, 10], [6, 12], [6, 13], [6, 20], [6, 27], [6, 29], [6, 30], [6, 33], [6, 35], [6, 38], [6, 39], [6, 41], [6, 42], [7, 8], [7, 9], [7, 10], [7, 11], [7, 17], [7, 21], [7, 22], [7, 28], [7, 30], [7, 33], [7, 34], [7, 40], [7, 42], [7, 44], [8, 15], [8, 18], [8, 21], [8, 27], [8, 29], [8, 32], [8, 33], [8, 38], [8, 43], [9, 10], [9, 14], [9, 18], [9, 21], [9, 25], [9, 26], [9, 28], [9, 31], [9, 33], [9, 34], [9, 38], [10, 21], [10, 26], [10, 39], [10, 42], [11, 13], [11, 15], [11, 16], [11, 19], [11, 22], [11, 28], [11, 29], [11, 33], [11, 35], [11, 37], [11, 40], [11, 43], [12, 16], [12, 17], [12, 19], [12, 29], [12, 35], [12, 37], [12, 39], [12, 41], [13, 18], [13, 19], [13, 21], [13, 26], [13, 35], [13, 39], [13, 43], [13, 44], [14, 16], [14, 22], [14, 29], [14, 30], [14, 31], [14, 32], [14, 34], [14, 35], [14, 36], [14, 37], [14, 43], [15, 21], [15, 28], [15, 29], [15, 32], [15, 33], [15, 34], [15, 36], [15, 38], [15, 42], [15, 43], [16, 17], [16, 18], [16, 33], [16, 38], [16, 39], [16, 40], [16, 41], [16, 44], [17, 26], [17, 27], [17, 28], [17, 29], [17, 31], [17, 33], [17, 38], [17, 40], [17, 41], [17, 44], [18, 23], [18, 36], [18, 37], [18, 40], [19, 22], [19, 25], [19, 26], [19, 29], [19, 35], [19, 36], [19, 38], [19, 41], [20, 23], [20, 25], [20, 27], [20, 28], [20, 31], [20, 36], [20, 38], [20, 39], [20, 42], [20, 43], [21, 26], [21, 36], [21, 38], [21, 39], [21, 40], [21, 41], [21, 43], [22, 31], [22, 34], [22, 36], [23, 25], [23, 30], [23, 36], [23, 38], [23, 39], [23, 40], [23, 44], [24, 31], [24, 40], [24, 43], [25, 31], [25, 35], [25, 40], [26, 27], [26, 40], [27, 29], [27, 31], [27, 34], [27, 36], [27, 42], [28, 34], [28, 37], [28, 40], [29, 31], [29, 33], [29, 35], [29, 40], [29, 43], [29, 44], [30, 32], [30, 35], [30, 36], [30, 37], [30, 43], [31, 32], [31, 41], [31, 43], [32, 35], [32, 36], [32, 38], [32, 39], [33, 39], [33, 40], [34, 39], [34, 40], [34, 41], [35, 37], [35, 43], [36, 39], [37, 44], [39, 41], [39, 42], [40, 42], [40, 43], [40, 44], [42, 43], [43, 44]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l3-s8/solution/solve.sh b/tasks/construct-mc-max-independent-set-l3-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4e5647fcdcda74fab77abb687135a53a5166a67b --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"independent_set": [2, 9, 13, 16, 22, 23, 24, 29, 32, 37, 42]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l3-s8/tests/check.py b/tasks/construct-mc-max-independent-set-l3-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s8/tests/check.py @@ -0,0 +1,18 @@ +"""Independent set of size >= k in a given graph (MathConstraint max_independent_set, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"set has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) in E: + raise Invalid(f"vertices {u} and {v} are adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-independent-set-l3-s8/tests/instance.json b/tasks/construct-mc-max-independent-set-l3-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..77f5919ca744577f87fc5e42471717c2ab636f5e --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 45, "k": 11, "edges": [[0, 9], [0, 12], [0, 13], [0, 15], [0, 17], [0, 19], [0, 20], [0, 23], [0, 27], [0, 30], [0, 32], [0, 40], [0, 43], [1, 7], [1, 10], [1, 13], [1, 18], [1, 22], [1, 23], [1, 25], [1, 27], [1, 28], [1, 30], [1, 32], [1, 33], [1, 36], [2, 6], [2, 8], [2, 10], [2, 12], [2, 15], [2, 33], [2, 34], [2, 38], [2, 40], [3, 6], [3, 16], [3, 18], [3, 21], [3, 23], [3, 25], [3, 29], [3, 31], [3, 32], [3, 33], [3, 35], [3, 40], [3, 44], [4, 5], [4, 6], [4, 10], [4, 13], [4, 14], [4, 15], [4, 20], [4, 25], [4, 36], [4, 37], [4, 38], [4, 42], [5, 7], [5, 9], [5, 12], [5, 17], [5, 22], [5, 37], [5, 40], [5, 43], [6, 8], [6, 10], [6, 12], [6, 13], [6, 20], [6, 27], [6, 29], [6, 30], [6, 33], [6, 35], [6, 38], [6, 39], [6, 41], [6, 42], [7, 8], [7, 9], [7, 10], [7, 11], [7, 17], [7, 21], [7, 22], [7, 28], [7, 30], [7, 33], [7, 34], [7, 40], [7, 42], [7, 44], [8, 15], [8, 18], [8, 21], [8, 27], [8, 29], [8, 32], [8, 33], [8, 38], [8, 43], [9, 10], [9, 14], [9, 18], [9, 21], [9, 25], [9, 26], [9, 28], [9, 31], [9, 33], [9, 34], [9, 38], [10, 21], [10, 26], [10, 39], [10, 42], [11, 13], [11, 15], [11, 16], [11, 19], [11, 22], [11, 28], [11, 29], [11, 33], [11, 35], [11, 37], [11, 40], [11, 43], [12, 16], [12, 17], [12, 19], [12, 29], [12, 35], [12, 37], [12, 39], [12, 41], [13, 18], [13, 19], [13, 21], [13, 26], [13, 35], [13, 39], [13, 43], [13, 44], [14, 16], [14, 22], [14, 29], [14, 30], [14, 31], [14, 32], [14, 34], [14, 35], [14, 36], [14, 37], [14, 43], [15, 21], [15, 28], [15, 29], [15, 32], [15, 33], [15, 34], [15, 36], [15, 38], [15, 42], [15, 43], [16, 17], [16, 18], [16, 33], [16, 38], [16, 39], [16, 40], [16, 41], [16, 44], [17, 26], [17, 27], [17, 28], [17, 29], [17, 31], [17, 33], [17, 38], [17, 40], [17, 41], [17, 44], [18, 23], [18, 36], [18, 37], [18, 40], [19, 22], [19, 25], [19, 26], [19, 29], [19, 35], [19, 36], [19, 38], [19, 41], [20, 23], [20, 25], [20, 27], [20, 28], [20, 31], [20, 36], [20, 38], [20, 39], [20, 42], [20, 43], [21, 26], [21, 36], [21, 38], [21, 39], [21, 40], [21, 41], [21, 43], [22, 31], [22, 34], [22, 36], [23, 25], [23, 30], [23, 36], [23, 38], [23, 39], [23, 40], [23, 44], [24, 31], [24, 40], [24, 43], [25, 31], [25, 35], [25, 40], [26, 27], [26, 40], [27, 29], [27, 31], [27, 34], [27, 36], [27, 42], [28, 34], [28, 37], [28, 40], [29, 31], [29, 33], [29, 35], [29, 40], [29, 43], [29, 44], [30, 32], [30, 35], [30, 36], [30, 37], [30, 43], [31, 32], [31, 41], [31, 43], [32, 35], [32, 36], [32, 38], [32, 39], [33, 39], [33, 40], [34, 39], [34, 40], [34, 41], [35, 37], [35, 43], [36, 39], [37, 44], [39, 41], [39, 42], [40, 42], [40, 43], [40, 44], [42, 43], [43, 44]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l3-s8/tests/run.py b/tasks/construct-mc-max-independent-set-l3-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-max-independent-set-l3-s8/tests/test.sh b/tasks/construct-mc-max-independent-set-l3-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-clique-coloring-l2-s0/environment/Dockerfile b/tasks/construct-mc-pysms-clique-coloring-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-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-clique-coloring-l2-s0/environment/instance.json b/tasks/construct-mc-pysms-clique-coloring-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f6cbef7b8e92e6b81d5f2cf28ff7175abd7f3240 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 12, "required_edges": [[1, 2], [0, 2], [1, 4], [2, 9], [2, 7]], "max_chromatic_number": 3, "max_clique": 5, "min_degree": 3, "family": "mc_pysms_clique_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-clique-coloring-l2-s0/solution/solve.sh b/tasks/construct-mc-pysms-clique-coloring-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..04c08f88d3cd052dec73656051f2a00f9e1b334e --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-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, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11]], "coloring": [1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-clique-coloring-l2-s0/tests/check.py b/tasks/construct-mc-pysms-clique-coloring-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-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-clique-coloring-l2-s0/tests/instance.json b/tasks/construct-mc-pysms-clique-coloring-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f6cbef7b8e92e6b81d5f2cf28ff7175abd7f3240 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 12, "required_edges": [[1, 2], [0, 2], [1, 4], [2, 9], [2, 7]], "max_chromatic_number": 3, "max_clique": 5, "min_degree": 3, "family": "mc_pysms_clique_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-clique-coloring-l2-s0/tests/run.py b/tasks/construct-mc-pysms-clique-coloring-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-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-clique-coloring-l2-s0/tests/test.sh b/tasks/construct-mc-pysms-clique-coloring-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-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-pysms-independent-connectivity-l3-s0/environment/Dockerfile b/tasks/construct-mc-pysms-independent-connectivity-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-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-mc-pysms-independent-connectivity-l3-s0/environment/instance.json b/tasks/construct-mc-pysms-independent-connectivity-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ba237d76b03dadcbc342599abec7723fe61400c2 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 16, "required_edges": [[6, 14], [13, 14], [0, 12], [2, 11], [2, 10], [8, 14], [7, 14], [6, 15], [5, 13], [12, 15], [2, 14], [0, 11], [0, 8], [8, 15], [14, 15], [4, 5], [5, 7], [2, 13], [0, 2], [0, 1], [0, 10], [0, 5], [10, 11], [3, 7]], "max_independent_set": 5, "min_connectivity": 1, "family": "mc_pysms_independent_connectivity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-independent-connectivity-l3-s0/solution/solve.sh b/tasks/construct-mc-pysms-independent-connectivity-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4b8141dfb1b77c83fdaab714902ed360207c54d0 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-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' +{"edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [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], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [11, 12], [11, 13], [11, 14], [11, 15], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-independent-connectivity-l3-s0/tests/check.py b/tasks/construct-mc-pysms-independent-connectivity-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l3-s0/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-independent-connectivity-l3-s0/tests/instance.json b/tasks/construct-mc-pysms-independent-connectivity-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ba237d76b03dadcbc342599abec7723fe61400c2 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 16, "required_edges": [[6, 14], [13, 14], [0, 12], [2, 11], [2, 10], [8, 14], [7, 14], [6, 15], [5, 13], [12, 15], [2, 14], [0, 11], [0, 8], [8, 15], [14, 15], [4, 5], [5, 7], [2, 13], [0, 2], [0, 1], [0, 10], [0, 5], [10, 11], [3, 7]], "max_independent_set": 5, "min_connectivity": 1, "family": "mc_pysms_independent_connectivity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-independent-connectivity-l3-s0/tests/run.py b/tasks/construct-mc-pysms-independent-connectivity-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-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-mc-pysms-independent-connectivity-l3-s0/tests/test.sh b/tasks/construct-mc-pysms-independent-connectivity-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-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-mc-pysms-min-connectivity-l5-s0/environment/Dockerfile b/tasks/construct-mc-pysms-min-connectivity-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-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-pysms-min-connectivity-l5-s0/environment/instance.json b/tasks/construct-mc-pysms-min-connectivity-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..01143a78e0eccedc56ccaf93c9ce7c1affcd4ffd --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 18, "required_edges": [[2, 9], [0, 10], [15, 17], [12, 15], [2, 6], [3, 17], [0, 14], [11, 13], [9, 14], [6, 12], [10, 13], [1, 10], [11, 17], [10, 16], [1, 5], [6, 14], [5, 10], [1, 9], [4, 14], [15, 16], [3, 12], [13, 16], [2, 3], [10, 15], [7, 13], [6, 16], [2, 8], [3, 10], [0, 15], [2, 16]], "min_connectivity": 4, "family": "mc_pysms_min_connectivity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-connectivity-l5-s0/solution/solve.sh b/tasks/construct-mc-pysms-min-connectivity-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..eb6e7062cc9837f07c0c2fa725d985e6483a6394 --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-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' +{"edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [13, 14], [13, 15], [13, 16], [13, 17], [14, 15], [14, 16], [14, 17], [15, 16], [15, 17], [16, 17]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-min-connectivity-l5-s0/tests/check.py b/tasks/construct-mc-pysms-min-connectivity-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-l5-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-connectivity-l5-s0/tests/instance.json b/tasks/construct-mc-pysms-min-connectivity-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..01143a78e0eccedc56ccaf93c9ce7c1affcd4ffd --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 18, "required_edges": [[2, 9], [0, 10], [15, 17], [12, 15], [2, 6], [3, 17], [0, 14], [11, 13], [9, 14], [6, 12], [10, 13], [1, 10], [11, 17], [10, 16], [1, 5], [6, 14], [5, 10], [1, 9], [4, 14], [15, 16], [3, 12], [13, 16], [2, 3], [10, 15], [7, 13], [6, 16], [2, 8], [3, 10], [0, 15], [2, 16]], "min_connectivity": 4, "family": "mc_pysms_min_connectivity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-connectivity-l5-s0/tests/run.py b/tasks/construct-mc-pysms-min-connectivity-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-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-pysms-min-connectivity-l5-s0/tests/test.sh b/tasks/construct-mc-pysms-min-connectivity-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-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-pysms-min-degree-l1-s1/environment/Dockerfile b/tasks/construct-mc-pysms-min-degree-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-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-pysms-min-degree-l1-s1/environment/instance.json b/tasks/construct-mc-pysms-min-degree-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6b3bbe56276d19ef8bcd646e22b50a3878c0d9ad --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 8, "required_edges": [[2, 6], [0, 6], [4, 7], [6, 7], [3, 7]], "min_degree": 3, "family": "mc_pysms_min_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-degree-l1-s1/solution/solve.sh b/tasks/construct-mc-pysms-min-degree-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a411bb51ad0fd830529a244c60057cdaa691261e --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-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' +{"edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-min-degree-l1-s1/tests/check.py b/tasks/construct-mc-pysms-min-degree-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l1-s1/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-min-degree-l1-s1/tests/instance.json b/tasks/construct-mc-pysms-min-degree-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6b3bbe56276d19ef8bcd646e22b50a3878c0d9ad --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 8, "required_edges": [[2, 6], [0, 6], [4, 7], [6, 7], [3, 7]], "min_degree": 3, "family": "mc_pysms_min_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-degree-l1-s1/tests/run.py b/tasks/construct-mc-pysms-min-degree-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-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-pysms-min-degree-l1-s1/tests/test.sh b/tasks/construct-mc-pysms-min-degree-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-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-pysms-min-girth-l3-s1/environment/Dockerfile b/tasks/construct-mc-pysms-min-girth-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l3-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-min-girth-l3-s1/environment/instance.json b/tasks/construct-mc-pysms-min-girth-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..16b3af49a0516685aad64dc9ae2a9bd2fda28f71 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 12, "required_edges": [], "min_girth": 3, "family": "mc_pysms_min_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-girth-l3-s1/solution/solve.sh b/tasks/construct-mc-pysms-min-girth-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9099c841c9e48c114f5c02b50d3a66619d4ef75d --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l3-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [7, 8], [7, 9], [7, 10], [7, 11], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-min-girth-l3-s1/tests/check.py b/tasks/construct-mc-pysms-min-girth-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l3-s1/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-min-girth-l3-s1/tests/instance.json b/tasks/construct-mc-pysms-min-girth-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..16b3af49a0516685aad64dc9ae2a9bd2fda28f71 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 12, "required_edges": [], "min_girth": 3, "family": "mc_pysms_min_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-girth-l3-s1/tests/run.py b/tasks/construct-mc-pysms-min-girth-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l3-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-min-girth-l3-s1/tests/test.sh b/tasks/construct-mc-pysms-min-girth-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l3-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-mtf-l2-s1/environment/Dockerfile b/tasks/construct-mc-pysms-mtf-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-l2-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-mtf-l2-s1/environment/instance.json b/tasks/construct-mc-pysms-mtf-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7311d6867272da95a692dfda565165d8edbcffba --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 9, "required_edges": [[4, 7], [0, 7]], "mtf": true, "family": "mc_pysms_mtf", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-mtf-l2-s1/solution/solve.sh b/tasks/construct-mc-pysms-mtf-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bf8a3fe812920234ed26dbce541041d8754d1b2e --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-l2-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 7], [0, 8], [1, 7], [1, 8], [2, 7], [2, 8], [3, 7], [3, 8], [4, 7], [4, 8], [5, 7], [5, 8], [6, 7], [6, 8]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-mtf-l2-s1/tests/check.py b/tasks/construct-mc-pysms-mtf-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-l2-s1/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-mtf-l2-s1/tests/instance.json b/tasks/construct-mc-pysms-mtf-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7311d6867272da95a692dfda565165d8edbcffba --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 9, "required_edges": [[4, 7], [0, 7]], "mtf": true, "family": "mc_pysms_mtf", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-mtf-l2-s1/tests/run.py b/tasks/construct-mc-pysms-mtf-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-l2-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-mtf-l2-s1/tests/test.sh b/tasks/construct-mc-pysms-mtf-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-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-pysms-mtf-l5-s2/environment/Dockerfile b/tasks/construct-mc-pysms-mtf-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-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-pysms-mtf-l5-s2/environment/instance.json b/tasks/construct-mc-pysms-mtf-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e108ae984678a107b51e77ab82c7e61bacf79c3b --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 16, "required_edges": [], "mtf": true, "family": "mc_pysms_mtf", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-mtf-l5-s2/solution/solve.sh b/tasks/construct-mc-pysms-mtf-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a1e997c9f1f3e4678ffec043deb81955d7939121 --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-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' +{"edges": [[0, 14], [0, 15], [1, 14], [1, 15], [2, 14], [2, 15], [3, 14], [3, 15], [4, 14], [4, 15], [5, 14], [5, 15], [6, 14], [6, 15], [7, 14], [7, 15], [8, 14], [8, 15], [9, 14], [9, 15], [10, 14], [10, 15], [11, 14], [11, 15], [12, 14], [12, 15], [13, 14], [13, 15]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-mtf-l5-s2/tests/check.py b/tasks/construct-mc-pysms-mtf-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-l5-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-mtf-l5-s2/tests/instance.json b/tasks/construct-mc-pysms-mtf-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e108ae984678a107b51e77ab82c7e61bacf79c3b --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 16, "required_edges": [], "mtf": true, "family": "mc_pysms_mtf", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-mtf-l5-s2/tests/run.py b/tasks/construct-mc-pysms-mtf-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-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-pysms-mtf-l5-s2/tests/test.sh b/tasks/construct-mc-pysms-mtf-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-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-pysms-num-edges-bounds-l1-s0/environment/Dockerfile b/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/environment/instance.json b/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..808f11ad80e7c847b9af7a8c69c9fedee3af014e --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 10, "required_edges": [], "max_edges": 30, "min_edges": 21, "family": "mc_pysms_num_edges_bounds", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/solution/solve.sh b/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e6d84b815d528be8939d48ce0ca9f000dd605aec --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 2], [1, 3], [1, 4], [1, 8], [1, 9], [2, 3], [2, 4], [2, 7], [2, 8], [2, 9], [3, 4], [3, 7], [3, 8], [3, 9], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/tests/check.py b/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/tests/instance.json b/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..808f11ad80e7c847b9af7a8c69c9fedee3af014e --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 10, "required_edges": [], "max_edges": 30, "min_edges": 21, "family": "mc_pysms_num_edges_bounds", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/tests/run.py b/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/tests/test.sh b/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l1-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/environment/Dockerfile b/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/environment/instance.json b/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..12830ddcc776163d8e5c74229e88ee863fddb1d4 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 14, "required_edges": [], "max_edges": 40, "min_edges": 14, "family": "mc_pysms_num_edges_bounds", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/solution/solve.sh b/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b8158e7c99687487b381e27c94892cea58e94d58 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/tests/check.py b/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/tests/instance.json b/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..12830ddcc776163d8e5c74229e88ee863fddb1d4 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 14, "required_edges": [], "max_edges": 40, "min_edges": 14, "family": "mc_pysms_num_edges_bounds", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/tests/run.py b/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/tests/test.sh b/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l5-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-quasigroup-idempotent-l5-s1/environment/Dockerfile b/tasks/construct-mc-quasigroup-idempotent-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l5-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-quasigroup-idempotent-l5-s1/environment/instance.json b/tasks/construct-mc-quasigroup-idempotent-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5726ced505c38a6b2fdd8ad4bbabffe3a92c2442 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 37, "family": "mc_quasigroup_idempotent", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-quasigroup-idempotent-l5-s1/solution/solve.sh b/tasks/construct-mc-quasigroup-idempotent-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..04187334393a977292ac25607ea71b09c1842c89 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-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' +{"table": [[0, 2, 22, 11, 27, 33, 10, 14, 1, 18, 20, 28, 24, 34, 6, 17, 32, 16, 13, 7, 35, 3, 12, 26, 5, 30, 15, 25, 4, 23, 36, 8, 19, 29, 31, 9, 21], [22, 1, 3, 23, 12, 28, 34, 11, 15, 2, 19, 21, 29, 25, 35, 7, 18, 33, 17, 14, 8, 36, 4, 13, 27, 6, 31, 16, 26, 5, 24, 0, 9, 20, 30, 32, 10], [11, 23, 2, 4, 24, 13, 29, 35, 12, 16, 3, 20, 22, 30, 26, 36, 8, 19, 34, 18, 15, 9, 0, 5, 14, 28, 7, 32, 17, 27, 6, 25, 1, 10, 21, 31, 33], [34, 12, 24, 3, 5, 25, 14, 30, 36, 13, 17, 4, 21, 23, 31, 27, 0, 9, 20, 35, 19, 16, 10, 1, 6, 15, 29, 8, 33, 18, 28, 7, 26, 2, 11, 22, 32], [33, 35, 13, 25, 4, 6, 26, 15, 31, 0, 14, 18, 5, 22, 24, 32, 28, 1, 10, 21, 36, 20, 17, 11, 2, 7, 16, 30, 9, 34, 19, 29, 8, 27, 3, 12, 23], [24, 34, 36, 14, 26, 5, 7, 27, 16, 32, 1, 15, 19, 6, 23, 25, 33, 29, 2, 11, 22, 0, 21, 18, 12, 3, 8, 17, 31, 10, 35, 20, 30, 9, 28, 4, 13], [14, 25, 35, 0, 15, 27, 6, 8, 28, 17, 33, 2, 16, 20, 7, 24, 26, 34, 30, 3, 12, 23, 1, 22, 19, 13, 4, 9, 18, 32, 11, 36, 21, 31, 10, 29, 5], [6, 15, 26, 36, 1, 16, 28, 7, 9, 29, 18, 34, 3, 17, 21, 8, 25, 27, 35, 31, 4, 13, 24, 2, 23, 20, 14, 5, 10, 19, 33, 12, 0, 22, 32, 11, 30], [31, 7, 16, 27, 0, 2, 17, 29, 8, 10, 30, 19, 35, 4, 18, 22, 9, 26, 28, 36, 32, 5, 14, 25, 3, 24, 21, 15, 6, 11, 20, 34, 13, 1, 23, 33, 12], [13, 32, 8, 17, 28, 1, 3, 18, 30, 9, 11, 31, 20, 36, 5, 19, 23, 10, 27, 29, 0, 33, 6, 15, 26, 4, 25, 22, 16, 7, 12, 21, 35, 14, 2, 24, 34], [35, 14, 33, 9, 18, 29, 2, 4, 19, 31, 10, 12, 32, 21, 0, 6, 20, 24, 11, 28, 30, 1, 34, 7, 16, 27, 5, 26, 23, 17, 8, 13, 22, 36, 15, 3, 25], [26, 36, 15, 34, 10, 19, 30, 3, 5, 20, 32, 11, 13, 33, 22, 1, 7, 21, 25, 12, 29, 31, 2, 35, 8, 17, 28, 6, 27, 24, 18, 9, 14, 23, 0, 16, 4], [5, 27, 0, 16, 35, 11, 20, 31, 4, 6, 21, 33, 12, 14, 34, 23, 2, 8, 22, 26, 13, 30, 32, 3, 36, 9, 18, 29, 7, 28, 25, 19, 10, 15, 24, 1, 17], [18, 6, 28, 1, 17, 36, 12, 21, 32, 5, 7, 22, 34, 13, 15, 35, 24, 3, 9, 23, 27, 14, 31, 33, 4, 0, 10, 19, 30, 8, 29, 26, 20, 11, 16, 25, 2], [3, 19, 7, 29, 2, 18, 0, 13, 22, 33, 6, 8, 23, 35, 14, 16, 36, 25, 4, 10, 24, 28, 15, 32, 34, 5, 1, 11, 20, 31, 9, 30, 27, 21, 12, 17, 26], [27, 4, 20, 8, 30, 3, 19, 1, 14, 23, 34, 7, 9, 24, 36, 15, 17, 0, 26, 5, 11, 25, 29, 16, 33, 35, 6, 2, 12, 21, 32, 10, 31, 28, 22, 13, 18], [19, 28, 5, 21, 9, 31, 4, 20, 2, 15, 24, 35, 8, 10, 25, 0, 16, 18, 1, 27, 6, 12, 26, 30, 17, 34, 36, 7, 3, 13, 22, 33, 11, 32, 29, 23, 14], [15, 20, 29, 6, 22, 10, 32, 5, 21, 3, 16, 25, 36, 9, 11, 26, 1, 17, 19, 2, 28, 7, 13, 27, 31, 18, 35, 0, 8, 4, 14, 23, 34, 12, 33, 30, 24], [25, 16, 21, 30, 7, 23, 11, 33, 6, 22, 4, 17, 26, 0, 10, 12, 27, 2, 18, 20, 3, 29, 8, 14, 28, 32, 19, 36, 1, 9, 5, 15, 24, 35, 13, 34, 31], [32, 26, 17, 22, 31, 8, 24, 12, 34, 7, 23, 5, 18, 27, 1, 11, 13, 28, 3, 19, 21, 4, 30, 9, 15, 29, 33, 20, 0, 2, 10, 6, 16, 25, 36, 14, 35], [36, 33, 27, 18, 23, 32, 9, 25, 13, 35, 8, 24, 6, 19, 28, 2, 12, 14, 29, 4, 20, 22, 5, 31, 10, 16, 30, 34, 21, 1, 3, 11, 7, 17, 26, 0, 15], [16, 0, 34, 28, 19, 24, 33, 10, 26, 14, 36, 9, 25, 7, 20, 29, 3, 13, 15, 30, 5, 21, 23, 6, 32, 11, 17, 31, 35, 22, 2, 4, 12, 8, 18, 27, 1], [2, 17, 1, 35, 29, 20, 25, 34, 11, 27, 15, 0, 10, 26, 8, 21, 30, 4, 14, 16, 31, 6, 22, 24, 7, 33, 12, 18, 32, 36, 23, 3, 5, 13, 9, 19, 28], [29, 3, 18, 2, 36, 30, 21, 26, 35, 12, 28, 16, 1, 11, 27, 9, 22, 31, 5, 15, 17, 32, 7, 23, 25, 8, 34, 13, 19, 33, 0, 24, 4, 6, 14, 10, 20], [21, 30, 4, 19, 3, 0, 31, 22, 27, 36, 13, 29, 17, 2, 12, 28, 10, 23, 32, 6, 16, 18, 33, 8, 24, 26, 9, 35, 14, 20, 34, 1, 25, 5, 7, 15, 11], [12, 22, 31, 5, 20, 4, 1, 32, 23, 28, 0, 14, 30, 18, 3, 13, 29, 11, 24, 33, 7, 17, 19, 34, 9, 25, 27, 10, 36, 15, 21, 35, 2, 26, 6, 8, 16], [17, 13, 23, 32, 6, 21, 5, 2, 33, 24, 29, 1, 15, 31, 19, 4, 14, 30, 12, 25, 34, 8, 18, 20, 35, 10, 26, 28, 11, 0, 16, 22, 36, 3, 27, 7, 9], [10, 18, 14, 24, 33, 7, 22, 6, 3, 34, 25, 30, 2, 16, 32, 20, 5, 15, 31, 13, 26, 35, 9, 19, 21, 36, 11, 27, 29, 12, 1, 17, 23, 0, 4, 28, 8], [9, 11, 19, 15, 25, 34, 8, 23, 7, 4, 35, 26, 31, 3, 17, 33, 21, 6, 16, 32, 14, 27, 36, 10, 20, 22, 0, 12, 28, 30, 13, 2, 18, 24, 1, 5, 29], [30, 10, 12, 20, 16, 26, 35, 9, 24, 8, 5, 36, 27, 32, 4, 18, 34, 22, 7, 17, 33, 15, 28, 0, 11, 21, 23, 1, 13, 29, 31, 14, 3, 19, 25, 2, 6], [7, 31, 11, 13, 21, 17, 27, 36, 10, 25, 9, 6, 0, 28, 33, 5, 19, 35, 23, 8, 18, 34, 16, 29, 1, 12, 22, 24, 2, 14, 30, 32, 15, 4, 20, 26, 3], [4, 8, 32, 12, 14, 22, 18, 28, 0, 11, 26, 10, 7, 1, 29, 34, 6, 20, 36, 24, 9, 19, 35, 17, 30, 2, 13, 23, 25, 3, 15, 31, 33, 16, 5, 21, 27], [28, 5, 9, 33, 13, 15, 23, 19, 29, 1, 12, 27, 11, 8, 2, 30, 35, 7, 21, 0, 25, 10, 20, 36, 18, 31, 3, 14, 24, 26, 4, 16, 32, 34, 17, 6, 22], [23, 29, 6, 10, 34, 14, 16, 24, 20, 30, 2, 13, 28, 12, 9, 3, 31, 36, 8, 22, 1, 26, 11, 21, 0, 19, 32, 4, 15, 25, 27, 5, 17, 33, 35, 18, 7], [8, 24, 30, 7, 11, 35, 15, 17, 25, 21, 31, 3, 14, 29, 13, 10, 4, 32, 0, 9, 23, 2, 27, 12, 22, 1, 20, 33, 5, 16, 26, 28, 6, 18, 34, 36, 19], [20, 9, 25, 31, 8, 12, 36, 16, 18, 26, 22, 32, 4, 15, 30, 14, 11, 5, 33, 1, 10, 24, 3, 28, 13, 23, 2, 21, 34, 6, 17, 27, 29, 7, 19, 35, 0], [1, 21, 10, 26, 32, 9, 13, 0, 17, 19, 27, 23, 33, 5, 16, 31, 15, 12, 6, 34, 2, 11, 25, 4, 29, 14, 24, 3, 22, 35, 7, 18, 28, 30, 8, 20, 36]]} +RLMATH_EOF diff --git a/tasks/construct-mc-quasigroup-idempotent-l5-s1/tests/check.py b/tasks/construct-mc-quasigroup-idempotent-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4563f2e9a90050cdd7c56dfc33831acde74c9ef2 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l5-s1/tests/check.py @@ -0,0 +1,21 @@ +"""Idempotent quasigroup satisfying QG3, (x*y)*(y*x) = x (MathConstraint quasigroup_idempotent, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + T = ans.get("table") + if not isinstance(T, list) or len(T) != n: + raise Invalid(f"table must be a list of {n} rows") + T = [int_list(r, n, 0, n - 1, "table row") for r in T] + full = list(range(n)) + for i in range(n): + if sorted(T[i]) != full or sorted(T[r][i] for r in range(n)) != full: + raise Invalid(f"row/column {i} is not a permutation (not a Latin square)") + if T[i][i] != i: + raise Invalid(f"not idempotent: {i}*{i} = {T[i][i]}") + for i in range(n): + for j in range(n): + if T[T[i][j]][T[j][i]] != i: + raise Invalid(f"QG3 fails for (x, y) = ({i}, {j})") + return None, {} diff --git a/tasks/construct-mc-quasigroup-idempotent-l5-s1/tests/instance.json b/tasks/construct-mc-quasigroup-idempotent-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5726ced505c38a6b2fdd8ad4bbabffe3a92c2442 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 37, "family": "mc_quasigroup_idempotent", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-quasigroup-idempotent-l5-s1/tests/run.py b/tasks/construct-mc-quasigroup-idempotent-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l5-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-quasigroup-idempotent-l5-s1/tests/test.sh b/tasks/construct-mc-quasigroup-idempotent-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l5-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-quasigroup-idempotent-l6-s3/environment/Dockerfile b/tasks/construct-mc-quasigroup-idempotent-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-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-quasigroup-idempotent-l6-s3/environment/instance.json b/tasks/construct-mc-quasigroup-idempotent-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f939df9de97c2ee971be1ec4a34d241b58bfe9c1 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 64, "family": "mc_quasigroup_idempotent", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-quasigroup-idempotent-l6-s3/solution/solve.sh b/tasks/construct-mc-quasigroup-idempotent-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4b8c7801b5354c46f7d6029829f9c3a182b7bb9d --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-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' +{"table": [[0, 3, 6, 5, 12, 15, 10, 9, 24, 27, 30, 29, 20, 23, 18, 17, 48, 51, 54, 53, 60, 63, 58, 57, 40, 43, 46, 45, 36, 39, 34, 33, 35, 32, 37, 38, 47, 44, 41, 42, 59, 56, 61, 62, 55, 52, 49, 50, 19, 16, 21, 22, 31, 28, 25, 26, 11, 8, 13, 14, 7, 4, 1, 2], [2, 1, 4, 7, 14, 13, 8, 11, 26, 25, 28, 31, 22, 21, 16, 19, 50, 49, 52, 55, 62, 61, 56, 59, 42, 41, 44, 47, 38, 37, 32, 35, 33, 34, 39, 36, 45, 46, 43, 40, 57, 58, 63, 60, 53, 54, 51, 48, 17, 18, 23, 20, 29, 30, 27, 24, 9, 10, 15, 12, 5, 6, 3, 0], [4, 7, 2, 1, 8, 11, 14, 13, 28, 31, 26, 25, 16, 19, 22, 21, 52, 55, 50, 49, 56, 59, 62, 61, 44, 47, 42, 41, 32, 35, 38, 37, 39, 36, 33, 34, 43, 40, 45, 46, 63, 60, 57, 58, 51, 48, 53, 54, 23, 20, 17, 18, 27, 24, 29, 30, 15, 12, 9, 10, 3, 0, 5, 6], [6, 5, 0, 3, 10, 9, 12, 15, 30, 29, 24, 27, 18, 17, 20, 23, 54, 53, 48, 51, 58, 57, 60, 63, 46, 45, 40, 43, 34, 33, 36, 39, 37, 38, 35, 32, 41, 42, 47, 44, 61, 62, 59, 56, 49, 50, 55, 52, 21, 22, 19, 16, 25, 26, 31, 28, 13, 14, 11, 8, 1, 2, 7, 4], [8, 11, 14, 13, 4, 7, 2, 1, 16, 19, 22, 21, 28, 31, 26, 25, 56, 59, 62, 61, 52, 55, 50, 49, 32, 35, 38, 37, 44, 47, 42, 41, 43, 40, 45, 46, 39, 36, 33, 34, 51, 48, 53, 54, 63, 60, 57, 58, 27, 24, 29, 30, 23, 20, 17, 18, 3, 0, 5, 6, 15, 12, 9, 10], [10, 9, 12, 15, 6, 5, 0, 3, 18, 17, 20, 23, 30, 29, 24, 27, 58, 57, 60, 63, 54, 53, 48, 51, 34, 33, 36, 39, 46, 45, 40, 43, 41, 42, 47, 44, 37, 38, 35, 32, 49, 50, 55, 52, 61, 62, 59, 56, 25, 26, 31, 28, 21, 22, 19, 16, 1, 2, 7, 4, 13, 14, 11, 8], [12, 15, 10, 9, 0, 3, 6, 5, 20, 23, 18, 17, 24, 27, 30, 29, 60, 63, 58, 57, 48, 51, 54, 53, 36, 39, 34, 33, 40, 43, 46, 45, 47, 44, 41, 42, 35, 32, 37, 38, 55, 52, 49, 50, 59, 56, 61, 62, 31, 28, 25, 26, 19, 16, 21, 22, 7, 4, 1, 2, 11, 8, 13, 14], [14, 13, 8, 11, 2, 1, 4, 7, 22, 21, 16, 19, 26, 25, 28, 31, 62, 61, 56, 59, 50, 49, 52, 55, 38, 37, 32, 35, 42, 41, 44, 47, 45, 46, 43, 40, 33, 34, 39, 36, 53, 54, 51, 48, 57, 58, 63, 60, 29, 30, 27, 24, 17, 18, 23, 20, 5, 6, 3, 0, 9, 10, 15, 12], [16, 19, 22, 21, 28, 31, 26, 25, 8, 11, 14, 13, 4, 7, 2, 1, 32, 35, 38, 37, 44, 47, 42, 41, 56, 59, 62, 61, 52, 55, 50, 49, 51, 48, 53, 54, 63, 60, 57, 58, 43, 40, 45, 46, 39, 36, 33, 34, 3, 0, 5, 6, 15, 12, 9, 10, 27, 24, 29, 30, 23, 20, 17, 18], [18, 17, 20, 23, 30, 29, 24, 27, 10, 9, 12, 15, 6, 5, 0, 3, 34, 33, 36, 39, 46, 45, 40, 43, 58, 57, 60, 63, 54, 53, 48, 51, 49, 50, 55, 52, 61, 62, 59, 56, 41, 42, 47, 44, 37, 38, 35, 32, 1, 2, 7, 4, 13, 14, 11, 8, 25, 26, 31, 28, 21, 22, 19, 16], [20, 23, 18, 17, 24, 27, 30, 29, 12, 15, 10, 9, 0, 3, 6, 5, 36, 39, 34, 33, 40, 43, 46, 45, 60, 63, 58, 57, 48, 51, 54, 53, 55, 52, 49, 50, 59, 56, 61, 62, 47, 44, 41, 42, 35, 32, 37, 38, 7, 4, 1, 2, 11, 8, 13, 14, 31, 28, 25, 26, 19, 16, 21, 22], [22, 21, 16, 19, 26, 25, 28, 31, 14, 13, 8, 11, 2, 1, 4, 7, 38, 37, 32, 35, 42, 41, 44, 47, 62, 61, 56, 59, 50, 49, 52, 55, 53, 54, 51, 48, 57, 58, 63, 60, 45, 46, 43, 40, 33, 34, 39, 36, 5, 6, 3, 0, 9, 10, 15, 12, 29, 30, 27, 24, 17, 18, 23, 20], [24, 27, 30, 29, 20, 23, 18, 17, 0, 3, 6, 5, 12, 15, 10, 9, 40, 43, 46, 45, 36, 39, 34, 33, 48, 51, 54, 53, 60, 63, 58, 57, 59, 56, 61, 62, 55, 52, 49, 50, 35, 32, 37, 38, 47, 44, 41, 42, 11, 8, 13, 14, 7, 4, 1, 2, 19, 16, 21, 22, 31, 28, 25, 26], [26, 25, 28, 31, 22, 21, 16, 19, 2, 1, 4, 7, 14, 13, 8, 11, 42, 41, 44, 47, 38, 37, 32, 35, 50, 49, 52, 55, 62, 61, 56, 59, 57, 58, 63, 60, 53, 54, 51, 48, 33, 34, 39, 36, 45, 46, 43, 40, 9, 10, 15, 12, 5, 6, 3, 0, 17, 18, 23, 20, 29, 30, 27, 24], [28, 31, 26, 25, 16, 19, 22, 21, 4, 7, 2, 1, 8, 11, 14, 13, 44, 47, 42, 41, 32, 35, 38, 37, 52, 55, 50, 49, 56, 59, 62, 61, 63, 60, 57, 58, 51, 48, 53, 54, 39, 36, 33, 34, 43, 40, 45, 46, 15, 12, 9, 10, 3, 0, 5, 6, 23, 20, 17, 18, 27, 24, 29, 30], [30, 29, 24, 27, 18, 17, 20, 23, 6, 5, 0, 3, 10, 9, 12, 15, 46, 45, 40, 43, 34, 33, 36, 39, 54, 53, 48, 51, 58, 57, 60, 63, 61, 62, 59, 56, 49, 50, 55, 52, 37, 38, 35, 32, 41, 42, 47, 44, 13, 14, 11, 8, 1, 2, 7, 4, 21, 22, 19, 16, 25, 26, 31, 28], [32, 35, 38, 37, 44, 47, 42, 41, 56, 59, 62, 61, 52, 55, 50, 49, 16, 19, 22, 21, 28, 31, 26, 25, 8, 11, 14, 13, 4, 7, 2, 1, 3, 0, 5, 6, 15, 12, 9, 10, 27, 24, 29, 30, 23, 20, 17, 18, 51, 48, 53, 54, 63, 60, 57, 58, 43, 40, 45, 46, 39, 36, 33, 34], [34, 33, 36, 39, 46, 45, 40, 43, 58, 57, 60, 63, 54, 53, 48, 51, 18, 17, 20, 23, 30, 29, 24, 27, 10, 9, 12, 15, 6, 5, 0, 3, 1, 2, 7, 4, 13, 14, 11, 8, 25, 26, 31, 28, 21, 22, 19, 16, 49, 50, 55, 52, 61, 62, 59, 56, 41, 42, 47, 44, 37, 38, 35, 32], [36, 39, 34, 33, 40, 43, 46, 45, 60, 63, 58, 57, 48, 51, 54, 53, 20, 23, 18, 17, 24, 27, 30, 29, 12, 15, 10, 9, 0, 3, 6, 5, 7, 4, 1, 2, 11, 8, 13, 14, 31, 28, 25, 26, 19, 16, 21, 22, 55, 52, 49, 50, 59, 56, 61, 62, 47, 44, 41, 42, 35, 32, 37, 38], [38, 37, 32, 35, 42, 41, 44, 47, 62, 61, 56, 59, 50, 49, 52, 55, 22, 21, 16, 19, 26, 25, 28, 31, 14, 13, 8, 11, 2, 1, 4, 7, 5, 6, 3, 0, 9, 10, 15, 12, 29, 30, 27, 24, 17, 18, 23, 20, 53, 54, 51, 48, 57, 58, 63, 60, 45, 46, 43, 40, 33, 34, 39, 36], [40, 43, 46, 45, 36, 39, 34, 33, 48, 51, 54, 53, 60, 63, 58, 57, 24, 27, 30, 29, 20, 23, 18, 17, 0, 3, 6, 5, 12, 15, 10, 9, 11, 8, 13, 14, 7, 4, 1, 2, 19, 16, 21, 22, 31, 28, 25, 26, 59, 56, 61, 62, 55, 52, 49, 50, 35, 32, 37, 38, 47, 44, 41, 42], [42, 41, 44, 47, 38, 37, 32, 35, 50, 49, 52, 55, 62, 61, 56, 59, 26, 25, 28, 31, 22, 21, 16, 19, 2, 1, 4, 7, 14, 13, 8, 11, 9, 10, 15, 12, 5, 6, 3, 0, 17, 18, 23, 20, 29, 30, 27, 24, 57, 58, 63, 60, 53, 54, 51, 48, 33, 34, 39, 36, 45, 46, 43, 40], [44, 47, 42, 41, 32, 35, 38, 37, 52, 55, 50, 49, 56, 59, 62, 61, 28, 31, 26, 25, 16, 19, 22, 21, 4, 7, 2, 1, 8, 11, 14, 13, 15, 12, 9, 10, 3, 0, 5, 6, 23, 20, 17, 18, 27, 24, 29, 30, 63, 60, 57, 58, 51, 48, 53, 54, 39, 36, 33, 34, 43, 40, 45, 46], [46, 45, 40, 43, 34, 33, 36, 39, 54, 53, 48, 51, 58, 57, 60, 63, 30, 29, 24, 27, 18, 17, 20, 23, 6, 5, 0, 3, 10, 9, 12, 15, 13, 14, 11, 8, 1, 2, 7, 4, 21, 22, 19, 16, 25, 26, 31, 28, 61, 62, 59, 56, 49, 50, 55, 52, 37, 38, 35, 32, 41, 42, 47, 44], [48, 51, 54, 53, 60, 63, 58, 57, 40, 43, 46, 45, 36, 39, 34, 33, 0, 3, 6, 5, 12, 15, 10, 9, 24, 27, 30, 29, 20, 23, 18, 17, 19, 16, 21, 22, 31, 28, 25, 26, 11, 8, 13, 14, 7, 4, 1, 2, 35, 32, 37, 38, 47, 44, 41, 42, 59, 56, 61, 62, 55, 52, 49, 50], [50, 49, 52, 55, 62, 61, 56, 59, 42, 41, 44, 47, 38, 37, 32, 35, 2, 1, 4, 7, 14, 13, 8, 11, 26, 25, 28, 31, 22, 21, 16, 19, 17, 18, 23, 20, 29, 30, 27, 24, 9, 10, 15, 12, 5, 6, 3, 0, 33, 34, 39, 36, 45, 46, 43, 40, 57, 58, 63, 60, 53, 54, 51, 48], [52, 55, 50, 49, 56, 59, 62, 61, 44, 47, 42, 41, 32, 35, 38, 37, 4, 7, 2, 1, 8, 11, 14, 13, 28, 31, 26, 25, 16, 19, 22, 21, 23, 20, 17, 18, 27, 24, 29, 30, 15, 12, 9, 10, 3, 0, 5, 6, 39, 36, 33, 34, 43, 40, 45, 46, 63, 60, 57, 58, 51, 48, 53, 54], [54, 53, 48, 51, 58, 57, 60, 63, 46, 45, 40, 43, 34, 33, 36, 39, 6, 5, 0, 3, 10, 9, 12, 15, 30, 29, 24, 27, 18, 17, 20, 23, 21, 22, 19, 16, 25, 26, 31, 28, 13, 14, 11, 8, 1, 2, 7, 4, 37, 38, 35, 32, 41, 42, 47, 44, 61, 62, 59, 56, 49, 50, 55, 52], [56, 59, 62, 61, 52, 55, 50, 49, 32, 35, 38, 37, 44, 47, 42, 41, 8, 11, 14, 13, 4, 7, 2, 1, 16, 19, 22, 21, 28, 31, 26, 25, 27, 24, 29, 30, 23, 20, 17, 18, 3, 0, 5, 6, 15, 12, 9, 10, 43, 40, 45, 46, 39, 36, 33, 34, 51, 48, 53, 54, 63, 60, 57, 58], [58, 57, 60, 63, 54, 53, 48, 51, 34, 33, 36, 39, 46, 45, 40, 43, 10, 9, 12, 15, 6, 5, 0, 3, 18, 17, 20, 23, 30, 29, 24, 27, 25, 26, 31, 28, 21, 22, 19, 16, 1, 2, 7, 4, 13, 14, 11, 8, 41, 42, 47, 44, 37, 38, 35, 32, 49, 50, 55, 52, 61, 62, 59, 56], [60, 63, 58, 57, 48, 51, 54, 53, 36, 39, 34, 33, 40, 43, 46, 45, 12, 15, 10, 9, 0, 3, 6, 5, 20, 23, 18, 17, 24, 27, 30, 29, 31, 28, 25, 26, 19, 16, 21, 22, 7, 4, 1, 2, 11, 8, 13, 14, 47, 44, 41, 42, 35, 32, 37, 38, 55, 52, 49, 50, 59, 56, 61, 62], [62, 61, 56, 59, 50, 49, 52, 55, 38, 37, 32, 35, 42, 41, 44, 47, 14, 13, 8, 11, 2, 1, 4, 7, 22, 21, 16, 19, 26, 25, 28, 31, 29, 30, 27, 24, 17, 18, 23, 20, 5, 6, 3, 0, 9, 10, 15, 12, 45, 46, 43, 40, 33, 34, 39, 36, 53, 54, 51, 48, 57, 58, 63, 60], [3, 0, 5, 6, 15, 12, 9, 10, 27, 24, 29, 30, 23, 20, 17, 18, 51, 48, 53, 54, 63, 60, 57, 58, 43, 40, 45, 46, 39, 36, 33, 34, 32, 35, 38, 37, 44, 47, 42, 41, 56, 59, 62, 61, 52, 55, 50, 49, 16, 19, 22, 21, 28, 31, 26, 25, 8, 11, 14, 13, 4, 7, 2, 1], [1, 2, 7, 4, 13, 14, 11, 8, 25, 26, 31, 28, 21, 22, 19, 16, 49, 50, 55, 52, 61, 62, 59, 56, 41, 42, 47, 44, 37, 38, 35, 32, 34, 33, 36, 39, 46, 45, 40, 43, 58, 57, 60, 63, 54, 53, 48, 51, 18, 17, 20, 23, 30, 29, 24, 27, 10, 9, 12, 15, 6, 5, 0, 3], [7, 4, 1, 2, 11, 8, 13, 14, 31, 28, 25, 26, 19, 16, 21, 22, 55, 52, 49, 50, 59, 56, 61, 62, 47, 44, 41, 42, 35, 32, 37, 38, 36, 39, 34, 33, 40, 43, 46, 45, 60, 63, 58, 57, 48, 51, 54, 53, 20, 23, 18, 17, 24, 27, 30, 29, 12, 15, 10, 9, 0, 3, 6, 5], [5, 6, 3, 0, 9, 10, 15, 12, 29, 30, 27, 24, 17, 18, 23, 20, 53, 54, 51, 48, 57, 58, 63, 60, 45, 46, 43, 40, 33, 34, 39, 36, 38, 37, 32, 35, 42, 41, 44, 47, 62, 61, 56, 59, 50, 49, 52, 55, 22, 21, 16, 19, 26, 25, 28, 31, 14, 13, 8, 11, 2, 1, 4, 7], [11, 8, 13, 14, 7, 4, 1, 2, 19, 16, 21, 22, 31, 28, 25, 26, 59, 56, 61, 62, 55, 52, 49, 50, 35, 32, 37, 38, 47, 44, 41, 42, 40, 43, 46, 45, 36, 39, 34, 33, 48, 51, 54, 53, 60, 63, 58, 57, 24, 27, 30, 29, 20, 23, 18, 17, 0, 3, 6, 5, 12, 15, 10, 9], [9, 10, 15, 12, 5, 6, 3, 0, 17, 18, 23, 20, 29, 30, 27, 24, 57, 58, 63, 60, 53, 54, 51, 48, 33, 34, 39, 36, 45, 46, 43, 40, 42, 41, 44, 47, 38, 37, 32, 35, 50, 49, 52, 55, 62, 61, 56, 59, 26, 25, 28, 31, 22, 21, 16, 19, 2, 1, 4, 7, 14, 13, 8, 11], [15, 12, 9, 10, 3, 0, 5, 6, 23, 20, 17, 18, 27, 24, 29, 30, 63, 60, 57, 58, 51, 48, 53, 54, 39, 36, 33, 34, 43, 40, 45, 46, 44, 47, 42, 41, 32, 35, 38, 37, 52, 55, 50, 49, 56, 59, 62, 61, 28, 31, 26, 25, 16, 19, 22, 21, 4, 7, 2, 1, 8, 11, 14, 13], [13, 14, 11, 8, 1, 2, 7, 4, 21, 22, 19, 16, 25, 26, 31, 28, 61, 62, 59, 56, 49, 50, 55, 52, 37, 38, 35, 32, 41, 42, 47, 44, 46, 45, 40, 43, 34, 33, 36, 39, 54, 53, 48, 51, 58, 57, 60, 63, 30, 29, 24, 27, 18, 17, 20, 23, 6, 5, 0, 3, 10, 9, 12, 15], [19, 16, 21, 22, 31, 28, 25, 26, 11, 8, 13, 14, 7, 4, 1, 2, 35, 32, 37, 38, 47, 44, 41, 42, 59, 56, 61, 62, 55, 52, 49, 50, 48, 51, 54, 53, 60, 63, 58, 57, 40, 43, 46, 45, 36, 39, 34, 33, 0, 3, 6, 5, 12, 15, 10, 9, 24, 27, 30, 29, 20, 23, 18, 17], [17, 18, 23, 20, 29, 30, 27, 24, 9, 10, 15, 12, 5, 6, 3, 0, 33, 34, 39, 36, 45, 46, 43, 40, 57, 58, 63, 60, 53, 54, 51, 48, 50, 49, 52, 55, 62, 61, 56, 59, 42, 41, 44, 47, 38, 37, 32, 35, 2, 1, 4, 7, 14, 13, 8, 11, 26, 25, 28, 31, 22, 21, 16, 19], [23, 20, 17, 18, 27, 24, 29, 30, 15, 12, 9, 10, 3, 0, 5, 6, 39, 36, 33, 34, 43, 40, 45, 46, 63, 60, 57, 58, 51, 48, 53, 54, 52, 55, 50, 49, 56, 59, 62, 61, 44, 47, 42, 41, 32, 35, 38, 37, 4, 7, 2, 1, 8, 11, 14, 13, 28, 31, 26, 25, 16, 19, 22, 21], [21, 22, 19, 16, 25, 26, 31, 28, 13, 14, 11, 8, 1, 2, 7, 4, 37, 38, 35, 32, 41, 42, 47, 44, 61, 62, 59, 56, 49, 50, 55, 52, 54, 53, 48, 51, 58, 57, 60, 63, 46, 45, 40, 43, 34, 33, 36, 39, 6, 5, 0, 3, 10, 9, 12, 15, 30, 29, 24, 27, 18, 17, 20, 23], [27, 24, 29, 30, 23, 20, 17, 18, 3, 0, 5, 6, 15, 12, 9, 10, 43, 40, 45, 46, 39, 36, 33, 34, 51, 48, 53, 54, 63, 60, 57, 58, 56, 59, 62, 61, 52, 55, 50, 49, 32, 35, 38, 37, 44, 47, 42, 41, 8, 11, 14, 13, 4, 7, 2, 1, 16, 19, 22, 21, 28, 31, 26, 25], [25, 26, 31, 28, 21, 22, 19, 16, 1, 2, 7, 4, 13, 14, 11, 8, 41, 42, 47, 44, 37, 38, 35, 32, 49, 50, 55, 52, 61, 62, 59, 56, 58, 57, 60, 63, 54, 53, 48, 51, 34, 33, 36, 39, 46, 45, 40, 43, 10, 9, 12, 15, 6, 5, 0, 3, 18, 17, 20, 23, 30, 29, 24, 27], [31, 28, 25, 26, 19, 16, 21, 22, 7, 4, 1, 2, 11, 8, 13, 14, 47, 44, 41, 42, 35, 32, 37, 38, 55, 52, 49, 50, 59, 56, 61, 62, 60, 63, 58, 57, 48, 51, 54, 53, 36, 39, 34, 33, 40, 43, 46, 45, 12, 15, 10, 9, 0, 3, 6, 5, 20, 23, 18, 17, 24, 27, 30, 29], [29, 30, 27, 24, 17, 18, 23, 20, 5, 6, 3, 0, 9, 10, 15, 12, 45, 46, 43, 40, 33, 34, 39, 36, 53, 54, 51, 48, 57, 58, 63, 60, 62, 61, 56, 59, 50, 49, 52, 55, 38, 37, 32, 35, 42, 41, 44, 47, 14, 13, 8, 11, 2, 1, 4, 7, 22, 21, 16, 19, 26, 25, 28, 31], [35, 32, 37, 38, 47, 44, 41, 42, 59, 56, 61, 62, 55, 52, 49, 50, 19, 16, 21, 22, 31, 28, 25, 26, 11, 8, 13, 14, 7, 4, 1, 2, 0, 3, 6, 5, 12, 15, 10, 9, 24, 27, 30, 29, 20, 23, 18, 17, 48, 51, 54, 53, 60, 63, 58, 57, 40, 43, 46, 45, 36, 39, 34, 33], [33, 34, 39, 36, 45, 46, 43, 40, 57, 58, 63, 60, 53, 54, 51, 48, 17, 18, 23, 20, 29, 30, 27, 24, 9, 10, 15, 12, 5, 6, 3, 0, 2, 1, 4, 7, 14, 13, 8, 11, 26, 25, 28, 31, 22, 21, 16, 19, 50, 49, 52, 55, 62, 61, 56, 59, 42, 41, 44, 47, 38, 37, 32, 35], [39, 36, 33, 34, 43, 40, 45, 46, 63, 60, 57, 58, 51, 48, 53, 54, 23, 20, 17, 18, 27, 24, 29, 30, 15, 12, 9, 10, 3, 0, 5, 6, 4, 7, 2, 1, 8, 11, 14, 13, 28, 31, 26, 25, 16, 19, 22, 21, 52, 55, 50, 49, 56, 59, 62, 61, 44, 47, 42, 41, 32, 35, 38, 37], [37, 38, 35, 32, 41, 42, 47, 44, 61, 62, 59, 56, 49, 50, 55, 52, 21, 22, 19, 16, 25, 26, 31, 28, 13, 14, 11, 8, 1, 2, 7, 4, 6, 5, 0, 3, 10, 9, 12, 15, 30, 29, 24, 27, 18, 17, 20, 23, 54, 53, 48, 51, 58, 57, 60, 63, 46, 45, 40, 43, 34, 33, 36, 39], [43, 40, 45, 46, 39, 36, 33, 34, 51, 48, 53, 54, 63, 60, 57, 58, 27, 24, 29, 30, 23, 20, 17, 18, 3, 0, 5, 6, 15, 12, 9, 10, 8, 11, 14, 13, 4, 7, 2, 1, 16, 19, 22, 21, 28, 31, 26, 25, 56, 59, 62, 61, 52, 55, 50, 49, 32, 35, 38, 37, 44, 47, 42, 41], [41, 42, 47, 44, 37, 38, 35, 32, 49, 50, 55, 52, 61, 62, 59, 56, 25, 26, 31, 28, 21, 22, 19, 16, 1, 2, 7, 4, 13, 14, 11, 8, 10, 9, 12, 15, 6, 5, 0, 3, 18, 17, 20, 23, 30, 29, 24, 27, 58, 57, 60, 63, 54, 53, 48, 51, 34, 33, 36, 39, 46, 45, 40, 43], [47, 44, 41, 42, 35, 32, 37, 38, 55, 52, 49, 50, 59, 56, 61, 62, 31, 28, 25, 26, 19, 16, 21, 22, 7, 4, 1, 2, 11, 8, 13, 14, 12, 15, 10, 9, 0, 3, 6, 5, 20, 23, 18, 17, 24, 27, 30, 29, 60, 63, 58, 57, 48, 51, 54, 53, 36, 39, 34, 33, 40, 43, 46, 45], [45, 46, 43, 40, 33, 34, 39, 36, 53, 54, 51, 48, 57, 58, 63, 60, 29, 30, 27, 24, 17, 18, 23, 20, 5, 6, 3, 0, 9, 10, 15, 12, 14, 13, 8, 11, 2, 1, 4, 7, 22, 21, 16, 19, 26, 25, 28, 31, 62, 61, 56, 59, 50, 49, 52, 55, 38, 37, 32, 35, 42, 41, 44, 47], [51, 48, 53, 54, 63, 60, 57, 58, 43, 40, 45, 46, 39, 36, 33, 34, 3, 0, 5, 6, 15, 12, 9, 10, 27, 24, 29, 30, 23, 20, 17, 18, 16, 19, 22, 21, 28, 31, 26, 25, 8, 11, 14, 13, 4, 7, 2, 1, 32, 35, 38, 37, 44, 47, 42, 41, 56, 59, 62, 61, 52, 55, 50, 49], [49, 50, 55, 52, 61, 62, 59, 56, 41, 42, 47, 44, 37, 38, 35, 32, 1, 2, 7, 4, 13, 14, 11, 8, 25, 26, 31, 28, 21, 22, 19, 16, 18, 17, 20, 23, 30, 29, 24, 27, 10, 9, 12, 15, 6, 5, 0, 3, 34, 33, 36, 39, 46, 45, 40, 43, 58, 57, 60, 63, 54, 53, 48, 51], [55, 52, 49, 50, 59, 56, 61, 62, 47, 44, 41, 42, 35, 32, 37, 38, 7, 4, 1, 2, 11, 8, 13, 14, 31, 28, 25, 26, 19, 16, 21, 22, 20, 23, 18, 17, 24, 27, 30, 29, 12, 15, 10, 9, 0, 3, 6, 5, 36, 39, 34, 33, 40, 43, 46, 45, 60, 63, 58, 57, 48, 51, 54, 53], [53, 54, 51, 48, 57, 58, 63, 60, 45, 46, 43, 40, 33, 34, 39, 36, 5, 6, 3, 0, 9, 10, 15, 12, 29, 30, 27, 24, 17, 18, 23, 20, 22, 21, 16, 19, 26, 25, 28, 31, 14, 13, 8, 11, 2, 1, 4, 7, 38, 37, 32, 35, 42, 41, 44, 47, 62, 61, 56, 59, 50, 49, 52, 55], [59, 56, 61, 62, 55, 52, 49, 50, 35, 32, 37, 38, 47, 44, 41, 42, 11, 8, 13, 14, 7, 4, 1, 2, 19, 16, 21, 22, 31, 28, 25, 26, 24, 27, 30, 29, 20, 23, 18, 17, 0, 3, 6, 5, 12, 15, 10, 9, 40, 43, 46, 45, 36, 39, 34, 33, 48, 51, 54, 53, 60, 63, 58, 57], [57, 58, 63, 60, 53, 54, 51, 48, 33, 34, 39, 36, 45, 46, 43, 40, 9, 10, 15, 12, 5, 6, 3, 0, 17, 18, 23, 20, 29, 30, 27, 24, 26, 25, 28, 31, 22, 21, 16, 19, 2, 1, 4, 7, 14, 13, 8, 11, 42, 41, 44, 47, 38, 37, 32, 35, 50, 49, 52, 55, 62, 61, 56, 59], [63, 60, 57, 58, 51, 48, 53, 54, 39, 36, 33, 34, 43, 40, 45, 46, 15, 12, 9, 10, 3, 0, 5, 6, 23, 20, 17, 18, 27, 24, 29, 30, 28, 31, 26, 25, 16, 19, 22, 21, 4, 7, 2, 1, 8, 11, 14, 13, 44, 47, 42, 41, 32, 35, 38, 37, 52, 55, 50, 49, 56, 59, 62, 61], [61, 62, 59, 56, 49, 50, 55, 52, 37, 38, 35, 32, 41, 42, 47, 44, 13, 14, 11, 8, 1, 2, 7, 4, 21, 22, 19, 16, 25, 26, 31, 28, 30, 29, 24, 27, 18, 17, 20, 23, 6, 5, 0, 3, 10, 9, 12, 15, 46, 45, 40, 43, 34, 33, 36, 39, 54, 53, 48, 51, 58, 57, 60, 63]]} +RLMATH_EOF diff --git a/tasks/construct-mc-quasigroup-idempotent-l6-s3/tests/check.py b/tasks/construct-mc-quasigroup-idempotent-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4563f2e9a90050cdd7c56dfc33831acde74c9ef2 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l6-s3/tests/check.py @@ -0,0 +1,21 @@ +"""Idempotent quasigroup satisfying QG3, (x*y)*(y*x) = x (MathConstraint quasigroup_idempotent, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + T = ans.get("table") + if not isinstance(T, list) or len(T) != n: + raise Invalid(f"table must be a list of {n} rows") + T = [int_list(r, n, 0, n - 1, "table row") for r in T] + full = list(range(n)) + for i in range(n): + if sorted(T[i]) != full or sorted(T[r][i] for r in range(n)) != full: + raise Invalid(f"row/column {i} is not a permutation (not a Latin square)") + if T[i][i] != i: + raise Invalid(f"not idempotent: {i}*{i} = {T[i][i]}") + for i in range(n): + for j in range(n): + if T[T[i][j]][T[j][i]] != i: + raise Invalid(f"QG3 fails for (x, y) = ({i}, {j})") + return None, {} diff --git a/tasks/construct-mc-quasigroup-idempotent-l6-s3/tests/instance.json b/tasks/construct-mc-quasigroup-idempotent-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f939df9de97c2ee971be1ec4a34d241b58bfe9c1 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 64, "family": "mc_quasigroup_idempotent", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-quasigroup-idempotent-l6-s3/tests/run.py b/tasks/construct-mc-quasigroup-idempotent-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-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-quasigroup-idempotent-l6-s3/tests/test.sh b/tasks/construct-mc-quasigroup-idempotent-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-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-ramsey-l3-s1/environment/Dockerfile b/tasks/construct-mc-ramsey-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-ramsey-l3-s1/environment/instance.json b/tasks/construct-mc-ramsey-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e51539f6793aae0eac866cf31ca6ea63010a0850 --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 15, "r": 4, "s": 4, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l3-s1/solution/solve.sh b/tasks/construct-mc-ramsey-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..259a5e9344ee27b4732d36da7a1cee1c7ce837bb --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-ramsey-l3-s1/tests/check.py b/tasks/construct-mc-ramsey-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s1/tests/check.py @@ -0,0 +1,31 @@ +"""Two-colouring of the edges of K_n with no colour-0 K_r and no colour-1 K_s (MathConstraint ramsey, +CC-BY-4.0). Adapted from pilot/grader.py check_ramsey; adds the optional fixed edge colours.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, r, s = inst["n"], inst["r"], inst["s"] + edges = list(itertools.combinations(range(n), 2)) + col = int_list(ans.get("colors"), len(edges), 0, 1, "colors") + for name, i, v in inst.get("fixed", []): + if col[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + c = {e: col[i] for i, e in enumerate(edges)} + for k, colour in ((r, 0), (s, 1)): + adj = {v: {u for u in range(n) if u != v and c[(min(u, v), max(u, v))] == colour} for v in range(n)} + + def grow(size, cand): + if size == k: + return True + if size + len(cand) < k: + return False + for v in sorted(cand): + if grow(size + 1, {u for u in cand if u > v} & adj[v]): + return True + return False + + if grow(0, set(range(n))): + raise Invalid(f"monochromatic K_{k} in colour {colour}") + return None, {} diff --git a/tasks/construct-mc-ramsey-l3-s1/tests/instance.json b/tasks/construct-mc-ramsey-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e51539f6793aae0eac866cf31ca6ea63010a0850 --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 15, "r": 4, "s": 4, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l3-s1/tests/run.py b/tasks/construct-mc-ramsey-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-ramsey-l3-s1/tests/test.sh b/tasks/construct-mc-ramsey-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-ramsey-l3-s6/environment/Dockerfile b/tasks/construct-mc-ramsey-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-ramsey-l3-s6/environment/instance.json b/tasks/construct-mc-ramsey-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c25d0fd2f052574f600138f95b37827b3bc40871 --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 14, "r": 3, "s": 6, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l3-s6/solution/solve.sh b/tasks/construct-mc-ramsey-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8cdd5bfa43e83dc461ee5ec257b11350fadbbcb2 --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-ramsey-l3-s6/tests/check.py b/tasks/construct-mc-ramsey-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s6/tests/check.py @@ -0,0 +1,31 @@ +"""Two-colouring of the edges of K_n with no colour-0 K_r and no colour-1 K_s (MathConstraint ramsey, +CC-BY-4.0). Adapted from pilot/grader.py check_ramsey; adds the optional fixed edge colours.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, r, s = inst["n"], inst["r"], inst["s"] + edges = list(itertools.combinations(range(n), 2)) + col = int_list(ans.get("colors"), len(edges), 0, 1, "colors") + for name, i, v in inst.get("fixed", []): + if col[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + c = {e: col[i] for i, e in enumerate(edges)} + for k, colour in ((r, 0), (s, 1)): + adj = {v: {u for u in range(n) if u != v and c[(min(u, v), max(u, v))] == colour} for v in range(n)} + + def grow(size, cand): + if size == k: + return True + if size + len(cand) < k: + return False + for v in sorted(cand): + if grow(size + 1, {u for u in cand if u > v} & adj[v]): + return True + return False + + if grow(0, set(range(n))): + raise Invalid(f"monochromatic K_{k} in colour {colour}") + return None, {} diff --git a/tasks/construct-mc-ramsey-l3-s6/tests/instance.json b/tasks/construct-mc-ramsey-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c25d0fd2f052574f600138f95b37827b3bc40871 --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 14, "r": 3, "s": 6, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l3-s6/tests/run.py b/tasks/construct-mc-ramsey-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-ramsey-l3-s6/tests/test.sh b/tasks/construct-mc-ramsey-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-ramsey-l4-s2/environment/Dockerfile b/tasks/construct-mc-ramsey-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-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-mc-ramsey-l4-s2/environment/instance.json b/tasks/construct-mc-ramsey-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8a7be9d5afa75909d1f5c6f6f21e6057ccca2a21 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 21, "r": 4, "s": 5, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s2/solution/solve.sh b/tasks/construct-mc-ramsey-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e4d042fdae8b900d8e1c4756a46238dde15b626c --- /dev/null +++ b/tasks/construct-mc-ramsey-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' +{"colors": [0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-ramsey-l4-s2/tests/check.py b/tasks/construct-mc-ramsey-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s2/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-s2/tests/instance.json b/tasks/construct-mc-ramsey-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8a7be9d5afa75909d1f5c6f6f21e6057ccca2a21 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 21, "r": 4, "s": 5, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s2/tests/run.py b/tasks/construct-mc-ramsey-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-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-mc-ramsey-l4-s2/tests/test.sh b/tasks/construct-mc-ramsey-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-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-mc-social-golfers-l1-s0/environment/Dockerfile b/tasks/construct-mc-social-golfers-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-social-golfers-l1-s0/environment/instance.json b/tasks/construct-mc-social-golfers-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d45dd0dc40743eecffc80e05dd98c32ffb05fdd8 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"n_groups": 3, "group_size": 3, "n_weeks": 4, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l1-s0/solution/solve.sh b/tasks/construct-mc-social-golfers-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b26234ceea903a0c7126a263ed2f99cc1f40deb1 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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' +{"schedule": [[0, 1, 2, 0, 1, 2, 0, 1, 2], [0, 1, 2, 2, 0, 1, 1, 2, 0], [0, 1, 2, 1, 2, 0, 2, 0, 1], [0, 0, 0, 1, 1, 1, 2, 2, 2]]} +RLMATH_EOF diff --git a/tasks/construct-mc-social-golfers-l1-s0/tests/check.py b/tasks/construct-mc-social-golfers-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..73977815b7b6094a8491075b6dc2ae1293e44930 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l1-s0/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-s0/tests/instance.json b/tasks/construct-mc-social-golfers-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d45dd0dc40743eecffc80e05dd98c32ffb05fdd8 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"n_groups": 3, "group_size": 3, "n_weeks": 4, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l1-s0/tests/run.py b/tasks/construct-mc-social-golfers-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-social-golfers-l1-s0/tests/test.sh b/tasks/construct-mc-social-golfers-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-social-golfers-l6-s3/environment/Dockerfile b/tasks/construct-mc-social-golfers-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-social-golfers-l6-s3/environment/instance.json b/tasks/construct-mc-social-golfers-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6da59344d3fe2e69958677c9f49e0835a8ed422e --- /dev/null +++ b/tasks/construct-mc-social-golfers-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"n_groups": 7, "group_size": 7, "n_weeks": 6, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l6-s3/solution/solve.sh b/tasks/construct-mc-social-golfers-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3c594bcbe9d03efae6e129dc85fafe4a32bed21b --- /dev/null +++ b/tasks/construct-mc-social-golfers-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' +{"schedule": [[0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6], [0, 1, 2, 3, 4, 5, 6, 6, 0, 1, 2, 3, 4, 5, 5, 6, 0, 1, 2, 3, 4, 4, 5, 6, 0, 1, 2, 3, 3, 4, 5, 6, 0, 1, 2, 2, 3, 4, 5, 6, 0, 1, 1, 2, 3, 4, 5, 6, 0], [0, 1, 2, 3, 4, 5, 6, 5, 6, 0, 1, 2, 3, 4, 3, 4, 5, 6, 0, 1, 2, 1, 2, 3, 4, 5, 6, 0, 6, 0, 1, 2, 3, 4, 5, 4, 5, 6, 0, 1, 2, 3, 2, 3, 4, 5, 6, 0, 1], [0, 1, 2, 3, 4, 5, 6, 4, 5, 6, 0, 1, 2, 3, 1, 2, 3, 4, 5, 6, 0, 5, 6, 0, 1, 2, 3, 4, 2, 3, 4, 5, 6, 0, 1, 6, 0, 1, 2, 3, 4, 5, 3, 4, 5, 6, 0, 1, 2], [0, 1, 2, 3, 4, 5, 6, 3, 4, 5, 6, 0, 1, 2, 6, 0, 1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 0, 1, 5, 6, 0, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 0, 4, 5, 6, 0, 1, 2, 3], [0, 1, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 0, 1, 4, 5, 6, 0, 1, 2, 3, 6, 0, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 0, 3, 4, 5, 6, 0, 1, 2, 5, 6, 0, 1, 2, 3, 4]]} +RLMATH_EOF diff --git a/tasks/construct-mc-social-golfers-l6-s3/tests/check.py b/tasks/construct-mc-social-golfers-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..73977815b7b6094a8491075b6dc2ae1293e44930 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l6-s3/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-l6-s3/tests/instance.json b/tasks/construct-mc-social-golfers-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6da59344d3fe2e69958677c9f49e0835a8ed422e --- /dev/null +++ b/tasks/construct-mc-social-golfers-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"n_groups": 7, "group_size": 7, "n_weeks": 6, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l6-s3/tests/run.py b/tasks/construct-mc-social-golfers-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-social-golfers-l6-s3/tests/test.sh b/tasks/construct-mc-social-golfers-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-vertex-cover-l2-s3/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l2-s3/environment/instance.json b/tasks/construct-mc-vertex-cover-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f9a89701c37d2aec6d5563f7f9821eec86b9d796 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 30, "k": 18, "edges": [[0, 1], [0, 6], [0, 7], [0, 9], [0, 13], [0, 16], [0, 22], [0, 23], [0, 25], [0, 26], [1, 3], [1, 8], [1, 9], [2, 6], [2, 11], [2, 15], [2, 16], [2, 17], [2, 19], [2, 23], [3, 10], [3, 22], [3, 26], [3, 29], [4, 6], [4, 19], [4, 22], [5, 7], [5, 14], [7, 11], [7, 21], [7, 24], [7, 26], [7, 27], [8, 15], [8, 21], [8, 28], [9, 11], [9, 13], [9, 15], [9, 18], [9, 29], [10, 17], [10, 29], [11, 15], [11, 22], [11, 25], [12, 13], [13, 16], [13, 19], [13, 29], [14, 22], [15, 29], [16, 21], [16, 22], [17, 21], [19, 23], [19, 25], [20, 22], [20, 24], [20, 28], [21, 27], [21, 28], [22, 24], [24, 25], [24, 27], [24, 29], [25, 29]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l2-s3/solution/solve.sh b/tasks/construct-mc-vertex-cover-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4970f3cc9a27be51cb1425309ecf543e6f44b91a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [0, 1, 2, 3, 4, 5, 7, 9, 10, 13, 14, 15, 21, 22, 23, 24, 25, 28]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l2-s3/tests/check.py b/tasks/construct-mc-vertex-cover-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l2-s3/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l2-s3/tests/instance.json b/tasks/construct-mc-vertex-cover-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f9a89701c37d2aec6d5563f7f9821eec86b9d796 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 30, "k": 18, "edges": [[0, 1], [0, 6], [0, 7], [0, 9], [0, 13], [0, 16], [0, 22], [0, 23], [0, 25], [0, 26], [1, 3], [1, 8], [1, 9], [2, 6], [2, 11], [2, 15], [2, 16], [2, 17], [2, 19], [2, 23], [3, 10], [3, 22], [3, 26], [3, 29], [4, 6], [4, 19], [4, 22], [5, 7], [5, 14], [7, 11], [7, 21], [7, 24], [7, 26], [7, 27], [8, 15], [8, 21], [8, 28], [9, 11], [9, 13], [9, 15], [9, 18], [9, 29], [10, 17], [10, 29], [11, 15], [11, 22], [11, 25], [12, 13], [13, 16], [13, 19], [13, 29], [14, 22], [15, 29], [16, 21], [16, 22], [17, 21], [19, 23], [19, 25], [20, 22], [20, 24], [20, 28], [21, 27], [21, 28], [22, 24], [24, 25], [24, 27], [24, 29], [25, 29]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l2-s3/tests/run.py b/tasks/construct-mc-vertex-cover-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l2-s3/tests/test.sh b/tasks/construct-mc-vertex-cover-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l2-s4/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l2-s4/environment/instance.json b/tasks/construct-mc-vertex-cover-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f996469969d18646d46f76ad8660d21dbc087786 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 30, "k": 18, "edges": [[0, 2], [0, 8], [0, 17], [0, 22], [1, 3], [1, 5], [1, 16], [1, 22], [2, 5], [2, 9], [2, 12], [2, 15], [2, 25], [2, 26], [2, 28], [3, 8], [3, 26], [4, 13], [4, 27], [4, 29], [5, 6], [5, 12], [5, 16], [5, 19], [5, 20], [5, 21], [5, 25], [5, 28], [6, 17], [6, 18], [6, 23], [6, 24], [6, 27], [6, 29], [7, 11], [7, 14], [7, 17], [7, 18], [7, 19], [7, 20], [7, 23], [7, 27], [8, 10], [8, 14], [8, 18], [8, 26], [10, 13], [10, 16], [10, 22], [10, 28], [12, 23], [13, 16], [13, 21], [13, 26], [14, 15], [14, 17], [14, 19], [14, 20], [14, 26], [15, 16], [15, 28], [15, 29], [16, 28], [17, 18], [17, 21], [17, 22], [17, 24], [18, 19], [18, 21], [18, 23], [18, 25], [18, 27], [19, 27], [19, 28], [20, 22], [22, 24], [22, 26], [22, 29], [24, 26], [24, 28], [25, 27], [25, 28]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l2-s4/solution/solve.sh b/tasks/construct-mc-vertex-cover-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2ac32894a27a53652e4ebfe2925f49bc162d8c28 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [2, 3, 5, 7, 8, 12, 13, 14, 16, 17, 18, 22, 23, 24, 26, 27, 28, 29]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l2-s4/tests/check.py b/tasks/construct-mc-vertex-cover-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l2-s4/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l2-s4/tests/instance.json b/tasks/construct-mc-vertex-cover-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f996469969d18646d46f76ad8660d21dbc087786 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 30, "k": 18, "edges": [[0, 2], [0, 8], [0, 17], [0, 22], [1, 3], [1, 5], [1, 16], [1, 22], [2, 5], [2, 9], [2, 12], [2, 15], [2, 25], [2, 26], [2, 28], [3, 8], [3, 26], [4, 13], [4, 27], [4, 29], [5, 6], [5, 12], [5, 16], [5, 19], [5, 20], [5, 21], [5, 25], [5, 28], [6, 17], [6, 18], [6, 23], [6, 24], [6, 27], [6, 29], [7, 11], [7, 14], [7, 17], [7, 18], [7, 19], [7, 20], [7, 23], [7, 27], [8, 10], [8, 14], [8, 18], [8, 26], [10, 13], [10, 16], [10, 22], [10, 28], [12, 23], [13, 16], [13, 21], [13, 26], [14, 15], [14, 17], [14, 19], [14, 20], [14, 26], [15, 16], [15, 28], [15, 29], [16, 28], [17, 18], [17, 21], [17, 22], [17, 24], [18, 19], [18, 21], [18, 23], [18, 25], [18, 27], [19, 27], [19, 28], [20, 22], [22, 24], [22, 26], [22, 29], [24, 26], [24, 28], [25, 27], [25, 28]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l2-s4/tests/run.py b/tasks/construct-mc-vertex-cover-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l2-s4/tests/test.sh b/tasks/construct-mc-vertex-cover-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-vertex-cover-l5-s0/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-vertex-cover-l5-s0/environment/instance.json b/tasks/construct-mc-vertex-cover-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f871c922a671bfdaaf2874c5848c85c97568fbea --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 2], [0, 6], [0, 9], [0, 10], [0, 12], [0, 34], [0, 53], [0, 59], [0, 63], [0, 70], [0, 84], [1, 16], [1, 18], [1, 22], [1, 26], [1, 52], [1, 58], [1, 74], [1, 78], [2, 16], [2, 18], [2, 21], [2, 22], [2, 25], [2, 26], [2, 37], [2, 38], [2, 43], [2, 44], [2, 50], [2, 52], [2, 67], [2, 68], [3, 13], [3, 16], [3, 30], [3, 33], [3, 46], [3, 53], [3, 57], [3, 61], [3, 71], [3, 72], [3, 73], [3, 78], [3, 82], [4, 15], [4, 22], [4, 36], [4, 41], [4, 44], [4, 50], [4, 59], [4, 69], [4, 77], [4, 85], [5, 13], [5, 23], [5, 24], [5, 26], [5, 32], [5, 38], [5, 44], [5, 45], [5, 46], [5, 58], [5, 83], [6, 10], [6, 15], [6, 26], [6, 27], [6, 40], [6, 52], [6, 53], [6, 55], [6, 61], [6, 69], [6, 75], [6, 79], [6, 88], [7, 9], [7, 15], [7, 24], [7, 36], [7, 43], [7, 48], [7, 58], [7, 71], [7, 74], [7, 76], [7, 77], [7, 78], [7, 80], [7, 83], [7, 85], [8, 26], [8, 30], [8, 74], [8, 76], [9, 23], [9, 38], [9, 52], [9, 67], [10, 12], [10, 27], [10, 35], [10, 36], [10, 41], [10, 44], [10, 46], [10, 50], [10, 59], [10, 60], [10, 63], [11, 13], [11, 22], [11, 24], [11, 27], [11, 44], [11, 46], [11, 60], [11, 63], [11, 65], [11, 67], [11, 70], [11, 75], [12, 13], [12, 24], [12, 28], [12, 34], [12, 36], [12, 48], [12, 50], [12, 53], [12, 56], [12, 61], [12, 62], [12, 72], [12, 87], [13, 17], [13, 28], [13, 29], [13, 39], [13, 40], [13, 45], [13, 48], [13, 51], [13, 54], [13, 63], [13, 66], [13, 68], [13, 69], [13, 73], [13, 76], [13, 84], [14, 21], [14, 41], [14, 51], [14, 52], [14, 57], [14, 77], [14, 85], [15, 16], [15, 26], [15, 33], [15, 35], [15, 37], [15, 39], [15, 41], [15, 42], [15, 45], [15, 60], [15, 63], [15, 73], [15, 77], [15, 80], [15, 83], [15, 89], [16, 28], [16, 31], [16, 32], [16, 50], [16, 52], [16, 68], [16, 69], [16, 78], [16, 84], [16, 86], [16, 87], [17, 21], [17, 24], [17, 25], [17, 27], [17, 31], [17, 33], [17, 46], [17, 49], [17, 50], [17, 64], [17, 80], [17, 83], [18, 23], [18, 41], [18, 61], [18, 66], [19, 21], [19, 23], [19, 38], [19, 44], [19, 52], [19, 63], [19, 66], [20, 31], [20, 40], [20, 67], [20, 73], [21, 35], [21, 42], [21, 43], [21, 44], [21, 54], [21, 61], [21, 77], [21, 78], [22, 24], [22, 25], [22, 35], [22, 46], [22, 63], [22, 65], [22, 78], [22, 80], [22, 87], [22, 88], [23, 26], [23, 31], [23, 32], [23, 34], [23, 55], [23, 57], [23, 63], [23, 69], [23, 78], [23, 79], [23, 85], [23, 88], [24, 28], [24, 42], [24, 47], [24, 57], [24, 59], [24, 65], [24, 67], [24, 74], [25, 40], [25, 44], [25, 45], [25, 47], [25, 67], [25, 73], [25, 76], [25, 84], [26, 31], [26, 41], [26, 68], [26, 71], [26, 74], [26, 87], [27, 29], [27, 30], [27, 42], [27, 51], [27, 53], [27, 55], [27, 61], [27, 68], [27, 69], [27, 81], [27, 87], [28, 53], [28, 69], [28, 71], [28, 86], [29, 39], [29, 48], [29, 49], [29, 55], [29, 58], [29, 67], [29, 74], [29, 76], [29, 78], [30, 37], [30, 38], [30, 55], [30, 56], [30, 65], [30, 72], [30, 73], [30, 78], [30, 87], [31, 50], [31, 63], [31, 65], [31, 67], [31, 68], [31, 84], [32, 38], [32, 39], [32, 41], [32, 65], [32, 67], [32, 69], [32, 71], [32, 73], [32, 74], [33, 36], [33, 39], [33, 40], [33, 43], [33, 52], [33, 53], [33, 71], [33, 80], [34, 36], [34, 44], [34, 46], [34, 57], [34, 71], [34, 72], [34, 78], [34, 82], [34, 83], [35, 63], [35, 67], [35, 80], [36, 37], [36, 44], [36, 65], [36, 75], [36, 89], [37, 44], [37, 56], [37, 70], [37, 76], [37, 84], [37, 87], [37, 89], [38, 41], [38, 55], [38, 60], [38, 61], [38, 73], [38, 76], [38, 80], [39, 50], [39, 54], [39, 59], [39, 64], [39, 73], [39, 77], [39, 84], [40, 42], [40, 55], [40, 62], [40, 76], [40, 79], [40, 86], [41, 42], [41, 51], [41, 52], [41, 57], [41, 58], [41, 74], [41, 76], [41, 81], [41, 85], [41, 89], [42, 63], [42, 68], [42, 73], [42, 80], [43, 44], [43, 45], [43, 46], [43, 51], [43, 56], [43, 58], [43, 70], [43, 77], [43, 87], [43, 88], [44, 49], [44, 70], [44, 72], [44, 74], [45, 63], [45, 64], [45, 71], [45, 73], [45, 76], [45, 78], [45, 83], [45, 86], [46, 69], [46, 72], [46, 79], [46, 83], [46, 87], [47, 58], [47, 61], [47, 65], [47, 66], [47, 80], [48, 50], [48, 58], [48, 59], [48, 60], [48, 76], [48, 87], [49, 50], [49, 78], [49, 85], [50, 53], [50, 69], [50, 72], [50, 73], [50, 74], [50, 78], [50, 87], [50, 88], [51, 66], [51, 87], [52, 53], [52, 63], [52, 66], [52, 69], [52, 74], [52, 78], [53, 63], [53, 71], [53, 81], [53, 86], [53, 87], [53, 89], [54, 83], [55, 71], [55, 89], [56, 67], [56, 68], [56, 72], [56, 74], [56, 80], [56, 83], [56, 86], [57, 61], [57, 66], [57, 76], [57, 87], [57, 89], [58, 61], [58, 67], [58, 68], [58, 69], [58, 78], [58, 79], [58, 82], [58, 86], [59, 61], [59, 73], [59, 74], [59, 78], [59, 82], [59, 85], [60, 62], [60, 67], [60, 74], [60, 83], [60, 87], [60, 89], [61, 69], [61, 77], [61, 87], [62, 71], [62, 77], [62, 87], [63, 67], [63, 69], [63, 70], [63, 71], [63, 85], [64, 68], [65, 72], [65, 74], [66, 84], [67, 81], [67, 87], [68, 69], [68, 84], [68, 86], [69, 71], [69, 73], [69, 77], [69, 88], [70, 80], [71, 84], [71, 89], [72, 89], [73, 75], [73, 76], [73, 82], [73, 84], [74, 75], [74, 87], [74, 88], [76, 77], [76, 80], [76, 81], [76, 86], [76, 89], [77, 83], [77, 86], [78, 83], [80, 81], [80, 88], [83, 86], [84, 86], [85, 87], [86, 88]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s0/solution/solve.sh b/tasks/construct-mc-vertex-cover-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c51b58820cfbab860fff74fa02a32a2847133a79 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [0, 3, 6, 9, 11, 12, 13, 15, 16, 17, 18, 21, 22, 23, 24, 25, 26, 27, 30, 31, 32, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 55, 57, 58, 59, 60, 62, 63, 66, 67, 68, 69, 71, 72, 73, 74, 76, 77, 78, 80, 82, 83, 85, 86, 87]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l5-s0/tests/check.py b/tasks/construct-mc-vertex-cover-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s0/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-s0/tests/instance.json b/tasks/construct-mc-vertex-cover-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f871c922a671bfdaaf2874c5848c85c97568fbea --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 2], [0, 6], [0, 9], [0, 10], [0, 12], [0, 34], [0, 53], [0, 59], [0, 63], [0, 70], [0, 84], [1, 16], [1, 18], [1, 22], [1, 26], [1, 52], [1, 58], [1, 74], [1, 78], [2, 16], [2, 18], [2, 21], [2, 22], [2, 25], [2, 26], [2, 37], [2, 38], [2, 43], [2, 44], [2, 50], [2, 52], [2, 67], [2, 68], [3, 13], [3, 16], [3, 30], [3, 33], [3, 46], [3, 53], [3, 57], [3, 61], [3, 71], [3, 72], [3, 73], [3, 78], [3, 82], [4, 15], [4, 22], [4, 36], [4, 41], [4, 44], [4, 50], [4, 59], [4, 69], [4, 77], [4, 85], [5, 13], [5, 23], [5, 24], [5, 26], [5, 32], [5, 38], [5, 44], [5, 45], [5, 46], [5, 58], [5, 83], [6, 10], [6, 15], [6, 26], [6, 27], [6, 40], [6, 52], [6, 53], [6, 55], [6, 61], [6, 69], [6, 75], [6, 79], [6, 88], [7, 9], [7, 15], [7, 24], [7, 36], [7, 43], [7, 48], [7, 58], [7, 71], [7, 74], [7, 76], [7, 77], [7, 78], [7, 80], [7, 83], [7, 85], [8, 26], [8, 30], [8, 74], [8, 76], [9, 23], [9, 38], [9, 52], [9, 67], [10, 12], [10, 27], [10, 35], [10, 36], [10, 41], [10, 44], [10, 46], [10, 50], [10, 59], [10, 60], [10, 63], [11, 13], [11, 22], [11, 24], [11, 27], [11, 44], [11, 46], [11, 60], [11, 63], [11, 65], [11, 67], [11, 70], [11, 75], [12, 13], [12, 24], [12, 28], [12, 34], [12, 36], [12, 48], [12, 50], [12, 53], [12, 56], [12, 61], [12, 62], [12, 72], [12, 87], [13, 17], [13, 28], [13, 29], [13, 39], [13, 40], [13, 45], [13, 48], [13, 51], [13, 54], [13, 63], [13, 66], [13, 68], [13, 69], [13, 73], [13, 76], [13, 84], [14, 21], [14, 41], [14, 51], [14, 52], [14, 57], [14, 77], [14, 85], [15, 16], [15, 26], [15, 33], [15, 35], [15, 37], [15, 39], [15, 41], [15, 42], [15, 45], [15, 60], [15, 63], [15, 73], [15, 77], [15, 80], [15, 83], [15, 89], [16, 28], [16, 31], [16, 32], [16, 50], [16, 52], [16, 68], [16, 69], [16, 78], [16, 84], [16, 86], [16, 87], [17, 21], [17, 24], [17, 25], [17, 27], [17, 31], [17, 33], [17, 46], [17, 49], [17, 50], [17, 64], [17, 80], [17, 83], [18, 23], [18, 41], [18, 61], [18, 66], [19, 21], [19, 23], [19, 38], [19, 44], [19, 52], [19, 63], [19, 66], [20, 31], [20, 40], [20, 67], [20, 73], [21, 35], [21, 42], [21, 43], [21, 44], [21, 54], [21, 61], [21, 77], [21, 78], [22, 24], [22, 25], [22, 35], [22, 46], [22, 63], [22, 65], [22, 78], [22, 80], [22, 87], [22, 88], [23, 26], [23, 31], [23, 32], [23, 34], [23, 55], [23, 57], [23, 63], [23, 69], [23, 78], [23, 79], [23, 85], [23, 88], [24, 28], [24, 42], [24, 47], [24, 57], [24, 59], [24, 65], [24, 67], [24, 74], [25, 40], [25, 44], [25, 45], [25, 47], [25, 67], [25, 73], [25, 76], [25, 84], [26, 31], [26, 41], [26, 68], [26, 71], [26, 74], [26, 87], [27, 29], [27, 30], [27, 42], [27, 51], [27, 53], [27, 55], [27, 61], [27, 68], [27, 69], [27, 81], [27, 87], [28, 53], [28, 69], [28, 71], [28, 86], [29, 39], [29, 48], [29, 49], [29, 55], [29, 58], [29, 67], [29, 74], [29, 76], [29, 78], [30, 37], [30, 38], [30, 55], [30, 56], [30, 65], [30, 72], [30, 73], [30, 78], [30, 87], [31, 50], [31, 63], [31, 65], [31, 67], [31, 68], [31, 84], [32, 38], [32, 39], [32, 41], [32, 65], [32, 67], [32, 69], [32, 71], [32, 73], [32, 74], [33, 36], [33, 39], [33, 40], [33, 43], [33, 52], [33, 53], [33, 71], [33, 80], [34, 36], [34, 44], [34, 46], [34, 57], [34, 71], [34, 72], [34, 78], [34, 82], [34, 83], [35, 63], [35, 67], [35, 80], [36, 37], [36, 44], [36, 65], [36, 75], [36, 89], [37, 44], [37, 56], [37, 70], [37, 76], [37, 84], [37, 87], [37, 89], [38, 41], [38, 55], [38, 60], [38, 61], [38, 73], [38, 76], [38, 80], [39, 50], [39, 54], [39, 59], [39, 64], [39, 73], [39, 77], [39, 84], [40, 42], [40, 55], [40, 62], [40, 76], [40, 79], [40, 86], [41, 42], [41, 51], [41, 52], [41, 57], [41, 58], [41, 74], [41, 76], [41, 81], [41, 85], [41, 89], [42, 63], [42, 68], [42, 73], [42, 80], [43, 44], [43, 45], [43, 46], [43, 51], [43, 56], [43, 58], [43, 70], [43, 77], [43, 87], [43, 88], [44, 49], [44, 70], [44, 72], [44, 74], [45, 63], [45, 64], [45, 71], [45, 73], [45, 76], [45, 78], [45, 83], [45, 86], [46, 69], [46, 72], [46, 79], [46, 83], [46, 87], [47, 58], [47, 61], [47, 65], [47, 66], [47, 80], [48, 50], [48, 58], [48, 59], [48, 60], [48, 76], [48, 87], [49, 50], [49, 78], [49, 85], [50, 53], [50, 69], [50, 72], [50, 73], [50, 74], [50, 78], [50, 87], [50, 88], [51, 66], [51, 87], [52, 53], [52, 63], [52, 66], [52, 69], [52, 74], [52, 78], [53, 63], [53, 71], [53, 81], [53, 86], [53, 87], [53, 89], [54, 83], [55, 71], [55, 89], [56, 67], [56, 68], [56, 72], [56, 74], [56, 80], [56, 83], [56, 86], [57, 61], [57, 66], [57, 76], [57, 87], [57, 89], [58, 61], [58, 67], [58, 68], [58, 69], [58, 78], [58, 79], [58, 82], [58, 86], [59, 61], [59, 73], [59, 74], [59, 78], [59, 82], [59, 85], [60, 62], [60, 67], [60, 74], [60, 83], [60, 87], [60, 89], [61, 69], [61, 77], [61, 87], [62, 71], [62, 77], [62, 87], [63, 67], [63, 69], [63, 70], [63, 71], [63, 85], [64, 68], [65, 72], [65, 74], [66, 84], [67, 81], [67, 87], [68, 69], [68, 84], [68, 86], [69, 71], [69, 73], [69, 77], [69, 88], [70, 80], [71, 84], [71, 89], [72, 89], [73, 75], [73, 76], [73, 82], [73, 84], [74, 75], [74, 87], [74, 88], [76, 77], [76, 80], [76, 81], [76, 86], [76, 89], [77, 83], [77, 86], [78, 83], [80, 81], [80, 88], [83, 86], [84, 86], [85, 87], [86, 88]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s0/tests/run.py b/tasks/construct-mc-vertex-cover-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-vertex-cover-l5-s0/tests/test.sh b/tasks/construct-mc-vertex-cover-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-vertex-cover-l6-s5/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l6-s5/environment/instance.json b/tasks/construct-mc-vertex-cover-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e39f82b7f8a6cc001f6bcdb37ac3ea6005cf5ee2 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 140, "k": 107, "edges": [[0, 2], [0, 12], [0, 15], [0, 20], [0, 24], [0, 46], [0, 50], [0, 51], [0, 52], [0, 53], [0, 62], [0, 70], [0, 95], [0, 102], [0, 117], [0, 121], [0, 127], [0, 134], [1, 3], [1, 11], [1, 16], [1, 52], [1, 53], [1, 60], [1, 64], [1, 69], [1, 79], [1, 81], [1, 90], [1, 91], [1, 98], [1, 100], [1, 102], [1, 103], [1, 105], [1, 110], [2, 21], [2, 33], [2, 39], [2, 44], [2, 50], [2, 53], [2, 61], [2, 71], [2, 92], [2, 98], [2, 120], [2, 132], [2, 139], [3, 5], [3, 9], [3, 12], [3, 25], [3, 30], [3, 35], [3, 38], [3, 55], [3, 56], [3, 62], [3, 76], [3, 77], [3, 79], [3, 90], [3, 102], [3, 114], [3, 121], [3, 127], [3, 132], [3, 137], [4, 45], [4, 52], [4, 75], [4, 81], [4, 90], [4, 97], [4, 107], [4, 125], [4, 129], [4, 135], [5, 22], [5, 27], [5, 31], [5, 46], [5, 60], [5, 63], [5, 66], [5, 70], [5, 83], [5, 97], [5, 98], [5, 106], [5, 112], [5, 117], [5, 131], [5, 135], [6, 15], [6, 28], [6, 30], [6, 43], [6, 47], [6, 54], [6, 55], [6, 62], [6, 64], [6, 72], [6, 85], [6, 88], [6, 96], [6, 110], [6, 112], [6, 113], [6, 137], [6, 138], [7, 25], [7, 39], [7, 51], [7, 63], [7, 65], [7, 74], [7, 77], [7, 80], [7, 89], [7, 90], [7, 91], [7, 93], [7, 96], [7, 100], [7, 101], [7, 102], [7, 109], [7, 116], [7, 117], [7, 128], [8, 13], [8, 15], [8, 16], [8, 28], [8, 29], [8, 32], [8, 62], [8, 71], [8, 95], [8, 96], [8, 102], [8, 104], [8, 124], [9, 16], [9, 20], [9, 27], [9, 30], [9, 32], [9, 51], [9, 65], [9, 68], [9, 73], [9, 80], [9, 92], [9, 94], [9, 100], [9, 102], [9, 103], [9, 104], [9, 126], [9, 134], [10, 16], [10, 36], [10, 38], [10, 52], [10, 53], [10, 69], [10, 70], [10, 81], [10, 88], [10, 101], [10, 111], [10, 113], [10, 120], [10, 128], [10, 131], [11, 25], [11, 51], [11, 57], [11, 61], [11, 66], [11, 69], [11, 76], [11, 88], [11, 93], [11, 98], [11, 99], [11, 100], [11, 102], [11, 116], [11, 121], [11, 122], [11, 125], [11, 129], [11, 131], [12, 18], [12, 49], [12, 51], [12, 55], [12, 56], [12, 83], [12, 85], [12, 88], [12, 91], [12, 100], [12, 104], [12, 105], [12, 107], [12, 113], [12, 116], [12, 119], [12, 134], [12, 138], [13, 22], [13, 25], [13, 33], [13, 47], [13, 57], [13, 62], [13, 68], [13, 86], [13, 92], [13, 99], [13, 112], [13, 113], [13, 115], [13, 122], [13, 131], [13, 132], [14, 18], [14, 29], [14, 33], [14, 44], [14, 56], [14, 59], [14, 67], [14, 68], [14, 79], [14, 115], [14, 116], [14, 122], [14, 125], [14, 126], [14, 129], [14, 134], [15, 29], [15, 43], [15, 45], [15, 46], [15, 52], [15, 63], [15, 69], [15, 74], [15, 86], [15, 87], [15, 91], [15, 97], [15, 98], [15, 102], [15, 104], [15, 111], [15, 115], [15, 124], [15, 138], [16, 17], [16, 18], [16, 20], [16, 24], [16, 28], [16, 30], [16, 33], [16, 46], [16, 47], [16, 53], [16, 82], [16, 83], [16, 85], [16, 86], [16, 87], [16, 94], [16, 112], [16, 117], [16, 123], [16, 124], [16, 127], [16, 135], [17, 27], [17, 28], [17, 29], [17, 31], [17, 33], [17, 39], [17, 45], [17, 50], [17, 53], [17, 54], [17, 59], [17, 61], [17, 63], [17, 75], [17, 82], [17, 91], [17, 92], [17, 110], [17, 112], [17, 115], [18, 60], [18, 73], [18, 81], [18, 99], [18, 103], [18, 113], [18, 130], [18, 131], [18, 137], [18, 138], [19, 20], [19, 30], [19, 39], [19, 60], [19, 62], [19, 64], [19, 69], [19, 70], [19, 72], [19, 73], [19, 77], [19, 80], [19, 86], [19, 87], [19, 96], [19, 97], [19, 114], [19, 119], [19, 121], [19, 127], [19, 139], [20, 25], [20, 38], [20, 39], [20, 40], [20, 41], [20, 45], [20, 47], [20, 58], [20, 61], [20, 66], [20, 72], [20, 74], [20, 76], [20, 82], [20, 85], [20, 89], [20, 95], [20, 99], [20, 122], [20, 132], [20, 133], [21, 25], [21, 28], [21, 46], [21, 49], [21, 62], [21, 75], [21, 86], [21, 89], [21, 92], [21, 100], [21, 117], [21, 123], [21, 124], [21, 134], [22, 30], [22, 79], [22, 80], [22, 88], [22, 90], [22, 95], [22, 112], [22, 114], [22, 121], [23, 27], [23, 29], [23, 33], [23, 41], [23, 43], [23, 45], [23, 46], [23, 48], [23, 57], [23, 65], [23, 70], [23, 75], [23, 80], [23, 87], [23, 90], [23, 98], [23, 104], [23, 106], [23, 107], [23, 113], [23, 115], [23, 121], [23, 130], [23, 134], [23, 139], [24, 25], [24, 35], [24, 41], [24, 45], [24, 57], [24, 60], [24, 63], [24, 67], [24, 69], [24, 70], [24, 79], [24, 83], [24, 97], [24, 102], [24, 110], [24, 111], [24, 122], [24, 129], [24, 138], [25, 33], [25, 37], [25, 47], [25, 51], [25, 56], [25, 61], [25, 73], [25, 76], [25, 93], [25, 95], [25, 103], [25, 106], [25, 107], [25, 112], [25, 123], [25, 127], [25, 128], [25, 138], [26, 29], [26, 32], [26, 52], [26, 57], [26, 91], [26, 92], [26, 98], [26, 103], [26, 114], [26, 116], [26, 121], [26, 122], [26, 128], [27, 30], [27, 37], [27, 38], [27, 48], [27, 57], [27, 81], [27, 82], [27, 113], [27, 117], [27, 118], [27, 125], [27, 135], [27, 137], [28, 31], [28, 34], [28, 36], [28, 37], [28, 48], [28, 53], [28, 61], [28, 65], [28, 67], [28, 69], [28, 75], [28, 84], [28, 99], [28, 101], [28, 104], [28, 138], [29, 32], [29, 38], [29, 56], [29, 59], [29, 74], [29, 84], [29, 85], [29, 90], [29, 93], [29, 94], [29, 97], [29, 98], [29, 108], [29, 109], [29, 118], [29, 121], [29, 132], [30, 32], [30, 34], [30, 42], [30, 45], [30, 61], [30, 65], [30, 80], [30, 82], [30, 86], [30, 90], [30, 94], [30, 101], [30, 106], [30, 111], [30, 112], [30, 114], [30, 129], [30, 130], [30, 133], [30, 134], [31, 33], [31, 42], [31, 45], [31, 57], [31, 63], [31, 65], [31, 67], [31, 71], [31, 77], [31, 81], [31, 85], [31, 89], [31, 94], [31, 107], [31, 110], [31, 129], [31, 130], [31, 133], [32, 33], [32, 35], [32, 59], [32, 65], [32, 74], [32, 85], [32, 97], [32, 105], [32, 112], [32, 120], [32, 131], [32, 133], [33, 44], [33, 45], [33, 57], [33, 65], [33, 107], [33, 119], [33, 121], [33, 122], [33, 125], [34, 43], [34, 48], [34, 51], [34, 54], [34, 59], [34, 61], [34, 63], [34, 67], [34, 73], [34, 82], [34, 94], [34, 97], [34, 99], [34, 102], [34, 109], [34, 115], [34, 118], [34, 119], [35, 43], [35, 48], [35, 51], [35, 52], [35, 76], [35, 103], [35, 115], [35, 116], [35, 119], [35, 121], [35, 136], [36, 51], [36, 59], [36, 73], [36, 75], [36, 84], [36, 85], [36, 87], [36, 98], [36, 106], [36, 111], [36, 113], [36, 119], [36, 122], [37, 46], [37, 65], [37, 76], [37, 80], [37, 90], [37, 95], [37, 103], [37, 119], [37, 124], [37, 137], [37, 138], [38, 39], [38, 50], [38, 63], [38, 67], [38, 69], [38, 85], [38, 95], [38, 100], [38, 105], [38, 122], [38, 125], [38, 128], [39, 52], [39, 56], [39, 61], [39, 66], [39, 69], [39, 73], [39, 74], [39, 83], [39, 100], [39, 102], [39, 106], [39, 107], [39, 109], [39, 122], [39, 138], [40, 51], [40, 75], [40, 76], [40, 81], [40, 91], [40, 95], [40, 112], [40, 124], [40, 127], [40, 139], [41, 49], [41, 53], [41, 55], [41, 57], [41, 62], [41, 68], [41, 98], [41, 102], [41, 107], [41, 109], [41, 110], [41, 125], [41, 135], [42, 46], [42, 48], [42, 51], [42, 57], [42, 62], [42, 65], [42, 66], [42, 71], [42, 81], [42, 89], [42, 102], [42, 118], [42, 119], [42, 121], [42, 122], [42, 130], [42, 133], [42, 135], [43, 45], [43, 49], [43, 61], [43, 62], [43, 66], [43, 81], [43, 87], [43, 105], [43, 114], [43, 115], [43, 133], [43, 134], [44, 48], [44, 50], [44, 52], [44, 53], [44, 57], [44, 63], [44, 67], [44, 70], [44, 71], [44, 85], [44, 86], [44, 93], [44, 95], [44, 97], [44, 115], [44, 124], [44, 126], [44, 139], [45, 47], [45, 56], [45, 60], [45, 65], [45, 70], [45, 81], [45, 99], [45, 101], [45, 105], [45, 122], [45, 127], [45, 128], [45, 130], [45, 133], [45, 138], [45, 139], [46, 55], [46, 59], [46, 65], [46, 68], [46, 70], [46, 78], [46, 86], [46, 90], [46, 92], [46, 96], [46, 114], [46, 115], [46, 124], [46, 128], [46, 134], [46, 139], [47, 51], [47, 52], [47, 54], [47, 83], [47, 94], [47, 114], [47, 115], [47, 123], [47, 126], [47, 134], [47, 136], [47, 137], [47, 139], [48, 49], [48, 50], [48, 51], [48, 55], [48, 66], [48, 67], [48, 71], [48, 72], [48, 73], [48, 80], [48, 84], [48, 88], [48, 91], [48, 92], [48, 94], [48, 95], [48, 99], [48, 121], [48, 129], [48, 130], [48, 135], [49, 65], [49, 80], [49, 81], [49, 86], [49, 89], [49, 101], [49, 103], [49, 104], [49, 105], [49, 115], [49, 116], [49, 121], [49, 124], [49, 131], [49, 134], [50, 52], [50, 55], [50, 56], [50, 67], [50, 75], [50, 76], [50, 81], [50, 82], [50, 86], [50, 93], [50, 99], [50, 101], [50, 105], [50, 106], [50, 114], [50, 119], [50, 133], [50, 135], [50, 138], [51, 58], [51, 73], [51, 76], [51, 79], [51, 80], [51, 86], [51, 87], [51, 101], [51, 104], [51, 110], [51, 112], [51, 126], [52, 59], [52, 69], [52, 80], [52, 81], [52, 100], [52, 120], [52, 127], [52, 128], [52, 136], [53, 63], [53, 65], [53, 73], [53, 75], [53, 85], [53, 90], [53, 91], [53, 92], [53, 102], [53, 109], [53, 110], [53, 116], [53, 119], [53, 125], [53, 132], [53, 136], [53, 137], [53, 138], [54, 60], [54, 69], [54, 108], [54, 109], [54, 123], [54, 126], [55, 75], [55, 86], [55, 96], [55, 98], [55, 100], [55, 101], [55, 119], [55, 120], [55, 123], [55, 131], [55, 134], [55, 137], [56, 60], [56, 71], [56, 88], [56, 91], [56, 104], [56, 116], [56, 121], [56, 136], [57, 64], [57, 68], [57, 71], [57, 72], [57, 85], [57, 87], [57, 102], [57, 117], [57, 131], [57, 134], [58, 68], [58, 78], [58, 81], [58, 84], [58, 90], [58, 102], [58, 105], [58, 119], [58, 121], [58, 125], [59, 60], [59, 64], [59, 69], [59, 78], [59, 86], [59, 87], [59, 94], [59, 119], [59, 124], [59, 128], [59, 130], [59, 131], [59, 137], [59, 138], [60, 65], [60, 78], [60, 80], [60, 86], [60, 89], [60, 91], [60, 94], [60, 95], [60, 104], [60, 108], [60, 122], [60, 123], [60, 127], [60, 137], [61, 71], [61, 77], [61, 79], [61, 83], [61, 88], [61, 94], [61, 107], [61, 111], [61, 113], [61, 125], [61, 134], [61, 137], [62, 63], [62, 69], [62, 71], [62, 77], [62, 84], [62, 86], [62, 94], [62, 95], [62, 98], [62, 116], [62, 118], [62, 124], [62, 126], [62, 128], [62, 135], [63, 67], [63, 85], [63, 91], [63, 96], [63, 101], [63, 116], [63, 119], [63, 124], [63, 129], [63, 131], [64, 69], [64, 71], [64, 73], [64, 83], [64, 88], [64, 93], [64, 101], [64, 108], [64, 109], [64, 110], [64, 122], [64, 123], [64, 134], [64, 136], [65, 67], [65, 79], [65, 83], [65, 108], [65, 109], [65, 117], [65, 121], [65, 136], [66, 67], [66, 86], [66, 93], [66, 106], [66, 110], [66, 111], [66, 126], [66, 133], [67, 76], [67, 81], [67, 83], [67, 86], [67, 96], [67, 105], [67, 113], [67, 115], [67, 120], [67, 131], [67, 139], [68, 74], [68, 79], [68, 80], [68, 82], [68, 88], [68, 92], [68, 101], [68, 107], [68, 109], [68, 110], [68, 114], [68, 115], [68, 123], [68, 125], [68, 130], [69, 70], [69, 75], [69, 87], [69, 90], [69, 91], [69, 107], [69, 109], [69, 110], [69, 114], [69, 117], [69, 125], [69, 133], [69, 135], [70, 79], [70, 86], [70, 112], [70, 114], [70, 117], [70, 120], [70, 126], [70, 129], [70, 130], [70, 137], [70, 138], [71, 78], [71, 90], [71, 91], [71, 98], [71, 101], [71, 109], [71, 117], [71, 119], [72, 83], [72, 86], [72, 91], [72, 98], [72, 105], [72, 110], [72, 111], [72, 119], [72, 122], [72, 123], [72, 128], [72, 139], [73, 84], [73, 92], [73, 93], [73, 95], [73, 109], [73, 116], [73, 121], [73, 130], [73, 133], [73, 139], [74, 79], [74, 83], [74, 91], [74, 101], [74, 128], [74, 137], [74, 138], [75, 83], [75, 84], [75, 86], [75, 91], [75, 93], [75, 94], [75, 95], [75, 103], [75, 108], [75, 115], [75, 123], [75, 124], [75, 129], [75, 134], [75, 137], [76, 101], [76, 112], [76, 121], [76, 130], [76, 136], [77, 84], [77, 85], [77, 114], [77, 119], [77, 122], [77, 128], [77, 133], [78, 80], [78, 100], [78, 101], [78, 102], [78, 104], [78, 105], [78, 112], [78, 114], [78, 117], [78, 126], [78, 128], [78, 131], [78, 132], [79, 89], [79, 98], [79, 126], [79, 135], [79, 136], [80, 88], [80, 100], [80, 102], [80, 104], [80, 112], [80, 118], [80, 124], [80, 133], [81, 98], [81, 100], [81, 106], [81, 118], [81, 125], [81, 131], [81, 132], [81, 133], [82, 87], [82, 96], [82, 100], [82, 101], [82, 104], [82, 110], [82, 116], [82, 125], [83, 95], [83, 104], [83, 116], [83, 128], [83, 133], [84, 90], [84, 121], [84, 127], [84, 137], [84, 139], [85, 86], [85, 94], [85, 114], [85, 124], [85, 134], [86, 107], [86, 108], [86, 112], [86, 117], [86, 128], [86, 129], [86, 131], [87, 91], [87, 93], [87, 96], [87, 100], [87, 103], [87, 104], [87, 105], [87, 108], [87, 114], [87, 117], [87, 118], [87, 124], [87, 132], [87, 133], [88, 102], [88, 111], [88, 115], [88, 130], [89, 91], [89, 100], [89, 107], [89, 123], [89, 128], [89, 134], [90, 100], [90, 128], [90, 132], [90, 136], [91, 98], [91, 103], [91, 105], [91, 116], [91, 127], [91, 131], [91, 132], [91, 133], [91, 134], [91, 139], [92, 96], [92, 103], [92, 110], [92, 111], [92, 118], [92, 127], [92, 130], [92, 135], [93, 94], [93, 99], [93, 104], [93, 105], [93, 114], [93, 120], [93, 128], [93, 130], [93, 134], [93, 139], [94, 96], [94, 101], [94, 110], [94, 116], [94, 136], [94, 138], [95, 98], [95, 104], [95, 105], [95, 109], [95, 113], [95, 114], [95, 122], [95, 133], [95, 137], [95, 139], [96, 103], [96, 114], [96, 117], [96, 128], [96, 129], [96, 134], [97, 99], [97, 105], [97, 112], [97, 114], [97, 125], [97, 139], [98, 109], [98, 111], [98, 130], [98, 132], [98, 134], [98, 135], [99, 113], [99, 122], [99, 126], [100, 107], [100, 110], [100, 120], [100, 121], [100, 129], [100, 130], [100, 136], [101, 104], [101, 113], [101, 134], [101, 137], [102, 105], [102, 113], [102, 115], [102, 116], [102, 121], [102, 125], [103, 122], [103, 135], [103, 137], [103, 138], [104, 107], [104, 109], [104, 113], [104, 114], [104, 117], [104, 124], [104, 127], [104, 133], [104, 134], [105, 106], [105, 108], [105, 114], [105, 134], [106, 114], [106, 122], [106, 126], [106, 130], [106, 136], [107, 114], [107, 117], [107, 119], [107, 122], [107, 126], [107, 127], [107, 138], [108, 123], [108, 125], [108, 138], [109, 120], [110, 114], [110, 121], [110, 130], [110, 132], [111, 122], [111, 129], [111, 130], [112, 126], [112, 132], [112, 139], [113, 124], [114, 116], [114, 135], [115, 123], [115, 130], [115, 133], [115, 138], [116, 120], [116, 127], [116, 129], [116, 131], [116, 134], [116, 136], [117, 118], [117, 123], [117, 126], [117, 127], [117, 128], [117, 129], [117, 135], [117, 138], [118, 127], [119, 130], [119, 133], [120, 121], [120, 138], [121, 129], [121, 134], [122, 130], [122, 138], [123, 139], [124, 126], [124, 130], [124, 131], [124, 133], [124, 136], [125, 129], [125, 133], [125, 139], [128, 130], [130, 134], [130, 137], [131, 134], [131, 135], [134, 139], [136, 137]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l6-s5/solution/solve.sh b/tasks/construct-mc-vertex-cover-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bee83aa43e6925325378d01b1201cad046e063a4 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [2, 3, 4, 5, 6, 7, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 27, 28, 29, 30, 31, 32, 34, 36, 38, 39, 41, 42, 43, 44, 45, 46, 48, 49, 50, 51, 52, 53, 54, 57, 60, 62, 63, 64, 65, 66, 68, 69, 70, 71, 73, 75, 76, 77, 78, 79, 80, 81, 83, 84, 86, 87, 88, 90, 91, 92, 94, 95, 96, 98, 99, 100, 101, 102, 103, 104, 105, 107, 110, 111, 112, 113, 114, 115, 116, 117, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 130, 131, 134, 136, 137, 138, 139]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l6-s5/tests/check.py b/tasks/construct-mc-vertex-cover-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l6-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-l6-s5/tests/instance.json b/tasks/construct-mc-vertex-cover-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e39f82b7f8a6cc001f6bcdb37ac3ea6005cf5ee2 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 140, "k": 107, "edges": [[0, 2], [0, 12], [0, 15], [0, 20], [0, 24], [0, 46], [0, 50], [0, 51], [0, 52], [0, 53], [0, 62], [0, 70], [0, 95], [0, 102], [0, 117], [0, 121], [0, 127], [0, 134], [1, 3], [1, 11], [1, 16], [1, 52], [1, 53], [1, 60], [1, 64], [1, 69], [1, 79], [1, 81], [1, 90], [1, 91], [1, 98], [1, 100], [1, 102], [1, 103], [1, 105], [1, 110], [2, 21], [2, 33], [2, 39], [2, 44], [2, 50], [2, 53], [2, 61], [2, 71], [2, 92], [2, 98], [2, 120], [2, 132], [2, 139], [3, 5], [3, 9], [3, 12], [3, 25], [3, 30], [3, 35], [3, 38], [3, 55], [3, 56], [3, 62], [3, 76], [3, 77], [3, 79], [3, 90], [3, 102], [3, 114], [3, 121], [3, 127], [3, 132], [3, 137], [4, 45], [4, 52], [4, 75], [4, 81], [4, 90], [4, 97], [4, 107], [4, 125], [4, 129], [4, 135], [5, 22], [5, 27], [5, 31], [5, 46], [5, 60], [5, 63], [5, 66], [5, 70], [5, 83], [5, 97], [5, 98], [5, 106], [5, 112], [5, 117], [5, 131], [5, 135], [6, 15], [6, 28], [6, 30], [6, 43], [6, 47], [6, 54], [6, 55], [6, 62], [6, 64], [6, 72], [6, 85], [6, 88], [6, 96], [6, 110], [6, 112], [6, 113], [6, 137], [6, 138], [7, 25], [7, 39], [7, 51], [7, 63], [7, 65], [7, 74], [7, 77], [7, 80], [7, 89], [7, 90], [7, 91], [7, 93], [7, 96], [7, 100], [7, 101], [7, 102], [7, 109], [7, 116], [7, 117], [7, 128], [8, 13], [8, 15], [8, 16], [8, 28], [8, 29], [8, 32], [8, 62], [8, 71], [8, 95], [8, 96], [8, 102], [8, 104], [8, 124], [9, 16], [9, 20], [9, 27], [9, 30], [9, 32], [9, 51], [9, 65], [9, 68], [9, 73], [9, 80], [9, 92], [9, 94], [9, 100], [9, 102], [9, 103], [9, 104], [9, 126], [9, 134], [10, 16], [10, 36], [10, 38], [10, 52], [10, 53], [10, 69], [10, 70], [10, 81], [10, 88], [10, 101], [10, 111], [10, 113], [10, 120], [10, 128], [10, 131], [11, 25], [11, 51], [11, 57], [11, 61], [11, 66], [11, 69], [11, 76], [11, 88], [11, 93], [11, 98], [11, 99], [11, 100], [11, 102], [11, 116], [11, 121], [11, 122], [11, 125], [11, 129], [11, 131], [12, 18], [12, 49], [12, 51], [12, 55], [12, 56], [12, 83], [12, 85], [12, 88], [12, 91], [12, 100], [12, 104], [12, 105], [12, 107], [12, 113], [12, 116], [12, 119], [12, 134], [12, 138], [13, 22], [13, 25], [13, 33], [13, 47], [13, 57], [13, 62], [13, 68], [13, 86], [13, 92], [13, 99], [13, 112], [13, 113], [13, 115], [13, 122], [13, 131], [13, 132], [14, 18], [14, 29], [14, 33], [14, 44], [14, 56], [14, 59], [14, 67], [14, 68], [14, 79], [14, 115], [14, 116], [14, 122], [14, 125], [14, 126], [14, 129], [14, 134], [15, 29], [15, 43], [15, 45], [15, 46], [15, 52], [15, 63], [15, 69], [15, 74], [15, 86], [15, 87], [15, 91], [15, 97], [15, 98], [15, 102], [15, 104], [15, 111], [15, 115], [15, 124], [15, 138], [16, 17], [16, 18], [16, 20], [16, 24], [16, 28], [16, 30], [16, 33], [16, 46], [16, 47], [16, 53], [16, 82], [16, 83], [16, 85], [16, 86], [16, 87], [16, 94], [16, 112], [16, 117], [16, 123], [16, 124], [16, 127], [16, 135], [17, 27], [17, 28], [17, 29], [17, 31], [17, 33], [17, 39], [17, 45], [17, 50], [17, 53], [17, 54], [17, 59], [17, 61], [17, 63], [17, 75], [17, 82], [17, 91], [17, 92], [17, 110], [17, 112], [17, 115], [18, 60], [18, 73], [18, 81], [18, 99], [18, 103], [18, 113], [18, 130], [18, 131], [18, 137], [18, 138], [19, 20], [19, 30], [19, 39], [19, 60], [19, 62], [19, 64], [19, 69], [19, 70], [19, 72], [19, 73], [19, 77], [19, 80], [19, 86], [19, 87], [19, 96], [19, 97], [19, 114], [19, 119], [19, 121], [19, 127], [19, 139], [20, 25], [20, 38], [20, 39], [20, 40], [20, 41], [20, 45], [20, 47], [20, 58], [20, 61], [20, 66], [20, 72], [20, 74], [20, 76], [20, 82], [20, 85], [20, 89], [20, 95], [20, 99], [20, 122], [20, 132], [20, 133], [21, 25], [21, 28], [21, 46], [21, 49], [21, 62], [21, 75], [21, 86], [21, 89], [21, 92], [21, 100], [21, 117], [21, 123], [21, 124], [21, 134], [22, 30], [22, 79], [22, 80], [22, 88], [22, 90], [22, 95], [22, 112], [22, 114], [22, 121], [23, 27], [23, 29], [23, 33], [23, 41], [23, 43], [23, 45], [23, 46], [23, 48], [23, 57], [23, 65], [23, 70], [23, 75], [23, 80], [23, 87], [23, 90], [23, 98], [23, 104], [23, 106], [23, 107], [23, 113], [23, 115], [23, 121], [23, 130], [23, 134], [23, 139], [24, 25], [24, 35], [24, 41], [24, 45], [24, 57], [24, 60], [24, 63], [24, 67], [24, 69], [24, 70], [24, 79], [24, 83], [24, 97], [24, 102], [24, 110], [24, 111], [24, 122], [24, 129], [24, 138], [25, 33], [25, 37], [25, 47], [25, 51], [25, 56], [25, 61], [25, 73], [25, 76], [25, 93], [25, 95], [25, 103], [25, 106], [25, 107], [25, 112], [25, 123], [25, 127], [25, 128], [25, 138], [26, 29], [26, 32], [26, 52], [26, 57], [26, 91], [26, 92], [26, 98], [26, 103], [26, 114], [26, 116], [26, 121], [26, 122], [26, 128], [27, 30], [27, 37], [27, 38], [27, 48], [27, 57], [27, 81], [27, 82], [27, 113], [27, 117], [27, 118], [27, 125], [27, 135], [27, 137], [28, 31], [28, 34], [28, 36], [28, 37], [28, 48], [28, 53], [28, 61], [28, 65], [28, 67], [28, 69], [28, 75], [28, 84], [28, 99], [28, 101], [28, 104], [28, 138], [29, 32], [29, 38], [29, 56], [29, 59], [29, 74], [29, 84], [29, 85], [29, 90], [29, 93], [29, 94], [29, 97], [29, 98], [29, 108], [29, 109], [29, 118], [29, 121], [29, 132], [30, 32], [30, 34], [30, 42], [30, 45], [30, 61], [30, 65], [30, 80], [30, 82], [30, 86], [30, 90], [30, 94], [30, 101], [30, 106], [30, 111], [30, 112], [30, 114], [30, 129], [30, 130], [30, 133], [30, 134], [31, 33], [31, 42], [31, 45], [31, 57], [31, 63], [31, 65], [31, 67], [31, 71], [31, 77], [31, 81], [31, 85], [31, 89], [31, 94], [31, 107], [31, 110], [31, 129], [31, 130], [31, 133], [32, 33], [32, 35], [32, 59], [32, 65], [32, 74], [32, 85], [32, 97], [32, 105], [32, 112], [32, 120], [32, 131], [32, 133], [33, 44], [33, 45], [33, 57], [33, 65], [33, 107], [33, 119], [33, 121], [33, 122], [33, 125], [34, 43], [34, 48], [34, 51], [34, 54], [34, 59], [34, 61], [34, 63], [34, 67], [34, 73], [34, 82], [34, 94], [34, 97], [34, 99], [34, 102], [34, 109], [34, 115], [34, 118], [34, 119], [35, 43], [35, 48], [35, 51], [35, 52], [35, 76], [35, 103], [35, 115], [35, 116], [35, 119], [35, 121], [35, 136], [36, 51], [36, 59], [36, 73], [36, 75], [36, 84], [36, 85], [36, 87], [36, 98], [36, 106], [36, 111], [36, 113], [36, 119], [36, 122], [37, 46], [37, 65], [37, 76], [37, 80], [37, 90], [37, 95], [37, 103], [37, 119], [37, 124], [37, 137], [37, 138], [38, 39], [38, 50], [38, 63], [38, 67], [38, 69], [38, 85], [38, 95], [38, 100], [38, 105], [38, 122], [38, 125], [38, 128], [39, 52], [39, 56], [39, 61], [39, 66], [39, 69], [39, 73], [39, 74], [39, 83], [39, 100], [39, 102], [39, 106], [39, 107], [39, 109], [39, 122], [39, 138], [40, 51], [40, 75], [40, 76], [40, 81], [40, 91], [40, 95], [40, 112], [40, 124], [40, 127], [40, 139], [41, 49], [41, 53], [41, 55], [41, 57], [41, 62], [41, 68], [41, 98], [41, 102], [41, 107], [41, 109], [41, 110], [41, 125], [41, 135], [42, 46], [42, 48], [42, 51], [42, 57], [42, 62], [42, 65], [42, 66], [42, 71], [42, 81], [42, 89], [42, 102], [42, 118], [42, 119], [42, 121], [42, 122], [42, 130], [42, 133], [42, 135], [43, 45], [43, 49], [43, 61], [43, 62], [43, 66], [43, 81], [43, 87], [43, 105], [43, 114], [43, 115], [43, 133], [43, 134], [44, 48], [44, 50], [44, 52], [44, 53], [44, 57], [44, 63], [44, 67], [44, 70], [44, 71], [44, 85], [44, 86], [44, 93], [44, 95], [44, 97], [44, 115], [44, 124], [44, 126], [44, 139], [45, 47], [45, 56], [45, 60], [45, 65], [45, 70], [45, 81], [45, 99], [45, 101], [45, 105], [45, 122], [45, 127], [45, 128], [45, 130], [45, 133], [45, 138], [45, 139], [46, 55], [46, 59], [46, 65], [46, 68], [46, 70], [46, 78], [46, 86], [46, 90], [46, 92], [46, 96], [46, 114], [46, 115], [46, 124], [46, 128], [46, 134], [46, 139], [47, 51], [47, 52], [47, 54], [47, 83], [47, 94], [47, 114], [47, 115], [47, 123], [47, 126], [47, 134], [47, 136], [47, 137], [47, 139], [48, 49], [48, 50], [48, 51], [48, 55], [48, 66], [48, 67], [48, 71], [48, 72], [48, 73], [48, 80], [48, 84], [48, 88], [48, 91], [48, 92], [48, 94], [48, 95], [48, 99], [48, 121], [48, 129], [48, 130], [48, 135], [49, 65], [49, 80], [49, 81], [49, 86], [49, 89], [49, 101], [49, 103], [49, 104], [49, 105], [49, 115], [49, 116], [49, 121], [49, 124], [49, 131], [49, 134], [50, 52], [50, 55], [50, 56], [50, 67], [50, 75], [50, 76], [50, 81], [50, 82], [50, 86], [50, 93], [50, 99], [50, 101], [50, 105], [50, 106], [50, 114], [50, 119], [50, 133], [50, 135], [50, 138], [51, 58], [51, 73], [51, 76], [51, 79], [51, 80], [51, 86], [51, 87], [51, 101], [51, 104], [51, 110], [51, 112], [51, 126], [52, 59], [52, 69], [52, 80], [52, 81], [52, 100], [52, 120], [52, 127], [52, 128], [52, 136], [53, 63], [53, 65], [53, 73], [53, 75], [53, 85], [53, 90], [53, 91], [53, 92], [53, 102], [53, 109], [53, 110], [53, 116], [53, 119], [53, 125], [53, 132], [53, 136], [53, 137], [53, 138], [54, 60], [54, 69], [54, 108], [54, 109], [54, 123], [54, 126], [55, 75], [55, 86], [55, 96], [55, 98], [55, 100], [55, 101], [55, 119], [55, 120], [55, 123], [55, 131], [55, 134], [55, 137], [56, 60], [56, 71], [56, 88], [56, 91], [56, 104], [56, 116], [56, 121], [56, 136], [57, 64], [57, 68], [57, 71], [57, 72], [57, 85], [57, 87], [57, 102], [57, 117], [57, 131], [57, 134], [58, 68], [58, 78], [58, 81], [58, 84], [58, 90], [58, 102], [58, 105], [58, 119], [58, 121], [58, 125], [59, 60], [59, 64], [59, 69], [59, 78], [59, 86], [59, 87], [59, 94], [59, 119], [59, 124], [59, 128], [59, 130], [59, 131], [59, 137], [59, 138], [60, 65], [60, 78], [60, 80], [60, 86], [60, 89], [60, 91], [60, 94], [60, 95], [60, 104], [60, 108], [60, 122], [60, 123], [60, 127], [60, 137], [61, 71], [61, 77], [61, 79], [61, 83], [61, 88], [61, 94], [61, 107], [61, 111], [61, 113], [61, 125], [61, 134], [61, 137], [62, 63], [62, 69], [62, 71], [62, 77], [62, 84], [62, 86], [62, 94], [62, 95], [62, 98], [62, 116], [62, 118], [62, 124], [62, 126], [62, 128], [62, 135], [63, 67], [63, 85], [63, 91], [63, 96], [63, 101], [63, 116], [63, 119], [63, 124], [63, 129], [63, 131], [64, 69], [64, 71], [64, 73], [64, 83], [64, 88], [64, 93], [64, 101], [64, 108], [64, 109], [64, 110], [64, 122], [64, 123], [64, 134], [64, 136], [65, 67], [65, 79], [65, 83], [65, 108], [65, 109], [65, 117], [65, 121], [65, 136], [66, 67], [66, 86], [66, 93], [66, 106], [66, 110], [66, 111], [66, 126], [66, 133], [67, 76], [67, 81], [67, 83], [67, 86], [67, 96], [67, 105], [67, 113], [67, 115], [67, 120], [67, 131], [67, 139], [68, 74], [68, 79], [68, 80], [68, 82], [68, 88], [68, 92], [68, 101], [68, 107], [68, 109], [68, 110], [68, 114], [68, 115], [68, 123], [68, 125], [68, 130], [69, 70], [69, 75], [69, 87], [69, 90], [69, 91], [69, 107], [69, 109], [69, 110], [69, 114], [69, 117], [69, 125], [69, 133], [69, 135], [70, 79], [70, 86], [70, 112], [70, 114], [70, 117], [70, 120], [70, 126], [70, 129], [70, 130], [70, 137], [70, 138], [71, 78], [71, 90], [71, 91], [71, 98], [71, 101], [71, 109], [71, 117], [71, 119], [72, 83], [72, 86], [72, 91], [72, 98], [72, 105], [72, 110], [72, 111], [72, 119], [72, 122], [72, 123], [72, 128], [72, 139], [73, 84], [73, 92], [73, 93], [73, 95], [73, 109], [73, 116], [73, 121], [73, 130], [73, 133], [73, 139], [74, 79], [74, 83], [74, 91], [74, 101], [74, 128], [74, 137], [74, 138], [75, 83], [75, 84], [75, 86], [75, 91], [75, 93], [75, 94], [75, 95], [75, 103], [75, 108], [75, 115], [75, 123], [75, 124], [75, 129], [75, 134], [75, 137], [76, 101], [76, 112], [76, 121], [76, 130], [76, 136], [77, 84], [77, 85], [77, 114], [77, 119], [77, 122], [77, 128], [77, 133], [78, 80], [78, 100], [78, 101], [78, 102], [78, 104], [78, 105], [78, 112], [78, 114], [78, 117], [78, 126], [78, 128], [78, 131], [78, 132], [79, 89], [79, 98], [79, 126], [79, 135], [79, 136], [80, 88], [80, 100], [80, 102], [80, 104], [80, 112], [80, 118], [80, 124], [80, 133], [81, 98], [81, 100], [81, 106], [81, 118], [81, 125], [81, 131], [81, 132], [81, 133], [82, 87], [82, 96], [82, 100], [82, 101], [82, 104], [82, 110], [82, 116], [82, 125], [83, 95], [83, 104], [83, 116], [83, 128], [83, 133], [84, 90], [84, 121], [84, 127], [84, 137], [84, 139], [85, 86], [85, 94], [85, 114], [85, 124], [85, 134], [86, 107], [86, 108], [86, 112], [86, 117], [86, 128], [86, 129], [86, 131], [87, 91], [87, 93], [87, 96], [87, 100], [87, 103], [87, 104], [87, 105], [87, 108], [87, 114], [87, 117], [87, 118], [87, 124], [87, 132], [87, 133], [88, 102], [88, 111], [88, 115], [88, 130], [89, 91], [89, 100], [89, 107], [89, 123], [89, 128], [89, 134], [90, 100], [90, 128], [90, 132], [90, 136], [91, 98], [91, 103], [91, 105], [91, 116], [91, 127], [91, 131], [91, 132], [91, 133], [91, 134], [91, 139], [92, 96], [92, 103], [92, 110], [92, 111], [92, 118], [92, 127], [92, 130], [92, 135], [93, 94], [93, 99], [93, 104], [93, 105], [93, 114], [93, 120], [93, 128], [93, 130], [93, 134], [93, 139], [94, 96], [94, 101], [94, 110], [94, 116], [94, 136], [94, 138], [95, 98], [95, 104], [95, 105], [95, 109], [95, 113], [95, 114], [95, 122], [95, 133], [95, 137], [95, 139], [96, 103], [96, 114], [96, 117], [96, 128], [96, 129], [96, 134], [97, 99], [97, 105], [97, 112], [97, 114], [97, 125], [97, 139], [98, 109], [98, 111], [98, 130], [98, 132], [98, 134], [98, 135], [99, 113], [99, 122], [99, 126], [100, 107], [100, 110], [100, 120], [100, 121], [100, 129], [100, 130], [100, 136], [101, 104], [101, 113], [101, 134], [101, 137], [102, 105], [102, 113], [102, 115], [102, 116], [102, 121], [102, 125], [103, 122], [103, 135], [103, 137], [103, 138], [104, 107], [104, 109], [104, 113], [104, 114], [104, 117], [104, 124], [104, 127], [104, 133], [104, 134], [105, 106], [105, 108], [105, 114], [105, 134], [106, 114], [106, 122], [106, 126], [106, 130], [106, 136], [107, 114], [107, 117], [107, 119], [107, 122], [107, 126], [107, 127], [107, 138], [108, 123], [108, 125], [108, 138], [109, 120], [110, 114], [110, 121], [110, 130], [110, 132], [111, 122], [111, 129], [111, 130], [112, 126], [112, 132], [112, 139], [113, 124], [114, 116], [114, 135], [115, 123], [115, 130], [115, 133], [115, 138], [116, 120], [116, 127], [116, 129], [116, 131], [116, 134], [116, 136], [117, 118], [117, 123], [117, 126], [117, 127], [117, 128], [117, 129], [117, 135], [117, 138], [118, 127], [119, 130], [119, 133], [120, 121], [120, 138], [121, 129], [121, 134], [122, 130], [122, 138], [123, 139], [124, 126], [124, 130], [124, 131], [124, 133], [124, 136], [125, 129], [125, 133], [125, 139], [128, 130], [130, 134], [130, 137], [131, 134], [131, 135], [134, 139], [136, 137]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l6-s5/tests/run.py b/tasks/construct-mc-vertex-cover-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l6-s5/tests/test.sh b/tasks/construct-mc-vertex-cover-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-nppc-3col-l6-s2/environment/Dockerfile b/tasks/construct-nppc-3col-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l6-s2/environment/instance.json b/tasks/construct-nppc-3col-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c9d7da0148c1de8720dae75ab1846520099c1aa5 --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 120, "edges": [[0, 9], [0, 46], [0, 61], [0, 63], [0, 97], [1, 33], [1, 36], [1, 57], [1, 79], [1, 102], [1, 105], [2, 16], [2, 26], [2, 28], [2, 35], [2, 40], [2, 43], [2, 48], [2, 56], [2, 65], [2, 83], [2, 89], [3, 10], [3, 17], [3, 32], [3, 35], [3, 40], [3, 56], [3, 59], [3, 70], [3, 85], [3, 99], [3, 100], [4, 24], [4, 47], [4, 50], [4, 59], [4, 66], [4, 81], [4, 84], [4, 85], [4, 106], [4, 110], [5, 25], [5, 29], [5, 31], [5, 35], [5, 47], [5, 48], [5, 52], [5, 55], [5, 63], [5, 71], [5, 81], [5, 86], [5, 97], [5, 99], [6, 26], [6, 31], [6, 34], [6, 45], [6, 64], [6, 76], [6, 95], [6, 107], [7, 14], [7, 73], [7, 107], [7, 112], [8, 23], [8, 35], [8, 87], [8, 112], [9, 16], [9, 27], [9, 28], [9, 37], [9, 38], [9, 67], [9, 77], [9, 80], [9, 82], [9, 103], [9, 117], [10, 69], [10, 118], [11, 12], [11, 36], [11, 45], [11, 63], [11, 79], [11, 83], [11, 88], [11, 99], [12, 34], [12, 55], [12, 60], [12, 64], [12, 118], [13, 30], [13, 54], [13, 64], [13, 84], [13, 102], [14, 87], [14, 90], [14, 97], [14, 116], [14, 119], [15, 55], [15, 82], [15, 92], [15, 97], [16, 34], [16, 67], [16, 74], [16, 97], [16, 105], [16, 110], [17, 28], [17, 40], [17, 73], [17, 83], [17, 91], [17, 115], [17, 116], [18, 21], [18, 28], [18, 29], [18, 55], [18, 65], [18, 69], [18, 75], [18, 77], [18, 92], [18, 105], [18, 108], [19, 41], [19, 53], [19, 74], [19, 76], [19, 85], [19, 91], [19, 108], [20, 67], [20, 73], [20, 103], [21, 34], [21, 35], [21, 78], [21, 79], [21, 82], [21, 89], [21, 98], [22, 28], [22, 39], [22, 45], [22, 118], [23, 35], [23, 49], [23, 52], [23, 55], [23, 60], [23, 70], [23, 104], [24, 28], [24, 40], [24, 43], [24, 46], [24, 48], [24, 71], [24, 73], [24, 75], [24, 76], [24, 86], [24, 116], [25, 36], [25, 60], [25, 62], [25, 83], [25, 87], [25, 90], [25, 101], [25, 107], [25, 115], [25, 119], [26, 33], [26, 79], [26, 82], [26, 117], [27, 28], [27, 46], [27, 57], [27, 85], [27, 96], [27, 98], [27, 112], [28, 36], [28, 39], [28, 58], [28, 67], [28, 105], [28, 111], [28, 113], [28, 114], [29, 57], [29, 69], [29, 74], [29, 81], [29, 93], [29, 99], [29, 100], [29, 111], [29, 116], [30, 31], [30, 35], [30, 57], [30, 60], [30, 80], [30, 97], [30, 117], [30, 118], [31, 32], [31, 37], [31, 48], [31, 78], [31, 83], [31, 94], [31, 114], [32, 54], [32, 57], [32, 62], [32, 64], [32, 88], [32, 99], [32, 114], [32, 115], [33, 83], [33, 90], [33, 113], [33, 117], [34, 83], [34, 95], [35, 73], [35, 103], [35, 104], [35, 105], [35, 110], [36, 40], [36, 46], [36, 52], [36, 59], [36, 63], [36, 70], [36, 71], [36, 104], [37, 41], [37, 54], [37, 69], [37, 79], [37, 105], [37, 110], [37, 111], [38, 65], [38, 83], [38, 84], [38, 85], [38, 88], [38, 110], [38, 116], [39, 75], [39, 93], [39, 95], [39, 102], [39, 113], [39, 115], [39, 117], [40, 45], [40, 93], [40, 110], [40, 111], [41, 42], [41, 46], [41, 65], [41, 78], [41, 93], [41, 94], [41, 95], [41, 108], [41, 116], [42, 82], [42, 117], [43, 62], [43, 83], [43, 105], [43, 106], [43, 111], [44, 49], [44, 53], [44, 57], [44, 74], [44, 81], [44, 95], [44, 101], [44, 108], [44, 110], [45, 46], [45, 73], [45, 102], [45, 109], [46, 47], [46, 49], [46, 63], [46, 79], [46, 97], [46, 99], [46, 111], [47, 51], [47, 70], [47, 75], [47, 76], [47, 80], [47, 82], [47, 87], [47, 91], [47, 103], [47, 115], [48, 50], [48, 93], [49, 73], [50, 70], [50, 80], [50, 83], [50, 112], [51, 58], [51, 62], [51, 65], [51, 69], [51, 74], [51, 91], [51, 95], [51, 101], [51, 106], [51, 109], [51, 111], [51, 119], [52, 90], [52, 91], [52, 100], [52, 105], [52, 108], [52, 109], [52, 110], [53, 69], [53, 114], [53, 116], [54, 68], [54, 72], [54, 83], [54, 87], [54, 90], [54, 107], [54, 108], [54, 112], [55, 85], [55, 93], [55, 116], [56, 59], [56, 67], [56, 90], [56, 98], [56, 100], [56, 106], [57, 65], [57, 74], [57, 91], [57, 116], [58, 93], [58, 95], [58, 109], [58, 114], [58, 115], [58, 116], [59, 61], [59, 73], [59, 93], [60, 68], [60, 74], [60, 77], [60, 90], [60, 95], [60, 105], [61, 67], [61, 68], [62, 71], [62, 87], [62, 89], [62, 103], [62, 111], [62, 119], [63, 67], [63, 75], [63, 76], [63, 94], [63, 95], [63, 113], [64, 86], [64, 117], [65, 66], [65, 92], [65, 104], [66, 78], [66, 82], [66, 113], [67, 75], [67, 79], [67, 80], [68, 98], [69, 84], [69, 112], [70, 84], [70, 100], [71, 81], [71, 88], [71, 90], [72, 77], [72, 88], [72, 97], [72, 112], [73, 77], [74, 100], [75, 76], [75, 87], [75, 97], [75, 105], [75, 108], [76, 110], [77, 83], [77, 91], [77, 95], [77, 99], [77, 102], [77, 106], [77, 114], [78, 85], [78, 116], [79, 90], [80, 99], [80, 116], [81, 83], [81, 86], [81, 89], [81, 94], [82, 91], [82, 97], [82, 99], [82, 114], [83, 86], [83, 88], [84, 86], [84, 93], [84, 118], [85, 87], [85, 90], [85, 102], [85, 107], [86, 88], [87, 88], [87, 89], [88, 113], [88, 115], [88, 117], [89, 91], [89, 100], [89, 114], [89, 116], [92, 97], [92, 107], [92, 113], [94, 102], [96, 113], [96, 115], [97, 108], [97, 114], [97, 116], [97, 118], [97, 119], [98, 109], [98, 115], [99, 103], [99, 109], [99, 117], [100, 109], [100, 112], [100, 115], [104, 115], [105, 112], [105, 117], [112, 113], [112, 115]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l6-s2/solution/solve.sh b/tasks/construct-nppc-3col-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8326554403a4b8fb0d6919c3e2d2b7839a2cd274 --- /dev/null +++ b/tasks/construct-nppc-3col-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' +{"coloring": [2, 0, 1, 2, 0, 2, 0, 1, 1, 1, 1, 0, 2, 0, 0, 2, 0, 1, 1, 0, 0, 2, 2, 2, 1, 0, 2, 2, 0, 0, 2, 1, 0, 1, 1, 0, 2, 0, 0, 1, 0, 1, 2, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 2, 1, 2, 2, 2, 0, 0, 2, 2, 2, 0, 2, 0, 0, 1, 0, 1, 0, 2, 1, 1, 0, 2, 1, 0, 2, 2, 0, 2, 0, 2, 1, 1, 1, 1, 1, 2, 2, 2, 1, 2, 1, 2, 2, 2, 1, 2, 0, 2, 2, 2, 2, 0, 0, 2]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l6-s2/tests/check.py b/tasks/construct-nppc-3col-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l6-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-l6-s2/tests/instance.json b/tasks/construct-nppc-3col-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c9d7da0148c1de8720dae75ab1846520099c1aa5 --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 120, "edges": [[0, 9], [0, 46], [0, 61], [0, 63], [0, 97], [1, 33], [1, 36], [1, 57], [1, 79], [1, 102], [1, 105], [2, 16], [2, 26], [2, 28], [2, 35], [2, 40], [2, 43], [2, 48], [2, 56], [2, 65], [2, 83], [2, 89], [3, 10], [3, 17], [3, 32], [3, 35], [3, 40], [3, 56], [3, 59], [3, 70], [3, 85], [3, 99], [3, 100], [4, 24], [4, 47], [4, 50], [4, 59], [4, 66], [4, 81], [4, 84], [4, 85], [4, 106], [4, 110], [5, 25], [5, 29], [5, 31], [5, 35], [5, 47], [5, 48], [5, 52], [5, 55], [5, 63], [5, 71], [5, 81], [5, 86], [5, 97], [5, 99], [6, 26], [6, 31], [6, 34], [6, 45], [6, 64], [6, 76], [6, 95], [6, 107], [7, 14], [7, 73], [7, 107], [7, 112], [8, 23], [8, 35], [8, 87], [8, 112], [9, 16], [9, 27], [9, 28], [9, 37], [9, 38], [9, 67], [9, 77], [9, 80], [9, 82], [9, 103], [9, 117], [10, 69], [10, 118], [11, 12], [11, 36], [11, 45], [11, 63], [11, 79], [11, 83], [11, 88], [11, 99], [12, 34], [12, 55], [12, 60], [12, 64], [12, 118], [13, 30], [13, 54], [13, 64], [13, 84], [13, 102], [14, 87], [14, 90], [14, 97], [14, 116], [14, 119], [15, 55], [15, 82], [15, 92], [15, 97], [16, 34], [16, 67], [16, 74], [16, 97], [16, 105], [16, 110], [17, 28], [17, 40], [17, 73], [17, 83], [17, 91], [17, 115], [17, 116], [18, 21], [18, 28], [18, 29], [18, 55], [18, 65], [18, 69], [18, 75], [18, 77], [18, 92], [18, 105], [18, 108], [19, 41], [19, 53], [19, 74], [19, 76], [19, 85], [19, 91], [19, 108], [20, 67], [20, 73], [20, 103], [21, 34], [21, 35], [21, 78], [21, 79], [21, 82], [21, 89], [21, 98], [22, 28], [22, 39], [22, 45], [22, 118], [23, 35], [23, 49], [23, 52], [23, 55], [23, 60], [23, 70], [23, 104], [24, 28], [24, 40], [24, 43], [24, 46], [24, 48], [24, 71], [24, 73], [24, 75], [24, 76], [24, 86], [24, 116], [25, 36], [25, 60], [25, 62], [25, 83], [25, 87], [25, 90], [25, 101], [25, 107], [25, 115], [25, 119], [26, 33], [26, 79], [26, 82], [26, 117], [27, 28], [27, 46], [27, 57], [27, 85], [27, 96], [27, 98], [27, 112], [28, 36], [28, 39], [28, 58], [28, 67], [28, 105], [28, 111], [28, 113], [28, 114], [29, 57], [29, 69], [29, 74], [29, 81], [29, 93], [29, 99], [29, 100], [29, 111], [29, 116], [30, 31], [30, 35], [30, 57], [30, 60], [30, 80], [30, 97], [30, 117], [30, 118], [31, 32], [31, 37], [31, 48], [31, 78], [31, 83], [31, 94], [31, 114], [32, 54], [32, 57], [32, 62], [32, 64], [32, 88], [32, 99], [32, 114], [32, 115], [33, 83], [33, 90], [33, 113], [33, 117], [34, 83], [34, 95], [35, 73], [35, 103], [35, 104], [35, 105], [35, 110], [36, 40], [36, 46], [36, 52], [36, 59], [36, 63], [36, 70], [36, 71], [36, 104], [37, 41], [37, 54], [37, 69], [37, 79], [37, 105], [37, 110], [37, 111], [38, 65], [38, 83], [38, 84], [38, 85], [38, 88], [38, 110], [38, 116], [39, 75], [39, 93], [39, 95], [39, 102], [39, 113], [39, 115], [39, 117], [40, 45], [40, 93], [40, 110], [40, 111], [41, 42], [41, 46], [41, 65], [41, 78], [41, 93], [41, 94], [41, 95], [41, 108], [41, 116], [42, 82], [42, 117], [43, 62], [43, 83], [43, 105], [43, 106], [43, 111], [44, 49], [44, 53], [44, 57], [44, 74], [44, 81], [44, 95], [44, 101], [44, 108], [44, 110], [45, 46], [45, 73], [45, 102], [45, 109], [46, 47], [46, 49], [46, 63], [46, 79], [46, 97], [46, 99], [46, 111], [47, 51], [47, 70], [47, 75], [47, 76], [47, 80], [47, 82], [47, 87], [47, 91], [47, 103], [47, 115], [48, 50], [48, 93], [49, 73], [50, 70], [50, 80], [50, 83], [50, 112], [51, 58], [51, 62], [51, 65], [51, 69], [51, 74], [51, 91], [51, 95], [51, 101], [51, 106], [51, 109], [51, 111], [51, 119], [52, 90], [52, 91], [52, 100], [52, 105], [52, 108], [52, 109], [52, 110], [53, 69], [53, 114], [53, 116], [54, 68], [54, 72], [54, 83], [54, 87], [54, 90], [54, 107], [54, 108], [54, 112], [55, 85], [55, 93], [55, 116], [56, 59], [56, 67], [56, 90], [56, 98], [56, 100], [56, 106], [57, 65], [57, 74], [57, 91], [57, 116], [58, 93], [58, 95], [58, 109], [58, 114], [58, 115], [58, 116], [59, 61], [59, 73], [59, 93], [60, 68], [60, 74], [60, 77], [60, 90], [60, 95], [60, 105], [61, 67], [61, 68], [62, 71], [62, 87], [62, 89], [62, 103], [62, 111], [62, 119], [63, 67], [63, 75], [63, 76], [63, 94], [63, 95], [63, 113], [64, 86], [64, 117], [65, 66], [65, 92], [65, 104], [66, 78], [66, 82], [66, 113], [67, 75], [67, 79], [67, 80], [68, 98], [69, 84], [69, 112], [70, 84], [70, 100], [71, 81], [71, 88], [71, 90], [72, 77], [72, 88], [72, 97], [72, 112], [73, 77], [74, 100], [75, 76], [75, 87], [75, 97], [75, 105], [75, 108], [76, 110], [77, 83], [77, 91], [77, 95], [77, 99], [77, 102], [77, 106], [77, 114], [78, 85], [78, 116], [79, 90], [80, 99], [80, 116], [81, 83], [81, 86], [81, 89], [81, 94], [82, 91], [82, 97], [82, 99], [82, 114], [83, 86], [83, 88], [84, 86], [84, 93], [84, 118], [85, 87], [85, 90], [85, 102], [85, 107], [86, 88], [87, 88], [87, 89], [88, 113], [88, 115], [88, 117], [89, 91], [89, 100], [89, 114], [89, 116], [92, 97], [92, 107], [92, 113], [94, 102], [96, 113], [96, 115], [97, 108], [97, 114], [97, 116], [97, 118], [97, 119], [98, 109], [98, 115], [99, 103], [99, 109], [99, 117], [100, 109], [100, 112], [100, 115], [104, 115], [105, 112], [105, 117], [112, 113], [112, 115]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l6-s2/tests/run.py b/tasks/construct-nppc-3col-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l6-s2/tests/test.sh b/tasks/construct-nppc-3col-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l6-s5/environment/Dockerfile b/tasks/construct-nppc-3col-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l6-s5/environment/instance.json b/tasks/construct-nppc-3col-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..92aae9140bbeaeb47d39ec4b537a019d68b58ec0 --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 120, "edges": [[0, 19], [0, 46], [0, 66], [0, 82], [0, 84], [0, 90], [0, 97], [1, 21], [1, 34], [1, 36], [1, 66], [1, 83], [1, 84], [1, 91], [1, 100], [2, 26], [2, 32], [2, 74], [2, 85], [2, 91], [2, 107], [3, 71], [3, 74], [3, 98], [3, 108], [4, 27], [4, 42], [4, 74], [4, 76], [4, 93], [4, 96], [4, 106], [5, 65], [5, 75], [5, 79], [5, 84], [5, 90], [5, 108], [5, 111], [6, 23], [6, 38], [6, 48], [6, 105], [6, 119], [7, 22], [7, 43], [7, 45], [7, 46], [7, 72], [7, 79], [7, 80], [7, 92], [7, 100], [7, 117], [8, 22], [8, 27], [8, 33], [8, 45], [8, 53], [8, 62], [8, 106], [8, 111], [9, 33], [9, 47], [9, 56], [9, 62], [9, 76], [9, 79], [9, 98], [9, 101], [9, 118], [10, 11], [10, 17], [10, 24], [10, 33], [10, 40], [10, 51], [10, 67], [10, 71], [10, 76], [10, 84], [10, 85], [10, 105], [10, 119], [11, 12], [11, 17], [11, 35], [11, 38], [11, 45], [11, 47], [11, 55], [12, 31], [12, 40], [12, 50], [12, 80], [12, 89], [12, 91], [12, 95], [12, 97], [12, 114], [13, 26], [13, 61], [13, 103], [14, 15], [14, 59], [14, 74], [14, 82], [14, 94], [14, 108], [14, 111], [14, 112], [15, 19], [15, 28], [15, 49], [15, 98], [15, 103], [15, 104], [15, 111], [15, 114], [16, 21], [16, 29], [16, 39], [16, 40], [16, 44], [16, 47], [16, 48], [16, 68], [16, 81], [16, 85], [16, 104], [16, 105], [17, 29], [17, 72], [17, 77], [17, 83], [17, 101], [18, 21], [18, 22], [18, 43], [18, 50], [18, 53], [18, 91], [18, 119], [19, 20], [19, 21], [19, 36], [19, 42], [19, 49], [19, 58], [19, 62], [19, 77], [19, 84], [19, 91], [19, 100], [19, 104], [20, 67], [20, 68], [20, 87], [20, 96], [20, 117], [21, 32], [21, 35], [21, 46], [21, 60], [21, 62], [21, 67], [21, 82], [21, 95], [21, 109], [21, 114], [21, 116], [22, 37], [22, 52], [22, 74], [22, 85], [22, 91], [22, 105], [22, 108], [23, 39], [23, 45], [23, 69], [23, 80], [23, 90], [23, 91], [23, 107], [23, 117], [23, 118], [24, 33], [24, 38], [24, 47], [24, 50], [24, 56], [24, 87], [24, 95], [24, 96], [24, 102], [24, 114], [25, 29], [25, 71], [25, 74], [25, 83], [25, 91], [25, 98], [25, 101], [26, 29], [26, 34], [26, 40], [26, 42], [26, 74], [26, 75], [26, 79], [26, 88], [26, 99], [26, 112], [27, 56], [27, 71], [27, 89], [28, 39], [28, 57], [28, 62], [28, 73], [28, 76], [28, 97], [28, 107], [28, 115], [29, 31], [29, 35], [29, 53], [29, 61], [29, 63], [29, 64], [29, 76], [29, 82], [29, 93], [29, 101], [30, 49], [30, 88], [30, 93], [30, 112], [30, 113], [31, 70], [31, 78], [31, 91], [31, 107], [31, 112], [31, 115], [32, 34], [32, 42], [32, 59], [32, 61], [32, 77], [32, 82], [32, 84], [32, 90], [32, 103], [32, 110], [33, 59], [33, 92], [34, 50], [34, 61], [34, 86], [34, 101], [34, 105], [34, 109], [35, 44], [35, 45], [35, 46], [35, 57], [35, 58], [35, 109], [36, 42], [36, 60], [36, 95], [36, 100], [37, 52], [37, 59], [37, 90], [37, 94], [37, 103], [37, 111], [38, 40], [38, 41], [38, 46], [38, 50], [38, 69], [38, 112], [38, 113], [39, 63], [39, 76], [39, 82], [39, 102], [40, 45], [40, 46], [40, 61], [40, 63], [40, 81], [40, 105], [40, 116], [41, 46], [41, 47], [41, 51], [41, 56], [41, 62], [41, 65], [41, 69], [41, 70], [41, 93], [41, 104], [42, 53], [42, 60], [42, 65], [42, 67], [42, 86], [42, 87], [42, 95], [42, 105], [42, 111], [43, 51], [43, 52], [43, 68], [43, 77], [43, 78], [43, 90], [43, 96], [43, 115], [44, 45], [44, 46], [44, 48], [44, 53], [44, 106], [45, 77], [45, 93], [45, 97], [45, 108], [46, 80], [46, 83], [46, 88], [47, 77], [47, 84], [47, 92], [47, 95], [47, 111], [47, 118], [48, 53], [48, 60], [48, 71], [48, 77], [48, 79], [48, 89], [48, 94], [48, 95], [49, 53], [49, 69], [49, 72], [49, 102], [49, 107], [49, 111], [49, 113], [50, 119], [51, 56], [51, 69], [51, 90], [51, 91], [51, 107], [52, 79], [53, 84], [54, 55], [54, 64], [54, 88], [54, 91], [54, 97], [54, 115], [54, 119], [55, 72], [55, 75], [55, 94], [55, 114], [56, 89], [56, 115], [57, 61], [57, 64], [57, 67], [57, 93], [57, 115], [58, 93], [58, 114], [59, 67], [59, 96], [59, 108], [59, 113], [60, 89], [60, 96], [61, 70], [61, 74], [61, 89], [61, 97], [61, 104], [61, 105], [62, 65], [62, 118], [63, 74], [63, 92], [63, 109], [64, 84], [64, 87], [64, 114], [65, 73], [65, 80], [65, 81], [65, 86], [65, 115], [66, 98], [67, 112], [67, 117], [68, 79], [68, 87], [68, 88], [68, 101], [68, 114], [69, 74], [69, 80], [69, 85], [69, 93], [69, 106], [70, 77], [70, 88], [71, 106], [72, 88], [72, 92], [73, 75], [73, 94], [73, 100], [73, 107], [74, 87], [74, 99], [75, 102], [76, 77], [76, 79], [76, 91], [76, 101], [76, 107], [76, 113], [76, 114], [77, 115], [78, 81], [78, 114], [78, 118], [79, 83], [79, 96], [79, 108], [80, 116], [81, 84], [81, 90], [81, 111], [81, 114], [82, 86], [82, 90], [82, 94], [83, 96], [84, 104], [84, 106], [85, 94], [85, 98], [86, 101], [86, 102], [86, 103], [87, 89], [87, 92], [88, 116], [91, 101], [91, 104], [91, 114], [92, 104], [93, 111], [93, 117], [94, 110], [94, 114], [95, 106], [96, 102], [96, 116], [97, 115], [97, 117], [98, 108], [99, 115], [100, 103], [101, 106], [102, 108], [103, 105], [104, 112], [105, 107], [105, 116], [106, 114], [107, 109], [107, 117], [110, 113], [111, 112], [111, 119], [112, 114], [112, 117], [115, 116]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l6-s5/solution/solve.sh b/tasks/construct-nppc-3col-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d16e901f383eed1e188a3f74efeb15f76132363d --- /dev/null +++ b/tasks/construct-nppc-3col-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' +{"coloring": [2, 1, 1, 2, 1, 2, 1, 2, 0, 0, 1, 0, 2, 0, 2, 0, 1, 2, 2, 1, 0, 0, 1, 2, 0, 2, 2, 2, 1, 0, 1, 1, 2, 2, 0, 2, 2, 2, 2, 0, 0, 0, 0, 1, 0, 1, 1, 2, 2, 2, 1, 2, 0, 1, 1, 2, 1, 0, 0, 1, 1, 1, 2, 2, 2, 1, 0, 2, 2, 1, 2, 0, 1, 2, 0, 0, 2, 0, 0, 1, 0, 2, 1, 0, 0, 2, 2, 1, 0, 0, 0, 0, 0, 2, 0, 1, 2, 0, 1, 1, 0, 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 1, 0, 0, 1, 2, 1, 1, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l6-s5/tests/check.py b/tasks/construct-nppc-3col-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s5/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-l6-s5/tests/instance.json b/tasks/construct-nppc-3col-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..92aae9140bbeaeb47d39ec4b537a019d68b58ec0 --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 120, "edges": [[0, 19], [0, 46], [0, 66], [0, 82], [0, 84], [0, 90], [0, 97], [1, 21], [1, 34], [1, 36], [1, 66], [1, 83], [1, 84], [1, 91], [1, 100], [2, 26], [2, 32], [2, 74], [2, 85], [2, 91], [2, 107], [3, 71], [3, 74], [3, 98], [3, 108], [4, 27], [4, 42], [4, 74], [4, 76], [4, 93], [4, 96], [4, 106], [5, 65], [5, 75], [5, 79], [5, 84], [5, 90], [5, 108], [5, 111], [6, 23], [6, 38], [6, 48], [6, 105], [6, 119], [7, 22], [7, 43], [7, 45], [7, 46], [7, 72], [7, 79], [7, 80], [7, 92], [7, 100], [7, 117], [8, 22], [8, 27], [8, 33], [8, 45], [8, 53], [8, 62], [8, 106], [8, 111], [9, 33], [9, 47], [9, 56], [9, 62], [9, 76], [9, 79], [9, 98], [9, 101], [9, 118], [10, 11], [10, 17], [10, 24], [10, 33], [10, 40], [10, 51], [10, 67], [10, 71], [10, 76], [10, 84], [10, 85], [10, 105], [10, 119], [11, 12], [11, 17], [11, 35], [11, 38], [11, 45], [11, 47], [11, 55], [12, 31], [12, 40], [12, 50], [12, 80], [12, 89], [12, 91], [12, 95], [12, 97], [12, 114], [13, 26], [13, 61], [13, 103], [14, 15], [14, 59], [14, 74], [14, 82], [14, 94], [14, 108], [14, 111], [14, 112], [15, 19], [15, 28], [15, 49], [15, 98], [15, 103], [15, 104], [15, 111], [15, 114], [16, 21], [16, 29], [16, 39], [16, 40], [16, 44], [16, 47], [16, 48], [16, 68], [16, 81], [16, 85], [16, 104], [16, 105], [17, 29], [17, 72], [17, 77], [17, 83], [17, 101], [18, 21], [18, 22], [18, 43], [18, 50], [18, 53], [18, 91], [18, 119], [19, 20], [19, 21], [19, 36], [19, 42], [19, 49], [19, 58], [19, 62], [19, 77], [19, 84], [19, 91], [19, 100], [19, 104], [20, 67], [20, 68], [20, 87], [20, 96], [20, 117], [21, 32], [21, 35], [21, 46], [21, 60], [21, 62], [21, 67], [21, 82], [21, 95], [21, 109], [21, 114], [21, 116], [22, 37], [22, 52], [22, 74], [22, 85], [22, 91], [22, 105], [22, 108], [23, 39], [23, 45], [23, 69], [23, 80], [23, 90], [23, 91], [23, 107], [23, 117], [23, 118], [24, 33], [24, 38], [24, 47], [24, 50], [24, 56], [24, 87], [24, 95], [24, 96], [24, 102], [24, 114], [25, 29], [25, 71], [25, 74], [25, 83], [25, 91], [25, 98], [25, 101], [26, 29], [26, 34], [26, 40], [26, 42], [26, 74], [26, 75], [26, 79], [26, 88], [26, 99], [26, 112], [27, 56], [27, 71], [27, 89], [28, 39], [28, 57], [28, 62], [28, 73], [28, 76], [28, 97], [28, 107], [28, 115], [29, 31], [29, 35], [29, 53], [29, 61], [29, 63], [29, 64], [29, 76], [29, 82], [29, 93], [29, 101], [30, 49], [30, 88], [30, 93], [30, 112], [30, 113], [31, 70], [31, 78], [31, 91], [31, 107], [31, 112], [31, 115], [32, 34], [32, 42], [32, 59], [32, 61], [32, 77], [32, 82], [32, 84], [32, 90], [32, 103], [32, 110], [33, 59], [33, 92], [34, 50], [34, 61], [34, 86], [34, 101], [34, 105], [34, 109], [35, 44], [35, 45], [35, 46], [35, 57], [35, 58], [35, 109], [36, 42], [36, 60], [36, 95], [36, 100], [37, 52], [37, 59], [37, 90], [37, 94], [37, 103], [37, 111], [38, 40], [38, 41], [38, 46], [38, 50], [38, 69], [38, 112], [38, 113], [39, 63], [39, 76], [39, 82], [39, 102], [40, 45], [40, 46], [40, 61], [40, 63], [40, 81], [40, 105], [40, 116], [41, 46], [41, 47], [41, 51], [41, 56], [41, 62], [41, 65], [41, 69], [41, 70], [41, 93], [41, 104], [42, 53], [42, 60], [42, 65], [42, 67], [42, 86], [42, 87], [42, 95], [42, 105], [42, 111], [43, 51], [43, 52], [43, 68], [43, 77], [43, 78], [43, 90], [43, 96], [43, 115], [44, 45], [44, 46], [44, 48], [44, 53], [44, 106], [45, 77], [45, 93], [45, 97], [45, 108], [46, 80], [46, 83], [46, 88], [47, 77], [47, 84], [47, 92], [47, 95], [47, 111], [47, 118], [48, 53], [48, 60], [48, 71], [48, 77], [48, 79], [48, 89], [48, 94], [48, 95], [49, 53], [49, 69], [49, 72], [49, 102], [49, 107], [49, 111], [49, 113], [50, 119], [51, 56], [51, 69], [51, 90], [51, 91], [51, 107], [52, 79], [53, 84], [54, 55], [54, 64], [54, 88], [54, 91], [54, 97], [54, 115], [54, 119], [55, 72], [55, 75], [55, 94], [55, 114], [56, 89], [56, 115], [57, 61], [57, 64], [57, 67], [57, 93], [57, 115], [58, 93], [58, 114], [59, 67], [59, 96], [59, 108], [59, 113], [60, 89], [60, 96], [61, 70], [61, 74], [61, 89], [61, 97], [61, 104], [61, 105], [62, 65], [62, 118], [63, 74], [63, 92], [63, 109], [64, 84], [64, 87], [64, 114], [65, 73], [65, 80], [65, 81], [65, 86], [65, 115], [66, 98], [67, 112], [67, 117], [68, 79], [68, 87], [68, 88], [68, 101], [68, 114], [69, 74], [69, 80], [69, 85], [69, 93], [69, 106], [70, 77], [70, 88], [71, 106], [72, 88], [72, 92], [73, 75], [73, 94], [73, 100], [73, 107], [74, 87], [74, 99], [75, 102], [76, 77], [76, 79], [76, 91], [76, 101], [76, 107], [76, 113], [76, 114], [77, 115], [78, 81], [78, 114], [78, 118], [79, 83], [79, 96], [79, 108], [80, 116], [81, 84], [81, 90], [81, 111], [81, 114], [82, 86], [82, 90], [82, 94], [83, 96], [84, 104], [84, 106], [85, 94], [85, 98], [86, 101], [86, 102], [86, 103], [87, 89], [87, 92], [88, 116], [91, 101], [91, 104], [91, 114], [92, 104], [93, 111], [93, 117], [94, 110], [94, 114], [95, 106], [96, 102], [96, 116], [97, 115], [97, 117], [98, 108], [99, 115], [100, 103], [101, 106], [102, 108], [103, 105], [104, 112], [105, 107], [105, 116], [106, 114], [107, 109], [107, 117], [110, 113], [111, 112], [111, 119], [112, 114], [112, 117], [115, 116]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l6-s5/tests/run.py b/tasks/construct-nppc-3col-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l6-s5/tests/test.sh b/tasks/construct-nppc-3col-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-bandwidth-l4-s6/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-bandwidth-l4-s6/environment/instance.json b/tasks/construct-nppc-bandwidth-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..829ae1f2c18c67c173901a3afb247ed93220eca2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 20, "bandwidth": 3, "edges": [[0, 3], [0, 4], [0, 8], [0, 9], [1, 5], [1, 12], [1, 17], [1, 18], [2, 3], [2, 8], [2, 14], [3, 4], [3, 8], [3, 15], [3, 19], [4, 8], [4, 9], [4, 15], [5, 6], [5, 11], [5, 14], [5, 16], [6, 7], [6, 12], [6, 17], [7, 12], [7, 13], [7, 17], [7, 18], [8, 9], [10, 12], [10, 13], [11, 14], [11, 19], [12, 13], [13, 18], [14, 15], [14, 16], [15, 19], [16, 17]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l4-s6/solution/solve.sh b/tasks/construct-nppc-bandwidth-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5ff2fcdc1322e9410858673404e862d575223767 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"layout": [1, 14, 6, 4, 2, 11, 13, 15, 3, 0, 19, 10, 16, 18, 8, 5, 9, 12, 17, 7]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l4-s6/tests/check.py b/tasks/construct-nppc-bandwidth-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s6/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-l4-s6/tests/instance.json b/tasks/construct-nppc-bandwidth-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..829ae1f2c18c67c173901a3afb247ed93220eca2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 20, "bandwidth": 3, "edges": [[0, 3], [0, 4], [0, 8], [0, 9], [1, 5], [1, 12], [1, 17], [1, 18], [2, 3], [2, 8], [2, 14], [3, 4], [3, 8], [3, 15], [3, 19], [4, 8], [4, 9], [4, 15], [5, 6], [5, 11], [5, 14], [5, 16], [6, 7], [6, 12], [6, 17], [7, 12], [7, 13], [7, 17], [7, 18], [8, 9], [10, 12], [10, 13], [11, 14], [11, 19], [12, 13], [13, 18], [14, 15], [14, 16], [15, 19], [16, 17]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l4-s6/tests/run.py b/tasks/construct-nppc-bandwidth-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-bandwidth-l4-s6/tests/test.sh b/tasks/construct-nppc-bandwidth-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-bandwidth-l4-s8/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-bandwidth-l4-s8/environment/instance.json b/tasks/construct-nppc-bandwidth-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e42d0e51348a49eb03fffb285779f9470d8d6042 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 20, "bandwidth": 3, "edges": [[0, 8], [0, 9], [1, 3], [1, 6], [1, 11], [1, 12], [1, 18], [2, 5], [2, 10], [2, 17], [2, 19], [3, 6], [3, 16], [4, 5], [4, 10], [5, 7], [5, 10], [5, 17], [6, 11], [6, 12], [6, 18], [6, 19], [7, 10], [7, 12], [7, 14], [8, 9], [8, 16], [9, 13], [9, 16], [10, 14], [11, 13], [11, 16], [12, 14], [12, 19], [13, 15], [13, 16], [14, 18], [15, 16], [18, 19]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l4-s8/solution/solve.sh b/tasks/construct-nppc-bandwidth-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..dd9491b33b7d8b1b635128c0ba6117c5a1add7be --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"layout": [0, 8, 15, 7, 19, 17, 9, 14, 1, 2, 16, 6, 11, 5, 13, 3, 4, 18, 10, 12]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l4-s8/tests/check.py b/tasks/construct-nppc-bandwidth-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s8/tests/check.py @@ -0,0 +1,14 @@ +"""Bandwidth <= b: layout must be a permutation of 0..n-1 with |p[u]-p[v]| <= b on every edge.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, b = inst["num_nodes"], inst["bandwidth"] + # upstream NPPC verifier compares sorted(layout) to range(n), which also accepts floats/bools + p = int_list(ans.get("layout"), n, 0, n - 1, "layout") + if len(set(p)) != n: + raise Invalid("layout is not a permutation of 0..n-1") + for u, v in inst["edges"]: + if abs(p[u] - p[v]) > b: + raise Invalid(f"edge ({u},{v}) has stretch {abs(p[u] - p[v])} > {b}") + return None, {} diff --git a/tasks/construct-nppc-bandwidth-l4-s8/tests/instance.json b/tasks/construct-nppc-bandwidth-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e42d0e51348a49eb03fffb285779f9470d8d6042 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 20, "bandwidth": 3, "edges": [[0, 8], [0, 9], [1, 3], [1, 6], [1, 11], [1, 12], [1, 18], [2, 5], [2, 10], [2, 17], [2, 19], [3, 6], [3, 16], [4, 5], [4, 10], [5, 7], [5, 10], [5, 17], [6, 11], [6, 12], [6, 18], [6, 19], [7, 10], [7, 12], [7, 14], [8, 9], [8, 16], [9, 13], [9, 16], [10, 14], [11, 13], [11, 16], [12, 14], [12, 19], [13, 15], [13, 16], [14, 18], [15, 16], [18, 19]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l4-s8/tests/run.py b/tasks/construct-nppc-bandwidth-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-bandwidth-l4-s8/tests/test.sh b/tasks/construct-nppc-bandwidth-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-clique-l1-s0/environment/Dockerfile b/tasks/construct-nppc-clique-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l1-s0/environment/instance.json b/tasks/construct-nppc-clique-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3b8648f37c9e1337e97a50a3f55607cfa38e85ca --- /dev/null +++ b/tasks/construct-nppc-clique-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "k": 4, "edges": [[0, 2], [0, 3], [0, 6], [0, 7], [1, 2], [1, 3], [1, 4], [1, 6], [1, 7], [2, 4], [2, 5], [2, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l1-s0/solution/solve.sh b/tasks/construct-nppc-clique-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e443510900a2049a89d3a134ea6486de8320ec14 --- /dev/null +++ b/tasks/construct-nppc-clique-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' +{"clique": [2, 4, 5, 6]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l1-s0/tests/check.py b/tasks/construct-nppc-clique-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l1-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-l1-s0/tests/instance.json b/tasks/construct-nppc-clique-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3b8648f37c9e1337e97a50a3f55607cfa38e85ca --- /dev/null +++ b/tasks/construct-nppc-clique-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "k": 4, "edges": [[0, 2], [0, 3], [0, 6], [0, 7], [1, 2], [1, 3], [1, 4], [1, 6], [1, 7], [2, 4], [2, 5], [2, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l1-s0/tests/run.py b/tasks/construct-nppc-clique-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l1-s0/tests/test.sh b/tasks/construct-nppc-clique-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l1-s9/environment/Dockerfile b/tasks/construct-nppc-clique-l1-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l1-s9/environment/instance.json b/tasks/construct-nppc-clique-l1-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..51a52bfa5295bf1c13aa6ce81aeec6b7b9bbd18d --- /dev/null +++ b/tasks/construct-nppc-clique-l1-s9/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "k": 4, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [4, 6], [5, 6], [5, 7], [6, 7]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l1-s9/solution/solve.sh b/tasks/construct-nppc-clique-l1-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..49a940bb6380364c73b763568b443192b05534fc --- /dev/null +++ b/tasks/construct-nppc-clique-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' +{"clique": [1, 5, 6, 7]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l1-s9/tests/check.py b/tasks/construct-nppc-clique-l1-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l1-s9/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l1-s9/tests/instance.json b/tasks/construct-nppc-clique-l1-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..51a52bfa5295bf1c13aa6ce81aeec6b7b9bbd18d --- /dev/null +++ b/tasks/construct-nppc-clique-l1-s9/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "k": 4, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [4, 6], [5, 6], [5, 7], [6, 7]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l1-s9/tests/run.py b/tasks/construct-nppc-clique-l1-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l1-s9/tests/test.sh b/tasks/construct-nppc-clique-l1-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l2-s2/environment/Dockerfile b/tasks/construct-nppc-clique-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l2-s2/environment/instance.json b/tasks/construct-nppc-clique-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..db1d6e0c5c8ae699ab0cb530ae970e1b53246457 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 7], [0, 10], [0, 11], [0, 12], [0, 13], [1, 2], [1, 3], [1, 5], [1, 6], [1, 7], [1, 8], [1, 11], [1, 12], [1, 13], [2, 3], [2, 4], [2, 6], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 10], [3, 11], [3, 12], [3, 13], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [5, 6], [5, 7], [5, 8], [5, 11], [5, 12], [6, 7], [6, 8], [6, 10], [7, 8], [7, 9], [7, 11], [7, 12], [8, 9], [8, 10], [8, 12], [9, 12], [9, 13], [11, 12], [12, 13]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s2/solution/solve.sh b/tasks/construct-nppc-clique-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5a6a59b71b77d79978463cb971808d1215887273 --- /dev/null +++ b/tasks/construct-nppc-clique-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' +{"clique": [0, 1, 3, 5, 7, 11, 12]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l2-s2/tests/check.py b/tasks/construct-nppc-clique-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s2/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-s2/tests/instance.json b/tasks/construct-nppc-clique-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..db1d6e0c5c8ae699ab0cb530ae970e1b53246457 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 7], [0, 10], [0, 11], [0, 12], [0, 13], [1, 2], [1, 3], [1, 5], [1, 6], [1, 7], [1, 8], [1, 11], [1, 12], [1, 13], [2, 3], [2, 4], [2, 6], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 10], [3, 11], [3, 12], [3, 13], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [5, 6], [5, 7], [5, 8], [5, 11], [5, 12], [6, 7], [6, 8], [6, 10], [7, 8], [7, 9], [7, 11], [7, 12], [8, 9], [8, 10], [8, 12], [9, 12], [9, 13], [11, 12], [12, 13]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s2/tests/run.py b/tasks/construct-nppc-clique-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l2-s2/tests/test.sh b/tasks/construct-nppc-clique-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l5-s6/environment/Dockerfile b/tasks/construct-nppc-clique-l5-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l5-s6/environment/instance.json b/tasks/construct-nppc-clique-l5-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1d75f14e85e47d7686598af87afd71e45c061509 --- /dev/null +++ b/tasks/construct-nppc-clique-l5-s6/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 5], [0, 7], [0, 10], [0, 11], [0, 12], [0, 13], [0, 15], [0, 16], [0, 19], [0, 26], [0, 27], [0, 32], [0, 33], [0, 34], [0, 35], [0, 36], [0, 38], [0, 39], [1, 2], [1, 3], [1, 6], [1, 8], [1, 9], [1, 11], [1, 12], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 30], [1, 32], [1, 33], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [2, 3], [2, 6], [2, 8], [2, 11], [2, 14], [2, 15], [2, 16], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 24], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 35], [2, 38], [2, 39], [3, 5], [3, 6], [3, 8], [3, 9], [3, 11], [3, 13], [3, 15], [3, 16], [3, 17], [3, 18], [3, 21], [3, 24], [3, 26], [3, 37], [3, 38], [3, 39], [4, 5], [4, 6], [4, 8], [4, 11], [4, 13], [4, 14], [4, 17], [4, 19], [4, 20], [4, 22], [4, 25], [4, 27], [4, 28], [4, 29], [4, 32], [4, 34], [4, 35], [4, 39], [5, 6], [5, 7], [5, 8], [5, 12], [5, 14], [5, 15], [5, 17], [5, 18], [5, 20], [5, 21], [5, 22], [5, 24], [5, 25], [5, 34], [5, 36], [5, 37], [6, 8], [6, 9], [6, 11], [6, 12], [6, 13], [6, 15], [6, 16], [6, 17], [6, 18], [6, 20], [6, 21], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [6, 34], [6, 35], [6, 36], [6, 37], [6, 39], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 22], [7, 24], [7, 25], [7, 26], [7, 27], [7, 29], [7, 30], [7, 32], [7, 33], [7, 34], [7, 35], [7, 36], [7, 38], [8, 9], [8, 11], [8, 12], [8, 14], [8, 16], [8, 17], [8, 18], [8, 20], [8, 21], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 32], [8, 33], [8, 34], [8, 35], [8, 36], [8, 37], [8, 38], [8, 39], [9, 12], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 24], [9, 25], [9, 26], [9, 27], [9, 30], [9, 32], [9, 33], [9, 34], [9, 35], [9, 36], [9, 37], [9, 39], [10, 13], [10, 15], [10, 16], [10, 17], [10, 19], [10, 25], [10, 27], [10, 29], [10, 31], [10, 34], [10, 37], [10, 39], [11, 14], [11, 18], [11, 20], [11, 21], [11, 23], [11, 25], [11, 26], [11, 28], [11, 30], [11, 31], [11, 33], [11, 34], [11, 35], [11, 36], [11, 38], [12, 13], [12, 16], [12, 17], [12, 18], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 30], [12, 32], [12, 33], [12, 34], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [13, 14], [13, 18], [13, 19], [13, 20], [13, 21], [13, 24], [13, 25], [13, 27], [13, 28], [13, 29], [13, 30], [13, 31], [13, 33], [13, 34], [13, 35], [13, 36], [14, 15], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 26], [14, 27], [14, 28], [14, 32], [14, 34], [14, 35], [14, 38], [15, 17], [15, 20], [15, 22], [15, 25], [15, 27], [15, 31], [15, 33], [15, 36], [16, 18], [16, 22], [16, 25], [16, 26], [16, 27], [16, 29], [16, 30], [16, 32], [16, 34], [17, 18], [17, 20], [17, 21], [17, 24], [17, 25], [17, 26], [17, 28], [17, 29], [17, 30], [17, 32], [17, 33], [17, 34], [17, 35], [17, 36], [17, 37], [17, 39], [18, 20], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 30], [18, 32], [18, 33], [18, 34], [18, 35], [18, 36], [18, 37], [18, 38], [18, 39], [19, 22], [19, 23], [19, 24], [19, 26], [19, 29], [19, 30], [19, 32], [19, 33], [19, 34], [19, 39], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 28], [20, 30], [20, 31], [20, 32], [20, 33], [20, 34], [20, 35], [20, 36], [20, 37], [20, 39], [21, 22], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [21, 36], [21, 37], [21, 38], [21, 39], [22, 26], [22, 27], [22, 31], [22, 33], [22, 34], [22, 36], [22, 37], [22, 39], [23, 24], [23, 25], [23, 26], [23, 28], [23, 31], [23, 32], [23, 33], [23, 39], [24, 25], [24, 26], [24, 27], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [24, 36], [24, 37], [24, 39], [25, 26], [25, 28], [25, 29], [25, 30], [25, 32], [25, 33], [25, 34], [25, 35], [25, 36], [25, 37], [25, 38], [25, 39], [26, 27], [26, 28], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [26, 36], [26, 37], [26, 39], [27, 30], [27, 34], [27, 37], [27, 38], [28, 30], [28, 31], [28, 32], [28, 33], [28, 35], [29, 30], [29, 34], [29, 35], [29, 36], [29, 37], [30, 32], [30, 33], [30, 34], [30, 35], [30, 36], [30, 37], [30, 39], [31, 32], [31, 33], [31, 34], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 38], [32, 39], [33, 34], [33, 35], [33, 36], [33, 37], [33, 38], [33, 39], [34, 35], [34, 36], [34, 37], [34, 39], [35, 36], [35, 37], [35, 38], [35, 39], [36, 37], [36, 38], [36, 39], [37, 39], [38, 39]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l5-s6/solution/solve.sh b/tasks/construct-nppc-clique-l5-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6818751e83d0a2c2f081dabce107bf6164df6f86 --- /dev/null +++ b/tasks/construct-nppc-clique-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' +{"clique": [1, 6, 8, 9, 12, 17, 18, 20, 21, 24, 25, 26, 30, 32, 33, 34, 35, 36, 37, 39]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l5-s6/tests/check.py b/tasks/construct-nppc-clique-l5-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l5-s6/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l5-s6/tests/instance.json b/tasks/construct-nppc-clique-l5-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1d75f14e85e47d7686598af87afd71e45c061509 --- /dev/null +++ b/tasks/construct-nppc-clique-l5-s6/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 5], [0, 7], [0, 10], [0, 11], [0, 12], [0, 13], [0, 15], [0, 16], [0, 19], [0, 26], [0, 27], [0, 32], [0, 33], [0, 34], [0, 35], [0, 36], [0, 38], [0, 39], [1, 2], [1, 3], [1, 6], [1, 8], [1, 9], [1, 11], [1, 12], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 30], [1, 32], [1, 33], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [2, 3], [2, 6], [2, 8], [2, 11], [2, 14], [2, 15], [2, 16], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 24], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 35], [2, 38], [2, 39], [3, 5], [3, 6], [3, 8], [3, 9], [3, 11], [3, 13], [3, 15], [3, 16], [3, 17], [3, 18], [3, 21], [3, 24], [3, 26], [3, 37], [3, 38], [3, 39], [4, 5], [4, 6], [4, 8], [4, 11], [4, 13], [4, 14], [4, 17], [4, 19], [4, 20], [4, 22], [4, 25], [4, 27], [4, 28], [4, 29], [4, 32], [4, 34], [4, 35], [4, 39], [5, 6], [5, 7], [5, 8], [5, 12], [5, 14], [5, 15], [5, 17], [5, 18], [5, 20], [5, 21], [5, 22], [5, 24], [5, 25], [5, 34], [5, 36], [5, 37], [6, 8], [6, 9], [6, 11], [6, 12], [6, 13], [6, 15], [6, 16], [6, 17], [6, 18], [6, 20], [6, 21], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [6, 34], [6, 35], [6, 36], [6, 37], [6, 39], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 22], [7, 24], [7, 25], [7, 26], [7, 27], [7, 29], [7, 30], [7, 32], [7, 33], [7, 34], [7, 35], [7, 36], [7, 38], [8, 9], [8, 11], [8, 12], [8, 14], [8, 16], [8, 17], [8, 18], [8, 20], [8, 21], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 32], [8, 33], [8, 34], [8, 35], [8, 36], [8, 37], [8, 38], [8, 39], [9, 12], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 24], [9, 25], [9, 26], [9, 27], [9, 30], [9, 32], [9, 33], [9, 34], [9, 35], [9, 36], [9, 37], [9, 39], [10, 13], [10, 15], [10, 16], [10, 17], [10, 19], [10, 25], [10, 27], [10, 29], [10, 31], [10, 34], [10, 37], [10, 39], [11, 14], [11, 18], [11, 20], [11, 21], [11, 23], [11, 25], [11, 26], [11, 28], [11, 30], [11, 31], [11, 33], [11, 34], [11, 35], [11, 36], [11, 38], [12, 13], [12, 16], [12, 17], [12, 18], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 30], [12, 32], [12, 33], [12, 34], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [13, 14], [13, 18], [13, 19], [13, 20], [13, 21], [13, 24], [13, 25], [13, 27], [13, 28], [13, 29], [13, 30], [13, 31], [13, 33], [13, 34], [13, 35], [13, 36], [14, 15], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 26], [14, 27], [14, 28], [14, 32], [14, 34], [14, 35], [14, 38], [15, 17], [15, 20], [15, 22], [15, 25], [15, 27], [15, 31], [15, 33], [15, 36], [16, 18], [16, 22], [16, 25], [16, 26], [16, 27], [16, 29], [16, 30], [16, 32], [16, 34], [17, 18], [17, 20], [17, 21], [17, 24], [17, 25], [17, 26], [17, 28], [17, 29], [17, 30], [17, 32], [17, 33], [17, 34], [17, 35], [17, 36], [17, 37], [17, 39], [18, 20], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 30], [18, 32], [18, 33], [18, 34], [18, 35], [18, 36], [18, 37], [18, 38], [18, 39], [19, 22], [19, 23], [19, 24], [19, 26], [19, 29], [19, 30], [19, 32], [19, 33], [19, 34], [19, 39], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 28], [20, 30], [20, 31], [20, 32], [20, 33], [20, 34], [20, 35], [20, 36], [20, 37], [20, 39], [21, 22], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [21, 36], [21, 37], [21, 38], [21, 39], [22, 26], [22, 27], [22, 31], [22, 33], [22, 34], [22, 36], [22, 37], [22, 39], [23, 24], [23, 25], [23, 26], [23, 28], [23, 31], [23, 32], [23, 33], [23, 39], [24, 25], [24, 26], [24, 27], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [24, 36], [24, 37], [24, 39], [25, 26], [25, 28], [25, 29], [25, 30], [25, 32], [25, 33], [25, 34], [25, 35], [25, 36], [25, 37], [25, 38], [25, 39], [26, 27], [26, 28], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [26, 36], [26, 37], [26, 39], [27, 30], [27, 34], [27, 37], [27, 38], [28, 30], [28, 31], [28, 32], [28, 33], [28, 35], [29, 30], [29, 34], [29, 35], [29, 36], [29, 37], [30, 32], [30, 33], [30, 34], [30, 35], [30, 36], [30, 37], [30, 39], [31, 32], [31, 33], [31, 34], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 38], [32, 39], [33, 34], [33, 35], [33, 36], [33, 37], [33, 38], [33, 39], [34, 35], [34, 36], [34, 37], [34, 39], [35, 36], [35, 37], [35, 38], [35, 39], [36, 37], [36, 38], [36, 39], [37, 39], [38, 39]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l5-s6/tests/run.py b/tasks/construct-nppc-clique-l5-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l5-s6/tests/test.sh b/tasks/construct-nppc-clique-l5-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l5-s8/environment/Dockerfile b/tasks/construct-nppc-clique-l5-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l5-s8/environment/instance.json b/tasks/construct-nppc-clique-l5-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..016c86a67c8fac4f35c0d392c1e22f744cb095ce --- /dev/null +++ b/tasks/construct-nppc-clique-l5-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 2], [0, 5], [0, 9], [0, 10], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 35], [0, 36], [0, 37], [0, 38], [0, 39], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 9], [1, 13], [1, 15], [1, 18], [1, 19], [1, 22], [1, 23], [1, 27], [1, 29], [1, 30], [1, 34], [1, 35], [1, 36], [1, 38], [2, 6], [2, 8], [2, 10], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 28], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 36], [2, 38], [2, 39], [3, 5], [3, 7], [3, 9], [3, 10], [3, 13], [3, 14], [3, 15], [3, 17], [3, 22], [3, 23], [3, 28], [3, 29], [3, 31], [3, 35], [3, 36], [3, 38], [3, 39], [4, 9], [4, 11], [4, 12], [4, 13], [4, 14], [4, 25], [4, 28], [4, 33], [4, 36], [4, 38], [4, 39], [5, 8], [5, 9], [5, 10], [5, 11], [5, 13], [5, 17], [5, 19], [5, 24], [5, 25], [5, 26], [5, 27], [5, 32], [5, 33], [5, 34], [5, 36], [5, 37], [5, 39], [6, 7], [6, 8], [6, 14], [6, 15], [6, 16], [6, 18], [6, 19], [6, 25], [6, 27], [6, 28], [6, 32], [6, 38], [7, 10], [7, 11], [7, 12], [7, 13], [7, 16], [7, 17], [7, 18], [7, 19], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 28], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [7, 38], [7, 39], [8, 9], [8, 11], [8, 14], [8, 17], [8, 22], [8, 23], [8, 25], [8, 26], [8, 31], [8, 32], [8, 34], [8, 35], [8, 36], [8, 37], [9, 11], [9, 13], [9, 14], [9, 17], [9, 21], [9, 23], [9, 24], [9, 25], [9, 27], [9, 28], [9, 30], [9, 31], [9, 32], [9, 34], [9, 35], [9, 37], [9, 38], [9, 39], [10, 12], [10, 14], [10, 15], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 26], [10, 27], [10, 28], [10, 29], [10, 32], [10, 33], [10, 34], [10, 35], [11, 12], [11, 13], [11, 15], [11, 17], [11, 22], [11, 26], [11, 27], [11, 28], [11, 30], [11, 31], [11, 35], [11, 36], [11, 37], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 29], [12, 30], [12, 31], [12, 32], [12, 33], [12, 36], [12, 38], [12, 39], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 22], [13, 24], [13, 25], [13, 26], [13, 27], [13, 29], [13, 30], [13, 31], [13, 32], [13, 33], [13, 34], [13, 36], [13, 37], [13, 38], [13, 39], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [14, 20], [14, 22], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 30], [14, 31], [14, 32], [14, 33], [14, 35], [14, 36], [14, 38], [14, 39], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 24], [15, 25], [15, 26], [15, 27], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [15, 36], [15, 38], [15, 39], [16, 17], [16, 18], [16, 22], [16, 24], [16, 25], [16, 26], [16, 27], [16, 30], [16, 31], [16, 32], [16, 33], [16, 34], [16, 36], [16, 37], [16, 38], [16, 39], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 24], [17, 25], [17, 26], [17, 27], [17, 30], [17, 31], [17, 32], [17, 33], [17, 35], [17, 36], [17, 38], [17, 39], [18, 20], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 30], [18, 31], [18, 32], [18, 33], [18, 36], [18, 38], [18, 39], [19, 20], [19, 22], [19, 25], [19, 28], [19, 29], [19, 31], [19, 32], [19, 35], [20, 21], [20, 25], [20, 26], [20, 28], [20, 30], [20, 31], [20, 33], [20, 34], [21, 22], [21, 23], [21, 24], [21, 29], [21, 30], [21, 31], [21, 34], [21, 35], [21, 36], [21, 37], [21, 38], [21, 39], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 30], [22, 31], [22, 32], [22, 33], [22, 35], [22, 36], [22, 37], [22, 38], [22, 39], [23, 25], [23, 26], [23, 28], [23, 30], [23, 31], [23, 35], [23, 38], [23, 39], [24, 25], [24, 26], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 36], [24, 37], [24, 38], [24, 39], [25, 26], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 35], [25, 36], [25, 38], [25, 39], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 36], [26, 38], [26, 39], [27, 28], [27, 29], [27, 33], [27, 36], [27, 38], [27, 39], [28, 29], [28, 30], [28, 33], [28, 35], [28, 37], [28, 38], [28, 39], [29, 31], [30, 31], [30, 32], [30, 33], [30, 34], [30, 35], [30, 36], [30, 37], [30, 38], [30, 39], [31, 32], [31, 33], [31, 34], [31, 35], [31, 36], [31, 38], [31, 39], [32, 33], [32, 34], [32, 35], [32, 36], [32, 38], [32, 39], [33, 35], [33, 36], [33, 38], [33, 39], [34, 37], [35, 36], [35, 38], [36, 38], [36, 39], [37, 38], [38, 39]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l5-s8/solution/solve.sh b/tasks/construct-nppc-clique-l5-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5d25cb6c65c4ac4380100c7b1f629f9a2f848c1e --- /dev/null +++ b/tasks/construct-nppc-clique-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' +{"clique": [0, 2, 12, 13, 14, 15, 16, 17, 18, 22, 24, 25, 26, 30, 31, 32, 33, 36, 38, 39]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l5-s8/tests/check.py b/tasks/construct-nppc-clique-l5-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l5-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-l5-s8/tests/instance.json b/tasks/construct-nppc-clique-l5-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..016c86a67c8fac4f35c0d392c1e22f744cb095ce --- /dev/null +++ b/tasks/construct-nppc-clique-l5-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 2], [0, 5], [0, 9], [0, 10], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 35], [0, 36], [0, 37], [0, 38], [0, 39], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 9], [1, 13], [1, 15], [1, 18], [1, 19], [1, 22], [1, 23], [1, 27], [1, 29], [1, 30], [1, 34], [1, 35], [1, 36], [1, 38], [2, 6], [2, 8], [2, 10], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 28], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 36], [2, 38], [2, 39], [3, 5], [3, 7], [3, 9], [3, 10], [3, 13], [3, 14], [3, 15], [3, 17], [3, 22], [3, 23], [3, 28], [3, 29], [3, 31], [3, 35], [3, 36], [3, 38], [3, 39], [4, 9], [4, 11], [4, 12], [4, 13], [4, 14], [4, 25], [4, 28], [4, 33], [4, 36], [4, 38], [4, 39], [5, 8], [5, 9], [5, 10], [5, 11], [5, 13], [5, 17], [5, 19], [5, 24], [5, 25], [5, 26], [5, 27], [5, 32], [5, 33], [5, 34], [5, 36], [5, 37], [5, 39], [6, 7], [6, 8], [6, 14], [6, 15], [6, 16], [6, 18], [6, 19], [6, 25], [6, 27], [6, 28], [6, 32], [6, 38], [7, 10], [7, 11], [7, 12], [7, 13], [7, 16], [7, 17], [7, 18], [7, 19], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 28], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [7, 38], [7, 39], [8, 9], [8, 11], [8, 14], [8, 17], [8, 22], [8, 23], [8, 25], [8, 26], [8, 31], [8, 32], [8, 34], [8, 35], [8, 36], [8, 37], [9, 11], [9, 13], [9, 14], [9, 17], [9, 21], [9, 23], [9, 24], [9, 25], [9, 27], [9, 28], [9, 30], [9, 31], [9, 32], [9, 34], [9, 35], [9, 37], [9, 38], [9, 39], [10, 12], [10, 14], [10, 15], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 26], [10, 27], [10, 28], [10, 29], [10, 32], [10, 33], [10, 34], [10, 35], [11, 12], [11, 13], [11, 15], [11, 17], [11, 22], [11, 26], [11, 27], [11, 28], [11, 30], [11, 31], [11, 35], [11, 36], [11, 37], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 29], [12, 30], [12, 31], [12, 32], [12, 33], [12, 36], [12, 38], [12, 39], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 22], [13, 24], [13, 25], [13, 26], [13, 27], [13, 29], [13, 30], [13, 31], [13, 32], [13, 33], [13, 34], [13, 36], [13, 37], [13, 38], [13, 39], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [14, 20], [14, 22], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 30], [14, 31], [14, 32], [14, 33], [14, 35], [14, 36], [14, 38], [14, 39], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 24], [15, 25], [15, 26], [15, 27], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [15, 36], [15, 38], [15, 39], [16, 17], [16, 18], [16, 22], [16, 24], [16, 25], [16, 26], [16, 27], [16, 30], [16, 31], [16, 32], [16, 33], [16, 34], [16, 36], [16, 37], [16, 38], [16, 39], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 24], [17, 25], [17, 26], [17, 27], [17, 30], [17, 31], [17, 32], [17, 33], [17, 35], [17, 36], [17, 38], [17, 39], [18, 20], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 30], [18, 31], [18, 32], [18, 33], [18, 36], [18, 38], [18, 39], [19, 20], [19, 22], [19, 25], [19, 28], [19, 29], [19, 31], [19, 32], [19, 35], [20, 21], [20, 25], [20, 26], [20, 28], [20, 30], [20, 31], [20, 33], [20, 34], [21, 22], [21, 23], [21, 24], [21, 29], [21, 30], [21, 31], [21, 34], [21, 35], [21, 36], [21, 37], [21, 38], [21, 39], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 30], [22, 31], [22, 32], [22, 33], [22, 35], [22, 36], [22, 37], [22, 38], [22, 39], [23, 25], [23, 26], [23, 28], [23, 30], [23, 31], [23, 35], [23, 38], [23, 39], [24, 25], [24, 26], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 36], [24, 37], [24, 38], [24, 39], [25, 26], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 35], [25, 36], [25, 38], [25, 39], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 36], [26, 38], [26, 39], [27, 28], [27, 29], [27, 33], [27, 36], [27, 38], [27, 39], [28, 29], [28, 30], [28, 33], [28, 35], [28, 37], [28, 38], [28, 39], [29, 31], [30, 31], [30, 32], [30, 33], [30, 34], [30, 35], [30, 36], [30, 37], [30, 38], [30, 39], [31, 32], [31, 33], [31, 34], [31, 35], [31, 36], [31, 38], [31, 39], [32, 33], [32, 34], [32, 35], [32, 36], [32, 38], [32, 39], [33, 35], [33, 36], [33, 38], [33, 39], [34, 37], [35, 36], [35, 38], [36, 38], [36, 39], [37, 38], [38, 39]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l5-s8/tests/run.py b/tasks/construct-nppc-clique-l5-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l5-s8/tests/test.sh b/tasks/construct-nppc-clique-l5-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-dominating-set-l5-s1/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-dominating-set-l5-s1/environment/instance.json b/tasks/construct-nppc-dominating-set-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..327e39556b4d07535f3fb939c17bb2725a549e7e --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 180, "k": 15, "edges": [[0, 16], [0, 20], [0, 25], [0, 26], [0, 35], [0, 38], [0, 41], [0, 42], [0, 60], [0, 65], [0, 69], [0, 71], [0, 80], [0, 87], [0, 92], [0, 97], [0, 102], [0, 105], [0, 106], [0, 110], [0, 111], [0, 116], [0, 118], [0, 126], [0, 128], [0, 134], [0, 139], [0, 143], [0, 150], [0, 158], [0, 162], [0, 175], [0, 179], [1, 5], [1, 9], [1, 16], [1, 18], [1, 20], [1, 21], [1, 23], [1, 25], [1, 39], [1, 51], [1, 62], [1, 63], [1, 65], [1, 67], [1, 75], [1, 81], [1, 82], [1, 83], [1, 105], [1, 107], [1, 108], [1, 111], [1, 125], [1, 136], [1, 138], [1, 148], [1, 149], [1, 165], [1, 166], [1, 172], [1, 178], [1, 179], [2, 7], [2, 8], [2, 20], [2, 23], [2, 28], [2, 29], [2, 33], [2, 35], [2, 39], [2, 40], [2, 45], [2, 50], [2, 54], [2, 56], [2, 57], [2, 63], [2, 64], [2, 76], [2, 78], [2, 80], [2, 84], [2, 86], [2, 90], [2, 91], [2, 93], [2, 99], [2, 111], [2, 117], [2, 121], [2, 124], [2, 125], [2, 126], [2, 127], [2, 130], [2, 139], [2, 140], [2, 143], [2, 144], [2, 154], [2, 155], [2, 157], [2, 162], [2, 170], [2, 171], [2, 176], [2, 177], [2, 179], [3, 12], [3, 15], [3, 23], [3, 24], [3, 26], [3, 47], [3, 51], [3, 60], [3, 63], [3, 75], [3, 87], [3, 89], [3, 93], [3, 101], [3, 103], [3, 106], [3, 109], [3, 112], [3, 115], [3, 119], [3, 122], [3, 137], [3, 140], [3, 148], [3, 150], [3, 152], [3, 153], [3, 154], [3, 167], [3, 168], [3, 169], [3, 174], [3, 175], [4, 7], [4, 8], [4, 11], [4, 14], [4, 16], [4, 18], [4, 25], [4, 35], [4, 48], [4, 51], [4, 54], [4, 56], [4, 58], [4, 61], [4, 68], [4, 71], [4, 76], [4, 77], [4, 86], [4, 89], [4, 93], [4, 99], [4, 107], [4, 113], [4, 114], [4, 116], [4, 125], [4, 129], [4, 131], [4, 135], [4, 142], [4, 150], [4, 152], [4, 157], [4, 158], [4, 165], [4, 167], [4, 178], [5, 8], [5, 9], [5, 19], [5, 26], [5, 33], [5, 51], [5, 54], [5, 56], [5, 58], [5, 61], [5, 66], [5, 72], [5, 81], [5, 83], [5, 85], [5, 90], [5, 94], [5, 102], [5, 125], [5, 127], [5, 129], [5, 136], [5, 137], [5, 142], [5, 145], [5, 146], [5, 150], [5, 153], [5, 164], [5, 165], [5, 178], [6, 9], [6, 10], [6, 16], [6, 22], [6, 23], [6, 27], [6, 31], [6, 32], [6, 35], [6, 39], [6, 46], [6, 49], [6, 57], [6, 66], [6, 68], [6, 72], [6, 73], [6, 74], [6, 84], [6, 86], [6, 88], [6, 95], [6, 98], [6, 116], [6, 118], [6, 119], [6, 121], [6, 128], [6, 130], [6, 132], [6, 135], [6, 137], [6, 140], [6, 145], [6, 146], [6, 151], [6, 160], [6, 168], [6, 173], [6, 175], [7, 8], [7, 12], [7, 15], [7, 19], [7, 20], [7, 21], [7, 23], [7, 26], [7, 27], [7, 28], [7, 30], [7, 38], [7, 41], [7, 54], [7, 57], [7, 58], [7, 66], [7, 68], [7, 73], [7, 75], [7, 80], [7, 82], [7, 90], [7, 93], [7, 94], [7, 96], [7, 122], [7, 123], [7, 124], [7, 125], [7, 148], [7, 155], [7, 161], [7, 170], [8, 9], [8, 11], [8, 20], [8, 22], [8, 30], [8, 34], [8, 36], [8, 37], [8, 39], [8, 40], [8, 42], [8, 65], [8, 67], [8, 73], [8, 78], [8, 81], [8, 92], [8, 97], [8, 98], [8, 109], [8, 115], [8, 121], [8, 125], [8, 129], [8, 145], [8, 149], [8, 156], [8, 163], [8, 168], [8, 169], [8, 172], [8, 174], [8, 176], [8, 178], [9, 18], [9, 19], [9, 22], [9, 23], [9, 26], [9, 27], [9, 31], [9, 32], [9, 45], [9, 46], [9, 50], [9, 55], [9, 65], [9, 66], [9, 70], [9, 73], [9, 75], [9, 79], [9, 84], [9, 94], [9, 95], [9, 106], [9, 112], [9, 116], [9, 118], [9, 142], [9, 146], [9, 148], [9, 159], [9, 168], [10, 12], [10, 13], [10, 16], [10, 19], [10, 25], [10, 27], [10, 31], [10, 43], [10, 50], [10, 57], [10, 58], [10, 62], [10, 66], [10, 80], [10, 85], [10, 86], [10, 97], [10, 98], [10, 100], [10, 105], [10, 122], [10, 139], [10, 142], [10, 145], [10, 156], [10, 157], [10, 166], [10, 169], [10, 173], [10, 174], [10, 178], [10, 179], [11, 19], [11, 21], [11, 23], [11, 28], [11, 32], [11, 34], [11, 38], [11, 44], [11, 56], [11, 58], [11, 62], [11, 66], [11, 71], [11, 74], [11, 76], [11, 77], [11, 84], [11, 85], [11, 99], [11, 104], [11, 107], [11, 113], [11, 122], [11, 123], [11, 125], [11, 135], [11, 137], [11, 139], [11, 140], [11, 149], [11, 153], [11, 154], [11, 162], [11, 163], [11, 168], [11, 169], [11, 175], [12, 17], [12, 18], [12, 27], [12, 31], [12, 34], [12, 38], [12, 44], [12, 47], [12, 50], [12, 51], [12, 55], [12, 59], [12, 69], [12, 72], [12, 76], [12, 77], [12, 83], [12, 90], [12, 91], [12, 93], [12, 94], [12, 99], [12, 111], [12, 122], [12, 125], [12, 130], [12, 134], [12, 135], [12, 141], [12, 142], [12, 145], [12, 146], [12, 147], [12, 148], [12, 156], [12, 157], [12, 164], [12, 166], [12, 176], [13, 18], [13, 30], [13, 33], [13, 37], [13, 47], [13, 49], [13, 50], [13, 61], [13, 71], [13, 76], [13, 79], [13, 80], [13, 82], [13, 86], [13, 88], [13, 90], [13, 97], [13, 98], [13, 99], [13, 104], [13, 107], [13, 111], [13, 112], [13, 114], [13, 120], [13, 127], [13, 128], [13, 132], [13, 134], [13, 141], [13, 144], [13, 155], [13, 162], [13, 165], [13, 166], [13, 167], [13, 172], [13, 178], [14, 20], [14, 22], [14, 24], [14, 27], [14, 30], [14, 33], [14, 36], [14, 52], [14, 57], [14, 61], [14, 64], [14, 66], [14, 68], [14, 70], [14, 71], [14, 77], [14, 85], [14, 86], [14, 89], [14, 95], [14, 96], [14, 100], [14, 105], [14, 107], [14, 109], [14, 117], [14, 130], [14, 134], [14, 138], [14, 141], [14, 142], [14, 144], [14, 146], [14, 149], [14, 151], [14, 153], [14, 155], [14, 162], [14, 168], [14, 171], [14, 174], [15, 20], [15, 21], [15, 22], [15, 29], [15, 30], [15, 33], [15, 36], [15, 44], [15, 46], [15, 58], [15, 60], [15, 63], [15, 64], [15, 67], [15, 69], [15, 72], [15, 76], [15, 77], [15, 83], [15, 88], [15, 91], [15, 101], [15, 102], [15, 103], [15, 119], [15, 121], [15, 122], [15, 130], [15, 132], [15, 137], [15, 141], [15, 142], [15, 144], [15, 145], [15, 153], [15, 154], [15, 158], [15, 167], [15, 171], [15, 175], [15, 176], [16, 20], [16, 25], [16, 28], [16, 29], [16, 30], [16, 36], [16, 39], [16, 40], [16, 44], [16, 46], [16, 52], [16, 54], [16, 56], [16, 67], [16, 74], [16, 78], [16, 83], [16, 98], [16, 100], [16, 101], [16, 103], [16, 104], [16, 105], [16, 106], [16, 115], [16, 118], [16, 123], [16, 124], [16, 125], [16, 135], [16, 145], [16, 152], [16, 153], [16, 162], [16, 163], [16, 170], [16, 171], [16, 173], [16, 174], [17, 18], [17, 19], [17, 22], [17, 29], [17, 31], [17, 40], [17, 46], [17, 47], [17, 50], [17, 58], [17, 61], [17, 62], [17, 63], [17, 85], [17, 93], [17, 95], [17, 96], [17, 102], [17, 106], [17, 108], [17, 109], [17, 114], [17, 117], [17, 127], [17, 128], [17, 130], [17, 131], [17, 133], [17, 135], [17, 140], [17, 142], [17, 144], [17, 167], [17, 168], [17, 169], [17, 173], [17, 175], [17, 179], [18, 21], [18, 24], [18, 26], [18, 32], [18, 39], [18, 46], [18, 49], [18, 50], [18, 58], [18, 59], [18, 63], [18, 66], [18, 67], [18, 74], [18, 76], [18, 79], [18, 81], [18, 87], [18, 89], [18, 92], [18, 96], [18, 109], [18, 110], [18, 112], [18, 117], [18, 118], [18, 122], [18, 125], [18, 133], [18, 134], [18, 138], [18, 139], [18, 145], [18, 146], [18, 150], [18, 152], [18, 157], [18, 163], [18, 168], [18, 179], [19, 22], [19, 25], [19, 27], [19, 28], [19, 31], [19, 33], [19, 34], [19, 56], [19, 58], [19, 59], [19, 70], [19, 72], [19, 74], [19, 78], [19, 79], [19, 83], [19, 92], [19, 93], [19, 103], [19, 110], [19, 127], [19, 151], [19, 153], [19, 158], [19, 161], [19, 169], [19, 172], [20, 28], [20, 31], [20, 36], [20, 40], [20, 43], [20, 54], [20, 58], [20, 61], [20, 64], [20, 65], [20, 66], [20, 69], [20, 71], [20, 72], [20, 79], [20, 83], [20, 84], [20, 85], [20, 91], [20, 97], [20, 100], [20, 102], [20, 107], [20, 116], [20, 122], [20, 132], [20, 133], [20, 134], [20, 140], [20, 145], [20, 153], [20, 154], [20, 158], [20, 160], [20, 161], [20, 169], [20, 174], [21, 26], [21, 28], [21, 34], [21, 39], [21, 41], [21, 48], [21, 62], [21, 64], [21, 65], [21, 72], [21, 73], [21, 75], [21, 76], [21, 90], [21, 92], [21, 97], [21, 106], [21, 107], [21, 110], [21, 116], [21, 117], [21, 118], [21, 120], [21, 126], [21, 127], [21, 128], [21, 134], [21, 141], [21, 142], [21, 143], [21, 146], [21, 149], [21, 155], [21, 156], [21, 163], [21, 164], [21, 167], [21, 168], [21, 171], [21, 176], [21, 178], [21, 179], [22, 23], [22, 30], [22, 37], [22, 38], [22, 48], [22, 50], [22, 53], [22, 61], [22, 66], [22, 70], [22, 82], [22, 92], [22, 93], [22, 102], [22, 103], [22, 104], [22, 106], [22, 113], [22, 115], [22, 122], [22, 125], [22, 126], [22, 128], [22, 130], [22, 139], [22, 141], [22, 162], [22, 169], [22, 172], [23, 24], [23, 31], [23, 42], [23, 58], [23, 64], [23, 77], [23, 94], [23, 95], [23, 98], [23, 105], [23, 116], [23, 125], [23, 134], [23, 169], [23, 179], [24, 29], [24, 30], [24, 33], [24, 35], [24, 40], [24, 45], [24, 46], [24, 61], [24, 67], [24, 69], [24, 84], [24, 86], [24, 88], [24, 93], [24, 103], [24, 113], [24, 114], [24, 117], [24, 124], [24, 125], [24, 127], [24, 130], [24, 135], [24, 137], [24, 138], [24, 146], [24, 148], [24, 154], [24, 167], [24, 168], [24, 172], [24, 173], [25, 26], [25, 28], [25, 29], [25, 32], [25, 37], [25, 60], [25, 66], [25, 71], [25, 95], [25, 96], [25, 98], [25, 112], [25, 116], [25, 118], [25, 121], [25, 124], [25, 130], [25, 131], [25, 142], [25, 148], [25, 155], [25, 156], [25, 166], [25, 173], [25, 176], [26, 33], [26, 38], [26, 39], [26, 45], [26, 56], [26, 67], [26, 70], [26, 71], [26, 73], [26, 75], [26, 77], [26, 82], [26, 90], [26, 95], [26, 113], [26, 120], [26, 137], [26, 145], [26, 148], [26, 155], [26, 159], [26, 160], [26, 161], [26, 162], [26, 166], [26, 177], [27, 30], [27, 33], [27, 34], [27, 36], [27, 37], [27, 38], [27, 39], [27, 47], [27, 50], [27, 53], [27, 56], [27, 58], [27, 60], [27, 61], [27, 67], [27, 83], [27, 84], [27, 92], [27, 96], [27, 99], [27, 105], [27, 119], [27, 121], [27, 126], [27, 144], [27, 152], [27, 166], [27, 171], [28, 30], [28, 34], [28, 38], [28, 40], [28, 41], [28, 42], [28, 47], [28, 48], [28, 50], [28, 51], [28, 59], [28, 60], [28, 61], [28, 62], [28, 63], [28, 66], [28, 68], [28, 70], [28, 74], [28, 85], [28, 87], [28, 96], [28, 101], [28, 103], [28, 104], [28, 109], [28, 120], [28, 122], [28, 156], [28, 158], [28, 167], [28, 169], [28, 170], [28, 173], [28, 177], [29, 38], [29, 42], [29, 43], [29, 45], [29, 50], [29, 56], [29, 60], [29, 69], [29, 75], [29, 76], [29, 83], [29, 86], [29, 90], [29, 96], [29, 97], [29, 99], [29, 100], [29, 113], [29, 114], [29, 120], [29, 121], [29, 124], [29, 133], [29, 135], [29, 140], [29, 143], [29, 144], [29, 145], [29, 150], [29, 152], [29, 156], [29, 159], [29, 162], [29, 164], [29, 165], [29, 171], [29, 176], [29, 179], [30, 37], [30, 39], [30, 40], [30, 43], [30, 47], [30, 56], [30, 60], [30, 65], [30, 66], [30, 67], [30, 68], [30, 76], [30, 78], [30, 84], [30, 96], [30, 103], [30, 105], [30, 108], [30, 109], [30, 112], [30, 114], [30, 124], [30, 130], [30, 131], [30, 132], [30, 134], [30, 147], [30, 151], [30, 156], [30, 164], [30, 173], [30, 178], [31, 33], [31, 38], [31, 39], [31, 51], [31, 52], [31, 58], [31, 61], [31, 69], [31, 77], [31, 81], [31, 90], [31, 96], [31, 98], [31, 101], [31, 106], [31, 112], [31, 115], [31, 117], [31, 118], [31, 125], [31, 130], [31, 132], [31, 133], [31, 134], [31, 137], [31, 145], [31, 149], [31, 152], [31, 162], [31, 176], [32, 35], [32, 42], [32, 45], [32, 49], [32, 52], [32, 56], [32, 60], [32, 63], [32, 67], [32, 72], [32, 73], [32, 74], [32, 75], [32, 77], [32, 80], [32, 86], [32, 93], [32, 96], [32, 99], [32, 101], [32, 103], [32, 105], [32, 115], [32, 116], [32, 119], [32, 134], [32, 143], [32, 146], [32, 151], [32, 163], [32, 164], [32, 169], [32, 172], [32, 173], [32, 175], [33, 35], [33, 40], [33, 41], [33, 47], [33, 50], [33, 52], [33, 57], [33, 58], [33, 67], [33, 75], [33, 80], [33, 84], [33, 85], [33, 97], [33, 101], [33, 102], [33, 106], [33, 107], [33, 109], [33, 112], [33, 113], [33, 115], [33, 119], [33, 121], [33, 123], [33, 124], [33, 127], [33, 128], [33, 134], [33, 136], [33, 142], [33, 144], [33, 145], [33, 146], [33, 148], [33, 149], [33, 153], [33, 166], [33, 169], [33, 173], [33, 176], [34, 37], [34, 39], [34, 70], [34, 71], [34, 76], [34, 90], [34, 94], [34, 96], [34, 101], [34, 102], [34, 108], [34, 111], [34, 112], [34, 114], [34, 119], [34, 120], [34, 125], [34, 128], [34, 135], [34, 141], [34, 146], [34, 151], [34, 154], [34, 159], [34, 165], [34, 166], [34, 172], [34, 176], [34, 178], [35, 36], [35, 43], [35, 47], [35, 63], [35, 69], [35, 72], [35, 80], [35, 86], [35, 88], [35, 93], [35, 105], [35, 113], [35, 114], [35, 128], [35, 133], [35, 138], [35, 142], [35, 144], [35, 152], [35, 153], [35, 157], [35, 161], [35, 162], [35, 167], [36, 52], [36, 86], [36, 88], [36, 95], [36, 96], [36, 114], [36, 116], [36, 121], [36, 122], [36, 131], [36, 136], [36, 153], [36, 163], [36, 165], [36, 173], [36, 178], [37, 39], [37, 40], [37, 44], [37, 48], [37, 49], [37, 51], [37, 53], [37, 58], [37, 60], [37, 65], [37, 68], [37, 71], [37, 85], [37, 89], [37, 94], [37, 107], [37, 108], [37, 120], [37, 123], [37, 124], [37, 129], [37, 130], [37, 135], [37, 136], [37, 163], [37, 165], [37, 174], [37, 178], [38, 39], [38, 45], [38, 46], [38, 56], [38, 57], [38, 58], [38, 60], [38, 62], [38, 69], [38, 80], [38, 85], [38, 86], [38, 87], [38, 90], [38, 94], [38, 95], [38, 99], [38, 112], [38, 120], [38, 121], [38, 123], [38, 124], [38, 134], [38, 139], [38, 141], [38, 142], [38, 143], [38, 156], [38, 171], [38, 176], [38, 177], [39, 60], [39, 67], [39, 70], [39, 76], [39, 85], [39, 87], [39, 89], [39, 91], [39, 98], [39, 100], [39, 121], [39, 123], [39, 124], [39, 127], [39, 133], [39, 136], [39, 150], [39, 163], [39, 164], [39, 166], [39, 177], [40, 41], [40, 45], [40, 46], [40, 48], [40, 49], [40, 59], [40, 63], [40, 65], [40, 68], [40, 69], [40, 72], [40, 74], [40, 76], [40, 77], [40, 79], [40, 80], [40, 81], [40, 90], [40, 98], [40, 99], [40, 102], [40, 109], [40, 110], [40, 111], [40, 115], [40, 118], [40, 123], [40, 124], [40, 125], [40, 126], [40, 135], [40, 144], [40, 149], [40, 166], [40, 168], [40, 170], [40, 179], [41, 44], [41, 60], [41, 69], [41, 76], [41, 84], [41, 85], [41, 89], [41, 100], [41, 101], [41, 105], [41, 114], [41, 117], [41, 118], [41, 127], [41, 138], [41, 142], [41, 146], [41, 148], [41, 149], [41, 151], [41, 153], [41, 157], [41, 160], [41, 161], [41, 165], [41, 170], [42, 43], [42, 52], [42, 56], [42, 57], [42, 67], [42, 74], [42, 98], [42, 100], [42, 101], [42, 108], [42, 109], [42, 111], [42, 113], [42, 130], [42, 134], [42, 141], [42, 142], [42, 148], [42, 161], [42, 171], [43, 46], [43, 53], [43, 84], [43, 89], [43, 94], [43, 105], [43, 108], [43, 113], [43, 119], [43, 120], [43, 132], [43, 133], [43, 136], [43, 144], [43, 145], [43, 148], [43, 158], [43, 162], [43, 163], [43, 172], [43, 174], [43, 177], [44, 50], [44, 52], [44, 68], [44, 69], [44, 79], [44, 84], [44, 85], [44, 89], [44, 93], [44, 99], [44, 100], [44, 111], [44, 113], [44, 114], [44, 120], [44, 124], [44, 126], [44, 129], [44, 134], [44, 138], [44, 143], [44, 150], [44, 152], [44, 157], [44, 161], [44, 162], [44, 165], [44, 166], [44, 171], [44, 176], [45, 47], [45, 48], [45, 55], [45, 59], [45, 62], [45, 70], [45, 73], [45, 77], [45, 90], [45, 94], [45, 101], [45, 104], [45, 105], [45, 110], [45, 115], [45, 116], [45, 117], [45, 122], [45, 124], [45, 126], [45, 129], [45, 131], [45, 133], [45, 134], [45, 153], [45, 154], [45, 167], [45, 168], [45, 170], [45, 172], [46, 53], [46, 59], [46, 66], [46, 70], [46, 78], [46, 82], [46, 85], [46, 87], [46, 91], [46, 92], [46, 107], [46, 108], [46, 131], [46, 132], [46, 134], [46, 139], [46, 154], [46, 156], [46, 159], [46, 161], [46, 163], [46, 167], [46, 168], [46, 169], [46, 170], [46, 173], [46, 179], [47, 49], [47, 52], [47, 55], [47, 56], [47, 58], [47, 60], [47, 62], [47, 68], [47, 69], [47, 70], [47, 71], [47, 72], [47, 74], [47, 76], [47, 77], [47, 79], [47, 82], [47, 90], [47, 92], [47, 96], [47, 112], [47, 113], [47, 114], [47, 117], [47, 118], [47, 126], [47, 128], [47, 130], [47, 133], [47, 134], [47, 146], [47, 147], [47, 150], [47, 160], [47, 168], [47, 174], [47, 179], [48, 50], [48, 53], [48, 63], [48, 71], [48, 73], [48, 80], [48, 88], [48, 93], [48, 94], [48, 96], [48, 102], [48, 105], [48, 109], [48, 115], [48, 117], [48, 129], [48, 140], [48, 142], [48, 143], [48, 151], [48, 158], [48, 159], [48, 168], [48, 173], [49, 50], [49, 56], [49, 57], [49, 58], [49, 60], [49, 62], [49, 68], [49, 77], [49, 79], [49, 80], [49, 85], [49, 87], [49, 98], [49, 101], [49, 102], [49, 107], [49, 114], [49, 122], [49, 126], [49, 127], [49, 130], [49, 131], [49, 134], [49, 135], [49, 136], [49, 139], [49, 148], [49, 153], [49, 164], [49, 169], [50, 52], [50, 65], [50, 71], [50, 75], [50, 78], [50, 79], [50, 82], [50, 84], [50, 92], [50, 100], [50, 104], [50, 115], [50, 122], [50, 127], [50, 132], [50, 137], [50, 140], [50, 145], [50, 152], [50, 156], [50, 160], [50, 161], [50, 162], [50, 173], [50, 175], [51, 52], [51, 53], [51, 61], [51, 63], [51, 67], [51, 69], [51, 73], [51, 74], [51, 82], [51, 95], [51, 116], [51, 128], [51, 131], [51, 137], [51, 142], [51, 146], [51, 148], [51, 150], [51, 152], [51, 156], [51, 160], [51, 174], [52, 56], [52, 57], [52, 61], [52, 64], [52, 66], [52, 67], [52, 68], [52, 70], [52, 71], [52, 74], [52, 75], [52, 76], [52, 81], [52, 93], [52, 94], [52, 97], [52, 103], [52, 107], [52, 113], [52, 115], [52, 122], [52, 124], [52, 125], [52, 128], [52, 130], [52, 135], [52, 145], [52, 147], [52, 148], [52, 153], [52, 161], [52, 164], [52, 165], [52, 167], [52, 168], [52, 177], [52, 178], [52, 179], [53, 60], [53, 61], [53, 78], [53, 88], [53, 92], [53, 94], [53, 95], [53, 105], [53, 111], [53, 112], [53, 118], [53, 121], [53, 124], [53, 135], [53, 136], [53, 146], [53, 147], [53, 159], [53, 166], [53, 174], [53, 175], [53, 179], [54, 56], [54, 57], [54, 58], [54, 62], [54, 65], [54, 79], [54, 82], [54, 83], [54, 84], [54, 85], [54, 87], [54, 89], [54, 92], [54, 104], [54, 105], [54, 111], [54, 112], [54, 118], [54, 128], [54, 132], [54, 145], [54, 147], [54, 158], [54, 159], [54, 178], [54, 179], [55, 56], [55, 63], [55, 77], [55, 81], [55, 87], [55, 88], [55, 90], [55, 92], [55, 93], [55, 96], [55, 97], [55, 101], [55, 107], [55, 114], [55, 125], [55, 127], [55, 130], [55, 132], [55, 141], [55, 146], [55, 152], [55, 154], [55, 156], [55, 157], [55, 163], [55, 164], [55, 167], [55, 168], [56, 58], [56, 67], [56, 68], [56, 71], [56, 72], [56, 75], [56, 76], [56, 80], [56, 95], [56, 117], [56, 119], [56, 121], [56, 126], [56, 131], [56, 134], [56, 149], [56, 154], [56, 156], [56, 165], [56, 176], [56, 178], [57, 58], [57, 63], [57, 64], [57, 69], [57, 80], [57, 83], [57, 87], [57, 102], [57, 116], [57, 121], [57, 123], [57, 129], [57, 141], [57, 148], [57, 152], [57, 160], [57, 163], [57, 166], [57, 168], [57, 175], [57, 177], [57, 179], [58, 60], [58, 62], [58, 64], [58, 69], [58, 72], [58, 73], [58, 77], [58, 78], [58, 80], [58, 86], [58, 91], [58, 93], [58, 102], [58, 107], [58, 110], [58, 116], [58, 120], [58, 126], [58, 129], [58, 134], [58, 138], [58, 142], [58, 143], [58, 159], [58, 169], [58, 171], [58, 172], [58, 174], [58, 179], [59, 60], [59, 61], [59, 64], [59, 67], [59, 68], [59, 71], [59, 72], [59, 75], [59, 82], [59, 83], [59, 85], [59, 86], [59, 91], [59, 100], [59, 105], [59, 111], [59, 113], [59, 120], [59, 121], [59, 129], [59, 136], [59, 142], [59, 145], [59, 152], [59, 157], [59, 168], [59, 173], [59, 174], [59, 176], [60, 61], [60, 66], [60, 68], [60, 78], [60, 81], [60, 99], [60, 103], [60, 110], [60, 130], [60, 135], [60, 136], [60, 138], [60, 144], [60, 145], [60, 153], [60, 165], [60, 167], [60, 168], [61, 68], [61, 70], [61, 91], [61, 94], [61, 97], [61, 101], [61, 102], [61, 106], [61, 115], [61, 120], [61, 121], [61, 123], [61, 127], [61, 133], [61, 139], [61, 149], [61, 151], [61, 153], [61, 158], [61, 163], [61, 164], [61, 166], [61, 173], [61, 175], [62, 63], [62, 67], [62, 69], [62, 78], [62, 81], [62, 86], [62, 90], [62, 91], [62, 98], [62, 108], [62, 112], [62, 113], [62, 121], [62, 122], [62, 124], [62, 125], [62, 127], [62, 132], [62, 138], [62, 145], [62, 150], [62, 157], [62, 168], [62, 169], [62, 171], [62, 175], [63, 67], [63, 98], [63, 120], [63, 123], [63, 124], [63, 126], [63, 130], [63, 132], [63, 133], [63, 136], [63, 150], [63, 153], [63, 154], [63, 157], [63, 161], [63, 167], [63, 175], [64, 71], [64, 77], [64, 81], [64, 84], [64, 86], [64, 91], [64, 94], [64, 106], [64, 119], [64, 130], [64, 140], [64, 143], [64, 146], [64, 153], [64, 154], [64, 155], [64, 160], [64, 162], [64, 164], [64, 165], [65, 73], [65, 79], [65, 84], [65, 101], [65, 105], [65, 108], [65, 109], [65, 114], [65, 118], [65, 120], [65, 129], [65, 133], [65, 137], [65, 139], [65, 140], [65, 145], [65, 147], [65, 152], [65, 154], [65, 158], [65, 169], [65, 174], [66, 68], [66, 78], [66, 81], [66, 83], [66, 84], [66, 85], [66, 86], [66, 88], [66, 111], [66, 115], [66, 119], [66, 122], [66, 125], [66, 129], [66, 136], [66, 143], [66, 144], [66, 146], [66, 148], [66, 155], [66, 161], [66, 163], [66, 165], [66, 170], [66, 172], [66, 176], [66, 179], [67, 71], [67, 77], [67, 90], [67, 92], [67, 95], [67, 100], [67, 105], [67, 108], [67, 109], [67, 113], [67, 117], [67, 120], [67, 123], [67, 125], [67, 126], [67, 127], [67, 130], [67, 131], [67, 152], [67, 163], [67, 164], [67, 166], [67, 168], [67, 171], [67, 176], [68, 70], [68, 78], [68, 79], [68, 81], [68, 89], [68, 91], [68, 101], [68, 103], [68, 107], [68, 108], [68, 110], [68, 111], [68, 123], [68, 124], [68, 127], [68, 129], [68, 133], [68, 145], [68, 148], [68, 152], [68, 162], [68, 163], [68, 171], [68, 175], [69, 70], [69, 78], [69, 79], [69, 101], [69, 104], [69, 105], [69, 106], [69, 107], [69, 108], [69, 118], [69, 132], [69, 142], [69, 144], [69, 150], [69, 153], [69, 168], [69, 173], [70, 73], [70, 74], [70, 75], [70, 82], [70, 88], [70, 90], [70, 96], [70, 111], [70, 119], [70, 132], [70, 133], [70, 145], [70, 156], [70, 159], [70, 161], [70, 178], [71, 79], [71, 80], [71, 82], [71, 84], [71, 86], [71, 96], [71, 103], [71, 110], [71, 115], [71, 120], [71, 124], [71, 126], [71, 128], [71, 133], [71, 138], [71, 143], [71, 149], [71, 162], [71, 164], [71, 171], [72, 73], [72, 76], [72, 80], [72, 93], [72, 96], [72, 98], [72, 101], [72, 102], [72, 105], [72, 108], [72, 109], [72, 115], [72, 116], [72, 117], [72, 121], [72, 125], [72, 136], [72, 138], [72, 139], [72, 140], [72, 148], [72, 150], [72, 154], [72, 156], [72, 158], [72, 160], [72, 162], [72, 173], [73, 74], [73, 79], [73, 83], [73, 86], [73, 93], [73, 94], [73, 97], [73, 100], [73, 107], [73, 109], [73, 116], [73, 118], [73, 119], [73, 121], [73, 123], [73, 127], [73, 130], [73, 132], [73, 133], [73, 141], [73, 144], [73, 148], [73, 149], [73, 155], [73, 158], [73, 161], [73, 166], [73, 167], [73, 171], [73, 176], [74, 79], [74, 80], [74, 85], [74, 86], [74, 93], [74, 94], [74, 98], [74, 112], [74, 115], [74, 120], [74, 122], [74, 128], [74, 136], [74, 141], [74, 146], [74, 155], [74, 156], [74, 157], [74, 160], [74, 166], [74, 168], [74, 178], [74, 179], [75, 84], [75, 86], [75, 87], [75, 90], [75, 91], [75, 97], [75, 98], [75, 103], [75, 120], [75, 122], [75, 124], [75, 129], [75, 135], [75, 143], [75, 148], [75, 149], [75, 151], [75, 156], [75, 166], [75, 176], [76, 82], [76, 84], [76, 86], [76, 88], [76, 90], [76, 98], [76, 100], [76, 102], [76, 109], [76, 110], [76, 113], [76, 115], [76, 120], [76, 121], [76, 142], [76, 145], [76, 150], [76, 153], [76, 157], [76, 160], [76, 162], [76, 163], [76, 169], [76, 176], [76, 178], [77, 78], [77, 81], [77, 85], [77, 86], [77, 93], [77, 96], [77, 99], [77, 109], [77, 112], [77, 113], [77, 116], [77, 122], [77, 125], [77, 132], [77, 148], [77, 150], [77, 154], [77, 172], [78, 84], [78, 87], [78, 92], [78, 96], [78, 99], [78, 104], [78, 108], [78, 115], [78, 124], [78, 129], [78, 142], [78, 146], [78, 147], [78, 169], [78, 171], [79, 89], [79, 90], [79, 94], [79, 96], [79, 108], [79, 109], [79, 115], [79, 116], [79, 121], [79, 122], [79, 133], [79, 135], [79, 147], [79, 161], [79, 167], [80, 81], [80, 86], [80, 93], [80, 100], [80, 102], [80, 103], [80, 105], [80, 107], [80, 110], [80, 122], [80, 127], [80, 152], [80, 153], [80, 156], [80, 162], [80, 163], [80, 168], [80, 169], [80, 177], [81, 84], [81, 86], [81, 87], [81, 89], [81, 102], [81, 105], [81, 115], [81, 117], [81, 121], [81, 125], [81, 132], [81, 135], [81, 137], [81, 138], [81, 148], [81, 149], [81, 156], [81, 160], [81, 165], [81, 168], [81, 170], [81, 178], [82, 96], [82, 97], [82, 100], [82, 104], [82, 107], [82, 108], [82, 110], [82, 126], [82, 146], [82, 149], [82, 150], [82, 151], [82, 155], [82, 160], [82, 161], [82, 162], [82, 164], [82, 166], [82, 169], [82, 170], [82, 172], [83, 84], [83, 91], [83, 93], [83, 95], [83, 106], [83, 109], [83, 117], [83, 118], [83, 119], [83, 122], [83, 129], [83, 131], [83, 138], [83, 147], [83, 148], [83, 151], [83, 168], [83, 174], [84, 86], [84, 92], [84, 93], [84, 102], [84, 104], [84, 107], [84, 114], [84, 115], [84, 129], [84, 138], [84, 144], [84, 157], [84, 159], [84, 162], [84, 168], [84, 178], [85, 86], [85, 89], [85, 91], [85, 92], [85, 95], [85, 101], [85, 107], [85, 110], [85, 121], [85, 152], [85, 153], [85, 167], [85, 169], [85, 174], [85, 179], [86, 88], [86, 92], [86, 97], [86, 103], [86, 107], [86, 108], [86, 112], [86, 115], [86, 119], [86, 126], [86, 146], [86, 152], [86, 155], [86, 159], [86, 161], [86, 166], [86, 169], [86, 172], [86, 176], [87, 103], [87, 120], [87, 121], [87, 122], [87, 125], [87, 137], [87, 141], [87, 145], [87, 147], [87, 148], [87, 156], [87, 162], [87, 168], [87, 171], [87, 173], [87, 177], [87, 178], [88, 93], [88, 96], [88, 97], [88, 99], [88, 103], [88, 113], [88, 121], [88, 122], [88, 135], [88, 136], [88, 140], [88, 142], [88, 143], [88, 144], [88, 153], [88, 158], [88, 162], [88, 166], [88, 167], [88, 169], [88, 172], [88, 179], [89, 94], [89, 95], [89, 96], [89, 102], [89, 103], [89, 115], [89, 118], [89, 122], [89, 125], [89, 126], [89, 133], [89, 147], [89, 150], [89, 157], [89, 168], [89, 172], [89, 176], [90, 99], [90, 103], [90, 105], [90, 109], [90, 111], [90, 124], [90, 131], [90, 135], [90, 145], [90, 149], [90, 153], [90, 156], [90, 157], [90, 167], [90, 170], [90, 176], [90, 179], [91, 92], [91, 94], [91, 95], [91, 96], [91, 105], [91, 106], [91, 114], [91, 119], [91, 121], [91, 130], [91, 131], [91, 136], [91, 142], [91, 144], [91, 155], [91, 156], [91, 157], [91, 159], [91, 171], [91, 175], [92, 95], [92, 96], [92, 97], [92, 101], [92, 102], [92, 110], [92, 112], [92, 116], [92, 129], [92, 131], [92, 132], [92, 135], [92, 138], [92, 139], [92, 140], [92, 143], [92, 144], [92, 158], [92, 159], [92, 160], [92, 161], [92, 162], [92, 168], [92, 172], [92, 174], [93, 96], [93, 99], [93, 104], [93, 106], [93, 109], [93, 114], [93, 118], [93, 122], [93, 127], [93, 133], [93, 137], [93, 139], [93, 143], [93, 150], [93, 161], [93, 164], [93, 165], [93, 169], [93, 171], [94, 97], [94, 106], [94, 110], [94, 113], [94, 120], [94, 123], [94, 133], [94, 140], [94, 143], [94, 146], [94, 151], [94, 162], [94, 164], [94, 165], [94, 168], [94, 171], [94, 174], [94, 176], [94, 178], [95, 96], [95, 100], [95, 102], [95, 105], [95, 107], [95, 113], [95, 116], [95, 119], [95, 129], [95, 142], [95, 143], [95, 145], [95, 146], [95, 148], [95, 150], [95, 156], [95, 157], [95, 162], [95, 170], [95, 175], [95, 176], [96, 102], [96, 103], [96, 104], [96, 106], [96, 111], [96, 122], [96, 124], [96, 132], [96, 137], [96, 140], [96, 141], [96, 154], [96, 156], [96, 157], [96, 166], [96, 168], [96, 174], [96, 176], [97, 99], [97, 105], [97, 107], [97, 110], [97, 113], [97, 119], [97, 120], [97, 121], [97, 123], [97, 125], [97, 131], [97, 136], [97, 144], [97, 146], [97, 159], [97, 163], [97, 172], [98, 104], [98, 108], [98, 110], [98, 111], [98, 112], [98, 119], [98, 120], [98, 125], [98, 136], [98, 142], [98, 161], [98, 163], [98, 168], [98, 170], [98, 172], [99, 102], [99, 106], [99, 115], [99, 116], [99, 130], [99, 131], [99, 144], [99, 145], [99, 151], [99, 161], [99, 162], [99, 171], [100, 101], [100, 105], [100, 108], [100, 110], [100, 125], [100, 127], [100, 129], [100, 135], [100, 141], [100, 145], [100, 150], [100, 153], [100, 165], [100, 167], [101, 118], [101, 127], [101, 134], [101, 136], [101, 141], [101, 142], [101, 148], [101, 152], [101, 153], [101, 155], [101, 158], [101, 165], [101, 170], [101, 177], [101, 179], [102, 103], [102, 117], [102, 124], [102, 128], [102, 130], [102, 133], [102, 134], [102, 141], [102, 142], [102, 147], [102, 154], [102, 156], [102, 164], [103, 106], [103, 107], [103, 108], [103, 109], [103, 119], [103, 121], [103, 132], [103, 134], [103, 140], [103, 145], [103, 150], [103, 151], [103, 153], [103, 154], [103, 155], [103, 158], [103, 159], [103, 161], [103, 162], [103, 173], [103, 174], [104, 106], [104, 115], [104, 116], [104, 129], [104, 133], [104, 136], [104, 142], [104, 148], [104, 152], [104, 154], [104, 157], [104, 158], [104, 167], [105, 106], [105, 108], [105, 123], [105, 124], [105, 125], [105, 126], [105, 128], [105, 129], [105, 132], [105, 134], [105, 150], [105, 151], [105, 157], [105, 161], [105, 164], [105, 178], [106, 107], [106, 118], [106, 122], [106, 123], [106, 125], [106, 126], [106, 130], [106, 132], [106, 134], [106, 137], [106, 154], [106, 159], [106, 163], [106, 168], [106, 173], [106, 178], [106, 179], [107, 108], [107, 115], [107, 116], [107, 125], [107, 127], [107, 128], [107, 139], [107, 140], [107, 141], [107, 147], [107, 151], [107, 152], [107, 164], [107, 165], [107, 170], [107, 171], [107, 175], [108, 113], [108, 119], [108, 123], [108, 125], [108, 134], [108, 157], [108, 166], [108, 170], [108, 173], [108, 176], [108, 177], [109, 115], [109, 116], [109, 117], [109, 118], [109, 121], [109, 123], [109, 124], [109, 132], [109, 140], [109, 141], [109, 142], [109, 146], [109, 147], [109, 148], [109, 150], [109, 152], [109, 154], [109, 156], [109, 164], [109, 169], [110, 112], [110, 113], [110, 115], [110, 117], [110, 120], [110, 121], [110, 123], [110, 125], [110, 129], [110, 130], [110, 131], [110, 134], [110, 136], [110, 137], [110, 139], [110, 143], [110, 144], [110, 149], [110, 152], [110, 153], [110, 159], [110, 162], [110, 166], [110, 173], [111, 116], [111, 118], [111, 122], [111, 124], [111, 127], [111, 130], [111, 135], [111, 139], [111, 140], [111, 141], [111, 142], [111, 143], [111, 144], [111, 145], [111, 148], [111, 149], [111, 154], [111, 156], [111, 163], [111, 165], [111, 173], [111, 176], [112, 121], [112, 125], [112, 127], [112, 131], [112, 138], [112, 143], [112, 159], [112, 171], [112, 176], [112, 178], [112, 179], [113, 114], [113, 123], [113, 126], [113, 129], [113, 132], [113, 137], [113, 146], [113, 149], [113, 150], [113, 161], [113, 162], [113, 165], [113, 176], [113, 179], [114, 121], [114, 133], [114, 135], [114, 139], [114, 140], [114, 160], [114, 164], [114, 177], [114, 178], [115, 121], [115, 127], [115, 133], [115, 136], [115, 148], [115, 154], [115, 158], [115, 161], [115, 172], [116, 121], [116, 124], [116, 126], [116, 133], [116, 140], [116, 147], [116, 149], [116, 151], [116, 153], [116, 157], [116, 163], [116, 167], [116, 169], [116, 170], [116, 171], [117, 119], [117, 122], [117, 123], [117, 131], [117, 138], [117, 139], [117, 143], [117, 149], [117, 153], [117, 163], [117, 170], [117, 175], [118, 120], [118, 123], [118, 124], [118, 127], [118, 139], [118, 143], [118, 145], [118, 146], [118, 148], [118, 149], [118, 152], [118, 158], [118, 166], [118, 178], [118, 179], [119, 123], [119, 127], [119, 132], [119, 138], [119, 139], [119, 140], [119, 146], [119, 152], [119, 158], [119, 163], [119, 165], [119, 170], [119, 172], [119, 173], [119, 175], [120, 124], [120, 129], [120, 132], [120, 136], [120, 145], [120, 146], [120, 152], [120, 156], [120, 164], [120, 167], [120, 175], [120, 179], [121, 123], [121, 128], [121, 129], [121, 133], [121, 137], [121, 141], [121, 142], [121, 144], [121, 146], [121, 148], [121, 151], [121, 154], [121, 156], [121, 170], [121, 173], [122, 127], [122, 129], [122, 142], [122, 143], [122, 145], [122, 153], [122, 156], [122, 157], [122, 158], [122, 160], [122, 163], [122, 164], [122, 165], [122, 171], [122, 173], [123, 127], [123, 128], [123, 139], [123, 143], [123, 150], [123, 152], [123, 162], [123, 167], [123, 170], [123, 176], [123, 179], [124, 126], [124, 131], [124, 144], [124, 146], [124, 162], [124, 166], [124, 167], [124, 171], [124, 179], [125, 132], [125, 139], [125, 143], [125, 146], [125, 147], [125, 156], [125, 157], [125, 159], [125, 161], [125, 162], [125, 166], [125, 169], [125, 170], [125, 177], [125, 178], [126, 129], [126, 133], [126, 134], [126, 136], [126, 142], [126, 143], [126, 144], [126, 146], [126, 148], [126, 149], [126, 151], [126, 155], [126, 160], [126, 161], [126, 165], [126, 170], [126, 172], [126, 173], [127, 133], [127, 135], [127, 143], [127, 147], [127, 148], [127, 150], [127, 156], [127, 164], [127, 167], [127, 172], [127, 177], [128, 132], [128, 140], [128, 141], [128, 143], [128, 150], [128, 159], [128, 164], [128, 166], [128, 173], [129, 134], [129, 142], [129, 146], [129, 148], [129, 149], [129, 151], [129, 153], [129, 158], [129, 161], [129, 166], [129, 172], [129, 177], [129, 178], [130, 133], [130, 136], [130, 142], [130, 143], [130, 144], [130, 146], [130, 152], [130, 153], [130, 170], [130, 176], [131, 136], [131, 139], [131, 150], [131, 158], [131, 159], [131, 170], [131, 173], [131, 174], [131, 178], [132, 133], [132, 136], [132, 143], [132, 145], [132, 148], [132, 151], [132, 153], [132, 155], [132, 157], [132, 173], [132, 177], [133, 136], [133, 139], [133, 146], [133, 147], [133, 149], [133, 151], [133, 153], [133, 170], [133, 177], [133, 179], [134, 149], [134, 155], [134, 156], [134, 161], [134, 166], [134, 168], [134, 171], [134, 173], [134, 176], [134, 179], [135, 138], [135, 146], [135, 150], [135, 154], [135, 158], [135, 161], [135, 165], [135, 166], [135, 167], [135, 171], [136, 139], [136, 140], [136, 141], [136, 142], [136, 144], [136, 153], [136, 154], [136, 159], [136, 171], [136, 174], [137, 143], [137, 147], [137, 148], [137, 151], [137, 157], [137, 164], [138, 148], [138, 155], [138, 156], [138, 162], [138, 163], [138, 166], [138, 174], [138, 176], [139, 141], [139, 142], [139, 147], [139, 149], [139, 160], [139, 163], [139, 167], [139, 171], [139, 172], [139, 174], [139, 177], [140, 142], [140, 144], [140, 146], [140, 154], [140, 155], [140, 157], [140, 165], [140, 166], [140, 169], [140, 177], [141, 144], [141, 146], [141, 150], [141, 153], [141, 156], [141, 179], [142, 144], [142, 148], [142, 149], [142, 153], [142, 155], [142, 157], [142, 159], [142, 160], [142, 161], [142, 162], [142, 163], [142, 166], [142, 168], [142, 171], [142, 178], [143, 151], [143, 153], [143, 156], [143, 164], [143, 166], [143, 167], [143, 170], [143, 173], [144, 154], [144, 156], [144, 168], [144, 172], [144, 177], [144, 178], [145, 146], [145, 154], [145, 158], [145, 165], [145, 170], [146, 148], [146, 152], [146, 154], [146, 160], [146, 161], [146, 165], [146, 169], [146, 172], [146, 174], [146, 176], [147, 150], [147, 153], [147, 155], [147, 159], [147, 160], [147, 166], [147, 168], [147, 170], [147, 171], [148, 151], [148, 152], [148, 155], [148, 160], [148, 161], [148, 162], [148, 165], [148, 168], [148, 170], [148, 173], [148, 174], [148, 178], [149, 152], [149, 153], [149, 159], [149, 160], [149, 164], [149, 167], [149, 168], [149, 169], [149, 172], [149, 173], [149, 176], [150, 153], [150, 163], [150, 164], [150, 167], [150, 171], [150, 174], [150, 178], [150, 179], [151, 153], [151, 161], [151, 163], [151, 169], [151, 170], [151, 177], [151, 178], [151, 179], [152, 153], [152, 163], [152, 168], [152, 170], [152, 176], [153, 161], [153, 162], [153, 163], [153, 169], [153, 174], [153, 175], [153, 179], [154, 159], [154, 160], [154, 161], [154, 168], [154, 176], [154, 177], [154, 179], [155, 158], [155, 174], [156, 157], [156, 161], [156, 162], [156, 164], [156, 166], [156, 168], [156, 170], [156, 171], [156, 172], [157, 159], [157, 160], [157, 166], [157, 168], [157, 179], [158, 160], [158, 166], [158, 168], [158, 176], [158, 177], [159, 168], [159, 173], [159, 179], [160, 161], [160, 165], [160, 174], [160, 179], [161, 164], [161, 174], [162, 172], [162, 174], [162, 177], [162, 179], [163, 171], [163, 174], [163, 176], [163, 179], [164, 168], [164, 171], [164, 173], [165, 166], [165, 167], [165, 169], [165, 174], [165, 178], [166, 174], [167, 168], [167, 177], [168, 169], [168, 175], [168, 177], [170, 176], [171, 176], [172, 174], [173, 175], [173, 178], [174, 175], [175, 176], [175, 177], [175, 178], [176, 177], [176, 178], [176, 179]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l5-s1/solution/solve.sh b/tasks/construct-nppc-dominating-set-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..178e8242193503c18065ab17f64764f5d7ebcbfa --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [13, 58, 65, 67, 68, 86, 96, 119, 122, 125, 146, 148, 153, 156, 168]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l5-s1/tests/check.py b/tasks/construct-nppc-dominating-set-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s1/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-l5-s1/tests/instance.json b/tasks/construct-nppc-dominating-set-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..327e39556b4d07535f3fb939c17bb2725a549e7e --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 180, "k": 15, "edges": [[0, 16], [0, 20], [0, 25], [0, 26], [0, 35], [0, 38], [0, 41], [0, 42], [0, 60], [0, 65], [0, 69], [0, 71], [0, 80], [0, 87], [0, 92], [0, 97], [0, 102], [0, 105], [0, 106], [0, 110], [0, 111], [0, 116], [0, 118], [0, 126], [0, 128], [0, 134], [0, 139], [0, 143], [0, 150], [0, 158], [0, 162], [0, 175], [0, 179], [1, 5], [1, 9], [1, 16], [1, 18], [1, 20], [1, 21], [1, 23], [1, 25], [1, 39], [1, 51], [1, 62], [1, 63], [1, 65], [1, 67], [1, 75], [1, 81], [1, 82], [1, 83], [1, 105], [1, 107], [1, 108], [1, 111], [1, 125], [1, 136], [1, 138], [1, 148], [1, 149], [1, 165], [1, 166], [1, 172], [1, 178], [1, 179], [2, 7], [2, 8], [2, 20], [2, 23], [2, 28], [2, 29], [2, 33], [2, 35], [2, 39], [2, 40], [2, 45], [2, 50], [2, 54], [2, 56], [2, 57], [2, 63], [2, 64], [2, 76], [2, 78], [2, 80], [2, 84], [2, 86], [2, 90], [2, 91], [2, 93], [2, 99], [2, 111], [2, 117], [2, 121], [2, 124], [2, 125], [2, 126], [2, 127], [2, 130], [2, 139], [2, 140], [2, 143], [2, 144], [2, 154], [2, 155], [2, 157], [2, 162], [2, 170], [2, 171], [2, 176], [2, 177], [2, 179], [3, 12], [3, 15], [3, 23], [3, 24], [3, 26], [3, 47], [3, 51], [3, 60], [3, 63], [3, 75], [3, 87], [3, 89], [3, 93], [3, 101], [3, 103], [3, 106], [3, 109], [3, 112], [3, 115], [3, 119], [3, 122], [3, 137], [3, 140], [3, 148], [3, 150], [3, 152], [3, 153], [3, 154], [3, 167], [3, 168], [3, 169], [3, 174], [3, 175], [4, 7], [4, 8], [4, 11], [4, 14], [4, 16], [4, 18], [4, 25], [4, 35], [4, 48], [4, 51], [4, 54], [4, 56], [4, 58], [4, 61], [4, 68], [4, 71], [4, 76], [4, 77], [4, 86], [4, 89], [4, 93], [4, 99], [4, 107], [4, 113], [4, 114], [4, 116], [4, 125], [4, 129], [4, 131], [4, 135], [4, 142], [4, 150], [4, 152], [4, 157], [4, 158], [4, 165], [4, 167], [4, 178], [5, 8], [5, 9], [5, 19], [5, 26], [5, 33], [5, 51], [5, 54], [5, 56], [5, 58], [5, 61], [5, 66], [5, 72], [5, 81], [5, 83], [5, 85], [5, 90], [5, 94], [5, 102], [5, 125], [5, 127], [5, 129], [5, 136], [5, 137], [5, 142], [5, 145], [5, 146], [5, 150], [5, 153], [5, 164], [5, 165], [5, 178], [6, 9], [6, 10], [6, 16], [6, 22], [6, 23], [6, 27], [6, 31], [6, 32], [6, 35], [6, 39], [6, 46], [6, 49], [6, 57], [6, 66], [6, 68], [6, 72], [6, 73], [6, 74], [6, 84], [6, 86], [6, 88], [6, 95], [6, 98], [6, 116], [6, 118], [6, 119], [6, 121], [6, 128], [6, 130], [6, 132], [6, 135], [6, 137], [6, 140], [6, 145], [6, 146], [6, 151], [6, 160], [6, 168], [6, 173], [6, 175], [7, 8], [7, 12], [7, 15], [7, 19], [7, 20], [7, 21], [7, 23], [7, 26], [7, 27], [7, 28], [7, 30], [7, 38], [7, 41], [7, 54], [7, 57], [7, 58], [7, 66], [7, 68], [7, 73], [7, 75], [7, 80], [7, 82], [7, 90], [7, 93], [7, 94], [7, 96], [7, 122], [7, 123], [7, 124], [7, 125], [7, 148], [7, 155], [7, 161], [7, 170], [8, 9], [8, 11], [8, 20], [8, 22], [8, 30], [8, 34], [8, 36], [8, 37], [8, 39], [8, 40], [8, 42], [8, 65], [8, 67], [8, 73], [8, 78], [8, 81], [8, 92], [8, 97], [8, 98], [8, 109], [8, 115], [8, 121], [8, 125], [8, 129], [8, 145], [8, 149], [8, 156], [8, 163], [8, 168], [8, 169], [8, 172], [8, 174], [8, 176], [8, 178], [9, 18], [9, 19], [9, 22], [9, 23], [9, 26], [9, 27], [9, 31], [9, 32], [9, 45], [9, 46], [9, 50], [9, 55], [9, 65], [9, 66], [9, 70], [9, 73], [9, 75], [9, 79], [9, 84], [9, 94], [9, 95], [9, 106], [9, 112], [9, 116], [9, 118], [9, 142], [9, 146], [9, 148], [9, 159], [9, 168], [10, 12], [10, 13], [10, 16], [10, 19], [10, 25], [10, 27], [10, 31], [10, 43], [10, 50], [10, 57], [10, 58], [10, 62], [10, 66], [10, 80], [10, 85], [10, 86], [10, 97], [10, 98], [10, 100], [10, 105], [10, 122], [10, 139], [10, 142], [10, 145], [10, 156], [10, 157], [10, 166], [10, 169], [10, 173], [10, 174], [10, 178], [10, 179], [11, 19], [11, 21], [11, 23], [11, 28], [11, 32], [11, 34], [11, 38], [11, 44], [11, 56], [11, 58], [11, 62], [11, 66], [11, 71], [11, 74], [11, 76], [11, 77], [11, 84], [11, 85], [11, 99], [11, 104], [11, 107], [11, 113], [11, 122], [11, 123], [11, 125], [11, 135], [11, 137], [11, 139], [11, 140], [11, 149], [11, 153], [11, 154], [11, 162], [11, 163], [11, 168], [11, 169], [11, 175], [12, 17], [12, 18], [12, 27], [12, 31], [12, 34], [12, 38], [12, 44], [12, 47], [12, 50], [12, 51], [12, 55], [12, 59], [12, 69], [12, 72], [12, 76], [12, 77], [12, 83], [12, 90], [12, 91], [12, 93], [12, 94], [12, 99], [12, 111], [12, 122], [12, 125], [12, 130], [12, 134], [12, 135], [12, 141], [12, 142], [12, 145], [12, 146], [12, 147], [12, 148], [12, 156], [12, 157], [12, 164], [12, 166], [12, 176], [13, 18], [13, 30], [13, 33], [13, 37], [13, 47], [13, 49], [13, 50], [13, 61], [13, 71], [13, 76], [13, 79], [13, 80], [13, 82], [13, 86], [13, 88], [13, 90], [13, 97], [13, 98], [13, 99], [13, 104], [13, 107], [13, 111], [13, 112], [13, 114], [13, 120], [13, 127], [13, 128], [13, 132], [13, 134], [13, 141], [13, 144], [13, 155], [13, 162], [13, 165], [13, 166], [13, 167], [13, 172], [13, 178], [14, 20], [14, 22], [14, 24], [14, 27], [14, 30], [14, 33], [14, 36], [14, 52], [14, 57], [14, 61], [14, 64], [14, 66], [14, 68], [14, 70], [14, 71], [14, 77], [14, 85], [14, 86], [14, 89], [14, 95], [14, 96], [14, 100], [14, 105], [14, 107], [14, 109], [14, 117], [14, 130], [14, 134], [14, 138], [14, 141], [14, 142], [14, 144], [14, 146], [14, 149], [14, 151], [14, 153], [14, 155], [14, 162], [14, 168], [14, 171], [14, 174], [15, 20], [15, 21], [15, 22], [15, 29], [15, 30], [15, 33], [15, 36], [15, 44], [15, 46], [15, 58], [15, 60], [15, 63], [15, 64], [15, 67], [15, 69], [15, 72], [15, 76], [15, 77], [15, 83], [15, 88], [15, 91], [15, 101], [15, 102], [15, 103], [15, 119], [15, 121], [15, 122], [15, 130], [15, 132], [15, 137], [15, 141], [15, 142], [15, 144], [15, 145], [15, 153], [15, 154], [15, 158], [15, 167], [15, 171], [15, 175], [15, 176], [16, 20], [16, 25], [16, 28], [16, 29], [16, 30], [16, 36], [16, 39], [16, 40], [16, 44], [16, 46], [16, 52], [16, 54], [16, 56], [16, 67], [16, 74], [16, 78], [16, 83], [16, 98], [16, 100], [16, 101], [16, 103], [16, 104], [16, 105], [16, 106], [16, 115], [16, 118], [16, 123], [16, 124], [16, 125], [16, 135], [16, 145], [16, 152], [16, 153], [16, 162], [16, 163], [16, 170], [16, 171], [16, 173], [16, 174], [17, 18], [17, 19], [17, 22], [17, 29], [17, 31], [17, 40], [17, 46], [17, 47], [17, 50], [17, 58], [17, 61], [17, 62], [17, 63], [17, 85], [17, 93], [17, 95], [17, 96], [17, 102], [17, 106], [17, 108], [17, 109], [17, 114], [17, 117], [17, 127], [17, 128], [17, 130], [17, 131], [17, 133], [17, 135], [17, 140], [17, 142], [17, 144], [17, 167], [17, 168], [17, 169], [17, 173], [17, 175], [17, 179], [18, 21], [18, 24], [18, 26], [18, 32], [18, 39], [18, 46], [18, 49], [18, 50], [18, 58], [18, 59], [18, 63], [18, 66], [18, 67], [18, 74], [18, 76], [18, 79], [18, 81], [18, 87], [18, 89], [18, 92], [18, 96], [18, 109], [18, 110], [18, 112], [18, 117], [18, 118], [18, 122], [18, 125], [18, 133], [18, 134], [18, 138], [18, 139], [18, 145], [18, 146], [18, 150], [18, 152], [18, 157], [18, 163], [18, 168], [18, 179], [19, 22], [19, 25], [19, 27], [19, 28], [19, 31], [19, 33], [19, 34], [19, 56], [19, 58], [19, 59], [19, 70], [19, 72], [19, 74], [19, 78], [19, 79], [19, 83], [19, 92], [19, 93], [19, 103], [19, 110], [19, 127], [19, 151], [19, 153], [19, 158], [19, 161], [19, 169], [19, 172], [20, 28], [20, 31], [20, 36], [20, 40], [20, 43], [20, 54], [20, 58], [20, 61], [20, 64], [20, 65], [20, 66], [20, 69], [20, 71], [20, 72], [20, 79], [20, 83], [20, 84], [20, 85], [20, 91], [20, 97], [20, 100], [20, 102], [20, 107], [20, 116], [20, 122], [20, 132], [20, 133], [20, 134], [20, 140], [20, 145], [20, 153], [20, 154], [20, 158], [20, 160], [20, 161], [20, 169], [20, 174], [21, 26], [21, 28], [21, 34], [21, 39], [21, 41], [21, 48], [21, 62], [21, 64], [21, 65], [21, 72], [21, 73], [21, 75], [21, 76], [21, 90], [21, 92], [21, 97], [21, 106], [21, 107], [21, 110], [21, 116], [21, 117], [21, 118], [21, 120], [21, 126], [21, 127], [21, 128], [21, 134], [21, 141], [21, 142], [21, 143], [21, 146], [21, 149], [21, 155], [21, 156], [21, 163], [21, 164], [21, 167], [21, 168], [21, 171], [21, 176], [21, 178], [21, 179], [22, 23], [22, 30], [22, 37], [22, 38], [22, 48], [22, 50], [22, 53], [22, 61], [22, 66], [22, 70], [22, 82], [22, 92], [22, 93], [22, 102], [22, 103], [22, 104], [22, 106], [22, 113], [22, 115], [22, 122], [22, 125], [22, 126], [22, 128], [22, 130], [22, 139], [22, 141], [22, 162], [22, 169], [22, 172], [23, 24], [23, 31], [23, 42], [23, 58], [23, 64], [23, 77], [23, 94], [23, 95], [23, 98], [23, 105], [23, 116], [23, 125], [23, 134], [23, 169], [23, 179], [24, 29], [24, 30], [24, 33], [24, 35], [24, 40], [24, 45], [24, 46], [24, 61], [24, 67], [24, 69], [24, 84], [24, 86], [24, 88], [24, 93], [24, 103], [24, 113], [24, 114], [24, 117], [24, 124], [24, 125], [24, 127], [24, 130], [24, 135], [24, 137], [24, 138], [24, 146], [24, 148], [24, 154], [24, 167], [24, 168], [24, 172], [24, 173], [25, 26], [25, 28], [25, 29], [25, 32], [25, 37], [25, 60], [25, 66], [25, 71], [25, 95], [25, 96], [25, 98], [25, 112], [25, 116], [25, 118], [25, 121], [25, 124], [25, 130], [25, 131], [25, 142], [25, 148], [25, 155], [25, 156], [25, 166], [25, 173], [25, 176], [26, 33], [26, 38], [26, 39], [26, 45], [26, 56], [26, 67], [26, 70], [26, 71], [26, 73], [26, 75], [26, 77], [26, 82], [26, 90], [26, 95], [26, 113], [26, 120], [26, 137], [26, 145], [26, 148], [26, 155], [26, 159], [26, 160], [26, 161], [26, 162], [26, 166], [26, 177], [27, 30], [27, 33], [27, 34], [27, 36], [27, 37], [27, 38], [27, 39], [27, 47], [27, 50], [27, 53], [27, 56], [27, 58], [27, 60], [27, 61], [27, 67], [27, 83], [27, 84], [27, 92], [27, 96], [27, 99], [27, 105], [27, 119], [27, 121], [27, 126], [27, 144], [27, 152], [27, 166], [27, 171], [28, 30], [28, 34], [28, 38], [28, 40], [28, 41], [28, 42], [28, 47], [28, 48], [28, 50], [28, 51], [28, 59], [28, 60], [28, 61], [28, 62], [28, 63], [28, 66], [28, 68], [28, 70], [28, 74], [28, 85], [28, 87], [28, 96], [28, 101], [28, 103], [28, 104], [28, 109], [28, 120], [28, 122], [28, 156], [28, 158], [28, 167], [28, 169], [28, 170], [28, 173], [28, 177], [29, 38], [29, 42], [29, 43], [29, 45], [29, 50], [29, 56], [29, 60], [29, 69], [29, 75], [29, 76], [29, 83], [29, 86], [29, 90], [29, 96], [29, 97], [29, 99], [29, 100], [29, 113], [29, 114], [29, 120], [29, 121], [29, 124], [29, 133], [29, 135], [29, 140], [29, 143], [29, 144], [29, 145], [29, 150], [29, 152], [29, 156], [29, 159], [29, 162], [29, 164], [29, 165], [29, 171], [29, 176], [29, 179], [30, 37], [30, 39], [30, 40], [30, 43], [30, 47], [30, 56], [30, 60], [30, 65], [30, 66], [30, 67], [30, 68], [30, 76], [30, 78], [30, 84], [30, 96], [30, 103], [30, 105], [30, 108], [30, 109], [30, 112], [30, 114], [30, 124], [30, 130], [30, 131], [30, 132], [30, 134], [30, 147], [30, 151], [30, 156], [30, 164], [30, 173], [30, 178], [31, 33], [31, 38], [31, 39], [31, 51], [31, 52], [31, 58], [31, 61], [31, 69], [31, 77], [31, 81], [31, 90], [31, 96], [31, 98], [31, 101], [31, 106], [31, 112], [31, 115], [31, 117], [31, 118], [31, 125], [31, 130], [31, 132], [31, 133], [31, 134], [31, 137], [31, 145], [31, 149], [31, 152], [31, 162], [31, 176], [32, 35], [32, 42], [32, 45], [32, 49], [32, 52], [32, 56], [32, 60], [32, 63], [32, 67], [32, 72], [32, 73], [32, 74], [32, 75], [32, 77], [32, 80], [32, 86], [32, 93], [32, 96], [32, 99], [32, 101], [32, 103], [32, 105], [32, 115], [32, 116], [32, 119], [32, 134], [32, 143], [32, 146], [32, 151], [32, 163], [32, 164], [32, 169], [32, 172], [32, 173], [32, 175], [33, 35], [33, 40], [33, 41], [33, 47], [33, 50], [33, 52], [33, 57], [33, 58], [33, 67], [33, 75], [33, 80], [33, 84], [33, 85], [33, 97], [33, 101], [33, 102], [33, 106], [33, 107], [33, 109], [33, 112], [33, 113], [33, 115], [33, 119], [33, 121], [33, 123], [33, 124], [33, 127], [33, 128], [33, 134], [33, 136], [33, 142], [33, 144], [33, 145], [33, 146], [33, 148], [33, 149], [33, 153], [33, 166], [33, 169], [33, 173], [33, 176], [34, 37], [34, 39], [34, 70], [34, 71], [34, 76], [34, 90], [34, 94], [34, 96], [34, 101], [34, 102], [34, 108], [34, 111], [34, 112], [34, 114], [34, 119], [34, 120], [34, 125], [34, 128], [34, 135], [34, 141], [34, 146], [34, 151], [34, 154], [34, 159], [34, 165], [34, 166], [34, 172], [34, 176], [34, 178], [35, 36], [35, 43], [35, 47], [35, 63], [35, 69], [35, 72], [35, 80], [35, 86], [35, 88], [35, 93], [35, 105], [35, 113], [35, 114], [35, 128], [35, 133], [35, 138], [35, 142], [35, 144], [35, 152], [35, 153], [35, 157], [35, 161], [35, 162], [35, 167], [36, 52], [36, 86], [36, 88], [36, 95], [36, 96], [36, 114], [36, 116], [36, 121], [36, 122], [36, 131], [36, 136], [36, 153], [36, 163], [36, 165], [36, 173], [36, 178], [37, 39], [37, 40], [37, 44], [37, 48], [37, 49], [37, 51], [37, 53], [37, 58], [37, 60], [37, 65], [37, 68], [37, 71], [37, 85], [37, 89], [37, 94], [37, 107], [37, 108], [37, 120], [37, 123], [37, 124], [37, 129], [37, 130], [37, 135], [37, 136], [37, 163], [37, 165], [37, 174], [37, 178], [38, 39], [38, 45], [38, 46], [38, 56], [38, 57], [38, 58], [38, 60], [38, 62], [38, 69], [38, 80], [38, 85], [38, 86], [38, 87], [38, 90], [38, 94], [38, 95], [38, 99], [38, 112], [38, 120], [38, 121], [38, 123], [38, 124], [38, 134], [38, 139], [38, 141], [38, 142], [38, 143], [38, 156], [38, 171], [38, 176], [38, 177], [39, 60], [39, 67], [39, 70], [39, 76], [39, 85], [39, 87], [39, 89], [39, 91], [39, 98], [39, 100], [39, 121], [39, 123], [39, 124], [39, 127], [39, 133], [39, 136], [39, 150], [39, 163], [39, 164], [39, 166], [39, 177], [40, 41], [40, 45], [40, 46], [40, 48], [40, 49], [40, 59], [40, 63], [40, 65], [40, 68], [40, 69], [40, 72], [40, 74], [40, 76], [40, 77], [40, 79], [40, 80], [40, 81], [40, 90], [40, 98], [40, 99], [40, 102], [40, 109], [40, 110], [40, 111], [40, 115], [40, 118], [40, 123], [40, 124], [40, 125], [40, 126], [40, 135], [40, 144], [40, 149], [40, 166], [40, 168], [40, 170], [40, 179], [41, 44], [41, 60], [41, 69], [41, 76], [41, 84], [41, 85], [41, 89], [41, 100], [41, 101], [41, 105], [41, 114], [41, 117], [41, 118], [41, 127], [41, 138], [41, 142], [41, 146], [41, 148], [41, 149], [41, 151], [41, 153], [41, 157], [41, 160], [41, 161], [41, 165], [41, 170], [42, 43], [42, 52], [42, 56], [42, 57], [42, 67], [42, 74], [42, 98], [42, 100], [42, 101], [42, 108], [42, 109], [42, 111], [42, 113], [42, 130], [42, 134], [42, 141], [42, 142], [42, 148], [42, 161], [42, 171], [43, 46], [43, 53], [43, 84], [43, 89], [43, 94], [43, 105], [43, 108], [43, 113], [43, 119], [43, 120], [43, 132], [43, 133], [43, 136], [43, 144], [43, 145], [43, 148], [43, 158], [43, 162], [43, 163], [43, 172], [43, 174], [43, 177], [44, 50], [44, 52], [44, 68], [44, 69], [44, 79], [44, 84], [44, 85], [44, 89], [44, 93], [44, 99], [44, 100], [44, 111], [44, 113], [44, 114], [44, 120], [44, 124], [44, 126], [44, 129], [44, 134], [44, 138], [44, 143], [44, 150], [44, 152], [44, 157], [44, 161], [44, 162], [44, 165], [44, 166], [44, 171], [44, 176], [45, 47], [45, 48], [45, 55], [45, 59], [45, 62], [45, 70], [45, 73], [45, 77], [45, 90], [45, 94], [45, 101], [45, 104], [45, 105], [45, 110], [45, 115], [45, 116], [45, 117], [45, 122], [45, 124], [45, 126], [45, 129], [45, 131], [45, 133], [45, 134], [45, 153], [45, 154], [45, 167], [45, 168], [45, 170], [45, 172], [46, 53], [46, 59], [46, 66], [46, 70], [46, 78], [46, 82], [46, 85], [46, 87], [46, 91], [46, 92], [46, 107], [46, 108], [46, 131], [46, 132], [46, 134], [46, 139], [46, 154], [46, 156], [46, 159], [46, 161], [46, 163], [46, 167], [46, 168], [46, 169], [46, 170], [46, 173], [46, 179], [47, 49], [47, 52], [47, 55], [47, 56], [47, 58], [47, 60], [47, 62], [47, 68], [47, 69], [47, 70], [47, 71], [47, 72], [47, 74], [47, 76], [47, 77], [47, 79], [47, 82], [47, 90], [47, 92], [47, 96], [47, 112], [47, 113], [47, 114], [47, 117], [47, 118], [47, 126], [47, 128], [47, 130], [47, 133], [47, 134], [47, 146], [47, 147], [47, 150], [47, 160], [47, 168], [47, 174], [47, 179], [48, 50], [48, 53], [48, 63], [48, 71], [48, 73], [48, 80], [48, 88], [48, 93], [48, 94], [48, 96], [48, 102], [48, 105], [48, 109], [48, 115], [48, 117], [48, 129], [48, 140], [48, 142], [48, 143], [48, 151], [48, 158], [48, 159], [48, 168], [48, 173], [49, 50], [49, 56], [49, 57], [49, 58], [49, 60], [49, 62], [49, 68], [49, 77], [49, 79], [49, 80], [49, 85], [49, 87], [49, 98], [49, 101], [49, 102], [49, 107], [49, 114], [49, 122], [49, 126], [49, 127], [49, 130], [49, 131], [49, 134], [49, 135], [49, 136], [49, 139], [49, 148], [49, 153], [49, 164], [49, 169], [50, 52], [50, 65], [50, 71], [50, 75], [50, 78], [50, 79], [50, 82], [50, 84], [50, 92], [50, 100], [50, 104], [50, 115], [50, 122], [50, 127], [50, 132], [50, 137], [50, 140], [50, 145], [50, 152], [50, 156], [50, 160], [50, 161], [50, 162], [50, 173], [50, 175], [51, 52], [51, 53], [51, 61], [51, 63], [51, 67], [51, 69], [51, 73], [51, 74], [51, 82], [51, 95], [51, 116], [51, 128], [51, 131], [51, 137], [51, 142], [51, 146], [51, 148], [51, 150], [51, 152], [51, 156], [51, 160], [51, 174], [52, 56], [52, 57], [52, 61], [52, 64], [52, 66], [52, 67], [52, 68], [52, 70], [52, 71], [52, 74], [52, 75], [52, 76], [52, 81], [52, 93], [52, 94], [52, 97], [52, 103], [52, 107], [52, 113], [52, 115], [52, 122], [52, 124], [52, 125], [52, 128], [52, 130], [52, 135], [52, 145], [52, 147], [52, 148], [52, 153], [52, 161], [52, 164], [52, 165], [52, 167], [52, 168], [52, 177], [52, 178], [52, 179], [53, 60], [53, 61], [53, 78], [53, 88], [53, 92], [53, 94], [53, 95], [53, 105], [53, 111], [53, 112], [53, 118], [53, 121], [53, 124], [53, 135], [53, 136], [53, 146], [53, 147], [53, 159], [53, 166], [53, 174], [53, 175], [53, 179], [54, 56], [54, 57], [54, 58], [54, 62], [54, 65], [54, 79], [54, 82], [54, 83], [54, 84], [54, 85], [54, 87], [54, 89], [54, 92], [54, 104], [54, 105], [54, 111], [54, 112], [54, 118], [54, 128], [54, 132], [54, 145], [54, 147], [54, 158], [54, 159], [54, 178], [54, 179], [55, 56], [55, 63], [55, 77], [55, 81], [55, 87], [55, 88], [55, 90], [55, 92], [55, 93], [55, 96], [55, 97], [55, 101], [55, 107], [55, 114], [55, 125], [55, 127], [55, 130], [55, 132], [55, 141], [55, 146], [55, 152], [55, 154], [55, 156], [55, 157], [55, 163], [55, 164], [55, 167], [55, 168], [56, 58], [56, 67], [56, 68], [56, 71], [56, 72], [56, 75], [56, 76], [56, 80], [56, 95], [56, 117], [56, 119], [56, 121], [56, 126], [56, 131], [56, 134], [56, 149], [56, 154], [56, 156], [56, 165], [56, 176], [56, 178], [57, 58], [57, 63], [57, 64], [57, 69], [57, 80], [57, 83], [57, 87], [57, 102], [57, 116], [57, 121], [57, 123], [57, 129], [57, 141], [57, 148], [57, 152], [57, 160], [57, 163], [57, 166], [57, 168], [57, 175], [57, 177], [57, 179], [58, 60], [58, 62], [58, 64], [58, 69], [58, 72], [58, 73], [58, 77], [58, 78], [58, 80], [58, 86], [58, 91], [58, 93], [58, 102], [58, 107], [58, 110], [58, 116], [58, 120], [58, 126], [58, 129], [58, 134], [58, 138], [58, 142], [58, 143], [58, 159], [58, 169], [58, 171], [58, 172], [58, 174], [58, 179], [59, 60], [59, 61], [59, 64], [59, 67], [59, 68], [59, 71], [59, 72], [59, 75], [59, 82], [59, 83], [59, 85], [59, 86], [59, 91], [59, 100], [59, 105], [59, 111], [59, 113], [59, 120], [59, 121], [59, 129], [59, 136], [59, 142], [59, 145], [59, 152], [59, 157], [59, 168], [59, 173], [59, 174], [59, 176], [60, 61], [60, 66], [60, 68], [60, 78], [60, 81], [60, 99], [60, 103], [60, 110], [60, 130], [60, 135], [60, 136], [60, 138], [60, 144], [60, 145], [60, 153], [60, 165], [60, 167], [60, 168], [61, 68], [61, 70], [61, 91], [61, 94], [61, 97], [61, 101], [61, 102], [61, 106], [61, 115], [61, 120], [61, 121], [61, 123], [61, 127], [61, 133], [61, 139], [61, 149], [61, 151], [61, 153], [61, 158], [61, 163], [61, 164], [61, 166], [61, 173], [61, 175], [62, 63], [62, 67], [62, 69], [62, 78], [62, 81], [62, 86], [62, 90], [62, 91], [62, 98], [62, 108], [62, 112], [62, 113], [62, 121], [62, 122], [62, 124], [62, 125], [62, 127], [62, 132], [62, 138], [62, 145], [62, 150], [62, 157], [62, 168], [62, 169], [62, 171], [62, 175], [63, 67], [63, 98], [63, 120], [63, 123], [63, 124], [63, 126], [63, 130], [63, 132], [63, 133], [63, 136], [63, 150], [63, 153], [63, 154], [63, 157], [63, 161], [63, 167], [63, 175], [64, 71], [64, 77], [64, 81], [64, 84], [64, 86], [64, 91], [64, 94], [64, 106], [64, 119], [64, 130], [64, 140], [64, 143], [64, 146], [64, 153], [64, 154], [64, 155], [64, 160], [64, 162], [64, 164], [64, 165], [65, 73], [65, 79], [65, 84], [65, 101], [65, 105], [65, 108], [65, 109], [65, 114], [65, 118], [65, 120], [65, 129], [65, 133], [65, 137], [65, 139], [65, 140], [65, 145], [65, 147], [65, 152], [65, 154], [65, 158], [65, 169], [65, 174], [66, 68], [66, 78], [66, 81], [66, 83], [66, 84], [66, 85], [66, 86], [66, 88], [66, 111], [66, 115], [66, 119], [66, 122], [66, 125], [66, 129], [66, 136], [66, 143], [66, 144], [66, 146], [66, 148], [66, 155], [66, 161], [66, 163], [66, 165], [66, 170], [66, 172], [66, 176], [66, 179], [67, 71], [67, 77], [67, 90], [67, 92], [67, 95], [67, 100], [67, 105], [67, 108], [67, 109], [67, 113], [67, 117], [67, 120], [67, 123], [67, 125], [67, 126], [67, 127], [67, 130], [67, 131], [67, 152], [67, 163], [67, 164], [67, 166], [67, 168], [67, 171], [67, 176], [68, 70], [68, 78], [68, 79], [68, 81], [68, 89], [68, 91], [68, 101], [68, 103], [68, 107], [68, 108], [68, 110], [68, 111], [68, 123], [68, 124], [68, 127], [68, 129], [68, 133], [68, 145], [68, 148], [68, 152], [68, 162], [68, 163], [68, 171], [68, 175], [69, 70], [69, 78], [69, 79], [69, 101], [69, 104], [69, 105], [69, 106], [69, 107], [69, 108], [69, 118], [69, 132], [69, 142], [69, 144], [69, 150], [69, 153], [69, 168], [69, 173], [70, 73], [70, 74], [70, 75], [70, 82], [70, 88], [70, 90], [70, 96], [70, 111], [70, 119], [70, 132], [70, 133], [70, 145], [70, 156], [70, 159], [70, 161], [70, 178], [71, 79], [71, 80], [71, 82], [71, 84], [71, 86], [71, 96], [71, 103], [71, 110], [71, 115], [71, 120], [71, 124], [71, 126], [71, 128], [71, 133], [71, 138], [71, 143], [71, 149], [71, 162], [71, 164], [71, 171], [72, 73], [72, 76], [72, 80], [72, 93], [72, 96], [72, 98], [72, 101], [72, 102], [72, 105], [72, 108], [72, 109], [72, 115], [72, 116], [72, 117], [72, 121], [72, 125], [72, 136], [72, 138], [72, 139], [72, 140], [72, 148], [72, 150], [72, 154], [72, 156], [72, 158], [72, 160], [72, 162], [72, 173], [73, 74], [73, 79], [73, 83], [73, 86], [73, 93], [73, 94], [73, 97], [73, 100], [73, 107], [73, 109], [73, 116], [73, 118], [73, 119], [73, 121], [73, 123], [73, 127], [73, 130], [73, 132], [73, 133], [73, 141], [73, 144], [73, 148], [73, 149], [73, 155], [73, 158], [73, 161], [73, 166], [73, 167], [73, 171], [73, 176], [74, 79], [74, 80], [74, 85], [74, 86], [74, 93], [74, 94], [74, 98], [74, 112], [74, 115], [74, 120], [74, 122], [74, 128], [74, 136], [74, 141], [74, 146], [74, 155], [74, 156], [74, 157], [74, 160], [74, 166], [74, 168], [74, 178], [74, 179], [75, 84], [75, 86], [75, 87], [75, 90], [75, 91], [75, 97], [75, 98], [75, 103], [75, 120], [75, 122], [75, 124], [75, 129], [75, 135], [75, 143], [75, 148], [75, 149], [75, 151], [75, 156], [75, 166], [75, 176], [76, 82], [76, 84], [76, 86], [76, 88], [76, 90], [76, 98], [76, 100], [76, 102], [76, 109], [76, 110], [76, 113], [76, 115], [76, 120], [76, 121], [76, 142], [76, 145], [76, 150], [76, 153], [76, 157], [76, 160], [76, 162], [76, 163], [76, 169], [76, 176], [76, 178], [77, 78], [77, 81], [77, 85], [77, 86], [77, 93], [77, 96], [77, 99], [77, 109], [77, 112], [77, 113], [77, 116], [77, 122], [77, 125], [77, 132], [77, 148], [77, 150], [77, 154], [77, 172], [78, 84], [78, 87], [78, 92], [78, 96], [78, 99], [78, 104], [78, 108], [78, 115], [78, 124], [78, 129], [78, 142], [78, 146], [78, 147], [78, 169], [78, 171], [79, 89], [79, 90], [79, 94], [79, 96], [79, 108], [79, 109], [79, 115], [79, 116], [79, 121], [79, 122], [79, 133], [79, 135], [79, 147], [79, 161], [79, 167], [80, 81], [80, 86], [80, 93], [80, 100], [80, 102], [80, 103], [80, 105], [80, 107], [80, 110], [80, 122], [80, 127], [80, 152], [80, 153], [80, 156], [80, 162], [80, 163], [80, 168], [80, 169], [80, 177], [81, 84], [81, 86], [81, 87], [81, 89], [81, 102], [81, 105], [81, 115], [81, 117], [81, 121], [81, 125], [81, 132], [81, 135], [81, 137], [81, 138], [81, 148], [81, 149], [81, 156], [81, 160], [81, 165], [81, 168], [81, 170], [81, 178], [82, 96], [82, 97], [82, 100], [82, 104], [82, 107], [82, 108], [82, 110], [82, 126], [82, 146], [82, 149], [82, 150], [82, 151], [82, 155], [82, 160], [82, 161], [82, 162], [82, 164], [82, 166], [82, 169], [82, 170], [82, 172], [83, 84], [83, 91], [83, 93], [83, 95], [83, 106], [83, 109], [83, 117], [83, 118], [83, 119], [83, 122], [83, 129], [83, 131], [83, 138], [83, 147], [83, 148], [83, 151], [83, 168], [83, 174], [84, 86], [84, 92], [84, 93], [84, 102], [84, 104], [84, 107], [84, 114], [84, 115], [84, 129], [84, 138], [84, 144], [84, 157], [84, 159], [84, 162], [84, 168], [84, 178], [85, 86], [85, 89], [85, 91], [85, 92], [85, 95], [85, 101], [85, 107], [85, 110], [85, 121], [85, 152], [85, 153], [85, 167], [85, 169], [85, 174], [85, 179], [86, 88], [86, 92], [86, 97], [86, 103], [86, 107], [86, 108], [86, 112], [86, 115], [86, 119], [86, 126], [86, 146], [86, 152], [86, 155], [86, 159], [86, 161], [86, 166], [86, 169], [86, 172], [86, 176], [87, 103], [87, 120], [87, 121], [87, 122], [87, 125], [87, 137], [87, 141], [87, 145], [87, 147], [87, 148], [87, 156], [87, 162], [87, 168], [87, 171], [87, 173], [87, 177], [87, 178], [88, 93], [88, 96], [88, 97], [88, 99], [88, 103], [88, 113], [88, 121], [88, 122], [88, 135], [88, 136], [88, 140], [88, 142], [88, 143], [88, 144], [88, 153], [88, 158], [88, 162], [88, 166], [88, 167], [88, 169], [88, 172], [88, 179], [89, 94], [89, 95], [89, 96], [89, 102], [89, 103], [89, 115], [89, 118], [89, 122], [89, 125], [89, 126], [89, 133], [89, 147], [89, 150], [89, 157], [89, 168], [89, 172], [89, 176], [90, 99], [90, 103], [90, 105], [90, 109], [90, 111], [90, 124], [90, 131], [90, 135], [90, 145], [90, 149], [90, 153], [90, 156], [90, 157], [90, 167], [90, 170], [90, 176], [90, 179], [91, 92], [91, 94], [91, 95], [91, 96], [91, 105], [91, 106], [91, 114], [91, 119], [91, 121], [91, 130], [91, 131], [91, 136], [91, 142], [91, 144], [91, 155], [91, 156], [91, 157], [91, 159], [91, 171], [91, 175], [92, 95], [92, 96], [92, 97], [92, 101], [92, 102], [92, 110], [92, 112], [92, 116], [92, 129], [92, 131], [92, 132], [92, 135], [92, 138], [92, 139], [92, 140], [92, 143], [92, 144], [92, 158], [92, 159], [92, 160], [92, 161], [92, 162], [92, 168], [92, 172], [92, 174], [93, 96], [93, 99], [93, 104], [93, 106], [93, 109], [93, 114], [93, 118], [93, 122], [93, 127], [93, 133], [93, 137], [93, 139], [93, 143], [93, 150], [93, 161], [93, 164], [93, 165], [93, 169], [93, 171], [94, 97], [94, 106], [94, 110], [94, 113], [94, 120], [94, 123], [94, 133], [94, 140], [94, 143], [94, 146], [94, 151], [94, 162], [94, 164], [94, 165], [94, 168], [94, 171], [94, 174], [94, 176], [94, 178], [95, 96], [95, 100], [95, 102], [95, 105], [95, 107], [95, 113], [95, 116], [95, 119], [95, 129], [95, 142], [95, 143], [95, 145], [95, 146], [95, 148], [95, 150], [95, 156], [95, 157], [95, 162], [95, 170], [95, 175], [95, 176], [96, 102], [96, 103], [96, 104], [96, 106], [96, 111], [96, 122], [96, 124], [96, 132], [96, 137], [96, 140], [96, 141], [96, 154], [96, 156], [96, 157], [96, 166], [96, 168], [96, 174], [96, 176], [97, 99], [97, 105], [97, 107], [97, 110], [97, 113], [97, 119], [97, 120], [97, 121], [97, 123], [97, 125], [97, 131], [97, 136], [97, 144], [97, 146], [97, 159], [97, 163], [97, 172], [98, 104], [98, 108], [98, 110], [98, 111], [98, 112], [98, 119], [98, 120], [98, 125], [98, 136], [98, 142], [98, 161], [98, 163], [98, 168], [98, 170], [98, 172], [99, 102], [99, 106], [99, 115], [99, 116], [99, 130], [99, 131], [99, 144], [99, 145], [99, 151], [99, 161], [99, 162], [99, 171], [100, 101], [100, 105], [100, 108], [100, 110], [100, 125], [100, 127], [100, 129], [100, 135], [100, 141], [100, 145], [100, 150], [100, 153], [100, 165], [100, 167], [101, 118], [101, 127], [101, 134], [101, 136], [101, 141], [101, 142], [101, 148], [101, 152], [101, 153], [101, 155], [101, 158], [101, 165], [101, 170], [101, 177], [101, 179], [102, 103], [102, 117], [102, 124], [102, 128], [102, 130], [102, 133], [102, 134], [102, 141], [102, 142], [102, 147], [102, 154], [102, 156], [102, 164], [103, 106], [103, 107], [103, 108], [103, 109], [103, 119], [103, 121], [103, 132], [103, 134], [103, 140], [103, 145], [103, 150], [103, 151], [103, 153], [103, 154], [103, 155], [103, 158], [103, 159], [103, 161], [103, 162], [103, 173], [103, 174], [104, 106], [104, 115], [104, 116], [104, 129], [104, 133], [104, 136], [104, 142], [104, 148], [104, 152], [104, 154], [104, 157], [104, 158], [104, 167], [105, 106], [105, 108], [105, 123], [105, 124], [105, 125], [105, 126], [105, 128], [105, 129], [105, 132], [105, 134], [105, 150], [105, 151], [105, 157], [105, 161], [105, 164], [105, 178], [106, 107], [106, 118], [106, 122], [106, 123], [106, 125], [106, 126], [106, 130], [106, 132], [106, 134], [106, 137], [106, 154], [106, 159], [106, 163], [106, 168], [106, 173], [106, 178], [106, 179], [107, 108], [107, 115], [107, 116], [107, 125], [107, 127], [107, 128], [107, 139], [107, 140], [107, 141], [107, 147], [107, 151], [107, 152], [107, 164], [107, 165], [107, 170], [107, 171], [107, 175], [108, 113], [108, 119], [108, 123], [108, 125], [108, 134], [108, 157], [108, 166], [108, 170], [108, 173], [108, 176], [108, 177], [109, 115], [109, 116], [109, 117], [109, 118], [109, 121], [109, 123], [109, 124], [109, 132], [109, 140], [109, 141], [109, 142], [109, 146], [109, 147], [109, 148], [109, 150], [109, 152], [109, 154], [109, 156], [109, 164], [109, 169], [110, 112], [110, 113], [110, 115], [110, 117], [110, 120], [110, 121], [110, 123], [110, 125], [110, 129], [110, 130], [110, 131], [110, 134], [110, 136], [110, 137], [110, 139], [110, 143], [110, 144], [110, 149], [110, 152], [110, 153], [110, 159], [110, 162], [110, 166], [110, 173], [111, 116], [111, 118], [111, 122], [111, 124], [111, 127], [111, 130], [111, 135], [111, 139], [111, 140], [111, 141], [111, 142], [111, 143], [111, 144], [111, 145], [111, 148], [111, 149], [111, 154], [111, 156], [111, 163], [111, 165], [111, 173], [111, 176], [112, 121], [112, 125], [112, 127], [112, 131], [112, 138], [112, 143], [112, 159], [112, 171], [112, 176], [112, 178], [112, 179], [113, 114], [113, 123], [113, 126], [113, 129], [113, 132], [113, 137], [113, 146], [113, 149], [113, 150], [113, 161], [113, 162], [113, 165], [113, 176], [113, 179], [114, 121], [114, 133], [114, 135], [114, 139], [114, 140], [114, 160], [114, 164], [114, 177], [114, 178], [115, 121], [115, 127], [115, 133], [115, 136], [115, 148], [115, 154], [115, 158], [115, 161], [115, 172], [116, 121], [116, 124], [116, 126], [116, 133], [116, 140], [116, 147], [116, 149], [116, 151], [116, 153], [116, 157], [116, 163], [116, 167], [116, 169], [116, 170], [116, 171], [117, 119], [117, 122], [117, 123], [117, 131], [117, 138], [117, 139], [117, 143], [117, 149], [117, 153], [117, 163], [117, 170], [117, 175], [118, 120], [118, 123], [118, 124], [118, 127], [118, 139], [118, 143], [118, 145], [118, 146], [118, 148], [118, 149], [118, 152], [118, 158], [118, 166], [118, 178], [118, 179], [119, 123], [119, 127], [119, 132], [119, 138], [119, 139], [119, 140], [119, 146], [119, 152], [119, 158], [119, 163], [119, 165], [119, 170], [119, 172], [119, 173], [119, 175], [120, 124], [120, 129], [120, 132], [120, 136], [120, 145], [120, 146], [120, 152], [120, 156], [120, 164], [120, 167], [120, 175], [120, 179], [121, 123], [121, 128], [121, 129], [121, 133], [121, 137], [121, 141], [121, 142], [121, 144], [121, 146], [121, 148], [121, 151], [121, 154], [121, 156], [121, 170], [121, 173], [122, 127], [122, 129], [122, 142], [122, 143], [122, 145], [122, 153], [122, 156], [122, 157], [122, 158], [122, 160], [122, 163], [122, 164], [122, 165], [122, 171], [122, 173], [123, 127], [123, 128], [123, 139], [123, 143], [123, 150], [123, 152], [123, 162], [123, 167], [123, 170], [123, 176], [123, 179], [124, 126], [124, 131], [124, 144], [124, 146], [124, 162], [124, 166], [124, 167], [124, 171], [124, 179], [125, 132], [125, 139], [125, 143], [125, 146], [125, 147], [125, 156], [125, 157], [125, 159], [125, 161], [125, 162], [125, 166], [125, 169], [125, 170], [125, 177], [125, 178], [126, 129], [126, 133], [126, 134], [126, 136], [126, 142], [126, 143], [126, 144], [126, 146], [126, 148], [126, 149], [126, 151], [126, 155], [126, 160], [126, 161], [126, 165], [126, 170], [126, 172], [126, 173], [127, 133], [127, 135], [127, 143], [127, 147], [127, 148], [127, 150], [127, 156], [127, 164], [127, 167], [127, 172], [127, 177], [128, 132], [128, 140], [128, 141], [128, 143], [128, 150], [128, 159], [128, 164], [128, 166], [128, 173], [129, 134], [129, 142], [129, 146], [129, 148], [129, 149], [129, 151], [129, 153], [129, 158], [129, 161], [129, 166], [129, 172], [129, 177], [129, 178], [130, 133], [130, 136], [130, 142], [130, 143], [130, 144], [130, 146], [130, 152], [130, 153], [130, 170], [130, 176], [131, 136], [131, 139], [131, 150], [131, 158], [131, 159], [131, 170], [131, 173], [131, 174], [131, 178], [132, 133], [132, 136], [132, 143], [132, 145], [132, 148], [132, 151], [132, 153], [132, 155], [132, 157], [132, 173], [132, 177], [133, 136], [133, 139], [133, 146], [133, 147], [133, 149], [133, 151], [133, 153], [133, 170], [133, 177], [133, 179], [134, 149], [134, 155], [134, 156], [134, 161], [134, 166], [134, 168], [134, 171], [134, 173], [134, 176], [134, 179], [135, 138], [135, 146], [135, 150], [135, 154], [135, 158], [135, 161], [135, 165], [135, 166], [135, 167], [135, 171], [136, 139], [136, 140], [136, 141], [136, 142], [136, 144], [136, 153], [136, 154], [136, 159], [136, 171], [136, 174], [137, 143], [137, 147], [137, 148], [137, 151], [137, 157], [137, 164], [138, 148], [138, 155], [138, 156], [138, 162], [138, 163], [138, 166], [138, 174], [138, 176], [139, 141], [139, 142], [139, 147], [139, 149], [139, 160], [139, 163], [139, 167], [139, 171], [139, 172], [139, 174], [139, 177], [140, 142], [140, 144], [140, 146], [140, 154], [140, 155], [140, 157], [140, 165], [140, 166], [140, 169], [140, 177], [141, 144], [141, 146], [141, 150], [141, 153], [141, 156], [141, 179], [142, 144], [142, 148], [142, 149], [142, 153], [142, 155], [142, 157], [142, 159], [142, 160], [142, 161], [142, 162], [142, 163], [142, 166], [142, 168], [142, 171], [142, 178], [143, 151], [143, 153], [143, 156], [143, 164], [143, 166], [143, 167], [143, 170], [143, 173], [144, 154], [144, 156], [144, 168], [144, 172], [144, 177], [144, 178], [145, 146], [145, 154], [145, 158], [145, 165], [145, 170], [146, 148], [146, 152], [146, 154], [146, 160], [146, 161], [146, 165], [146, 169], [146, 172], [146, 174], [146, 176], [147, 150], [147, 153], [147, 155], [147, 159], [147, 160], [147, 166], [147, 168], [147, 170], [147, 171], [148, 151], [148, 152], [148, 155], [148, 160], [148, 161], [148, 162], [148, 165], [148, 168], [148, 170], [148, 173], [148, 174], [148, 178], [149, 152], [149, 153], [149, 159], [149, 160], [149, 164], [149, 167], [149, 168], [149, 169], [149, 172], [149, 173], [149, 176], [150, 153], [150, 163], [150, 164], [150, 167], [150, 171], [150, 174], [150, 178], [150, 179], [151, 153], [151, 161], [151, 163], [151, 169], [151, 170], [151, 177], [151, 178], [151, 179], [152, 153], [152, 163], [152, 168], [152, 170], [152, 176], [153, 161], [153, 162], [153, 163], [153, 169], [153, 174], [153, 175], [153, 179], [154, 159], [154, 160], [154, 161], [154, 168], [154, 176], [154, 177], [154, 179], [155, 158], [155, 174], [156, 157], [156, 161], [156, 162], [156, 164], [156, 166], [156, 168], [156, 170], [156, 171], [156, 172], [157, 159], [157, 160], [157, 166], [157, 168], [157, 179], [158, 160], [158, 166], [158, 168], [158, 176], [158, 177], [159, 168], [159, 173], [159, 179], [160, 161], [160, 165], [160, 174], [160, 179], [161, 164], [161, 174], [162, 172], [162, 174], [162, 177], [162, 179], [163, 171], [163, 174], [163, 176], [163, 179], [164, 168], [164, 171], [164, 173], [165, 166], [165, 167], [165, 169], [165, 174], [165, 178], [166, 174], [167, 168], [167, 177], [168, 169], [168, 175], [168, 177], [170, 176], [171, 176], [172, 174], [173, 175], [173, 178], [174, 175], [175, 176], [175, 177], [175, 178], [176, 177], [176, 178], [176, 179]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l5-s1/tests/run.py b/tasks/construct-nppc-dominating-set-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-dominating-set-l5-s1/tests/test.sh b/tasks/construct-nppc-dominating-set-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-dominating-set-l5-s6/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l5-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-dominating-set-l5-s6/environment/instance.json b/tasks/construct-nppc-dominating-set-l5-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..40986e8920a1438ecb6bb4a51e2903f25eccb37e --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s6/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 180, "k": 15, "edges": [[0, 4], [0, 6], [0, 8], [0, 9], [0, 13], [0, 19], [0, 45], [0, 47], [0, 52], [0, 63], [0, 64], [0, 73], [0, 95], [0, 96], [0, 99], [0, 101], [0, 103], [0, 121], [0, 132], [0, 143], [0, 153], [0, 160], [0, 168], [0, 175], [0, 176], [1, 5], [1, 7], [1, 9], [1, 10], [1, 17], [1, 22], [1, 24], [1, 29], [1, 30], [1, 33], [1, 44], [1, 47], [1, 48], [1, 55], [1, 56], [1, 67], [1, 73], [1, 74], [1, 77], [1, 84], [1, 89], [1, 91], [1, 104], [1, 111], [1, 120], [1, 121], [1, 122], [1, 124], [1, 128], [1, 132], [1, 138], [1, 139], [1, 141], [1, 145], [1, 147], [1, 149], [1, 150], [1, 155], [1, 161], [1, 163], [1, 166], [1, 169], [1, 173], [1, 177], [2, 14], [2, 21], [2, 36], [2, 40], [2, 45], [2, 48], [2, 51], [2, 56], [2, 65], [2, 68], [2, 83], [2, 88], [2, 89], [2, 94], [2, 96], [2, 99], [2, 100], [2, 102], [2, 103], [2, 113], [2, 120], [2, 127], [2, 131], [2, 135], [2, 136], [2, 140], [2, 144], [2, 145], [2, 150], [2, 154], [2, 156], [2, 158], [2, 159], [2, 161], [2, 162], [2, 163], [2, 164], [2, 165], [2, 169], [2, 171], [3, 9], [3, 10], [3, 15], [3, 17], [3, 19], [3, 34], [3, 41], [3, 55], [3, 56], [3, 60], [3, 61], [3, 66], [3, 67], [3, 69], [3, 76], [3, 82], [3, 88], [3, 90], [3, 92], [3, 93], [3, 96], [3, 101], [3, 102], [3, 103], [3, 105], [3, 114], [3, 116], [3, 117], [3, 133], [3, 134], [3, 140], [3, 158], [3, 159], [3, 160], [3, 168], [3, 177], [3, 179], [4, 16], [4, 17], [4, 34], [4, 42], [4, 45], [4, 49], [4, 50], [4, 57], [4, 60], [4, 61], [4, 62], [4, 83], [4, 84], [4, 89], [4, 90], [4, 99], [4, 101], [4, 108], [4, 110], [4, 114], [4, 118], [4, 122], [4, 127], [4, 129], [4, 131], [4, 134], [4, 135], [4, 138], [4, 152], [4, 154], [4, 157], [4, 158], [4, 159], [4, 176], [5, 10], [5, 11], [5, 34], [5, 37], [5, 44], [5, 47], [5, 48], [5, 56], [5, 64], [5, 69], [5, 73], [5, 75], [5, 80], [5, 81], [5, 86], [5, 88], [5, 89], [5, 99], [5, 107], [5, 110], [5, 120], [5, 125], [5, 128], [5, 132], [5, 134], [5, 145], [5, 162], [5, 164], [5, 165], [5, 173], [5, 175], [6, 10], [6, 14], [6, 18], [6, 25], [6, 29], [6, 47], [6, 48], [6, 51], [6, 53], [6, 58], [6, 62], [6, 67], [6, 74], [6, 81], [6, 83], [6, 86], [6, 89], [6, 90], [6, 93], [6, 94], [6, 96], [6, 101], [6, 102], [6, 103], [6, 105], [6, 110], [6, 111], [6, 124], [6, 128], [6, 130], [6, 132], [6, 151], [6, 153], [6, 159], [6, 161], [6, 162], [6, 165], [6, 166], [6, 167], [6, 170], [6, 173], [6, 174], [6, 178], [6, 179], [7, 15], [7, 16], [7, 19], [7, 21], [7, 23], [7, 25], [7, 29], [7, 32], [7, 34], [7, 35], [7, 42], [7, 46], [7, 51], [7, 54], [7, 68], [7, 69], [7, 70], [7, 71], [7, 72], [7, 79], [7, 85], [7, 89], [7, 104], [7, 105], [7, 106], [7, 107], [7, 109], [7, 111], [7, 114], [7, 126], [7, 127], [7, 131], [7, 133], [7, 134], [7, 136], [7, 146], [7, 149], [7, 155], [7, 156], [7, 158], [7, 162], [7, 166], [7, 174], [7, 175], [8, 24], [8, 25], [8, 28], [8, 31], [8, 39], [8, 40], [8, 43], [8, 45], [8, 46], [8, 48], [8, 51], [8, 56], [8, 65], [8, 67], [8, 68], [8, 69], [8, 84], [8, 86], [8, 87], [8, 90], [8, 91], [8, 93], [8, 101], [8, 102], [8, 109], [8, 111], [8, 115], [8, 120], [8, 125], [8, 129], [8, 133], [8, 136], [8, 138], [8, 145], [8, 146], [8, 151], [8, 157], [8, 166], [8, 177], [8, 179], [9, 10], [9, 11], [9, 15], [9, 20], [9, 32], [9, 45], [9, 47], [9, 56], [9, 57], [9, 59], [9, 64], [9, 70], [9, 73], [9, 83], [9, 86], [9, 88], [9, 89], [9, 90], [9, 97], [9, 99], [9, 101], [9, 102], [9, 103], [9, 110], [9, 115], [9, 126], [9, 138], [9, 143], [9, 146], [9, 166], [9, 177], [9, 178], [10, 23], [10, 25], [10, 27], [10, 33], [10, 34], [10, 37], [10, 38], [10, 39], [10, 48], [10, 50], [10, 51], [10, 52], [10, 58], [10, 65], [10, 67], [10, 70], [10, 75], [10, 81], [10, 82], [10, 92], [10, 98], [10, 100], [10, 103], [10, 108], [10, 112], [10, 117], [10, 119], [10, 120], [10, 122], [10, 127], [10, 128], [10, 134], [10, 139], [10, 142], [10, 143], [10, 148], [10, 152], [10, 154], [10, 156], [10, 165], [10, 175], [10, 177], [10, 179], [11, 17], [11, 20], [11, 24], [11, 34], [11, 42], [11, 47], [11, 65], [11, 66], [11, 67], [11, 70], [11, 73], [11, 77], [11, 81], [11, 83], [11, 98], [11, 117], [11, 122], [11, 130], [11, 136], [11, 138], [11, 150], [11, 165], [11, 174], [12, 26], [12, 29], [12, 34], [12, 48], [12, 58], [12, 62], [12, 73], [12, 79], [12, 83], [12, 85], [12, 86], [12, 90], [12, 99], [12, 109], [12, 123], [12, 125], [12, 131], [12, 134], [12, 135], [12, 139], [12, 152], [12, 154], [12, 155], [12, 164], [12, 166], [12, 169], [12, 175], [12, 177], [13, 17], [13, 28], [13, 33], [13, 37], [13, 39], [13, 43], [13, 46], [13, 49], [13, 52], [13, 56], [13, 57], [13, 61], [13, 63], [13, 70], [13, 71], [13, 85], [13, 90], [13, 96], [13, 105], [13, 109], [13, 110], [13, 116], [13, 123], [13, 124], [13, 127], [13, 132], [13, 133], [13, 143], [13, 149], [13, 150], [13, 151], [13, 152], [13, 157], [13, 165], [13, 170], [13, 171], [13, 175], [14, 21], [14, 30], [14, 36], [14, 38], [14, 39], [14, 44], [14, 45], [14, 50], [14, 54], [14, 62], [14, 67], [14, 72], [14, 75], [14, 81], [14, 88], [14, 89], [14, 90], [14, 95], [14, 102], [14, 103], [14, 110], [14, 111], [14, 114], [14, 117], [14, 118], [14, 119], [14, 123], [14, 127], [14, 130], [14, 137], [14, 138], [14, 145], [14, 146], [14, 147], [14, 150], [14, 153], [14, 163], [14, 165], [14, 168], [14, 172], [15, 19], [15, 24], [15, 28], [15, 30], [15, 32], [15, 41], [15, 44], [15, 51], [15, 59], [15, 65], [15, 66], [15, 70], [15, 71], [15, 73], [15, 79], [15, 84], [15, 91], [15, 94], [15, 102], [15, 108], [15, 111], [15, 117], [15, 120], [15, 124], [15, 126], [15, 127], [15, 142], [15, 144], [15, 146], [15, 149], [15, 150], [15, 158], [15, 165], [15, 169], [15, 170], [15, 177], [16, 19], [16, 33], [16, 38], [16, 42], [16, 43], [16, 49], [16, 52], [16, 56], [16, 58], [16, 71], [16, 72], [16, 77], [16, 78], [16, 80], [16, 85], [16, 91], [16, 103], [16, 107], [16, 108], [16, 129], [16, 137], [16, 138], [16, 139], [16, 148], [16, 150], [16, 151], [16, 156], [16, 157], [16, 165], [16, 173], [16, 174], [17, 23], [17, 26], [17, 36], [17, 37], [17, 39], [17, 48], [17, 53], [17, 57], [17, 58], [17, 64], [17, 65], [17, 77], [17, 84], [17, 95], [17, 97], [17, 99], [17, 110], [17, 113], [17, 118], [17, 122], [17, 144], [17, 148], [17, 161], [17, 173], [17, 176], [18, 31], [18, 32], [18, 33], [18, 37], [18, 55], [18, 57], [18, 58], [18, 63], [18, 73], [18, 77], [18, 82], [18, 84], [18, 89], [18, 95], [18, 98], [18, 99], [18, 103], [18, 111], [18, 119], [18, 121], [18, 135], [18, 136], [18, 139], [18, 142], [18, 149], [18, 153], [18, 159], [18, 161], [18, 162], [19, 20], [19, 21], [19, 23], [19, 28], [19, 32], [19, 34], [19, 47], [19, 52], [19, 55], [19, 66], [19, 67], [19, 70], [19, 73], [19, 79], [19, 81], [19, 86], [19, 87], [19, 89], [19, 93], [19, 99], [19, 100], [19, 106], [19, 108], [19, 117], [19, 119], [19, 120], [19, 121], [19, 127], [19, 133], [19, 144], [19, 147], [19, 152], [19, 155], [19, 160], [19, 166], [19, 168], [19, 174], [19, 175], [20, 24], [20, 32], [20, 33], [20, 57], [20, 59], [20, 60], [20, 63], [20, 66], [20, 70], [20, 75], [20, 78], [20, 86], [20, 94], [20, 97], [20, 98], [20, 101], [20, 106], [20, 111], [20, 117], [20, 121], [20, 124], [20, 130], [20, 131], [20, 134], [20, 136], [20, 141], [20, 157], [20, 158], [20, 159], [20, 169], [21, 28], [21, 35], [21, 38], [21, 39], [21, 58], [21, 60], [21, 61], [21, 65], [21, 71], [21, 82], [21, 88], [21, 102], [21, 107], [21, 110], [21, 113], [21, 115], [21, 117], [21, 124], [21, 130], [21, 146], [21, 149], [21, 153], [21, 159], [21, 160], [21, 161], [21, 172], [21, 175], [22, 23], [22, 25], [22, 27], [22, 36], [22, 37], [22, 38], [22, 45], [22, 46], [22, 49], [22, 51], [22, 52], [22, 54], [22, 57], [22, 58], [22, 60], [22, 61], [22, 66], [22, 69], [22, 88], [22, 89], [22, 92], [22, 101], [22, 102], [22, 110], [22, 113], [22, 116], [22, 123], [22, 130], [22, 139], [22, 141], [22, 145], [22, 149], [22, 151], [22, 155], [22, 161], [22, 167], [22, 172], [22, 174], [22, 175], [22, 179], [23, 28], [23, 32], [23, 33], [23, 35], [23, 37], [23, 40], [23, 46], [23, 55], [23, 72], [23, 88], [23, 92], [23, 94], [23, 99], [23, 102], [23, 106], [23, 110], [23, 115], [23, 119], [23, 120], [23, 126], [23, 137], [23, 138], [23, 144], [23, 145], [23, 152], [23, 153], [23, 174], [23, 176], [24, 44], [24, 45], [24, 65], [24, 73], [24, 81], [24, 82], [24, 88], [24, 93], [24, 102], [24, 113], [24, 116], [24, 118], [24, 120], [24, 129], [24, 132], [24, 135], [24, 137], [24, 149], [24, 154], [24, 161], [24, 163], [24, 168], [24, 174], [24, 178], [25, 31], [25, 33], [25, 36], [25, 58], [25, 64], [25, 65], [25, 67], [25, 69], [25, 77], [25, 79], [25, 87], [25, 88], [25, 91], [25, 99], [25, 100], [25, 112], [25, 123], [25, 126], [25, 127], [25, 129], [25, 131], [25, 134], [25, 136], [25, 144], [25, 164], [26, 27], [26, 29], [26, 35], [26, 37], [26, 40], [26, 48], [26, 50], [26, 55], [26, 58], [26, 61], [26, 63], [26, 66], [26, 87], [26, 100], [26, 104], [26, 105], [26, 108], [26, 112], [26, 116], [26, 129], [26, 137], [26, 148], [26, 149], [26, 153], [26, 154], [26, 161], [26, 171], [26, 175], [26, 176], [27, 32], [27, 36], [27, 54], [27, 55], [27, 63], [27, 65], [27, 68], [27, 72], [27, 75], [27, 77], [27, 91], [27, 102], [27, 107], [27, 108], [27, 116], [27, 118], [27, 124], [27, 126], [27, 127], [27, 141], [27, 145], [27, 146], [27, 152], [27, 157], [27, 159], [27, 160], [27, 162], [27, 163], [27, 164], [27, 174], [27, 175], [27, 176], [27, 178], [28, 31], [28, 38], [28, 72], [28, 79], [28, 90], [28, 93], [28, 106], [28, 131], [28, 133], [28, 135], [28, 137], [28, 138], [28, 140], [28, 146], [28, 149], [28, 154], [28, 155], [28, 156], [28, 159], [28, 162], [28, 167], [28, 175], [28, 177], [29, 33], [29, 34], [29, 51], [29, 52], [29, 56], [29, 59], [29, 67], [29, 68], [29, 75], [29, 79], [29, 83], [29, 88], [29, 93], [29, 97], [29, 100], [29, 110], [29, 120], [29, 128], [29, 130], [29, 133], [29, 150], [29, 163], [29, 173], [30, 36], [30, 40], [30, 45], [30, 46], [30, 47], [30, 57], [30, 58], [30, 62], [30, 64], [30, 70], [30, 72], [30, 74], [30, 78], [30, 80], [30, 83], [30, 89], [30, 93], [30, 101], [30, 117], [30, 119], [30, 124], [30, 128], [30, 130], [30, 131], [30, 140], [30, 144], [30, 145], [30, 149], [30, 161], [31, 43], [31, 47], [31, 49], [31, 56], [31, 57], [31, 60], [31, 61], [31, 62], [31, 63], [31, 65], [31, 71], [31, 80], [31, 84], [31, 87], [31, 92], [31, 94], [31, 105], [31, 106], [31, 108], [31, 127], [31, 137], [31, 146], [31, 147], [31, 157], [31, 159], [31, 164], [31, 167], [31, 174], [31, 178], [32, 33], [32, 34], [32, 35], [32, 38], [32, 61], [32, 63], [32, 74], [32, 77], [32, 82], [32, 90], [32, 101], [32, 102], [32, 105], [32, 108], [32, 123], [32, 126], [32, 131], [32, 132], [32, 133], [32, 134], [32, 143], [32, 145], [32, 149], [32, 150], [32, 153], [32, 157], [32, 160], [32, 166], [32, 167], [32, 168], [32, 173], [32, 177], [33, 36], [33, 48], [33, 50], [33, 51], [33, 54], [33, 61], [33, 83], [33, 85], [33, 93], [33, 99], [33, 100], [33, 107], [33, 109], [33, 114], [33, 115], [33, 119], [33, 122], [33, 125], [33, 128], [33, 134], [33, 136], [33, 142], [33, 144], [33, 148], [33, 163], [33, 166], [33, 169], [33, 179], [34, 42], [34, 61], [34, 76], [34, 80], [34, 81], [34, 100], [34, 104], [34, 108], [34, 109], [34, 113], [34, 114], [34, 116], [34, 132], [34, 144], [34, 151], [34, 156], [34, 170], [34, 171], [34, 174], [34, 177], [35, 36], [35, 48], [35, 50], [35, 54], [35, 58], [35, 60], [35, 65], [35, 86], [35, 91], [35, 95], [35, 98], [35, 100], [35, 107], [35, 109], [35, 111], [35, 116], [35, 117], [35, 121], [35, 125], [35, 135], [35, 141], [35, 146], [35, 150], [35, 158], [35, 163], [35, 164], [35, 166], [35, 169], [35, 170], [35, 172], [35, 174], [35, 177], [36, 37], [36, 43], [36, 56], [36, 57], [36, 61], [36, 63], [36, 64], [36, 69], [36, 70], [36, 78], [36, 82], [36, 84], [36, 87], [36, 88], [36, 89], [36, 92], [36, 98], [36, 104], [36, 116], [36, 128], [36, 130], [36, 137], [36, 139], [36, 142], [36, 146], [36, 148], [36, 149], [36, 160], [36, 163], [36, 164], [36, 171], [36, 172], [36, 177], [36, 178], [37, 38], [37, 45], [37, 46], [37, 48], [37, 53], [37, 62], [37, 66], [37, 70], [37, 72], [37, 78], [37, 82], [37, 89], [37, 94], [37, 97], [37, 102], [37, 113], [37, 114], [37, 135], [37, 147], [37, 151], [37, 153], [37, 155], [37, 160], [37, 177], [38, 41], [38, 43], [38, 48], [38, 49], [38, 50], [38, 62], [38, 70], [38, 73], [38, 83], [38, 85], [38, 87], [38, 88], [38, 94], [38, 95], [38, 101], [38, 102], [38, 105], [38, 109], [38, 111], [38, 116], [38, 118], [38, 120], [38, 123], [38, 124], [38, 135], [38, 143], [38, 145], [38, 150], [38, 155], [38, 157], [38, 165], [38, 168], [38, 169], [39, 43], [39, 61], [39, 63], [39, 71], [39, 74], [39, 82], [39, 85], [39, 93], [39, 97], [39, 99], [39, 103], [39, 115], [39, 116], [39, 119], [39, 121], [39, 125], [39, 131], [39, 135], [39, 136], [39, 137], [39, 140], [39, 144], [39, 149], [39, 157], [39, 160], [39, 165], [39, 168], [39, 178], [40, 43], [40, 61], [40, 63], [40, 64], [40, 66], [40, 67], [40, 69], [40, 81], [40, 86], [40, 87], [40, 90], [40, 92], [40, 99], [40, 101], [40, 104], [40, 106], [40, 112], [40, 113], [40, 122], [40, 127], [40, 128], [40, 132], [40, 134], [40, 143], [40, 145], [40, 153], [40, 154], [40, 157], [40, 159], [40, 164], [40, 168], [40, 177], [41, 42], [41, 43], [41, 44], [41, 50], [41, 57], [41, 63], [41, 66], [41, 68], [41, 70], [41, 85], [41, 91], [41, 100], [41, 101], [41, 103], [41, 104], [41, 108], [41, 113], [41, 115], [41, 119], [41, 127], [41, 132], [41, 134], [41, 155], [41, 156], [41, 157], [41, 168], [41, 169], [41, 174], [42, 51], [42, 52], [42, 53], [42, 56], [42, 63], [42, 64], [42, 68], [42, 79], [42, 81], [42, 87], [42, 98], [42, 99], [42, 105], [42, 119], [42, 122], [42, 123], [42, 133], [42, 135], [42, 140], [42, 142], [42, 143], [42, 144], [42, 146], [42, 147], [42, 148], [42, 153], [42, 159], [42, 166], [42, 167], [42, 177], [43, 50], [43, 51], [43, 60], [43, 80], [43, 85], [43, 86], [43, 92], [43, 98], [43, 108], [43, 114], [43, 117], [43, 121], [43, 129], [43, 131], [43, 136], [43, 140], [43, 147], [43, 150], [43, 151], [43, 155], [43, 156], [43, 158], [43, 161], [43, 173], [43, 178], [44, 47], [44, 48], [44, 55], [44, 56], [44, 63], [44, 64], [44, 66], [44, 69], [44, 80], [44, 88], [44, 90], [44, 93], [44, 96], [44, 102], [44, 109], [44, 115], [44, 117], [44, 123], [44, 125], [44, 129], [44, 130], [44, 132], [44, 141], [44, 144], [44, 145], [44, 162], [44, 168], [44, 169], [44, 174], [44, 178], [45, 56], [45, 66], [45, 74], [45, 77], [45, 88], [45, 98], [45, 103], [45, 112], [45, 117], [45, 120], [45, 126], [45, 128], [45, 131], [45, 133], [45, 135], [45, 136], [45, 144], [45, 151], [45, 152], [45, 160], [45, 164], [45, 167], [46, 54], [46, 58], [46, 66], [46, 71], [46, 73], [46, 77], [46, 95], [46, 109], [46, 112], [46, 114], [46, 118], [46, 119], [46, 121], [46, 126], [46, 132], [46, 135], [46, 137], [46, 138], [46, 142], [46, 144], [46, 146], [46, 153], [46, 157], [46, 159], [46, 162], [46, 165], [46, 168], [46, 178], [46, 179], [47, 49], [47, 53], [47, 58], [47, 64], [47, 65], [47, 68], [47, 85], [47, 94], [47, 98], [47, 101], [47, 102], [47, 113], [47, 114], [47, 117], [47, 119], [47, 124], [47, 125], [47, 133], [47, 137], [47, 139], [47, 147], [47, 154], [47, 159], [47, 160], [47, 162], [47, 174], [47, 175], [47, 178], [48, 53], [48, 58], [48, 59], [48, 60], [48, 62], [48, 67], [48, 71], [48, 76], [48, 81], [48, 82], [48, 95], [48, 104], [48, 106], [48, 112], [48, 114], [48, 115], [48, 118], [48, 119], [48, 128], [48, 130], [48, 131], [48, 133], [48, 139], [48, 140], [48, 149], [48, 153], [48, 162], [48, 167], [48, 172], [49, 54], [49, 55], [49, 60], [49, 61], [49, 76], [49, 82], [49, 93], [49, 94], [49, 103], [49, 107], [49, 108], [49, 111], [49, 113], [49, 118], [49, 122], [49, 124], [49, 135], [49, 139], [49, 163], [49, 164], [49, 171], [49, 177], [50, 63], [50, 67], [50, 68], [50, 74], [50, 89], [50, 102], [50, 112], [50, 114], [50, 116], [50, 127], [50, 131], [50, 133], [50, 135], [50, 138], [50, 139], [50, 141], [50, 149], [50, 151], [50, 158], [50, 170], [50, 171], [50, 173], [50, 176], [51, 66], [51, 73], [51, 79], [51, 80], [51, 81], [51, 91], [51, 94], [51, 104], [51, 107], [51, 116], [51, 117], [51, 122], [51, 124], [51, 128], [51, 129], [51, 137], [51, 143], [51, 153], [51, 159], [51, 168], [51, 172], [51, 173], [51, 176], [52, 63], [52, 64], [52, 66], [52, 70], [52, 71], [52, 76], [52, 80], [52, 82], [52, 84], [52, 87], [52, 88], [52, 98], [52, 99], [52, 100], [52, 106], [52, 108], [52, 124], [52, 126], [52, 129], [52, 134], [52, 137], [52, 142], [52, 143], [52, 144], [52, 156], [52, 157], [52, 166], [52, 171], [52, 174], [52, 177], [53, 55], [53, 69], [53, 86], [53, 92], [53, 99], [53, 105], [53, 108], [53, 116], [53, 121], [53, 123], [53, 128], [53, 129], [53, 131], [53, 133], [53, 138], [53, 139], [53, 151], [53, 159], [53, 167], [53, 176], [53, 177], [54, 60], [54, 68], [54, 71], [54, 74], [54, 78], [54, 81], [54, 82], [54, 89], [54, 92], [54, 97], [54, 104], [54, 106], [54, 116], [54, 120], [54, 128], [54, 135], [54, 146], [54, 154], [54, 158], [54, 159], [54, 163], [54, 168], [54, 171], [55, 56], [55, 66], [55, 68], [55, 76], [55, 81], [55, 90], [55, 99], [55, 103], [55, 104], [55, 106], [55, 110], [55, 124], [55, 131], [55, 133], [55, 136], [55, 142], [55, 152], [55, 156], [55, 158], [55, 160], [55, 161], [55, 163], [55, 175], [56, 67], [56, 87], [56, 89], [56, 91], [56, 98], [56, 104], [56, 105], [56, 107], [56, 110], [56, 118], [56, 119], [56, 127], [56, 146], [56, 148], [56, 152], [56, 154], [56, 160], [56, 166], [56, 170], [56, 175], [56, 176], [56, 178], [57, 63], [57, 74], [57, 78], [57, 91], [57, 98], [57, 102], [57, 109], [57, 110], [57, 123], [57, 126], [57, 130], [57, 133], [57, 135], [57, 141], [57, 144], [57, 148], [57, 158], [57, 165], [57, 178], [57, 179], [58, 59], [58, 60], [58, 61], [58, 63], [58, 71], [58, 77], [58, 79], [58, 85], [58, 89], [58, 94], [58, 97], [58, 105], [58, 120], [58, 123], [58, 124], [58, 125], [58, 127], [58, 132], [58, 149], [58, 164], [58, 168], [58, 169], [58, 172], [58, 174], [59, 61], [59, 64], [59, 68], [59, 69], [59, 99], [59, 107], [59, 116], [59, 119], [59, 134], [59, 138], [59, 140], [59, 141], [59, 142], [59, 146], [59, 148], [59, 163], [59, 168], [59, 169], [60, 65], [60, 68], [60, 77], [60, 80], [60, 82], [60, 87], [60, 89], [60, 94], [60, 95], [60, 111], [60, 120], [60, 126], [60, 134], [60, 136], [60, 137], [60, 144], [60, 146], [60, 147], [60, 150], [60, 160], [60, 161], [60, 163], [60, 166], [60, 167], [60, 173], [60, 178], [61, 62], [61, 66], [61, 69], [61, 78], [61, 82], [61, 88], [61, 92], [61, 100], [61, 102], [61, 109], [61, 114], [61, 134], [61, 138], [61, 139], [61, 141], [61, 148], [61, 153], [61, 163], [61, 165], [61, 170], [61, 173], [62, 65], [62, 68], [62, 69], [62, 73], [62, 80], [62, 81], [62, 83], [62, 91], [62, 101], [62, 108], [62, 115], [62, 118], [62, 119], [62, 122], [62, 126], [62, 131], [62, 133], [62, 134], [62, 140], [62, 142], [62, 147], [62, 149], [62, 150], [62, 151], [62, 154], [62, 162], [62, 165], [62, 166], [62, 169], [62, 176], [63, 64], [63, 75], [63, 77], [63, 81], [63, 93], [63, 97], [63, 116], [63, 130], [63, 136], [63, 146], [63, 153], [63, 159], [63, 163], [63, 166], [63, 168], [63, 174], [63, 179], [64, 66], [64, 71], [64, 75], [64, 76], [64, 81], [64, 87], [64, 91], [64, 96], [64, 106], [64, 128], [64, 130], [64, 135], [64, 136], [64, 138], [64, 143], [64, 146], [64, 148], [64, 149], [64, 157], [64, 168], [64, 170], [64, 176], [65, 68], [65, 71], [65, 81], [65, 93], [65, 99], [65, 102], [65, 104], [65, 106], [65, 107], [65, 108], [65, 109], [65, 110], [65, 111], [65, 119], [65, 121], [65, 127], [65, 132], [65, 137], [65, 139], [65, 143], [65, 151], [65, 158], [65, 160], [65, 161], [65, 164], [65, 165], [65, 168], [65, 176], [65, 179], [66, 67], [66, 76], [66, 95], [66, 102], [66, 108], [66, 109], [66, 116], [66, 119], [66, 124], [66, 125], [66, 131], [66, 135], [66, 142], [66, 145], [66, 154], [66, 155], [66, 156], [66, 157], [66, 166], [66, 178], [67, 68], [67, 74], [67, 86], [67, 94], [67, 97], [67, 110], [67, 111], [67, 117], [67, 121], [67, 125], [67, 126], [67, 130], [67, 133], [67, 134], [67, 136], [67, 139], [67, 145], [67, 146], [67, 149], [67, 150], [67, 158], [67, 159], [67, 163], [67, 173], [67, 175], [67, 177], [68, 69], [68, 84], [68, 86], [68, 96], [68, 99], [68, 113], [68, 117], [68, 120], [68, 122], [68, 123], [68, 130], [68, 134], [68, 148], [68, 151], [68, 153], [68, 154], [68, 161], [68, 164], [68, 172], [68, 173], [68, 176], [69, 70], [69, 73], [69, 80], [69, 87], [69, 92], [69, 101], [69, 102], [69, 104], [69, 113], [69, 118], [69, 121], [69, 134], [69, 144], [69, 145], [69, 150], [69, 151], [69, 157], [69, 166], [69, 171], [69, 173], [69, 174], [69, 175], [70, 78], [70, 81], [70, 95], [70, 102], [70, 107], [70, 109], [70, 110], [70, 112], [70, 113], [70, 117], [70, 121], [70, 122], [70, 124], [70, 126], [70, 131], [70, 142], [70, 144], [70, 145], [70, 149], [70, 155], [70, 158], [70, 159], [70, 160], [70, 161], [70, 162], [70, 170], [70, 173], [70, 174], [70, 176], [71, 74], [71, 83], [71, 86], [71, 87], [71, 92], [71, 94], [71, 112], [71, 113], [71, 118], [71, 119], [71, 127], [71, 140], [71, 145], [71, 147], [71, 148], [71, 149], [71, 150], [71, 162], [71, 172], [71, 173], [71, 178], [72, 74], [72, 87], [72, 88], [72, 89], [72, 102], [72, 116], [72, 119], [72, 121], [72, 126], [72, 129], [72, 130], [72, 135], [72, 136], [72, 144], [72, 145], [72, 146], [72, 148], [72, 159], [72, 165], [72, 167], [72, 172], [72, 175], [73, 75], [73, 77], [73, 78], [73, 79], [73, 80], [73, 83], [73, 89], [73, 98], [73, 104], [73, 108], [73, 109], [73, 120], [73, 124], [73, 126], [73, 142], [73, 147], [73, 155], [73, 165], [73, 167], [73, 168], [73, 170], [73, 176], [74, 80], [74, 82], [74, 83], [74, 84], [74, 86], [74, 92], [74, 96], [74, 99], [74, 103], [74, 107], [74, 108], [74, 113], [74, 117], [74, 121], [74, 125], [74, 128], [74, 129], [74, 136], [74, 140], [74, 141], [74, 143], [74, 155], [74, 161], [74, 165], [74, 168], [74, 169], [74, 173], [74, 175], [74, 177], [74, 178], [75, 76], [75, 80], [75, 82], [75, 90], [75, 99], [75, 103], [75, 105], [75, 112], [75, 113], [75, 116], [75, 122], [75, 127], [75, 129], [75, 135], [75, 136], [75, 143], [75, 146], [75, 147], [75, 176], [75, 178], [76, 81], [76, 103], [76, 106], [76, 122], [76, 133], [76, 135], [76, 139], [76, 140], [76, 142], [76, 143], [76, 150], [76, 151], [76, 159], [76, 160], [76, 165], [76, 166], [76, 170], [76, 171], [76, 178], [77, 84], [77, 85], [77, 88], [77, 91], [77, 100], [77, 102], [77, 108], [77, 110], [77, 118], [77, 122], [77, 125], [77, 134], [77, 152], [77, 168], [77, 176], [77, 177], [78, 80], [78, 81], [78, 104], [78, 105], [78, 123], [78, 124], [78, 125], [78, 129], [78, 131], [78, 132], [78, 133], [78, 134], [78, 135], [78, 141], [78, 155], [78, 160], [78, 177], [79, 83], [79, 89], [79, 91], [79, 92], [79, 93], [79, 95], [79, 96], [79, 97], [79, 100], [79, 101], [79, 103], [79, 105], [79, 118], [79, 122], [79, 124], [79, 129], [79, 136], [79, 139], [79, 145], [79, 149], [79, 160], [79, 162], [79, 165], [79, 166], [80, 84], [80, 85], [80, 89], [80, 97], [80, 100], [80, 102], [80, 109], [80, 116], [80, 118], [80, 120], [80, 134], [80, 137], [80, 148], [80, 151], [80, 155], [80, 156], [80, 157], [80, 159], [80, 160], [80, 162], [80, 164], [80, 165], [80, 171], [80, 172], [80, 173], [80, 179], [81, 83], [81, 84], [81, 91], [81, 94], [81, 103], [81, 104], [81, 116], [81, 126], [81, 134], [81, 137], [81, 138], [81, 153], [81, 160], [81, 169], [82, 84], [82, 87], [82, 89], [82, 92], [82, 97], [82, 99], [82, 102], [82, 111], [82, 115], [82, 122], [82, 125], [82, 127], [82, 132], [82, 135], [82, 143], [82, 147], [82, 156], [82, 160], [82, 168], [82, 170], [82, 171], [82, 173], [82, 174], [82, 175], [82, 179], [83, 96], [83, 100], [83, 103], [83, 107], [83, 114], [83, 120], [83, 124], [83, 138], [83, 144], [83, 160], [83, 161], [83, 168], [83, 174], [83, 175], [84, 85], [84, 88], [84, 101], [84, 125], [84, 134], [84, 135], [84, 141], [84, 143], [84, 151], [84, 152], [84, 157], [84, 160], [84, 163], [84, 166], [84, 169], [84, 171], [84, 174], [84, 177], [85, 90], [85, 96], [85, 118], [85, 125], [85, 127], [85, 128], [85, 131], [85, 137], [85, 139], [85, 154], [85, 157], [85, 161], [85, 163], [85, 171], [85, 172], [85, 174], [85, 177], [85, 178], [86, 89], [86, 91], [86, 95], [86, 106], [86, 108], [86, 114], [86, 126], [86, 128], [86, 156], [86, 158], [86, 159], [86, 172], [86, 173], [87, 89], [87, 90], [87, 91], [87, 97], [87, 99], [87, 100], [87, 101], [87, 102], [87, 107], [87, 112], [87, 119], [87, 125], [87, 133], [87, 140], [87, 143], [87, 146], [87, 148], [87, 153], [87, 154], [87, 156], [87, 161], [87, 162], [87, 170], [87, 171], [87, 172], [87, 178], [88, 90], [88, 119], [88, 121], [88, 131], [88, 135], [88, 138], [88, 155], [88, 163], [88, 170], [88, 171], [88, 173], [88, 174], [88, 175], [88, 177], [89, 92], [89, 98], [89, 111], [89, 113], [89, 114], [89, 120], [89, 124], [89, 134], [89, 140], [89, 141], [89, 145], [89, 154], [89, 160], [89, 164], [89, 171], [89, 173], [90, 92], [90, 95], [90, 98], [90, 101], [90, 111], [90, 124], [90, 126], [90, 135], [90, 136], [90, 143], [90, 154], [90, 168], [90, 169], [90, 176], [91, 95], [91, 102], [91, 108], [91, 109], [91, 114], [91, 129], [91, 133], [91, 134], [91, 150], [91, 155], [91, 158], [91, 162], [91, 163], [91, 164], [91, 175], [92, 93], [92, 98], [92, 105], [92, 109], [92, 120], [92, 130], [92, 136], [92, 139], [92, 141], [92, 146], [92, 149], [92, 154], [92, 167], [92, 179], [93, 96], [93, 107], [93, 108], [93, 112], [93, 113], [93, 114], [93, 115], [93, 116], [93, 118], [93, 122], [93, 123], [93, 130], [93, 131], [93, 132], [93, 133], [93, 136], [93, 137], [93, 149], [93, 151], [93, 156], [93, 157], [93, 169], [93, 174], [93, 177], [94, 95], [94, 98], [94, 100], [94, 102], [94, 114], [94, 116], [94, 122], [94, 127], [94, 149], [94, 155], [94, 169], [94, 172], [94, 178], [95, 97], [95, 98], [95, 99], [95, 110], [95, 114], [95, 118], [95, 129], [95, 138], [95, 143], [95, 144], [95, 146], [95, 157], [95, 166], [95, 168], [95, 172], [95, 173], [96, 98], [96, 108], [96, 110], [96, 116], [96, 126], [96, 139], [96, 142], [96, 149], [96, 150], [96, 154], [96, 157], [96, 161], [96, 162], [96, 165], [96, 167], [96, 170], [96, 179], [97, 99], [97, 102], [97, 104], [97, 105], [97, 108], [97, 109], [97, 117], [97, 124], [97, 129], [97, 132], [97, 133], [97, 137], [97, 139], [97, 148], [97, 149], [97, 155], [97, 157], [97, 158], [97, 172], [97, 173], [97, 175], [97, 178], [98, 100], [98, 101], [98, 102], [98, 104], [98, 106], [98, 115], [98, 116], [98, 124], [98, 129], [98, 138], [98, 151], [98, 155], [98, 159], [98, 161], [98, 164], [98, 168], [98, 176], [98, 177], [99, 102], [99, 104], [99, 106], [99, 107], [99, 116], [99, 121], [99, 124], [99, 125], [99, 127], [99, 134], [99, 139], [99, 142], [99, 143], [99, 157], [99, 158], [99, 163], [99, 173], [99, 176], [100, 109], [100, 110], [100, 111], [100, 113], [100, 116], [100, 118], [100, 134], [100, 139], [100, 140], [100, 143], [100, 148], [100, 149], [100, 154], [100, 159], [100, 168], [100, 178], [101, 110], [101, 111], [101, 113], [101, 116], [101, 117], [101, 134], [101, 139], [101, 140], [101, 146], [101, 150], [101, 152], [101, 153], [101, 154], [101, 169], [101, 170], [101, 171], [101, 176], [102, 105], [102, 108], [102, 109], [102, 111], [102, 113], [102, 120], [102, 125], [102, 132], [102, 135], [102, 142], [102, 147], [102, 149], [102, 164], [102, 173], [103, 117], [103, 119], [103, 120], [103, 130], [103, 132], [103, 135], [103, 136], [103, 137], [103, 140], [103, 143], [103, 146], [103, 152], [103, 154], [103, 157], [103, 159], [103, 160], [103, 166], [103, 171], [103, 175], [104, 106], [104, 108], [104, 112], [104, 114], [104, 115], [104, 121], [104, 130], [104, 136], [104, 139], [104, 143], [104, 146], [104, 147], [104, 151], [104, 170], [104, 174], [104, 176], [105, 106], [105, 108], [105, 111], [105, 113], [105, 115], [105, 118], [105, 120], [105, 121], [105, 128], [105, 132], [105, 134], [105, 148], [105, 149], [105, 161], [105, 164], [105, 171], [105, 174], [105, 177], [106, 107], [106, 121], [106, 124], [106, 135], [106, 139], [106, 141], [106, 144], [106, 148], [106, 149], [106, 151], [106, 153], [106, 156], [106, 170], [106, 176], [107, 112], [107, 115], [107, 117], [107, 126], [107, 142], [107, 154], [107, 157], [107, 166], [107, 167], [107, 168], [107, 169], [107, 173], [107, 174], [107, 177], [107, 179], [108, 109], [108, 110], [108, 111], [108, 114], [108, 115], [108, 116], [108, 119], [108, 121], [108, 122], [108, 124], [108, 130], [108, 132], [108, 137], [108, 139], [108, 143], [108, 146], [108, 150], [108, 154], [108, 156], [108, 159], [108, 166], [108, 167], [108, 168], [108, 169], [108, 172], [108, 174], [109, 116], [109, 117], [109, 122], [109, 124], [109, 125], [109, 126], [109, 128], [109, 130], [109, 145], [109, 148], [109, 149], [109, 150], [109, 151], [109, 156], [109, 157], [109, 158], [109, 169], [109, 172], [109, 178], [109, 179], [110, 111], [110, 113], [110, 123], [110, 128], [110, 131], [110, 136], [110, 138], [110, 141], [110, 145], [110, 154], [110, 159], [110, 167], [110, 168], [110, 172], [110, 179], [111, 123], [111, 131], [111, 137], [111, 153], [111, 155], [111, 156], [111, 159], [111, 163], [111, 165], [111, 175], [111, 176], [112, 115], [112, 116], [112, 119], [112, 121], [112, 125], [112, 130], [112, 140], [112, 150], [112, 152], [112, 153], [112, 159], [112, 161], [112, 163], [112, 168], [112, 172], [113, 125], [113, 126], [113, 129], [113, 130], [113, 131], [113, 133], [113, 145], [113, 150], [113, 156], [113, 162], [113, 164], [113, 171], [114, 119], [114, 122], [114, 125], [114, 131], [114, 133], [114, 135], [114, 136], [114, 140], [114, 141], [114, 146], [114, 155], [114, 160], [114, 163], [114, 174], [114, 176], [115, 121], [115, 127], [115, 130], [115, 134], [115, 136], [115, 143], [115, 146], [115, 149], [115, 150], [115, 154], [115, 166], [115, 172], [115, 178], [115, 179], [116, 126], [116, 135], [116, 136], [116, 141], [116, 145], [116, 148], [116, 152], [116, 154], [116, 166], [116, 172], [117, 118], [117, 120], [117, 121], [117, 135], [117, 138], [117, 147], [117, 148], [117, 161], [117, 164], [117, 165], [117, 167], [117, 174], [118, 120], [118, 123], [118, 125], [118, 139], [118, 142], [118, 143], [118, 148], [118, 150], [118, 153], [118, 172], [118, 174], [118, 179], [119, 121], [119, 124], [119, 148], [119, 149], [119, 150], [119, 160], [119, 178], [120, 127], [120, 128], [120, 138], [120, 140], [120, 142], [120, 155], [120, 160], [120, 163], [120, 176], [121, 122], [121, 123], [121, 129], [121, 137], [121, 138], [121, 142], [121, 148], [121, 150], [121, 154], [121, 155], [121, 160], [121, 163], [121, 165], [121, 170], [121, 175], [121, 177], [121, 179], [122, 123], [122, 135], [122, 138], [122, 145], [122, 146], [122, 150], [122, 154], [122, 159], [122, 166], [122, 174], [123, 135], [123, 136], [123, 143], [123, 145], [123, 147], [123, 163], [123, 166], [123, 173], [123, 174], [124, 134], [124, 135], [124, 138], [124, 143], [124, 145], [124, 160], [124, 162], [124, 166], [124, 167], [124, 178], [125, 129], [125, 136], [125, 138], [125, 144], [125, 152], [125, 155], [125, 158], [125, 162], [125, 172], [125, 174], [126, 128], [126, 129], [126, 131], [126, 134], [126, 135], [126, 142], [126, 143], [126, 145], [126, 148], [126, 157], [126, 159], [126, 161], [126, 168], [126, 179], [127, 137], [127, 141], [127, 142], [127, 146], [127, 148], [127, 150], [127, 151], [127, 154], [127, 155], [127, 156], [127, 157], [127, 161], [127, 164], [127, 166], [127, 170], [127, 172], [127, 175], [127, 176], [127, 179], [128, 138], [128, 140], [128, 144], [128, 148], [128, 151], [128, 153], [128, 161], [128, 175], [128, 177], [128, 179], [129, 139], [129, 144], [129, 153], [129, 155], [129, 156], [129, 159], [129, 161], [129, 165], [129, 167], [130, 131], [130, 144], [130, 156], [130, 158], [130, 161], [130, 162], [130, 171], [130, 177], [130, 178], [130, 179], [131, 132], [131, 142], [131, 143], [131, 154], [131, 159], [131, 162], [131, 174], [131, 178], [131, 179], [132, 134], [132, 140], [132, 141], [132, 148], [132, 155], [132, 169], [132, 177], [133, 135], [133, 138], [133, 142], [133, 145], [133, 146], [133, 148], [133, 151], [133, 152], [133, 154], [133, 157], [133, 162], [133, 163], [133, 179], [134, 161], [134, 170], [134, 177], [135, 137], [135, 139], [135, 141], [135, 147], [135, 148], [135, 152], [135, 155], [135, 167], [135, 169], [135, 170], [136, 139], [136, 140], [136, 148], [136, 154], [136, 161], [136, 165], [136, 173], [136, 176], [137, 141], [137, 146], [137, 147], [137, 152], [137, 154], [137, 156], [137, 160], [137, 168], [137, 169], [137, 170], [137, 174], [137, 176], [137, 178], [137, 179], [138, 141], [138, 145], [138, 147], [138, 159], [138, 171], [138, 173], [138, 177], [139, 143], [139, 145], [139, 150], [139, 154], [139, 156], [139, 158], [139, 160], [139, 162], [139, 165], [139, 173], [139, 179], [140, 148], [140, 154], [140, 157], [140, 165], [140, 170], [140, 175], [141, 148], [141, 150], [141, 157], [141, 161], [141, 166], [141, 167], [141, 168], [141, 174], [142, 151], [142, 152], [142, 154], [142, 161], [142, 163], [142, 169], [142, 171], [142, 172], [142, 175], [142, 176], [143, 145], [143, 152], [143, 158], [143, 164], [143, 169], [143, 170], [143, 172], [143, 173], [143, 174], [144, 146], [144, 151], [144, 156], [144, 159], [144, 165], [144, 168], [144, 175], [145, 162], [145, 164], [145, 166], [146, 150], [146, 163], [146, 171], [146, 173], [146, 174], [146, 178], [146, 179], [147, 150], [147, 153], [147, 155], [147, 158], [147, 159], [147, 160], [147, 164], [147, 172], [147, 173], [147, 174], [148, 153], [148, 157], [148, 158], [148, 162], [148, 163], [148, 164], [148, 165], [148, 169], [148, 172], [148, 174], [148, 175], [148, 176], [148, 178], [149, 154], [149, 157], [149, 159], [149, 171], [149, 173], [149, 175], [149, 176], [150, 153], [150, 157], [150, 163], [150, 164], [150, 167], [150, 177], [151, 152], [151, 153], [151, 159], [151, 160], [151, 164], [151, 166], [151, 167], [151, 172], [151, 179], [152, 155], [152, 162], [152, 163], [152, 164], [152, 174], [152, 177], [153, 154], [153, 160], [153, 165], [154, 163], [154, 166], [154, 169], [154, 172], [154, 179], [155, 162], [155, 164], [155, 167], [155, 173], [155, 176], [155, 179], [156, 165], [156, 170], [156, 174], [156, 177], [157, 158], [157, 175], [158, 166], [158, 168], [158, 175], [158, 178], [159, 160], [159, 165], [159, 173], [160, 165], [160, 168], [160, 170], [160, 173], [160, 174], [160, 175], [160, 178], [160, 179], [161, 170], [161, 172], [162, 165], [162, 166], [162, 167], [162, 169], [162, 171], [162, 173], [162, 175], [162, 179], [163, 164], [163, 165], [163, 172], [163, 175], [163, 179], [165, 166], [165, 170], [165, 174], [166, 169], [166, 176], [166, 177], [166, 178], [167, 168], [167, 170], [167, 171], [167, 173], [167, 176], [167, 179], [168, 171], [168, 172], [168, 175], [169, 173], [170, 173], [170, 179], [171, 172], [171, 176], [172, 174], [173, 175], [174, 176], [175, 178]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l5-s6/solution/solve.sh b/tasks/construct-nppc-dominating-set-l5-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..03676f2350d0b62952f7c9ae3a535b4909b9fcd7 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [1, 8, 10, 26, 36, 58, 70, 71, 99, 101, 108, 115, 135, 159, 165]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l5-s6/tests/check.py b/tasks/construct-nppc-dominating-set-l5-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s6/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-l5-s6/tests/instance.json b/tasks/construct-nppc-dominating-set-l5-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..40986e8920a1438ecb6bb4a51e2903f25eccb37e --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s6/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 180, "k": 15, "edges": [[0, 4], [0, 6], [0, 8], [0, 9], [0, 13], [0, 19], [0, 45], [0, 47], [0, 52], [0, 63], [0, 64], [0, 73], [0, 95], [0, 96], [0, 99], [0, 101], [0, 103], [0, 121], [0, 132], [0, 143], [0, 153], [0, 160], [0, 168], [0, 175], [0, 176], [1, 5], [1, 7], [1, 9], [1, 10], [1, 17], [1, 22], [1, 24], [1, 29], [1, 30], [1, 33], [1, 44], [1, 47], [1, 48], [1, 55], [1, 56], [1, 67], [1, 73], [1, 74], [1, 77], [1, 84], [1, 89], [1, 91], [1, 104], [1, 111], [1, 120], [1, 121], [1, 122], [1, 124], [1, 128], [1, 132], [1, 138], [1, 139], [1, 141], [1, 145], [1, 147], [1, 149], [1, 150], [1, 155], [1, 161], [1, 163], [1, 166], [1, 169], [1, 173], [1, 177], [2, 14], [2, 21], [2, 36], [2, 40], [2, 45], [2, 48], [2, 51], [2, 56], [2, 65], [2, 68], [2, 83], [2, 88], [2, 89], [2, 94], [2, 96], [2, 99], [2, 100], [2, 102], [2, 103], [2, 113], [2, 120], [2, 127], [2, 131], [2, 135], [2, 136], [2, 140], [2, 144], [2, 145], [2, 150], [2, 154], [2, 156], [2, 158], [2, 159], [2, 161], [2, 162], [2, 163], [2, 164], [2, 165], [2, 169], [2, 171], [3, 9], [3, 10], [3, 15], [3, 17], [3, 19], [3, 34], [3, 41], [3, 55], [3, 56], [3, 60], [3, 61], [3, 66], [3, 67], [3, 69], [3, 76], [3, 82], [3, 88], [3, 90], [3, 92], [3, 93], [3, 96], [3, 101], [3, 102], [3, 103], [3, 105], [3, 114], [3, 116], [3, 117], [3, 133], [3, 134], [3, 140], [3, 158], [3, 159], [3, 160], [3, 168], [3, 177], [3, 179], [4, 16], [4, 17], [4, 34], [4, 42], [4, 45], [4, 49], [4, 50], [4, 57], [4, 60], [4, 61], [4, 62], [4, 83], [4, 84], [4, 89], [4, 90], [4, 99], [4, 101], [4, 108], [4, 110], [4, 114], [4, 118], [4, 122], [4, 127], [4, 129], [4, 131], [4, 134], [4, 135], [4, 138], [4, 152], [4, 154], [4, 157], [4, 158], [4, 159], [4, 176], [5, 10], [5, 11], [5, 34], [5, 37], [5, 44], [5, 47], [5, 48], [5, 56], [5, 64], [5, 69], [5, 73], [5, 75], [5, 80], [5, 81], [5, 86], [5, 88], [5, 89], [5, 99], [5, 107], [5, 110], [5, 120], [5, 125], [5, 128], [5, 132], [5, 134], [5, 145], [5, 162], [5, 164], [5, 165], [5, 173], [5, 175], [6, 10], [6, 14], [6, 18], [6, 25], [6, 29], [6, 47], [6, 48], [6, 51], [6, 53], [6, 58], [6, 62], [6, 67], [6, 74], [6, 81], [6, 83], [6, 86], [6, 89], [6, 90], [6, 93], [6, 94], [6, 96], [6, 101], [6, 102], [6, 103], [6, 105], [6, 110], [6, 111], [6, 124], [6, 128], [6, 130], [6, 132], [6, 151], [6, 153], [6, 159], [6, 161], [6, 162], [6, 165], [6, 166], [6, 167], [6, 170], [6, 173], [6, 174], [6, 178], [6, 179], [7, 15], [7, 16], [7, 19], [7, 21], [7, 23], [7, 25], [7, 29], [7, 32], [7, 34], [7, 35], [7, 42], [7, 46], [7, 51], [7, 54], [7, 68], [7, 69], [7, 70], [7, 71], [7, 72], [7, 79], [7, 85], [7, 89], [7, 104], [7, 105], [7, 106], [7, 107], [7, 109], [7, 111], [7, 114], [7, 126], [7, 127], [7, 131], [7, 133], [7, 134], [7, 136], [7, 146], [7, 149], [7, 155], [7, 156], [7, 158], [7, 162], [7, 166], [7, 174], [7, 175], [8, 24], [8, 25], [8, 28], [8, 31], [8, 39], [8, 40], [8, 43], [8, 45], [8, 46], [8, 48], [8, 51], [8, 56], [8, 65], [8, 67], [8, 68], [8, 69], [8, 84], [8, 86], [8, 87], [8, 90], [8, 91], [8, 93], [8, 101], [8, 102], [8, 109], [8, 111], [8, 115], [8, 120], [8, 125], [8, 129], [8, 133], [8, 136], [8, 138], [8, 145], [8, 146], [8, 151], [8, 157], [8, 166], [8, 177], [8, 179], [9, 10], [9, 11], [9, 15], [9, 20], [9, 32], [9, 45], [9, 47], [9, 56], [9, 57], [9, 59], [9, 64], [9, 70], [9, 73], [9, 83], [9, 86], [9, 88], [9, 89], [9, 90], [9, 97], [9, 99], [9, 101], [9, 102], [9, 103], [9, 110], [9, 115], [9, 126], [9, 138], [9, 143], [9, 146], [9, 166], [9, 177], [9, 178], [10, 23], [10, 25], [10, 27], [10, 33], [10, 34], [10, 37], [10, 38], [10, 39], [10, 48], [10, 50], [10, 51], [10, 52], [10, 58], [10, 65], [10, 67], [10, 70], [10, 75], [10, 81], [10, 82], [10, 92], [10, 98], [10, 100], [10, 103], [10, 108], [10, 112], [10, 117], [10, 119], [10, 120], [10, 122], [10, 127], [10, 128], [10, 134], [10, 139], [10, 142], [10, 143], [10, 148], [10, 152], [10, 154], [10, 156], [10, 165], [10, 175], [10, 177], [10, 179], [11, 17], [11, 20], [11, 24], [11, 34], [11, 42], [11, 47], [11, 65], [11, 66], [11, 67], [11, 70], [11, 73], [11, 77], [11, 81], [11, 83], [11, 98], [11, 117], [11, 122], [11, 130], [11, 136], [11, 138], [11, 150], [11, 165], [11, 174], [12, 26], [12, 29], [12, 34], [12, 48], [12, 58], [12, 62], [12, 73], [12, 79], [12, 83], [12, 85], [12, 86], [12, 90], [12, 99], [12, 109], [12, 123], [12, 125], [12, 131], [12, 134], [12, 135], [12, 139], [12, 152], [12, 154], [12, 155], [12, 164], [12, 166], [12, 169], [12, 175], [12, 177], [13, 17], [13, 28], [13, 33], [13, 37], [13, 39], [13, 43], [13, 46], [13, 49], [13, 52], [13, 56], [13, 57], [13, 61], [13, 63], [13, 70], [13, 71], [13, 85], [13, 90], [13, 96], [13, 105], [13, 109], [13, 110], [13, 116], [13, 123], [13, 124], [13, 127], [13, 132], [13, 133], [13, 143], [13, 149], [13, 150], [13, 151], [13, 152], [13, 157], [13, 165], [13, 170], [13, 171], [13, 175], [14, 21], [14, 30], [14, 36], [14, 38], [14, 39], [14, 44], [14, 45], [14, 50], [14, 54], [14, 62], [14, 67], [14, 72], [14, 75], [14, 81], [14, 88], [14, 89], [14, 90], [14, 95], [14, 102], [14, 103], [14, 110], [14, 111], [14, 114], [14, 117], [14, 118], [14, 119], [14, 123], [14, 127], [14, 130], [14, 137], [14, 138], [14, 145], [14, 146], [14, 147], [14, 150], [14, 153], [14, 163], [14, 165], [14, 168], [14, 172], [15, 19], [15, 24], [15, 28], [15, 30], [15, 32], [15, 41], [15, 44], [15, 51], [15, 59], [15, 65], [15, 66], [15, 70], [15, 71], [15, 73], [15, 79], [15, 84], [15, 91], [15, 94], [15, 102], [15, 108], [15, 111], [15, 117], [15, 120], [15, 124], [15, 126], [15, 127], [15, 142], [15, 144], [15, 146], [15, 149], [15, 150], [15, 158], [15, 165], [15, 169], [15, 170], [15, 177], [16, 19], [16, 33], [16, 38], [16, 42], [16, 43], [16, 49], [16, 52], [16, 56], [16, 58], [16, 71], [16, 72], [16, 77], [16, 78], [16, 80], [16, 85], [16, 91], [16, 103], [16, 107], [16, 108], [16, 129], [16, 137], [16, 138], [16, 139], [16, 148], [16, 150], [16, 151], [16, 156], [16, 157], [16, 165], [16, 173], [16, 174], [17, 23], [17, 26], [17, 36], [17, 37], [17, 39], [17, 48], [17, 53], [17, 57], [17, 58], [17, 64], [17, 65], [17, 77], [17, 84], [17, 95], [17, 97], [17, 99], [17, 110], [17, 113], [17, 118], [17, 122], [17, 144], [17, 148], [17, 161], [17, 173], [17, 176], [18, 31], [18, 32], [18, 33], [18, 37], [18, 55], [18, 57], [18, 58], [18, 63], [18, 73], [18, 77], [18, 82], [18, 84], [18, 89], [18, 95], [18, 98], [18, 99], [18, 103], [18, 111], [18, 119], [18, 121], [18, 135], [18, 136], [18, 139], [18, 142], [18, 149], [18, 153], [18, 159], [18, 161], [18, 162], [19, 20], [19, 21], [19, 23], [19, 28], [19, 32], [19, 34], [19, 47], [19, 52], [19, 55], [19, 66], [19, 67], [19, 70], [19, 73], [19, 79], [19, 81], [19, 86], [19, 87], [19, 89], [19, 93], [19, 99], [19, 100], [19, 106], [19, 108], [19, 117], [19, 119], [19, 120], [19, 121], [19, 127], [19, 133], [19, 144], [19, 147], [19, 152], [19, 155], [19, 160], [19, 166], [19, 168], [19, 174], [19, 175], [20, 24], [20, 32], [20, 33], [20, 57], [20, 59], [20, 60], [20, 63], [20, 66], [20, 70], [20, 75], [20, 78], [20, 86], [20, 94], [20, 97], [20, 98], [20, 101], [20, 106], [20, 111], [20, 117], [20, 121], [20, 124], [20, 130], [20, 131], [20, 134], [20, 136], [20, 141], [20, 157], [20, 158], [20, 159], [20, 169], [21, 28], [21, 35], [21, 38], [21, 39], [21, 58], [21, 60], [21, 61], [21, 65], [21, 71], [21, 82], [21, 88], [21, 102], [21, 107], [21, 110], [21, 113], [21, 115], [21, 117], [21, 124], [21, 130], [21, 146], [21, 149], [21, 153], [21, 159], [21, 160], [21, 161], [21, 172], [21, 175], [22, 23], [22, 25], [22, 27], [22, 36], [22, 37], [22, 38], [22, 45], [22, 46], [22, 49], [22, 51], [22, 52], [22, 54], [22, 57], [22, 58], [22, 60], [22, 61], [22, 66], [22, 69], [22, 88], [22, 89], [22, 92], [22, 101], [22, 102], [22, 110], [22, 113], [22, 116], [22, 123], [22, 130], [22, 139], [22, 141], [22, 145], [22, 149], [22, 151], [22, 155], [22, 161], [22, 167], [22, 172], [22, 174], [22, 175], [22, 179], [23, 28], [23, 32], [23, 33], [23, 35], [23, 37], [23, 40], [23, 46], [23, 55], [23, 72], [23, 88], [23, 92], [23, 94], [23, 99], [23, 102], [23, 106], [23, 110], [23, 115], [23, 119], [23, 120], [23, 126], [23, 137], [23, 138], [23, 144], [23, 145], [23, 152], [23, 153], [23, 174], [23, 176], [24, 44], [24, 45], [24, 65], [24, 73], [24, 81], [24, 82], [24, 88], [24, 93], [24, 102], [24, 113], [24, 116], [24, 118], [24, 120], [24, 129], [24, 132], [24, 135], [24, 137], [24, 149], [24, 154], [24, 161], [24, 163], [24, 168], [24, 174], [24, 178], [25, 31], [25, 33], [25, 36], [25, 58], [25, 64], [25, 65], [25, 67], [25, 69], [25, 77], [25, 79], [25, 87], [25, 88], [25, 91], [25, 99], [25, 100], [25, 112], [25, 123], [25, 126], [25, 127], [25, 129], [25, 131], [25, 134], [25, 136], [25, 144], [25, 164], [26, 27], [26, 29], [26, 35], [26, 37], [26, 40], [26, 48], [26, 50], [26, 55], [26, 58], [26, 61], [26, 63], [26, 66], [26, 87], [26, 100], [26, 104], [26, 105], [26, 108], [26, 112], [26, 116], [26, 129], [26, 137], [26, 148], [26, 149], [26, 153], [26, 154], [26, 161], [26, 171], [26, 175], [26, 176], [27, 32], [27, 36], [27, 54], [27, 55], [27, 63], [27, 65], [27, 68], [27, 72], [27, 75], [27, 77], [27, 91], [27, 102], [27, 107], [27, 108], [27, 116], [27, 118], [27, 124], [27, 126], [27, 127], [27, 141], [27, 145], [27, 146], [27, 152], [27, 157], [27, 159], [27, 160], [27, 162], [27, 163], [27, 164], [27, 174], [27, 175], [27, 176], [27, 178], [28, 31], [28, 38], [28, 72], [28, 79], [28, 90], [28, 93], [28, 106], [28, 131], [28, 133], [28, 135], [28, 137], [28, 138], [28, 140], [28, 146], [28, 149], [28, 154], [28, 155], [28, 156], [28, 159], [28, 162], [28, 167], [28, 175], [28, 177], [29, 33], [29, 34], [29, 51], [29, 52], [29, 56], [29, 59], [29, 67], [29, 68], [29, 75], [29, 79], [29, 83], [29, 88], [29, 93], [29, 97], [29, 100], [29, 110], [29, 120], [29, 128], [29, 130], [29, 133], [29, 150], [29, 163], [29, 173], [30, 36], [30, 40], [30, 45], [30, 46], [30, 47], [30, 57], [30, 58], [30, 62], [30, 64], [30, 70], [30, 72], [30, 74], [30, 78], [30, 80], [30, 83], [30, 89], [30, 93], [30, 101], [30, 117], [30, 119], [30, 124], [30, 128], [30, 130], [30, 131], [30, 140], [30, 144], [30, 145], [30, 149], [30, 161], [31, 43], [31, 47], [31, 49], [31, 56], [31, 57], [31, 60], [31, 61], [31, 62], [31, 63], [31, 65], [31, 71], [31, 80], [31, 84], [31, 87], [31, 92], [31, 94], [31, 105], [31, 106], [31, 108], [31, 127], [31, 137], [31, 146], [31, 147], [31, 157], [31, 159], [31, 164], [31, 167], [31, 174], [31, 178], [32, 33], [32, 34], [32, 35], [32, 38], [32, 61], [32, 63], [32, 74], [32, 77], [32, 82], [32, 90], [32, 101], [32, 102], [32, 105], [32, 108], [32, 123], [32, 126], [32, 131], [32, 132], [32, 133], [32, 134], [32, 143], [32, 145], [32, 149], [32, 150], [32, 153], [32, 157], [32, 160], [32, 166], [32, 167], [32, 168], [32, 173], [32, 177], [33, 36], [33, 48], [33, 50], [33, 51], [33, 54], [33, 61], [33, 83], [33, 85], [33, 93], [33, 99], [33, 100], [33, 107], [33, 109], [33, 114], [33, 115], [33, 119], [33, 122], [33, 125], [33, 128], [33, 134], [33, 136], [33, 142], [33, 144], [33, 148], [33, 163], [33, 166], [33, 169], [33, 179], [34, 42], [34, 61], [34, 76], [34, 80], [34, 81], [34, 100], [34, 104], [34, 108], [34, 109], [34, 113], [34, 114], [34, 116], [34, 132], [34, 144], [34, 151], [34, 156], [34, 170], [34, 171], [34, 174], [34, 177], [35, 36], [35, 48], [35, 50], [35, 54], [35, 58], [35, 60], [35, 65], [35, 86], [35, 91], [35, 95], [35, 98], [35, 100], [35, 107], [35, 109], [35, 111], [35, 116], [35, 117], [35, 121], [35, 125], [35, 135], [35, 141], [35, 146], [35, 150], [35, 158], [35, 163], [35, 164], [35, 166], [35, 169], [35, 170], [35, 172], [35, 174], [35, 177], [36, 37], [36, 43], [36, 56], [36, 57], [36, 61], [36, 63], [36, 64], [36, 69], [36, 70], [36, 78], [36, 82], [36, 84], [36, 87], [36, 88], [36, 89], [36, 92], [36, 98], [36, 104], [36, 116], [36, 128], [36, 130], [36, 137], [36, 139], [36, 142], [36, 146], [36, 148], [36, 149], [36, 160], [36, 163], [36, 164], [36, 171], [36, 172], [36, 177], [36, 178], [37, 38], [37, 45], [37, 46], [37, 48], [37, 53], [37, 62], [37, 66], [37, 70], [37, 72], [37, 78], [37, 82], [37, 89], [37, 94], [37, 97], [37, 102], [37, 113], [37, 114], [37, 135], [37, 147], [37, 151], [37, 153], [37, 155], [37, 160], [37, 177], [38, 41], [38, 43], [38, 48], [38, 49], [38, 50], [38, 62], [38, 70], [38, 73], [38, 83], [38, 85], [38, 87], [38, 88], [38, 94], [38, 95], [38, 101], [38, 102], [38, 105], [38, 109], [38, 111], [38, 116], [38, 118], [38, 120], [38, 123], [38, 124], [38, 135], [38, 143], [38, 145], [38, 150], [38, 155], [38, 157], [38, 165], [38, 168], [38, 169], [39, 43], [39, 61], [39, 63], [39, 71], [39, 74], [39, 82], [39, 85], [39, 93], [39, 97], [39, 99], [39, 103], [39, 115], [39, 116], [39, 119], [39, 121], [39, 125], [39, 131], [39, 135], [39, 136], [39, 137], [39, 140], [39, 144], [39, 149], [39, 157], [39, 160], [39, 165], [39, 168], [39, 178], [40, 43], [40, 61], [40, 63], [40, 64], [40, 66], [40, 67], [40, 69], [40, 81], [40, 86], [40, 87], [40, 90], [40, 92], [40, 99], [40, 101], [40, 104], [40, 106], [40, 112], [40, 113], [40, 122], [40, 127], [40, 128], [40, 132], [40, 134], [40, 143], [40, 145], [40, 153], [40, 154], [40, 157], [40, 159], [40, 164], [40, 168], [40, 177], [41, 42], [41, 43], [41, 44], [41, 50], [41, 57], [41, 63], [41, 66], [41, 68], [41, 70], [41, 85], [41, 91], [41, 100], [41, 101], [41, 103], [41, 104], [41, 108], [41, 113], [41, 115], [41, 119], [41, 127], [41, 132], [41, 134], [41, 155], [41, 156], [41, 157], [41, 168], [41, 169], [41, 174], [42, 51], [42, 52], [42, 53], [42, 56], [42, 63], [42, 64], [42, 68], [42, 79], [42, 81], [42, 87], [42, 98], [42, 99], [42, 105], [42, 119], [42, 122], [42, 123], [42, 133], [42, 135], [42, 140], [42, 142], [42, 143], [42, 144], [42, 146], [42, 147], [42, 148], [42, 153], [42, 159], [42, 166], [42, 167], [42, 177], [43, 50], [43, 51], [43, 60], [43, 80], [43, 85], [43, 86], [43, 92], [43, 98], [43, 108], [43, 114], [43, 117], [43, 121], [43, 129], [43, 131], [43, 136], [43, 140], [43, 147], [43, 150], [43, 151], [43, 155], [43, 156], [43, 158], [43, 161], [43, 173], [43, 178], [44, 47], [44, 48], [44, 55], [44, 56], [44, 63], [44, 64], [44, 66], [44, 69], [44, 80], [44, 88], [44, 90], [44, 93], [44, 96], [44, 102], [44, 109], [44, 115], [44, 117], [44, 123], [44, 125], [44, 129], [44, 130], [44, 132], [44, 141], [44, 144], [44, 145], [44, 162], [44, 168], [44, 169], [44, 174], [44, 178], [45, 56], [45, 66], [45, 74], [45, 77], [45, 88], [45, 98], [45, 103], [45, 112], [45, 117], [45, 120], [45, 126], [45, 128], [45, 131], [45, 133], [45, 135], [45, 136], [45, 144], [45, 151], [45, 152], [45, 160], [45, 164], [45, 167], [46, 54], [46, 58], [46, 66], [46, 71], [46, 73], [46, 77], [46, 95], [46, 109], [46, 112], [46, 114], [46, 118], [46, 119], [46, 121], [46, 126], [46, 132], [46, 135], [46, 137], [46, 138], [46, 142], [46, 144], [46, 146], [46, 153], [46, 157], [46, 159], [46, 162], [46, 165], [46, 168], [46, 178], [46, 179], [47, 49], [47, 53], [47, 58], [47, 64], [47, 65], [47, 68], [47, 85], [47, 94], [47, 98], [47, 101], [47, 102], [47, 113], [47, 114], [47, 117], [47, 119], [47, 124], [47, 125], [47, 133], [47, 137], [47, 139], [47, 147], [47, 154], [47, 159], [47, 160], [47, 162], [47, 174], [47, 175], [47, 178], [48, 53], [48, 58], [48, 59], [48, 60], [48, 62], [48, 67], [48, 71], [48, 76], [48, 81], [48, 82], [48, 95], [48, 104], [48, 106], [48, 112], [48, 114], [48, 115], [48, 118], [48, 119], [48, 128], [48, 130], [48, 131], [48, 133], [48, 139], [48, 140], [48, 149], [48, 153], [48, 162], [48, 167], [48, 172], [49, 54], [49, 55], [49, 60], [49, 61], [49, 76], [49, 82], [49, 93], [49, 94], [49, 103], [49, 107], [49, 108], [49, 111], [49, 113], [49, 118], [49, 122], [49, 124], [49, 135], [49, 139], [49, 163], [49, 164], [49, 171], [49, 177], [50, 63], [50, 67], [50, 68], [50, 74], [50, 89], [50, 102], [50, 112], [50, 114], [50, 116], [50, 127], [50, 131], [50, 133], [50, 135], [50, 138], [50, 139], [50, 141], [50, 149], [50, 151], [50, 158], [50, 170], [50, 171], [50, 173], [50, 176], [51, 66], [51, 73], [51, 79], [51, 80], [51, 81], [51, 91], [51, 94], [51, 104], [51, 107], [51, 116], [51, 117], [51, 122], [51, 124], [51, 128], [51, 129], [51, 137], [51, 143], [51, 153], [51, 159], [51, 168], [51, 172], [51, 173], [51, 176], [52, 63], [52, 64], [52, 66], [52, 70], [52, 71], [52, 76], [52, 80], [52, 82], [52, 84], [52, 87], [52, 88], [52, 98], [52, 99], [52, 100], [52, 106], [52, 108], [52, 124], [52, 126], [52, 129], [52, 134], [52, 137], [52, 142], [52, 143], [52, 144], [52, 156], [52, 157], [52, 166], [52, 171], [52, 174], [52, 177], [53, 55], [53, 69], [53, 86], [53, 92], [53, 99], [53, 105], [53, 108], [53, 116], [53, 121], [53, 123], [53, 128], [53, 129], [53, 131], [53, 133], [53, 138], [53, 139], [53, 151], [53, 159], [53, 167], [53, 176], [53, 177], [54, 60], [54, 68], [54, 71], [54, 74], [54, 78], [54, 81], [54, 82], [54, 89], [54, 92], [54, 97], [54, 104], [54, 106], [54, 116], [54, 120], [54, 128], [54, 135], [54, 146], [54, 154], [54, 158], [54, 159], [54, 163], [54, 168], [54, 171], [55, 56], [55, 66], [55, 68], [55, 76], [55, 81], [55, 90], [55, 99], [55, 103], [55, 104], [55, 106], [55, 110], [55, 124], [55, 131], [55, 133], [55, 136], [55, 142], [55, 152], [55, 156], [55, 158], [55, 160], [55, 161], [55, 163], [55, 175], [56, 67], [56, 87], [56, 89], [56, 91], [56, 98], [56, 104], [56, 105], [56, 107], [56, 110], [56, 118], [56, 119], [56, 127], [56, 146], [56, 148], [56, 152], [56, 154], [56, 160], [56, 166], [56, 170], [56, 175], [56, 176], [56, 178], [57, 63], [57, 74], [57, 78], [57, 91], [57, 98], [57, 102], [57, 109], [57, 110], [57, 123], [57, 126], [57, 130], [57, 133], [57, 135], [57, 141], [57, 144], [57, 148], [57, 158], [57, 165], [57, 178], [57, 179], [58, 59], [58, 60], [58, 61], [58, 63], [58, 71], [58, 77], [58, 79], [58, 85], [58, 89], [58, 94], [58, 97], [58, 105], [58, 120], [58, 123], [58, 124], [58, 125], [58, 127], [58, 132], [58, 149], [58, 164], [58, 168], [58, 169], [58, 172], [58, 174], [59, 61], [59, 64], [59, 68], [59, 69], [59, 99], [59, 107], [59, 116], [59, 119], [59, 134], [59, 138], [59, 140], [59, 141], [59, 142], [59, 146], [59, 148], [59, 163], [59, 168], [59, 169], [60, 65], [60, 68], [60, 77], [60, 80], [60, 82], [60, 87], [60, 89], [60, 94], [60, 95], [60, 111], [60, 120], [60, 126], [60, 134], [60, 136], [60, 137], [60, 144], [60, 146], [60, 147], [60, 150], [60, 160], [60, 161], [60, 163], [60, 166], [60, 167], [60, 173], [60, 178], [61, 62], [61, 66], [61, 69], [61, 78], [61, 82], [61, 88], [61, 92], [61, 100], [61, 102], [61, 109], [61, 114], [61, 134], [61, 138], [61, 139], [61, 141], [61, 148], [61, 153], [61, 163], [61, 165], [61, 170], [61, 173], [62, 65], [62, 68], [62, 69], [62, 73], [62, 80], [62, 81], [62, 83], [62, 91], [62, 101], [62, 108], [62, 115], [62, 118], [62, 119], [62, 122], [62, 126], [62, 131], [62, 133], [62, 134], [62, 140], [62, 142], [62, 147], [62, 149], [62, 150], [62, 151], [62, 154], [62, 162], [62, 165], [62, 166], [62, 169], [62, 176], [63, 64], [63, 75], [63, 77], [63, 81], [63, 93], [63, 97], [63, 116], [63, 130], [63, 136], [63, 146], [63, 153], [63, 159], [63, 163], [63, 166], [63, 168], [63, 174], [63, 179], [64, 66], [64, 71], [64, 75], [64, 76], [64, 81], [64, 87], [64, 91], [64, 96], [64, 106], [64, 128], [64, 130], [64, 135], [64, 136], [64, 138], [64, 143], [64, 146], [64, 148], [64, 149], [64, 157], [64, 168], [64, 170], [64, 176], [65, 68], [65, 71], [65, 81], [65, 93], [65, 99], [65, 102], [65, 104], [65, 106], [65, 107], [65, 108], [65, 109], [65, 110], [65, 111], [65, 119], [65, 121], [65, 127], [65, 132], [65, 137], [65, 139], [65, 143], [65, 151], [65, 158], [65, 160], [65, 161], [65, 164], [65, 165], [65, 168], [65, 176], [65, 179], [66, 67], [66, 76], [66, 95], [66, 102], [66, 108], [66, 109], [66, 116], [66, 119], [66, 124], [66, 125], [66, 131], [66, 135], [66, 142], [66, 145], [66, 154], [66, 155], [66, 156], [66, 157], [66, 166], [66, 178], [67, 68], [67, 74], [67, 86], [67, 94], [67, 97], [67, 110], [67, 111], [67, 117], [67, 121], [67, 125], [67, 126], [67, 130], [67, 133], [67, 134], [67, 136], [67, 139], [67, 145], [67, 146], [67, 149], [67, 150], [67, 158], [67, 159], [67, 163], [67, 173], [67, 175], [67, 177], [68, 69], [68, 84], [68, 86], [68, 96], [68, 99], [68, 113], [68, 117], [68, 120], [68, 122], [68, 123], [68, 130], [68, 134], [68, 148], [68, 151], [68, 153], [68, 154], [68, 161], [68, 164], [68, 172], [68, 173], [68, 176], [69, 70], [69, 73], [69, 80], [69, 87], [69, 92], [69, 101], [69, 102], [69, 104], [69, 113], [69, 118], [69, 121], [69, 134], [69, 144], [69, 145], [69, 150], [69, 151], [69, 157], [69, 166], [69, 171], [69, 173], [69, 174], [69, 175], [70, 78], [70, 81], [70, 95], [70, 102], [70, 107], [70, 109], [70, 110], [70, 112], [70, 113], [70, 117], [70, 121], [70, 122], [70, 124], [70, 126], [70, 131], [70, 142], [70, 144], [70, 145], [70, 149], [70, 155], [70, 158], [70, 159], [70, 160], [70, 161], [70, 162], [70, 170], [70, 173], [70, 174], [70, 176], [71, 74], [71, 83], [71, 86], [71, 87], [71, 92], [71, 94], [71, 112], [71, 113], [71, 118], [71, 119], [71, 127], [71, 140], [71, 145], [71, 147], [71, 148], [71, 149], [71, 150], [71, 162], [71, 172], [71, 173], [71, 178], [72, 74], [72, 87], [72, 88], [72, 89], [72, 102], [72, 116], [72, 119], [72, 121], [72, 126], [72, 129], [72, 130], [72, 135], [72, 136], [72, 144], [72, 145], [72, 146], [72, 148], [72, 159], [72, 165], [72, 167], [72, 172], [72, 175], [73, 75], [73, 77], [73, 78], [73, 79], [73, 80], [73, 83], [73, 89], [73, 98], [73, 104], [73, 108], [73, 109], [73, 120], [73, 124], [73, 126], [73, 142], [73, 147], [73, 155], [73, 165], [73, 167], [73, 168], [73, 170], [73, 176], [74, 80], [74, 82], [74, 83], [74, 84], [74, 86], [74, 92], [74, 96], [74, 99], [74, 103], [74, 107], [74, 108], [74, 113], [74, 117], [74, 121], [74, 125], [74, 128], [74, 129], [74, 136], [74, 140], [74, 141], [74, 143], [74, 155], [74, 161], [74, 165], [74, 168], [74, 169], [74, 173], [74, 175], [74, 177], [74, 178], [75, 76], [75, 80], [75, 82], [75, 90], [75, 99], [75, 103], [75, 105], [75, 112], [75, 113], [75, 116], [75, 122], [75, 127], [75, 129], [75, 135], [75, 136], [75, 143], [75, 146], [75, 147], [75, 176], [75, 178], [76, 81], [76, 103], [76, 106], [76, 122], [76, 133], [76, 135], [76, 139], [76, 140], [76, 142], [76, 143], [76, 150], [76, 151], [76, 159], [76, 160], [76, 165], [76, 166], [76, 170], [76, 171], [76, 178], [77, 84], [77, 85], [77, 88], [77, 91], [77, 100], [77, 102], [77, 108], [77, 110], [77, 118], [77, 122], [77, 125], [77, 134], [77, 152], [77, 168], [77, 176], [77, 177], [78, 80], [78, 81], [78, 104], [78, 105], [78, 123], [78, 124], [78, 125], [78, 129], [78, 131], [78, 132], [78, 133], [78, 134], [78, 135], [78, 141], [78, 155], [78, 160], [78, 177], [79, 83], [79, 89], [79, 91], [79, 92], [79, 93], [79, 95], [79, 96], [79, 97], [79, 100], [79, 101], [79, 103], [79, 105], [79, 118], [79, 122], [79, 124], [79, 129], [79, 136], [79, 139], [79, 145], [79, 149], [79, 160], [79, 162], [79, 165], [79, 166], [80, 84], [80, 85], [80, 89], [80, 97], [80, 100], [80, 102], [80, 109], [80, 116], [80, 118], [80, 120], [80, 134], [80, 137], [80, 148], [80, 151], [80, 155], [80, 156], [80, 157], [80, 159], [80, 160], [80, 162], [80, 164], [80, 165], [80, 171], [80, 172], [80, 173], [80, 179], [81, 83], [81, 84], [81, 91], [81, 94], [81, 103], [81, 104], [81, 116], [81, 126], [81, 134], [81, 137], [81, 138], [81, 153], [81, 160], [81, 169], [82, 84], [82, 87], [82, 89], [82, 92], [82, 97], [82, 99], [82, 102], [82, 111], [82, 115], [82, 122], [82, 125], [82, 127], [82, 132], [82, 135], [82, 143], [82, 147], [82, 156], [82, 160], [82, 168], [82, 170], [82, 171], [82, 173], [82, 174], [82, 175], [82, 179], [83, 96], [83, 100], [83, 103], [83, 107], [83, 114], [83, 120], [83, 124], [83, 138], [83, 144], [83, 160], [83, 161], [83, 168], [83, 174], [83, 175], [84, 85], [84, 88], [84, 101], [84, 125], [84, 134], [84, 135], [84, 141], [84, 143], [84, 151], [84, 152], [84, 157], [84, 160], [84, 163], [84, 166], [84, 169], [84, 171], [84, 174], [84, 177], [85, 90], [85, 96], [85, 118], [85, 125], [85, 127], [85, 128], [85, 131], [85, 137], [85, 139], [85, 154], [85, 157], [85, 161], [85, 163], [85, 171], [85, 172], [85, 174], [85, 177], [85, 178], [86, 89], [86, 91], [86, 95], [86, 106], [86, 108], [86, 114], [86, 126], [86, 128], [86, 156], [86, 158], [86, 159], [86, 172], [86, 173], [87, 89], [87, 90], [87, 91], [87, 97], [87, 99], [87, 100], [87, 101], [87, 102], [87, 107], [87, 112], [87, 119], [87, 125], [87, 133], [87, 140], [87, 143], [87, 146], [87, 148], [87, 153], [87, 154], [87, 156], [87, 161], [87, 162], [87, 170], [87, 171], [87, 172], [87, 178], [88, 90], [88, 119], [88, 121], [88, 131], [88, 135], [88, 138], [88, 155], [88, 163], [88, 170], [88, 171], [88, 173], [88, 174], [88, 175], [88, 177], [89, 92], [89, 98], [89, 111], [89, 113], [89, 114], [89, 120], [89, 124], [89, 134], [89, 140], [89, 141], [89, 145], [89, 154], [89, 160], [89, 164], [89, 171], [89, 173], [90, 92], [90, 95], [90, 98], [90, 101], [90, 111], [90, 124], [90, 126], [90, 135], [90, 136], [90, 143], [90, 154], [90, 168], [90, 169], [90, 176], [91, 95], [91, 102], [91, 108], [91, 109], [91, 114], [91, 129], [91, 133], [91, 134], [91, 150], [91, 155], [91, 158], [91, 162], [91, 163], [91, 164], [91, 175], [92, 93], [92, 98], [92, 105], [92, 109], [92, 120], [92, 130], [92, 136], [92, 139], [92, 141], [92, 146], [92, 149], [92, 154], [92, 167], [92, 179], [93, 96], [93, 107], [93, 108], [93, 112], [93, 113], [93, 114], [93, 115], [93, 116], [93, 118], [93, 122], [93, 123], [93, 130], [93, 131], [93, 132], [93, 133], [93, 136], [93, 137], [93, 149], [93, 151], [93, 156], [93, 157], [93, 169], [93, 174], [93, 177], [94, 95], [94, 98], [94, 100], [94, 102], [94, 114], [94, 116], [94, 122], [94, 127], [94, 149], [94, 155], [94, 169], [94, 172], [94, 178], [95, 97], [95, 98], [95, 99], [95, 110], [95, 114], [95, 118], [95, 129], [95, 138], [95, 143], [95, 144], [95, 146], [95, 157], [95, 166], [95, 168], [95, 172], [95, 173], [96, 98], [96, 108], [96, 110], [96, 116], [96, 126], [96, 139], [96, 142], [96, 149], [96, 150], [96, 154], [96, 157], [96, 161], [96, 162], [96, 165], [96, 167], [96, 170], [96, 179], [97, 99], [97, 102], [97, 104], [97, 105], [97, 108], [97, 109], [97, 117], [97, 124], [97, 129], [97, 132], [97, 133], [97, 137], [97, 139], [97, 148], [97, 149], [97, 155], [97, 157], [97, 158], [97, 172], [97, 173], [97, 175], [97, 178], [98, 100], [98, 101], [98, 102], [98, 104], [98, 106], [98, 115], [98, 116], [98, 124], [98, 129], [98, 138], [98, 151], [98, 155], [98, 159], [98, 161], [98, 164], [98, 168], [98, 176], [98, 177], [99, 102], [99, 104], [99, 106], [99, 107], [99, 116], [99, 121], [99, 124], [99, 125], [99, 127], [99, 134], [99, 139], [99, 142], [99, 143], [99, 157], [99, 158], [99, 163], [99, 173], [99, 176], [100, 109], [100, 110], [100, 111], [100, 113], [100, 116], [100, 118], [100, 134], [100, 139], [100, 140], [100, 143], [100, 148], [100, 149], [100, 154], [100, 159], [100, 168], [100, 178], [101, 110], [101, 111], [101, 113], [101, 116], [101, 117], [101, 134], [101, 139], [101, 140], [101, 146], [101, 150], [101, 152], [101, 153], [101, 154], [101, 169], [101, 170], [101, 171], [101, 176], [102, 105], [102, 108], [102, 109], [102, 111], [102, 113], [102, 120], [102, 125], [102, 132], [102, 135], [102, 142], [102, 147], [102, 149], [102, 164], [102, 173], [103, 117], [103, 119], [103, 120], [103, 130], [103, 132], [103, 135], [103, 136], [103, 137], [103, 140], [103, 143], [103, 146], [103, 152], [103, 154], [103, 157], [103, 159], [103, 160], [103, 166], [103, 171], [103, 175], [104, 106], [104, 108], [104, 112], [104, 114], [104, 115], [104, 121], [104, 130], [104, 136], [104, 139], [104, 143], [104, 146], [104, 147], [104, 151], [104, 170], [104, 174], [104, 176], [105, 106], [105, 108], [105, 111], [105, 113], [105, 115], [105, 118], [105, 120], [105, 121], [105, 128], [105, 132], [105, 134], [105, 148], [105, 149], [105, 161], [105, 164], [105, 171], [105, 174], [105, 177], [106, 107], [106, 121], [106, 124], [106, 135], [106, 139], [106, 141], [106, 144], [106, 148], [106, 149], [106, 151], [106, 153], [106, 156], [106, 170], [106, 176], [107, 112], [107, 115], [107, 117], [107, 126], [107, 142], [107, 154], [107, 157], [107, 166], [107, 167], [107, 168], [107, 169], [107, 173], [107, 174], [107, 177], [107, 179], [108, 109], [108, 110], [108, 111], [108, 114], [108, 115], [108, 116], [108, 119], [108, 121], [108, 122], [108, 124], [108, 130], [108, 132], [108, 137], [108, 139], [108, 143], [108, 146], [108, 150], [108, 154], [108, 156], [108, 159], [108, 166], [108, 167], [108, 168], [108, 169], [108, 172], [108, 174], [109, 116], [109, 117], [109, 122], [109, 124], [109, 125], [109, 126], [109, 128], [109, 130], [109, 145], [109, 148], [109, 149], [109, 150], [109, 151], [109, 156], [109, 157], [109, 158], [109, 169], [109, 172], [109, 178], [109, 179], [110, 111], [110, 113], [110, 123], [110, 128], [110, 131], [110, 136], [110, 138], [110, 141], [110, 145], [110, 154], [110, 159], [110, 167], [110, 168], [110, 172], [110, 179], [111, 123], [111, 131], [111, 137], [111, 153], [111, 155], [111, 156], [111, 159], [111, 163], [111, 165], [111, 175], [111, 176], [112, 115], [112, 116], [112, 119], [112, 121], [112, 125], [112, 130], [112, 140], [112, 150], [112, 152], [112, 153], [112, 159], [112, 161], [112, 163], [112, 168], [112, 172], [113, 125], [113, 126], [113, 129], [113, 130], [113, 131], [113, 133], [113, 145], [113, 150], [113, 156], [113, 162], [113, 164], [113, 171], [114, 119], [114, 122], [114, 125], [114, 131], [114, 133], [114, 135], [114, 136], [114, 140], [114, 141], [114, 146], [114, 155], [114, 160], [114, 163], [114, 174], [114, 176], [115, 121], [115, 127], [115, 130], [115, 134], [115, 136], [115, 143], [115, 146], [115, 149], [115, 150], [115, 154], [115, 166], [115, 172], [115, 178], [115, 179], [116, 126], [116, 135], [116, 136], [116, 141], [116, 145], [116, 148], [116, 152], [116, 154], [116, 166], [116, 172], [117, 118], [117, 120], [117, 121], [117, 135], [117, 138], [117, 147], [117, 148], [117, 161], [117, 164], [117, 165], [117, 167], [117, 174], [118, 120], [118, 123], [118, 125], [118, 139], [118, 142], [118, 143], [118, 148], [118, 150], [118, 153], [118, 172], [118, 174], [118, 179], [119, 121], [119, 124], [119, 148], [119, 149], [119, 150], [119, 160], [119, 178], [120, 127], [120, 128], [120, 138], [120, 140], [120, 142], [120, 155], [120, 160], [120, 163], [120, 176], [121, 122], [121, 123], [121, 129], [121, 137], [121, 138], [121, 142], [121, 148], [121, 150], [121, 154], [121, 155], [121, 160], [121, 163], [121, 165], [121, 170], [121, 175], [121, 177], [121, 179], [122, 123], [122, 135], [122, 138], [122, 145], [122, 146], [122, 150], [122, 154], [122, 159], [122, 166], [122, 174], [123, 135], [123, 136], [123, 143], [123, 145], [123, 147], [123, 163], [123, 166], [123, 173], [123, 174], [124, 134], [124, 135], [124, 138], [124, 143], [124, 145], [124, 160], [124, 162], [124, 166], [124, 167], [124, 178], [125, 129], [125, 136], [125, 138], [125, 144], [125, 152], [125, 155], [125, 158], [125, 162], [125, 172], [125, 174], [126, 128], [126, 129], [126, 131], [126, 134], [126, 135], [126, 142], [126, 143], [126, 145], [126, 148], [126, 157], [126, 159], [126, 161], [126, 168], [126, 179], [127, 137], [127, 141], [127, 142], [127, 146], [127, 148], [127, 150], [127, 151], [127, 154], [127, 155], [127, 156], [127, 157], [127, 161], [127, 164], [127, 166], [127, 170], [127, 172], [127, 175], [127, 176], [127, 179], [128, 138], [128, 140], [128, 144], [128, 148], [128, 151], [128, 153], [128, 161], [128, 175], [128, 177], [128, 179], [129, 139], [129, 144], [129, 153], [129, 155], [129, 156], [129, 159], [129, 161], [129, 165], [129, 167], [130, 131], [130, 144], [130, 156], [130, 158], [130, 161], [130, 162], [130, 171], [130, 177], [130, 178], [130, 179], [131, 132], [131, 142], [131, 143], [131, 154], [131, 159], [131, 162], [131, 174], [131, 178], [131, 179], [132, 134], [132, 140], [132, 141], [132, 148], [132, 155], [132, 169], [132, 177], [133, 135], [133, 138], [133, 142], [133, 145], [133, 146], [133, 148], [133, 151], [133, 152], [133, 154], [133, 157], [133, 162], [133, 163], [133, 179], [134, 161], [134, 170], [134, 177], [135, 137], [135, 139], [135, 141], [135, 147], [135, 148], [135, 152], [135, 155], [135, 167], [135, 169], [135, 170], [136, 139], [136, 140], [136, 148], [136, 154], [136, 161], [136, 165], [136, 173], [136, 176], [137, 141], [137, 146], [137, 147], [137, 152], [137, 154], [137, 156], [137, 160], [137, 168], [137, 169], [137, 170], [137, 174], [137, 176], [137, 178], [137, 179], [138, 141], [138, 145], [138, 147], [138, 159], [138, 171], [138, 173], [138, 177], [139, 143], [139, 145], [139, 150], [139, 154], [139, 156], [139, 158], [139, 160], [139, 162], [139, 165], [139, 173], [139, 179], [140, 148], [140, 154], [140, 157], [140, 165], [140, 170], [140, 175], [141, 148], [141, 150], [141, 157], [141, 161], [141, 166], [141, 167], [141, 168], [141, 174], [142, 151], [142, 152], [142, 154], [142, 161], [142, 163], [142, 169], [142, 171], [142, 172], [142, 175], [142, 176], [143, 145], [143, 152], [143, 158], [143, 164], [143, 169], [143, 170], [143, 172], [143, 173], [143, 174], [144, 146], [144, 151], [144, 156], [144, 159], [144, 165], [144, 168], [144, 175], [145, 162], [145, 164], [145, 166], [146, 150], [146, 163], [146, 171], [146, 173], [146, 174], [146, 178], [146, 179], [147, 150], [147, 153], [147, 155], [147, 158], [147, 159], [147, 160], [147, 164], [147, 172], [147, 173], [147, 174], [148, 153], [148, 157], [148, 158], [148, 162], [148, 163], [148, 164], [148, 165], [148, 169], [148, 172], [148, 174], [148, 175], [148, 176], [148, 178], [149, 154], [149, 157], [149, 159], [149, 171], [149, 173], [149, 175], [149, 176], [150, 153], [150, 157], [150, 163], [150, 164], [150, 167], [150, 177], [151, 152], [151, 153], [151, 159], [151, 160], [151, 164], [151, 166], [151, 167], [151, 172], [151, 179], [152, 155], [152, 162], [152, 163], [152, 164], [152, 174], [152, 177], [153, 154], [153, 160], [153, 165], [154, 163], [154, 166], [154, 169], [154, 172], [154, 179], [155, 162], [155, 164], [155, 167], [155, 173], [155, 176], [155, 179], [156, 165], [156, 170], [156, 174], [156, 177], [157, 158], [157, 175], [158, 166], [158, 168], [158, 175], [158, 178], [159, 160], [159, 165], [159, 173], [160, 165], [160, 168], [160, 170], [160, 173], [160, 174], [160, 175], [160, 178], [160, 179], [161, 170], [161, 172], [162, 165], [162, 166], [162, 167], [162, 169], [162, 171], [162, 173], [162, 175], [162, 179], [163, 164], [163, 165], [163, 172], [163, 175], [163, 179], [165, 166], [165, 170], [165, 174], [166, 169], [166, 176], [166, 177], [166, 178], [167, 168], [167, 170], [167, 171], [167, 173], [167, 176], [167, 179], [168, 171], [168, 172], [168, 175], [169, 173], [170, 173], [170, 179], [171, 172], [171, 176], [172, 174], [173, 175], [174, 176], [175, 178]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l5-s6/tests/run.py b/tasks/construct-nppc-dominating-set-l5-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-dominating-set-l5-s6/tests/test.sh b/tasks/construct-nppc-dominating-set-l5-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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-nppc-independent-set-l3-s2/environment/Dockerfile b/tasks/construct-nppc-independent-set-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-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-nppc-independent-set-l3-s2/environment/instance.json b/tasks/construct-nppc-independent-set-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c0c5dafc93f1fb18a5b18312f823bd28adab9696 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 2], [0, 7], [0, 9], [0, 11], [0, 12], [0, 16], [0, 20], [0, 23], [1, 2], [1, 9], [1, 12], [1, 20], [2, 5], [2, 7], [2, 8], [2, 9], [2, 13], [2, 14], [2, 15], [2, 16], [2, 19], [2, 20], [2, 21], [3, 6], [3, 7], [3, 14], [3, 20], [3, 23], [4, 7], [4, 12], [4, 13], [4, 23], [5, 6], [5, 7], [5, 12], [5, 20], [5, 23], [6, 7], [6, 9], [6, 10], [6, 11], [6, 13], [6, 17], [6, 20], [6, 21], [6, 22], [7, 9], [7, 14], [7, 19], [7, 20], [7, 21], [8, 9], [8, 11], [8, 12], [8, 13], [8, 17], [8, 20], [8, 23], [9, 15], [9, 16], [9, 17], [9, 18], [9, 21], [9, 23], [10, 12], [10, 13], [10, 14], [10, 16], [10, 20], [10, 23], [11, 13], [11, 14], [11, 20], [11, 21], [11, 23], [12, 13], [12, 14], [12, 16], [12, 17], [12, 19], [12, 20], [12, 21], [12, 23], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [15, 17], [15, 23], [16, 17], [16, 20], [16, 21], [16, 22], [16, 23], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [18, 20], [20, 21], [20, 22], [20, 23], [21, 23], [22, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s2/solution/solve.sh b/tasks/construct-nppc-independent-set-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..214078305f0559cb9b1daea626273ee74cd43612 --- /dev/null +++ b/tasks/construct-nppc-independent-set-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' +{"independent_set": [0, 1, 3, 4, 5, 8, 10, 15, 18, 19, 21, 22]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l3-s2/tests/check.py b/tasks/construct-nppc-independent-set-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s2/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-s2/tests/instance.json b/tasks/construct-nppc-independent-set-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c0c5dafc93f1fb18a5b18312f823bd28adab9696 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 2], [0, 7], [0, 9], [0, 11], [0, 12], [0, 16], [0, 20], [0, 23], [1, 2], [1, 9], [1, 12], [1, 20], [2, 5], [2, 7], [2, 8], [2, 9], [2, 13], [2, 14], [2, 15], [2, 16], [2, 19], [2, 20], [2, 21], [3, 6], [3, 7], [3, 14], [3, 20], [3, 23], [4, 7], [4, 12], [4, 13], [4, 23], [5, 6], [5, 7], [5, 12], [5, 20], [5, 23], [6, 7], [6, 9], [6, 10], [6, 11], [6, 13], [6, 17], [6, 20], [6, 21], [6, 22], [7, 9], [7, 14], [7, 19], [7, 20], [7, 21], [8, 9], [8, 11], [8, 12], [8, 13], [8, 17], [8, 20], [8, 23], [9, 15], [9, 16], [9, 17], [9, 18], [9, 21], [9, 23], [10, 12], [10, 13], [10, 14], [10, 16], [10, 20], [10, 23], [11, 13], [11, 14], [11, 20], [11, 21], [11, 23], [12, 13], [12, 14], [12, 16], [12, 17], [12, 19], [12, 20], [12, 21], [12, 23], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [15, 17], [15, 23], [16, 17], [16, 20], [16, 21], [16, 22], [16, 23], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [18, 20], [20, 21], [20, 22], [20, 23], [21, 23], [22, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s2/tests/run.py b/tasks/construct-nppc-independent-set-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-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-nppc-independent-set-l3-s2/tests/test.sh b/tasks/construct-nppc-independent-set-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-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-nppc-independent-set-l4-s6/environment/Dockerfile b/tasks/construct-nppc-independent-set-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l4-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-independent-set-l4-s6/environment/instance.json b/tasks/construct-nppc-independent-set-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..51f0b1daf2fd9346258775bd1f2822171d186764 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 32, "k": 16, "edges": [[0, 2], [0, 3], [0, 4], [0, 7], [0, 8], [0, 9], [0, 10], [0, 12], [0, 13], [0, 15], [0, 17], [0, 20], [0, 22], [0, 23], [0, 24], [0, 26], [0, 28], [0, 29], [0, 30], [0, 31], [1, 3], [1, 8], [1, 9], [1, 18], [1, 19], [1, 27], [1, 28], [2, 4], [2, 5], [2, 6], [2, 9], [2, 11], [2, 12], [2, 13], [2, 14], [2, 16], [2, 19], [2, 25], [2, 27], [3, 5], [3, 6], [3, 9], [3, 10], [3, 11], [3, 14], [3, 15], [3, 17], [3, 18], [3, 22], [3, 23], [3, 24], [3, 25], [3, 27], [3, 28], [4, 5], [4, 6], [4, 8], [4, 11], [4, 12], [4, 15], [4, 16], [4, 17], [4, 22], [4, 24], [4, 25], [4, 27], [4, 28], [4, 30], [4, 31], [5, 6], [5, 18], [5, 19], [5, 22], [5, 28], [6, 8], [6, 10], [6, 11], [6, 12], [6, 15], [6, 21], [6, 28], [6, 29], [6, 30], [6, 31], [7, 9], [7, 17], [7, 18], [7, 19], [8, 10], [8, 11], [8, 12], [8, 13], [8, 15], [8, 16], [8, 17], [8, 20], [8, 22], [8, 26], [8, 27], [8, 29], [8, 31], [9, 11], [9, 12], [9, 19], [9, 22], [9, 25], [9, 26], [9, 27], [9, 28], [9, 30], [10, 18], [10, 20], [10, 22], [10, 28], [10, 31], [11, 13], [11, 17], [11, 18], [11, 19], [11, 28], [11, 31], [12, 13], [12, 17], [12, 19], [12, 20], [12, 27], [12, 31], [13, 15], [13, 16], [13, 20], [13, 21], [13, 24], [13, 25], [13, 28], [13, 29], [13, 31], [14, 17], [14, 19], [14, 22], [14, 27], [15, 31], [16, 17], [16, 18], [17, 18], [17, 19], [17, 23], [17, 24], [17, 29], [18, 19], [18, 21], [18, 23], [18, 26], [18, 31], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [19, 31], [20, 21], [20, 25], [20, 27], [20, 31], [21, 22], [21, 28], [22, 23], [22, 24], [22, 25], [22, 26], [22, 29], [22, 30], [23, 31], [24, 27], [24, 28], [24, 31], [25, 27], [25, 31], [26, 27], [26, 28], [26, 31], [27, 29], [27, 30], [28, 31], [29, 31]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l4-s6/solution/solve.sh b/tasks/construct-nppc-independent-set-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e38e98c294967e758d78be50c6ff36e8f94d8ef6 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l4-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"independent_set": [1, 5, 7, 10, 11, 12, 14, 15, 16, 21, 23, 24, 25, 26, 29, 30]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l4-s6/tests/check.py b/tasks/construct-nppc-independent-set-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l4-s6/tests/check.py @@ -0,0 +1,19 @@ +"""Independent set of size >= k. Accepts any valid independent set.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + s = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + # upstream NPPC verifier checks len(list) >= size but only tests pairs u < v, so [v]*k passed + if len(set(s)) != len(s): + raise Invalid("independent_set contains duplicates") + if len(s) < k: + raise Invalid(f"independent_set has {len(s)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(s), 2): + if (u, v) in es: + raise Invalid(f"edge between {u} and {v}") + return None, {"size": len(s)} diff --git a/tasks/construct-nppc-independent-set-l4-s6/tests/instance.json b/tasks/construct-nppc-independent-set-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..51f0b1daf2fd9346258775bd1f2822171d186764 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 32, "k": 16, "edges": [[0, 2], [0, 3], [0, 4], [0, 7], [0, 8], [0, 9], [0, 10], [0, 12], [0, 13], [0, 15], [0, 17], [0, 20], [0, 22], [0, 23], [0, 24], [0, 26], [0, 28], [0, 29], [0, 30], [0, 31], [1, 3], [1, 8], [1, 9], [1, 18], [1, 19], [1, 27], [1, 28], [2, 4], [2, 5], [2, 6], [2, 9], [2, 11], [2, 12], [2, 13], [2, 14], [2, 16], [2, 19], [2, 25], [2, 27], [3, 5], [3, 6], [3, 9], [3, 10], [3, 11], [3, 14], [3, 15], [3, 17], [3, 18], [3, 22], [3, 23], [3, 24], [3, 25], [3, 27], [3, 28], [4, 5], [4, 6], [4, 8], [4, 11], [4, 12], [4, 15], [4, 16], [4, 17], [4, 22], [4, 24], [4, 25], [4, 27], [4, 28], [4, 30], [4, 31], [5, 6], [5, 18], [5, 19], [5, 22], [5, 28], [6, 8], [6, 10], [6, 11], [6, 12], [6, 15], [6, 21], [6, 28], [6, 29], [6, 30], [6, 31], [7, 9], [7, 17], [7, 18], [7, 19], [8, 10], [8, 11], [8, 12], [8, 13], [8, 15], [8, 16], [8, 17], [8, 20], [8, 22], [8, 26], [8, 27], [8, 29], [8, 31], [9, 11], [9, 12], [9, 19], [9, 22], [9, 25], [9, 26], [9, 27], [9, 28], [9, 30], [10, 18], [10, 20], [10, 22], [10, 28], [10, 31], [11, 13], [11, 17], [11, 18], [11, 19], [11, 28], [11, 31], [12, 13], [12, 17], [12, 19], [12, 20], [12, 27], [12, 31], [13, 15], [13, 16], [13, 20], [13, 21], [13, 24], [13, 25], [13, 28], [13, 29], [13, 31], [14, 17], [14, 19], [14, 22], [14, 27], [15, 31], [16, 17], [16, 18], [17, 18], [17, 19], [17, 23], [17, 24], [17, 29], [18, 19], [18, 21], [18, 23], [18, 26], [18, 31], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [19, 31], [20, 21], [20, 25], [20, 27], [20, 31], [21, 22], [21, 28], [22, 23], [22, 24], [22, 25], [22, 26], [22, 29], [22, 30], [23, 31], [24, 27], [24, 28], [24, 31], [25, 27], [25, 31], [26, 27], [26, 28], [26, 31], [27, 29], [27, 30], [28, 31], [29, 31]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l4-s6/tests/run.py b/tasks/construct-nppc-independent-set-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l4-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-independent-set-l4-s6/tests/test.sh b/tasks/construct-nppc-independent-set-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l4-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-independent-set-l4-s8/environment/Dockerfile b/tasks/construct-nppc-independent-set-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l4-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-independent-set-l4-s8/environment/instance.json b/tasks/construct-nppc-independent-set-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d280e4577f99f874e9116ae4f592b901bfb4766b --- /dev/null +++ b/tasks/construct-nppc-independent-set-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 32, "k": 16, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 10], [0, 12], [0, 14], [0, 15], [0, 16], [0, 20], [0, 23], [0, 28], [0, 29], [1, 3], [1, 4], [1, 5], [1, 6], [1, 10], [1, 11], [1, 14], [1, 16], [1, 17], [1, 18], [1, 22], [1, 24], [1, 26], [1, 29], [1, 30], [2, 3], [2, 4], [2, 10], [2, 11], [2, 12], [2, 14], [2, 20], [2, 29], [2, 31], [3, 4], [3, 5], [3, 6], [3, 7], [3, 13], [3, 16], [3, 23], [3, 24], [3, 25], [3, 26], [3, 29], [3, 30], [3, 31], [4, 5], [4, 6], [4, 8], [4, 10], [4, 13], [4, 15], [4, 19], [4, 21], [4, 22], [4, 25], [4, 26], [4, 27], [4, 29], [4, 31], [5, 7], [5, 9], [5, 11], [5, 12], [5, 14], [5, 15], [5, 19], [5, 20], [5, 25], [5, 27], [5, 29], [5, 30], [5, 31], [6, 10], [6, 11], [6, 12], [6, 16], [6, 31], [7, 16], [7, 20], [7, 23], [7, 26], [7, 29], [7, 31], [8, 11], [8, 15], [8, 16], [8, 20], [8, 23], [8, 26], [9, 11], [9, 12], [9, 15], [9, 20], [9, 23], [9, 31], [10, 11], [10, 12], [10, 14], [10, 15], [10, 19], [10, 22], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 31], [11, 14], [11, 16], [11, 21], [11, 22], [11, 23], [11, 25], [11, 28], [12, 13], [12, 14], [12, 15], [12, 17], [12, 19], [12, 22], [12, 24], [12, 26], [12, 31], [13, 14], [13, 15], [13, 16], [13, 23], [13, 26], [13, 28], [13, 29], [14, 18], [14, 19], [14, 22], [14, 23], [14, 24], [14, 27], [14, 28], [14, 29], [15, 16], [15, 17], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 31], [16, 17], [16, 19], [16, 28], [16, 30], [16, 31], [17, 20], [17, 26], [18, 23], [18, 26], [18, 28], [18, 29], [18, 31], [19, 23], [19, 26], [19, 29], [20, 24], [20, 25], [20, 27], [20, 30], [20, 31], [21, 28], [22, 23], [22, 28], [22, 29], [22, 31], [23, 26], [23, 28], [23, 30], [23, 31], [24, 29], [24, 31], [25, 29], [26, 28], [26, 29], [26, 30], [26, 31], [28, 30], [28, 31], [29, 30]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l4-s8/solution/solve.sh b/tasks/construct-nppc-independent-set-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e54c678ed90da4a4aa94b0f1f5d265c09be4719a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l4-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"independent_set": [0, 2, 6, 7, 8, 9, 13, 17, 18, 19, 21, 22, 24, 25, 27, 30]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l4-s8/tests/check.py b/tasks/construct-nppc-independent-set-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l4-s8/tests/check.py @@ -0,0 +1,19 @@ +"""Independent set of size >= k. Accepts any valid independent set.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + s = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + # upstream NPPC verifier checks len(list) >= size but only tests pairs u < v, so [v]*k passed + if len(set(s)) != len(s): + raise Invalid("independent_set contains duplicates") + if len(s) < k: + raise Invalid(f"independent_set has {len(s)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(s), 2): + if (u, v) in es: + raise Invalid(f"edge between {u} and {v}") + return None, {"size": len(s)} diff --git a/tasks/construct-nppc-independent-set-l4-s8/tests/instance.json b/tasks/construct-nppc-independent-set-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d280e4577f99f874e9116ae4f592b901bfb4766b --- /dev/null +++ b/tasks/construct-nppc-independent-set-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 32, "k": 16, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 10], [0, 12], [0, 14], [0, 15], [0, 16], [0, 20], [0, 23], [0, 28], [0, 29], [1, 3], [1, 4], [1, 5], [1, 6], [1, 10], [1, 11], [1, 14], [1, 16], [1, 17], [1, 18], [1, 22], [1, 24], [1, 26], [1, 29], [1, 30], [2, 3], [2, 4], [2, 10], [2, 11], [2, 12], [2, 14], [2, 20], [2, 29], [2, 31], [3, 4], [3, 5], [3, 6], [3, 7], [3, 13], [3, 16], [3, 23], [3, 24], [3, 25], [3, 26], [3, 29], [3, 30], [3, 31], [4, 5], [4, 6], [4, 8], [4, 10], [4, 13], [4, 15], [4, 19], [4, 21], [4, 22], [4, 25], [4, 26], [4, 27], [4, 29], [4, 31], [5, 7], [5, 9], [5, 11], [5, 12], [5, 14], [5, 15], [5, 19], [5, 20], [5, 25], [5, 27], [5, 29], [5, 30], [5, 31], [6, 10], [6, 11], [6, 12], [6, 16], [6, 31], [7, 16], [7, 20], [7, 23], [7, 26], [7, 29], [7, 31], [8, 11], [8, 15], [8, 16], [8, 20], [8, 23], [8, 26], [9, 11], [9, 12], [9, 15], [9, 20], [9, 23], [9, 31], [10, 11], [10, 12], [10, 14], [10, 15], [10, 19], [10, 22], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 31], [11, 14], [11, 16], [11, 21], [11, 22], [11, 23], [11, 25], [11, 28], [12, 13], [12, 14], [12, 15], [12, 17], [12, 19], [12, 22], [12, 24], [12, 26], [12, 31], [13, 14], [13, 15], [13, 16], [13, 23], [13, 26], [13, 28], [13, 29], [14, 18], [14, 19], [14, 22], [14, 23], [14, 24], [14, 27], [14, 28], [14, 29], [15, 16], [15, 17], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 31], [16, 17], [16, 19], [16, 28], [16, 30], [16, 31], [17, 20], [17, 26], [18, 23], [18, 26], [18, 28], [18, 29], [18, 31], [19, 23], [19, 26], [19, 29], [20, 24], [20, 25], [20, 27], [20, 30], [20, 31], [21, 28], [22, 23], [22, 28], [22, 29], [22, 31], [23, 26], [23, 28], [23, 30], [23, 31], [24, 29], [24, 31], [25, 29], [26, 28], [26, 29], [26, 30], [26, 31], [28, 30], [28, 31], [29, 30]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l4-s8/tests/run.py b/tasks/construct-nppc-independent-set-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l4-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-independent-set-l4-s8/tests/test.sh b/tasks/construct-nppc-independent-set-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l4-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quad-diophantine-l1-s1/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2c090499caeafe75846ac4ee751e77686b050674 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l1-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 11, "y": 1} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l1-s1/tests/check.py b/tasks/construct-nppc-quad-diophantine-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l1-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-l1-s1/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..60de6920c91826939d82ee522cdee6e6d3947bea --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"a": 35, "b": 28, "c": 4263, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l1-s1/tests/run.py b/tasks/construct-nppc-quad-diophantine-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l1-s1/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l1-s6/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l1-s6/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f4b4e97f8db526d8b97ae9ba9002e059dbfef7e1 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"a": 39, "b": 34, "c": 76728, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l1-s6/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..642d30c6ed3d601eca3e655812d6dd3cbd63a105 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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' +{"x": 44, "y": 36} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l1-s6/tests/check.py b/tasks/construct-nppc-quad-diophantine-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l1-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-l1-s6/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f4b4e97f8db526d8b97ae9ba9002e059dbfef7e1 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"a": 39, "b": 34, "c": 76728, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l1-s6/tests/run.py b/tasks/construct-nppc-quad-diophantine-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l1-s6/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l1-s8/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l1-s8/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8944a9a524eb589d61876e334d1cd599eb52cfef --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"a": 33, "b": 6, "c": 3534, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l1-s8/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2ac7b64b75ecba3f6e7534ec01838b5bbaecf754 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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": 10, "y": 39} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l1-s8/tests/check.py b/tasks/construct-nppc-quad-diophantine-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l1-s8/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l1-s8/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8944a9a524eb589d61876e334d1cd599eb52cfef --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"a": 33, "b": 6, "c": 3534, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l1-s8/tests/run.py b/tasks/construct-nppc-quad-diophantine-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l1-s8/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l2-s4/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l2-s4/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7822f12288cd3d3737c2c15360778f9fe5a42623 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"a": 698, "b": 71, "c": 731295, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s4/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2e4f8e3ce23b602f815f6a20d89702d2e28aaa84 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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": 32, "y": 233} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l2-s4/tests/check.py b/tasks/construct-nppc-quad-diophantine-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s4/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-s4/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7822f12288cd3d3737c2c15360778f9fe5a42623 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"a": 698, "b": 71, "c": 731295, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s4/tests/run.py b/tasks/construct-nppc-quad-diophantine-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l2-s4/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l5-s0/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l5-s0/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cccfbb0265fa9009a4be7bd573d8a126695573f5 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"a": 583055, "b": 3680858, "c": 1957469919416979390, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l5-s0/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..daf0fc1f4bef7505f1b03a83d5583193eb1b4b42 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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": 1832282, "y": 1154165} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l5-s0/tests/check.py b/tasks/construct-nppc-quad-diophantine-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l5-s0/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l5-s0/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cccfbb0265fa9009a4be7bd573d8a126695573f5 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"a": 583055, "b": 3680858, "c": 1957469919416979390, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l5-s0/tests/run.py b/tasks/construct-nppc-quad-diophantine-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l5-s0/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quadratic-congruence-l1-s6/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l1-s6/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ed4d6e5fda693539ca22a85714f30fad97451ef7 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"a": 14, "b": 26, "c": 169, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l1-s6/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ff6ca5d6c79176ef64893b317172e876a69d7620 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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' +{"x": 90} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l1-s6/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l1-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-l1-s6/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ed4d6e5fda693539ca22a85714f30fad97451ef7 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"a": 14, "b": 26, "c": 169, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l1-s6/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l1-s6/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l1-s8/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l1-s8/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7a40de1a8636df2718161ad8f6e94fec0668e47c --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"a": 19, "b": 54, "c": 92, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l1-s8/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ac9d33fb7db574807f007f87dba71a6ea93e91c --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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": 71} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l1-s8/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l1-s8/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l1-s8/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7a40de1a8636df2718161ad8f6e94fec0668e47c --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"a": 19, "b": 54, "c": 92, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l1-s8/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l1-s8/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l2-s3/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l2-s3/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3bd884203ded109e18d1f9f6ddea05b6a843520b --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"a": 2401, "b": 9336, "c": 7075, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s3/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6de73e0734e7bbd6ca01370a4afce2b7916d4797 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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' +{"x": 4619} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s3/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s3/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-s3/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3bd884203ded109e18d1f9f6ddea05b6a843520b --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"a": 2401, "b": 9336, "c": 7075, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s3/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l2-s3/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l5-s0/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l5-s0/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8e1c4b56ef6e45a0fe7c7b88e66febeebe048e94 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"a": 4462881905751867591, "b": 5824574491979322253, "c": 3879206096814625443, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l5-s0/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..aa4ceeb76899e9c9e35079ccc91b87e2262f4534 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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": 3875433992922812351} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l5-s0/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l5-s0/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l5-s0/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8e1c4b56ef6e45a0fe7c7b88e66febeebe048e94 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"a": 4462881905751867591, "b": 5824574491979322253, "c": 3879206096814625443, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l5-s0/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l5-s0/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l5-s7/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l5-s7/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1dc3441a5b8e01bf1ad40e328662e60185686743 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"a": 597618835044042815, "b": 5063666165401949383, "c": 236146277776390021, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l5-s7/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8a2e5964598a8a80bfa8f4cdc2d68f945e307c6d --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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": 232322412197427741} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l5-s7/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l5-s7/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l5-s7/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1dc3441a5b8e01bf1ad40e328662e60185686743 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"a": 597618835044042815, "b": 5063666165401949383, "c": 236146277776390021, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l5-s7/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l5-s7/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-vertex-cover-l3-s3/environment/Dockerfile b/tasks/construct-nppc-vertex-cover-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l3-s3/environment/instance.json b/tasks/construct-nppc-vertex-cover-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e5b855735562bbb2161286f22302ecae446bd5db --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 8], [0, 9], [0, 10], [0, 11], [0, 13], [0, 15], [0, 17], [0, 18], [0, 19], [0, 21], [0, 22], [0, 23], [1, 2], [1, 7], [1, 14], [1, 18], [1, 19], [1, 22], [2, 3], [2, 4], [2, 5], [2, 8], [2, 11], [2, 12], [2, 13], [2, 16], [2, 17], [2, 18], [2, 23], [3, 8], [3, 9], [3, 17], [3, 20], [3, 22], [4, 18], [5, 7], [5, 9], [5, 14], [5, 20], [6, 8], [6, 12], [6, 18], [6, 19], [6, 20], [7, 8], [7, 9], [7, 11], [7, 12], [7, 13], [7, 14], [7, 17], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [8, 12], [8, 13], [8, 14], [8, 17], [8, 18], [8, 19], [8, 22], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 22], [9, 23], [10, 19], [10, 22], [11, 18], [11, 22], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [13, 18], [13, 19], [13, 20], [14, 15], [14, 17], [14, 18], [14, 19], [14, 20], [14, 23], [15, 18], [15, 19], [15, 20], [16, 17], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [18, 21], [18, 22], [19, 20], [19, 21], [19, 22], [20, 21], [20, 23], [22, 23]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l3-s3/solution/solve.sh b/tasks/construct-nppc-vertex-cover-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..28a92dd12dd6781a65236ced7125edb21e182b21 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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' +{"cover": [0, 2, 7, 8, 9, 12, 14, 17, 18, 19, 20, 22]} +RLMATH_EOF diff --git a/tasks/construct-nppc-vertex-cover-l3-s3/tests/instance.json b/tasks/construct-nppc-vertex-cover-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e5b855735562bbb2161286f22302ecae446bd5db --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 8], [0, 9], [0, 10], [0, 11], [0, 13], [0, 15], [0, 17], [0, 18], [0, 19], [0, 21], [0, 22], [0, 23], [1, 2], [1, 7], [1, 14], [1, 18], [1, 19], [1, 22], [2, 3], [2, 4], [2, 5], [2, 8], [2, 11], [2, 12], [2, 13], [2, 16], [2, 17], [2, 18], [2, 23], [3, 8], [3, 9], [3, 17], [3, 20], [3, 22], [4, 18], [5, 7], [5, 9], [5, 14], [5, 20], [6, 8], [6, 12], [6, 18], [6, 19], [6, 20], [7, 8], [7, 9], [7, 11], [7, 12], [7, 13], [7, 14], [7, 17], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [8, 12], [8, 13], [8, 14], [8, 17], [8, 18], [8, 19], [8, 22], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 22], [9, 23], [10, 19], [10, 22], [11, 18], [11, 22], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [13, 18], [13, 19], [13, 20], [14, 15], [14, 17], [14, 18], [14, 19], [14, 20], [14, 23], [15, 18], [15, 19], [15, 20], [16, 17], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [18, 21], [18, 22], [19, 20], [19, 21], [19, 22], [20, 21], [20, 23], [22, 23]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l3-s3/tests/run.py b/tasks/construct-nppc-vertex-cover-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l3-s3/tests/test.sh b/tasks/construct-nppc-vertex-cover-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l3-s4/environment/Dockerfile b/tasks/construct-nppc-vertex-cover-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l3-s4/environment/instance.json b/tasks/construct-nppc-vertex-cover-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6a6393e905687186bbc7ae6bd24fe2bfc74a6e52 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 2], [0, 3], [0, 4], [0, 6], [0, 7], [0, 9], [0, 10], [0, 12], [0, 13], [0, 14], [0, 15], [0, 18], [0, 20], [0, 21], [0, 23], [1, 4], [1, 6], [1, 7], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 20], [1, 21], [2, 9], [2, 11], [2, 20], [3, 5], [3, 7], [3, 9], [3, 11], [3, 15], [3, 17], [4, 5], [4, 6], [4, 7], [4, 10], [4, 11], [4, 14], [4, 15], [4, 20], [4, 21], [4, 22], [5, 6], [5, 8], [5, 9], [5, 10], [5, 11], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 20], [5, 21], [6, 8], [6, 9], [6, 11], [6, 12], [6, 13], [6, 15], [6, 17], [6, 20], [6, 21], [6, 23], [7, 10], [7, 11], [7, 12], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 20], [7, 21], [8, 10], [8, 11], [8, 15], [8, 17], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 18], [9, 21], [9, 23], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 17], [10, 18], [10, 19], [10, 20], [10, 22], [10, 23], [11, 13], [11, 15], [11, 16], [11, 17], [11, 18], [11, 20], [11, 22], [12, 15], [15, 16], [15, 18], [15, 20], [15, 23], [16, 20], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [18, 20], [19, 20], [20, 22]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l3-s4/solution/solve.sh b/tasks/construct-nppc-vertex-cover-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b0f7b3ecd462bef2c4eb383581c9328b19345dae --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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' +{"cover": [0, 1, 4, 5, 6, 7, 9, 10, 11, 15, 17, 20]} +RLMATH_EOF diff --git a/tasks/construct-nppc-vertex-cover-l3-s4/tests/check.py b/tasks/construct-nppc-vertex-cover-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d8ed740cc660c4837d941a8d70ea394c3bc9f69e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l3-s4/tests/check.py @@ -0,0 +1,18 @@ +"""Vertex cover of size <= k. Accepts any valid cover.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier converts to a set without type checks (floats/bools slip through and + # duplicates are silently merged); here entries must be distinct ints in range + c = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(c)) != len(c): + raise Invalid("cover contains duplicates") + if len(c) > k: + raise Invalid(f"cover has {len(c)} > {k} vertices") + s = set(c) + for u, v in inst["edges"]: + if u not in s and v not in s: + raise Invalid(f"edge ({u},{v}) not covered") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-vertex-cover-l3-s4/tests/instance.json b/tasks/construct-nppc-vertex-cover-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6a6393e905687186bbc7ae6bd24fe2bfc74a6e52 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 2], [0, 3], [0, 4], [0, 6], [0, 7], [0, 9], [0, 10], [0, 12], [0, 13], [0, 14], [0, 15], [0, 18], [0, 20], [0, 21], [0, 23], [1, 4], [1, 6], [1, 7], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 20], [1, 21], [2, 9], [2, 11], [2, 20], [3, 5], [3, 7], [3, 9], [3, 11], [3, 15], [3, 17], [4, 5], [4, 6], [4, 7], [4, 10], [4, 11], [4, 14], [4, 15], [4, 20], [4, 21], [4, 22], [5, 6], [5, 8], [5, 9], [5, 10], [5, 11], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 20], [5, 21], [6, 8], [6, 9], [6, 11], [6, 12], [6, 13], [6, 15], [6, 17], [6, 20], [6, 21], [6, 23], [7, 10], [7, 11], [7, 12], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 20], [7, 21], [8, 10], [8, 11], [8, 15], [8, 17], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 18], [9, 21], [9, 23], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 17], [10, 18], [10, 19], [10, 20], [10, 22], [10, 23], [11, 13], [11, 15], [11, 16], [11, 17], [11, 18], [11, 20], [11, 22], [12, 15], [15, 16], [15, 18], [15, 20], [15, 23], [16, 20], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [18, 20], [19, 20], [20, 22]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l3-s4/tests/run.py b/tasks/construct-nppc-vertex-cover-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l3-s4/tests/test.sh b/tasks/construct-nppc-vertex-cover-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-rg-graph-color-l4-s7/environment/Dockerfile b/tasks/construct-rg-graph-color-l4-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l4-s7/environment/instance.json b/tasks/construct-rg-graph-color-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2b59d5a720a88883b6d6654a0ebe5f192995ff45 --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"num_vertices": 20, "num_colors": 3, "edges": [[0, 4], [0, 14], [0, 15], [1, 2], [1, 4], [1, 7], [2, 4], [2, 7], [2, 14], [2, 17], [2, 19], [3, 7], [3, 9], [3, 10], [3, 13], [3, 18], [4, 5], [6, 10], [6, 11], [6, 15], [7, 8], [7, 11], [8, 12], [8, 13], [8, 15], [9, 14], [10, 12], [10, 17], [12, 13], [12, 16], [12, 17], [13, 15], [18, 19]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l4-s7/solution/solve.sh b/tasks/construct-rg-graph-color-l4-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2f27edd523d59f07a22aff9721b8ff511fb4ec38 --- /dev/null +++ b/tasks/construct-rg-graph-color-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' +{"coloring": [1, 1, 2, 1, 3, 1, 1, 3, 1, 2, 2, 2, 3, 2, 3, 3, 1, 1, 2, 1]} +RLMATH_EOF diff --git a/tasks/construct-rg-graph-color-l4-s7/tests/check.py b/tasks/construct-rg-graph-color-l4-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e9328912405d1c894970c90415be62bf9556ed36 --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s7/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-l4-s7/tests/instance.json b/tasks/construct-rg-graph-color-l4-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2b59d5a720a88883b6d6654a0ebe5f192995ff45 --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s7/tests/instance.json @@ -0,0 +1 @@ +{"num_vertices": 20, "num_colors": 3, "edges": [[0, 4], [0, 14], [0, 15], [1, 2], [1, 4], [1, 7], [2, 4], [2, 7], [2, 14], [2, 17], [2, 19], [3, 7], [3, 9], [3, 10], [3, 13], [3, 18], [4, 5], [6, 10], [6, 11], [6, 15], [7, 8], [7, 11], [8, 12], [8, 13], [8, 15], [9, 14], [10, 12], [10, 17], [12, 13], [12, 16], [12, 17], [13, 15], [18, 19]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l4-s7/tests/run.py b/tasks/construct-rg-graph-color-l4-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l4-s7/tests/test.sh b/tasks/construct-rg-graph-color-l4-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-intermediate-integration-l2-s3/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l2-s3/environment/instance.json b/tasks/construct-rg-intermediate-integration-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..16998ebeb2b842e5a456db512a46b64894caf9f7 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "(36*x - 4)*exp(9*x**2 - 2*x + 6)", "problem_type": "exponential", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l2-s3/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..95848ac4b4ade35de81f463a8b929e07cc1facbf --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "2*exp(9*x**2 - 2*x + 6) + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l2-s3/tests/check.py b/tasks/construct-rg-intermediate-integration-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l2-s3/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-intermediate-integration-l2-s3/tests/instance.json b/tasks/construct-rg-intermediate-integration-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..16998ebeb2b842e5a456db512a46b64894caf9f7 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "(36*x - 4)*exp(9*x**2 - 2*x + 6)", "problem_type": "exponential", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l2-s3/tests/run.py b/tasks/construct-rg-intermediate-integration-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l2-s3/tests/test.sh b/tasks/construct-rg-intermediate-integration-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l2-s4/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l2-s4/environment/instance.json b/tasks/construct-rg-intermediate-integration-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..61566d8207739ac1b216eb439ac049531f13a1cc --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-8*sqrt(5 - 8*x)", "problem_type": "radical", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l2-s4/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c7f85650dcc2188e7acb29efac32cc3e2505076e --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "2*(5 - 8*x)**(3/2)/3 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l2-s4/tests/check.py b/tasks/construct-rg-intermediate-integration-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l2-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-l2-s4/tests/instance.json b/tasks/construct-rg-intermediate-integration-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..61566d8207739ac1b216eb439ac049531f13a1cc --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-8*sqrt(5 - 8*x)", "problem_type": "radical", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l2-s4/tests/run.py b/tasks/construct-rg-intermediate-integration-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l2-s4/tests/test.sh b/tasks/construct-rg-intermediate-integration-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s0/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s0/environment/instance.json b/tasks/construct-rg-intermediate-integration-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9a15f238d9c5cc70139a0735b9c7cf09e9a5b788 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "2*sin(x)*cos(x)", "problem_type": "cyclic", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l5-s0/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5398e088a03bb9532b90d5f73c2ea37b71967f36 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "sin(x)**2 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l5-s0/tests/check.py b/tasks/construct-rg-intermediate-integration-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-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-intermediate-integration-l5-s0/tests/instance.json b/tasks/construct-rg-intermediate-integration-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9a15f238d9c5cc70139a0735b9c7cf09e9a5b788 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "2*sin(x)*cos(x)", "problem_type": "cyclic", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l5-s0/tests/run.py b/tasks/construct-rg-intermediate-integration-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s0/tests/test.sh b/tasks/construct-rg-intermediate-integration-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l6-s2/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l6-s2/environment/instance.json b/tasks/construct-rg-intermediate-integration-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..92aaaeabd48c46c6a9dbaafad3ca8dc6c6859370 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "2*x**4*exp(x)", "problem_type": "repeated_parts", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l6-s2/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..be61b2ca28f372aecd0b70756b73c110bdac2e0d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "(2*x**4 - 8*x**3 + 24*x**2 - 48*x + 48)*exp(x) + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l6-s2/tests/check.py b/tasks/construct-rg-intermediate-integration-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l6-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-l6-s2/tests/instance.json b/tasks/construct-rg-intermediate-integration-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..92aaaeabd48c46c6a9dbaafad3ca8dc6c6859370 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "2*x**4*exp(x)", "problem_type": "repeated_parts", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l6-s2/tests/run.py b/tasks/construct-rg-intermediate-integration-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l6-s2/tests/test.sh b/tasks/construct-rg-intermediate-integration-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-simple-integration-l4-s1/environment/Dockerfile b/tasks/construct-rg-simple-integration-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l4-s1/environment/instance.json b/tasks/construct-rg-simple-integration-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d54a17f40fef9808b5fcdb65f351e647d8b833fe --- /dev/null +++ b/tasks/construct-rg-simple-integration-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "-35*X**9/4 + 72*X**7 + 4*X + 3", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l4-s1/solution/solve.sh b/tasks/construct-rg-simple-integration-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..75683797fa16630628baaa08159a1f42a3c63fd8 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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' +{"antiderivative": "-7*X**10/8 + 9*X**8 + 2*X**2 + 3*X + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l4-s1/tests/check.py b/tasks/construct-rg-simple-integration-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l4-s1/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-l4-s1/tests/instance.json b/tasks/construct-rg-simple-integration-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d54a17f40fef9808b5fcdb65f351e647d8b833fe --- /dev/null +++ b/tasks/construct-rg-simple-integration-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "-35*X**9/4 + 72*X**7 + 4*X + 3", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l4-s1/tests/run.py b/tasks/construct-rg-simple-integration-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l4-s1/tests/test.sh b/tasks/construct-rg-simple-integration-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l4-s6/environment/Dockerfile b/tasks/construct-rg-simple-integration-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l4-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-simple-integration-l4-s6/environment/instance.json b/tasks/construct-rg-simple-integration-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b958ca82880c056f69e8901a49d644324531a92f --- /dev/null +++ b/tasks/construct-rg-simple-integration-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-7*x**6/9 + 6*x**5 - 16*x + 7", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l4-s6/solution/solve.sh b/tasks/construct-rg-simple-integration-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4022549ef8f497d74575aa05f1285b3fd52b2ab2 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l4-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"antiderivative": "-x**7/9 + x**6 - 8*x**2 + 7*x + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l4-s6/tests/check.py b/tasks/construct-rg-simple-integration-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l4-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-l4-s6/tests/instance.json b/tasks/construct-rg-simple-integration-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b958ca82880c056f69e8901a49d644324531a92f --- /dev/null +++ b/tasks/construct-rg-simple-integration-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-7*x**6/9 + 6*x**5 - 16*x + 7", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l4-s6/tests/run.py b/tasks/construct-rg-simple-integration-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-l4-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-simple-integration-l4-s6/tests/test.sh b/tasks/construct-rg-simple-integration-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l4-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-antiderivative-l1-s7/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l1-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l1-s7/environment/instance.json b/tasks/construct-rlve-antiderivative-l1-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b1c7187032d87f5b73f9999ca97ea6268b9f41d3 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l1-s7/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "x**x*(log(x) + 1)", "max_ops": 24, "max_len": 480, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l1-s7/solution/solve.sh b/tasks/construct-rlve-antiderivative-l1-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07e4257b8567dbc5096f98e35d0ff0185d7abe68 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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' +{"F": "x**x"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l1-s7/tests/check.py b/tasks/construct-rlve-antiderivative-l1-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l1-s7/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-l1-s7/tests/instance.json b/tasks/construct-rlve-antiderivative-l1-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b1c7187032d87f5b73f9999ca97ea6268b9f41d3 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l1-s7/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "x**x*(log(x) + 1)", "max_ops": 24, "max_len": 480, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l1-s7/tests/run.py b/tasks/construct-rlve-antiderivative-l1-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l1-s7/tests/test.sh b/tasks/construct-rlve-antiderivative-l1-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-bezout-identity-l4-s2/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l4-s2/environment/instance.json b/tasks/construct-rlve-bezout-identity-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..febbb4d1807d8a30d9f02090cef267a3e6eb0ad9 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"A": [505, -1919, 950, -1520, -2020, -1919, -606, 202], "target": 1, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l4-s2/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5cd7b0ff6bf95e4bb7a5e1478ca08c473e75ba0b --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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' +{"X": [1204, 301, -32, 0, 0, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l4-s2/tests/check.py b/tasks/construct-rlve-bezout-identity-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l4-s2/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-l4-s2/tests/instance.json b/tasks/construct-rlve-bezout-identity-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..febbb4d1807d8a30d9f02090cef267a3e6eb0ad9 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"A": [505, -1919, 950, -1520, -2020, -1919, -606, 202], "target": 1, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l4-s2/tests/run.py b/tasks/construct-rlve-bezout-identity-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l4-s2/tests/test.sh b/tasks/construct-rlve-bezout-identity-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-construct-hack-interval-l1-s5/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l1-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l1-s5/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a3e3e661875a81f3b08b8c3891850672c45f024f --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s5/environment/instance.json @@ -0,0 +1 @@ +{"mod": 31, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s5/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l1-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c7f7c431e0be3ac6de8d61ef711a85c7f987ee6a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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' +{"L": 6, "R": 10} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s5/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l1-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s5/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-s5/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a3e3e661875a81f3b08b8c3891850672c45f024f --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s5/tests/instance.json @@ -0,0 +1 @@ +{"mod": 31, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s5/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l1-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l1-s5/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l1-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l2-s0/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l2-s0/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d586c902c50a973c76fd21c258364011097c566d --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"mod": 4100, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l2-s0/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5f74b428454872d6e434f4619dae8481b0c4aa9a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l2-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"L": 20, "R": 399} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l2-s0/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l2-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-l2-s0/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d586c902c50a973c76fd21c258364011097c566d --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"mod": 4100, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l2-s0/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l2-s0/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l2-s9/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l2-s9/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..26d8b3a9a55f63c26b150220f6c112618d9eb015 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"mod": 1365, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l2-s9/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8c6e6ba1c5d4694385762767c701670cf35fa6a5 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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' +{"L": 1, "R": 158} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l2-s9/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l2-s9/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l2-s9/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..26d8b3a9a55f63c26b150220f6c112618d9eb015 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"mod": 1365, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l2-s9/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l2-s9/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l6-s1/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s1/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f80bedd39d607f06dfe055262c880d0d92527d5d --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"mod": 257941101304329733, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s1/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c3812986bf86088c24b82168edfd989528a072b2 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"L": 53823303912989199, "R": 63823303912989198} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s1/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-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-l6-s1/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f80bedd39d607f06dfe055262c880d0d92527d5d --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"mod": 257941101304329733, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s1/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s1/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s6/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s6/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fb7b4e223a36597d1a8775cd7084d28c62a091df --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"mod": 859533681024633006, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s6/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bd4daaa1de1eeb7a8480d5e29c8c806e9dc5e23e --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"L": 85803129221697054, "R": 185803129221697053} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s6/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s6/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s6/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fb7b4e223a36597d1a8775cd7084d28c62a091df --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"mod": 859533681024633006, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s6/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s6/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s8/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s8/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ff60dba4b890bb93ea0b79af4eb7da6a03314b8 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"mod": 673985507134050059, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s8/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1c4d52e299326c81386c2aa3b28431bc32f1813d --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"L": 437826085608600708, "R": 537826085608600707} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s8/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-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-l6-s8/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ff60dba4b890bb93ea0b79af4eb7da6a03314b8 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"mod": 673985507134050059, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s8/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l6-s8/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l6-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-crt-l3-s6/environment/Dockerfile b/tasks/construct-rlve-crt-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-l3-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-crt-l3-s6/environment/instance.json b/tasks/construct-rlve-crt-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..451bc61d19e448d15a3ba8523b86778e8f5881f0 --- /dev/null +++ b/tasks/construct-rlve-crt-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"moduli": [2515, 2349, 4024, 795], "residues": [2109, 2275, 600, 649], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l3-s6/solution/solve.sh b/tasks/construct-rlve-crt-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0cfd732b356165b39e97cba174f0ddc539bdf8fd --- /dev/null +++ b/tasks/construct-rlve-crt-l3-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 4624} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l3-s6/tests/check.py b/tasks/construct-rlve-crt-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l3-s6/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-l3-s6/tests/instance.json b/tasks/construct-rlve-crt-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..451bc61d19e448d15a3ba8523b86778e8f5881f0 --- /dev/null +++ b/tasks/construct-rlve-crt-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [2515, 2349, 4024, 795], "residues": [2109, 2275, 600, 649], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l3-s6/tests/run.py b/tasks/construct-rlve-crt-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-l3-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-crt-l3-s6/tests/test.sh b/tasks/construct-rlve-crt-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-l3-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s1/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-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-distinct-subset-sum-permutation-l2-s1/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..baf675f41db7d8174c4900b0ba7aceed248d4aad --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"A": [11, 1, 6, 10, 9, 2, 5], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s1/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..91132185b89d4da59f9409df46fc67ed6c0f862b --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-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' +{"B": [1, 2, 9, 11, 10, 5, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s1/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s1/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-l2-s1/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..baf675f41db7d8174c4900b0ba7aceed248d4aad --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"A": [11, 1, 6, 10, 9, 2, 5], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s1/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-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-distinct-subset-sum-permutation-l2-s1/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-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-distinct-subset-sum-permutation-l2-s6/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l2-s6/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..17aa1451bdcce311113d906d4a5de950421585b4 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"A": [1, 2, 8, 0, 4, 7, 9], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s6/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..006b925da2b59a13636771029d0ee0f034b53f63 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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' +{"B": [2, 4, 9, 1, 7, 8, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s6/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s6/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-l2-s6/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..17aa1451bdcce311113d906d4a5de950421585b4 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"A": [1, 2, 8, 0, 4, 7, 9], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s6/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l2-s6/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-graph-isomorphism-l5-s2/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l5-s2/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..85c1e39e23913c4b10e2a0252691494562fbc68a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 26, "edges1": [[9, 17], [17, 21], [4, 24], [6, 25], [7, 21], [11, 15], [11, 13], [3, 6], [9, 15], [5, 23], [7, 23], [3, 25], [13, 23], [0, 7], [13, 15], [0, 18], [5, 11], [12, 13], [10, 14], [12, 15], [0, 17], [1, 4], [4, 23], [10, 20], [5, 15], [10, 12], [1, 18], [4, 6], [16, 20], [4, 17], [7, 9], [6, 8], [15, 24], [14, 20], [2, 6], [14, 15], [0, 12], [19, 25], [18, 23], [8, 21], [4, 13], [14, 17], [9, 23], [3, 11], [3, 4], [0, 24], [1, 11], [0, 21], [19, 20], [10, 15], [23, 24], [1, 25], [2, 8], [21, 25], [8, 9], [6, 11], [15, 21], [5, 21], [1, 22], [16, 22], [1, 23], [1, 24], [23, 25], [16, 24], [6, 10], [0, 2], [19, 22], [10, 18], [2, 12], [10, 11], [3, 7], [15, 17], [10, 16], [14, 16], [10, 17], [3, 12], [17, 25], [2, 14], [11, 20], [17, 19], [5, 22], [8, 25], [3, 9], [6, 7], [9, 18], [6, 23], [5, 8], [2, 17], [12, 20], [17, 18], [4, 15], [7, 8], [20, 25], [0, 19], [8, 14], [9, 12], [9, 11], [13, 18], [8, 18], [0, 11], [12, 24], [7, 20], [10, 23], [10, 24], [11, 24], [5, 25], [0, 13], [22, 25], [7, 16], [1, 8], [12, 19], [6, 17], [1, 7], [0, 9], [3, 20], [10, 25], [1, 21], [8, 11], [12, 23], [7, 13], [10, 22], [2, 5], [8, 15], [2, 10], [4, 20], [0, 5], [18, 20], [20, 21], [16, 21], [17, 24], [3, 16], [6, 24], [1, 10], [0, 16], [4, 18], [6, 20], [2, 4], [1, 5], [6, 15], [11, 14], [3, 21], [8, 13], [5, 9], [12, 22], [0, 14], [11, 12], [10, 13], [4, 16], [6, 9], [2, 19], [12, 17], [22, 23], [6, 18], [3, 24], [8, 23], [1, 14], [10, 21], [2, 11], [8, 16], [2, 22], [15, 23], [4, 25], [2, 25], [5, 19], [20, 24], [4, 22], [11, 23], [4, 7], [1, 13], [12, 18], [0, 8], [14, 24], [6, 12], [7, 10], [9, 20], [21, 23], [8, 19], [6, 14], [12, 16], [5, 18], [9, 22], [13, 20], [8, 22], [15, 25], [10, 19], [3, 23], [7, 15], [15, 20], [12, 21], [19, 21], [8, 17], [3, 18], [7, 25], [18, 22], [12, 25], [4, 12], [14, 25], [13, 16], [4, 14], [0, 23], [13, 19], [4, 21], [4, 8], [9, 21], [1, 19], [9, 16], [14, 18], [13, 21], [5, 24], [16, 18], [1, 2]], "edges2": [[0, 20], [3, 10], [16, 17], [2, 21], [1, 18], [0, 2], [4, 9], [2, 23], [2, 8], [3, 12], [3, 18], [1, 6], [0, 5], [4, 22], [4, 15], [7, 25], [21, 25], [6, 13], [6, 21], [2, 22], [8, 17], [8, 24], [5, 16], [3, 6], [14, 24], [6, 18], [0, 24], [16, 23], [11, 21], [18, 24], [18, 22], [20, 23], [1, 23], [7, 19], [6, 7], [10, 25], [6, 12], [4, 7], [7, 21], [8, 16], [7, 24], [16, 18], [8, 9], [7, 20], [6, 19], [11, 24], [9, 20], [2, 17], [8, 12], [4, 6], [15, 18], [6, 14], [19, 23], [6, 24], [4, 25], [7, 17], [0, 19], [11, 23], [6, 20], [10, 17], [6, 17], [5, 13], [2, 7], [24, 25], [10, 18], [8, 22], [2, 13], [2, 20], [10, 14], [0, 1], [0, 4], [17, 18], [11, 15], [11, 18], [8, 15], [8, 20], [22, 23], [0, 13], [1, 8], [10, 13], [12, 18], [5, 14], [18, 20], [21, 22], [5, 20], [13, 16], [5, 10], [10, 21], [7, 8], [5, 23], [0, 17], [12, 20], [13, 21], [14, 23], [0, 14], [4, 17], [8, 19], [9, 23], [5, 11], [15, 20], [0, 3], [3, 16], [10, 23], [1, 12], [14, 15], [16, 24], [14, 20], [9, 13], [15, 16], [6, 22], [15, 22], [5, 22], [16, 19], [23, 25], [13, 23], [6, 25], [8, 23], [12, 16], [22, 24], [4, 14], [17, 24], [7, 15], [8, 13], [0, 23], [9, 19], [0, 15], [18, 23], [4, 20], [12, 15], [3, 21], [15, 24], [1, 9], [8, 25], [14, 16], [22, 25], [11, 19], [6, 11], [13, 15], [5, 12], [20, 22], [20, 21], [11, 25], [2, 18], [2, 6], [7, 9], [3, 8], [2, 16], [12, 24], [0, 11], [9, 18], [13, 18], [5, 9], [19, 25], [17, 20], [8, 14], [1, 14], [19, 21], [2, 19], [10, 12], [5, 21], [7, 18], [13, 24], [12, 17], [10, 16], [12, 25], [13, 17], [0, 6], [17, 23], [9, 25], [3, 20], [1, 4], [1, 19], [3, 25], [12, 22], [3, 7], [6, 9], [8, 11], [10, 20], [16, 25], [4, 5], [18, 21], [12, 23], [0, 21], [11, 22], [11, 12], [9, 17], [21, 23], [7, 14], [1, 7], [10, 15], [15, 23], [16, 21], [1, 25], [1, 11], [2, 3], [16, 22], [12, 14], [3, 22], [14, 22], [3, 5], [4, 19], [1, 24], [3, 13], [5, 6], [5, 17], [2, 14], [11, 17], [18, 25], [8, 21], [4, 21], [20, 25]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l5-s2/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..28d83157cf852bc883225ddffbd4e0d2af31eafb --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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' +{"p": [0, 7, 1, 10, 18, 4, 12, 3, 6, 5, 8, 14, 23, 2, 24, 22, 13, 11, 17, 19, 16, 21, 9, 20, 15, 25]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l5-s2/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l5-s2/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-l5-s2/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..85c1e39e23913c4b10e2a0252691494562fbc68a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 26, "edges1": [[9, 17], [17, 21], [4, 24], [6, 25], [7, 21], [11, 15], [11, 13], [3, 6], [9, 15], [5, 23], [7, 23], [3, 25], [13, 23], [0, 7], [13, 15], [0, 18], [5, 11], [12, 13], [10, 14], [12, 15], [0, 17], [1, 4], [4, 23], [10, 20], [5, 15], [10, 12], [1, 18], [4, 6], [16, 20], [4, 17], [7, 9], [6, 8], [15, 24], [14, 20], [2, 6], [14, 15], [0, 12], [19, 25], [18, 23], [8, 21], [4, 13], [14, 17], [9, 23], [3, 11], [3, 4], [0, 24], [1, 11], [0, 21], [19, 20], [10, 15], [23, 24], [1, 25], [2, 8], [21, 25], [8, 9], [6, 11], [15, 21], [5, 21], [1, 22], [16, 22], [1, 23], [1, 24], [23, 25], [16, 24], [6, 10], [0, 2], [19, 22], [10, 18], [2, 12], [10, 11], [3, 7], [15, 17], [10, 16], [14, 16], [10, 17], [3, 12], [17, 25], [2, 14], [11, 20], [17, 19], [5, 22], [8, 25], [3, 9], [6, 7], [9, 18], [6, 23], [5, 8], [2, 17], [12, 20], [17, 18], [4, 15], [7, 8], [20, 25], [0, 19], [8, 14], [9, 12], [9, 11], [13, 18], [8, 18], [0, 11], [12, 24], [7, 20], [10, 23], [10, 24], [11, 24], [5, 25], [0, 13], [22, 25], [7, 16], [1, 8], [12, 19], [6, 17], [1, 7], [0, 9], [3, 20], [10, 25], [1, 21], [8, 11], [12, 23], [7, 13], [10, 22], [2, 5], [8, 15], [2, 10], [4, 20], [0, 5], [18, 20], [20, 21], [16, 21], [17, 24], [3, 16], [6, 24], [1, 10], [0, 16], [4, 18], [6, 20], [2, 4], [1, 5], [6, 15], [11, 14], [3, 21], [8, 13], [5, 9], [12, 22], [0, 14], [11, 12], [10, 13], [4, 16], [6, 9], [2, 19], [12, 17], [22, 23], [6, 18], [3, 24], [8, 23], [1, 14], [10, 21], [2, 11], [8, 16], [2, 22], [15, 23], [4, 25], [2, 25], [5, 19], [20, 24], [4, 22], [11, 23], [4, 7], [1, 13], [12, 18], [0, 8], [14, 24], [6, 12], [7, 10], [9, 20], [21, 23], [8, 19], [6, 14], [12, 16], [5, 18], [9, 22], [13, 20], [8, 22], [15, 25], [10, 19], [3, 23], [7, 15], [15, 20], [12, 21], [19, 21], [8, 17], [3, 18], [7, 25], [18, 22], [12, 25], [4, 12], [14, 25], [13, 16], [4, 14], [0, 23], [13, 19], [4, 21], [4, 8], [9, 21], [1, 19], [9, 16], [14, 18], [13, 21], [5, 24], [16, 18], [1, 2]], "edges2": [[0, 20], [3, 10], [16, 17], [2, 21], [1, 18], [0, 2], [4, 9], [2, 23], [2, 8], [3, 12], [3, 18], [1, 6], [0, 5], [4, 22], [4, 15], [7, 25], [21, 25], [6, 13], [6, 21], [2, 22], [8, 17], [8, 24], [5, 16], [3, 6], [14, 24], [6, 18], [0, 24], [16, 23], [11, 21], [18, 24], [18, 22], [20, 23], [1, 23], [7, 19], [6, 7], [10, 25], [6, 12], [4, 7], [7, 21], [8, 16], [7, 24], [16, 18], [8, 9], [7, 20], [6, 19], [11, 24], [9, 20], [2, 17], [8, 12], [4, 6], [15, 18], [6, 14], [19, 23], [6, 24], [4, 25], [7, 17], [0, 19], [11, 23], [6, 20], [10, 17], [6, 17], [5, 13], [2, 7], [24, 25], [10, 18], [8, 22], [2, 13], [2, 20], [10, 14], [0, 1], [0, 4], [17, 18], [11, 15], [11, 18], [8, 15], [8, 20], [22, 23], [0, 13], [1, 8], [10, 13], [12, 18], [5, 14], [18, 20], [21, 22], [5, 20], [13, 16], [5, 10], [10, 21], [7, 8], [5, 23], [0, 17], [12, 20], [13, 21], [14, 23], [0, 14], [4, 17], [8, 19], [9, 23], [5, 11], [15, 20], [0, 3], [3, 16], [10, 23], [1, 12], [14, 15], [16, 24], [14, 20], [9, 13], [15, 16], [6, 22], [15, 22], [5, 22], [16, 19], [23, 25], [13, 23], [6, 25], [8, 23], [12, 16], [22, 24], [4, 14], [17, 24], [7, 15], [8, 13], [0, 23], [9, 19], [0, 15], [18, 23], [4, 20], [12, 15], [3, 21], [15, 24], [1, 9], [8, 25], [14, 16], [22, 25], [11, 19], [6, 11], [13, 15], [5, 12], [20, 22], [20, 21], [11, 25], [2, 18], [2, 6], [7, 9], [3, 8], [2, 16], [12, 24], [0, 11], [9, 18], [13, 18], [5, 9], [19, 25], [17, 20], [8, 14], [1, 14], [19, 21], [2, 19], [10, 12], [5, 21], [7, 18], [13, 24], [12, 17], [10, 16], [12, 25], [13, 17], [0, 6], [17, 23], [9, 25], [3, 20], [1, 4], [1, 19], [3, 25], [12, 22], [3, 7], [6, 9], [8, 11], [10, 20], [16, 25], [4, 5], [18, 21], [12, 23], [0, 21], [11, 22], [11, 12], [9, 17], [21, 23], [7, 14], [1, 7], [10, 15], [15, 23], [16, 21], [1, 25], [1, 11], [2, 3], [16, 22], [12, 14], [3, 22], [14, 22], [3, 5], [4, 19], [1, 24], [3, 13], [5, 6], [5, 17], [2, 14], [11, 17], [18, 25], [8, 21], [4, 21], [20, 25]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l5-s2/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l5-s2/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-grid-parity-construction-l5-s5/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l5-s5/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fa95bbcdd335c7aa4aee869cdec6d700827534f0 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["11001", "00000", "00110", "01000", "11101", "01101", "01000", "00110", "00001", "00000", "01011", "00110", "10110"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l5-s5/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fde7cd33a5fd12b76e63c9742691e0e802dc50c3 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["01001", "00110", "00000", "00000", "01000", "00001", "00110", "00000", "00000", "00001", "00011", "01110", "10000"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l5-s5/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l5-s5/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-l5-s5/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fa95bbcdd335c7aa4aee869cdec6d700827534f0 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["11001", "00000", "00110", "01000", "11101", "01101", "01000", "00110", "00001", "00000", "01011", "00110", "10110"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l5-s5/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l5-s5/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-imp-party-l3-s2/environment/Dockerfile b/tasks/construct-rlve-imp-party-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l3-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-imp-party-l3-s2/environment/instance.json b/tasks/construct-rlve-imp-party-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7389890f6a17865d36b7a51805074d17f3eff123 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 8], [0, 10], [0, 12], [0, 14], [0, 15], [0, 16], [0, 17], [0, 19], [0, 20], [0, 21], [0, 22], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [2, 3], [2, 4], [2, 8], [2, 10], [2, 17], [2, 19], [2, 20], [2, 21], [2, 22], [3, 4], [3, 5], [3, 6], [3, 8], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [4, 5], [4, 6], [4, 7], [4, 8], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [5, 8], [5, 10], [5, 12], [5, 14], [5, 16], [5, 17], [5, 19], [5, 20], [5, 21], [5, 22], [6, 7], [6, 8], [6, 9], [6, 10], [6, 12], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [7, 8], [7, 10], [7, 12], [7, 14], [7, 15], [7, 16], [7, 17], [7, 20], [7, 21], [7, 22], [8, 9], [8, 10], [8, 12], [8, 14], [8, 15], [8, 16], [8, 17], [8, 19], [8, 20], [8, 21], [8, 22], [9, 10], [9, 12], [9, 14], [9, 15], [9, 16], [9, 17], [9, 19], [9, 21], [9, 22], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [11, 12], [11, 15], [11, 17], [11, 19], [11, 20], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [13, 14], [13, 15], [13, 16], [13, 19], [13, 20], [13, 22], [14, 15], [14, 16], [14, 17], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [18, 20], [18, 21], [18, 22], [19, 20], [19, 21], [19, 22], [19, 23], [20, 21], [20, 22], [20, 23], [21, 22], [21, 23], [22, 23]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l3-s2/solution/solve.sh b/tasks/construct-rlve-imp-party-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0ccb2a64a7ee5e8c786b0b438fa85c5e06e55fd3 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l3-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [4, 6, 8, 14, 15, 16, 19, 22]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l3-s2/tests/check.py b/tasks/construct-rlve-imp-party-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l3-s2/tests/check.py @@ -0,0 +1,14 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + c = int_list(ans.get("clique"), n, 0, 3 * n - 1, "clique") + if len(set(c)) != n: + raise Invalid("vertices must be distinct") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(n): + for j in range(i + 1, n): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-imp-party-l3-s2/tests/instance.json b/tasks/construct-rlve-imp-party-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7389890f6a17865d36b7a51805074d17f3eff123 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 8], [0, 10], [0, 12], [0, 14], [0, 15], [0, 16], [0, 17], [0, 19], [0, 20], [0, 21], [0, 22], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [2, 3], [2, 4], [2, 8], [2, 10], [2, 17], [2, 19], [2, 20], [2, 21], [2, 22], [3, 4], [3, 5], [3, 6], [3, 8], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [4, 5], [4, 6], [4, 7], [4, 8], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [5, 8], [5, 10], [5, 12], [5, 14], [5, 16], [5, 17], [5, 19], [5, 20], [5, 21], [5, 22], [6, 7], [6, 8], [6, 9], [6, 10], [6, 12], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [7, 8], [7, 10], [7, 12], [7, 14], [7, 15], [7, 16], [7, 17], [7, 20], [7, 21], [7, 22], [8, 9], [8, 10], [8, 12], [8, 14], [8, 15], [8, 16], [8, 17], [8, 19], [8, 20], [8, 21], [8, 22], [9, 10], [9, 12], [9, 14], [9, 15], [9, 16], [9, 17], [9, 19], [9, 21], [9, 22], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [11, 12], [11, 15], [11, 17], [11, 19], [11, 20], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [13, 14], [13, 15], [13, 16], [13, 19], [13, 20], [13, 22], [14, 15], [14, 16], [14, 17], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [18, 20], [18, 21], [18, 22], [19, 20], [19, 21], [19, 22], [19, 23], [20, 21], [20, 22], [20, 23], [21, 22], [21, 23], [22, 23]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l3-s2/tests/run.py b/tasks/construct-rlve-imp-party-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-l3-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-imp-party-l3-s2/tests/test.sh b/tasks/construct-rlve-imp-party-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l3-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-imp-party-l3-s5/environment/Dockerfile b/tasks/construct-rlve-imp-party-l3-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l3-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-imp-party-l3-s5/environment/instance.json b/tasks/construct-rlve-imp-party-l3-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c8ec525439a0720ff91b7dd19edad0bf8ebb866f --- /dev/null +++ b/tasks/construct-rlve-imp-party-l3-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 6], [0, 7], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 15], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [1, 2], [1, 4], [1, 5], [1, 6], [1, 7], [1, 9], [1, 10], [1, 11], [1, 13], [1, 15], [1, 18], [1, 19], [1, 20], [1, 21], [1, 23], [2, 4], [2, 5], [2, 6], [2, 7], [2, 9], [2, 10], [2, 11], [2, 13], [2, 15], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [3, 6], [3, 15], [3, 18], [4, 5], [4, 6], [4, 7], [4, 9], [4, 10], [4, 11], [4, 13], [4, 15], [4, 16], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [5, 6], [5, 7], [5, 9], [5, 10], [5, 11], [5, 13], [5, 15], [5, 18], [5, 19], [5, 20], [5, 21], [6, 7], [6, 9], [6, 10], [6, 11], [6, 13], [6, 14], [6, 15], [6, 18], [6, 19], [6, 20], [6, 21], [6, 23], [7, 8], [7, 9], [7, 10], [7, 11], [7, 13], [7, 14], [7, 15], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [8, 11], [8, 18], [8, 19], [9, 10], [9, 11], [9, 13], [9, 15], [9, 16], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [11, 13], [11, 14], [11, 15], [11, 18], [11, 19], [11, 20], [11, 21], [12, 13], [12, 18], [12, 21], [13, 15], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [15, 16], [15, 18], [15, 19], [15, 20], [15, 21], [16, 18], [16, 21], [17, 20], [17, 21], [18, 19], [18, 20], [18, 21], [19, 20], [19, 21], [20, 21], [20, 22], [20, 23], [21, 22]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l3-s5/solution/solve.sh b/tasks/construct-rlve-imp-party-l3-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cbc447fcb5f8928ad2d266194723580f2e34998f --- /dev/null +++ b/tasks/construct-rlve-imp-party-l3-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [0, 1, 2, 6, 7, 10, 15, 21]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l3-s5/tests/check.py b/tasks/construct-rlve-imp-party-l3-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l3-s5/tests/check.py @@ -0,0 +1,14 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + c = int_list(ans.get("clique"), n, 0, 3 * n - 1, "clique") + if len(set(c)) != n: + raise Invalid("vertices must be distinct") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(n): + for j in range(i + 1, n): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-imp-party-l3-s5/tests/instance.json b/tasks/construct-rlve-imp-party-l3-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c8ec525439a0720ff91b7dd19edad0bf8ebb866f --- /dev/null +++ b/tasks/construct-rlve-imp-party-l3-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 6], [0, 7], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 15], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [1, 2], [1, 4], [1, 5], [1, 6], [1, 7], [1, 9], [1, 10], [1, 11], [1, 13], [1, 15], [1, 18], [1, 19], [1, 20], [1, 21], [1, 23], [2, 4], [2, 5], [2, 6], [2, 7], [2, 9], [2, 10], [2, 11], [2, 13], [2, 15], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [3, 6], [3, 15], [3, 18], [4, 5], [4, 6], [4, 7], [4, 9], [4, 10], [4, 11], [4, 13], [4, 15], [4, 16], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [5, 6], [5, 7], [5, 9], [5, 10], [5, 11], [5, 13], [5, 15], [5, 18], [5, 19], [5, 20], [5, 21], [6, 7], [6, 9], [6, 10], [6, 11], [6, 13], [6, 14], [6, 15], [6, 18], [6, 19], [6, 20], [6, 21], [6, 23], [7, 8], [7, 9], [7, 10], [7, 11], [7, 13], [7, 14], [7, 15], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [8, 11], [8, 18], [8, 19], [9, 10], [9, 11], [9, 13], [9, 15], [9, 16], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [11, 13], [11, 14], [11, 15], [11, 18], [11, 19], [11, 20], [11, 21], [12, 13], [12, 18], [12, 21], [13, 15], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [15, 16], [15, 18], [15, 19], [15, 20], [15, 21], [16, 18], [16, 21], [17, 20], [17, 21], [18, 19], [18, 20], [18, 21], [19, 20], [19, 21], [20, 21], [20, 22], [20, 23], [21, 22]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l3-s5/tests/test.sh b/tasks/construct-rlve-imp-party-l3-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l3-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-integer-linear-system-l3-s8/environment/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..da6295c64a8594312ee5521af5d943d9f3bd8bf9 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s8/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 1, 1, 0, 0, 0, 1, 0], [1, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 1, 1, 0], [1, 0, 1, 1, 0, 1, 1, 1], [0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0, 1], [0, 0, 0, 1, 0, 0, 1, 0], [1, 0, 0, 0, 1, 1, 1, 1], [0, 1, 0, 1, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 1, 0, 0, 1], [0, 1, 0, 0, 0, 0, 1, 1]], "rhs": [11, 20, 16, 11, 19, 4, 6, 6, 12, 18, 7, 14, 18, 20, 12, 23, 14, 20, 12], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l4-s2/environment/Dockerfile b/tasks/construct-rlve-integer-linear-system-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l4-s2/environment/instance.json b/tasks/construct-rlve-integer-linear-system-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a5f5bdf1480b171e2e77d0fd96d14c9e62f54523 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [[2, 0, 0, 2, 0, 2, 1, 1, 0, 0, 0, 0], [0, 2, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 2, 1, 2, 0, 2, 0, 2, 0, 2], [2, 1, 1, 0, 0, 2, 1, 0, 1, 1, 0, 1], [1, 0, 0, 2, 1, 0, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 1, 0, 2, 0, 1, 0, 0], [2, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0], [2, 0, 0, 0, 1, 0, 2, 0, 0, 1, 2, 0], [0, 0, 0, 1, 1, 2, 0, 0, 1, 2, 1, 1], [2, 0, 2, 1, 0, 1, 2, 1, 1, 2, 1, 0], [2, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 0, 0, 0, 0, 1, 2, 0, 0], [0, 0, 0, 1, 2, 0, 2, 1, 0, 0, 0, 0], [1, 2, 2, 1, 0, 2, 0, 0, 1, 2, 2, 0], [0, 0, 0, 0, 0, 2, 0, 1, 2, 0, 2, 1], [1, 1, 2, 1, 2, 1, 0, 0, 2, 0, 0, 0], [0, 2, 1, 0, 0, 1, 1, 1, 0, 0, 2, 0], [1, 0, 1, 1, 2, 2, 1, 0, 2, 2, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0, 2, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 2, 2], [1, 2, 1, 2, 0, 2, 1, 1, 1, 1, 0, 0], [2, 0, 2, 0, 1, 2, 2, 2, 0, 0, 0, 0], [0, 2, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 2, 2, 0, 1, 0, 2, 1, 0]], "rhs": [44, 41, 24, 93, 72, 57, 29, 61, 59, 83, 94, 29, 48, 47, 36, 115, 59, 84, 58, 106, 25, 68, 83, 63, 50, 78], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l4-s2/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5969fca60fec16d792e34c2e1bee6774b2dc923e --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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' +{"x": [6, 8, 11, 9, 11, 5, 1, 3, 6, 12, 11, 12]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l4-s2/tests/check.py b/tasks/construct-rlve-integer-linear-system-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l4-s2/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = len(inst["coeffs"][0]) + x = int_list(ans.get("x"), n, name="x") + for k, (e, r) in enumerate(zip(inst["coeffs"], inst["rhs"])): + if sum(c * v for c, v in zip(e, x)) != r: + raise Invalid(f"equation {k} is violated") + return None, {} diff --git a/tasks/construct-rlve-integer-linear-system-l4-s2/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a5f5bdf1480b171e2e77d0fd96d14c9e62f54523 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [[2, 0, 0, 2, 0, 2, 1, 1, 0, 0, 0, 0], [0, 2, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 2, 1, 2, 0, 2, 0, 2, 0, 2], [2, 1, 1, 0, 0, 2, 1, 0, 1, 1, 0, 1], [1, 0, 0, 2, 1, 0, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 1, 0, 2, 0, 1, 0, 0], [2, 1, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0], [2, 0, 0, 0, 1, 0, 2, 0, 0, 1, 2, 0], [0, 0, 0, 1, 1, 2, 0, 0, 1, 2, 1, 1], [2, 0, 2, 1, 0, 1, 2, 1, 1, 2, 1, 0], [2, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 0, 0, 0, 0, 1, 2, 0, 0], [0, 0, 0, 1, 2, 0, 2, 1, 0, 0, 0, 0], [1, 2, 2, 1, 0, 2, 0, 0, 1, 2, 2, 0], [0, 0, 0, 0, 0, 2, 0, 1, 2, 0, 2, 1], [1, 1, 2, 1, 2, 1, 0, 0, 2, 0, 0, 0], [0, 2, 1, 0, 0, 1, 1, 1, 0, 0, 2, 0], [1, 0, 1, 1, 2, 2, 1, 0, 2, 2, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0, 2, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 2, 2], [1, 2, 1, 2, 0, 2, 1, 1, 1, 1, 0, 0], [2, 0, 2, 0, 1, 2, 2, 2, 0, 0, 0, 0], [0, 2, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 2, 2, 0, 1, 0, 2, 1, 0]], "rhs": [44, 41, 24, 93, 72, 57, 29, 61, 59, 83, 94, 29, 48, 47, 36, 115, 59, 84, 58, 106, 25, 68, 83, 63, 50, 78], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l4-s2/tests/run.py b/tasks/construct-rlve-integer-linear-system-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l4-s2/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-matrix-permutation-equivalence-l1-s5/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l1-s5/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a15fd2af1acdd386be7974abb99555965584145f --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s5/environment/instance.json @@ -0,0 +1 @@ +{"A": ["110", "101", "110"], "B": ["110", "101", "110"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s5/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8a5b28270ed24a07a1d77ed19220b34367505fc6 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [2, 1, 0], "b": [0, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s5/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s5/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-s5/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a15fd2af1acdd386be7974abb99555965584145f --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s5/tests/instance.json @@ -0,0 +1 @@ +{"A": ["110", "101", "110"], "B": ["110", "101", "110"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s5/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l1-s5/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l2-s0/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l2-s0/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..08c42ba77b5b0ac10753109443cf1c012d5b6369 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"A": ["00001", "00000", "00000"], "B": ["00000", "01000", "00000"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l2-s0/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..987ed1a8f0894a828d7e34db229e52ea86ac5a6e --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [1, 0, 2], "b": [0, 4, 2, 3, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l2-s0/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l2-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-l2-s0/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..08c42ba77b5b0ac10753109443cf1c012d5b6369 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"A": ["00001", "00000", "00000"], "B": ["00000", "01000", "00000"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l2-s0/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l2-s0/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l2-s9/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l2-s9/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dad2b681687d1915cce31a28479c52a5c58215bf --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"A": ["11111", "01110", "11111"], "B": ["11111", "11111", "10101"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l2-s9/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ecdccd70622d02478d67f45035138e954ca2e708 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [0, 2, 1], "b": [1, 4, 3, 0, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l2-s9/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s9/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l2-s9/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dad2b681687d1915cce31a28479c52a5c58215bf --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"A": ["11111", "01110", "11111"], "B": ["11111", "11111", "10101"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l2-s9/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l2-s9/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l6-s1/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l6-s1/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ece31375db96f1bede5f1c5131b9854243dda0aa --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"A": ["11001001000", "11001000000", "10110011001", "00100010101", "00000001101", "11000000100", "00101001011", "00010000100", "00000000100", "00000000000", "00010010000", "10000110010", "00001101000", "00010000000", "10100101000", "00000100010", "10010000001", "00001000001", "00101010000", "00001001001"], "B": ["01110011000", "10000000010", "00001000010", "00001000000", "00100000101", "00000000000", "00100001000", "11001001000", "00100110000", "00000001011", "01000110001", "00000000010", "11100000000", "00001000101", "00100011000", "11000011011", "00010100000", "10010100001", "00100010101", "00001011000"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l6-s1/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..222dda5a32362b9cccf8c834d6997d320e7950b0 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [6, 10, 7, 8, 1, 9, 17, 3, 12, 16, 14, 13, 18, 5, 19, 2, 15, 11, 0, 4], "b": [6, 2, 4, 9, 8, 5, 7, 10, 1, 3, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l6-s1/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l6-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-l6-s1/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ece31375db96f1bede5f1c5131b9854243dda0aa --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"A": ["11001001000", "11001000000", "10110011001", "00100010101", "00000001101", "11000000100", "00101001011", "00010000100", "00000000100", "00000000000", "00010010000", "10000110010", "00001101000", "00010000000", "10100101000", "00000100010", "10010000001", "00001000001", "00101010000", "00001001001"], "B": ["01110011000", "10000000010", "00001000010", "00001000000", "00100000101", "00000000000", "00100001000", "11001001000", "00100110000", "00000001011", "01000110001", "00000000010", "11100000000", "00001000101", "00100011000", "11000011011", "00010100000", "10010100001", "00100010101", "00001011000"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l6-s1/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l6-s1/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l6-s6/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l6-s6/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a659dfb68d66eaa728922e9bec5d1bd0817fc326 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"A": ["1101110101011110110101", "1101111111111101011111", "0110111110111111000101", "1011111111010001111101", "1000100111011111111110", "1111111010111011111110", "0101101101111001001111", "0011011111001101011111", "0111111111011110101000"], "B": ["1100111011101110010101", "0101111111010101001111", "0111010110110111010111", "1111111110100010101111", "1110101111110110101001", "1111111111111110011101", "1010011010011111111101", "1110110000110101111111", "1011111111101101111110"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l6-s6/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ccad4bb61a6559594b38a125cd1b94a5af12a309 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [6, 4, 0, 3, 7, 1, 2, 8, 5], "b": [6, 9, 5, 0, 18, 4, 15, 17, 19, 20, 3, 13, 10, 12, 21, 14, 2, 1, 8, 11, 16, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l6-s6/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s6/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l6-s6/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a659dfb68d66eaa728922e9bec5d1bd0817fc326 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"A": ["1101110101011110110101", "1101111111111101011111", "0110111110111111000101", "1011111111010001111101", "1000100111011111111110", "1111111010111011111110", "0101101101111001001111", "0011011111001101011111", "0111111111011110101000"], "B": ["1100111011101110010101", "0101111111010101001111", "0111010110110111010111", "1111111110100010101111", "1110101111110110101001", "1111111111111110011101", "1010011010011111111101", "1110110000110101111111", "1011111111101101111110"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l6-s6/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l6-s6/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l6-s8/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l6-s8/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bc6aacc1dbc8dbf44eec261583ecb45e5c386333 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"A": ["110010011", "100011110", "110110010", "000011000", "001000100", "001001001", "001111000", "010001101", "101010100", "010100110", "001101001", "101000110", "000100000", "000110001", "000101000", "001100101", "010000000", "101011111", "000010001"], "B": ["000111001", "010001101", "100010011", "000010000", "001101010", "000001001", "001000000", "100100000", "000010010", "000110011", "110001110", "011011000", "111010100", "110101111", "100110000", "111100100", "000100011", "100001101", "100000010"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l6-s8/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ac9fdeba92c1fdbb2cc482adca5b90dc14ae0453 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [15, 11, 6, 12, 7, 4, 16, 18, 14, 10, 1, 9, 2, 17, 13, 0, 5, 8, 3], "b": [4, 7, 1, 8, 3, 6, 0, 5, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l6-s8/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l6-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-l6-s8/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bc6aacc1dbc8dbf44eec261583ecb45e5c386333 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"A": ["110010011", "100011110", "110110010", "000011000", "001000100", "001001001", "001111000", "010001101", "101010100", "010100110", "001101001", "101000110", "000100000", "000110001", "000101000", "001100101", "010000000", "101011111", "000010001"], "B": ["000111001", "010001101", "100010011", "000010000", "001101010", "000001001", "001000000", "100100000", "000010010", "000110011", "110001110", "011011000", "111010100", "110101111", "100110000", "111100100", "000100011", "100001101", "100000010"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l6-s8/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l6-s8/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-maximum-clique-l1-s1/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l1-s1/environment/instance.json b/tasks/construct-rlve-maximum-clique-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..208ecfd834df1fb7a41a9f5f61ca4a4252ba6981 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "k": 5, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [1, 2], [1, 3], [1, 4], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 6], [3, 7], [4, 5], [4, 7], [5, 6]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l1-s1/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ea35585c49cc570b1cd28bd8dc3f826a755b6077 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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' +{"clique": [0, 1, 2, 3, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l1-s1/tests/check.py b/tasks/construct-rlve-maximum-clique-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l1-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-l1-s1/tests/instance.json b/tasks/construct-rlve-maximum-clique-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..208ecfd834df1fb7a41a9f5f61ca4a4252ba6981 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "k": 5, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [1, 2], [1, 3], [1, 4], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 6], [3, 7], [4, 5], [4, 7], [5, 6]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l1-s1/tests/run.py b/tasks/construct-rlve-maximum-clique-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l1-s1/tests/test.sh b/tasks/construct-rlve-maximum-clique-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l1-s8/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l1-s8/environment/instance.json b/tasks/construct-rlve-maximum-clique-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f8c4a64d27d6744b3b737cfd13ac7eeece33a997 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "k": 5, "edges": [[0, 1], [0, 3], [0, 5], [0, 6], [0, 7], [1, 2], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 6], [5, 7], [6, 7]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l1-s8/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..040c34e178321da865018ea02583f9f060e4cc50 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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' +{"clique": [0, 1, 5, 6, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l1-s8/tests/check.py b/tasks/construct-rlve-maximum-clique-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l1-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-l1-s8/tests/instance.json b/tasks/construct-rlve-maximum-clique-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f8c4a64d27d6744b3b737cfd13ac7eeece33a997 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "k": 5, "edges": [[0, 1], [0, 3], [0, 5], [0, 6], [0, 7], [1, 2], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 6], [5, 7], [6, 7]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l1-s8/tests/run.py b/tasks/construct-rlve-maximum-clique-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l1-s8/tests/test.sh b/tasks/construct-rlve-maximum-clique-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l2-s3/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l2-s3/environment/instance.json b/tasks/construct-rlve-maximum-clique-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f31350e16e02206afa0a27e22ac4aa5be331a9e4 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 4, "edges": [[0, 1], [0, 5], [0, 7], [0, 9], [0, 13], [1, 7], [1, 11], [2, 7], [2, 8], [2, 9], [2, 10], [2, 12], [3, 8], [3, 9], [3, 13], [4, 5], [4, 11], [5, 11], [6, 9], [6, 10], [6, 11], [6, 13], [7, 8], [7, 10], [7, 11], [8, 10], [8, 12], [9, 10], [9, 12], [10, 13], [11, 13]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s3/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..422b509479f1f3ec66912fa879c528bf935978f8 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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' +{"clique": [2, 7, 8, 10]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l2-s3/tests/check.py b/tasks/construct-rlve-maximum-clique-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-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("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-s3/tests/instance.json b/tasks/construct-rlve-maximum-clique-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f31350e16e02206afa0a27e22ac4aa5be331a9e4 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 4, "edges": [[0, 1], [0, 5], [0, 7], [0, 9], [0, 13], [1, 7], [1, 11], [2, 7], [2, 8], [2, 9], [2, 10], [2, 12], [3, 8], [3, 9], [3, 13], [4, 5], [4, 11], [5, 11], [6, 9], [6, 10], [6, 11], [6, 13], [7, 8], [7, 10], [7, 11], [8, 10], [8, 12], [9, 10], [9, 12], [10, 13], [11, 13]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s3/tests/run.py b/tasks/construct-rlve-maximum-clique-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l2-s3/tests/test.sh b/tasks/construct-rlve-maximum-clique-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l5-s0/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l5-s0/environment/instance.json b/tasks/construct-rlve-maximum-clique-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5e70474df04b989527579ac67a4245630f9b51b7 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 44, "k": 13, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 17], [0, 18], [0, 19], [0, 22], [0, 23], [0, 24], [0, 26], [0, 27], [0, 28], [0, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 37], [0, 40], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 11], [1, 12], [1, 15], [1, 16], [1, 17], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 35], [1, 36], [1, 38], [1, 40], [1, 41], [1, 42], [1, 43], [2, 4], [2, 5], [2, 6], [2, 7], [2, 10], [2, 11], [2, 12], [2, 13], [2, 15], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 26], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 33], [2, 34], [2, 35], [2, 37], [2, 38], [2, 39], [2, 40], [2, 41], [2, 43], [3, 4], [3, 5], [3, 6], [3, 7], [3, 10], [3, 11], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 25], [3, 26], [3, 27], [3, 28], [3, 31], [3, 32], [3, 33], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [3, 40], [3, 42], [3, 43], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 17], [4, 18], [4, 20], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 30], [4, 31], [4, 33], [4, 34], [4, 35], [4, 36], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 43], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 16], [5, 17], [5, 19], [5, 20], [5, 21], [5, 22], [5, 25], [5, 27], [5, 28], [5, 29], [5, 30], [5, 33], [5, 34], [5, 36], [5, 37], [5, 39], [5, 40], [5, 41], [5, 43], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 14], [6, 16], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [6, 27], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [6, 34], [6, 35], [6, 36], [6, 37], [6, 38], [6, 39], [6, 41], [6, 43], [7, 9], [7, 10], [7, 11], [7, 12], [7, 14], [7, 15], [7, 17], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 29], [7, 30], [7, 34], [7, 35], [7, 37], [7, 39], [7, 40], [7, 42], [7, 43], [8, 9], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 18], [8, 19], [8, 20], [8, 21], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 32], [8, 33], [8, 34], [8, 35], [8, 37], [8, 38], [8, 40], [8, 41], [8, 42], [8, 43], [9, 10], [9, 11], [9, 12], [9, 13], [9, 15], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 25], [9, 27], [9, 30], [9, 31], [9, 32], [9, 34], [9, 35], [9, 36], [9, 37], [9, 39], [9, 40], [9, 41], [9, 42], [9, 43], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 25], [10, 29], [10, 30], [10, 31], [10, 32], [10, 33], [10, 35], [10, 36], [10, 38], [10, 40], [10, 42], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 18], [11, 19], [11, 22], [11, 27], [11, 28], [11, 31], [11, 35], [11, 36], [11, 37], [11, 39], [11, 41], [11, 42], [12, 13], [12, 14], [12, 15], [12, 16], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 24], [12, 26], [12, 29], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [12, 36], [12, 37], [12, 39], [12, 40], [12, 41], [12, 42], [12, 43], [13, 15], [13, 16], [13, 17], [13, 18], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 26], [13, 27], [13, 28], [13, 29], [13, 32], [13, 34], [13, 35], [13, 38], [13, 40], [13, 41], [13, 42], [13, 43], [14, 15], [14, 16], [14, 17], [14, 19], [14, 20], [14, 21], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 33], [14, 34], [14, 35], [14, 37], [14, 38], [14, 39], [14, 40], [14, 42], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 24], [15, 25], [15, 26], [15, 27], [15, 30], [15, 34], [15, 35], [15, 36], [15, 37], [15, 38], [15, 39], [15, 40], [15, 41], [15, 42], [15, 43], [16, 17], [16, 18], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 32], [16, 34], [16, 35], [16, 36], [16, 37], [16, 38], [16, 39], [16, 40], [16, 41], [16, 42], [16, 43], [17, 18], [17, 19], [17, 21], [17, 22], [17, 23], [17, 24], [17, 27], [17, 28], [17, 29], [17, 31], [17, 32], [17, 33], [17, 34], [17, 36], [17, 37], [17, 38], [17, 40], [17, 41], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 27], [18, 29], [18, 30], [18, 34], [18, 35], [18, 37], [18, 39], [18, 40], [18, 41], [18, 42], [18, 43], [19, 20], [19, 21], [19, 22], [19, 23], [19, 25], [19, 26], [19, 27], [19, 28], [19, 31], [19, 32], [19, 34], [19, 35], [19, 37], [19, 38], [19, 40], [19, 41], [19, 43], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 34], [20, 35], [20, 37], [20, 38], [20, 39], [20, 40], [20, 41], [20, 42], [21, 22], [21, 24], [21, 25], [21, 26], [21, 28], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [21, 38], [21, 39], [21, 40], [21, 41], [21, 42], [21, 43], [22, 23], [22, 24], [22, 26], [22, 27], [22, 28], [22, 29], [22, 30], [22, 31], [22, 32], [22, 33], [22, 34], [22, 35], [22, 37], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [23, 24], [23, 25], [23, 26], [23, 27], [23, 29], [23, 31], [23, 32], [23, 33], [23, 34], [23, 37], [23, 38], [23, 39], [23, 40], [23, 43], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [24, 36], [24, 37], [24, 38], [24, 40], [24, 41], [24, 42], [25, 26], [25, 27], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 35], [25, 36], [25, 38], [25, 39], [25, 40], [25, 41], [25, 42], [25, 43], [26, 27], [26, 30], [26, 31], [26, 32], [26, 36], [26, 39], [26, 40], [26, 41], [26, 42], [26, 43], [27, 28], [27, 30], [27, 31], [27, 32], [27, 33], [27, 35], [27, 36], [27, 37], [27, 39], [27, 40], [27, 41], [27, 42], [27, 43], [28, 29], [28, 30], [28, 32], [28, 34], [28, 35], [28, 37], [29, 30], [29, 31], [29, 32], [29, 35], [29, 37], [29, 38], [29, 40], [29, 41], [29, 42], [29, 43], [30, 32], [30, 35], [30, 38], [30, 41], [30, 43], [31, 32], [31, 33], [31, 34], [31, 36], [31, 38], [31, 40], [31, 43], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 38], [32, 39], [32, 41], [32, 42], [33, 34], [33, 36], [33, 37], [33, 38], [33, 39], [33, 40], [33, 42], [33, 43], [34, 36], [34, 38], [34, 39], [34, 40], [34, 41], [34, 42], [34, 43], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 42], [35, 43], [36, 37], [36, 39], [36, 40], [36, 41], [36, 42], [36, 43], [37, 38], [37, 39], [37, 40], [37, 41], [37, 43], [38, 39], [38, 40], [38, 41], [38, 42], [39, 40], [39, 41], [40, 41], [40, 42], [40, 43], [41, 42], [41, 43], [42, 43]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l5-s0/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6630e07355dc4aee1cf50087c017a31380f5a564 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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' +{"clique": [1, 8, 12, 15, 16, 20, 21, 22, 24, 26, 40, 41, 42]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l5-s0/tests/check.py b/tasks/construct-rlve-maximum-clique-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l5-s0/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l5-s0/tests/instance.json b/tasks/construct-rlve-maximum-clique-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5e70474df04b989527579ac67a4245630f9b51b7 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 44, "k": 13, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 17], [0, 18], [0, 19], [0, 22], [0, 23], [0, 24], [0, 26], [0, 27], [0, 28], [0, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 37], [0, 40], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 11], [1, 12], [1, 15], [1, 16], [1, 17], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 35], [1, 36], [1, 38], [1, 40], [1, 41], [1, 42], [1, 43], [2, 4], [2, 5], [2, 6], [2, 7], [2, 10], [2, 11], [2, 12], [2, 13], [2, 15], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 26], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 33], [2, 34], [2, 35], [2, 37], [2, 38], [2, 39], [2, 40], [2, 41], [2, 43], [3, 4], [3, 5], [3, 6], [3, 7], [3, 10], [3, 11], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 25], [3, 26], [3, 27], [3, 28], [3, 31], [3, 32], [3, 33], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [3, 40], [3, 42], [3, 43], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 17], [4, 18], [4, 20], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 30], [4, 31], [4, 33], [4, 34], [4, 35], [4, 36], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 43], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 16], [5, 17], [5, 19], [5, 20], [5, 21], [5, 22], [5, 25], [5, 27], [5, 28], [5, 29], [5, 30], [5, 33], [5, 34], [5, 36], [5, 37], [5, 39], [5, 40], [5, 41], [5, 43], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 14], [6, 16], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [6, 27], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [6, 34], [6, 35], [6, 36], [6, 37], [6, 38], [6, 39], [6, 41], [6, 43], [7, 9], [7, 10], [7, 11], [7, 12], [7, 14], [7, 15], [7, 17], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 29], [7, 30], [7, 34], [7, 35], [7, 37], [7, 39], [7, 40], [7, 42], [7, 43], [8, 9], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 18], [8, 19], [8, 20], [8, 21], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 32], [8, 33], [8, 34], [8, 35], [8, 37], [8, 38], [8, 40], [8, 41], [8, 42], [8, 43], [9, 10], [9, 11], [9, 12], [9, 13], [9, 15], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 25], [9, 27], [9, 30], [9, 31], [9, 32], [9, 34], [9, 35], [9, 36], [9, 37], [9, 39], [9, 40], [9, 41], [9, 42], [9, 43], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 25], [10, 29], [10, 30], [10, 31], [10, 32], [10, 33], [10, 35], [10, 36], [10, 38], [10, 40], [10, 42], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 18], [11, 19], [11, 22], [11, 27], [11, 28], [11, 31], [11, 35], [11, 36], [11, 37], [11, 39], [11, 41], [11, 42], [12, 13], [12, 14], [12, 15], [12, 16], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 24], [12, 26], [12, 29], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [12, 36], [12, 37], [12, 39], [12, 40], [12, 41], [12, 42], [12, 43], [13, 15], [13, 16], [13, 17], [13, 18], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 26], [13, 27], [13, 28], [13, 29], [13, 32], [13, 34], [13, 35], [13, 38], [13, 40], [13, 41], [13, 42], [13, 43], [14, 15], [14, 16], [14, 17], [14, 19], [14, 20], [14, 21], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 33], [14, 34], [14, 35], [14, 37], [14, 38], [14, 39], [14, 40], [14, 42], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 24], [15, 25], [15, 26], [15, 27], [15, 30], [15, 34], [15, 35], [15, 36], [15, 37], [15, 38], [15, 39], [15, 40], [15, 41], [15, 42], [15, 43], [16, 17], [16, 18], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 32], [16, 34], [16, 35], [16, 36], [16, 37], [16, 38], [16, 39], [16, 40], [16, 41], [16, 42], [16, 43], [17, 18], [17, 19], [17, 21], [17, 22], [17, 23], [17, 24], [17, 27], [17, 28], [17, 29], [17, 31], [17, 32], [17, 33], [17, 34], [17, 36], [17, 37], [17, 38], [17, 40], [17, 41], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 27], [18, 29], [18, 30], [18, 34], [18, 35], [18, 37], [18, 39], [18, 40], [18, 41], [18, 42], [18, 43], [19, 20], [19, 21], [19, 22], [19, 23], [19, 25], [19, 26], [19, 27], [19, 28], [19, 31], [19, 32], [19, 34], [19, 35], [19, 37], [19, 38], [19, 40], [19, 41], [19, 43], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 34], [20, 35], [20, 37], [20, 38], [20, 39], [20, 40], [20, 41], [20, 42], [21, 22], [21, 24], [21, 25], [21, 26], [21, 28], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [21, 38], [21, 39], [21, 40], [21, 41], [21, 42], [21, 43], [22, 23], [22, 24], [22, 26], [22, 27], [22, 28], [22, 29], [22, 30], [22, 31], [22, 32], [22, 33], [22, 34], [22, 35], [22, 37], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [23, 24], [23, 25], [23, 26], [23, 27], [23, 29], [23, 31], [23, 32], [23, 33], [23, 34], [23, 37], [23, 38], [23, 39], [23, 40], [23, 43], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [24, 36], [24, 37], [24, 38], [24, 40], [24, 41], [24, 42], [25, 26], [25, 27], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 35], [25, 36], [25, 38], [25, 39], [25, 40], [25, 41], [25, 42], [25, 43], [26, 27], [26, 30], [26, 31], [26, 32], [26, 36], [26, 39], [26, 40], [26, 41], [26, 42], [26, 43], [27, 28], [27, 30], [27, 31], [27, 32], [27, 33], [27, 35], [27, 36], [27, 37], [27, 39], [27, 40], [27, 41], [27, 42], [27, 43], [28, 29], [28, 30], [28, 32], [28, 34], [28, 35], [28, 37], [29, 30], [29, 31], [29, 32], [29, 35], [29, 37], [29, 38], [29, 40], [29, 41], [29, 42], [29, 43], [30, 32], [30, 35], [30, 38], [30, 41], [30, 43], [31, 32], [31, 33], [31, 34], [31, 36], [31, 38], [31, 40], [31, 43], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 38], [32, 39], [32, 41], [32, 42], [33, 34], [33, 36], [33, 37], [33, 38], [33, 39], [33, 40], [33, 42], [33, 43], [34, 36], [34, 38], [34, 39], [34, 40], [34, 41], [34, 42], [34, 43], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 42], [35, 43], [36, 37], [36, 39], [36, 40], [36, 41], [36, 42], [36, 43], [37, 38], [37, 39], [37, 40], [37, 41], [37, 43], [38, 39], [38, 40], [38, 41], [38, 42], [39, 40], [39, 41], [40, 41], [40, 42], [40, 43], [41, 42], [41, 43], [42, 43]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l5-s0/tests/run.py b/tasks/construct-rlve-maximum-clique-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l5-s0/tests/test.sh b/tasks/construct-rlve-maximum-clique-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l5-s7/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l5-s7/environment/instance.json b/tasks/construct-rlve-maximum-clique-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..54a14c17056aafef97281eed816963f8e6c0e281 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 44, "k": 12, "edges": [[0, 1], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 15], [0, 16], [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, 30], [0, 32], [0, 33], [0, 36], [0, 38], [0, 39], [0, 40], [0, 41], [0, 42], [0, 43], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 10], [1, 11], [1, 12], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [1, 41], [1, 42], [1, 43], [2, 3], [2, 4], [2, 6], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 15], [2, 17], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 25], [2, 26], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 33], [2, 34], [2, 35], [2, 36], [2, 37], [2, 38], [2, 41], [2, 43], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 23], [3, 26], [3, 27], [3, 28], [3, 29], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [3, 41], [3, 42], [4, 5], [4, 7], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 15], [4, 17], [4, 18], [4, 19], [4, 21], [4, 22], [4, 25], [4, 26], [4, 27], [4, 29], [4, 31], [4, 32], [4, 33], [4, 36], [4, 38], [4, 41], [4, 42], [5, 7], [5, 8], [5, 9], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 29], [5, 30], [5, 33], [5, 34], [5, 36], [5, 37], [5, 39], [5, 40], [5, 41], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 14], [6, 15], [6, 20], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 34], [6, 35], [6, 37], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [7, 8], [7, 9], [7, 10], [7, 11], [7, 13], [7, 14], [7, 15], [7, 18], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 27], [7, 28], [7, 30], [7, 31], [7, 33], [7, 34], [7, 35], [7, 36], [7, 37], [7, 38], [7, 40], [7, 41], [7, 42], [8, 10], [8, 11], [8, 12], [8, 13], [8, 15], [8, 16], [8, 17], [8, 19], [8, 21], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 29], [8, 30], [8, 31], [8, 36], [8, 37], [8, 38], [8, 39], [8, 40], [8, 41], [8, 42], [9, 11], [9, 12], [9, 13], [9, 14], [9, 16], [9, 17], [9, 18], [9, 20], [9, 21], [9, 22], [9, 24], [9, 25], [9, 26], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 35], [9, 37], [9, 38], [9, 39], [9, 40], [9, 41], [9, 42], [10, 12], [10, 13], [10, 14], [10, 15], [10, 17], [10, 18], [10, 20], [10, 21], [10, 22], [10, 25], [10, 26], [10, 27], [10, 29], [10, 30], [10, 31], [10, 32], [10, 34], [10, 38], [10, 39], [10, 40], [10, 42], [10, 43], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 23], [11, 24], [11, 25], [11, 26], [11, 28], [11, 29], [11, 30], [11, 31], [11, 33], [11, 34], [11, 36], [11, 37], [11, 38], [11, 39], [11, 40], [11, 41], [11, 42], [11, 43], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 20], [12, 25], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 34], [12, 35], [12, 37], [12, 38], [12, 39], [12, 40], [12, 41], [12, 42], [12, 43], [13, 14], [13, 15], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 24], [13, 25], [13, 27], [13, 28], [13, 29], [13, 30], [13, 31], [13, 32], [13, 34], [13, 35], [13, 37], [13, 38], [13, 39], [13, 40], [13, 42], [13, 43], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 22], [14, 23], [14, 24], [14, 25], [14, 27], [14, 28], [14, 29], [14, 31], [14, 33], [14, 34], [14, 35], [14, 36], [14, 37], [14, 38], [14, 39], [14, 40], [14, 41], [14, 42], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 27], [15, 29], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [15, 37], [15, 38], [15, 39], [15, 41], [15, 42], [15, 43], [16, 17], [16, 18], [16, 20], [16, 21], [16, 28], [16, 29], [16, 32], [16, 33], [16, 34], [16, 36], [16, 37], [16, 38], [16, 40], [16, 41], [16, 42], [16, 43], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 25], [17, 27], [17, 28], [17, 29], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [17, 39], [17, 40], [17, 41], [17, 42], [17, 43], [18, 19], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [18, 36], [18, 37], [18, 39], [18, 40], [18, 41], [18, 42], [18, 43], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 29], [19, 31], [19, 32], [19, 34], [19, 35], [19, 36], [19, 38], [19, 39], [19, 40], [20, 22], [20, 24], [20, 26], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 34], [20, 35], [20, 36], [20, 38], [20, 40], [20, 41], [20, 42], [20, 43], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 34], [21, 35], [21, 36], [21, 37], [21, 38], [21, 39], [21, 40], [21, 41], [21, 42], [22, 23], [22, 24], [22, 25], [22, 27], [22, 28], [22, 30], [22, 31], [22, 33], [22, 34], [22, 35], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 43], [23, 24], [23, 25], [23, 27], [23, 28], [23, 30], [23, 31], [23, 32], [23, 34], [23, 35], [23, 36], [23, 37], [23, 38], [23, 39], [23, 40], [23, 41], [23, 42], [23, 43], [24, 26], [24, 27], [24, 28], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [24, 36], [24, 39], [24, 41], [24, 42], [24, 43], [25, 26], [25, 27], [25, 28], [25, 29], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [25, 37], [25, 38], [25, 39], [25, 40], [25, 41], [25, 42], [25, 43], [26, 28], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [26, 37], [26, 38], [26, 39], [26, 40], [26, 42], [27, 28], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 34], [27, 37], [27, 39], [27, 40], [27, 43], [28, 29], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [28, 36], [28, 37], [28, 38], [28, 39], [28, 40], [28, 42], [28, 43], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 35], [29, 36], [29, 38], [29, 39], [29, 40], [29, 42], [30, 31], [30, 33], [30, 34], [30, 35], [30, 36], [30, 37], [30, 39], [30, 40], [30, 43], [31, 32], [31, 33], [31, 34], [31, 35], [31, 36], [31, 39], [31, 43], [32, 33], [32, 35], [32, 36], [32, 37], [32, 39], [32, 41], [32, 42], [32, 43], [33, 34], [33, 35], [33, 36], [33, 37], [33, 38], [33, 40], [33, 43], [34, 35], [34, 36], [34, 37], [34, 38], [34, 39], [34, 40], [34, 41], [34, 42], [34, 43], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 43], [36, 37], [36, 40], [36, 41], [37, 38], [37, 39], [37, 40], [37, 41], [37, 42], [38, 40], [38, 41], [38, 43], [39, 41], [39, 43], [40, 41], [40, 43], [41, 42], [41, 43], [42, 43]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l5-s7/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..929470fc9422500e41bc6f850856448b92369bf8 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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' +{"clique": [1, 2, 6, 15, 22, 23, 25, 34, 35, 38, 41, 43]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l5-s7/tests/check.py b/tasks/construct-rlve-maximum-clique-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l5-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-l5-s7/tests/instance.json b/tasks/construct-rlve-maximum-clique-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..54a14c17056aafef97281eed816963f8e6c0e281 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 44, "k": 12, "edges": [[0, 1], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 15], [0, 16], [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, 30], [0, 32], [0, 33], [0, 36], [0, 38], [0, 39], [0, 40], [0, 41], [0, 42], [0, 43], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 10], [1, 11], [1, 12], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [1, 41], [1, 42], [1, 43], [2, 3], [2, 4], [2, 6], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 15], [2, 17], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 25], [2, 26], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 33], [2, 34], [2, 35], [2, 36], [2, 37], [2, 38], [2, 41], [2, 43], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 23], [3, 26], [3, 27], [3, 28], [3, 29], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [3, 41], [3, 42], [4, 5], [4, 7], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 15], [4, 17], [4, 18], [4, 19], [4, 21], [4, 22], [4, 25], [4, 26], [4, 27], [4, 29], [4, 31], [4, 32], [4, 33], [4, 36], [4, 38], [4, 41], [4, 42], [5, 7], [5, 8], [5, 9], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 29], [5, 30], [5, 33], [5, 34], [5, 36], [5, 37], [5, 39], [5, 40], [5, 41], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 14], [6, 15], [6, 20], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 34], [6, 35], [6, 37], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [7, 8], [7, 9], [7, 10], [7, 11], [7, 13], [7, 14], [7, 15], [7, 18], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 27], [7, 28], [7, 30], [7, 31], [7, 33], [7, 34], [7, 35], [7, 36], [7, 37], [7, 38], [7, 40], [7, 41], [7, 42], [8, 10], [8, 11], [8, 12], [8, 13], [8, 15], [8, 16], [8, 17], [8, 19], [8, 21], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 29], [8, 30], [8, 31], [8, 36], [8, 37], [8, 38], [8, 39], [8, 40], [8, 41], [8, 42], [9, 11], [9, 12], [9, 13], [9, 14], [9, 16], [9, 17], [9, 18], [9, 20], [9, 21], [9, 22], [9, 24], [9, 25], [9, 26], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 35], [9, 37], [9, 38], [9, 39], [9, 40], [9, 41], [9, 42], [10, 12], [10, 13], [10, 14], [10, 15], [10, 17], [10, 18], [10, 20], [10, 21], [10, 22], [10, 25], [10, 26], [10, 27], [10, 29], [10, 30], [10, 31], [10, 32], [10, 34], [10, 38], [10, 39], [10, 40], [10, 42], [10, 43], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 23], [11, 24], [11, 25], [11, 26], [11, 28], [11, 29], [11, 30], [11, 31], [11, 33], [11, 34], [11, 36], [11, 37], [11, 38], [11, 39], [11, 40], [11, 41], [11, 42], [11, 43], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 20], [12, 25], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 34], [12, 35], [12, 37], [12, 38], [12, 39], [12, 40], [12, 41], [12, 42], [12, 43], [13, 14], [13, 15], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 24], [13, 25], [13, 27], [13, 28], [13, 29], [13, 30], [13, 31], [13, 32], [13, 34], [13, 35], [13, 37], [13, 38], [13, 39], [13, 40], [13, 42], [13, 43], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 22], [14, 23], [14, 24], [14, 25], [14, 27], [14, 28], [14, 29], [14, 31], [14, 33], [14, 34], [14, 35], [14, 36], [14, 37], [14, 38], [14, 39], [14, 40], [14, 41], [14, 42], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 27], [15, 29], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [15, 37], [15, 38], [15, 39], [15, 41], [15, 42], [15, 43], [16, 17], [16, 18], [16, 20], [16, 21], [16, 28], [16, 29], [16, 32], [16, 33], [16, 34], [16, 36], [16, 37], [16, 38], [16, 40], [16, 41], [16, 42], [16, 43], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 25], [17, 27], [17, 28], [17, 29], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [17, 39], [17, 40], [17, 41], [17, 42], [17, 43], [18, 19], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [18, 36], [18, 37], [18, 39], [18, 40], [18, 41], [18, 42], [18, 43], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 29], [19, 31], [19, 32], [19, 34], [19, 35], [19, 36], [19, 38], [19, 39], [19, 40], [20, 22], [20, 24], [20, 26], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 34], [20, 35], [20, 36], [20, 38], [20, 40], [20, 41], [20, 42], [20, 43], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 34], [21, 35], [21, 36], [21, 37], [21, 38], [21, 39], [21, 40], [21, 41], [21, 42], [22, 23], [22, 24], [22, 25], [22, 27], [22, 28], [22, 30], [22, 31], [22, 33], [22, 34], [22, 35], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 43], [23, 24], [23, 25], [23, 27], [23, 28], [23, 30], [23, 31], [23, 32], [23, 34], [23, 35], [23, 36], [23, 37], [23, 38], [23, 39], [23, 40], [23, 41], [23, 42], [23, 43], [24, 26], [24, 27], [24, 28], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [24, 36], [24, 39], [24, 41], [24, 42], [24, 43], [25, 26], [25, 27], [25, 28], [25, 29], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [25, 37], [25, 38], [25, 39], [25, 40], [25, 41], [25, 42], [25, 43], [26, 28], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [26, 37], [26, 38], [26, 39], [26, 40], [26, 42], [27, 28], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 34], [27, 37], [27, 39], [27, 40], [27, 43], [28, 29], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [28, 36], [28, 37], [28, 38], [28, 39], [28, 40], [28, 42], [28, 43], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 35], [29, 36], [29, 38], [29, 39], [29, 40], [29, 42], [30, 31], [30, 33], [30, 34], [30, 35], [30, 36], [30, 37], [30, 39], [30, 40], [30, 43], [31, 32], [31, 33], [31, 34], [31, 35], [31, 36], [31, 39], [31, 43], [32, 33], [32, 35], [32, 36], [32, 37], [32, 39], [32, 41], [32, 42], [32, 43], [33, 34], [33, 35], [33, 36], [33, 37], [33, 38], [33, 40], [33, 43], [34, 35], [34, 36], [34, 37], [34, 38], [34, 39], [34, 40], [34, 41], [34, 42], [34, 43], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 43], [36, 37], [36, 40], [36, 41], [37, 38], [37, 39], [37, 40], [37, 41], [37, 42], [38, 40], [38, 41], [38, 43], [39, 41], [39, 43], [40, 41], [40, 43], [41, 42], [41, 43], [42, 43]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l5-s7/tests/run.py b/tasks/construct-rlve-maximum-clique-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l5-s7/tests/test.sh b/tasks/construct-rlve-maximum-clique-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l5-s9/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l5-s9/environment/instance.json b/tasks/construct-rlve-maximum-clique-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..76df6a77c9bb12f7feb18fdff2d5a349c1c28140 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 44, "k": 13, "edges": [[0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 11], [0, 12], [0, 13], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29], [0, 30], [0, 31], [0, 33], [0, 34], [0, 35], [0, 36], [0, 39], [0, 41], [0, 42], [1, 2], [1, 4], [1, 6], [1, 8], [1, 9], [1, 11], [1, 12], [1, 14], [1, 15], [1, 17], [1, 18], [1, 19], [1, 20], [1, 22], [1, 23], [1, 26], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [1, 36], [1, 39], [1, 40], [1, 41], [1, 42], [1, 43], [2, 3], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 18], [2, 19], [2, 21], [2, 23], [2, 24], [2, 26], [2, 27], [2, 28], [2, 29], [2, 31], [2, 32], [2, 33], [2, 36], [2, 37], [2, 39], [2, 40], [2, 41], [2, 42], [3, 4], [3, 5], [3, 6], [3, 7], [3, 9], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 27], [3, 28], [3, 29], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 39], [3, 40], [3, 41], [3, 42], [3, 43], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 12], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 38], [4, 40], [4, 41], [4, 42], [4, 43], [5, 6], [5, 7], [5, 9], [5, 10], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 21], [5, 23], [5, 24], [5, 25], [5, 27], [5, 29], [5, 30], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [5, 36], [5, 37], [5, 40], [5, 41], [5, 42], [5, 43], [6, 8], [6, 9], [6, 10], [6, 12], [6, 15], [6, 16], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [6, 23], [6, 24], [6, 26], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [6, 35], [6, 36], [6, 37], [6, 38], [6, 41], [6, 42], [6, 43], [7, 9], [7, 10], [7, 11], [7, 12], [7, 14], [7, 15], [7, 16], [7, 17], [7, 19], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 31], [7, 33], [7, 35], [7, 36], [7, 37], [7, 41], [7, 42], [8, 9], [8, 10], [8, 14], [8, 15], [8, 16], [8, 18], [8, 19], [8, 20], [8, 22], [8, 23], [8, 25], [8, 26], [8, 27], [8, 31], [8, 32], [8, 34], [8, 36], [8, 37], [8, 39], [8, 41], [8, 42], [9, 10], [9, 12], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 22], [9, 23], [9, 24], [9, 25], [9, 27], [9, 28], [9, 30], [9, 32], [9, 34], [9, 35], [9, 37], [9, 38], [9, 40], [9, 41], [9, 42], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 19], [10, 21], [10, 22], [10, 23], [10, 25], [10, 28], [10, 30], [10, 31], [10, 33], [10, 34], [10, 35], [10, 36], [10, 37], [10, 39], [10, 40], [10, 41], [10, 42], [10, 43], [11, 12], [11, 14], [11, 15], [11, 16], [11, 18], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 27], [11, 28], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 36], [11, 37], [11, 38], [11, 39], [11, 40], [11, 42], [11, 43], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 29], [12, 30], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [12, 36], [12, 37], [12, 39], [12, 40], [12, 41], [12, 42], [12, 43], [13, 14], [13, 15], [13, 16], [13, 17], [13, 19], [13, 22], [13, 24], [13, 26], [13, 27], [13, 28], [13, 29], [13, 31], [13, 32], [13, 33], [13, 34], [13, 36], [13, 37], [13, 38], [13, 39], [13, 41], [13, 42], [14, 15], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [14, 36], [14, 38], [14, 39], [14, 41], [14, 42], [15, 16], [15, 18], [15, 19], [15, 22], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 34], [15, 35], [15, 36], [15, 37], [15, 38], [15, 40], [15, 41], [15, 42], [15, 43], [16, 17], [16, 18], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 33], [16, 35], [16, 37], [16, 38], [16, 39], [16, 40], [16, 42], [16, 43], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 30], [17, 31], [17, 32], [17, 37], [17, 38], [17, 39], [17, 40], [17, 43], [18, 21], [18, 22], [18, 23], [18, 24], [18, 26], [18, 27], [18, 29], [18, 30], [18, 33], [18, 34], [18, 35], [18, 37], [18, 39], [18, 40], [18, 41], [18, 42], [18, 43], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 26], [19, 30], [19, 32], [19, 33], [19, 34], [19, 35], [19, 38], [19, 39], [19, 41], [19, 42], [19, 43], [20, 21], [20, 23], [20, 24], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 34], [20, 35], [20, 37], [20, 38], [20, 39], [20, 40], [20, 41], [20, 42], [20, 43], [21, 22], [21, 24], [21, 25], [21, 26], [21, 27], [21, 31], [21, 32], [21, 33], [21, 34], [21, 37], [21, 38], [21, 41], [21, 42], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 30], [22, 32], [22, 33], [22, 34], [22, 35], [22, 36], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 43], [23, 25], [23, 26], [23, 28], [23, 32], [23, 33], [23, 34], [23, 35], [23, 36], [23, 37], [23, 38], [23, 39], [23, 41], [23, 42], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 36], [24, 37], [24, 38], [24, 41], [24, 43], [25, 26], [25, 28], [25, 30], [25, 31], [25, 33], [25, 34], [25, 35], [25, 36], [25, 37], [25, 38], [25, 39], [25, 40], [25, 41], [25, 42], [26, 28], [26, 29], [26, 30], [26, 31], [26, 33], [26, 34], [26, 35], [26, 36], [26, 39], [26, 40], [26, 41], [26, 42], [26, 43], [27, 28], [27, 29], [27, 31], [27, 32], [27, 33], [27, 35], [27, 37], [27, 38], [27, 39], [27, 41], [27, 43], [28, 29], [28, 30], [28, 31], [28, 32], [28, 36], [28, 37], [28, 39], [28, 40], [28, 42], [28, 43], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 35], [29, 36], [29, 37], [29, 39], [29, 41], [30, 32], [30, 33], [30, 34], [30, 35], [30, 36], [30, 37], [30, 39], [30, 40], [30, 41], [30, 42], [30, 43], [31, 32], [31, 33], [31, 35], [31, 36], [31, 37], [31, 38], [31, 39], [31, 40], [31, 42], [31, 43], [32, 33], [32, 34], [32, 36], [32, 37], [32, 39], [32, 40], [32, 42], [33, 34], [33, 35], [33, 36], [33, 37], [33, 38], [33, 39], [33, 41], [33, 42], [33, 43], [34, 38], [34, 39], [34, 40], [34, 42], [34, 43], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 42], [35, 43], [36, 37], [36, 38], [36, 39], [36, 40], [36, 41], [36, 42], [37, 38], [37, 39], [37, 40], [37, 41], [37, 42], [37, 43], [38, 39], [38, 40], [38, 42], [38, 43], [39, 40], [39, 41], [39, 42], [39, 43], [40, 41], [40, 43], [41, 42], [41, 43], [42, 43]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l5-s9/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f3a86b7362ba1b10e2c3b6425875f10e56ff4c60 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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' +{"clique": [1, 4, 6, 12, 15, 18, 22, 26, 30, 35, 41, 42, 43]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l5-s9/tests/check.py b/tasks/construct-rlve-maximum-clique-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l5-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-l5-s9/tests/instance.json b/tasks/construct-rlve-maximum-clique-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..76df6a77c9bb12f7feb18fdff2d5a349c1c28140 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 44, "k": 13, "edges": [[0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 11], [0, 12], [0, 13], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29], [0, 30], [0, 31], [0, 33], [0, 34], [0, 35], [0, 36], [0, 39], [0, 41], [0, 42], [1, 2], [1, 4], [1, 6], [1, 8], [1, 9], [1, 11], [1, 12], [1, 14], [1, 15], [1, 17], [1, 18], [1, 19], [1, 20], [1, 22], [1, 23], [1, 26], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [1, 36], [1, 39], [1, 40], [1, 41], [1, 42], [1, 43], [2, 3], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 18], [2, 19], [2, 21], [2, 23], [2, 24], [2, 26], [2, 27], [2, 28], [2, 29], [2, 31], [2, 32], [2, 33], [2, 36], [2, 37], [2, 39], [2, 40], [2, 41], [2, 42], [3, 4], [3, 5], [3, 6], [3, 7], [3, 9], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 27], [3, 28], [3, 29], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 39], [3, 40], [3, 41], [3, 42], [3, 43], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 12], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 38], [4, 40], [4, 41], [4, 42], [4, 43], [5, 6], [5, 7], [5, 9], [5, 10], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 21], [5, 23], [5, 24], [5, 25], [5, 27], [5, 29], [5, 30], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [5, 36], [5, 37], [5, 40], [5, 41], [5, 42], [5, 43], [6, 8], [6, 9], [6, 10], [6, 12], [6, 15], [6, 16], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [6, 23], [6, 24], [6, 26], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [6, 35], [6, 36], [6, 37], [6, 38], [6, 41], [6, 42], [6, 43], [7, 9], [7, 10], [7, 11], [7, 12], [7, 14], [7, 15], [7, 16], [7, 17], [7, 19], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 31], [7, 33], [7, 35], [7, 36], [7, 37], [7, 41], [7, 42], [8, 9], [8, 10], [8, 14], [8, 15], [8, 16], [8, 18], [8, 19], [8, 20], [8, 22], [8, 23], [8, 25], [8, 26], [8, 27], [8, 31], [8, 32], [8, 34], [8, 36], [8, 37], [8, 39], [8, 41], [8, 42], [9, 10], [9, 12], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 22], [9, 23], [9, 24], [9, 25], [9, 27], [9, 28], [9, 30], [9, 32], [9, 34], [9, 35], [9, 37], [9, 38], [9, 40], [9, 41], [9, 42], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 19], [10, 21], [10, 22], [10, 23], [10, 25], [10, 28], [10, 30], [10, 31], [10, 33], [10, 34], [10, 35], [10, 36], [10, 37], [10, 39], [10, 40], [10, 41], [10, 42], [10, 43], [11, 12], [11, 14], [11, 15], [11, 16], [11, 18], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 27], [11, 28], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 36], [11, 37], [11, 38], [11, 39], [11, 40], [11, 42], [11, 43], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 29], [12, 30], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [12, 36], [12, 37], [12, 39], [12, 40], [12, 41], [12, 42], [12, 43], [13, 14], [13, 15], [13, 16], [13, 17], [13, 19], [13, 22], [13, 24], [13, 26], [13, 27], [13, 28], [13, 29], [13, 31], [13, 32], [13, 33], [13, 34], [13, 36], [13, 37], [13, 38], [13, 39], [13, 41], [13, 42], [14, 15], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [14, 36], [14, 38], [14, 39], [14, 41], [14, 42], [15, 16], [15, 18], [15, 19], [15, 22], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 34], [15, 35], [15, 36], [15, 37], [15, 38], [15, 40], [15, 41], [15, 42], [15, 43], [16, 17], [16, 18], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 33], [16, 35], [16, 37], [16, 38], [16, 39], [16, 40], [16, 42], [16, 43], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 30], [17, 31], [17, 32], [17, 37], [17, 38], [17, 39], [17, 40], [17, 43], [18, 21], [18, 22], [18, 23], [18, 24], [18, 26], [18, 27], [18, 29], [18, 30], [18, 33], [18, 34], [18, 35], [18, 37], [18, 39], [18, 40], [18, 41], [18, 42], [18, 43], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 26], [19, 30], [19, 32], [19, 33], [19, 34], [19, 35], [19, 38], [19, 39], [19, 41], [19, 42], [19, 43], [20, 21], [20, 23], [20, 24], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 34], [20, 35], [20, 37], [20, 38], [20, 39], [20, 40], [20, 41], [20, 42], [20, 43], [21, 22], [21, 24], [21, 25], [21, 26], [21, 27], [21, 31], [21, 32], [21, 33], [21, 34], [21, 37], [21, 38], [21, 41], [21, 42], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 30], [22, 32], [22, 33], [22, 34], [22, 35], [22, 36], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 43], [23, 25], [23, 26], [23, 28], [23, 32], [23, 33], [23, 34], [23, 35], [23, 36], [23, 37], [23, 38], [23, 39], [23, 41], [23, 42], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 36], [24, 37], [24, 38], [24, 41], [24, 43], [25, 26], [25, 28], [25, 30], [25, 31], [25, 33], [25, 34], [25, 35], [25, 36], [25, 37], [25, 38], [25, 39], [25, 40], [25, 41], [25, 42], [26, 28], [26, 29], [26, 30], [26, 31], [26, 33], [26, 34], [26, 35], [26, 36], [26, 39], [26, 40], [26, 41], [26, 42], [26, 43], [27, 28], [27, 29], [27, 31], [27, 32], [27, 33], [27, 35], [27, 37], [27, 38], [27, 39], [27, 41], [27, 43], [28, 29], [28, 30], [28, 31], [28, 32], [28, 36], [28, 37], [28, 39], [28, 40], [28, 42], [28, 43], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 35], [29, 36], [29, 37], [29, 39], [29, 41], [30, 32], [30, 33], [30, 34], [30, 35], [30, 36], [30, 37], [30, 39], [30, 40], [30, 41], [30, 42], [30, 43], [31, 32], [31, 33], [31, 35], [31, 36], [31, 37], [31, 38], [31, 39], [31, 40], [31, 42], [31, 43], [32, 33], [32, 34], [32, 36], [32, 37], [32, 39], [32, 40], [32, 42], [33, 34], [33, 35], [33, 36], [33, 37], [33, 38], [33, 39], [33, 41], [33, 42], [33, 43], [34, 38], [34, 39], [34, 40], [34, 42], [34, 43], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 42], [35, 43], [36, 37], [36, 38], [36, 39], [36, 40], [36, 41], [36, 42], [37, 38], [37, 39], [37, 40], [37, 41], [37, 42], [37, 43], [38, 39], [38, 40], [38, 42], [38, 43], [39, 40], [39, 41], [39, 42], [39, 43], [40, 41], [40, 43], [41, 42], [41, 43], [42, 43]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l5-s9/tests/run.py b/tasks/construct-rlve-maximum-clique-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l5-s9/tests/test.sh b/tasks/construct-rlve-maximum-clique-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-min-chromatic-number-l2-s5/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l2-s5/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-l2-s5/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ff7db39e5bc8c0302d3ed1741d05791e9d6e1b95 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 10, "k": 4, "edges": [[0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [1, 3], [1, 4], [1, 5], [1, 8], [1, 9], [2, 3], [2, 4], [2, 6], [2, 7], [2, 9], [3, 6], [3, 7], [3, 8], [3, 9], [4, 5], [4, 7], [4, 8], [4, 9], [5, 6], [5, 9], [6, 7], [7, 8], [7, 9]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l2-s5/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l2-s5/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-harmonious-coloring-l2-s8/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l2-s8/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ae2f4e29096ab72d3819ce4d23055c39c77daf29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "k": 5, "edges": [[1, 2], [1, 4], [1, 6], [2, 4], [2, 6], [3, 4], [5, 6]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l2-s8/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..52f9f53a06d73dc811df51453ff26a2ce10f0f34 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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' +{"colors": [0, 0, 1, 2, 3, 2, 4, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l2-s8/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l2-s8/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-l2-s8/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ae2f4e29096ab72d3819ce4d23055c39c77daf29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "k": 5, "edges": [[1, 2], [1, 4], [1, 6], [2, 4], [2, 6], [3, 4], [5, 6]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l2-s8/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l2-s8/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l6-s7/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l6-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l6-s7/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l6-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..039efc2a03481477c1bfabe795790720872e1fa3 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l6-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "k": 9, "edges": [[0, 5], [0, 10], [0, 13], [0, 14], [1, 4], [1, 13], [2, 4], [2, 7], [2, 10], [3, 7], [3, 10], [4, 9], [4, 11], [5, 14], [5, 17], [6, 13], [6, 15], [7, 8], [7, 9], [7, 10], [8, 11], [9, 10], [9, 13], [9, 15], [10, 14], [11, 12], [11, 15], [14, 17], [15, 17], [16, 17]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l6-s7/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l6-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a62be66efc30e50cf792700558e00c34488e0664 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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' +{"colors": [0, 1, 2, 1, 3, 4, 5, 6, 7, 4, 8, 0, 6, 2, 5, 1, 2, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l6-s7/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l6-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l6-s7/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-l6-s7/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l6-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..039efc2a03481477c1bfabe795790720872e1fa3 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l6-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "k": 9, "edges": [[0, 5], [0, 10], [0, 13], [0, 14], [1, 4], [1, 13], [2, 4], [2, 7], [2, 10], [3, 7], [3, 10], [4, 9], [4, 11], [5, 14], [5, 17], [6, 13], [6, 15], [7, 8], [7, 9], [7, 10], [8, 11], [9, 10], [9, 13], [9, 15], [10, 14], [11, 12], [11, 15], [14, 17], [15, 17], [16, 17]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l6-s7/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l6-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l6-s7/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l6-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-l4-s0/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-pairwise-sums-recovery-l4-s0/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cd64e5ad24b367769bb77b1f574648c04427ecbf --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "sums": [33, 32, 32, 43, 15, 22, 29, 16, 27, 37, 7, 38, 30, 23, 11, 28, 40, 36, 34, 26, 37, 20, 23, 24, 23, 31, 20, 40, 19, 31, 24, 6, 28, 44, 11, 38, 15, 19, 41, 35, 27, 43, 21, 28, 42, 21, 26, 39, 39, 33, 32, 35, 36, 27, 37, 35, 24, 45, 22, 29, 16, 25, 18, 25, 41, 38], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l4-s0/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ed14d612497f699d022461ee9cb59f3d18d16c84 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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' +{"numbers": [1, 5, 6, 10, 14, 15, 17, 18, 20, 21, 22, 23]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l4-s0/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s0/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-l4-s0/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cd64e5ad24b367769bb77b1f574648c04427ecbf --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "sums": [33, 32, 32, 43, 15, 22, 29, 16, 27, 37, 7, 38, 30, 23, 11, 28, 40, 36, 34, 26, 37, 20, 23, 24, 23, 31, 20, 40, 19, 31, 24, 6, 28, 44, 11, 38, 15, 19, 41, 35, 27, 43, 21, 28, 42, 21, 26, 39, 39, 33, 32, 35, 36, 27, 37, 35, 24, 45, 22, 29, 16, 25, 18, 25, 41, 38], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l4-s0/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-pairwise-sums-recovery-l4-s0/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-pan-solar-panels-l5-s2/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l5-s2/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..49948319000905a62a88f83199dca0c11e11208a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"A": 397903077, "B": 613586830, "C": 614063208, "D": 644386145, "target": 214795381, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l5-s2/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4d89e696b88dc761632f387bf96fe33404411d1c --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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' +{"X": 429590762, "Y": 644386143} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l5-s2/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l5-s2/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-l5-s2/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..49948319000905a62a88f83199dca0c11e11208a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"A": 397903077, "B": 613586830, "C": 614063208, "D": 644386145, "target": 214795381, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l5-s2/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l5-s2/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l5-s5/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l5-s5/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d7f3425b8c3fb68d8b0a44d0aa5cdb47a40b154e --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"A": 454397313, "B": 674798904, "C": 675015801, "D": 765269083, "target": 255089694, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l5-s5/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e2412f58710c29fceaba84f22b879f035c250b41 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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' +{"X": 510179388, "Y": 765269082} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l5-s5/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l5-s5/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-l5-s5/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d7f3425b8c3fb68d8b0a44d0aa5cdb47a40b154e --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"A": 454397313, "B": 674798904, "C": 675015801, "D": 765269083, "target": 255089694, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l5-s5/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l5-s5/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-l4-s3/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l4-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-polynomial-interpolation-l4-s3/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l4-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4c518e66d211fdbc4708c29acc58ae78810b1939 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l4-s3/environment/instance.json @@ -0,0 +1 @@ +{"X": [5, 8, 3, -9, 2, -7, 7, -6, -4, -5], "Y": [5612247, 339520293, 69303, -612899913, 2223, -59457177, 105316663, -14064729, -302103, -2524553], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l4-s3/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l4-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..06185b5fe16b76953b8516d51ee961fb3a3cfe31 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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' +{"coeffs": [-3, 5, 4, -3, -5, 2, -1, 2, 4, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l4-s3/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l4-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l4-s3/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-l4-s3/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l4-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4c518e66d211fdbc4708c29acc58ae78810b1939 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l4-s3/tests/instance.json @@ -0,0 +1 @@ +{"X": [5, 8, 3, -9, 2, -7, 7, -6, -4, -5], "Y": [5612247, 339520293, 69303, -612899913, 2223, -59457177, 105316663, -14064729, -302103, -2524553], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l4-s3/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l4-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-polynomial-interpolation-l4-s3/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l4-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-prefix-product-permutation-l4-s1/environment/Dockerfile b/tasks/construct-rlve-prefix-product-permutation-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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-rlve-prefix-product-permutation-l4-s1/environment/instance.json b/tasks/construct-rlve-prefix-product-permutation-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a3e920f1e387dc13ef64754a1bd06334d925523a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 457, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l4-s1/solution/solve.sh b/tasks/construct-rlve-prefix-product-permutation-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9c3b2b59ec645c0f1da2fdb27df7f16e6e6839aa --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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' +{"perm": [1, 2, 230, 306, 344, 184, 382, 197, 401, 255, 321, 375, 420, 212, 99, 62, 201, 243, 128, 434, 161, 371, 188, 160, 439, 129, 335, 238, 50, 395, 260, 60, 101, 278, 122, 223, 293, 211, 446, 376, 81, 380, 186, 373, 323, 326, 309, 283, 220, 29, 65, 234, 168, 70, 348, 350, 254, 450, 198, 32, 359, 16, 259, 429, 51, 226, 368, 192, 290, 54, 112, 104, 147, 145, 106, 196, 452, 185, 417, 82, 41, 80, 419, 447, 322, 415, 187, 437, 162, 191, 392, 227, 155, 173, 142, 179, 339, 246, 15, 398, 33, 182, 346, 72, 313, 75, 264, 253, 403, 349, 404, 71, 356, 183, 454, 307, 328, 126, 245, 362, 180, 35, 237, 432, 130, 118, 215, 19, 26, 125, 342, 308, 413, 324, 325, 414, 374, 448, 256, 218, 285, 95, 281, 311, 74, 354, 73, 315, 282, 412, 327, 343, 455, 231, 93, 287, 209, 295, 270, 24, 21, 89, 269, 301, 210, 422, 224, 53, 390, 193, 208, 303, 94, 318, 219, 411, 310, 316, 96, 121, 425, 102, 114, 6, 78, 43, 87, 23, 300, 296, 90, 68, 170, 252, 352, 76, 8, 59, 428, 396, 17, 217, 320, 449, 402, 351, 265, 171, 157, 165, 38, 14, 361, 340, 127, 441, 202, 140, 175, 49, 431, 336, 36, 167, 407, 66, 92, 305, 456, 3, 154, 367, 393, 52, 292, 423, 123, 28, 410, 284, 319, 257, 18, 332, 119, 98, 445, 421, 294, 302, 288, 194, 108, 57, 10, 139, 242, 442, 63, 31, 400, 451, 383, 107, 207, 289, 391, 369, 163, 159, 436, 372, 416, 381, 453, 345, 357, 34, 338, 363, 143, 149, 48, 240, 141, 365, 156, 251, 266, 69, 406, 235, 37, 249, 158, 190, 370, 438, 435, 189, 164, 250, 172, 366, 228, 4, 116, 132, 47, 177, 144, 386, 105, 385, 148, 178, 364, 174, 241, 203, 11, 85, 45, 134, 135, 46, 151, 117, 334, 433, 440, 244, 341, 329, 27, 222, 424, 279, 97, 214, 333, 131, 152, 5, 276, 103, 388, 55, 110, 56, 206, 195, 384, 146, 387, 113, 277, 426, 61, 444, 213, 120, 280, 317, 286, 304, 232, 67, 268, 297, 22, 272, 44, 137, 12, 40, 379, 418, 377, 42, 274, 7, 263, 353, 314, 312, 355, 347, 405, 169, 267, 91, 233, 408, 30, 200, 443, 100, 427, 261, 9, 205, 109, 111, 389, 291, 225, 394, 430, 239, 176, 150, 133, 136, 86, 273, 79, 378, 83, 13, 248, 166, 236, 337, 181, 358, 399, 199, 64, 409, 221, 124, 330, 20, 299, 271, 88, 298, 25, 331, 216, 258, 397, 360, 247, 39, 84, 138, 204, 58, 262, 77, 275, 115, 153, 229, 457]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-product-permutation-l4-s1/tests/check.py b/tasks/construct-rlve-prefix-product-permutation-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3d93850acd79cc0f8fff05cdbb0c63aabc484815 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-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(), 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-l4-s1/tests/instance.json b/tasks/construct-rlve-prefix-product-permutation-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a3e920f1e387dc13ef64754a1bd06334d925523a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 457, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l4-s1/tests/run.py b/tasks/construct-rlve-prefix-product-permutation-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-product-permutation-l4-s1/tests/test.sh b/tasks/construct-rlve-prefix-product-permutation-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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-rlve-prefix-sum-permutation-l1-s1/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l1-s1/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..46fdd5e61d1ce27c0f0f901ecb726eb3965be429 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l1-s1/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0ae16a59822818ad01310e674349c797c052c50c --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [20, 1, 18, 3, 16, 5, 14, 7, 12, 9, 10, 11, 8, 13, 6, 15, 4, 17, 2, 19]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l1-s1/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l1-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-l1-s1/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..46fdd5e61d1ce27c0f0f901ecb726eb3965be429 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l1-s1/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l1-s1/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l1-s6/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l1-s6/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4708db7e2714ff6cc9f5703ecabb7eee239cbc5c --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 16, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l1-s6/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a4c6d8b1c3b25aec8bb65ad19b046c9458c4625f --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [16, 1, 14, 3, 12, 5, 10, 7, 8, 9, 6, 11, 4, 13, 2, 15]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l1-s6/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l1-s6/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l1-s6/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4708db7e2714ff6cc9f5703ecabb7eee239cbc5c --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 16, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l1-s6/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l1-s6/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l1-s8/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l1-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-sum-permutation-l1-s8/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4b42dff77330828333bbafed1885266205aa917a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 30, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l1-s8/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e3b45963067e7ae8a7a5890a4fc8bff4137f2cbe --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l1-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [30, 1, 28, 3, 26, 5, 24, 7, 22, 9, 20, 11, 18, 13, 16, 15, 14, 17, 12, 19, 10, 21, 8, 23, 6, 25, 4, 27, 2, 29]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l1-s8/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l1-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-l1-s8/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4b42dff77330828333bbafed1885266205aa917a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 30, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l1-s8/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l1-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-sum-permutation-l1-s8/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l1-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-sum-permutation-l5-s0/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l5-s0/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..208c75cb32e250b204728b256a774845dad41752 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 8562, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l5-s0/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..68c60cdd3a2586f2cd4ef996b3412c7a1948c7cc --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [8562, 1, 8560, 3, 8558, 5, 8556, 7, 8554, 9, 8552, 11, 8550, 13, 8548, 15, 8546, 17, 8544, 19, 8542, 21, 8540, 23, 8538, 25, 8536, 27, 8534, 29, 8532, 31, 8530, 33, 8528, 35, 8526, 37, 8524, 39, 8522, 41, 8520, 43, 8518, 45, 8516, 47, 8514, 49, 8512, 51, 8510, 53, 8508, 55, 8506, 57, 8504, 59, 8502, 61, 8500, 63, 8498, 65, 8496, 67, 8494, 69, 8492, 71, 8490, 73, 8488, 75, 8486, 77, 8484, 79, 8482, 81, 8480, 83, 8478, 85, 8476, 87, 8474, 89, 8472, 91, 8470, 93, 8468, 95, 8466, 97, 8464, 99, 8462, 101, 8460, 103, 8458, 105, 8456, 107, 8454, 109, 8452, 111, 8450, 113, 8448, 115, 8446, 117, 8444, 119, 8442, 121, 8440, 123, 8438, 125, 8436, 127, 8434, 129, 8432, 131, 8430, 133, 8428, 135, 8426, 137, 8424, 139, 8422, 141, 8420, 143, 8418, 145, 8416, 147, 8414, 149, 8412, 151, 8410, 153, 8408, 155, 8406, 157, 8404, 159, 8402, 161, 8400, 163, 8398, 165, 8396, 167, 8394, 169, 8392, 171, 8390, 173, 8388, 175, 8386, 177, 8384, 179, 8382, 181, 8380, 183, 8378, 185, 8376, 187, 8374, 189, 8372, 191, 8370, 193, 8368, 195, 8366, 197, 8364, 199, 8362, 201, 8360, 203, 8358, 205, 8356, 207, 8354, 209, 8352, 211, 8350, 213, 8348, 215, 8346, 217, 8344, 219, 8342, 221, 8340, 223, 8338, 225, 8336, 227, 8334, 229, 8332, 231, 8330, 233, 8328, 235, 8326, 237, 8324, 239, 8322, 241, 8320, 243, 8318, 245, 8316, 247, 8314, 249, 8312, 251, 8310, 253, 8308, 255, 8306, 257, 8304, 259, 8302, 261, 8300, 263, 8298, 265, 8296, 267, 8294, 269, 8292, 271, 8290, 273, 8288, 275, 8286, 277, 8284, 279, 8282, 281, 8280, 283, 8278, 285, 8276, 287, 8274, 289, 8272, 291, 8270, 293, 8268, 295, 8266, 297, 8264, 299, 8262, 301, 8260, 303, 8258, 305, 8256, 307, 8254, 309, 8252, 311, 8250, 313, 8248, 315, 8246, 317, 8244, 319, 8242, 321, 8240, 323, 8238, 325, 8236, 327, 8234, 329, 8232, 331, 8230, 333, 8228, 335, 8226, 337, 8224, 339, 8222, 341, 8220, 343, 8218, 345, 8216, 347, 8214, 349, 8212, 351, 8210, 353, 8208, 355, 8206, 357, 8204, 359, 8202, 361, 8200, 363, 8198, 365, 8196, 367, 8194, 369, 8192, 371, 8190, 373, 8188, 375, 8186, 377, 8184, 379, 8182, 381, 8180, 383, 8178, 385, 8176, 387, 8174, 389, 8172, 391, 8170, 393, 8168, 395, 8166, 397, 8164, 399, 8162, 401, 8160, 403, 8158, 405, 8156, 407, 8154, 409, 8152, 411, 8150, 413, 8148, 415, 8146, 417, 8144, 419, 8142, 421, 8140, 423, 8138, 425, 8136, 427, 8134, 429, 8132, 431, 8130, 433, 8128, 435, 8126, 437, 8124, 439, 8122, 441, 8120, 443, 8118, 445, 8116, 447, 8114, 449, 8112, 451, 8110, 453, 8108, 455, 8106, 457, 8104, 459, 8102, 461, 8100, 463, 8098, 465, 8096, 467, 8094, 469, 8092, 471, 8090, 473, 8088, 475, 8086, 477, 8084, 479, 8082, 481, 8080, 483, 8078, 485, 8076, 487, 8074, 489, 8072, 491, 8070, 493, 8068, 495, 8066, 497, 8064, 499, 8062, 501, 8060, 503, 8058, 505, 8056, 507, 8054, 509, 8052, 511, 8050, 513, 8048, 515, 8046, 517, 8044, 519, 8042, 521, 8040, 523, 8038, 525, 8036, 527, 8034, 529, 8032, 531, 8030, 533, 8028, 535, 8026, 537, 8024, 539, 8022, 541, 8020, 543, 8018, 545, 8016, 547, 8014, 549, 8012, 551, 8010, 553, 8008, 555, 8006, 557, 8004, 559, 8002, 561, 8000, 563, 7998, 565, 7996, 567, 7994, 569, 7992, 571, 7990, 573, 7988, 575, 7986, 577, 7984, 579, 7982, 581, 7980, 583, 7978, 585, 7976, 587, 7974, 589, 7972, 591, 7970, 593, 7968, 595, 7966, 597, 7964, 599, 7962, 601, 7960, 603, 7958, 605, 7956, 607, 7954, 609, 7952, 611, 7950, 613, 7948, 615, 7946, 617, 7944, 619, 7942, 621, 7940, 623, 7938, 625, 7936, 627, 7934, 629, 7932, 631, 7930, 633, 7928, 635, 7926, 637, 7924, 639, 7922, 641, 7920, 643, 7918, 645, 7916, 647, 7914, 649, 7912, 651, 7910, 653, 7908, 655, 7906, 657, 7904, 659, 7902, 661, 7900, 663, 7898, 665, 7896, 667, 7894, 669, 7892, 671, 7890, 673, 7888, 675, 7886, 677, 7884, 679, 7882, 681, 7880, 683, 7878, 685, 7876, 687, 7874, 689, 7872, 691, 7870, 693, 7868, 695, 7866, 697, 7864, 699, 7862, 701, 7860, 703, 7858, 705, 7856, 707, 7854, 709, 7852, 711, 7850, 713, 7848, 715, 7846, 717, 7844, 719, 7842, 721, 7840, 723, 7838, 725, 7836, 727, 7834, 729, 7832, 731, 7830, 733, 7828, 735, 7826, 737, 7824, 739, 7822, 741, 7820, 743, 7818, 745, 7816, 747, 7814, 749, 7812, 751, 7810, 753, 7808, 755, 7806, 757, 7804, 759, 7802, 761, 7800, 763, 7798, 765, 7796, 767, 7794, 769, 7792, 771, 7790, 773, 7788, 775, 7786, 777, 7784, 779, 7782, 781, 7780, 783, 7778, 785, 7776, 787, 7774, 789, 7772, 791, 7770, 793, 7768, 795, 7766, 797, 7764, 799, 7762, 801, 7760, 803, 7758, 805, 7756, 807, 7754, 809, 7752, 811, 7750, 813, 7748, 815, 7746, 817, 7744, 819, 7742, 821, 7740, 823, 7738, 825, 7736, 827, 7734, 829, 7732, 831, 7730, 833, 7728, 835, 7726, 837, 7724, 839, 7722, 841, 7720, 843, 7718, 845, 7716, 847, 7714, 849, 7712, 851, 7710, 853, 7708, 855, 7706, 857, 7704, 859, 7702, 861, 7700, 863, 7698, 865, 7696, 867, 7694, 869, 7692, 871, 7690, 873, 7688, 875, 7686, 877, 7684, 879, 7682, 881, 7680, 883, 7678, 885, 7676, 887, 7674, 889, 7672, 891, 7670, 893, 7668, 895, 7666, 897, 7664, 899, 7662, 901, 7660, 903, 7658, 905, 7656, 907, 7654, 909, 7652, 911, 7650, 913, 7648, 915, 7646, 917, 7644, 919, 7642, 921, 7640, 923, 7638, 925, 7636, 927, 7634, 929, 7632, 931, 7630, 933, 7628, 935, 7626, 937, 7624, 939, 7622, 941, 7620, 943, 7618, 945, 7616, 947, 7614, 949, 7612, 951, 7610, 953, 7608, 955, 7606, 957, 7604, 959, 7602, 961, 7600, 963, 7598, 965, 7596, 967, 7594, 969, 7592, 971, 7590, 973, 7588, 975, 7586, 977, 7584, 979, 7582, 981, 7580, 983, 7578, 985, 7576, 987, 7574, 989, 7572, 991, 7570, 993, 7568, 995, 7566, 997, 7564, 999, 7562, 1001, 7560, 1003, 7558, 1005, 7556, 1007, 7554, 1009, 7552, 1011, 7550, 1013, 7548, 1015, 7546, 1017, 7544, 1019, 7542, 1021, 7540, 1023, 7538, 1025, 7536, 1027, 7534, 1029, 7532, 1031, 7530, 1033, 7528, 1035, 7526, 1037, 7524, 1039, 7522, 1041, 7520, 1043, 7518, 1045, 7516, 1047, 7514, 1049, 7512, 1051, 7510, 1053, 7508, 1055, 7506, 1057, 7504, 1059, 7502, 1061, 7500, 1063, 7498, 1065, 7496, 1067, 7494, 1069, 7492, 1071, 7490, 1073, 7488, 1075, 7486, 1077, 7484, 1079, 7482, 1081, 7480, 1083, 7478, 1085, 7476, 1087, 7474, 1089, 7472, 1091, 7470, 1093, 7468, 1095, 7466, 1097, 7464, 1099, 7462, 1101, 7460, 1103, 7458, 1105, 7456, 1107, 7454, 1109, 7452, 1111, 7450, 1113, 7448, 1115, 7446, 1117, 7444, 1119, 7442, 1121, 7440, 1123, 7438, 1125, 7436, 1127, 7434, 1129, 7432, 1131, 7430, 1133, 7428, 1135, 7426, 1137, 7424, 1139, 7422, 1141, 7420, 1143, 7418, 1145, 7416, 1147, 7414, 1149, 7412, 1151, 7410, 1153, 7408, 1155, 7406, 1157, 7404, 1159, 7402, 1161, 7400, 1163, 7398, 1165, 7396, 1167, 7394, 1169, 7392, 1171, 7390, 1173, 7388, 1175, 7386, 1177, 7384, 1179, 7382, 1181, 7380, 1183, 7378, 1185, 7376, 1187, 7374, 1189, 7372, 1191, 7370, 1193, 7368, 1195, 7366, 1197, 7364, 1199, 7362, 1201, 7360, 1203, 7358, 1205, 7356, 1207, 7354, 1209, 7352, 1211, 7350, 1213, 7348, 1215, 7346, 1217, 7344, 1219, 7342, 1221, 7340, 1223, 7338, 1225, 7336, 1227, 7334, 1229, 7332, 1231, 7330, 1233, 7328, 1235, 7326, 1237, 7324, 1239, 7322, 1241, 7320, 1243, 7318, 1245, 7316, 1247, 7314, 1249, 7312, 1251, 7310, 1253, 7308, 1255, 7306, 1257, 7304, 1259, 7302, 1261, 7300, 1263, 7298, 1265, 7296, 1267, 7294, 1269, 7292, 1271, 7290, 1273, 7288, 1275, 7286, 1277, 7284, 1279, 7282, 1281, 7280, 1283, 7278, 1285, 7276, 1287, 7274, 1289, 7272, 1291, 7270, 1293, 7268, 1295, 7266, 1297, 7264, 1299, 7262, 1301, 7260, 1303, 7258, 1305, 7256, 1307, 7254, 1309, 7252, 1311, 7250, 1313, 7248, 1315, 7246, 1317, 7244, 1319, 7242, 1321, 7240, 1323, 7238, 1325, 7236, 1327, 7234, 1329, 7232, 1331, 7230, 1333, 7228, 1335, 7226, 1337, 7224, 1339, 7222, 1341, 7220, 1343, 7218, 1345, 7216, 1347, 7214, 1349, 7212, 1351, 7210, 1353, 7208, 1355, 7206, 1357, 7204, 1359, 7202, 1361, 7200, 1363, 7198, 1365, 7196, 1367, 7194, 1369, 7192, 1371, 7190, 1373, 7188, 1375, 7186, 1377, 7184, 1379, 7182, 1381, 7180, 1383, 7178, 1385, 7176, 1387, 7174, 1389, 7172, 1391, 7170, 1393, 7168, 1395, 7166, 1397, 7164, 1399, 7162, 1401, 7160, 1403, 7158, 1405, 7156, 1407, 7154, 1409, 7152, 1411, 7150, 1413, 7148, 1415, 7146, 1417, 7144, 1419, 7142, 1421, 7140, 1423, 7138, 1425, 7136, 1427, 7134, 1429, 7132, 1431, 7130, 1433, 7128, 1435, 7126, 1437, 7124, 1439, 7122, 1441, 7120, 1443, 7118, 1445, 7116, 1447, 7114, 1449, 7112, 1451, 7110, 1453, 7108, 1455, 7106, 1457, 7104, 1459, 7102, 1461, 7100, 1463, 7098, 1465, 7096, 1467, 7094, 1469, 7092, 1471, 7090, 1473, 7088, 1475, 7086, 1477, 7084, 1479, 7082, 1481, 7080, 1483, 7078, 1485, 7076, 1487, 7074, 1489, 7072, 1491, 7070, 1493, 7068, 1495, 7066, 1497, 7064, 1499, 7062, 1501, 7060, 1503, 7058, 1505, 7056, 1507, 7054, 1509, 7052, 1511, 7050, 1513, 7048, 1515, 7046, 1517, 7044, 1519, 7042, 1521, 7040, 1523, 7038, 1525, 7036, 1527, 7034, 1529, 7032, 1531, 7030, 1533, 7028, 1535, 7026, 1537, 7024, 1539, 7022, 1541, 7020, 1543, 7018, 1545, 7016, 1547, 7014, 1549, 7012, 1551, 7010, 1553, 7008, 1555, 7006, 1557, 7004, 1559, 7002, 1561, 7000, 1563, 6998, 1565, 6996, 1567, 6994, 1569, 6992, 1571, 6990, 1573, 6988, 1575, 6986, 1577, 6984, 1579, 6982, 1581, 6980, 1583, 6978, 1585, 6976, 1587, 6974, 1589, 6972, 1591, 6970, 1593, 6968, 1595, 6966, 1597, 6964, 1599, 6962, 1601, 6960, 1603, 6958, 1605, 6956, 1607, 6954, 1609, 6952, 1611, 6950, 1613, 6948, 1615, 6946, 1617, 6944, 1619, 6942, 1621, 6940, 1623, 6938, 1625, 6936, 1627, 6934, 1629, 6932, 1631, 6930, 1633, 6928, 1635, 6926, 1637, 6924, 1639, 6922, 1641, 6920, 1643, 6918, 1645, 6916, 1647, 6914, 1649, 6912, 1651, 6910, 1653, 6908, 1655, 6906, 1657, 6904, 1659, 6902, 1661, 6900, 1663, 6898, 1665, 6896, 1667, 6894, 1669, 6892, 1671, 6890, 1673, 6888, 1675, 6886, 1677, 6884, 1679, 6882, 1681, 6880, 1683, 6878, 1685, 6876, 1687, 6874, 1689, 6872, 1691, 6870, 1693, 6868, 1695, 6866, 1697, 6864, 1699, 6862, 1701, 6860, 1703, 6858, 1705, 6856, 1707, 6854, 1709, 6852, 1711, 6850, 1713, 6848, 1715, 6846, 1717, 6844, 1719, 6842, 1721, 6840, 1723, 6838, 1725, 6836, 1727, 6834, 1729, 6832, 1731, 6830, 1733, 6828, 1735, 6826, 1737, 6824, 1739, 6822, 1741, 6820, 1743, 6818, 1745, 6816, 1747, 6814, 1749, 6812, 1751, 6810, 1753, 6808, 1755, 6806, 1757, 6804, 1759, 6802, 1761, 6800, 1763, 6798, 1765, 6796, 1767, 6794, 1769, 6792, 1771, 6790, 1773, 6788, 1775, 6786, 1777, 6784, 1779, 6782, 1781, 6780, 1783, 6778, 1785, 6776, 1787, 6774, 1789, 6772, 1791, 6770, 1793, 6768, 1795, 6766, 1797, 6764, 1799, 6762, 1801, 6760, 1803, 6758, 1805, 6756, 1807, 6754, 1809, 6752, 1811, 6750, 1813, 6748, 1815, 6746, 1817, 6744, 1819, 6742, 1821, 6740, 1823, 6738, 1825, 6736, 1827, 6734, 1829, 6732, 1831, 6730, 1833, 6728, 1835, 6726, 1837, 6724, 1839, 6722, 1841, 6720, 1843, 6718, 1845, 6716, 1847, 6714, 1849, 6712, 1851, 6710, 1853, 6708, 1855, 6706, 1857, 6704, 1859, 6702, 1861, 6700, 1863, 6698, 1865, 6696, 1867, 6694, 1869, 6692, 1871, 6690, 1873, 6688, 1875, 6686, 1877, 6684, 1879, 6682, 1881, 6680, 1883, 6678, 1885, 6676, 1887, 6674, 1889, 6672, 1891, 6670, 1893, 6668, 1895, 6666, 1897, 6664, 1899, 6662, 1901, 6660, 1903, 6658, 1905, 6656, 1907, 6654, 1909, 6652, 1911, 6650, 1913, 6648, 1915, 6646, 1917, 6644, 1919, 6642, 1921, 6640, 1923, 6638, 1925, 6636, 1927, 6634, 1929, 6632, 1931, 6630, 1933, 6628, 1935, 6626, 1937, 6624, 1939, 6622, 1941, 6620, 1943, 6618, 1945, 6616, 1947, 6614, 1949, 6612, 1951, 6610, 1953, 6608, 1955, 6606, 1957, 6604, 1959, 6602, 1961, 6600, 1963, 6598, 1965, 6596, 1967, 6594, 1969, 6592, 1971, 6590, 1973, 6588, 1975, 6586, 1977, 6584, 1979, 6582, 1981, 6580, 1983, 6578, 1985, 6576, 1987, 6574, 1989, 6572, 1991, 6570, 1993, 6568, 1995, 6566, 1997, 6564, 1999, 6562, 2001, 6560, 2003, 6558, 2005, 6556, 2007, 6554, 2009, 6552, 2011, 6550, 2013, 6548, 2015, 6546, 2017, 6544, 2019, 6542, 2021, 6540, 2023, 6538, 2025, 6536, 2027, 6534, 2029, 6532, 2031, 6530, 2033, 6528, 2035, 6526, 2037, 6524, 2039, 6522, 2041, 6520, 2043, 6518, 2045, 6516, 2047, 6514, 2049, 6512, 2051, 6510, 2053, 6508, 2055, 6506, 2057, 6504, 2059, 6502, 2061, 6500, 2063, 6498, 2065, 6496, 2067, 6494, 2069, 6492, 2071, 6490, 2073, 6488, 2075, 6486, 2077, 6484, 2079, 6482, 2081, 6480, 2083, 6478, 2085, 6476, 2087, 6474, 2089, 6472, 2091, 6470, 2093, 6468, 2095, 6466, 2097, 6464, 2099, 6462, 2101, 6460, 2103, 6458, 2105, 6456, 2107, 6454, 2109, 6452, 2111, 6450, 2113, 6448, 2115, 6446, 2117, 6444, 2119, 6442, 2121, 6440, 2123, 6438, 2125, 6436, 2127, 6434, 2129, 6432, 2131, 6430, 2133, 6428, 2135, 6426, 2137, 6424, 2139, 6422, 2141, 6420, 2143, 6418, 2145, 6416, 2147, 6414, 2149, 6412, 2151, 6410, 2153, 6408, 2155, 6406, 2157, 6404, 2159, 6402, 2161, 6400, 2163, 6398, 2165, 6396, 2167, 6394, 2169, 6392, 2171, 6390, 2173, 6388, 2175, 6386, 2177, 6384, 2179, 6382, 2181, 6380, 2183, 6378, 2185, 6376, 2187, 6374, 2189, 6372, 2191, 6370, 2193, 6368, 2195, 6366, 2197, 6364, 2199, 6362, 2201, 6360, 2203, 6358, 2205, 6356, 2207, 6354, 2209, 6352, 2211, 6350, 2213, 6348, 2215, 6346, 2217, 6344, 2219, 6342, 2221, 6340, 2223, 6338, 2225, 6336, 2227, 6334, 2229, 6332, 2231, 6330, 2233, 6328, 2235, 6326, 2237, 6324, 2239, 6322, 2241, 6320, 2243, 6318, 2245, 6316, 2247, 6314, 2249, 6312, 2251, 6310, 2253, 6308, 2255, 6306, 2257, 6304, 2259, 6302, 2261, 6300, 2263, 6298, 2265, 6296, 2267, 6294, 2269, 6292, 2271, 6290, 2273, 6288, 2275, 6286, 2277, 6284, 2279, 6282, 2281, 6280, 2283, 6278, 2285, 6276, 2287, 6274, 2289, 6272, 2291, 6270, 2293, 6268, 2295, 6266, 2297, 6264, 2299, 6262, 2301, 6260, 2303, 6258, 2305, 6256, 2307, 6254, 2309, 6252, 2311, 6250, 2313, 6248, 2315, 6246, 2317, 6244, 2319, 6242, 2321, 6240, 2323, 6238, 2325, 6236, 2327, 6234, 2329, 6232, 2331, 6230, 2333, 6228, 2335, 6226, 2337, 6224, 2339, 6222, 2341, 6220, 2343, 6218, 2345, 6216, 2347, 6214, 2349, 6212, 2351, 6210, 2353, 6208, 2355, 6206, 2357, 6204, 2359, 6202, 2361, 6200, 2363, 6198, 2365, 6196, 2367, 6194, 2369, 6192, 2371, 6190, 2373, 6188, 2375, 6186, 2377, 6184, 2379, 6182, 2381, 6180, 2383, 6178, 2385, 6176, 2387, 6174, 2389, 6172, 2391, 6170, 2393, 6168, 2395, 6166, 2397, 6164, 2399, 6162, 2401, 6160, 2403, 6158, 2405, 6156, 2407, 6154, 2409, 6152, 2411, 6150, 2413, 6148, 2415, 6146, 2417, 6144, 2419, 6142, 2421, 6140, 2423, 6138, 2425, 6136, 2427, 6134, 2429, 6132, 2431, 6130, 2433, 6128, 2435, 6126, 2437, 6124, 2439, 6122, 2441, 6120, 2443, 6118, 2445, 6116, 2447, 6114, 2449, 6112, 2451, 6110, 2453, 6108, 2455, 6106, 2457, 6104, 2459, 6102, 2461, 6100, 2463, 6098, 2465, 6096, 2467, 6094, 2469, 6092, 2471, 6090, 2473, 6088, 2475, 6086, 2477, 6084, 2479, 6082, 2481, 6080, 2483, 6078, 2485, 6076, 2487, 6074, 2489, 6072, 2491, 6070, 2493, 6068, 2495, 6066, 2497, 6064, 2499, 6062, 2501, 6060, 2503, 6058, 2505, 6056, 2507, 6054, 2509, 6052, 2511, 6050, 2513, 6048, 2515, 6046, 2517, 6044, 2519, 6042, 2521, 6040, 2523, 6038, 2525, 6036, 2527, 6034, 2529, 6032, 2531, 6030, 2533, 6028, 2535, 6026, 2537, 6024, 2539, 6022, 2541, 6020, 2543, 6018, 2545, 6016, 2547, 6014, 2549, 6012, 2551, 6010, 2553, 6008, 2555, 6006, 2557, 6004, 2559, 6002, 2561, 6000, 2563, 5998, 2565, 5996, 2567, 5994, 2569, 5992, 2571, 5990, 2573, 5988, 2575, 5986, 2577, 5984, 2579, 5982, 2581, 5980, 2583, 5978, 2585, 5976, 2587, 5974, 2589, 5972, 2591, 5970, 2593, 5968, 2595, 5966, 2597, 5964, 2599, 5962, 2601, 5960, 2603, 5958, 2605, 5956, 2607, 5954, 2609, 5952, 2611, 5950, 2613, 5948, 2615, 5946, 2617, 5944, 2619, 5942, 2621, 5940, 2623, 5938, 2625, 5936, 2627, 5934, 2629, 5932, 2631, 5930, 2633, 5928, 2635, 5926, 2637, 5924, 2639, 5922, 2641, 5920, 2643, 5918, 2645, 5916, 2647, 5914, 2649, 5912, 2651, 5910, 2653, 5908, 2655, 5906, 2657, 5904, 2659, 5902, 2661, 5900, 2663, 5898, 2665, 5896, 2667, 5894, 2669, 5892, 2671, 5890, 2673, 5888, 2675, 5886, 2677, 5884, 2679, 5882, 2681, 5880, 2683, 5878, 2685, 5876, 2687, 5874, 2689, 5872, 2691, 5870, 2693, 5868, 2695, 5866, 2697, 5864, 2699, 5862, 2701, 5860, 2703, 5858, 2705, 5856, 2707, 5854, 2709, 5852, 2711, 5850, 2713, 5848, 2715, 5846, 2717, 5844, 2719, 5842, 2721, 5840, 2723, 5838, 2725, 5836, 2727, 5834, 2729, 5832, 2731, 5830, 2733, 5828, 2735, 5826, 2737, 5824, 2739, 5822, 2741, 5820, 2743, 5818, 2745, 5816, 2747, 5814, 2749, 5812, 2751, 5810, 2753, 5808, 2755, 5806, 2757, 5804, 2759, 5802, 2761, 5800, 2763, 5798, 2765, 5796, 2767, 5794, 2769, 5792, 2771, 5790, 2773, 5788, 2775, 5786, 2777, 5784, 2779, 5782, 2781, 5780, 2783, 5778, 2785, 5776, 2787, 5774, 2789, 5772, 2791, 5770, 2793, 5768, 2795, 5766, 2797, 5764, 2799, 5762, 2801, 5760, 2803, 5758, 2805, 5756, 2807, 5754, 2809, 5752, 2811, 5750, 2813, 5748, 2815, 5746, 2817, 5744, 2819, 5742, 2821, 5740, 2823, 5738, 2825, 5736, 2827, 5734, 2829, 5732, 2831, 5730, 2833, 5728, 2835, 5726, 2837, 5724, 2839, 5722, 2841, 5720, 2843, 5718, 2845, 5716, 2847, 5714, 2849, 5712, 2851, 5710, 2853, 5708, 2855, 5706, 2857, 5704, 2859, 5702, 2861, 5700, 2863, 5698, 2865, 5696, 2867, 5694, 2869, 5692, 2871, 5690, 2873, 5688, 2875, 5686, 2877, 5684, 2879, 5682, 2881, 5680, 2883, 5678, 2885, 5676, 2887, 5674, 2889, 5672, 2891, 5670, 2893, 5668, 2895, 5666, 2897, 5664, 2899, 5662, 2901, 5660, 2903, 5658, 2905, 5656, 2907, 5654, 2909, 5652, 2911, 5650, 2913, 5648, 2915, 5646, 2917, 5644, 2919, 5642, 2921, 5640, 2923, 5638, 2925, 5636, 2927, 5634, 2929, 5632, 2931, 5630, 2933, 5628, 2935, 5626, 2937, 5624, 2939, 5622, 2941, 5620, 2943, 5618, 2945, 5616, 2947, 5614, 2949, 5612, 2951, 5610, 2953, 5608, 2955, 5606, 2957, 5604, 2959, 5602, 2961, 5600, 2963, 5598, 2965, 5596, 2967, 5594, 2969, 5592, 2971, 5590, 2973, 5588, 2975, 5586, 2977, 5584, 2979, 5582, 2981, 5580, 2983, 5578, 2985, 5576, 2987, 5574, 2989, 5572, 2991, 5570, 2993, 5568, 2995, 5566, 2997, 5564, 2999, 5562, 3001, 5560, 3003, 5558, 3005, 5556, 3007, 5554, 3009, 5552, 3011, 5550, 3013, 5548, 3015, 5546, 3017, 5544, 3019, 5542, 3021, 5540, 3023, 5538, 3025, 5536, 3027, 5534, 3029, 5532, 3031, 5530, 3033, 5528, 3035, 5526, 3037, 5524, 3039, 5522, 3041, 5520, 3043, 5518, 3045, 5516, 3047, 5514, 3049, 5512, 3051, 5510, 3053, 5508, 3055, 5506, 3057, 5504, 3059, 5502, 3061, 5500, 3063, 5498, 3065, 5496, 3067, 5494, 3069, 5492, 3071, 5490, 3073, 5488, 3075, 5486, 3077, 5484, 3079, 5482, 3081, 5480, 3083, 5478, 3085, 5476, 3087, 5474, 3089, 5472, 3091, 5470, 3093, 5468, 3095, 5466, 3097, 5464, 3099, 5462, 3101, 5460, 3103, 5458, 3105, 5456, 3107, 5454, 3109, 5452, 3111, 5450, 3113, 5448, 3115, 5446, 3117, 5444, 3119, 5442, 3121, 5440, 3123, 5438, 3125, 5436, 3127, 5434, 3129, 5432, 3131, 5430, 3133, 5428, 3135, 5426, 3137, 5424, 3139, 5422, 3141, 5420, 3143, 5418, 3145, 5416, 3147, 5414, 3149, 5412, 3151, 5410, 3153, 5408, 3155, 5406, 3157, 5404, 3159, 5402, 3161, 5400, 3163, 5398, 3165, 5396, 3167, 5394, 3169, 5392, 3171, 5390, 3173, 5388, 3175, 5386, 3177, 5384, 3179, 5382, 3181, 5380, 3183, 5378, 3185, 5376, 3187, 5374, 3189, 5372, 3191, 5370, 3193, 5368, 3195, 5366, 3197, 5364, 3199, 5362, 3201, 5360, 3203, 5358, 3205, 5356, 3207, 5354, 3209, 5352, 3211, 5350, 3213, 5348, 3215, 5346, 3217, 5344, 3219, 5342, 3221, 5340, 3223, 5338, 3225, 5336, 3227, 5334, 3229, 5332, 3231, 5330, 3233, 5328, 3235, 5326, 3237, 5324, 3239, 5322, 3241, 5320, 3243, 5318, 3245, 5316, 3247, 5314, 3249, 5312, 3251, 5310, 3253, 5308, 3255, 5306, 3257, 5304, 3259, 5302, 3261, 5300, 3263, 5298, 3265, 5296, 3267, 5294, 3269, 5292, 3271, 5290, 3273, 5288, 3275, 5286, 3277, 5284, 3279, 5282, 3281, 5280, 3283, 5278, 3285, 5276, 3287, 5274, 3289, 5272, 3291, 5270, 3293, 5268, 3295, 5266, 3297, 5264, 3299, 5262, 3301, 5260, 3303, 5258, 3305, 5256, 3307, 5254, 3309, 5252, 3311, 5250, 3313, 5248, 3315, 5246, 3317, 5244, 3319, 5242, 3321, 5240, 3323, 5238, 3325, 5236, 3327, 5234, 3329, 5232, 3331, 5230, 3333, 5228, 3335, 5226, 3337, 5224, 3339, 5222, 3341, 5220, 3343, 5218, 3345, 5216, 3347, 5214, 3349, 5212, 3351, 5210, 3353, 5208, 3355, 5206, 3357, 5204, 3359, 5202, 3361, 5200, 3363, 5198, 3365, 5196, 3367, 5194, 3369, 5192, 3371, 5190, 3373, 5188, 3375, 5186, 3377, 5184, 3379, 5182, 3381, 5180, 3383, 5178, 3385, 5176, 3387, 5174, 3389, 5172, 3391, 5170, 3393, 5168, 3395, 5166, 3397, 5164, 3399, 5162, 3401, 5160, 3403, 5158, 3405, 5156, 3407, 5154, 3409, 5152, 3411, 5150, 3413, 5148, 3415, 5146, 3417, 5144, 3419, 5142, 3421, 5140, 3423, 5138, 3425, 5136, 3427, 5134, 3429, 5132, 3431, 5130, 3433, 5128, 3435, 5126, 3437, 5124, 3439, 5122, 3441, 5120, 3443, 5118, 3445, 5116, 3447, 5114, 3449, 5112, 3451, 5110, 3453, 5108, 3455, 5106, 3457, 5104, 3459, 5102, 3461, 5100, 3463, 5098, 3465, 5096, 3467, 5094, 3469, 5092, 3471, 5090, 3473, 5088, 3475, 5086, 3477, 5084, 3479, 5082, 3481, 5080, 3483, 5078, 3485, 5076, 3487, 5074, 3489, 5072, 3491, 5070, 3493, 5068, 3495, 5066, 3497, 5064, 3499, 5062, 3501, 5060, 3503, 5058, 3505, 5056, 3507, 5054, 3509, 5052, 3511, 5050, 3513, 5048, 3515, 5046, 3517, 5044, 3519, 5042, 3521, 5040, 3523, 5038, 3525, 5036, 3527, 5034, 3529, 5032, 3531, 5030, 3533, 5028, 3535, 5026, 3537, 5024, 3539, 5022, 3541, 5020, 3543, 5018, 3545, 5016, 3547, 5014, 3549, 5012, 3551, 5010, 3553, 5008, 3555, 5006, 3557, 5004, 3559, 5002, 3561, 5000, 3563, 4998, 3565, 4996, 3567, 4994, 3569, 4992, 3571, 4990, 3573, 4988, 3575, 4986, 3577, 4984, 3579, 4982, 3581, 4980, 3583, 4978, 3585, 4976, 3587, 4974, 3589, 4972, 3591, 4970, 3593, 4968, 3595, 4966, 3597, 4964, 3599, 4962, 3601, 4960, 3603, 4958, 3605, 4956, 3607, 4954, 3609, 4952, 3611, 4950, 3613, 4948, 3615, 4946, 3617, 4944, 3619, 4942, 3621, 4940, 3623, 4938, 3625, 4936, 3627, 4934, 3629, 4932, 3631, 4930, 3633, 4928, 3635, 4926, 3637, 4924, 3639, 4922, 3641, 4920, 3643, 4918, 3645, 4916, 3647, 4914, 3649, 4912, 3651, 4910, 3653, 4908, 3655, 4906, 3657, 4904, 3659, 4902, 3661, 4900, 3663, 4898, 3665, 4896, 3667, 4894, 3669, 4892, 3671, 4890, 3673, 4888, 3675, 4886, 3677, 4884, 3679, 4882, 3681, 4880, 3683, 4878, 3685, 4876, 3687, 4874, 3689, 4872, 3691, 4870, 3693, 4868, 3695, 4866, 3697, 4864, 3699, 4862, 3701, 4860, 3703, 4858, 3705, 4856, 3707, 4854, 3709, 4852, 3711, 4850, 3713, 4848, 3715, 4846, 3717, 4844, 3719, 4842, 3721, 4840, 3723, 4838, 3725, 4836, 3727, 4834, 3729, 4832, 3731, 4830, 3733, 4828, 3735, 4826, 3737, 4824, 3739, 4822, 3741, 4820, 3743, 4818, 3745, 4816, 3747, 4814, 3749, 4812, 3751, 4810, 3753, 4808, 3755, 4806, 3757, 4804, 3759, 4802, 3761, 4800, 3763, 4798, 3765, 4796, 3767, 4794, 3769, 4792, 3771, 4790, 3773, 4788, 3775, 4786, 3777, 4784, 3779, 4782, 3781, 4780, 3783, 4778, 3785, 4776, 3787, 4774, 3789, 4772, 3791, 4770, 3793, 4768, 3795, 4766, 3797, 4764, 3799, 4762, 3801, 4760, 3803, 4758, 3805, 4756, 3807, 4754, 3809, 4752, 3811, 4750, 3813, 4748, 3815, 4746, 3817, 4744, 3819, 4742, 3821, 4740, 3823, 4738, 3825, 4736, 3827, 4734, 3829, 4732, 3831, 4730, 3833, 4728, 3835, 4726, 3837, 4724, 3839, 4722, 3841, 4720, 3843, 4718, 3845, 4716, 3847, 4714, 3849, 4712, 3851, 4710, 3853, 4708, 3855, 4706, 3857, 4704, 3859, 4702, 3861, 4700, 3863, 4698, 3865, 4696, 3867, 4694, 3869, 4692, 3871, 4690, 3873, 4688, 3875, 4686, 3877, 4684, 3879, 4682, 3881, 4680, 3883, 4678, 3885, 4676, 3887, 4674, 3889, 4672, 3891, 4670, 3893, 4668, 3895, 4666, 3897, 4664, 3899, 4662, 3901, 4660, 3903, 4658, 3905, 4656, 3907, 4654, 3909, 4652, 3911, 4650, 3913, 4648, 3915, 4646, 3917, 4644, 3919, 4642, 3921, 4640, 3923, 4638, 3925, 4636, 3927, 4634, 3929, 4632, 3931, 4630, 3933, 4628, 3935, 4626, 3937, 4624, 3939, 4622, 3941, 4620, 3943, 4618, 3945, 4616, 3947, 4614, 3949, 4612, 3951, 4610, 3953, 4608, 3955, 4606, 3957, 4604, 3959, 4602, 3961, 4600, 3963, 4598, 3965, 4596, 3967, 4594, 3969, 4592, 3971, 4590, 3973, 4588, 3975, 4586, 3977, 4584, 3979, 4582, 3981, 4580, 3983, 4578, 3985, 4576, 3987, 4574, 3989, 4572, 3991, 4570, 3993, 4568, 3995, 4566, 3997, 4564, 3999, 4562, 4001, 4560, 4003, 4558, 4005, 4556, 4007, 4554, 4009, 4552, 4011, 4550, 4013, 4548, 4015, 4546, 4017, 4544, 4019, 4542, 4021, 4540, 4023, 4538, 4025, 4536, 4027, 4534, 4029, 4532, 4031, 4530, 4033, 4528, 4035, 4526, 4037, 4524, 4039, 4522, 4041, 4520, 4043, 4518, 4045, 4516, 4047, 4514, 4049, 4512, 4051, 4510, 4053, 4508, 4055, 4506, 4057, 4504, 4059, 4502, 4061, 4500, 4063, 4498, 4065, 4496, 4067, 4494, 4069, 4492, 4071, 4490, 4073, 4488, 4075, 4486, 4077, 4484, 4079, 4482, 4081, 4480, 4083, 4478, 4085, 4476, 4087, 4474, 4089, 4472, 4091, 4470, 4093, 4468, 4095, 4466, 4097, 4464, 4099, 4462, 4101, 4460, 4103, 4458, 4105, 4456, 4107, 4454, 4109, 4452, 4111, 4450, 4113, 4448, 4115, 4446, 4117, 4444, 4119, 4442, 4121, 4440, 4123, 4438, 4125, 4436, 4127, 4434, 4129, 4432, 4131, 4430, 4133, 4428, 4135, 4426, 4137, 4424, 4139, 4422, 4141, 4420, 4143, 4418, 4145, 4416, 4147, 4414, 4149, 4412, 4151, 4410, 4153, 4408, 4155, 4406, 4157, 4404, 4159, 4402, 4161, 4400, 4163, 4398, 4165, 4396, 4167, 4394, 4169, 4392, 4171, 4390, 4173, 4388, 4175, 4386, 4177, 4384, 4179, 4382, 4181, 4380, 4183, 4378, 4185, 4376, 4187, 4374, 4189, 4372, 4191, 4370, 4193, 4368, 4195, 4366, 4197, 4364, 4199, 4362, 4201, 4360, 4203, 4358, 4205, 4356, 4207, 4354, 4209, 4352, 4211, 4350, 4213, 4348, 4215, 4346, 4217, 4344, 4219, 4342, 4221, 4340, 4223, 4338, 4225, 4336, 4227, 4334, 4229, 4332, 4231, 4330, 4233, 4328, 4235, 4326, 4237, 4324, 4239, 4322, 4241, 4320, 4243, 4318, 4245, 4316, 4247, 4314, 4249, 4312, 4251, 4310, 4253, 4308, 4255, 4306, 4257, 4304, 4259, 4302, 4261, 4300, 4263, 4298, 4265, 4296, 4267, 4294, 4269, 4292, 4271, 4290, 4273, 4288, 4275, 4286, 4277, 4284, 4279, 4282, 4281, 4280, 4283, 4278, 4285, 4276, 4287, 4274, 4289, 4272, 4291, 4270, 4293, 4268, 4295, 4266, 4297, 4264, 4299, 4262, 4301, 4260, 4303, 4258, 4305, 4256, 4307, 4254, 4309, 4252, 4311, 4250, 4313, 4248, 4315, 4246, 4317, 4244, 4319, 4242, 4321, 4240, 4323, 4238, 4325, 4236, 4327, 4234, 4329, 4232, 4331, 4230, 4333, 4228, 4335, 4226, 4337, 4224, 4339, 4222, 4341, 4220, 4343, 4218, 4345, 4216, 4347, 4214, 4349, 4212, 4351, 4210, 4353, 4208, 4355, 4206, 4357, 4204, 4359, 4202, 4361, 4200, 4363, 4198, 4365, 4196, 4367, 4194, 4369, 4192, 4371, 4190, 4373, 4188, 4375, 4186, 4377, 4184, 4379, 4182, 4381, 4180, 4383, 4178, 4385, 4176, 4387, 4174, 4389, 4172, 4391, 4170, 4393, 4168, 4395, 4166, 4397, 4164, 4399, 4162, 4401, 4160, 4403, 4158, 4405, 4156, 4407, 4154, 4409, 4152, 4411, 4150, 4413, 4148, 4415, 4146, 4417, 4144, 4419, 4142, 4421, 4140, 4423, 4138, 4425, 4136, 4427, 4134, 4429, 4132, 4431, 4130, 4433, 4128, 4435, 4126, 4437, 4124, 4439, 4122, 4441, 4120, 4443, 4118, 4445, 4116, 4447, 4114, 4449, 4112, 4451, 4110, 4453, 4108, 4455, 4106, 4457, 4104, 4459, 4102, 4461, 4100, 4463, 4098, 4465, 4096, 4467, 4094, 4469, 4092, 4471, 4090, 4473, 4088, 4475, 4086, 4477, 4084, 4479, 4082, 4481, 4080, 4483, 4078, 4485, 4076, 4487, 4074, 4489, 4072, 4491, 4070, 4493, 4068, 4495, 4066, 4497, 4064, 4499, 4062, 4501, 4060, 4503, 4058, 4505, 4056, 4507, 4054, 4509, 4052, 4511, 4050, 4513, 4048, 4515, 4046, 4517, 4044, 4519, 4042, 4521, 4040, 4523, 4038, 4525, 4036, 4527, 4034, 4529, 4032, 4531, 4030, 4533, 4028, 4535, 4026, 4537, 4024, 4539, 4022, 4541, 4020, 4543, 4018, 4545, 4016, 4547, 4014, 4549, 4012, 4551, 4010, 4553, 4008, 4555, 4006, 4557, 4004, 4559, 4002, 4561, 4000, 4563, 3998, 4565, 3996, 4567, 3994, 4569, 3992, 4571, 3990, 4573, 3988, 4575, 3986, 4577, 3984, 4579, 3982, 4581, 3980, 4583, 3978, 4585, 3976, 4587, 3974, 4589, 3972, 4591, 3970, 4593, 3968, 4595, 3966, 4597, 3964, 4599, 3962, 4601, 3960, 4603, 3958, 4605, 3956, 4607, 3954, 4609, 3952, 4611, 3950, 4613, 3948, 4615, 3946, 4617, 3944, 4619, 3942, 4621, 3940, 4623, 3938, 4625, 3936, 4627, 3934, 4629, 3932, 4631, 3930, 4633, 3928, 4635, 3926, 4637, 3924, 4639, 3922, 4641, 3920, 4643, 3918, 4645, 3916, 4647, 3914, 4649, 3912, 4651, 3910, 4653, 3908, 4655, 3906, 4657, 3904, 4659, 3902, 4661, 3900, 4663, 3898, 4665, 3896, 4667, 3894, 4669, 3892, 4671, 3890, 4673, 3888, 4675, 3886, 4677, 3884, 4679, 3882, 4681, 3880, 4683, 3878, 4685, 3876, 4687, 3874, 4689, 3872, 4691, 3870, 4693, 3868, 4695, 3866, 4697, 3864, 4699, 3862, 4701, 3860, 4703, 3858, 4705, 3856, 4707, 3854, 4709, 3852, 4711, 3850, 4713, 3848, 4715, 3846, 4717, 3844, 4719, 3842, 4721, 3840, 4723, 3838, 4725, 3836, 4727, 3834, 4729, 3832, 4731, 3830, 4733, 3828, 4735, 3826, 4737, 3824, 4739, 3822, 4741, 3820, 4743, 3818, 4745, 3816, 4747, 3814, 4749, 3812, 4751, 3810, 4753, 3808, 4755, 3806, 4757, 3804, 4759, 3802, 4761, 3800, 4763, 3798, 4765, 3796, 4767, 3794, 4769, 3792, 4771, 3790, 4773, 3788, 4775, 3786, 4777, 3784, 4779, 3782, 4781, 3780, 4783, 3778, 4785, 3776, 4787, 3774, 4789, 3772, 4791, 3770, 4793, 3768, 4795, 3766, 4797, 3764, 4799, 3762, 4801, 3760, 4803, 3758, 4805, 3756, 4807, 3754, 4809, 3752, 4811, 3750, 4813, 3748, 4815, 3746, 4817, 3744, 4819, 3742, 4821, 3740, 4823, 3738, 4825, 3736, 4827, 3734, 4829, 3732, 4831, 3730, 4833, 3728, 4835, 3726, 4837, 3724, 4839, 3722, 4841, 3720, 4843, 3718, 4845, 3716, 4847, 3714, 4849, 3712, 4851, 3710, 4853, 3708, 4855, 3706, 4857, 3704, 4859, 3702, 4861, 3700, 4863, 3698, 4865, 3696, 4867, 3694, 4869, 3692, 4871, 3690, 4873, 3688, 4875, 3686, 4877, 3684, 4879, 3682, 4881, 3680, 4883, 3678, 4885, 3676, 4887, 3674, 4889, 3672, 4891, 3670, 4893, 3668, 4895, 3666, 4897, 3664, 4899, 3662, 4901, 3660, 4903, 3658, 4905, 3656, 4907, 3654, 4909, 3652, 4911, 3650, 4913, 3648, 4915, 3646, 4917, 3644, 4919, 3642, 4921, 3640, 4923, 3638, 4925, 3636, 4927, 3634, 4929, 3632, 4931, 3630, 4933, 3628, 4935, 3626, 4937, 3624, 4939, 3622, 4941, 3620, 4943, 3618, 4945, 3616, 4947, 3614, 4949, 3612, 4951, 3610, 4953, 3608, 4955, 3606, 4957, 3604, 4959, 3602, 4961, 3600, 4963, 3598, 4965, 3596, 4967, 3594, 4969, 3592, 4971, 3590, 4973, 3588, 4975, 3586, 4977, 3584, 4979, 3582, 4981, 3580, 4983, 3578, 4985, 3576, 4987, 3574, 4989, 3572, 4991, 3570, 4993, 3568, 4995, 3566, 4997, 3564, 4999, 3562, 5001, 3560, 5003, 3558, 5005, 3556, 5007, 3554, 5009, 3552, 5011, 3550, 5013, 3548, 5015, 3546, 5017, 3544, 5019, 3542, 5021, 3540, 5023, 3538, 5025, 3536, 5027, 3534, 5029, 3532, 5031, 3530, 5033, 3528, 5035, 3526, 5037, 3524, 5039, 3522, 5041, 3520, 5043, 3518, 5045, 3516, 5047, 3514, 5049, 3512, 5051, 3510, 5053, 3508, 5055, 3506, 5057, 3504, 5059, 3502, 5061, 3500, 5063, 3498, 5065, 3496, 5067, 3494, 5069, 3492, 5071, 3490, 5073, 3488, 5075, 3486, 5077, 3484, 5079, 3482, 5081, 3480, 5083, 3478, 5085, 3476, 5087, 3474, 5089, 3472, 5091, 3470, 5093, 3468, 5095, 3466, 5097, 3464, 5099, 3462, 5101, 3460, 5103, 3458, 5105, 3456, 5107, 3454, 5109, 3452, 5111, 3450, 5113, 3448, 5115, 3446, 5117, 3444, 5119, 3442, 5121, 3440, 5123, 3438, 5125, 3436, 5127, 3434, 5129, 3432, 5131, 3430, 5133, 3428, 5135, 3426, 5137, 3424, 5139, 3422, 5141, 3420, 5143, 3418, 5145, 3416, 5147, 3414, 5149, 3412, 5151, 3410, 5153, 3408, 5155, 3406, 5157, 3404, 5159, 3402, 5161, 3400, 5163, 3398, 5165, 3396, 5167, 3394, 5169, 3392, 5171, 3390, 5173, 3388, 5175, 3386, 5177, 3384, 5179, 3382, 5181, 3380, 5183, 3378, 5185, 3376, 5187, 3374, 5189, 3372, 5191, 3370, 5193, 3368, 5195, 3366, 5197, 3364, 5199, 3362, 5201, 3360, 5203, 3358, 5205, 3356, 5207, 3354, 5209, 3352, 5211, 3350, 5213, 3348, 5215, 3346, 5217, 3344, 5219, 3342, 5221, 3340, 5223, 3338, 5225, 3336, 5227, 3334, 5229, 3332, 5231, 3330, 5233, 3328, 5235, 3326, 5237, 3324, 5239, 3322, 5241, 3320, 5243, 3318, 5245, 3316, 5247, 3314, 5249, 3312, 5251, 3310, 5253, 3308, 5255, 3306, 5257, 3304, 5259, 3302, 5261, 3300, 5263, 3298, 5265, 3296, 5267, 3294, 5269, 3292, 5271, 3290, 5273, 3288, 5275, 3286, 5277, 3284, 5279, 3282, 5281, 3280, 5283, 3278, 5285, 3276, 5287, 3274, 5289, 3272, 5291, 3270, 5293, 3268, 5295, 3266, 5297, 3264, 5299, 3262, 5301, 3260, 5303, 3258, 5305, 3256, 5307, 3254, 5309, 3252, 5311, 3250, 5313, 3248, 5315, 3246, 5317, 3244, 5319, 3242, 5321, 3240, 5323, 3238, 5325, 3236, 5327, 3234, 5329, 3232, 5331, 3230, 5333, 3228, 5335, 3226, 5337, 3224, 5339, 3222, 5341, 3220, 5343, 3218, 5345, 3216, 5347, 3214, 5349, 3212, 5351, 3210, 5353, 3208, 5355, 3206, 5357, 3204, 5359, 3202, 5361, 3200, 5363, 3198, 5365, 3196, 5367, 3194, 5369, 3192, 5371, 3190, 5373, 3188, 5375, 3186, 5377, 3184, 5379, 3182, 5381, 3180, 5383, 3178, 5385, 3176, 5387, 3174, 5389, 3172, 5391, 3170, 5393, 3168, 5395, 3166, 5397, 3164, 5399, 3162, 5401, 3160, 5403, 3158, 5405, 3156, 5407, 3154, 5409, 3152, 5411, 3150, 5413, 3148, 5415, 3146, 5417, 3144, 5419, 3142, 5421, 3140, 5423, 3138, 5425, 3136, 5427, 3134, 5429, 3132, 5431, 3130, 5433, 3128, 5435, 3126, 5437, 3124, 5439, 3122, 5441, 3120, 5443, 3118, 5445, 3116, 5447, 3114, 5449, 3112, 5451, 3110, 5453, 3108, 5455, 3106, 5457, 3104, 5459, 3102, 5461, 3100, 5463, 3098, 5465, 3096, 5467, 3094, 5469, 3092, 5471, 3090, 5473, 3088, 5475, 3086, 5477, 3084, 5479, 3082, 5481, 3080, 5483, 3078, 5485, 3076, 5487, 3074, 5489, 3072, 5491, 3070, 5493, 3068, 5495, 3066, 5497, 3064, 5499, 3062, 5501, 3060, 5503, 3058, 5505, 3056, 5507, 3054, 5509, 3052, 5511, 3050, 5513, 3048, 5515, 3046, 5517, 3044, 5519, 3042, 5521, 3040, 5523, 3038, 5525, 3036, 5527, 3034, 5529, 3032, 5531, 3030, 5533, 3028, 5535, 3026, 5537, 3024, 5539, 3022, 5541, 3020, 5543, 3018, 5545, 3016, 5547, 3014, 5549, 3012, 5551, 3010, 5553, 3008, 5555, 3006, 5557, 3004, 5559, 3002, 5561, 3000, 5563, 2998, 5565, 2996, 5567, 2994, 5569, 2992, 5571, 2990, 5573, 2988, 5575, 2986, 5577, 2984, 5579, 2982, 5581, 2980, 5583, 2978, 5585, 2976, 5587, 2974, 5589, 2972, 5591, 2970, 5593, 2968, 5595, 2966, 5597, 2964, 5599, 2962, 5601, 2960, 5603, 2958, 5605, 2956, 5607, 2954, 5609, 2952, 5611, 2950, 5613, 2948, 5615, 2946, 5617, 2944, 5619, 2942, 5621, 2940, 5623, 2938, 5625, 2936, 5627, 2934, 5629, 2932, 5631, 2930, 5633, 2928, 5635, 2926, 5637, 2924, 5639, 2922, 5641, 2920, 5643, 2918, 5645, 2916, 5647, 2914, 5649, 2912, 5651, 2910, 5653, 2908, 5655, 2906, 5657, 2904, 5659, 2902, 5661, 2900, 5663, 2898, 5665, 2896, 5667, 2894, 5669, 2892, 5671, 2890, 5673, 2888, 5675, 2886, 5677, 2884, 5679, 2882, 5681, 2880, 5683, 2878, 5685, 2876, 5687, 2874, 5689, 2872, 5691, 2870, 5693, 2868, 5695, 2866, 5697, 2864, 5699, 2862, 5701, 2860, 5703, 2858, 5705, 2856, 5707, 2854, 5709, 2852, 5711, 2850, 5713, 2848, 5715, 2846, 5717, 2844, 5719, 2842, 5721, 2840, 5723, 2838, 5725, 2836, 5727, 2834, 5729, 2832, 5731, 2830, 5733, 2828, 5735, 2826, 5737, 2824, 5739, 2822, 5741, 2820, 5743, 2818, 5745, 2816, 5747, 2814, 5749, 2812, 5751, 2810, 5753, 2808, 5755, 2806, 5757, 2804, 5759, 2802, 5761, 2800, 5763, 2798, 5765, 2796, 5767, 2794, 5769, 2792, 5771, 2790, 5773, 2788, 5775, 2786, 5777, 2784, 5779, 2782, 5781, 2780, 5783, 2778, 5785, 2776, 5787, 2774, 5789, 2772, 5791, 2770, 5793, 2768, 5795, 2766, 5797, 2764, 5799, 2762, 5801, 2760, 5803, 2758, 5805, 2756, 5807, 2754, 5809, 2752, 5811, 2750, 5813, 2748, 5815, 2746, 5817, 2744, 5819, 2742, 5821, 2740, 5823, 2738, 5825, 2736, 5827, 2734, 5829, 2732, 5831, 2730, 5833, 2728, 5835, 2726, 5837, 2724, 5839, 2722, 5841, 2720, 5843, 2718, 5845, 2716, 5847, 2714, 5849, 2712, 5851, 2710, 5853, 2708, 5855, 2706, 5857, 2704, 5859, 2702, 5861, 2700, 5863, 2698, 5865, 2696, 5867, 2694, 5869, 2692, 5871, 2690, 5873, 2688, 5875, 2686, 5877, 2684, 5879, 2682, 5881, 2680, 5883, 2678, 5885, 2676, 5887, 2674, 5889, 2672, 5891, 2670, 5893, 2668, 5895, 2666, 5897, 2664, 5899, 2662, 5901, 2660, 5903, 2658, 5905, 2656, 5907, 2654, 5909, 2652, 5911, 2650, 5913, 2648, 5915, 2646, 5917, 2644, 5919, 2642, 5921, 2640, 5923, 2638, 5925, 2636, 5927, 2634, 5929, 2632, 5931, 2630, 5933, 2628, 5935, 2626, 5937, 2624, 5939, 2622, 5941, 2620, 5943, 2618, 5945, 2616, 5947, 2614, 5949, 2612, 5951, 2610, 5953, 2608, 5955, 2606, 5957, 2604, 5959, 2602, 5961, 2600, 5963, 2598, 5965, 2596, 5967, 2594, 5969, 2592, 5971, 2590, 5973, 2588, 5975, 2586, 5977, 2584, 5979, 2582, 5981, 2580, 5983, 2578, 5985, 2576, 5987, 2574, 5989, 2572, 5991, 2570, 5993, 2568, 5995, 2566, 5997, 2564, 5999, 2562, 6001, 2560, 6003, 2558, 6005, 2556, 6007, 2554, 6009, 2552, 6011, 2550, 6013, 2548, 6015, 2546, 6017, 2544, 6019, 2542, 6021, 2540, 6023, 2538, 6025, 2536, 6027, 2534, 6029, 2532, 6031, 2530, 6033, 2528, 6035, 2526, 6037, 2524, 6039, 2522, 6041, 2520, 6043, 2518, 6045, 2516, 6047, 2514, 6049, 2512, 6051, 2510, 6053, 2508, 6055, 2506, 6057, 2504, 6059, 2502, 6061, 2500, 6063, 2498, 6065, 2496, 6067, 2494, 6069, 2492, 6071, 2490, 6073, 2488, 6075, 2486, 6077, 2484, 6079, 2482, 6081, 2480, 6083, 2478, 6085, 2476, 6087, 2474, 6089, 2472, 6091, 2470, 6093, 2468, 6095, 2466, 6097, 2464, 6099, 2462, 6101, 2460, 6103, 2458, 6105, 2456, 6107, 2454, 6109, 2452, 6111, 2450, 6113, 2448, 6115, 2446, 6117, 2444, 6119, 2442, 6121, 2440, 6123, 2438, 6125, 2436, 6127, 2434, 6129, 2432, 6131, 2430, 6133, 2428, 6135, 2426, 6137, 2424, 6139, 2422, 6141, 2420, 6143, 2418, 6145, 2416, 6147, 2414, 6149, 2412, 6151, 2410, 6153, 2408, 6155, 2406, 6157, 2404, 6159, 2402, 6161, 2400, 6163, 2398, 6165, 2396, 6167, 2394, 6169, 2392, 6171, 2390, 6173, 2388, 6175, 2386, 6177, 2384, 6179, 2382, 6181, 2380, 6183, 2378, 6185, 2376, 6187, 2374, 6189, 2372, 6191, 2370, 6193, 2368, 6195, 2366, 6197, 2364, 6199, 2362, 6201, 2360, 6203, 2358, 6205, 2356, 6207, 2354, 6209, 2352, 6211, 2350, 6213, 2348, 6215, 2346, 6217, 2344, 6219, 2342, 6221, 2340, 6223, 2338, 6225, 2336, 6227, 2334, 6229, 2332, 6231, 2330, 6233, 2328, 6235, 2326, 6237, 2324, 6239, 2322, 6241, 2320, 6243, 2318, 6245, 2316, 6247, 2314, 6249, 2312, 6251, 2310, 6253, 2308, 6255, 2306, 6257, 2304, 6259, 2302, 6261, 2300, 6263, 2298, 6265, 2296, 6267, 2294, 6269, 2292, 6271, 2290, 6273, 2288, 6275, 2286, 6277, 2284, 6279, 2282, 6281, 2280, 6283, 2278, 6285, 2276, 6287, 2274, 6289, 2272, 6291, 2270, 6293, 2268, 6295, 2266, 6297, 2264, 6299, 2262, 6301, 2260, 6303, 2258, 6305, 2256, 6307, 2254, 6309, 2252, 6311, 2250, 6313, 2248, 6315, 2246, 6317, 2244, 6319, 2242, 6321, 2240, 6323, 2238, 6325, 2236, 6327, 2234, 6329, 2232, 6331, 2230, 6333, 2228, 6335, 2226, 6337, 2224, 6339, 2222, 6341, 2220, 6343, 2218, 6345, 2216, 6347, 2214, 6349, 2212, 6351, 2210, 6353, 2208, 6355, 2206, 6357, 2204, 6359, 2202, 6361, 2200, 6363, 2198, 6365, 2196, 6367, 2194, 6369, 2192, 6371, 2190, 6373, 2188, 6375, 2186, 6377, 2184, 6379, 2182, 6381, 2180, 6383, 2178, 6385, 2176, 6387, 2174, 6389, 2172, 6391, 2170, 6393, 2168, 6395, 2166, 6397, 2164, 6399, 2162, 6401, 2160, 6403, 2158, 6405, 2156, 6407, 2154, 6409, 2152, 6411, 2150, 6413, 2148, 6415, 2146, 6417, 2144, 6419, 2142, 6421, 2140, 6423, 2138, 6425, 2136, 6427, 2134, 6429, 2132, 6431, 2130, 6433, 2128, 6435, 2126, 6437, 2124, 6439, 2122, 6441, 2120, 6443, 2118, 6445, 2116, 6447, 2114, 6449, 2112, 6451, 2110, 6453, 2108, 6455, 2106, 6457, 2104, 6459, 2102, 6461, 2100, 6463, 2098, 6465, 2096, 6467, 2094, 6469, 2092, 6471, 2090, 6473, 2088, 6475, 2086, 6477, 2084, 6479, 2082, 6481, 2080, 6483, 2078, 6485, 2076, 6487, 2074, 6489, 2072, 6491, 2070, 6493, 2068, 6495, 2066, 6497, 2064, 6499, 2062, 6501, 2060, 6503, 2058, 6505, 2056, 6507, 2054, 6509, 2052, 6511, 2050, 6513, 2048, 6515, 2046, 6517, 2044, 6519, 2042, 6521, 2040, 6523, 2038, 6525, 2036, 6527, 2034, 6529, 2032, 6531, 2030, 6533, 2028, 6535, 2026, 6537, 2024, 6539, 2022, 6541, 2020, 6543, 2018, 6545, 2016, 6547, 2014, 6549, 2012, 6551, 2010, 6553, 2008, 6555, 2006, 6557, 2004, 6559, 2002, 6561, 2000, 6563, 1998, 6565, 1996, 6567, 1994, 6569, 1992, 6571, 1990, 6573, 1988, 6575, 1986, 6577, 1984, 6579, 1982, 6581, 1980, 6583, 1978, 6585, 1976, 6587, 1974, 6589, 1972, 6591, 1970, 6593, 1968, 6595, 1966, 6597, 1964, 6599, 1962, 6601, 1960, 6603, 1958, 6605, 1956, 6607, 1954, 6609, 1952, 6611, 1950, 6613, 1948, 6615, 1946, 6617, 1944, 6619, 1942, 6621, 1940, 6623, 1938, 6625, 1936, 6627, 1934, 6629, 1932, 6631, 1930, 6633, 1928, 6635, 1926, 6637, 1924, 6639, 1922, 6641, 1920, 6643, 1918, 6645, 1916, 6647, 1914, 6649, 1912, 6651, 1910, 6653, 1908, 6655, 1906, 6657, 1904, 6659, 1902, 6661, 1900, 6663, 1898, 6665, 1896, 6667, 1894, 6669, 1892, 6671, 1890, 6673, 1888, 6675, 1886, 6677, 1884, 6679, 1882, 6681, 1880, 6683, 1878, 6685, 1876, 6687, 1874, 6689, 1872, 6691, 1870, 6693, 1868, 6695, 1866, 6697, 1864, 6699, 1862, 6701, 1860, 6703, 1858, 6705, 1856, 6707, 1854, 6709, 1852, 6711, 1850, 6713, 1848, 6715, 1846, 6717, 1844, 6719, 1842, 6721, 1840, 6723, 1838, 6725, 1836, 6727, 1834, 6729, 1832, 6731, 1830, 6733, 1828, 6735, 1826, 6737, 1824, 6739, 1822, 6741, 1820, 6743, 1818, 6745, 1816, 6747, 1814, 6749, 1812, 6751, 1810, 6753, 1808, 6755, 1806, 6757, 1804, 6759, 1802, 6761, 1800, 6763, 1798, 6765, 1796, 6767, 1794, 6769, 1792, 6771, 1790, 6773, 1788, 6775, 1786, 6777, 1784, 6779, 1782, 6781, 1780, 6783, 1778, 6785, 1776, 6787, 1774, 6789, 1772, 6791, 1770, 6793, 1768, 6795, 1766, 6797, 1764, 6799, 1762, 6801, 1760, 6803, 1758, 6805, 1756, 6807, 1754, 6809, 1752, 6811, 1750, 6813, 1748, 6815, 1746, 6817, 1744, 6819, 1742, 6821, 1740, 6823, 1738, 6825, 1736, 6827, 1734, 6829, 1732, 6831, 1730, 6833, 1728, 6835, 1726, 6837, 1724, 6839, 1722, 6841, 1720, 6843, 1718, 6845, 1716, 6847, 1714, 6849, 1712, 6851, 1710, 6853, 1708, 6855, 1706, 6857, 1704, 6859, 1702, 6861, 1700, 6863, 1698, 6865, 1696, 6867, 1694, 6869, 1692, 6871, 1690, 6873, 1688, 6875, 1686, 6877, 1684, 6879, 1682, 6881, 1680, 6883, 1678, 6885, 1676, 6887, 1674, 6889, 1672, 6891, 1670, 6893, 1668, 6895, 1666, 6897, 1664, 6899, 1662, 6901, 1660, 6903, 1658, 6905, 1656, 6907, 1654, 6909, 1652, 6911, 1650, 6913, 1648, 6915, 1646, 6917, 1644, 6919, 1642, 6921, 1640, 6923, 1638, 6925, 1636, 6927, 1634, 6929, 1632, 6931, 1630, 6933, 1628, 6935, 1626, 6937, 1624, 6939, 1622, 6941, 1620, 6943, 1618, 6945, 1616, 6947, 1614, 6949, 1612, 6951, 1610, 6953, 1608, 6955, 1606, 6957, 1604, 6959, 1602, 6961, 1600, 6963, 1598, 6965, 1596, 6967, 1594, 6969, 1592, 6971, 1590, 6973, 1588, 6975, 1586, 6977, 1584, 6979, 1582, 6981, 1580, 6983, 1578, 6985, 1576, 6987, 1574, 6989, 1572, 6991, 1570, 6993, 1568, 6995, 1566, 6997, 1564, 6999, 1562, 7001, 1560, 7003, 1558, 7005, 1556, 7007, 1554, 7009, 1552, 7011, 1550, 7013, 1548, 7015, 1546, 7017, 1544, 7019, 1542, 7021, 1540, 7023, 1538, 7025, 1536, 7027, 1534, 7029, 1532, 7031, 1530, 7033, 1528, 7035, 1526, 7037, 1524, 7039, 1522, 7041, 1520, 7043, 1518, 7045, 1516, 7047, 1514, 7049, 1512, 7051, 1510, 7053, 1508, 7055, 1506, 7057, 1504, 7059, 1502, 7061, 1500, 7063, 1498, 7065, 1496, 7067, 1494, 7069, 1492, 7071, 1490, 7073, 1488, 7075, 1486, 7077, 1484, 7079, 1482, 7081, 1480, 7083, 1478, 7085, 1476, 7087, 1474, 7089, 1472, 7091, 1470, 7093, 1468, 7095, 1466, 7097, 1464, 7099, 1462, 7101, 1460, 7103, 1458, 7105, 1456, 7107, 1454, 7109, 1452, 7111, 1450, 7113, 1448, 7115, 1446, 7117, 1444, 7119, 1442, 7121, 1440, 7123, 1438, 7125, 1436, 7127, 1434, 7129, 1432, 7131, 1430, 7133, 1428, 7135, 1426, 7137, 1424, 7139, 1422, 7141, 1420, 7143, 1418, 7145, 1416, 7147, 1414, 7149, 1412, 7151, 1410, 7153, 1408, 7155, 1406, 7157, 1404, 7159, 1402, 7161, 1400, 7163, 1398, 7165, 1396, 7167, 1394, 7169, 1392, 7171, 1390, 7173, 1388, 7175, 1386, 7177, 1384, 7179, 1382, 7181, 1380, 7183, 1378, 7185, 1376, 7187, 1374, 7189, 1372, 7191, 1370, 7193, 1368, 7195, 1366, 7197, 1364, 7199, 1362, 7201, 1360, 7203, 1358, 7205, 1356, 7207, 1354, 7209, 1352, 7211, 1350, 7213, 1348, 7215, 1346, 7217, 1344, 7219, 1342, 7221, 1340, 7223, 1338, 7225, 1336, 7227, 1334, 7229, 1332, 7231, 1330, 7233, 1328, 7235, 1326, 7237, 1324, 7239, 1322, 7241, 1320, 7243, 1318, 7245, 1316, 7247, 1314, 7249, 1312, 7251, 1310, 7253, 1308, 7255, 1306, 7257, 1304, 7259, 1302, 7261, 1300, 7263, 1298, 7265, 1296, 7267, 1294, 7269, 1292, 7271, 1290, 7273, 1288, 7275, 1286, 7277, 1284, 7279, 1282, 7281, 1280, 7283, 1278, 7285, 1276, 7287, 1274, 7289, 1272, 7291, 1270, 7293, 1268, 7295, 1266, 7297, 1264, 7299, 1262, 7301, 1260, 7303, 1258, 7305, 1256, 7307, 1254, 7309, 1252, 7311, 1250, 7313, 1248, 7315, 1246, 7317, 1244, 7319, 1242, 7321, 1240, 7323, 1238, 7325, 1236, 7327, 1234, 7329, 1232, 7331, 1230, 7333, 1228, 7335, 1226, 7337, 1224, 7339, 1222, 7341, 1220, 7343, 1218, 7345, 1216, 7347, 1214, 7349, 1212, 7351, 1210, 7353, 1208, 7355, 1206, 7357, 1204, 7359, 1202, 7361, 1200, 7363, 1198, 7365, 1196, 7367, 1194, 7369, 1192, 7371, 1190, 7373, 1188, 7375, 1186, 7377, 1184, 7379, 1182, 7381, 1180, 7383, 1178, 7385, 1176, 7387, 1174, 7389, 1172, 7391, 1170, 7393, 1168, 7395, 1166, 7397, 1164, 7399, 1162, 7401, 1160, 7403, 1158, 7405, 1156, 7407, 1154, 7409, 1152, 7411, 1150, 7413, 1148, 7415, 1146, 7417, 1144, 7419, 1142, 7421, 1140, 7423, 1138, 7425, 1136, 7427, 1134, 7429, 1132, 7431, 1130, 7433, 1128, 7435, 1126, 7437, 1124, 7439, 1122, 7441, 1120, 7443, 1118, 7445, 1116, 7447, 1114, 7449, 1112, 7451, 1110, 7453, 1108, 7455, 1106, 7457, 1104, 7459, 1102, 7461, 1100, 7463, 1098, 7465, 1096, 7467, 1094, 7469, 1092, 7471, 1090, 7473, 1088, 7475, 1086, 7477, 1084, 7479, 1082, 7481, 1080, 7483, 1078, 7485, 1076, 7487, 1074, 7489, 1072, 7491, 1070, 7493, 1068, 7495, 1066, 7497, 1064, 7499, 1062, 7501, 1060, 7503, 1058, 7505, 1056, 7507, 1054, 7509, 1052, 7511, 1050, 7513, 1048, 7515, 1046, 7517, 1044, 7519, 1042, 7521, 1040, 7523, 1038, 7525, 1036, 7527, 1034, 7529, 1032, 7531, 1030, 7533, 1028, 7535, 1026, 7537, 1024, 7539, 1022, 7541, 1020, 7543, 1018, 7545, 1016, 7547, 1014, 7549, 1012, 7551, 1010, 7553, 1008, 7555, 1006, 7557, 1004, 7559, 1002, 7561, 1000, 7563, 998, 7565, 996, 7567, 994, 7569, 992, 7571, 990, 7573, 988, 7575, 986, 7577, 984, 7579, 982, 7581, 980, 7583, 978, 7585, 976, 7587, 974, 7589, 972, 7591, 970, 7593, 968, 7595, 966, 7597, 964, 7599, 962, 7601, 960, 7603, 958, 7605, 956, 7607, 954, 7609, 952, 7611, 950, 7613, 948, 7615, 946, 7617, 944, 7619, 942, 7621, 940, 7623, 938, 7625, 936, 7627, 934, 7629, 932, 7631, 930, 7633, 928, 7635, 926, 7637, 924, 7639, 922, 7641, 920, 7643, 918, 7645, 916, 7647, 914, 7649, 912, 7651, 910, 7653, 908, 7655, 906, 7657, 904, 7659, 902, 7661, 900, 7663, 898, 7665, 896, 7667, 894, 7669, 892, 7671, 890, 7673, 888, 7675, 886, 7677, 884, 7679, 882, 7681, 880, 7683, 878, 7685, 876, 7687, 874, 7689, 872, 7691, 870, 7693, 868, 7695, 866, 7697, 864, 7699, 862, 7701, 860, 7703, 858, 7705, 856, 7707, 854, 7709, 852, 7711, 850, 7713, 848, 7715, 846, 7717, 844, 7719, 842, 7721, 840, 7723, 838, 7725, 836, 7727, 834, 7729, 832, 7731, 830, 7733, 828, 7735, 826, 7737, 824, 7739, 822, 7741, 820, 7743, 818, 7745, 816, 7747, 814, 7749, 812, 7751, 810, 7753, 808, 7755, 806, 7757, 804, 7759, 802, 7761, 800, 7763, 798, 7765, 796, 7767, 794, 7769, 792, 7771, 790, 7773, 788, 7775, 786, 7777, 784, 7779, 782, 7781, 780, 7783, 778, 7785, 776, 7787, 774, 7789, 772, 7791, 770, 7793, 768, 7795, 766, 7797, 764, 7799, 762, 7801, 760, 7803, 758, 7805, 756, 7807, 754, 7809, 752, 7811, 750, 7813, 748, 7815, 746, 7817, 744, 7819, 742, 7821, 740, 7823, 738, 7825, 736, 7827, 734, 7829, 732, 7831, 730, 7833, 728, 7835, 726, 7837, 724, 7839, 722, 7841, 720, 7843, 718, 7845, 716, 7847, 714, 7849, 712, 7851, 710, 7853, 708, 7855, 706, 7857, 704, 7859, 702, 7861, 700, 7863, 698, 7865, 696, 7867, 694, 7869, 692, 7871, 690, 7873, 688, 7875, 686, 7877, 684, 7879, 682, 7881, 680, 7883, 678, 7885, 676, 7887, 674, 7889, 672, 7891, 670, 7893, 668, 7895, 666, 7897, 664, 7899, 662, 7901, 660, 7903, 658, 7905, 656, 7907, 654, 7909, 652, 7911, 650, 7913, 648, 7915, 646, 7917, 644, 7919, 642, 7921, 640, 7923, 638, 7925, 636, 7927, 634, 7929, 632, 7931, 630, 7933, 628, 7935, 626, 7937, 624, 7939, 622, 7941, 620, 7943, 618, 7945, 616, 7947, 614, 7949, 612, 7951, 610, 7953, 608, 7955, 606, 7957, 604, 7959, 602, 7961, 600, 7963, 598, 7965, 596, 7967, 594, 7969, 592, 7971, 590, 7973, 588, 7975, 586, 7977, 584, 7979, 582, 7981, 580, 7983, 578, 7985, 576, 7987, 574, 7989, 572, 7991, 570, 7993, 568, 7995, 566, 7997, 564, 7999, 562, 8001, 560, 8003, 558, 8005, 556, 8007, 554, 8009, 552, 8011, 550, 8013, 548, 8015, 546, 8017, 544, 8019, 542, 8021, 540, 8023, 538, 8025, 536, 8027, 534, 8029, 532, 8031, 530, 8033, 528, 8035, 526, 8037, 524, 8039, 522, 8041, 520, 8043, 518, 8045, 516, 8047, 514, 8049, 512, 8051, 510, 8053, 508, 8055, 506, 8057, 504, 8059, 502, 8061, 500, 8063, 498, 8065, 496, 8067, 494, 8069, 492, 8071, 490, 8073, 488, 8075, 486, 8077, 484, 8079, 482, 8081, 480, 8083, 478, 8085, 476, 8087, 474, 8089, 472, 8091, 470, 8093, 468, 8095, 466, 8097, 464, 8099, 462, 8101, 460, 8103, 458, 8105, 456, 8107, 454, 8109, 452, 8111, 450, 8113, 448, 8115, 446, 8117, 444, 8119, 442, 8121, 440, 8123, 438, 8125, 436, 8127, 434, 8129, 432, 8131, 430, 8133, 428, 8135, 426, 8137, 424, 8139, 422, 8141, 420, 8143, 418, 8145, 416, 8147, 414, 8149, 412, 8151, 410, 8153, 408, 8155, 406, 8157, 404, 8159, 402, 8161, 400, 8163, 398, 8165, 396, 8167, 394, 8169, 392, 8171, 390, 8173, 388, 8175, 386, 8177, 384, 8179, 382, 8181, 380, 8183, 378, 8185, 376, 8187, 374, 8189, 372, 8191, 370, 8193, 368, 8195, 366, 8197, 364, 8199, 362, 8201, 360, 8203, 358, 8205, 356, 8207, 354, 8209, 352, 8211, 350, 8213, 348, 8215, 346, 8217, 344, 8219, 342, 8221, 340, 8223, 338, 8225, 336, 8227, 334, 8229, 332, 8231, 330, 8233, 328, 8235, 326, 8237, 324, 8239, 322, 8241, 320, 8243, 318, 8245, 316, 8247, 314, 8249, 312, 8251, 310, 8253, 308, 8255, 306, 8257, 304, 8259, 302, 8261, 300, 8263, 298, 8265, 296, 8267, 294, 8269, 292, 8271, 290, 8273, 288, 8275, 286, 8277, 284, 8279, 282, 8281, 280, 8283, 278, 8285, 276, 8287, 274, 8289, 272, 8291, 270, 8293, 268, 8295, 266, 8297, 264, 8299, 262, 8301, 260, 8303, 258, 8305, 256, 8307, 254, 8309, 252, 8311, 250, 8313, 248, 8315, 246, 8317, 244, 8319, 242, 8321, 240, 8323, 238, 8325, 236, 8327, 234, 8329, 232, 8331, 230, 8333, 228, 8335, 226, 8337, 224, 8339, 222, 8341, 220, 8343, 218, 8345, 216, 8347, 214, 8349, 212, 8351, 210, 8353, 208, 8355, 206, 8357, 204, 8359, 202, 8361, 200, 8363, 198, 8365, 196, 8367, 194, 8369, 192, 8371, 190, 8373, 188, 8375, 186, 8377, 184, 8379, 182, 8381, 180, 8383, 178, 8385, 176, 8387, 174, 8389, 172, 8391, 170, 8393, 168, 8395, 166, 8397, 164, 8399, 162, 8401, 160, 8403, 158, 8405, 156, 8407, 154, 8409, 152, 8411, 150, 8413, 148, 8415, 146, 8417, 144, 8419, 142, 8421, 140, 8423, 138, 8425, 136, 8427, 134, 8429, 132, 8431, 130, 8433, 128, 8435, 126, 8437, 124, 8439, 122, 8441, 120, 8443, 118, 8445, 116, 8447, 114, 8449, 112, 8451, 110, 8453, 108, 8455, 106, 8457, 104, 8459, 102, 8461, 100, 8463, 98, 8465, 96, 8467, 94, 8469, 92, 8471, 90, 8473, 88, 8475, 86, 8477, 84, 8479, 82, 8481, 80, 8483, 78, 8485, 76, 8487, 74, 8489, 72, 8491, 70, 8493, 68, 8495, 66, 8497, 64, 8499, 62, 8501, 60, 8503, 58, 8505, 56, 8507, 54, 8509, 52, 8511, 50, 8513, 48, 8515, 46, 8517, 44, 8519, 42, 8521, 40, 8523, 38, 8525, 36, 8527, 34, 8529, 32, 8531, 30, 8533, 28, 8535, 26, 8537, 24, 8539, 22, 8541, 20, 8543, 18, 8545, 16, 8547, 14, 8549, 12, 8551, 10, 8553, 8, 8555, 6, 8557, 4, 8559, 2, 8561]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l5-s0/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l5-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-l5-s0/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..208c75cb32e250b204728b256a774845dad41752 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 8562, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l5-s0/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l5-s0/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l5-s9/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l5-s9/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bbbaeb31d69181d24164f75dcd803d418a7ef63c --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 8660, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l5-s9/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ca11c9093b0a9ecba1be61fb673298a4b98bc423 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [8660, 1, 8658, 3, 8656, 5, 8654, 7, 8652, 9, 8650, 11, 8648, 13, 8646, 15, 8644, 17, 8642, 19, 8640, 21, 8638, 23, 8636, 25, 8634, 27, 8632, 29, 8630, 31, 8628, 33, 8626, 35, 8624, 37, 8622, 39, 8620, 41, 8618, 43, 8616, 45, 8614, 47, 8612, 49, 8610, 51, 8608, 53, 8606, 55, 8604, 57, 8602, 59, 8600, 61, 8598, 63, 8596, 65, 8594, 67, 8592, 69, 8590, 71, 8588, 73, 8586, 75, 8584, 77, 8582, 79, 8580, 81, 8578, 83, 8576, 85, 8574, 87, 8572, 89, 8570, 91, 8568, 93, 8566, 95, 8564, 97, 8562, 99, 8560, 101, 8558, 103, 8556, 105, 8554, 107, 8552, 109, 8550, 111, 8548, 113, 8546, 115, 8544, 117, 8542, 119, 8540, 121, 8538, 123, 8536, 125, 8534, 127, 8532, 129, 8530, 131, 8528, 133, 8526, 135, 8524, 137, 8522, 139, 8520, 141, 8518, 143, 8516, 145, 8514, 147, 8512, 149, 8510, 151, 8508, 153, 8506, 155, 8504, 157, 8502, 159, 8500, 161, 8498, 163, 8496, 165, 8494, 167, 8492, 169, 8490, 171, 8488, 173, 8486, 175, 8484, 177, 8482, 179, 8480, 181, 8478, 183, 8476, 185, 8474, 187, 8472, 189, 8470, 191, 8468, 193, 8466, 195, 8464, 197, 8462, 199, 8460, 201, 8458, 203, 8456, 205, 8454, 207, 8452, 209, 8450, 211, 8448, 213, 8446, 215, 8444, 217, 8442, 219, 8440, 221, 8438, 223, 8436, 225, 8434, 227, 8432, 229, 8430, 231, 8428, 233, 8426, 235, 8424, 237, 8422, 239, 8420, 241, 8418, 243, 8416, 245, 8414, 247, 8412, 249, 8410, 251, 8408, 253, 8406, 255, 8404, 257, 8402, 259, 8400, 261, 8398, 263, 8396, 265, 8394, 267, 8392, 269, 8390, 271, 8388, 273, 8386, 275, 8384, 277, 8382, 279, 8380, 281, 8378, 283, 8376, 285, 8374, 287, 8372, 289, 8370, 291, 8368, 293, 8366, 295, 8364, 297, 8362, 299, 8360, 301, 8358, 303, 8356, 305, 8354, 307, 8352, 309, 8350, 311, 8348, 313, 8346, 315, 8344, 317, 8342, 319, 8340, 321, 8338, 323, 8336, 325, 8334, 327, 8332, 329, 8330, 331, 8328, 333, 8326, 335, 8324, 337, 8322, 339, 8320, 341, 8318, 343, 8316, 345, 8314, 347, 8312, 349, 8310, 351, 8308, 353, 8306, 355, 8304, 357, 8302, 359, 8300, 361, 8298, 363, 8296, 365, 8294, 367, 8292, 369, 8290, 371, 8288, 373, 8286, 375, 8284, 377, 8282, 379, 8280, 381, 8278, 383, 8276, 385, 8274, 387, 8272, 389, 8270, 391, 8268, 393, 8266, 395, 8264, 397, 8262, 399, 8260, 401, 8258, 403, 8256, 405, 8254, 407, 8252, 409, 8250, 411, 8248, 413, 8246, 415, 8244, 417, 8242, 419, 8240, 421, 8238, 423, 8236, 425, 8234, 427, 8232, 429, 8230, 431, 8228, 433, 8226, 435, 8224, 437, 8222, 439, 8220, 441, 8218, 443, 8216, 445, 8214, 447, 8212, 449, 8210, 451, 8208, 453, 8206, 455, 8204, 457, 8202, 459, 8200, 461, 8198, 463, 8196, 465, 8194, 467, 8192, 469, 8190, 471, 8188, 473, 8186, 475, 8184, 477, 8182, 479, 8180, 481, 8178, 483, 8176, 485, 8174, 487, 8172, 489, 8170, 491, 8168, 493, 8166, 495, 8164, 497, 8162, 499, 8160, 501, 8158, 503, 8156, 505, 8154, 507, 8152, 509, 8150, 511, 8148, 513, 8146, 515, 8144, 517, 8142, 519, 8140, 521, 8138, 523, 8136, 525, 8134, 527, 8132, 529, 8130, 531, 8128, 533, 8126, 535, 8124, 537, 8122, 539, 8120, 541, 8118, 543, 8116, 545, 8114, 547, 8112, 549, 8110, 551, 8108, 553, 8106, 555, 8104, 557, 8102, 559, 8100, 561, 8098, 563, 8096, 565, 8094, 567, 8092, 569, 8090, 571, 8088, 573, 8086, 575, 8084, 577, 8082, 579, 8080, 581, 8078, 583, 8076, 585, 8074, 587, 8072, 589, 8070, 591, 8068, 593, 8066, 595, 8064, 597, 8062, 599, 8060, 601, 8058, 603, 8056, 605, 8054, 607, 8052, 609, 8050, 611, 8048, 613, 8046, 615, 8044, 617, 8042, 619, 8040, 621, 8038, 623, 8036, 625, 8034, 627, 8032, 629, 8030, 631, 8028, 633, 8026, 635, 8024, 637, 8022, 639, 8020, 641, 8018, 643, 8016, 645, 8014, 647, 8012, 649, 8010, 651, 8008, 653, 8006, 655, 8004, 657, 8002, 659, 8000, 661, 7998, 663, 7996, 665, 7994, 667, 7992, 669, 7990, 671, 7988, 673, 7986, 675, 7984, 677, 7982, 679, 7980, 681, 7978, 683, 7976, 685, 7974, 687, 7972, 689, 7970, 691, 7968, 693, 7966, 695, 7964, 697, 7962, 699, 7960, 701, 7958, 703, 7956, 705, 7954, 707, 7952, 709, 7950, 711, 7948, 713, 7946, 715, 7944, 717, 7942, 719, 7940, 721, 7938, 723, 7936, 725, 7934, 727, 7932, 729, 7930, 731, 7928, 733, 7926, 735, 7924, 737, 7922, 739, 7920, 741, 7918, 743, 7916, 745, 7914, 747, 7912, 749, 7910, 751, 7908, 753, 7906, 755, 7904, 757, 7902, 759, 7900, 761, 7898, 763, 7896, 765, 7894, 767, 7892, 769, 7890, 771, 7888, 773, 7886, 775, 7884, 777, 7882, 779, 7880, 781, 7878, 783, 7876, 785, 7874, 787, 7872, 789, 7870, 791, 7868, 793, 7866, 795, 7864, 797, 7862, 799, 7860, 801, 7858, 803, 7856, 805, 7854, 807, 7852, 809, 7850, 811, 7848, 813, 7846, 815, 7844, 817, 7842, 819, 7840, 821, 7838, 823, 7836, 825, 7834, 827, 7832, 829, 7830, 831, 7828, 833, 7826, 835, 7824, 837, 7822, 839, 7820, 841, 7818, 843, 7816, 845, 7814, 847, 7812, 849, 7810, 851, 7808, 853, 7806, 855, 7804, 857, 7802, 859, 7800, 861, 7798, 863, 7796, 865, 7794, 867, 7792, 869, 7790, 871, 7788, 873, 7786, 875, 7784, 877, 7782, 879, 7780, 881, 7778, 883, 7776, 885, 7774, 887, 7772, 889, 7770, 891, 7768, 893, 7766, 895, 7764, 897, 7762, 899, 7760, 901, 7758, 903, 7756, 905, 7754, 907, 7752, 909, 7750, 911, 7748, 913, 7746, 915, 7744, 917, 7742, 919, 7740, 921, 7738, 923, 7736, 925, 7734, 927, 7732, 929, 7730, 931, 7728, 933, 7726, 935, 7724, 937, 7722, 939, 7720, 941, 7718, 943, 7716, 945, 7714, 947, 7712, 949, 7710, 951, 7708, 953, 7706, 955, 7704, 957, 7702, 959, 7700, 961, 7698, 963, 7696, 965, 7694, 967, 7692, 969, 7690, 971, 7688, 973, 7686, 975, 7684, 977, 7682, 979, 7680, 981, 7678, 983, 7676, 985, 7674, 987, 7672, 989, 7670, 991, 7668, 993, 7666, 995, 7664, 997, 7662, 999, 7660, 1001, 7658, 1003, 7656, 1005, 7654, 1007, 7652, 1009, 7650, 1011, 7648, 1013, 7646, 1015, 7644, 1017, 7642, 1019, 7640, 1021, 7638, 1023, 7636, 1025, 7634, 1027, 7632, 1029, 7630, 1031, 7628, 1033, 7626, 1035, 7624, 1037, 7622, 1039, 7620, 1041, 7618, 1043, 7616, 1045, 7614, 1047, 7612, 1049, 7610, 1051, 7608, 1053, 7606, 1055, 7604, 1057, 7602, 1059, 7600, 1061, 7598, 1063, 7596, 1065, 7594, 1067, 7592, 1069, 7590, 1071, 7588, 1073, 7586, 1075, 7584, 1077, 7582, 1079, 7580, 1081, 7578, 1083, 7576, 1085, 7574, 1087, 7572, 1089, 7570, 1091, 7568, 1093, 7566, 1095, 7564, 1097, 7562, 1099, 7560, 1101, 7558, 1103, 7556, 1105, 7554, 1107, 7552, 1109, 7550, 1111, 7548, 1113, 7546, 1115, 7544, 1117, 7542, 1119, 7540, 1121, 7538, 1123, 7536, 1125, 7534, 1127, 7532, 1129, 7530, 1131, 7528, 1133, 7526, 1135, 7524, 1137, 7522, 1139, 7520, 1141, 7518, 1143, 7516, 1145, 7514, 1147, 7512, 1149, 7510, 1151, 7508, 1153, 7506, 1155, 7504, 1157, 7502, 1159, 7500, 1161, 7498, 1163, 7496, 1165, 7494, 1167, 7492, 1169, 7490, 1171, 7488, 1173, 7486, 1175, 7484, 1177, 7482, 1179, 7480, 1181, 7478, 1183, 7476, 1185, 7474, 1187, 7472, 1189, 7470, 1191, 7468, 1193, 7466, 1195, 7464, 1197, 7462, 1199, 7460, 1201, 7458, 1203, 7456, 1205, 7454, 1207, 7452, 1209, 7450, 1211, 7448, 1213, 7446, 1215, 7444, 1217, 7442, 1219, 7440, 1221, 7438, 1223, 7436, 1225, 7434, 1227, 7432, 1229, 7430, 1231, 7428, 1233, 7426, 1235, 7424, 1237, 7422, 1239, 7420, 1241, 7418, 1243, 7416, 1245, 7414, 1247, 7412, 1249, 7410, 1251, 7408, 1253, 7406, 1255, 7404, 1257, 7402, 1259, 7400, 1261, 7398, 1263, 7396, 1265, 7394, 1267, 7392, 1269, 7390, 1271, 7388, 1273, 7386, 1275, 7384, 1277, 7382, 1279, 7380, 1281, 7378, 1283, 7376, 1285, 7374, 1287, 7372, 1289, 7370, 1291, 7368, 1293, 7366, 1295, 7364, 1297, 7362, 1299, 7360, 1301, 7358, 1303, 7356, 1305, 7354, 1307, 7352, 1309, 7350, 1311, 7348, 1313, 7346, 1315, 7344, 1317, 7342, 1319, 7340, 1321, 7338, 1323, 7336, 1325, 7334, 1327, 7332, 1329, 7330, 1331, 7328, 1333, 7326, 1335, 7324, 1337, 7322, 1339, 7320, 1341, 7318, 1343, 7316, 1345, 7314, 1347, 7312, 1349, 7310, 1351, 7308, 1353, 7306, 1355, 7304, 1357, 7302, 1359, 7300, 1361, 7298, 1363, 7296, 1365, 7294, 1367, 7292, 1369, 7290, 1371, 7288, 1373, 7286, 1375, 7284, 1377, 7282, 1379, 7280, 1381, 7278, 1383, 7276, 1385, 7274, 1387, 7272, 1389, 7270, 1391, 7268, 1393, 7266, 1395, 7264, 1397, 7262, 1399, 7260, 1401, 7258, 1403, 7256, 1405, 7254, 1407, 7252, 1409, 7250, 1411, 7248, 1413, 7246, 1415, 7244, 1417, 7242, 1419, 7240, 1421, 7238, 1423, 7236, 1425, 7234, 1427, 7232, 1429, 7230, 1431, 7228, 1433, 7226, 1435, 7224, 1437, 7222, 1439, 7220, 1441, 7218, 1443, 7216, 1445, 7214, 1447, 7212, 1449, 7210, 1451, 7208, 1453, 7206, 1455, 7204, 1457, 7202, 1459, 7200, 1461, 7198, 1463, 7196, 1465, 7194, 1467, 7192, 1469, 7190, 1471, 7188, 1473, 7186, 1475, 7184, 1477, 7182, 1479, 7180, 1481, 7178, 1483, 7176, 1485, 7174, 1487, 7172, 1489, 7170, 1491, 7168, 1493, 7166, 1495, 7164, 1497, 7162, 1499, 7160, 1501, 7158, 1503, 7156, 1505, 7154, 1507, 7152, 1509, 7150, 1511, 7148, 1513, 7146, 1515, 7144, 1517, 7142, 1519, 7140, 1521, 7138, 1523, 7136, 1525, 7134, 1527, 7132, 1529, 7130, 1531, 7128, 1533, 7126, 1535, 7124, 1537, 7122, 1539, 7120, 1541, 7118, 1543, 7116, 1545, 7114, 1547, 7112, 1549, 7110, 1551, 7108, 1553, 7106, 1555, 7104, 1557, 7102, 1559, 7100, 1561, 7098, 1563, 7096, 1565, 7094, 1567, 7092, 1569, 7090, 1571, 7088, 1573, 7086, 1575, 7084, 1577, 7082, 1579, 7080, 1581, 7078, 1583, 7076, 1585, 7074, 1587, 7072, 1589, 7070, 1591, 7068, 1593, 7066, 1595, 7064, 1597, 7062, 1599, 7060, 1601, 7058, 1603, 7056, 1605, 7054, 1607, 7052, 1609, 7050, 1611, 7048, 1613, 7046, 1615, 7044, 1617, 7042, 1619, 7040, 1621, 7038, 1623, 7036, 1625, 7034, 1627, 7032, 1629, 7030, 1631, 7028, 1633, 7026, 1635, 7024, 1637, 7022, 1639, 7020, 1641, 7018, 1643, 7016, 1645, 7014, 1647, 7012, 1649, 7010, 1651, 7008, 1653, 7006, 1655, 7004, 1657, 7002, 1659, 7000, 1661, 6998, 1663, 6996, 1665, 6994, 1667, 6992, 1669, 6990, 1671, 6988, 1673, 6986, 1675, 6984, 1677, 6982, 1679, 6980, 1681, 6978, 1683, 6976, 1685, 6974, 1687, 6972, 1689, 6970, 1691, 6968, 1693, 6966, 1695, 6964, 1697, 6962, 1699, 6960, 1701, 6958, 1703, 6956, 1705, 6954, 1707, 6952, 1709, 6950, 1711, 6948, 1713, 6946, 1715, 6944, 1717, 6942, 1719, 6940, 1721, 6938, 1723, 6936, 1725, 6934, 1727, 6932, 1729, 6930, 1731, 6928, 1733, 6926, 1735, 6924, 1737, 6922, 1739, 6920, 1741, 6918, 1743, 6916, 1745, 6914, 1747, 6912, 1749, 6910, 1751, 6908, 1753, 6906, 1755, 6904, 1757, 6902, 1759, 6900, 1761, 6898, 1763, 6896, 1765, 6894, 1767, 6892, 1769, 6890, 1771, 6888, 1773, 6886, 1775, 6884, 1777, 6882, 1779, 6880, 1781, 6878, 1783, 6876, 1785, 6874, 1787, 6872, 1789, 6870, 1791, 6868, 1793, 6866, 1795, 6864, 1797, 6862, 1799, 6860, 1801, 6858, 1803, 6856, 1805, 6854, 1807, 6852, 1809, 6850, 1811, 6848, 1813, 6846, 1815, 6844, 1817, 6842, 1819, 6840, 1821, 6838, 1823, 6836, 1825, 6834, 1827, 6832, 1829, 6830, 1831, 6828, 1833, 6826, 1835, 6824, 1837, 6822, 1839, 6820, 1841, 6818, 1843, 6816, 1845, 6814, 1847, 6812, 1849, 6810, 1851, 6808, 1853, 6806, 1855, 6804, 1857, 6802, 1859, 6800, 1861, 6798, 1863, 6796, 1865, 6794, 1867, 6792, 1869, 6790, 1871, 6788, 1873, 6786, 1875, 6784, 1877, 6782, 1879, 6780, 1881, 6778, 1883, 6776, 1885, 6774, 1887, 6772, 1889, 6770, 1891, 6768, 1893, 6766, 1895, 6764, 1897, 6762, 1899, 6760, 1901, 6758, 1903, 6756, 1905, 6754, 1907, 6752, 1909, 6750, 1911, 6748, 1913, 6746, 1915, 6744, 1917, 6742, 1919, 6740, 1921, 6738, 1923, 6736, 1925, 6734, 1927, 6732, 1929, 6730, 1931, 6728, 1933, 6726, 1935, 6724, 1937, 6722, 1939, 6720, 1941, 6718, 1943, 6716, 1945, 6714, 1947, 6712, 1949, 6710, 1951, 6708, 1953, 6706, 1955, 6704, 1957, 6702, 1959, 6700, 1961, 6698, 1963, 6696, 1965, 6694, 1967, 6692, 1969, 6690, 1971, 6688, 1973, 6686, 1975, 6684, 1977, 6682, 1979, 6680, 1981, 6678, 1983, 6676, 1985, 6674, 1987, 6672, 1989, 6670, 1991, 6668, 1993, 6666, 1995, 6664, 1997, 6662, 1999, 6660, 2001, 6658, 2003, 6656, 2005, 6654, 2007, 6652, 2009, 6650, 2011, 6648, 2013, 6646, 2015, 6644, 2017, 6642, 2019, 6640, 2021, 6638, 2023, 6636, 2025, 6634, 2027, 6632, 2029, 6630, 2031, 6628, 2033, 6626, 2035, 6624, 2037, 6622, 2039, 6620, 2041, 6618, 2043, 6616, 2045, 6614, 2047, 6612, 2049, 6610, 2051, 6608, 2053, 6606, 2055, 6604, 2057, 6602, 2059, 6600, 2061, 6598, 2063, 6596, 2065, 6594, 2067, 6592, 2069, 6590, 2071, 6588, 2073, 6586, 2075, 6584, 2077, 6582, 2079, 6580, 2081, 6578, 2083, 6576, 2085, 6574, 2087, 6572, 2089, 6570, 2091, 6568, 2093, 6566, 2095, 6564, 2097, 6562, 2099, 6560, 2101, 6558, 2103, 6556, 2105, 6554, 2107, 6552, 2109, 6550, 2111, 6548, 2113, 6546, 2115, 6544, 2117, 6542, 2119, 6540, 2121, 6538, 2123, 6536, 2125, 6534, 2127, 6532, 2129, 6530, 2131, 6528, 2133, 6526, 2135, 6524, 2137, 6522, 2139, 6520, 2141, 6518, 2143, 6516, 2145, 6514, 2147, 6512, 2149, 6510, 2151, 6508, 2153, 6506, 2155, 6504, 2157, 6502, 2159, 6500, 2161, 6498, 2163, 6496, 2165, 6494, 2167, 6492, 2169, 6490, 2171, 6488, 2173, 6486, 2175, 6484, 2177, 6482, 2179, 6480, 2181, 6478, 2183, 6476, 2185, 6474, 2187, 6472, 2189, 6470, 2191, 6468, 2193, 6466, 2195, 6464, 2197, 6462, 2199, 6460, 2201, 6458, 2203, 6456, 2205, 6454, 2207, 6452, 2209, 6450, 2211, 6448, 2213, 6446, 2215, 6444, 2217, 6442, 2219, 6440, 2221, 6438, 2223, 6436, 2225, 6434, 2227, 6432, 2229, 6430, 2231, 6428, 2233, 6426, 2235, 6424, 2237, 6422, 2239, 6420, 2241, 6418, 2243, 6416, 2245, 6414, 2247, 6412, 2249, 6410, 2251, 6408, 2253, 6406, 2255, 6404, 2257, 6402, 2259, 6400, 2261, 6398, 2263, 6396, 2265, 6394, 2267, 6392, 2269, 6390, 2271, 6388, 2273, 6386, 2275, 6384, 2277, 6382, 2279, 6380, 2281, 6378, 2283, 6376, 2285, 6374, 2287, 6372, 2289, 6370, 2291, 6368, 2293, 6366, 2295, 6364, 2297, 6362, 2299, 6360, 2301, 6358, 2303, 6356, 2305, 6354, 2307, 6352, 2309, 6350, 2311, 6348, 2313, 6346, 2315, 6344, 2317, 6342, 2319, 6340, 2321, 6338, 2323, 6336, 2325, 6334, 2327, 6332, 2329, 6330, 2331, 6328, 2333, 6326, 2335, 6324, 2337, 6322, 2339, 6320, 2341, 6318, 2343, 6316, 2345, 6314, 2347, 6312, 2349, 6310, 2351, 6308, 2353, 6306, 2355, 6304, 2357, 6302, 2359, 6300, 2361, 6298, 2363, 6296, 2365, 6294, 2367, 6292, 2369, 6290, 2371, 6288, 2373, 6286, 2375, 6284, 2377, 6282, 2379, 6280, 2381, 6278, 2383, 6276, 2385, 6274, 2387, 6272, 2389, 6270, 2391, 6268, 2393, 6266, 2395, 6264, 2397, 6262, 2399, 6260, 2401, 6258, 2403, 6256, 2405, 6254, 2407, 6252, 2409, 6250, 2411, 6248, 2413, 6246, 2415, 6244, 2417, 6242, 2419, 6240, 2421, 6238, 2423, 6236, 2425, 6234, 2427, 6232, 2429, 6230, 2431, 6228, 2433, 6226, 2435, 6224, 2437, 6222, 2439, 6220, 2441, 6218, 2443, 6216, 2445, 6214, 2447, 6212, 2449, 6210, 2451, 6208, 2453, 6206, 2455, 6204, 2457, 6202, 2459, 6200, 2461, 6198, 2463, 6196, 2465, 6194, 2467, 6192, 2469, 6190, 2471, 6188, 2473, 6186, 2475, 6184, 2477, 6182, 2479, 6180, 2481, 6178, 2483, 6176, 2485, 6174, 2487, 6172, 2489, 6170, 2491, 6168, 2493, 6166, 2495, 6164, 2497, 6162, 2499, 6160, 2501, 6158, 2503, 6156, 2505, 6154, 2507, 6152, 2509, 6150, 2511, 6148, 2513, 6146, 2515, 6144, 2517, 6142, 2519, 6140, 2521, 6138, 2523, 6136, 2525, 6134, 2527, 6132, 2529, 6130, 2531, 6128, 2533, 6126, 2535, 6124, 2537, 6122, 2539, 6120, 2541, 6118, 2543, 6116, 2545, 6114, 2547, 6112, 2549, 6110, 2551, 6108, 2553, 6106, 2555, 6104, 2557, 6102, 2559, 6100, 2561, 6098, 2563, 6096, 2565, 6094, 2567, 6092, 2569, 6090, 2571, 6088, 2573, 6086, 2575, 6084, 2577, 6082, 2579, 6080, 2581, 6078, 2583, 6076, 2585, 6074, 2587, 6072, 2589, 6070, 2591, 6068, 2593, 6066, 2595, 6064, 2597, 6062, 2599, 6060, 2601, 6058, 2603, 6056, 2605, 6054, 2607, 6052, 2609, 6050, 2611, 6048, 2613, 6046, 2615, 6044, 2617, 6042, 2619, 6040, 2621, 6038, 2623, 6036, 2625, 6034, 2627, 6032, 2629, 6030, 2631, 6028, 2633, 6026, 2635, 6024, 2637, 6022, 2639, 6020, 2641, 6018, 2643, 6016, 2645, 6014, 2647, 6012, 2649, 6010, 2651, 6008, 2653, 6006, 2655, 6004, 2657, 6002, 2659, 6000, 2661, 5998, 2663, 5996, 2665, 5994, 2667, 5992, 2669, 5990, 2671, 5988, 2673, 5986, 2675, 5984, 2677, 5982, 2679, 5980, 2681, 5978, 2683, 5976, 2685, 5974, 2687, 5972, 2689, 5970, 2691, 5968, 2693, 5966, 2695, 5964, 2697, 5962, 2699, 5960, 2701, 5958, 2703, 5956, 2705, 5954, 2707, 5952, 2709, 5950, 2711, 5948, 2713, 5946, 2715, 5944, 2717, 5942, 2719, 5940, 2721, 5938, 2723, 5936, 2725, 5934, 2727, 5932, 2729, 5930, 2731, 5928, 2733, 5926, 2735, 5924, 2737, 5922, 2739, 5920, 2741, 5918, 2743, 5916, 2745, 5914, 2747, 5912, 2749, 5910, 2751, 5908, 2753, 5906, 2755, 5904, 2757, 5902, 2759, 5900, 2761, 5898, 2763, 5896, 2765, 5894, 2767, 5892, 2769, 5890, 2771, 5888, 2773, 5886, 2775, 5884, 2777, 5882, 2779, 5880, 2781, 5878, 2783, 5876, 2785, 5874, 2787, 5872, 2789, 5870, 2791, 5868, 2793, 5866, 2795, 5864, 2797, 5862, 2799, 5860, 2801, 5858, 2803, 5856, 2805, 5854, 2807, 5852, 2809, 5850, 2811, 5848, 2813, 5846, 2815, 5844, 2817, 5842, 2819, 5840, 2821, 5838, 2823, 5836, 2825, 5834, 2827, 5832, 2829, 5830, 2831, 5828, 2833, 5826, 2835, 5824, 2837, 5822, 2839, 5820, 2841, 5818, 2843, 5816, 2845, 5814, 2847, 5812, 2849, 5810, 2851, 5808, 2853, 5806, 2855, 5804, 2857, 5802, 2859, 5800, 2861, 5798, 2863, 5796, 2865, 5794, 2867, 5792, 2869, 5790, 2871, 5788, 2873, 5786, 2875, 5784, 2877, 5782, 2879, 5780, 2881, 5778, 2883, 5776, 2885, 5774, 2887, 5772, 2889, 5770, 2891, 5768, 2893, 5766, 2895, 5764, 2897, 5762, 2899, 5760, 2901, 5758, 2903, 5756, 2905, 5754, 2907, 5752, 2909, 5750, 2911, 5748, 2913, 5746, 2915, 5744, 2917, 5742, 2919, 5740, 2921, 5738, 2923, 5736, 2925, 5734, 2927, 5732, 2929, 5730, 2931, 5728, 2933, 5726, 2935, 5724, 2937, 5722, 2939, 5720, 2941, 5718, 2943, 5716, 2945, 5714, 2947, 5712, 2949, 5710, 2951, 5708, 2953, 5706, 2955, 5704, 2957, 5702, 2959, 5700, 2961, 5698, 2963, 5696, 2965, 5694, 2967, 5692, 2969, 5690, 2971, 5688, 2973, 5686, 2975, 5684, 2977, 5682, 2979, 5680, 2981, 5678, 2983, 5676, 2985, 5674, 2987, 5672, 2989, 5670, 2991, 5668, 2993, 5666, 2995, 5664, 2997, 5662, 2999, 5660, 3001, 5658, 3003, 5656, 3005, 5654, 3007, 5652, 3009, 5650, 3011, 5648, 3013, 5646, 3015, 5644, 3017, 5642, 3019, 5640, 3021, 5638, 3023, 5636, 3025, 5634, 3027, 5632, 3029, 5630, 3031, 5628, 3033, 5626, 3035, 5624, 3037, 5622, 3039, 5620, 3041, 5618, 3043, 5616, 3045, 5614, 3047, 5612, 3049, 5610, 3051, 5608, 3053, 5606, 3055, 5604, 3057, 5602, 3059, 5600, 3061, 5598, 3063, 5596, 3065, 5594, 3067, 5592, 3069, 5590, 3071, 5588, 3073, 5586, 3075, 5584, 3077, 5582, 3079, 5580, 3081, 5578, 3083, 5576, 3085, 5574, 3087, 5572, 3089, 5570, 3091, 5568, 3093, 5566, 3095, 5564, 3097, 5562, 3099, 5560, 3101, 5558, 3103, 5556, 3105, 5554, 3107, 5552, 3109, 5550, 3111, 5548, 3113, 5546, 3115, 5544, 3117, 5542, 3119, 5540, 3121, 5538, 3123, 5536, 3125, 5534, 3127, 5532, 3129, 5530, 3131, 5528, 3133, 5526, 3135, 5524, 3137, 5522, 3139, 5520, 3141, 5518, 3143, 5516, 3145, 5514, 3147, 5512, 3149, 5510, 3151, 5508, 3153, 5506, 3155, 5504, 3157, 5502, 3159, 5500, 3161, 5498, 3163, 5496, 3165, 5494, 3167, 5492, 3169, 5490, 3171, 5488, 3173, 5486, 3175, 5484, 3177, 5482, 3179, 5480, 3181, 5478, 3183, 5476, 3185, 5474, 3187, 5472, 3189, 5470, 3191, 5468, 3193, 5466, 3195, 5464, 3197, 5462, 3199, 5460, 3201, 5458, 3203, 5456, 3205, 5454, 3207, 5452, 3209, 5450, 3211, 5448, 3213, 5446, 3215, 5444, 3217, 5442, 3219, 5440, 3221, 5438, 3223, 5436, 3225, 5434, 3227, 5432, 3229, 5430, 3231, 5428, 3233, 5426, 3235, 5424, 3237, 5422, 3239, 5420, 3241, 5418, 3243, 5416, 3245, 5414, 3247, 5412, 3249, 5410, 3251, 5408, 3253, 5406, 3255, 5404, 3257, 5402, 3259, 5400, 3261, 5398, 3263, 5396, 3265, 5394, 3267, 5392, 3269, 5390, 3271, 5388, 3273, 5386, 3275, 5384, 3277, 5382, 3279, 5380, 3281, 5378, 3283, 5376, 3285, 5374, 3287, 5372, 3289, 5370, 3291, 5368, 3293, 5366, 3295, 5364, 3297, 5362, 3299, 5360, 3301, 5358, 3303, 5356, 3305, 5354, 3307, 5352, 3309, 5350, 3311, 5348, 3313, 5346, 3315, 5344, 3317, 5342, 3319, 5340, 3321, 5338, 3323, 5336, 3325, 5334, 3327, 5332, 3329, 5330, 3331, 5328, 3333, 5326, 3335, 5324, 3337, 5322, 3339, 5320, 3341, 5318, 3343, 5316, 3345, 5314, 3347, 5312, 3349, 5310, 3351, 5308, 3353, 5306, 3355, 5304, 3357, 5302, 3359, 5300, 3361, 5298, 3363, 5296, 3365, 5294, 3367, 5292, 3369, 5290, 3371, 5288, 3373, 5286, 3375, 5284, 3377, 5282, 3379, 5280, 3381, 5278, 3383, 5276, 3385, 5274, 3387, 5272, 3389, 5270, 3391, 5268, 3393, 5266, 3395, 5264, 3397, 5262, 3399, 5260, 3401, 5258, 3403, 5256, 3405, 5254, 3407, 5252, 3409, 5250, 3411, 5248, 3413, 5246, 3415, 5244, 3417, 5242, 3419, 5240, 3421, 5238, 3423, 5236, 3425, 5234, 3427, 5232, 3429, 5230, 3431, 5228, 3433, 5226, 3435, 5224, 3437, 5222, 3439, 5220, 3441, 5218, 3443, 5216, 3445, 5214, 3447, 5212, 3449, 5210, 3451, 5208, 3453, 5206, 3455, 5204, 3457, 5202, 3459, 5200, 3461, 5198, 3463, 5196, 3465, 5194, 3467, 5192, 3469, 5190, 3471, 5188, 3473, 5186, 3475, 5184, 3477, 5182, 3479, 5180, 3481, 5178, 3483, 5176, 3485, 5174, 3487, 5172, 3489, 5170, 3491, 5168, 3493, 5166, 3495, 5164, 3497, 5162, 3499, 5160, 3501, 5158, 3503, 5156, 3505, 5154, 3507, 5152, 3509, 5150, 3511, 5148, 3513, 5146, 3515, 5144, 3517, 5142, 3519, 5140, 3521, 5138, 3523, 5136, 3525, 5134, 3527, 5132, 3529, 5130, 3531, 5128, 3533, 5126, 3535, 5124, 3537, 5122, 3539, 5120, 3541, 5118, 3543, 5116, 3545, 5114, 3547, 5112, 3549, 5110, 3551, 5108, 3553, 5106, 3555, 5104, 3557, 5102, 3559, 5100, 3561, 5098, 3563, 5096, 3565, 5094, 3567, 5092, 3569, 5090, 3571, 5088, 3573, 5086, 3575, 5084, 3577, 5082, 3579, 5080, 3581, 5078, 3583, 5076, 3585, 5074, 3587, 5072, 3589, 5070, 3591, 5068, 3593, 5066, 3595, 5064, 3597, 5062, 3599, 5060, 3601, 5058, 3603, 5056, 3605, 5054, 3607, 5052, 3609, 5050, 3611, 5048, 3613, 5046, 3615, 5044, 3617, 5042, 3619, 5040, 3621, 5038, 3623, 5036, 3625, 5034, 3627, 5032, 3629, 5030, 3631, 5028, 3633, 5026, 3635, 5024, 3637, 5022, 3639, 5020, 3641, 5018, 3643, 5016, 3645, 5014, 3647, 5012, 3649, 5010, 3651, 5008, 3653, 5006, 3655, 5004, 3657, 5002, 3659, 5000, 3661, 4998, 3663, 4996, 3665, 4994, 3667, 4992, 3669, 4990, 3671, 4988, 3673, 4986, 3675, 4984, 3677, 4982, 3679, 4980, 3681, 4978, 3683, 4976, 3685, 4974, 3687, 4972, 3689, 4970, 3691, 4968, 3693, 4966, 3695, 4964, 3697, 4962, 3699, 4960, 3701, 4958, 3703, 4956, 3705, 4954, 3707, 4952, 3709, 4950, 3711, 4948, 3713, 4946, 3715, 4944, 3717, 4942, 3719, 4940, 3721, 4938, 3723, 4936, 3725, 4934, 3727, 4932, 3729, 4930, 3731, 4928, 3733, 4926, 3735, 4924, 3737, 4922, 3739, 4920, 3741, 4918, 3743, 4916, 3745, 4914, 3747, 4912, 3749, 4910, 3751, 4908, 3753, 4906, 3755, 4904, 3757, 4902, 3759, 4900, 3761, 4898, 3763, 4896, 3765, 4894, 3767, 4892, 3769, 4890, 3771, 4888, 3773, 4886, 3775, 4884, 3777, 4882, 3779, 4880, 3781, 4878, 3783, 4876, 3785, 4874, 3787, 4872, 3789, 4870, 3791, 4868, 3793, 4866, 3795, 4864, 3797, 4862, 3799, 4860, 3801, 4858, 3803, 4856, 3805, 4854, 3807, 4852, 3809, 4850, 3811, 4848, 3813, 4846, 3815, 4844, 3817, 4842, 3819, 4840, 3821, 4838, 3823, 4836, 3825, 4834, 3827, 4832, 3829, 4830, 3831, 4828, 3833, 4826, 3835, 4824, 3837, 4822, 3839, 4820, 3841, 4818, 3843, 4816, 3845, 4814, 3847, 4812, 3849, 4810, 3851, 4808, 3853, 4806, 3855, 4804, 3857, 4802, 3859, 4800, 3861, 4798, 3863, 4796, 3865, 4794, 3867, 4792, 3869, 4790, 3871, 4788, 3873, 4786, 3875, 4784, 3877, 4782, 3879, 4780, 3881, 4778, 3883, 4776, 3885, 4774, 3887, 4772, 3889, 4770, 3891, 4768, 3893, 4766, 3895, 4764, 3897, 4762, 3899, 4760, 3901, 4758, 3903, 4756, 3905, 4754, 3907, 4752, 3909, 4750, 3911, 4748, 3913, 4746, 3915, 4744, 3917, 4742, 3919, 4740, 3921, 4738, 3923, 4736, 3925, 4734, 3927, 4732, 3929, 4730, 3931, 4728, 3933, 4726, 3935, 4724, 3937, 4722, 3939, 4720, 3941, 4718, 3943, 4716, 3945, 4714, 3947, 4712, 3949, 4710, 3951, 4708, 3953, 4706, 3955, 4704, 3957, 4702, 3959, 4700, 3961, 4698, 3963, 4696, 3965, 4694, 3967, 4692, 3969, 4690, 3971, 4688, 3973, 4686, 3975, 4684, 3977, 4682, 3979, 4680, 3981, 4678, 3983, 4676, 3985, 4674, 3987, 4672, 3989, 4670, 3991, 4668, 3993, 4666, 3995, 4664, 3997, 4662, 3999, 4660, 4001, 4658, 4003, 4656, 4005, 4654, 4007, 4652, 4009, 4650, 4011, 4648, 4013, 4646, 4015, 4644, 4017, 4642, 4019, 4640, 4021, 4638, 4023, 4636, 4025, 4634, 4027, 4632, 4029, 4630, 4031, 4628, 4033, 4626, 4035, 4624, 4037, 4622, 4039, 4620, 4041, 4618, 4043, 4616, 4045, 4614, 4047, 4612, 4049, 4610, 4051, 4608, 4053, 4606, 4055, 4604, 4057, 4602, 4059, 4600, 4061, 4598, 4063, 4596, 4065, 4594, 4067, 4592, 4069, 4590, 4071, 4588, 4073, 4586, 4075, 4584, 4077, 4582, 4079, 4580, 4081, 4578, 4083, 4576, 4085, 4574, 4087, 4572, 4089, 4570, 4091, 4568, 4093, 4566, 4095, 4564, 4097, 4562, 4099, 4560, 4101, 4558, 4103, 4556, 4105, 4554, 4107, 4552, 4109, 4550, 4111, 4548, 4113, 4546, 4115, 4544, 4117, 4542, 4119, 4540, 4121, 4538, 4123, 4536, 4125, 4534, 4127, 4532, 4129, 4530, 4131, 4528, 4133, 4526, 4135, 4524, 4137, 4522, 4139, 4520, 4141, 4518, 4143, 4516, 4145, 4514, 4147, 4512, 4149, 4510, 4151, 4508, 4153, 4506, 4155, 4504, 4157, 4502, 4159, 4500, 4161, 4498, 4163, 4496, 4165, 4494, 4167, 4492, 4169, 4490, 4171, 4488, 4173, 4486, 4175, 4484, 4177, 4482, 4179, 4480, 4181, 4478, 4183, 4476, 4185, 4474, 4187, 4472, 4189, 4470, 4191, 4468, 4193, 4466, 4195, 4464, 4197, 4462, 4199, 4460, 4201, 4458, 4203, 4456, 4205, 4454, 4207, 4452, 4209, 4450, 4211, 4448, 4213, 4446, 4215, 4444, 4217, 4442, 4219, 4440, 4221, 4438, 4223, 4436, 4225, 4434, 4227, 4432, 4229, 4430, 4231, 4428, 4233, 4426, 4235, 4424, 4237, 4422, 4239, 4420, 4241, 4418, 4243, 4416, 4245, 4414, 4247, 4412, 4249, 4410, 4251, 4408, 4253, 4406, 4255, 4404, 4257, 4402, 4259, 4400, 4261, 4398, 4263, 4396, 4265, 4394, 4267, 4392, 4269, 4390, 4271, 4388, 4273, 4386, 4275, 4384, 4277, 4382, 4279, 4380, 4281, 4378, 4283, 4376, 4285, 4374, 4287, 4372, 4289, 4370, 4291, 4368, 4293, 4366, 4295, 4364, 4297, 4362, 4299, 4360, 4301, 4358, 4303, 4356, 4305, 4354, 4307, 4352, 4309, 4350, 4311, 4348, 4313, 4346, 4315, 4344, 4317, 4342, 4319, 4340, 4321, 4338, 4323, 4336, 4325, 4334, 4327, 4332, 4329, 4330, 4331, 4328, 4333, 4326, 4335, 4324, 4337, 4322, 4339, 4320, 4341, 4318, 4343, 4316, 4345, 4314, 4347, 4312, 4349, 4310, 4351, 4308, 4353, 4306, 4355, 4304, 4357, 4302, 4359, 4300, 4361, 4298, 4363, 4296, 4365, 4294, 4367, 4292, 4369, 4290, 4371, 4288, 4373, 4286, 4375, 4284, 4377, 4282, 4379, 4280, 4381, 4278, 4383, 4276, 4385, 4274, 4387, 4272, 4389, 4270, 4391, 4268, 4393, 4266, 4395, 4264, 4397, 4262, 4399, 4260, 4401, 4258, 4403, 4256, 4405, 4254, 4407, 4252, 4409, 4250, 4411, 4248, 4413, 4246, 4415, 4244, 4417, 4242, 4419, 4240, 4421, 4238, 4423, 4236, 4425, 4234, 4427, 4232, 4429, 4230, 4431, 4228, 4433, 4226, 4435, 4224, 4437, 4222, 4439, 4220, 4441, 4218, 4443, 4216, 4445, 4214, 4447, 4212, 4449, 4210, 4451, 4208, 4453, 4206, 4455, 4204, 4457, 4202, 4459, 4200, 4461, 4198, 4463, 4196, 4465, 4194, 4467, 4192, 4469, 4190, 4471, 4188, 4473, 4186, 4475, 4184, 4477, 4182, 4479, 4180, 4481, 4178, 4483, 4176, 4485, 4174, 4487, 4172, 4489, 4170, 4491, 4168, 4493, 4166, 4495, 4164, 4497, 4162, 4499, 4160, 4501, 4158, 4503, 4156, 4505, 4154, 4507, 4152, 4509, 4150, 4511, 4148, 4513, 4146, 4515, 4144, 4517, 4142, 4519, 4140, 4521, 4138, 4523, 4136, 4525, 4134, 4527, 4132, 4529, 4130, 4531, 4128, 4533, 4126, 4535, 4124, 4537, 4122, 4539, 4120, 4541, 4118, 4543, 4116, 4545, 4114, 4547, 4112, 4549, 4110, 4551, 4108, 4553, 4106, 4555, 4104, 4557, 4102, 4559, 4100, 4561, 4098, 4563, 4096, 4565, 4094, 4567, 4092, 4569, 4090, 4571, 4088, 4573, 4086, 4575, 4084, 4577, 4082, 4579, 4080, 4581, 4078, 4583, 4076, 4585, 4074, 4587, 4072, 4589, 4070, 4591, 4068, 4593, 4066, 4595, 4064, 4597, 4062, 4599, 4060, 4601, 4058, 4603, 4056, 4605, 4054, 4607, 4052, 4609, 4050, 4611, 4048, 4613, 4046, 4615, 4044, 4617, 4042, 4619, 4040, 4621, 4038, 4623, 4036, 4625, 4034, 4627, 4032, 4629, 4030, 4631, 4028, 4633, 4026, 4635, 4024, 4637, 4022, 4639, 4020, 4641, 4018, 4643, 4016, 4645, 4014, 4647, 4012, 4649, 4010, 4651, 4008, 4653, 4006, 4655, 4004, 4657, 4002, 4659, 4000, 4661, 3998, 4663, 3996, 4665, 3994, 4667, 3992, 4669, 3990, 4671, 3988, 4673, 3986, 4675, 3984, 4677, 3982, 4679, 3980, 4681, 3978, 4683, 3976, 4685, 3974, 4687, 3972, 4689, 3970, 4691, 3968, 4693, 3966, 4695, 3964, 4697, 3962, 4699, 3960, 4701, 3958, 4703, 3956, 4705, 3954, 4707, 3952, 4709, 3950, 4711, 3948, 4713, 3946, 4715, 3944, 4717, 3942, 4719, 3940, 4721, 3938, 4723, 3936, 4725, 3934, 4727, 3932, 4729, 3930, 4731, 3928, 4733, 3926, 4735, 3924, 4737, 3922, 4739, 3920, 4741, 3918, 4743, 3916, 4745, 3914, 4747, 3912, 4749, 3910, 4751, 3908, 4753, 3906, 4755, 3904, 4757, 3902, 4759, 3900, 4761, 3898, 4763, 3896, 4765, 3894, 4767, 3892, 4769, 3890, 4771, 3888, 4773, 3886, 4775, 3884, 4777, 3882, 4779, 3880, 4781, 3878, 4783, 3876, 4785, 3874, 4787, 3872, 4789, 3870, 4791, 3868, 4793, 3866, 4795, 3864, 4797, 3862, 4799, 3860, 4801, 3858, 4803, 3856, 4805, 3854, 4807, 3852, 4809, 3850, 4811, 3848, 4813, 3846, 4815, 3844, 4817, 3842, 4819, 3840, 4821, 3838, 4823, 3836, 4825, 3834, 4827, 3832, 4829, 3830, 4831, 3828, 4833, 3826, 4835, 3824, 4837, 3822, 4839, 3820, 4841, 3818, 4843, 3816, 4845, 3814, 4847, 3812, 4849, 3810, 4851, 3808, 4853, 3806, 4855, 3804, 4857, 3802, 4859, 3800, 4861, 3798, 4863, 3796, 4865, 3794, 4867, 3792, 4869, 3790, 4871, 3788, 4873, 3786, 4875, 3784, 4877, 3782, 4879, 3780, 4881, 3778, 4883, 3776, 4885, 3774, 4887, 3772, 4889, 3770, 4891, 3768, 4893, 3766, 4895, 3764, 4897, 3762, 4899, 3760, 4901, 3758, 4903, 3756, 4905, 3754, 4907, 3752, 4909, 3750, 4911, 3748, 4913, 3746, 4915, 3744, 4917, 3742, 4919, 3740, 4921, 3738, 4923, 3736, 4925, 3734, 4927, 3732, 4929, 3730, 4931, 3728, 4933, 3726, 4935, 3724, 4937, 3722, 4939, 3720, 4941, 3718, 4943, 3716, 4945, 3714, 4947, 3712, 4949, 3710, 4951, 3708, 4953, 3706, 4955, 3704, 4957, 3702, 4959, 3700, 4961, 3698, 4963, 3696, 4965, 3694, 4967, 3692, 4969, 3690, 4971, 3688, 4973, 3686, 4975, 3684, 4977, 3682, 4979, 3680, 4981, 3678, 4983, 3676, 4985, 3674, 4987, 3672, 4989, 3670, 4991, 3668, 4993, 3666, 4995, 3664, 4997, 3662, 4999, 3660, 5001, 3658, 5003, 3656, 5005, 3654, 5007, 3652, 5009, 3650, 5011, 3648, 5013, 3646, 5015, 3644, 5017, 3642, 5019, 3640, 5021, 3638, 5023, 3636, 5025, 3634, 5027, 3632, 5029, 3630, 5031, 3628, 5033, 3626, 5035, 3624, 5037, 3622, 5039, 3620, 5041, 3618, 5043, 3616, 5045, 3614, 5047, 3612, 5049, 3610, 5051, 3608, 5053, 3606, 5055, 3604, 5057, 3602, 5059, 3600, 5061, 3598, 5063, 3596, 5065, 3594, 5067, 3592, 5069, 3590, 5071, 3588, 5073, 3586, 5075, 3584, 5077, 3582, 5079, 3580, 5081, 3578, 5083, 3576, 5085, 3574, 5087, 3572, 5089, 3570, 5091, 3568, 5093, 3566, 5095, 3564, 5097, 3562, 5099, 3560, 5101, 3558, 5103, 3556, 5105, 3554, 5107, 3552, 5109, 3550, 5111, 3548, 5113, 3546, 5115, 3544, 5117, 3542, 5119, 3540, 5121, 3538, 5123, 3536, 5125, 3534, 5127, 3532, 5129, 3530, 5131, 3528, 5133, 3526, 5135, 3524, 5137, 3522, 5139, 3520, 5141, 3518, 5143, 3516, 5145, 3514, 5147, 3512, 5149, 3510, 5151, 3508, 5153, 3506, 5155, 3504, 5157, 3502, 5159, 3500, 5161, 3498, 5163, 3496, 5165, 3494, 5167, 3492, 5169, 3490, 5171, 3488, 5173, 3486, 5175, 3484, 5177, 3482, 5179, 3480, 5181, 3478, 5183, 3476, 5185, 3474, 5187, 3472, 5189, 3470, 5191, 3468, 5193, 3466, 5195, 3464, 5197, 3462, 5199, 3460, 5201, 3458, 5203, 3456, 5205, 3454, 5207, 3452, 5209, 3450, 5211, 3448, 5213, 3446, 5215, 3444, 5217, 3442, 5219, 3440, 5221, 3438, 5223, 3436, 5225, 3434, 5227, 3432, 5229, 3430, 5231, 3428, 5233, 3426, 5235, 3424, 5237, 3422, 5239, 3420, 5241, 3418, 5243, 3416, 5245, 3414, 5247, 3412, 5249, 3410, 5251, 3408, 5253, 3406, 5255, 3404, 5257, 3402, 5259, 3400, 5261, 3398, 5263, 3396, 5265, 3394, 5267, 3392, 5269, 3390, 5271, 3388, 5273, 3386, 5275, 3384, 5277, 3382, 5279, 3380, 5281, 3378, 5283, 3376, 5285, 3374, 5287, 3372, 5289, 3370, 5291, 3368, 5293, 3366, 5295, 3364, 5297, 3362, 5299, 3360, 5301, 3358, 5303, 3356, 5305, 3354, 5307, 3352, 5309, 3350, 5311, 3348, 5313, 3346, 5315, 3344, 5317, 3342, 5319, 3340, 5321, 3338, 5323, 3336, 5325, 3334, 5327, 3332, 5329, 3330, 5331, 3328, 5333, 3326, 5335, 3324, 5337, 3322, 5339, 3320, 5341, 3318, 5343, 3316, 5345, 3314, 5347, 3312, 5349, 3310, 5351, 3308, 5353, 3306, 5355, 3304, 5357, 3302, 5359, 3300, 5361, 3298, 5363, 3296, 5365, 3294, 5367, 3292, 5369, 3290, 5371, 3288, 5373, 3286, 5375, 3284, 5377, 3282, 5379, 3280, 5381, 3278, 5383, 3276, 5385, 3274, 5387, 3272, 5389, 3270, 5391, 3268, 5393, 3266, 5395, 3264, 5397, 3262, 5399, 3260, 5401, 3258, 5403, 3256, 5405, 3254, 5407, 3252, 5409, 3250, 5411, 3248, 5413, 3246, 5415, 3244, 5417, 3242, 5419, 3240, 5421, 3238, 5423, 3236, 5425, 3234, 5427, 3232, 5429, 3230, 5431, 3228, 5433, 3226, 5435, 3224, 5437, 3222, 5439, 3220, 5441, 3218, 5443, 3216, 5445, 3214, 5447, 3212, 5449, 3210, 5451, 3208, 5453, 3206, 5455, 3204, 5457, 3202, 5459, 3200, 5461, 3198, 5463, 3196, 5465, 3194, 5467, 3192, 5469, 3190, 5471, 3188, 5473, 3186, 5475, 3184, 5477, 3182, 5479, 3180, 5481, 3178, 5483, 3176, 5485, 3174, 5487, 3172, 5489, 3170, 5491, 3168, 5493, 3166, 5495, 3164, 5497, 3162, 5499, 3160, 5501, 3158, 5503, 3156, 5505, 3154, 5507, 3152, 5509, 3150, 5511, 3148, 5513, 3146, 5515, 3144, 5517, 3142, 5519, 3140, 5521, 3138, 5523, 3136, 5525, 3134, 5527, 3132, 5529, 3130, 5531, 3128, 5533, 3126, 5535, 3124, 5537, 3122, 5539, 3120, 5541, 3118, 5543, 3116, 5545, 3114, 5547, 3112, 5549, 3110, 5551, 3108, 5553, 3106, 5555, 3104, 5557, 3102, 5559, 3100, 5561, 3098, 5563, 3096, 5565, 3094, 5567, 3092, 5569, 3090, 5571, 3088, 5573, 3086, 5575, 3084, 5577, 3082, 5579, 3080, 5581, 3078, 5583, 3076, 5585, 3074, 5587, 3072, 5589, 3070, 5591, 3068, 5593, 3066, 5595, 3064, 5597, 3062, 5599, 3060, 5601, 3058, 5603, 3056, 5605, 3054, 5607, 3052, 5609, 3050, 5611, 3048, 5613, 3046, 5615, 3044, 5617, 3042, 5619, 3040, 5621, 3038, 5623, 3036, 5625, 3034, 5627, 3032, 5629, 3030, 5631, 3028, 5633, 3026, 5635, 3024, 5637, 3022, 5639, 3020, 5641, 3018, 5643, 3016, 5645, 3014, 5647, 3012, 5649, 3010, 5651, 3008, 5653, 3006, 5655, 3004, 5657, 3002, 5659, 3000, 5661, 2998, 5663, 2996, 5665, 2994, 5667, 2992, 5669, 2990, 5671, 2988, 5673, 2986, 5675, 2984, 5677, 2982, 5679, 2980, 5681, 2978, 5683, 2976, 5685, 2974, 5687, 2972, 5689, 2970, 5691, 2968, 5693, 2966, 5695, 2964, 5697, 2962, 5699, 2960, 5701, 2958, 5703, 2956, 5705, 2954, 5707, 2952, 5709, 2950, 5711, 2948, 5713, 2946, 5715, 2944, 5717, 2942, 5719, 2940, 5721, 2938, 5723, 2936, 5725, 2934, 5727, 2932, 5729, 2930, 5731, 2928, 5733, 2926, 5735, 2924, 5737, 2922, 5739, 2920, 5741, 2918, 5743, 2916, 5745, 2914, 5747, 2912, 5749, 2910, 5751, 2908, 5753, 2906, 5755, 2904, 5757, 2902, 5759, 2900, 5761, 2898, 5763, 2896, 5765, 2894, 5767, 2892, 5769, 2890, 5771, 2888, 5773, 2886, 5775, 2884, 5777, 2882, 5779, 2880, 5781, 2878, 5783, 2876, 5785, 2874, 5787, 2872, 5789, 2870, 5791, 2868, 5793, 2866, 5795, 2864, 5797, 2862, 5799, 2860, 5801, 2858, 5803, 2856, 5805, 2854, 5807, 2852, 5809, 2850, 5811, 2848, 5813, 2846, 5815, 2844, 5817, 2842, 5819, 2840, 5821, 2838, 5823, 2836, 5825, 2834, 5827, 2832, 5829, 2830, 5831, 2828, 5833, 2826, 5835, 2824, 5837, 2822, 5839, 2820, 5841, 2818, 5843, 2816, 5845, 2814, 5847, 2812, 5849, 2810, 5851, 2808, 5853, 2806, 5855, 2804, 5857, 2802, 5859, 2800, 5861, 2798, 5863, 2796, 5865, 2794, 5867, 2792, 5869, 2790, 5871, 2788, 5873, 2786, 5875, 2784, 5877, 2782, 5879, 2780, 5881, 2778, 5883, 2776, 5885, 2774, 5887, 2772, 5889, 2770, 5891, 2768, 5893, 2766, 5895, 2764, 5897, 2762, 5899, 2760, 5901, 2758, 5903, 2756, 5905, 2754, 5907, 2752, 5909, 2750, 5911, 2748, 5913, 2746, 5915, 2744, 5917, 2742, 5919, 2740, 5921, 2738, 5923, 2736, 5925, 2734, 5927, 2732, 5929, 2730, 5931, 2728, 5933, 2726, 5935, 2724, 5937, 2722, 5939, 2720, 5941, 2718, 5943, 2716, 5945, 2714, 5947, 2712, 5949, 2710, 5951, 2708, 5953, 2706, 5955, 2704, 5957, 2702, 5959, 2700, 5961, 2698, 5963, 2696, 5965, 2694, 5967, 2692, 5969, 2690, 5971, 2688, 5973, 2686, 5975, 2684, 5977, 2682, 5979, 2680, 5981, 2678, 5983, 2676, 5985, 2674, 5987, 2672, 5989, 2670, 5991, 2668, 5993, 2666, 5995, 2664, 5997, 2662, 5999, 2660, 6001, 2658, 6003, 2656, 6005, 2654, 6007, 2652, 6009, 2650, 6011, 2648, 6013, 2646, 6015, 2644, 6017, 2642, 6019, 2640, 6021, 2638, 6023, 2636, 6025, 2634, 6027, 2632, 6029, 2630, 6031, 2628, 6033, 2626, 6035, 2624, 6037, 2622, 6039, 2620, 6041, 2618, 6043, 2616, 6045, 2614, 6047, 2612, 6049, 2610, 6051, 2608, 6053, 2606, 6055, 2604, 6057, 2602, 6059, 2600, 6061, 2598, 6063, 2596, 6065, 2594, 6067, 2592, 6069, 2590, 6071, 2588, 6073, 2586, 6075, 2584, 6077, 2582, 6079, 2580, 6081, 2578, 6083, 2576, 6085, 2574, 6087, 2572, 6089, 2570, 6091, 2568, 6093, 2566, 6095, 2564, 6097, 2562, 6099, 2560, 6101, 2558, 6103, 2556, 6105, 2554, 6107, 2552, 6109, 2550, 6111, 2548, 6113, 2546, 6115, 2544, 6117, 2542, 6119, 2540, 6121, 2538, 6123, 2536, 6125, 2534, 6127, 2532, 6129, 2530, 6131, 2528, 6133, 2526, 6135, 2524, 6137, 2522, 6139, 2520, 6141, 2518, 6143, 2516, 6145, 2514, 6147, 2512, 6149, 2510, 6151, 2508, 6153, 2506, 6155, 2504, 6157, 2502, 6159, 2500, 6161, 2498, 6163, 2496, 6165, 2494, 6167, 2492, 6169, 2490, 6171, 2488, 6173, 2486, 6175, 2484, 6177, 2482, 6179, 2480, 6181, 2478, 6183, 2476, 6185, 2474, 6187, 2472, 6189, 2470, 6191, 2468, 6193, 2466, 6195, 2464, 6197, 2462, 6199, 2460, 6201, 2458, 6203, 2456, 6205, 2454, 6207, 2452, 6209, 2450, 6211, 2448, 6213, 2446, 6215, 2444, 6217, 2442, 6219, 2440, 6221, 2438, 6223, 2436, 6225, 2434, 6227, 2432, 6229, 2430, 6231, 2428, 6233, 2426, 6235, 2424, 6237, 2422, 6239, 2420, 6241, 2418, 6243, 2416, 6245, 2414, 6247, 2412, 6249, 2410, 6251, 2408, 6253, 2406, 6255, 2404, 6257, 2402, 6259, 2400, 6261, 2398, 6263, 2396, 6265, 2394, 6267, 2392, 6269, 2390, 6271, 2388, 6273, 2386, 6275, 2384, 6277, 2382, 6279, 2380, 6281, 2378, 6283, 2376, 6285, 2374, 6287, 2372, 6289, 2370, 6291, 2368, 6293, 2366, 6295, 2364, 6297, 2362, 6299, 2360, 6301, 2358, 6303, 2356, 6305, 2354, 6307, 2352, 6309, 2350, 6311, 2348, 6313, 2346, 6315, 2344, 6317, 2342, 6319, 2340, 6321, 2338, 6323, 2336, 6325, 2334, 6327, 2332, 6329, 2330, 6331, 2328, 6333, 2326, 6335, 2324, 6337, 2322, 6339, 2320, 6341, 2318, 6343, 2316, 6345, 2314, 6347, 2312, 6349, 2310, 6351, 2308, 6353, 2306, 6355, 2304, 6357, 2302, 6359, 2300, 6361, 2298, 6363, 2296, 6365, 2294, 6367, 2292, 6369, 2290, 6371, 2288, 6373, 2286, 6375, 2284, 6377, 2282, 6379, 2280, 6381, 2278, 6383, 2276, 6385, 2274, 6387, 2272, 6389, 2270, 6391, 2268, 6393, 2266, 6395, 2264, 6397, 2262, 6399, 2260, 6401, 2258, 6403, 2256, 6405, 2254, 6407, 2252, 6409, 2250, 6411, 2248, 6413, 2246, 6415, 2244, 6417, 2242, 6419, 2240, 6421, 2238, 6423, 2236, 6425, 2234, 6427, 2232, 6429, 2230, 6431, 2228, 6433, 2226, 6435, 2224, 6437, 2222, 6439, 2220, 6441, 2218, 6443, 2216, 6445, 2214, 6447, 2212, 6449, 2210, 6451, 2208, 6453, 2206, 6455, 2204, 6457, 2202, 6459, 2200, 6461, 2198, 6463, 2196, 6465, 2194, 6467, 2192, 6469, 2190, 6471, 2188, 6473, 2186, 6475, 2184, 6477, 2182, 6479, 2180, 6481, 2178, 6483, 2176, 6485, 2174, 6487, 2172, 6489, 2170, 6491, 2168, 6493, 2166, 6495, 2164, 6497, 2162, 6499, 2160, 6501, 2158, 6503, 2156, 6505, 2154, 6507, 2152, 6509, 2150, 6511, 2148, 6513, 2146, 6515, 2144, 6517, 2142, 6519, 2140, 6521, 2138, 6523, 2136, 6525, 2134, 6527, 2132, 6529, 2130, 6531, 2128, 6533, 2126, 6535, 2124, 6537, 2122, 6539, 2120, 6541, 2118, 6543, 2116, 6545, 2114, 6547, 2112, 6549, 2110, 6551, 2108, 6553, 2106, 6555, 2104, 6557, 2102, 6559, 2100, 6561, 2098, 6563, 2096, 6565, 2094, 6567, 2092, 6569, 2090, 6571, 2088, 6573, 2086, 6575, 2084, 6577, 2082, 6579, 2080, 6581, 2078, 6583, 2076, 6585, 2074, 6587, 2072, 6589, 2070, 6591, 2068, 6593, 2066, 6595, 2064, 6597, 2062, 6599, 2060, 6601, 2058, 6603, 2056, 6605, 2054, 6607, 2052, 6609, 2050, 6611, 2048, 6613, 2046, 6615, 2044, 6617, 2042, 6619, 2040, 6621, 2038, 6623, 2036, 6625, 2034, 6627, 2032, 6629, 2030, 6631, 2028, 6633, 2026, 6635, 2024, 6637, 2022, 6639, 2020, 6641, 2018, 6643, 2016, 6645, 2014, 6647, 2012, 6649, 2010, 6651, 2008, 6653, 2006, 6655, 2004, 6657, 2002, 6659, 2000, 6661, 1998, 6663, 1996, 6665, 1994, 6667, 1992, 6669, 1990, 6671, 1988, 6673, 1986, 6675, 1984, 6677, 1982, 6679, 1980, 6681, 1978, 6683, 1976, 6685, 1974, 6687, 1972, 6689, 1970, 6691, 1968, 6693, 1966, 6695, 1964, 6697, 1962, 6699, 1960, 6701, 1958, 6703, 1956, 6705, 1954, 6707, 1952, 6709, 1950, 6711, 1948, 6713, 1946, 6715, 1944, 6717, 1942, 6719, 1940, 6721, 1938, 6723, 1936, 6725, 1934, 6727, 1932, 6729, 1930, 6731, 1928, 6733, 1926, 6735, 1924, 6737, 1922, 6739, 1920, 6741, 1918, 6743, 1916, 6745, 1914, 6747, 1912, 6749, 1910, 6751, 1908, 6753, 1906, 6755, 1904, 6757, 1902, 6759, 1900, 6761, 1898, 6763, 1896, 6765, 1894, 6767, 1892, 6769, 1890, 6771, 1888, 6773, 1886, 6775, 1884, 6777, 1882, 6779, 1880, 6781, 1878, 6783, 1876, 6785, 1874, 6787, 1872, 6789, 1870, 6791, 1868, 6793, 1866, 6795, 1864, 6797, 1862, 6799, 1860, 6801, 1858, 6803, 1856, 6805, 1854, 6807, 1852, 6809, 1850, 6811, 1848, 6813, 1846, 6815, 1844, 6817, 1842, 6819, 1840, 6821, 1838, 6823, 1836, 6825, 1834, 6827, 1832, 6829, 1830, 6831, 1828, 6833, 1826, 6835, 1824, 6837, 1822, 6839, 1820, 6841, 1818, 6843, 1816, 6845, 1814, 6847, 1812, 6849, 1810, 6851, 1808, 6853, 1806, 6855, 1804, 6857, 1802, 6859, 1800, 6861, 1798, 6863, 1796, 6865, 1794, 6867, 1792, 6869, 1790, 6871, 1788, 6873, 1786, 6875, 1784, 6877, 1782, 6879, 1780, 6881, 1778, 6883, 1776, 6885, 1774, 6887, 1772, 6889, 1770, 6891, 1768, 6893, 1766, 6895, 1764, 6897, 1762, 6899, 1760, 6901, 1758, 6903, 1756, 6905, 1754, 6907, 1752, 6909, 1750, 6911, 1748, 6913, 1746, 6915, 1744, 6917, 1742, 6919, 1740, 6921, 1738, 6923, 1736, 6925, 1734, 6927, 1732, 6929, 1730, 6931, 1728, 6933, 1726, 6935, 1724, 6937, 1722, 6939, 1720, 6941, 1718, 6943, 1716, 6945, 1714, 6947, 1712, 6949, 1710, 6951, 1708, 6953, 1706, 6955, 1704, 6957, 1702, 6959, 1700, 6961, 1698, 6963, 1696, 6965, 1694, 6967, 1692, 6969, 1690, 6971, 1688, 6973, 1686, 6975, 1684, 6977, 1682, 6979, 1680, 6981, 1678, 6983, 1676, 6985, 1674, 6987, 1672, 6989, 1670, 6991, 1668, 6993, 1666, 6995, 1664, 6997, 1662, 6999, 1660, 7001, 1658, 7003, 1656, 7005, 1654, 7007, 1652, 7009, 1650, 7011, 1648, 7013, 1646, 7015, 1644, 7017, 1642, 7019, 1640, 7021, 1638, 7023, 1636, 7025, 1634, 7027, 1632, 7029, 1630, 7031, 1628, 7033, 1626, 7035, 1624, 7037, 1622, 7039, 1620, 7041, 1618, 7043, 1616, 7045, 1614, 7047, 1612, 7049, 1610, 7051, 1608, 7053, 1606, 7055, 1604, 7057, 1602, 7059, 1600, 7061, 1598, 7063, 1596, 7065, 1594, 7067, 1592, 7069, 1590, 7071, 1588, 7073, 1586, 7075, 1584, 7077, 1582, 7079, 1580, 7081, 1578, 7083, 1576, 7085, 1574, 7087, 1572, 7089, 1570, 7091, 1568, 7093, 1566, 7095, 1564, 7097, 1562, 7099, 1560, 7101, 1558, 7103, 1556, 7105, 1554, 7107, 1552, 7109, 1550, 7111, 1548, 7113, 1546, 7115, 1544, 7117, 1542, 7119, 1540, 7121, 1538, 7123, 1536, 7125, 1534, 7127, 1532, 7129, 1530, 7131, 1528, 7133, 1526, 7135, 1524, 7137, 1522, 7139, 1520, 7141, 1518, 7143, 1516, 7145, 1514, 7147, 1512, 7149, 1510, 7151, 1508, 7153, 1506, 7155, 1504, 7157, 1502, 7159, 1500, 7161, 1498, 7163, 1496, 7165, 1494, 7167, 1492, 7169, 1490, 7171, 1488, 7173, 1486, 7175, 1484, 7177, 1482, 7179, 1480, 7181, 1478, 7183, 1476, 7185, 1474, 7187, 1472, 7189, 1470, 7191, 1468, 7193, 1466, 7195, 1464, 7197, 1462, 7199, 1460, 7201, 1458, 7203, 1456, 7205, 1454, 7207, 1452, 7209, 1450, 7211, 1448, 7213, 1446, 7215, 1444, 7217, 1442, 7219, 1440, 7221, 1438, 7223, 1436, 7225, 1434, 7227, 1432, 7229, 1430, 7231, 1428, 7233, 1426, 7235, 1424, 7237, 1422, 7239, 1420, 7241, 1418, 7243, 1416, 7245, 1414, 7247, 1412, 7249, 1410, 7251, 1408, 7253, 1406, 7255, 1404, 7257, 1402, 7259, 1400, 7261, 1398, 7263, 1396, 7265, 1394, 7267, 1392, 7269, 1390, 7271, 1388, 7273, 1386, 7275, 1384, 7277, 1382, 7279, 1380, 7281, 1378, 7283, 1376, 7285, 1374, 7287, 1372, 7289, 1370, 7291, 1368, 7293, 1366, 7295, 1364, 7297, 1362, 7299, 1360, 7301, 1358, 7303, 1356, 7305, 1354, 7307, 1352, 7309, 1350, 7311, 1348, 7313, 1346, 7315, 1344, 7317, 1342, 7319, 1340, 7321, 1338, 7323, 1336, 7325, 1334, 7327, 1332, 7329, 1330, 7331, 1328, 7333, 1326, 7335, 1324, 7337, 1322, 7339, 1320, 7341, 1318, 7343, 1316, 7345, 1314, 7347, 1312, 7349, 1310, 7351, 1308, 7353, 1306, 7355, 1304, 7357, 1302, 7359, 1300, 7361, 1298, 7363, 1296, 7365, 1294, 7367, 1292, 7369, 1290, 7371, 1288, 7373, 1286, 7375, 1284, 7377, 1282, 7379, 1280, 7381, 1278, 7383, 1276, 7385, 1274, 7387, 1272, 7389, 1270, 7391, 1268, 7393, 1266, 7395, 1264, 7397, 1262, 7399, 1260, 7401, 1258, 7403, 1256, 7405, 1254, 7407, 1252, 7409, 1250, 7411, 1248, 7413, 1246, 7415, 1244, 7417, 1242, 7419, 1240, 7421, 1238, 7423, 1236, 7425, 1234, 7427, 1232, 7429, 1230, 7431, 1228, 7433, 1226, 7435, 1224, 7437, 1222, 7439, 1220, 7441, 1218, 7443, 1216, 7445, 1214, 7447, 1212, 7449, 1210, 7451, 1208, 7453, 1206, 7455, 1204, 7457, 1202, 7459, 1200, 7461, 1198, 7463, 1196, 7465, 1194, 7467, 1192, 7469, 1190, 7471, 1188, 7473, 1186, 7475, 1184, 7477, 1182, 7479, 1180, 7481, 1178, 7483, 1176, 7485, 1174, 7487, 1172, 7489, 1170, 7491, 1168, 7493, 1166, 7495, 1164, 7497, 1162, 7499, 1160, 7501, 1158, 7503, 1156, 7505, 1154, 7507, 1152, 7509, 1150, 7511, 1148, 7513, 1146, 7515, 1144, 7517, 1142, 7519, 1140, 7521, 1138, 7523, 1136, 7525, 1134, 7527, 1132, 7529, 1130, 7531, 1128, 7533, 1126, 7535, 1124, 7537, 1122, 7539, 1120, 7541, 1118, 7543, 1116, 7545, 1114, 7547, 1112, 7549, 1110, 7551, 1108, 7553, 1106, 7555, 1104, 7557, 1102, 7559, 1100, 7561, 1098, 7563, 1096, 7565, 1094, 7567, 1092, 7569, 1090, 7571, 1088, 7573, 1086, 7575, 1084, 7577, 1082, 7579, 1080, 7581, 1078, 7583, 1076, 7585, 1074, 7587, 1072, 7589, 1070, 7591, 1068, 7593, 1066, 7595, 1064, 7597, 1062, 7599, 1060, 7601, 1058, 7603, 1056, 7605, 1054, 7607, 1052, 7609, 1050, 7611, 1048, 7613, 1046, 7615, 1044, 7617, 1042, 7619, 1040, 7621, 1038, 7623, 1036, 7625, 1034, 7627, 1032, 7629, 1030, 7631, 1028, 7633, 1026, 7635, 1024, 7637, 1022, 7639, 1020, 7641, 1018, 7643, 1016, 7645, 1014, 7647, 1012, 7649, 1010, 7651, 1008, 7653, 1006, 7655, 1004, 7657, 1002, 7659, 1000, 7661, 998, 7663, 996, 7665, 994, 7667, 992, 7669, 990, 7671, 988, 7673, 986, 7675, 984, 7677, 982, 7679, 980, 7681, 978, 7683, 976, 7685, 974, 7687, 972, 7689, 970, 7691, 968, 7693, 966, 7695, 964, 7697, 962, 7699, 960, 7701, 958, 7703, 956, 7705, 954, 7707, 952, 7709, 950, 7711, 948, 7713, 946, 7715, 944, 7717, 942, 7719, 940, 7721, 938, 7723, 936, 7725, 934, 7727, 932, 7729, 930, 7731, 928, 7733, 926, 7735, 924, 7737, 922, 7739, 920, 7741, 918, 7743, 916, 7745, 914, 7747, 912, 7749, 910, 7751, 908, 7753, 906, 7755, 904, 7757, 902, 7759, 900, 7761, 898, 7763, 896, 7765, 894, 7767, 892, 7769, 890, 7771, 888, 7773, 886, 7775, 884, 7777, 882, 7779, 880, 7781, 878, 7783, 876, 7785, 874, 7787, 872, 7789, 870, 7791, 868, 7793, 866, 7795, 864, 7797, 862, 7799, 860, 7801, 858, 7803, 856, 7805, 854, 7807, 852, 7809, 850, 7811, 848, 7813, 846, 7815, 844, 7817, 842, 7819, 840, 7821, 838, 7823, 836, 7825, 834, 7827, 832, 7829, 830, 7831, 828, 7833, 826, 7835, 824, 7837, 822, 7839, 820, 7841, 818, 7843, 816, 7845, 814, 7847, 812, 7849, 810, 7851, 808, 7853, 806, 7855, 804, 7857, 802, 7859, 800, 7861, 798, 7863, 796, 7865, 794, 7867, 792, 7869, 790, 7871, 788, 7873, 786, 7875, 784, 7877, 782, 7879, 780, 7881, 778, 7883, 776, 7885, 774, 7887, 772, 7889, 770, 7891, 768, 7893, 766, 7895, 764, 7897, 762, 7899, 760, 7901, 758, 7903, 756, 7905, 754, 7907, 752, 7909, 750, 7911, 748, 7913, 746, 7915, 744, 7917, 742, 7919, 740, 7921, 738, 7923, 736, 7925, 734, 7927, 732, 7929, 730, 7931, 728, 7933, 726, 7935, 724, 7937, 722, 7939, 720, 7941, 718, 7943, 716, 7945, 714, 7947, 712, 7949, 710, 7951, 708, 7953, 706, 7955, 704, 7957, 702, 7959, 700, 7961, 698, 7963, 696, 7965, 694, 7967, 692, 7969, 690, 7971, 688, 7973, 686, 7975, 684, 7977, 682, 7979, 680, 7981, 678, 7983, 676, 7985, 674, 7987, 672, 7989, 670, 7991, 668, 7993, 666, 7995, 664, 7997, 662, 7999, 660, 8001, 658, 8003, 656, 8005, 654, 8007, 652, 8009, 650, 8011, 648, 8013, 646, 8015, 644, 8017, 642, 8019, 640, 8021, 638, 8023, 636, 8025, 634, 8027, 632, 8029, 630, 8031, 628, 8033, 626, 8035, 624, 8037, 622, 8039, 620, 8041, 618, 8043, 616, 8045, 614, 8047, 612, 8049, 610, 8051, 608, 8053, 606, 8055, 604, 8057, 602, 8059, 600, 8061, 598, 8063, 596, 8065, 594, 8067, 592, 8069, 590, 8071, 588, 8073, 586, 8075, 584, 8077, 582, 8079, 580, 8081, 578, 8083, 576, 8085, 574, 8087, 572, 8089, 570, 8091, 568, 8093, 566, 8095, 564, 8097, 562, 8099, 560, 8101, 558, 8103, 556, 8105, 554, 8107, 552, 8109, 550, 8111, 548, 8113, 546, 8115, 544, 8117, 542, 8119, 540, 8121, 538, 8123, 536, 8125, 534, 8127, 532, 8129, 530, 8131, 528, 8133, 526, 8135, 524, 8137, 522, 8139, 520, 8141, 518, 8143, 516, 8145, 514, 8147, 512, 8149, 510, 8151, 508, 8153, 506, 8155, 504, 8157, 502, 8159, 500, 8161, 498, 8163, 496, 8165, 494, 8167, 492, 8169, 490, 8171, 488, 8173, 486, 8175, 484, 8177, 482, 8179, 480, 8181, 478, 8183, 476, 8185, 474, 8187, 472, 8189, 470, 8191, 468, 8193, 466, 8195, 464, 8197, 462, 8199, 460, 8201, 458, 8203, 456, 8205, 454, 8207, 452, 8209, 450, 8211, 448, 8213, 446, 8215, 444, 8217, 442, 8219, 440, 8221, 438, 8223, 436, 8225, 434, 8227, 432, 8229, 430, 8231, 428, 8233, 426, 8235, 424, 8237, 422, 8239, 420, 8241, 418, 8243, 416, 8245, 414, 8247, 412, 8249, 410, 8251, 408, 8253, 406, 8255, 404, 8257, 402, 8259, 400, 8261, 398, 8263, 396, 8265, 394, 8267, 392, 8269, 390, 8271, 388, 8273, 386, 8275, 384, 8277, 382, 8279, 380, 8281, 378, 8283, 376, 8285, 374, 8287, 372, 8289, 370, 8291, 368, 8293, 366, 8295, 364, 8297, 362, 8299, 360, 8301, 358, 8303, 356, 8305, 354, 8307, 352, 8309, 350, 8311, 348, 8313, 346, 8315, 344, 8317, 342, 8319, 340, 8321, 338, 8323, 336, 8325, 334, 8327, 332, 8329, 330, 8331, 328, 8333, 326, 8335, 324, 8337, 322, 8339, 320, 8341, 318, 8343, 316, 8345, 314, 8347, 312, 8349, 310, 8351, 308, 8353, 306, 8355, 304, 8357, 302, 8359, 300, 8361, 298, 8363, 296, 8365, 294, 8367, 292, 8369, 290, 8371, 288, 8373, 286, 8375, 284, 8377, 282, 8379, 280, 8381, 278, 8383, 276, 8385, 274, 8387, 272, 8389, 270, 8391, 268, 8393, 266, 8395, 264, 8397, 262, 8399, 260, 8401, 258, 8403, 256, 8405, 254, 8407, 252, 8409, 250, 8411, 248, 8413, 246, 8415, 244, 8417, 242, 8419, 240, 8421, 238, 8423, 236, 8425, 234, 8427, 232, 8429, 230, 8431, 228, 8433, 226, 8435, 224, 8437, 222, 8439, 220, 8441, 218, 8443, 216, 8445, 214, 8447, 212, 8449, 210, 8451, 208, 8453, 206, 8455, 204, 8457, 202, 8459, 200, 8461, 198, 8463, 196, 8465, 194, 8467, 192, 8469, 190, 8471, 188, 8473, 186, 8475, 184, 8477, 182, 8479, 180, 8481, 178, 8483, 176, 8485, 174, 8487, 172, 8489, 170, 8491, 168, 8493, 166, 8495, 164, 8497, 162, 8499, 160, 8501, 158, 8503, 156, 8505, 154, 8507, 152, 8509, 150, 8511, 148, 8513, 146, 8515, 144, 8517, 142, 8519, 140, 8521, 138, 8523, 136, 8525, 134, 8527, 132, 8529, 130, 8531, 128, 8533, 126, 8535, 124, 8537, 122, 8539, 120, 8541, 118, 8543, 116, 8545, 114, 8547, 112, 8549, 110, 8551, 108, 8553, 106, 8555, 104, 8557, 102, 8559, 100, 8561, 98, 8563, 96, 8565, 94, 8567, 92, 8569, 90, 8571, 88, 8573, 86, 8575, 84, 8577, 82, 8579, 80, 8581, 78, 8583, 76, 8585, 74, 8587, 72, 8589, 70, 8591, 68, 8593, 66, 8595, 64, 8597, 62, 8599, 60, 8601, 58, 8603, 56, 8605, 54, 8607, 52, 8609, 50, 8611, 48, 8613, 46, 8615, 44, 8617, 42, 8619, 40, 8621, 38, 8623, 36, 8625, 34, 8627, 32, 8629, 30, 8631, 28, 8633, 26, 8635, 24, 8637, 22, 8639, 20, 8641, 18, 8643, 16, 8645, 14, 8647, 12, 8649, 10, 8651, 8, 8653, 6, 8655, 4, 8657, 2, 8659]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l5-s9/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l5-s9/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l5-s9/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bbbaeb31d69181d24164f75dcd803d418a7ef63c --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 8660, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l5-s9/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l5-s9/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l6-s5/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l6-s5/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0aa8e5543a611a4e20b6f03b73b85d18549f90b0 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 20570, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s5/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0f3a9abb3dc2b246dc9349af94c6339501b8e27e --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [20570, 1, 20568, 3, 20566, 5, 20564, 7, 20562, 9, 20560, 11, 20558, 13, 20556, 15, 20554, 17, 20552, 19, 20550, 21, 20548, 23, 20546, 25, 20544, 27, 20542, 29, 20540, 31, 20538, 33, 20536, 35, 20534, 37, 20532, 39, 20530, 41, 20528, 43, 20526, 45, 20524, 47, 20522, 49, 20520, 51, 20518, 53, 20516, 55, 20514, 57, 20512, 59, 20510, 61, 20508, 63, 20506, 65, 20504, 67, 20502, 69, 20500, 71, 20498, 73, 20496, 75, 20494, 77, 20492, 79, 20490, 81, 20488, 83, 20486, 85, 20484, 87, 20482, 89, 20480, 91, 20478, 93, 20476, 95, 20474, 97, 20472, 99, 20470, 101, 20468, 103, 20466, 105, 20464, 107, 20462, 109, 20460, 111, 20458, 113, 20456, 115, 20454, 117, 20452, 119, 20450, 121, 20448, 123, 20446, 125, 20444, 127, 20442, 129, 20440, 131, 20438, 133, 20436, 135, 20434, 137, 20432, 139, 20430, 141, 20428, 143, 20426, 145, 20424, 147, 20422, 149, 20420, 151, 20418, 153, 20416, 155, 20414, 157, 20412, 159, 20410, 161, 20408, 163, 20406, 165, 20404, 167, 20402, 169, 20400, 171, 20398, 173, 20396, 175, 20394, 177, 20392, 179, 20390, 181, 20388, 183, 20386, 185, 20384, 187, 20382, 189, 20380, 191, 20378, 193, 20376, 195, 20374, 197, 20372, 199, 20370, 201, 20368, 203, 20366, 205, 20364, 207, 20362, 209, 20360, 211, 20358, 213, 20356, 215, 20354, 217, 20352, 219, 20350, 221, 20348, 223, 20346, 225, 20344, 227, 20342, 229, 20340, 231, 20338, 233, 20336, 235, 20334, 237, 20332, 239, 20330, 241, 20328, 243, 20326, 245, 20324, 247, 20322, 249, 20320, 251, 20318, 253, 20316, 255, 20314, 257, 20312, 259, 20310, 261, 20308, 263, 20306, 265, 20304, 267, 20302, 269, 20300, 271, 20298, 273, 20296, 275, 20294, 277, 20292, 279, 20290, 281, 20288, 283, 20286, 285, 20284, 287, 20282, 289, 20280, 291, 20278, 293, 20276, 295, 20274, 297, 20272, 299, 20270, 301, 20268, 303, 20266, 305, 20264, 307, 20262, 309, 20260, 311, 20258, 313, 20256, 315, 20254, 317, 20252, 319, 20250, 321, 20248, 323, 20246, 325, 20244, 327, 20242, 329, 20240, 331, 20238, 333, 20236, 335, 20234, 337, 20232, 339, 20230, 341, 20228, 343, 20226, 345, 20224, 347, 20222, 349, 20220, 351, 20218, 353, 20216, 355, 20214, 357, 20212, 359, 20210, 361, 20208, 363, 20206, 365, 20204, 367, 20202, 369, 20200, 371, 20198, 373, 20196, 375, 20194, 377, 20192, 379, 20190, 381, 20188, 383, 20186, 385, 20184, 387, 20182, 389, 20180, 391, 20178, 393, 20176, 395, 20174, 397, 20172, 399, 20170, 401, 20168, 403, 20166, 405, 20164, 407, 20162, 409, 20160, 411, 20158, 413, 20156, 415, 20154, 417, 20152, 419, 20150, 421, 20148, 423, 20146, 425, 20144, 427, 20142, 429, 20140, 431, 20138, 433, 20136, 435, 20134, 437, 20132, 439, 20130, 441, 20128, 443, 20126, 445, 20124, 447, 20122, 449, 20120, 451, 20118, 453, 20116, 455, 20114, 457, 20112, 459, 20110, 461, 20108, 463, 20106, 465, 20104, 467, 20102, 469, 20100, 471, 20098, 473, 20096, 475, 20094, 477, 20092, 479, 20090, 481, 20088, 483, 20086, 485, 20084, 487, 20082, 489, 20080, 491, 20078, 493, 20076, 495, 20074, 497, 20072, 499, 20070, 501, 20068, 503, 20066, 505, 20064, 507, 20062, 509, 20060, 511, 20058, 513, 20056, 515, 20054, 517, 20052, 519, 20050, 521, 20048, 523, 20046, 525, 20044, 527, 20042, 529, 20040, 531, 20038, 533, 20036, 535, 20034, 537, 20032, 539, 20030, 541, 20028, 543, 20026, 545, 20024, 547, 20022, 549, 20020, 551, 20018, 553, 20016, 555, 20014, 557, 20012, 559, 20010, 561, 20008, 563, 20006, 565, 20004, 567, 20002, 569, 20000, 571, 19998, 573, 19996, 575, 19994, 577, 19992, 579, 19990, 581, 19988, 583, 19986, 585, 19984, 587, 19982, 589, 19980, 591, 19978, 593, 19976, 595, 19974, 597, 19972, 599, 19970, 601, 19968, 603, 19966, 605, 19964, 607, 19962, 609, 19960, 611, 19958, 613, 19956, 615, 19954, 617, 19952, 619, 19950, 621, 19948, 623, 19946, 625, 19944, 627, 19942, 629, 19940, 631, 19938, 633, 19936, 635, 19934, 637, 19932, 639, 19930, 641, 19928, 643, 19926, 645, 19924, 647, 19922, 649, 19920, 651, 19918, 653, 19916, 655, 19914, 657, 19912, 659, 19910, 661, 19908, 663, 19906, 665, 19904, 667, 19902, 669, 19900, 671, 19898, 673, 19896, 675, 19894, 677, 19892, 679, 19890, 681, 19888, 683, 19886, 685, 19884, 687, 19882, 689, 19880, 691, 19878, 693, 19876, 695, 19874, 697, 19872, 699, 19870, 701, 19868, 703, 19866, 705, 19864, 707, 19862, 709, 19860, 711, 19858, 713, 19856, 715, 19854, 717, 19852, 719, 19850, 721, 19848, 723, 19846, 725, 19844, 727, 19842, 729, 19840, 731, 19838, 733, 19836, 735, 19834, 737, 19832, 739, 19830, 741, 19828, 743, 19826, 745, 19824, 747, 19822, 749, 19820, 751, 19818, 753, 19816, 755, 19814, 757, 19812, 759, 19810, 761, 19808, 763, 19806, 765, 19804, 767, 19802, 769, 19800, 771, 19798, 773, 19796, 775, 19794, 777, 19792, 779, 19790, 781, 19788, 783, 19786, 785, 19784, 787, 19782, 789, 19780, 791, 19778, 793, 19776, 795, 19774, 797, 19772, 799, 19770, 801, 19768, 803, 19766, 805, 19764, 807, 19762, 809, 19760, 811, 19758, 813, 19756, 815, 19754, 817, 19752, 819, 19750, 821, 19748, 823, 19746, 825, 19744, 827, 19742, 829, 19740, 831, 19738, 833, 19736, 835, 19734, 837, 19732, 839, 19730, 841, 19728, 843, 19726, 845, 19724, 847, 19722, 849, 19720, 851, 19718, 853, 19716, 855, 19714, 857, 19712, 859, 19710, 861, 19708, 863, 19706, 865, 19704, 867, 19702, 869, 19700, 871, 19698, 873, 19696, 875, 19694, 877, 19692, 879, 19690, 881, 19688, 883, 19686, 885, 19684, 887, 19682, 889, 19680, 891, 19678, 893, 19676, 895, 19674, 897, 19672, 899, 19670, 901, 19668, 903, 19666, 905, 19664, 907, 19662, 909, 19660, 911, 19658, 913, 19656, 915, 19654, 917, 19652, 919, 19650, 921, 19648, 923, 19646, 925, 19644, 927, 19642, 929, 19640, 931, 19638, 933, 19636, 935, 19634, 937, 19632, 939, 19630, 941, 19628, 943, 19626, 945, 19624, 947, 19622, 949, 19620, 951, 19618, 953, 19616, 955, 19614, 957, 19612, 959, 19610, 961, 19608, 963, 19606, 965, 19604, 967, 19602, 969, 19600, 971, 19598, 973, 19596, 975, 19594, 977, 19592, 979, 19590, 981, 19588, 983, 19586, 985, 19584, 987, 19582, 989, 19580, 991, 19578, 993, 19576, 995, 19574, 997, 19572, 999, 19570, 1001, 19568, 1003, 19566, 1005, 19564, 1007, 19562, 1009, 19560, 1011, 19558, 1013, 19556, 1015, 19554, 1017, 19552, 1019, 19550, 1021, 19548, 1023, 19546, 1025, 19544, 1027, 19542, 1029, 19540, 1031, 19538, 1033, 19536, 1035, 19534, 1037, 19532, 1039, 19530, 1041, 19528, 1043, 19526, 1045, 19524, 1047, 19522, 1049, 19520, 1051, 19518, 1053, 19516, 1055, 19514, 1057, 19512, 1059, 19510, 1061, 19508, 1063, 19506, 1065, 19504, 1067, 19502, 1069, 19500, 1071, 19498, 1073, 19496, 1075, 19494, 1077, 19492, 1079, 19490, 1081, 19488, 1083, 19486, 1085, 19484, 1087, 19482, 1089, 19480, 1091, 19478, 1093, 19476, 1095, 19474, 1097, 19472, 1099, 19470, 1101, 19468, 1103, 19466, 1105, 19464, 1107, 19462, 1109, 19460, 1111, 19458, 1113, 19456, 1115, 19454, 1117, 19452, 1119, 19450, 1121, 19448, 1123, 19446, 1125, 19444, 1127, 19442, 1129, 19440, 1131, 19438, 1133, 19436, 1135, 19434, 1137, 19432, 1139, 19430, 1141, 19428, 1143, 19426, 1145, 19424, 1147, 19422, 1149, 19420, 1151, 19418, 1153, 19416, 1155, 19414, 1157, 19412, 1159, 19410, 1161, 19408, 1163, 19406, 1165, 19404, 1167, 19402, 1169, 19400, 1171, 19398, 1173, 19396, 1175, 19394, 1177, 19392, 1179, 19390, 1181, 19388, 1183, 19386, 1185, 19384, 1187, 19382, 1189, 19380, 1191, 19378, 1193, 19376, 1195, 19374, 1197, 19372, 1199, 19370, 1201, 19368, 1203, 19366, 1205, 19364, 1207, 19362, 1209, 19360, 1211, 19358, 1213, 19356, 1215, 19354, 1217, 19352, 1219, 19350, 1221, 19348, 1223, 19346, 1225, 19344, 1227, 19342, 1229, 19340, 1231, 19338, 1233, 19336, 1235, 19334, 1237, 19332, 1239, 19330, 1241, 19328, 1243, 19326, 1245, 19324, 1247, 19322, 1249, 19320, 1251, 19318, 1253, 19316, 1255, 19314, 1257, 19312, 1259, 19310, 1261, 19308, 1263, 19306, 1265, 19304, 1267, 19302, 1269, 19300, 1271, 19298, 1273, 19296, 1275, 19294, 1277, 19292, 1279, 19290, 1281, 19288, 1283, 19286, 1285, 19284, 1287, 19282, 1289, 19280, 1291, 19278, 1293, 19276, 1295, 19274, 1297, 19272, 1299, 19270, 1301, 19268, 1303, 19266, 1305, 19264, 1307, 19262, 1309, 19260, 1311, 19258, 1313, 19256, 1315, 19254, 1317, 19252, 1319, 19250, 1321, 19248, 1323, 19246, 1325, 19244, 1327, 19242, 1329, 19240, 1331, 19238, 1333, 19236, 1335, 19234, 1337, 19232, 1339, 19230, 1341, 19228, 1343, 19226, 1345, 19224, 1347, 19222, 1349, 19220, 1351, 19218, 1353, 19216, 1355, 19214, 1357, 19212, 1359, 19210, 1361, 19208, 1363, 19206, 1365, 19204, 1367, 19202, 1369, 19200, 1371, 19198, 1373, 19196, 1375, 19194, 1377, 19192, 1379, 19190, 1381, 19188, 1383, 19186, 1385, 19184, 1387, 19182, 1389, 19180, 1391, 19178, 1393, 19176, 1395, 19174, 1397, 19172, 1399, 19170, 1401, 19168, 1403, 19166, 1405, 19164, 1407, 19162, 1409, 19160, 1411, 19158, 1413, 19156, 1415, 19154, 1417, 19152, 1419, 19150, 1421, 19148, 1423, 19146, 1425, 19144, 1427, 19142, 1429, 19140, 1431, 19138, 1433, 19136, 1435, 19134, 1437, 19132, 1439, 19130, 1441, 19128, 1443, 19126, 1445, 19124, 1447, 19122, 1449, 19120, 1451, 19118, 1453, 19116, 1455, 19114, 1457, 19112, 1459, 19110, 1461, 19108, 1463, 19106, 1465, 19104, 1467, 19102, 1469, 19100, 1471, 19098, 1473, 19096, 1475, 19094, 1477, 19092, 1479, 19090, 1481, 19088, 1483, 19086, 1485, 19084, 1487, 19082, 1489, 19080, 1491, 19078, 1493, 19076, 1495, 19074, 1497, 19072, 1499, 19070, 1501, 19068, 1503, 19066, 1505, 19064, 1507, 19062, 1509, 19060, 1511, 19058, 1513, 19056, 1515, 19054, 1517, 19052, 1519, 19050, 1521, 19048, 1523, 19046, 1525, 19044, 1527, 19042, 1529, 19040, 1531, 19038, 1533, 19036, 1535, 19034, 1537, 19032, 1539, 19030, 1541, 19028, 1543, 19026, 1545, 19024, 1547, 19022, 1549, 19020, 1551, 19018, 1553, 19016, 1555, 19014, 1557, 19012, 1559, 19010, 1561, 19008, 1563, 19006, 1565, 19004, 1567, 19002, 1569, 19000, 1571, 18998, 1573, 18996, 1575, 18994, 1577, 18992, 1579, 18990, 1581, 18988, 1583, 18986, 1585, 18984, 1587, 18982, 1589, 18980, 1591, 18978, 1593, 18976, 1595, 18974, 1597, 18972, 1599, 18970, 1601, 18968, 1603, 18966, 1605, 18964, 1607, 18962, 1609, 18960, 1611, 18958, 1613, 18956, 1615, 18954, 1617, 18952, 1619, 18950, 1621, 18948, 1623, 18946, 1625, 18944, 1627, 18942, 1629, 18940, 1631, 18938, 1633, 18936, 1635, 18934, 1637, 18932, 1639, 18930, 1641, 18928, 1643, 18926, 1645, 18924, 1647, 18922, 1649, 18920, 1651, 18918, 1653, 18916, 1655, 18914, 1657, 18912, 1659, 18910, 1661, 18908, 1663, 18906, 1665, 18904, 1667, 18902, 1669, 18900, 1671, 18898, 1673, 18896, 1675, 18894, 1677, 18892, 1679, 18890, 1681, 18888, 1683, 18886, 1685, 18884, 1687, 18882, 1689, 18880, 1691, 18878, 1693, 18876, 1695, 18874, 1697, 18872, 1699, 18870, 1701, 18868, 1703, 18866, 1705, 18864, 1707, 18862, 1709, 18860, 1711, 18858, 1713, 18856, 1715, 18854, 1717, 18852, 1719, 18850, 1721, 18848, 1723, 18846, 1725, 18844, 1727, 18842, 1729, 18840, 1731, 18838, 1733, 18836, 1735, 18834, 1737, 18832, 1739, 18830, 1741, 18828, 1743, 18826, 1745, 18824, 1747, 18822, 1749, 18820, 1751, 18818, 1753, 18816, 1755, 18814, 1757, 18812, 1759, 18810, 1761, 18808, 1763, 18806, 1765, 18804, 1767, 18802, 1769, 18800, 1771, 18798, 1773, 18796, 1775, 18794, 1777, 18792, 1779, 18790, 1781, 18788, 1783, 18786, 1785, 18784, 1787, 18782, 1789, 18780, 1791, 18778, 1793, 18776, 1795, 18774, 1797, 18772, 1799, 18770, 1801, 18768, 1803, 18766, 1805, 18764, 1807, 18762, 1809, 18760, 1811, 18758, 1813, 18756, 1815, 18754, 1817, 18752, 1819, 18750, 1821, 18748, 1823, 18746, 1825, 18744, 1827, 18742, 1829, 18740, 1831, 18738, 1833, 18736, 1835, 18734, 1837, 18732, 1839, 18730, 1841, 18728, 1843, 18726, 1845, 18724, 1847, 18722, 1849, 18720, 1851, 18718, 1853, 18716, 1855, 18714, 1857, 18712, 1859, 18710, 1861, 18708, 1863, 18706, 1865, 18704, 1867, 18702, 1869, 18700, 1871, 18698, 1873, 18696, 1875, 18694, 1877, 18692, 1879, 18690, 1881, 18688, 1883, 18686, 1885, 18684, 1887, 18682, 1889, 18680, 1891, 18678, 1893, 18676, 1895, 18674, 1897, 18672, 1899, 18670, 1901, 18668, 1903, 18666, 1905, 18664, 1907, 18662, 1909, 18660, 1911, 18658, 1913, 18656, 1915, 18654, 1917, 18652, 1919, 18650, 1921, 18648, 1923, 18646, 1925, 18644, 1927, 18642, 1929, 18640, 1931, 18638, 1933, 18636, 1935, 18634, 1937, 18632, 1939, 18630, 1941, 18628, 1943, 18626, 1945, 18624, 1947, 18622, 1949, 18620, 1951, 18618, 1953, 18616, 1955, 18614, 1957, 18612, 1959, 18610, 1961, 18608, 1963, 18606, 1965, 18604, 1967, 18602, 1969, 18600, 1971, 18598, 1973, 18596, 1975, 18594, 1977, 18592, 1979, 18590, 1981, 18588, 1983, 18586, 1985, 18584, 1987, 18582, 1989, 18580, 1991, 18578, 1993, 18576, 1995, 18574, 1997, 18572, 1999, 18570, 2001, 18568, 2003, 18566, 2005, 18564, 2007, 18562, 2009, 18560, 2011, 18558, 2013, 18556, 2015, 18554, 2017, 18552, 2019, 18550, 2021, 18548, 2023, 18546, 2025, 18544, 2027, 18542, 2029, 18540, 2031, 18538, 2033, 18536, 2035, 18534, 2037, 18532, 2039, 18530, 2041, 18528, 2043, 18526, 2045, 18524, 2047, 18522, 2049, 18520, 2051, 18518, 2053, 18516, 2055, 18514, 2057, 18512, 2059, 18510, 2061, 18508, 2063, 18506, 2065, 18504, 2067, 18502, 2069, 18500, 2071, 18498, 2073, 18496, 2075, 18494, 2077, 18492, 2079, 18490, 2081, 18488, 2083, 18486, 2085, 18484, 2087, 18482, 2089, 18480, 2091, 18478, 2093, 18476, 2095, 18474, 2097, 18472, 2099, 18470, 2101, 18468, 2103, 18466, 2105, 18464, 2107, 18462, 2109, 18460, 2111, 18458, 2113, 18456, 2115, 18454, 2117, 18452, 2119, 18450, 2121, 18448, 2123, 18446, 2125, 18444, 2127, 18442, 2129, 18440, 2131, 18438, 2133, 18436, 2135, 18434, 2137, 18432, 2139, 18430, 2141, 18428, 2143, 18426, 2145, 18424, 2147, 18422, 2149, 18420, 2151, 18418, 2153, 18416, 2155, 18414, 2157, 18412, 2159, 18410, 2161, 18408, 2163, 18406, 2165, 18404, 2167, 18402, 2169, 18400, 2171, 18398, 2173, 18396, 2175, 18394, 2177, 18392, 2179, 18390, 2181, 18388, 2183, 18386, 2185, 18384, 2187, 18382, 2189, 18380, 2191, 18378, 2193, 18376, 2195, 18374, 2197, 18372, 2199, 18370, 2201, 18368, 2203, 18366, 2205, 18364, 2207, 18362, 2209, 18360, 2211, 18358, 2213, 18356, 2215, 18354, 2217, 18352, 2219, 18350, 2221, 18348, 2223, 18346, 2225, 18344, 2227, 18342, 2229, 18340, 2231, 18338, 2233, 18336, 2235, 18334, 2237, 18332, 2239, 18330, 2241, 18328, 2243, 18326, 2245, 18324, 2247, 18322, 2249, 18320, 2251, 18318, 2253, 18316, 2255, 18314, 2257, 18312, 2259, 18310, 2261, 18308, 2263, 18306, 2265, 18304, 2267, 18302, 2269, 18300, 2271, 18298, 2273, 18296, 2275, 18294, 2277, 18292, 2279, 18290, 2281, 18288, 2283, 18286, 2285, 18284, 2287, 18282, 2289, 18280, 2291, 18278, 2293, 18276, 2295, 18274, 2297, 18272, 2299, 18270, 2301, 18268, 2303, 18266, 2305, 18264, 2307, 18262, 2309, 18260, 2311, 18258, 2313, 18256, 2315, 18254, 2317, 18252, 2319, 18250, 2321, 18248, 2323, 18246, 2325, 18244, 2327, 18242, 2329, 18240, 2331, 18238, 2333, 18236, 2335, 18234, 2337, 18232, 2339, 18230, 2341, 18228, 2343, 18226, 2345, 18224, 2347, 18222, 2349, 18220, 2351, 18218, 2353, 18216, 2355, 18214, 2357, 18212, 2359, 18210, 2361, 18208, 2363, 18206, 2365, 18204, 2367, 18202, 2369, 18200, 2371, 18198, 2373, 18196, 2375, 18194, 2377, 18192, 2379, 18190, 2381, 18188, 2383, 18186, 2385, 18184, 2387, 18182, 2389, 18180, 2391, 18178, 2393, 18176, 2395, 18174, 2397, 18172, 2399, 18170, 2401, 18168, 2403, 18166, 2405, 18164, 2407, 18162, 2409, 18160, 2411, 18158, 2413, 18156, 2415, 18154, 2417, 18152, 2419, 18150, 2421, 18148, 2423, 18146, 2425, 18144, 2427, 18142, 2429, 18140, 2431, 18138, 2433, 18136, 2435, 18134, 2437, 18132, 2439, 18130, 2441, 18128, 2443, 18126, 2445, 18124, 2447, 18122, 2449, 18120, 2451, 18118, 2453, 18116, 2455, 18114, 2457, 18112, 2459, 18110, 2461, 18108, 2463, 18106, 2465, 18104, 2467, 18102, 2469, 18100, 2471, 18098, 2473, 18096, 2475, 18094, 2477, 18092, 2479, 18090, 2481, 18088, 2483, 18086, 2485, 18084, 2487, 18082, 2489, 18080, 2491, 18078, 2493, 18076, 2495, 18074, 2497, 18072, 2499, 18070, 2501, 18068, 2503, 18066, 2505, 18064, 2507, 18062, 2509, 18060, 2511, 18058, 2513, 18056, 2515, 18054, 2517, 18052, 2519, 18050, 2521, 18048, 2523, 18046, 2525, 18044, 2527, 18042, 2529, 18040, 2531, 18038, 2533, 18036, 2535, 18034, 2537, 18032, 2539, 18030, 2541, 18028, 2543, 18026, 2545, 18024, 2547, 18022, 2549, 18020, 2551, 18018, 2553, 18016, 2555, 18014, 2557, 18012, 2559, 18010, 2561, 18008, 2563, 18006, 2565, 18004, 2567, 18002, 2569, 18000, 2571, 17998, 2573, 17996, 2575, 17994, 2577, 17992, 2579, 17990, 2581, 17988, 2583, 17986, 2585, 17984, 2587, 17982, 2589, 17980, 2591, 17978, 2593, 17976, 2595, 17974, 2597, 17972, 2599, 17970, 2601, 17968, 2603, 17966, 2605, 17964, 2607, 17962, 2609, 17960, 2611, 17958, 2613, 17956, 2615, 17954, 2617, 17952, 2619, 17950, 2621, 17948, 2623, 17946, 2625, 17944, 2627, 17942, 2629, 17940, 2631, 17938, 2633, 17936, 2635, 17934, 2637, 17932, 2639, 17930, 2641, 17928, 2643, 17926, 2645, 17924, 2647, 17922, 2649, 17920, 2651, 17918, 2653, 17916, 2655, 17914, 2657, 17912, 2659, 17910, 2661, 17908, 2663, 17906, 2665, 17904, 2667, 17902, 2669, 17900, 2671, 17898, 2673, 17896, 2675, 17894, 2677, 17892, 2679, 17890, 2681, 17888, 2683, 17886, 2685, 17884, 2687, 17882, 2689, 17880, 2691, 17878, 2693, 17876, 2695, 17874, 2697, 17872, 2699, 17870, 2701, 17868, 2703, 17866, 2705, 17864, 2707, 17862, 2709, 17860, 2711, 17858, 2713, 17856, 2715, 17854, 2717, 17852, 2719, 17850, 2721, 17848, 2723, 17846, 2725, 17844, 2727, 17842, 2729, 17840, 2731, 17838, 2733, 17836, 2735, 17834, 2737, 17832, 2739, 17830, 2741, 17828, 2743, 17826, 2745, 17824, 2747, 17822, 2749, 17820, 2751, 17818, 2753, 17816, 2755, 17814, 2757, 17812, 2759, 17810, 2761, 17808, 2763, 17806, 2765, 17804, 2767, 17802, 2769, 17800, 2771, 17798, 2773, 17796, 2775, 17794, 2777, 17792, 2779, 17790, 2781, 17788, 2783, 17786, 2785, 17784, 2787, 17782, 2789, 17780, 2791, 17778, 2793, 17776, 2795, 17774, 2797, 17772, 2799, 17770, 2801, 17768, 2803, 17766, 2805, 17764, 2807, 17762, 2809, 17760, 2811, 17758, 2813, 17756, 2815, 17754, 2817, 17752, 2819, 17750, 2821, 17748, 2823, 17746, 2825, 17744, 2827, 17742, 2829, 17740, 2831, 17738, 2833, 17736, 2835, 17734, 2837, 17732, 2839, 17730, 2841, 17728, 2843, 17726, 2845, 17724, 2847, 17722, 2849, 17720, 2851, 17718, 2853, 17716, 2855, 17714, 2857, 17712, 2859, 17710, 2861, 17708, 2863, 17706, 2865, 17704, 2867, 17702, 2869, 17700, 2871, 17698, 2873, 17696, 2875, 17694, 2877, 17692, 2879, 17690, 2881, 17688, 2883, 17686, 2885, 17684, 2887, 17682, 2889, 17680, 2891, 17678, 2893, 17676, 2895, 17674, 2897, 17672, 2899, 17670, 2901, 17668, 2903, 17666, 2905, 17664, 2907, 17662, 2909, 17660, 2911, 17658, 2913, 17656, 2915, 17654, 2917, 17652, 2919, 17650, 2921, 17648, 2923, 17646, 2925, 17644, 2927, 17642, 2929, 17640, 2931, 17638, 2933, 17636, 2935, 17634, 2937, 17632, 2939, 17630, 2941, 17628, 2943, 17626, 2945, 17624, 2947, 17622, 2949, 17620, 2951, 17618, 2953, 17616, 2955, 17614, 2957, 17612, 2959, 17610, 2961, 17608, 2963, 17606, 2965, 17604, 2967, 17602, 2969, 17600, 2971, 17598, 2973, 17596, 2975, 17594, 2977, 17592, 2979, 17590, 2981, 17588, 2983, 17586, 2985, 17584, 2987, 17582, 2989, 17580, 2991, 17578, 2993, 17576, 2995, 17574, 2997, 17572, 2999, 17570, 3001, 17568, 3003, 17566, 3005, 17564, 3007, 17562, 3009, 17560, 3011, 17558, 3013, 17556, 3015, 17554, 3017, 17552, 3019, 17550, 3021, 17548, 3023, 17546, 3025, 17544, 3027, 17542, 3029, 17540, 3031, 17538, 3033, 17536, 3035, 17534, 3037, 17532, 3039, 17530, 3041, 17528, 3043, 17526, 3045, 17524, 3047, 17522, 3049, 17520, 3051, 17518, 3053, 17516, 3055, 17514, 3057, 17512, 3059, 17510, 3061, 17508, 3063, 17506, 3065, 17504, 3067, 17502, 3069, 17500, 3071, 17498, 3073, 17496, 3075, 17494, 3077, 17492, 3079, 17490, 3081, 17488, 3083, 17486, 3085, 17484, 3087, 17482, 3089, 17480, 3091, 17478, 3093, 17476, 3095, 17474, 3097, 17472, 3099, 17470, 3101, 17468, 3103, 17466, 3105, 17464, 3107, 17462, 3109, 17460, 3111, 17458, 3113, 17456, 3115, 17454, 3117, 17452, 3119, 17450, 3121, 17448, 3123, 17446, 3125, 17444, 3127, 17442, 3129, 17440, 3131, 17438, 3133, 17436, 3135, 17434, 3137, 17432, 3139, 17430, 3141, 17428, 3143, 17426, 3145, 17424, 3147, 17422, 3149, 17420, 3151, 17418, 3153, 17416, 3155, 17414, 3157, 17412, 3159, 17410, 3161, 17408, 3163, 17406, 3165, 17404, 3167, 17402, 3169, 17400, 3171, 17398, 3173, 17396, 3175, 17394, 3177, 17392, 3179, 17390, 3181, 17388, 3183, 17386, 3185, 17384, 3187, 17382, 3189, 17380, 3191, 17378, 3193, 17376, 3195, 17374, 3197, 17372, 3199, 17370, 3201, 17368, 3203, 17366, 3205, 17364, 3207, 17362, 3209, 17360, 3211, 17358, 3213, 17356, 3215, 17354, 3217, 17352, 3219, 17350, 3221, 17348, 3223, 17346, 3225, 17344, 3227, 17342, 3229, 17340, 3231, 17338, 3233, 17336, 3235, 17334, 3237, 17332, 3239, 17330, 3241, 17328, 3243, 17326, 3245, 17324, 3247, 17322, 3249, 17320, 3251, 17318, 3253, 17316, 3255, 17314, 3257, 17312, 3259, 17310, 3261, 17308, 3263, 17306, 3265, 17304, 3267, 17302, 3269, 17300, 3271, 17298, 3273, 17296, 3275, 17294, 3277, 17292, 3279, 17290, 3281, 17288, 3283, 17286, 3285, 17284, 3287, 17282, 3289, 17280, 3291, 17278, 3293, 17276, 3295, 17274, 3297, 17272, 3299, 17270, 3301, 17268, 3303, 17266, 3305, 17264, 3307, 17262, 3309, 17260, 3311, 17258, 3313, 17256, 3315, 17254, 3317, 17252, 3319, 17250, 3321, 17248, 3323, 17246, 3325, 17244, 3327, 17242, 3329, 17240, 3331, 17238, 3333, 17236, 3335, 17234, 3337, 17232, 3339, 17230, 3341, 17228, 3343, 17226, 3345, 17224, 3347, 17222, 3349, 17220, 3351, 17218, 3353, 17216, 3355, 17214, 3357, 17212, 3359, 17210, 3361, 17208, 3363, 17206, 3365, 17204, 3367, 17202, 3369, 17200, 3371, 17198, 3373, 17196, 3375, 17194, 3377, 17192, 3379, 17190, 3381, 17188, 3383, 17186, 3385, 17184, 3387, 17182, 3389, 17180, 3391, 17178, 3393, 17176, 3395, 17174, 3397, 17172, 3399, 17170, 3401, 17168, 3403, 17166, 3405, 17164, 3407, 17162, 3409, 17160, 3411, 17158, 3413, 17156, 3415, 17154, 3417, 17152, 3419, 17150, 3421, 17148, 3423, 17146, 3425, 17144, 3427, 17142, 3429, 17140, 3431, 17138, 3433, 17136, 3435, 17134, 3437, 17132, 3439, 17130, 3441, 17128, 3443, 17126, 3445, 17124, 3447, 17122, 3449, 17120, 3451, 17118, 3453, 17116, 3455, 17114, 3457, 17112, 3459, 17110, 3461, 17108, 3463, 17106, 3465, 17104, 3467, 17102, 3469, 17100, 3471, 17098, 3473, 17096, 3475, 17094, 3477, 17092, 3479, 17090, 3481, 17088, 3483, 17086, 3485, 17084, 3487, 17082, 3489, 17080, 3491, 17078, 3493, 17076, 3495, 17074, 3497, 17072, 3499, 17070, 3501, 17068, 3503, 17066, 3505, 17064, 3507, 17062, 3509, 17060, 3511, 17058, 3513, 17056, 3515, 17054, 3517, 17052, 3519, 17050, 3521, 17048, 3523, 17046, 3525, 17044, 3527, 17042, 3529, 17040, 3531, 17038, 3533, 17036, 3535, 17034, 3537, 17032, 3539, 17030, 3541, 17028, 3543, 17026, 3545, 17024, 3547, 17022, 3549, 17020, 3551, 17018, 3553, 17016, 3555, 17014, 3557, 17012, 3559, 17010, 3561, 17008, 3563, 17006, 3565, 17004, 3567, 17002, 3569, 17000, 3571, 16998, 3573, 16996, 3575, 16994, 3577, 16992, 3579, 16990, 3581, 16988, 3583, 16986, 3585, 16984, 3587, 16982, 3589, 16980, 3591, 16978, 3593, 16976, 3595, 16974, 3597, 16972, 3599, 16970, 3601, 16968, 3603, 16966, 3605, 16964, 3607, 16962, 3609, 16960, 3611, 16958, 3613, 16956, 3615, 16954, 3617, 16952, 3619, 16950, 3621, 16948, 3623, 16946, 3625, 16944, 3627, 16942, 3629, 16940, 3631, 16938, 3633, 16936, 3635, 16934, 3637, 16932, 3639, 16930, 3641, 16928, 3643, 16926, 3645, 16924, 3647, 16922, 3649, 16920, 3651, 16918, 3653, 16916, 3655, 16914, 3657, 16912, 3659, 16910, 3661, 16908, 3663, 16906, 3665, 16904, 3667, 16902, 3669, 16900, 3671, 16898, 3673, 16896, 3675, 16894, 3677, 16892, 3679, 16890, 3681, 16888, 3683, 16886, 3685, 16884, 3687, 16882, 3689, 16880, 3691, 16878, 3693, 16876, 3695, 16874, 3697, 16872, 3699, 16870, 3701, 16868, 3703, 16866, 3705, 16864, 3707, 16862, 3709, 16860, 3711, 16858, 3713, 16856, 3715, 16854, 3717, 16852, 3719, 16850, 3721, 16848, 3723, 16846, 3725, 16844, 3727, 16842, 3729, 16840, 3731, 16838, 3733, 16836, 3735, 16834, 3737, 16832, 3739, 16830, 3741, 16828, 3743, 16826, 3745, 16824, 3747, 16822, 3749, 16820, 3751, 16818, 3753, 16816, 3755, 16814, 3757, 16812, 3759, 16810, 3761, 16808, 3763, 16806, 3765, 16804, 3767, 16802, 3769, 16800, 3771, 16798, 3773, 16796, 3775, 16794, 3777, 16792, 3779, 16790, 3781, 16788, 3783, 16786, 3785, 16784, 3787, 16782, 3789, 16780, 3791, 16778, 3793, 16776, 3795, 16774, 3797, 16772, 3799, 16770, 3801, 16768, 3803, 16766, 3805, 16764, 3807, 16762, 3809, 16760, 3811, 16758, 3813, 16756, 3815, 16754, 3817, 16752, 3819, 16750, 3821, 16748, 3823, 16746, 3825, 16744, 3827, 16742, 3829, 16740, 3831, 16738, 3833, 16736, 3835, 16734, 3837, 16732, 3839, 16730, 3841, 16728, 3843, 16726, 3845, 16724, 3847, 16722, 3849, 16720, 3851, 16718, 3853, 16716, 3855, 16714, 3857, 16712, 3859, 16710, 3861, 16708, 3863, 16706, 3865, 16704, 3867, 16702, 3869, 16700, 3871, 16698, 3873, 16696, 3875, 16694, 3877, 16692, 3879, 16690, 3881, 16688, 3883, 16686, 3885, 16684, 3887, 16682, 3889, 16680, 3891, 16678, 3893, 16676, 3895, 16674, 3897, 16672, 3899, 16670, 3901, 16668, 3903, 16666, 3905, 16664, 3907, 16662, 3909, 16660, 3911, 16658, 3913, 16656, 3915, 16654, 3917, 16652, 3919, 16650, 3921, 16648, 3923, 16646, 3925, 16644, 3927, 16642, 3929, 16640, 3931, 16638, 3933, 16636, 3935, 16634, 3937, 16632, 3939, 16630, 3941, 16628, 3943, 16626, 3945, 16624, 3947, 16622, 3949, 16620, 3951, 16618, 3953, 16616, 3955, 16614, 3957, 16612, 3959, 16610, 3961, 16608, 3963, 16606, 3965, 16604, 3967, 16602, 3969, 16600, 3971, 16598, 3973, 16596, 3975, 16594, 3977, 16592, 3979, 16590, 3981, 16588, 3983, 16586, 3985, 16584, 3987, 16582, 3989, 16580, 3991, 16578, 3993, 16576, 3995, 16574, 3997, 16572, 3999, 16570, 4001, 16568, 4003, 16566, 4005, 16564, 4007, 16562, 4009, 16560, 4011, 16558, 4013, 16556, 4015, 16554, 4017, 16552, 4019, 16550, 4021, 16548, 4023, 16546, 4025, 16544, 4027, 16542, 4029, 16540, 4031, 16538, 4033, 16536, 4035, 16534, 4037, 16532, 4039, 16530, 4041, 16528, 4043, 16526, 4045, 16524, 4047, 16522, 4049, 16520, 4051, 16518, 4053, 16516, 4055, 16514, 4057, 16512, 4059, 16510, 4061, 16508, 4063, 16506, 4065, 16504, 4067, 16502, 4069, 16500, 4071, 16498, 4073, 16496, 4075, 16494, 4077, 16492, 4079, 16490, 4081, 16488, 4083, 16486, 4085, 16484, 4087, 16482, 4089, 16480, 4091, 16478, 4093, 16476, 4095, 16474, 4097, 16472, 4099, 16470, 4101, 16468, 4103, 16466, 4105, 16464, 4107, 16462, 4109, 16460, 4111, 16458, 4113, 16456, 4115, 16454, 4117, 16452, 4119, 16450, 4121, 16448, 4123, 16446, 4125, 16444, 4127, 16442, 4129, 16440, 4131, 16438, 4133, 16436, 4135, 16434, 4137, 16432, 4139, 16430, 4141, 16428, 4143, 16426, 4145, 16424, 4147, 16422, 4149, 16420, 4151, 16418, 4153, 16416, 4155, 16414, 4157, 16412, 4159, 16410, 4161, 16408, 4163, 16406, 4165, 16404, 4167, 16402, 4169, 16400, 4171, 16398, 4173, 16396, 4175, 16394, 4177, 16392, 4179, 16390, 4181, 16388, 4183, 16386, 4185, 16384, 4187, 16382, 4189, 16380, 4191, 16378, 4193, 16376, 4195, 16374, 4197, 16372, 4199, 16370, 4201, 16368, 4203, 16366, 4205, 16364, 4207, 16362, 4209, 16360, 4211, 16358, 4213, 16356, 4215, 16354, 4217, 16352, 4219, 16350, 4221, 16348, 4223, 16346, 4225, 16344, 4227, 16342, 4229, 16340, 4231, 16338, 4233, 16336, 4235, 16334, 4237, 16332, 4239, 16330, 4241, 16328, 4243, 16326, 4245, 16324, 4247, 16322, 4249, 16320, 4251, 16318, 4253, 16316, 4255, 16314, 4257, 16312, 4259, 16310, 4261, 16308, 4263, 16306, 4265, 16304, 4267, 16302, 4269, 16300, 4271, 16298, 4273, 16296, 4275, 16294, 4277, 16292, 4279, 16290, 4281, 16288, 4283, 16286, 4285, 16284, 4287, 16282, 4289, 16280, 4291, 16278, 4293, 16276, 4295, 16274, 4297, 16272, 4299, 16270, 4301, 16268, 4303, 16266, 4305, 16264, 4307, 16262, 4309, 16260, 4311, 16258, 4313, 16256, 4315, 16254, 4317, 16252, 4319, 16250, 4321, 16248, 4323, 16246, 4325, 16244, 4327, 16242, 4329, 16240, 4331, 16238, 4333, 16236, 4335, 16234, 4337, 16232, 4339, 16230, 4341, 16228, 4343, 16226, 4345, 16224, 4347, 16222, 4349, 16220, 4351, 16218, 4353, 16216, 4355, 16214, 4357, 16212, 4359, 16210, 4361, 16208, 4363, 16206, 4365, 16204, 4367, 16202, 4369, 16200, 4371, 16198, 4373, 16196, 4375, 16194, 4377, 16192, 4379, 16190, 4381, 16188, 4383, 16186, 4385, 16184, 4387, 16182, 4389, 16180, 4391, 16178, 4393, 16176, 4395, 16174, 4397, 16172, 4399, 16170, 4401, 16168, 4403, 16166, 4405, 16164, 4407, 16162, 4409, 16160, 4411, 16158, 4413, 16156, 4415, 16154, 4417, 16152, 4419, 16150, 4421, 16148, 4423, 16146, 4425, 16144, 4427, 16142, 4429, 16140, 4431, 16138, 4433, 16136, 4435, 16134, 4437, 16132, 4439, 16130, 4441, 16128, 4443, 16126, 4445, 16124, 4447, 16122, 4449, 16120, 4451, 16118, 4453, 16116, 4455, 16114, 4457, 16112, 4459, 16110, 4461, 16108, 4463, 16106, 4465, 16104, 4467, 16102, 4469, 16100, 4471, 16098, 4473, 16096, 4475, 16094, 4477, 16092, 4479, 16090, 4481, 16088, 4483, 16086, 4485, 16084, 4487, 16082, 4489, 16080, 4491, 16078, 4493, 16076, 4495, 16074, 4497, 16072, 4499, 16070, 4501, 16068, 4503, 16066, 4505, 16064, 4507, 16062, 4509, 16060, 4511, 16058, 4513, 16056, 4515, 16054, 4517, 16052, 4519, 16050, 4521, 16048, 4523, 16046, 4525, 16044, 4527, 16042, 4529, 16040, 4531, 16038, 4533, 16036, 4535, 16034, 4537, 16032, 4539, 16030, 4541, 16028, 4543, 16026, 4545, 16024, 4547, 16022, 4549, 16020, 4551, 16018, 4553, 16016, 4555, 16014, 4557, 16012, 4559, 16010, 4561, 16008, 4563, 16006, 4565, 16004, 4567, 16002, 4569, 16000, 4571, 15998, 4573, 15996, 4575, 15994, 4577, 15992, 4579, 15990, 4581, 15988, 4583, 15986, 4585, 15984, 4587, 15982, 4589, 15980, 4591, 15978, 4593, 15976, 4595, 15974, 4597, 15972, 4599, 15970, 4601, 15968, 4603, 15966, 4605, 15964, 4607, 15962, 4609, 15960, 4611, 15958, 4613, 15956, 4615, 15954, 4617, 15952, 4619, 15950, 4621, 15948, 4623, 15946, 4625, 15944, 4627, 15942, 4629, 15940, 4631, 15938, 4633, 15936, 4635, 15934, 4637, 15932, 4639, 15930, 4641, 15928, 4643, 15926, 4645, 15924, 4647, 15922, 4649, 15920, 4651, 15918, 4653, 15916, 4655, 15914, 4657, 15912, 4659, 15910, 4661, 15908, 4663, 15906, 4665, 15904, 4667, 15902, 4669, 15900, 4671, 15898, 4673, 15896, 4675, 15894, 4677, 15892, 4679, 15890, 4681, 15888, 4683, 15886, 4685, 15884, 4687, 15882, 4689, 15880, 4691, 15878, 4693, 15876, 4695, 15874, 4697, 15872, 4699, 15870, 4701, 15868, 4703, 15866, 4705, 15864, 4707, 15862, 4709, 15860, 4711, 15858, 4713, 15856, 4715, 15854, 4717, 15852, 4719, 15850, 4721, 15848, 4723, 15846, 4725, 15844, 4727, 15842, 4729, 15840, 4731, 15838, 4733, 15836, 4735, 15834, 4737, 15832, 4739, 15830, 4741, 15828, 4743, 15826, 4745, 15824, 4747, 15822, 4749, 15820, 4751, 15818, 4753, 15816, 4755, 15814, 4757, 15812, 4759, 15810, 4761, 15808, 4763, 15806, 4765, 15804, 4767, 15802, 4769, 15800, 4771, 15798, 4773, 15796, 4775, 15794, 4777, 15792, 4779, 15790, 4781, 15788, 4783, 15786, 4785, 15784, 4787, 15782, 4789, 15780, 4791, 15778, 4793, 15776, 4795, 15774, 4797, 15772, 4799, 15770, 4801, 15768, 4803, 15766, 4805, 15764, 4807, 15762, 4809, 15760, 4811, 15758, 4813, 15756, 4815, 15754, 4817, 15752, 4819, 15750, 4821, 15748, 4823, 15746, 4825, 15744, 4827, 15742, 4829, 15740, 4831, 15738, 4833, 15736, 4835, 15734, 4837, 15732, 4839, 15730, 4841, 15728, 4843, 15726, 4845, 15724, 4847, 15722, 4849, 15720, 4851, 15718, 4853, 15716, 4855, 15714, 4857, 15712, 4859, 15710, 4861, 15708, 4863, 15706, 4865, 15704, 4867, 15702, 4869, 15700, 4871, 15698, 4873, 15696, 4875, 15694, 4877, 15692, 4879, 15690, 4881, 15688, 4883, 15686, 4885, 15684, 4887, 15682, 4889, 15680, 4891, 15678, 4893, 15676, 4895, 15674, 4897, 15672, 4899, 15670, 4901, 15668, 4903, 15666, 4905, 15664, 4907, 15662, 4909, 15660, 4911, 15658, 4913, 15656, 4915, 15654, 4917, 15652, 4919, 15650, 4921, 15648, 4923, 15646, 4925, 15644, 4927, 15642, 4929, 15640, 4931, 15638, 4933, 15636, 4935, 15634, 4937, 15632, 4939, 15630, 4941, 15628, 4943, 15626, 4945, 15624, 4947, 15622, 4949, 15620, 4951, 15618, 4953, 15616, 4955, 15614, 4957, 15612, 4959, 15610, 4961, 15608, 4963, 15606, 4965, 15604, 4967, 15602, 4969, 15600, 4971, 15598, 4973, 15596, 4975, 15594, 4977, 15592, 4979, 15590, 4981, 15588, 4983, 15586, 4985, 15584, 4987, 15582, 4989, 15580, 4991, 15578, 4993, 15576, 4995, 15574, 4997, 15572, 4999, 15570, 5001, 15568, 5003, 15566, 5005, 15564, 5007, 15562, 5009, 15560, 5011, 15558, 5013, 15556, 5015, 15554, 5017, 15552, 5019, 15550, 5021, 15548, 5023, 15546, 5025, 15544, 5027, 15542, 5029, 15540, 5031, 15538, 5033, 15536, 5035, 15534, 5037, 15532, 5039, 15530, 5041, 15528, 5043, 15526, 5045, 15524, 5047, 15522, 5049, 15520, 5051, 15518, 5053, 15516, 5055, 15514, 5057, 15512, 5059, 15510, 5061, 15508, 5063, 15506, 5065, 15504, 5067, 15502, 5069, 15500, 5071, 15498, 5073, 15496, 5075, 15494, 5077, 15492, 5079, 15490, 5081, 15488, 5083, 15486, 5085, 15484, 5087, 15482, 5089, 15480, 5091, 15478, 5093, 15476, 5095, 15474, 5097, 15472, 5099, 15470, 5101, 15468, 5103, 15466, 5105, 15464, 5107, 15462, 5109, 15460, 5111, 15458, 5113, 15456, 5115, 15454, 5117, 15452, 5119, 15450, 5121, 15448, 5123, 15446, 5125, 15444, 5127, 15442, 5129, 15440, 5131, 15438, 5133, 15436, 5135, 15434, 5137, 15432, 5139, 15430, 5141, 15428, 5143, 15426, 5145, 15424, 5147, 15422, 5149, 15420, 5151, 15418, 5153, 15416, 5155, 15414, 5157, 15412, 5159, 15410, 5161, 15408, 5163, 15406, 5165, 15404, 5167, 15402, 5169, 15400, 5171, 15398, 5173, 15396, 5175, 15394, 5177, 15392, 5179, 15390, 5181, 15388, 5183, 15386, 5185, 15384, 5187, 15382, 5189, 15380, 5191, 15378, 5193, 15376, 5195, 15374, 5197, 15372, 5199, 15370, 5201, 15368, 5203, 15366, 5205, 15364, 5207, 15362, 5209, 15360, 5211, 15358, 5213, 15356, 5215, 15354, 5217, 15352, 5219, 15350, 5221, 15348, 5223, 15346, 5225, 15344, 5227, 15342, 5229, 15340, 5231, 15338, 5233, 15336, 5235, 15334, 5237, 15332, 5239, 15330, 5241, 15328, 5243, 15326, 5245, 15324, 5247, 15322, 5249, 15320, 5251, 15318, 5253, 15316, 5255, 15314, 5257, 15312, 5259, 15310, 5261, 15308, 5263, 15306, 5265, 15304, 5267, 15302, 5269, 15300, 5271, 15298, 5273, 15296, 5275, 15294, 5277, 15292, 5279, 15290, 5281, 15288, 5283, 15286, 5285, 15284, 5287, 15282, 5289, 15280, 5291, 15278, 5293, 15276, 5295, 15274, 5297, 15272, 5299, 15270, 5301, 15268, 5303, 15266, 5305, 15264, 5307, 15262, 5309, 15260, 5311, 15258, 5313, 15256, 5315, 15254, 5317, 15252, 5319, 15250, 5321, 15248, 5323, 15246, 5325, 15244, 5327, 15242, 5329, 15240, 5331, 15238, 5333, 15236, 5335, 15234, 5337, 15232, 5339, 15230, 5341, 15228, 5343, 15226, 5345, 15224, 5347, 15222, 5349, 15220, 5351, 15218, 5353, 15216, 5355, 15214, 5357, 15212, 5359, 15210, 5361, 15208, 5363, 15206, 5365, 15204, 5367, 15202, 5369, 15200, 5371, 15198, 5373, 15196, 5375, 15194, 5377, 15192, 5379, 15190, 5381, 15188, 5383, 15186, 5385, 15184, 5387, 15182, 5389, 15180, 5391, 15178, 5393, 15176, 5395, 15174, 5397, 15172, 5399, 15170, 5401, 15168, 5403, 15166, 5405, 15164, 5407, 15162, 5409, 15160, 5411, 15158, 5413, 15156, 5415, 15154, 5417, 15152, 5419, 15150, 5421, 15148, 5423, 15146, 5425, 15144, 5427, 15142, 5429, 15140, 5431, 15138, 5433, 15136, 5435, 15134, 5437, 15132, 5439, 15130, 5441, 15128, 5443, 15126, 5445, 15124, 5447, 15122, 5449, 15120, 5451, 15118, 5453, 15116, 5455, 15114, 5457, 15112, 5459, 15110, 5461, 15108, 5463, 15106, 5465, 15104, 5467, 15102, 5469, 15100, 5471, 15098, 5473, 15096, 5475, 15094, 5477, 15092, 5479, 15090, 5481, 15088, 5483, 15086, 5485, 15084, 5487, 15082, 5489, 15080, 5491, 15078, 5493, 15076, 5495, 15074, 5497, 15072, 5499, 15070, 5501, 15068, 5503, 15066, 5505, 15064, 5507, 15062, 5509, 15060, 5511, 15058, 5513, 15056, 5515, 15054, 5517, 15052, 5519, 15050, 5521, 15048, 5523, 15046, 5525, 15044, 5527, 15042, 5529, 15040, 5531, 15038, 5533, 15036, 5535, 15034, 5537, 15032, 5539, 15030, 5541, 15028, 5543, 15026, 5545, 15024, 5547, 15022, 5549, 15020, 5551, 15018, 5553, 15016, 5555, 15014, 5557, 15012, 5559, 15010, 5561, 15008, 5563, 15006, 5565, 15004, 5567, 15002, 5569, 15000, 5571, 14998, 5573, 14996, 5575, 14994, 5577, 14992, 5579, 14990, 5581, 14988, 5583, 14986, 5585, 14984, 5587, 14982, 5589, 14980, 5591, 14978, 5593, 14976, 5595, 14974, 5597, 14972, 5599, 14970, 5601, 14968, 5603, 14966, 5605, 14964, 5607, 14962, 5609, 14960, 5611, 14958, 5613, 14956, 5615, 14954, 5617, 14952, 5619, 14950, 5621, 14948, 5623, 14946, 5625, 14944, 5627, 14942, 5629, 14940, 5631, 14938, 5633, 14936, 5635, 14934, 5637, 14932, 5639, 14930, 5641, 14928, 5643, 14926, 5645, 14924, 5647, 14922, 5649, 14920, 5651, 14918, 5653, 14916, 5655, 14914, 5657, 14912, 5659, 14910, 5661, 14908, 5663, 14906, 5665, 14904, 5667, 14902, 5669, 14900, 5671, 14898, 5673, 14896, 5675, 14894, 5677, 14892, 5679, 14890, 5681, 14888, 5683, 14886, 5685, 14884, 5687, 14882, 5689, 14880, 5691, 14878, 5693, 14876, 5695, 14874, 5697, 14872, 5699, 14870, 5701, 14868, 5703, 14866, 5705, 14864, 5707, 14862, 5709, 14860, 5711, 14858, 5713, 14856, 5715, 14854, 5717, 14852, 5719, 14850, 5721, 14848, 5723, 14846, 5725, 14844, 5727, 14842, 5729, 14840, 5731, 14838, 5733, 14836, 5735, 14834, 5737, 14832, 5739, 14830, 5741, 14828, 5743, 14826, 5745, 14824, 5747, 14822, 5749, 14820, 5751, 14818, 5753, 14816, 5755, 14814, 5757, 14812, 5759, 14810, 5761, 14808, 5763, 14806, 5765, 14804, 5767, 14802, 5769, 14800, 5771, 14798, 5773, 14796, 5775, 14794, 5777, 14792, 5779, 14790, 5781, 14788, 5783, 14786, 5785, 14784, 5787, 14782, 5789, 14780, 5791, 14778, 5793, 14776, 5795, 14774, 5797, 14772, 5799, 14770, 5801, 14768, 5803, 14766, 5805, 14764, 5807, 14762, 5809, 14760, 5811, 14758, 5813, 14756, 5815, 14754, 5817, 14752, 5819, 14750, 5821, 14748, 5823, 14746, 5825, 14744, 5827, 14742, 5829, 14740, 5831, 14738, 5833, 14736, 5835, 14734, 5837, 14732, 5839, 14730, 5841, 14728, 5843, 14726, 5845, 14724, 5847, 14722, 5849, 14720, 5851, 14718, 5853, 14716, 5855, 14714, 5857, 14712, 5859, 14710, 5861, 14708, 5863, 14706, 5865, 14704, 5867, 14702, 5869, 14700, 5871, 14698, 5873, 14696, 5875, 14694, 5877, 14692, 5879, 14690, 5881, 14688, 5883, 14686, 5885, 14684, 5887, 14682, 5889, 14680, 5891, 14678, 5893, 14676, 5895, 14674, 5897, 14672, 5899, 14670, 5901, 14668, 5903, 14666, 5905, 14664, 5907, 14662, 5909, 14660, 5911, 14658, 5913, 14656, 5915, 14654, 5917, 14652, 5919, 14650, 5921, 14648, 5923, 14646, 5925, 14644, 5927, 14642, 5929, 14640, 5931, 14638, 5933, 14636, 5935, 14634, 5937, 14632, 5939, 14630, 5941, 14628, 5943, 14626, 5945, 14624, 5947, 14622, 5949, 14620, 5951, 14618, 5953, 14616, 5955, 14614, 5957, 14612, 5959, 14610, 5961, 14608, 5963, 14606, 5965, 14604, 5967, 14602, 5969, 14600, 5971, 14598, 5973, 14596, 5975, 14594, 5977, 14592, 5979, 14590, 5981, 14588, 5983, 14586, 5985, 14584, 5987, 14582, 5989, 14580, 5991, 14578, 5993, 14576, 5995, 14574, 5997, 14572, 5999, 14570, 6001, 14568, 6003, 14566, 6005, 14564, 6007, 14562, 6009, 14560, 6011, 14558, 6013, 14556, 6015, 14554, 6017, 14552, 6019, 14550, 6021, 14548, 6023, 14546, 6025, 14544, 6027, 14542, 6029, 14540, 6031, 14538, 6033, 14536, 6035, 14534, 6037, 14532, 6039, 14530, 6041, 14528, 6043, 14526, 6045, 14524, 6047, 14522, 6049, 14520, 6051, 14518, 6053, 14516, 6055, 14514, 6057, 14512, 6059, 14510, 6061, 14508, 6063, 14506, 6065, 14504, 6067, 14502, 6069, 14500, 6071, 14498, 6073, 14496, 6075, 14494, 6077, 14492, 6079, 14490, 6081, 14488, 6083, 14486, 6085, 14484, 6087, 14482, 6089, 14480, 6091, 14478, 6093, 14476, 6095, 14474, 6097, 14472, 6099, 14470, 6101, 14468, 6103, 14466, 6105, 14464, 6107, 14462, 6109, 14460, 6111, 14458, 6113, 14456, 6115, 14454, 6117, 14452, 6119, 14450, 6121, 14448, 6123, 14446, 6125, 14444, 6127, 14442, 6129, 14440, 6131, 14438, 6133, 14436, 6135, 14434, 6137, 14432, 6139, 14430, 6141, 14428, 6143, 14426, 6145, 14424, 6147, 14422, 6149, 14420, 6151, 14418, 6153, 14416, 6155, 14414, 6157, 14412, 6159, 14410, 6161, 14408, 6163, 14406, 6165, 14404, 6167, 14402, 6169, 14400, 6171, 14398, 6173, 14396, 6175, 14394, 6177, 14392, 6179, 14390, 6181, 14388, 6183, 14386, 6185, 14384, 6187, 14382, 6189, 14380, 6191, 14378, 6193, 14376, 6195, 14374, 6197, 14372, 6199, 14370, 6201, 14368, 6203, 14366, 6205, 14364, 6207, 14362, 6209, 14360, 6211, 14358, 6213, 14356, 6215, 14354, 6217, 14352, 6219, 14350, 6221, 14348, 6223, 14346, 6225, 14344, 6227, 14342, 6229, 14340, 6231, 14338, 6233, 14336, 6235, 14334, 6237, 14332, 6239, 14330, 6241, 14328, 6243, 14326, 6245, 14324, 6247, 14322, 6249, 14320, 6251, 14318, 6253, 14316, 6255, 14314, 6257, 14312, 6259, 14310, 6261, 14308, 6263, 14306, 6265, 14304, 6267, 14302, 6269, 14300, 6271, 14298, 6273, 14296, 6275, 14294, 6277, 14292, 6279, 14290, 6281, 14288, 6283, 14286, 6285, 14284, 6287, 14282, 6289, 14280, 6291, 14278, 6293, 14276, 6295, 14274, 6297, 14272, 6299, 14270, 6301, 14268, 6303, 14266, 6305, 14264, 6307, 14262, 6309, 14260, 6311, 14258, 6313, 14256, 6315, 14254, 6317, 14252, 6319, 14250, 6321, 14248, 6323, 14246, 6325, 14244, 6327, 14242, 6329, 14240, 6331, 14238, 6333, 14236, 6335, 14234, 6337, 14232, 6339, 14230, 6341, 14228, 6343, 14226, 6345, 14224, 6347, 14222, 6349, 14220, 6351, 14218, 6353, 14216, 6355, 14214, 6357, 14212, 6359, 14210, 6361, 14208, 6363, 14206, 6365, 14204, 6367, 14202, 6369, 14200, 6371, 14198, 6373, 14196, 6375, 14194, 6377, 14192, 6379, 14190, 6381, 14188, 6383, 14186, 6385, 14184, 6387, 14182, 6389, 14180, 6391, 14178, 6393, 14176, 6395, 14174, 6397, 14172, 6399, 14170, 6401, 14168, 6403, 14166, 6405, 14164, 6407, 14162, 6409, 14160, 6411, 14158, 6413, 14156, 6415, 14154, 6417, 14152, 6419, 14150, 6421, 14148, 6423, 14146, 6425, 14144, 6427, 14142, 6429, 14140, 6431, 14138, 6433, 14136, 6435, 14134, 6437, 14132, 6439, 14130, 6441, 14128, 6443, 14126, 6445, 14124, 6447, 14122, 6449, 14120, 6451, 14118, 6453, 14116, 6455, 14114, 6457, 14112, 6459, 14110, 6461, 14108, 6463, 14106, 6465, 14104, 6467, 14102, 6469, 14100, 6471, 14098, 6473, 14096, 6475, 14094, 6477, 14092, 6479, 14090, 6481, 14088, 6483, 14086, 6485, 14084, 6487, 14082, 6489, 14080, 6491, 14078, 6493, 14076, 6495, 14074, 6497, 14072, 6499, 14070, 6501, 14068, 6503, 14066, 6505, 14064, 6507, 14062, 6509, 14060, 6511, 14058, 6513, 14056, 6515, 14054, 6517, 14052, 6519, 14050, 6521, 14048, 6523, 14046, 6525, 14044, 6527, 14042, 6529, 14040, 6531, 14038, 6533, 14036, 6535, 14034, 6537, 14032, 6539, 14030, 6541, 14028, 6543, 14026, 6545, 14024, 6547, 14022, 6549, 14020, 6551, 14018, 6553, 14016, 6555, 14014, 6557, 14012, 6559, 14010, 6561, 14008, 6563, 14006, 6565, 14004, 6567, 14002, 6569, 14000, 6571, 13998, 6573, 13996, 6575, 13994, 6577, 13992, 6579, 13990, 6581, 13988, 6583, 13986, 6585, 13984, 6587, 13982, 6589, 13980, 6591, 13978, 6593, 13976, 6595, 13974, 6597, 13972, 6599, 13970, 6601, 13968, 6603, 13966, 6605, 13964, 6607, 13962, 6609, 13960, 6611, 13958, 6613, 13956, 6615, 13954, 6617, 13952, 6619, 13950, 6621, 13948, 6623, 13946, 6625, 13944, 6627, 13942, 6629, 13940, 6631, 13938, 6633, 13936, 6635, 13934, 6637, 13932, 6639, 13930, 6641, 13928, 6643, 13926, 6645, 13924, 6647, 13922, 6649, 13920, 6651, 13918, 6653, 13916, 6655, 13914, 6657, 13912, 6659, 13910, 6661, 13908, 6663, 13906, 6665, 13904, 6667, 13902, 6669, 13900, 6671, 13898, 6673, 13896, 6675, 13894, 6677, 13892, 6679, 13890, 6681, 13888, 6683, 13886, 6685, 13884, 6687, 13882, 6689, 13880, 6691, 13878, 6693, 13876, 6695, 13874, 6697, 13872, 6699, 13870, 6701, 13868, 6703, 13866, 6705, 13864, 6707, 13862, 6709, 13860, 6711, 13858, 6713, 13856, 6715, 13854, 6717, 13852, 6719, 13850, 6721, 13848, 6723, 13846, 6725, 13844, 6727, 13842, 6729, 13840, 6731, 13838, 6733, 13836, 6735, 13834, 6737, 13832, 6739, 13830, 6741, 13828, 6743, 13826, 6745, 13824, 6747, 13822, 6749, 13820, 6751, 13818, 6753, 13816, 6755, 13814, 6757, 13812, 6759, 13810, 6761, 13808, 6763, 13806, 6765, 13804, 6767, 13802, 6769, 13800, 6771, 13798, 6773, 13796, 6775, 13794, 6777, 13792, 6779, 13790, 6781, 13788, 6783, 13786, 6785, 13784, 6787, 13782, 6789, 13780, 6791, 13778, 6793, 13776, 6795, 13774, 6797, 13772, 6799, 13770, 6801, 13768, 6803, 13766, 6805, 13764, 6807, 13762, 6809, 13760, 6811, 13758, 6813, 13756, 6815, 13754, 6817, 13752, 6819, 13750, 6821, 13748, 6823, 13746, 6825, 13744, 6827, 13742, 6829, 13740, 6831, 13738, 6833, 13736, 6835, 13734, 6837, 13732, 6839, 13730, 6841, 13728, 6843, 13726, 6845, 13724, 6847, 13722, 6849, 13720, 6851, 13718, 6853, 13716, 6855, 13714, 6857, 13712, 6859, 13710, 6861, 13708, 6863, 13706, 6865, 13704, 6867, 13702, 6869, 13700, 6871, 13698, 6873, 13696, 6875, 13694, 6877, 13692, 6879, 13690, 6881, 13688, 6883, 13686, 6885, 13684, 6887, 13682, 6889, 13680, 6891, 13678, 6893, 13676, 6895, 13674, 6897, 13672, 6899, 13670, 6901, 13668, 6903, 13666, 6905, 13664, 6907, 13662, 6909, 13660, 6911, 13658, 6913, 13656, 6915, 13654, 6917, 13652, 6919, 13650, 6921, 13648, 6923, 13646, 6925, 13644, 6927, 13642, 6929, 13640, 6931, 13638, 6933, 13636, 6935, 13634, 6937, 13632, 6939, 13630, 6941, 13628, 6943, 13626, 6945, 13624, 6947, 13622, 6949, 13620, 6951, 13618, 6953, 13616, 6955, 13614, 6957, 13612, 6959, 13610, 6961, 13608, 6963, 13606, 6965, 13604, 6967, 13602, 6969, 13600, 6971, 13598, 6973, 13596, 6975, 13594, 6977, 13592, 6979, 13590, 6981, 13588, 6983, 13586, 6985, 13584, 6987, 13582, 6989, 13580, 6991, 13578, 6993, 13576, 6995, 13574, 6997, 13572, 6999, 13570, 7001, 13568, 7003, 13566, 7005, 13564, 7007, 13562, 7009, 13560, 7011, 13558, 7013, 13556, 7015, 13554, 7017, 13552, 7019, 13550, 7021, 13548, 7023, 13546, 7025, 13544, 7027, 13542, 7029, 13540, 7031, 13538, 7033, 13536, 7035, 13534, 7037, 13532, 7039, 13530, 7041, 13528, 7043, 13526, 7045, 13524, 7047, 13522, 7049, 13520, 7051, 13518, 7053, 13516, 7055, 13514, 7057, 13512, 7059, 13510, 7061, 13508, 7063, 13506, 7065, 13504, 7067, 13502, 7069, 13500, 7071, 13498, 7073, 13496, 7075, 13494, 7077, 13492, 7079, 13490, 7081, 13488, 7083, 13486, 7085, 13484, 7087, 13482, 7089, 13480, 7091, 13478, 7093, 13476, 7095, 13474, 7097, 13472, 7099, 13470, 7101, 13468, 7103, 13466, 7105, 13464, 7107, 13462, 7109, 13460, 7111, 13458, 7113, 13456, 7115, 13454, 7117, 13452, 7119, 13450, 7121, 13448, 7123, 13446, 7125, 13444, 7127, 13442, 7129, 13440, 7131, 13438, 7133, 13436, 7135, 13434, 7137, 13432, 7139, 13430, 7141, 13428, 7143, 13426, 7145, 13424, 7147, 13422, 7149, 13420, 7151, 13418, 7153, 13416, 7155, 13414, 7157, 13412, 7159, 13410, 7161, 13408, 7163, 13406, 7165, 13404, 7167, 13402, 7169, 13400, 7171, 13398, 7173, 13396, 7175, 13394, 7177, 13392, 7179, 13390, 7181, 13388, 7183, 13386, 7185, 13384, 7187, 13382, 7189, 13380, 7191, 13378, 7193, 13376, 7195, 13374, 7197, 13372, 7199, 13370, 7201, 13368, 7203, 13366, 7205, 13364, 7207, 13362, 7209, 13360, 7211, 13358, 7213, 13356, 7215, 13354, 7217, 13352, 7219, 13350, 7221, 13348, 7223, 13346, 7225, 13344, 7227, 13342, 7229, 13340, 7231, 13338, 7233, 13336, 7235, 13334, 7237, 13332, 7239, 13330, 7241, 13328, 7243, 13326, 7245, 13324, 7247, 13322, 7249, 13320, 7251, 13318, 7253, 13316, 7255, 13314, 7257, 13312, 7259, 13310, 7261, 13308, 7263, 13306, 7265, 13304, 7267, 13302, 7269, 13300, 7271, 13298, 7273, 13296, 7275, 13294, 7277, 13292, 7279, 13290, 7281, 13288, 7283, 13286, 7285, 13284, 7287, 13282, 7289, 13280, 7291, 13278, 7293, 13276, 7295, 13274, 7297, 13272, 7299, 13270, 7301, 13268, 7303, 13266, 7305, 13264, 7307, 13262, 7309, 13260, 7311, 13258, 7313, 13256, 7315, 13254, 7317, 13252, 7319, 13250, 7321, 13248, 7323, 13246, 7325, 13244, 7327, 13242, 7329, 13240, 7331, 13238, 7333, 13236, 7335, 13234, 7337, 13232, 7339, 13230, 7341, 13228, 7343, 13226, 7345, 13224, 7347, 13222, 7349, 13220, 7351, 13218, 7353, 13216, 7355, 13214, 7357, 13212, 7359, 13210, 7361, 13208, 7363, 13206, 7365, 13204, 7367, 13202, 7369, 13200, 7371, 13198, 7373, 13196, 7375, 13194, 7377, 13192, 7379, 13190, 7381, 13188, 7383, 13186, 7385, 13184, 7387, 13182, 7389, 13180, 7391, 13178, 7393, 13176, 7395, 13174, 7397, 13172, 7399, 13170, 7401, 13168, 7403, 13166, 7405, 13164, 7407, 13162, 7409, 13160, 7411, 13158, 7413, 13156, 7415, 13154, 7417, 13152, 7419, 13150, 7421, 13148, 7423, 13146, 7425, 13144, 7427, 13142, 7429, 13140, 7431, 13138, 7433, 13136, 7435, 13134, 7437, 13132, 7439, 13130, 7441, 13128, 7443, 13126, 7445, 13124, 7447, 13122, 7449, 13120, 7451, 13118, 7453, 13116, 7455, 13114, 7457, 13112, 7459, 13110, 7461, 13108, 7463, 13106, 7465, 13104, 7467, 13102, 7469, 13100, 7471, 13098, 7473, 13096, 7475, 13094, 7477, 13092, 7479, 13090, 7481, 13088, 7483, 13086, 7485, 13084, 7487, 13082, 7489, 13080, 7491, 13078, 7493, 13076, 7495, 13074, 7497, 13072, 7499, 13070, 7501, 13068, 7503, 13066, 7505, 13064, 7507, 13062, 7509, 13060, 7511, 13058, 7513, 13056, 7515, 13054, 7517, 13052, 7519, 13050, 7521, 13048, 7523, 13046, 7525, 13044, 7527, 13042, 7529, 13040, 7531, 13038, 7533, 13036, 7535, 13034, 7537, 13032, 7539, 13030, 7541, 13028, 7543, 13026, 7545, 13024, 7547, 13022, 7549, 13020, 7551, 13018, 7553, 13016, 7555, 13014, 7557, 13012, 7559, 13010, 7561, 13008, 7563, 13006, 7565, 13004, 7567, 13002, 7569, 13000, 7571, 12998, 7573, 12996, 7575, 12994, 7577, 12992, 7579, 12990, 7581, 12988, 7583, 12986, 7585, 12984, 7587, 12982, 7589, 12980, 7591, 12978, 7593, 12976, 7595, 12974, 7597, 12972, 7599, 12970, 7601, 12968, 7603, 12966, 7605, 12964, 7607, 12962, 7609, 12960, 7611, 12958, 7613, 12956, 7615, 12954, 7617, 12952, 7619, 12950, 7621, 12948, 7623, 12946, 7625, 12944, 7627, 12942, 7629, 12940, 7631, 12938, 7633, 12936, 7635, 12934, 7637, 12932, 7639, 12930, 7641, 12928, 7643, 12926, 7645, 12924, 7647, 12922, 7649, 12920, 7651, 12918, 7653, 12916, 7655, 12914, 7657, 12912, 7659, 12910, 7661, 12908, 7663, 12906, 7665, 12904, 7667, 12902, 7669, 12900, 7671, 12898, 7673, 12896, 7675, 12894, 7677, 12892, 7679, 12890, 7681, 12888, 7683, 12886, 7685, 12884, 7687, 12882, 7689, 12880, 7691, 12878, 7693, 12876, 7695, 12874, 7697, 12872, 7699, 12870, 7701, 12868, 7703, 12866, 7705, 12864, 7707, 12862, 7709, 12860, 7711, 12858, 7713, 12856, 7715, 12854, 7717, 12852, 7719, 12850, 7721, 12848, 7723, 12846, 7725, 12844, 7727, 12842, 7729, 12840, 7731, 12838, 7733, 12836, 7735, 12834, 7737, 12832, 7739, 12830, 7741, 12828, 7743, 12826, 7745, 12824, 7747, 12822, 7749, 12820, 7751, 12818, 7753, 12816, 7755, 12814, 7757, 12812, 7759, 12810, 7761, 12808, 7763, 12806, 7765, 12804, 7767, 12802, 7769, 12800, 7771, 12798, 7773, 12796, 7775, 12794, 7777, 12792, 7779, 12790, 7781, 12788, 7783, 12786, 7785, 12784, 7787, 12782, 7789, 12780, 7791, 12778, 7793, 12776, 7795, 12774, 7797, 12772, 7799, 12770, 7801, 12768, 7803, 12766, 7805, 12764, 7807, 12762, 7809, 12760, 7811, 12758, 7813, 12756, 7815, 12754, 7817, 12752, 7819, 12750, 7821, 12748, 7823, 12746, 7825, 12744, 7827, 12742, 7829, 12740, 7831, 12738, 7833, 12736, 7835, 12734, 7837, 12732, 7839, 12730, 7841, 12728, 7843, 12726, 7845, 12724, 7847, 12722, 7849, 12720, 7851, 12718, 7853, 12716, 7855, 12714, 7857, 12712, 7859, 12710, 7861, 12708, 7863, 12706, 7865, 12704, 7867, 12702, 7869, 12700, 7871, 12698, 7873, 12696, 7875, 12694, 7877, 12692, 7879, 12690, 7881, 12688, 7883, 12686, 7885, 12684, 7887, 12682, 7889, 12680, 7891, 12678, 7893, 12676, 7895, 12674, 7897, 12672, 7899, 12670, 7901, 12668, 7903, 12666, 7905, 12664, 7907, 12662, 7909, 12660, 7911, 12658, 7913, 12656, 7915, 12654, 7917, 12652, 7919, 12650, 7921, 12648, 7923, 12646, 7925, 12644, 7927, 12642, 7929, 12640, 7931, 12638, 7933, 12636, 7935, 12634, 7937, 12632, 7939, 12630, 7941, 12628, 7943, 12626, 7945, 12624, 7947, 12622, 7949, 12620, 7951, 12618, 7953, 12616, 7955, 12614, 7957, 12612, 7959, 12610, 7961, 12608, 7963, 12606, 7965, 12604, 7967, 12602, 7969, 12600, 7971, 12598, 7973, 12596, 7975, 12594, 7977, 12592, 7979, 12590, 7981, 12588, 7983, 12586, 7985, 12584, 7987, 12582, 7989, 12580, 7991, 12578, 7993, 12576, 7995, 12574, 7997, 12572, 7999, 12570, 8001, 12568, 8003, 12566, 8005, 12564, 8007, 12562, 8009, 12560, 8011, 12558, 8013, 12556, 8015, 12554, 8017, 12552, 8019, 12550, 8021, 12548, 8023, 12546, 8025, 12544, 8027, 12542, 8029, 12540, 8031, 12538, 8033, 12536, 8035, 12534, 8037, 12532, 8039, 12530, 8041, 12528, 8043, 12526, 8045, 12524, 8047, 12522, 8049, 12520, 8051, 12518, 8053, 12516, 8055, 12514, 8057, 12512, 8059, 12510, 8061, 12508, 8063, 12506, 8065, 12504, 8067, 12502, 8069, 12500, 8071, 12498, 8073, 12496, 8075, 12494, 8077, 12492, 8079, 12490, 8081, 12488, 8083, 12486, 8085, 12484, 8087, 12482, 8089, 12480, 8091, 12478, 8093, 12476, 8095, 12474, 8097, 12472, 8099, 12470, 8101, 12468, 8103, 12466, 8105, 12464, 8107, 12462, 8109, 12460, 8111, 12458, 8113, 12456, 8115, 12454, 8117, 12452, 8119, 12450, 8121, 12448, 8123, 12446, 8125, 12444, 8127, 12442, 8129, 12440, 8131, 12438, 8133, 12436, 8135, 12434, 8137, 12432, 8139, 12430, 8141, 12428, 8143, 12426, 8145, 12424, 8147, 12422, 8149, 12420, 8151, 12418, 8153, 12416, 8155, 12414, 8157, 12412, 8159, 12410, 8161, 12408, 8163, 12406, 8165, 12404, 8167, 12402, 8169, 12400, 8171, 12398, 8173, 12396, 8175, 12394, 8177, 12392, 8179, 12390, 8181, 12388, 8183, 12386, 8185, 12384, 8187, 12382, 8189, 12380, 8191, 12378, 8193, 12376, 8195, 12374, 8197, 12372, 8199, 12370, 8201, 12368, 8203, 12366, 8205, 12364, 8207, 12362, 8209, 12360, 8211, 12358, 8213, 12356, 8215, 12354, 8217, 12352, 8219, 12350, 8221, 12348, 8223, 12346, 8225, 12344, 8227, 12342, 8229, 12340, 8231, 12338, 8233, 12336, 8235, 12334, 8237, 12332, 8239, 12330, 8241, 12328, 8243, 12326, 8245, 12324, 8247, 12322, 8249, 12320, 8251, 12318, 8253, 12316, 8255, 12314, 8257, 12312, 8259, 12310, 8261, 12308, 8263, 12306, 8265, 12304, 8267, 12302, 8269, 12300, 8271, 12298, 8273, 12296, 8275, 12294, 8277, 12292, 8279, 12290, 8281, 12288, 8283, 12286, 8285, 12284, 8287, 12282, 8289, 12280, 8291, 12278, 8293, 12276, 8295, 12274, 8297, 12272, 8299, 12270, 8301, 12268, 8303, 12266, 8305, 12264, 8307, 12262, 8309, 12260, 8311, 12258, 8313, 12256, 8315, 12254, 8317, 12252, 8319, 12250, 8321, 12248, 8323, 12246, 8325, 12244, 8327, 12242, 8329, 12240, 8331, 12238, 8333, 12236, 8335, 12234, 8337, 12232, 8339, 12230, 8341, 12228, 8343, 12226, 8345, 12224, 8347, 12222, 8349, 12220, 8351, 12218, 8353, 12216, 8355, 12214, 8357, 12212, 8359, 12210, 8361, 12208, 8363, 12206, 8365, 12204, 8367, 12202, 8369, 12200, 8371, 12198, 8373, 12196, 8375, 12194, 8377, 12192, 8379, 12190, 8381, 12188, 8383, 12186, 8385, 12184, 8387, 12182, 8389, 12180, 8391, 12178, 8393, 12176, 8395, 12174, 8397, 12172, 8399, 12170, 8401, 12168, 8403, 12166, 8405, 12164, 8407, 12162, 8409, 12160, 8411, 12158, 8413, 12156, 8415, 12154, 8417, 12152, 8419, 12150, 8421, 12148, 8423, 12146, 8425, 12144, 8427, 12142, 8429, 12140, 8431, 12138, 8433, 12136, 8435, 12134, 8437, 12132, 8439, 12130, 8441, 12128, 8443, 12126, 8445, 12124, 8447, 12122, 8449, 12120, 8451, 12118, 8453, 12116, 8455, 12114, 8457, 12112, 8459, 12110, 8461, 12108, 8463, 12106, 8465, 12104, 8467, 12102, 8469, 12100, 8471, 12098, 8473, 12096, 8475, 12094, 8477, 12092, 8479, 12090, 8481, 12088, 8483, 12086, 8485, 12084, 8487, 12082, 8489, 12080, 8491, 12078, 8493, 12076, 8495, 12074, 8497, 12072, 8499, 12070, 8501, 12068, 8503, 12066, 8505, 12064, 8507, 12062, 8509, 12060, 8511, 12058, 8513, 12056, 8515, 12054, 8517, 12052, 8519, 12050, 8521, 12048, 8523, 12046, 8525, 12044, 8527, 12042, 8529, 12040, 8531, 12038, 8533, 12036, 8535, 12034, 8537, 12032, 8539, 12030, 8541, 12028, 8543, 12026, 8545, 12024, 8547, 12022, 8549, 12020, 8551, 12018, 8553, 12016, 8555, 12014, 8557, 12012, 8559, 12010, 8561, 12008, 8563, 12006, 8565, 12004, 8567, 12002, 8569, 12000, 8571, 11998, 8573, 11996, 8575, 11994, 8577, 11992, 8579, 11990, 8581, 11988, 8583, 11986, 8585, 11984, 8587, 11982, 8589, 11980, 8591, 11978, 8593, 11976, 8595, 11974, 8597, 11972, 8599, 11970, 8601, 11968, 8603, 11966, 8605, 11964, 8607, 11962, 8609, 11960, 8611, 11958, 8613, 11956, 8615, 11954, 8617, 11952, 8619, 11950, 8621, 11948, 8623, 11946, 8625, 11944, 8627, 11942, 8629, 11940, 8631, 11938, 8633, 11936, 8635, 11934, 8637, 11932, 8639, 11930, 8641, 11928, 8643, 11926, 8645, 11924, 8647, 11922, 8649, 11920, 8651, 11918, 8653, 11916, 8655, 11914, 8657, 11912, 8659, 11910, 8661, 11908, 8663, 11906, 8665, 11904, 8667, 11902, 8669, 11900, 8671, 11898, 8673, 11896, 8675, 11894, 8677, 11892, 8679, 11890, 8681, 11888, 8683, 11886, 8685, 11884, 8687, 11882, 8689, 11880, 8691, 11878, 8693, 11876, 8695, 11874, 8697, 11872, 8699, 11870, 8701, 11868, 8703, 11866, 8705, 11864, 8707, 11862, 8709, 11860, 8711, 11858, 8713, 11856, 8715, 11854, 8717, 11852, 8719, 11850, 8721, 11848, 8723, 11846, 8725, 11844, 8727, 11842, 8729, 11840, 8731, 11838, 8733, 11836, 8735, 11834, 8737, 11832, 8739, 11830, 8741, 11828, 8743, 11826, 8745, 11824, 8747, 11822, 8749, 11820, 8751, 11818, 8753, 11816, 8755, 11814, 8757, 11812, 8759, 11810, 8761, 11808, 8763, 11806, 8765, 11804, 8767, 11802, 8769, 11800, 8771, 11798, 8773, 11796, 8775, 11794, 8777, 11792, 8779, 11790, 8781, 11788, 8783, 11786, 8785, 11784, 8787, 11782, 8789, 11780, 8791, 11778, 8793, 11776, 8795, 11774, 8797, 11772, 8799, 11770, 8801, 11768, 8803, 11766, 8805, 11764, 8807, 11762, 8809, 11760, 8811, 11758, 8813, 11756, 8815, 11754, 8817, 11752, 8819, 11750, 8821, 11748, 8823, 11746, 8825, 11744, 8827, 11742, 8829, 11740, 8831, 11738, 8833, 11736, 8835, 11734, 8837, 11732, 8839, 11730, 8841, 11728, 8843, 11726, 8845, 11724, 8847, 11722, 8849, 11720, 8851, 11718, 8853, 11716, 8855, 11714, 8857, 11712, 8859, 11710, 8861, 11708, 8863, 11706, 8865, 11704, 8867, 11702, 8869, 11700, 8871, 11698, 8873, 11696, 8875, 11694, 8877, 11692, 8879, 11690, 8881, 11688, 8883, 11686, 8885, 11684, 8887, 11682, 8889, 11680, 8891, 11678, 8893, 11676, 8895, 11674, 8897, 11672, 8899, 11670, 8901, 11668, 8903, 11666, 8905, 11664, 8907, 11662, 8909, 11660, 8911, 11658, 8913, 11656, 8915, 11654, 8917, 11652, 8919, 11650, 8921, 11648, 8923, 11646, 8925, 11644, 8927, 11642, 8929, 11640, 8931, 11638, 8933, 11636, 8935, 11634, 8937, 11632, 8939, 11630, 8941, 11628, 8943, 11626, 8945, 11624, 8947, 11622, 8949, 11620, 8951, 11618, 8953, 11616, 8955, 11614, 8957, 11612, 8959, 11610, 8961, 11608, 8963, 11606, 8965, 11604, 8967, 11602, 8969, 11600, 8971, 11598, 8973, 11596, 8975, 11594, 8977, 11592, 8979, 11590, 8981, 11588, 8983, 11586, 8985, 11584, 8987, 11582, 8989, 11580, 8991, 11578, 8993, 11576, 8995, 11574, 8997, 11572, 8999, 11570, 9001, 11568, 9003, 11566, 9005, 11564, 9007, 11562, 9009, 11560, 9011, 11558, 9013, 11556, 9015, 11554, 9017, 11552, 9019, 11550, 9021, 11548, 9023, 11546, 9025, 11544, 9027, 11542, 9029, 11540, 9031, 11538, 9033, 11536, 9035, 11534, 9037, 11532, 9039, 11530, 9041, 11528, 9043, 11526, 9045, 11524, 9047, 11522, 9049, 11520, 9051, 11518, 9053, 11516, 9055, 11514, 9057, 11512, 9059, 11510, 9061, 11508, 9063, 11506, 9065, 11504, 9067, 11502, 9069, 11500, 9071, 11498, 9073, 11496, 9075, 11494, 9077, 11492, 9079, 11490, 9081, 11488, 9083, 11486, 9085, 11484, 9087, 11482, 9089, 11480, 9091, 11478, 9093, 11476, 9095, 11474, 9097, 11472, 9099, 11470, 9101, 11468, 9103, 11466, 9105, 11464, 9107, 11462, 9109, 11460, 9111, 11458, 9113, 11456, 9115, 11454, 9117, 11452, 9119, 11450, 9121, 11448, 9123, 11446, 9125, 11444, 9127, 11442, 9129, 11440, 9131, 11438, 9133, 11436, 9135, 11434, 9137, 11432, 9139, 11430, 9141, 11428, 9143, 11426, 9145, 11424, 9147, 11422, 9149, 11420, 9151, 11418, 9153, 11416, 9155, 11414, 9157, 11412, 9159, 11410, 9161, 11408, 9163, 11406, 9165, 11404, 9167, 11402, 9169, 11400, 9171, 11398, 9173, 11396, 9175, 11394, 9177, 11392, 9179, 11390, 9181, 11388, 9183, 11386, 9185, 11384, 9187, 11382, 9189, 11380, 9191, 11378, 9193, 11376, 9195, 11374, 9197, 11372, 9199, 11370, 9201, 11368, 9203, 11366, 9205, 11364, 9207, 11362, 9209, 11360, 9211, 11358, 9213, 11356, 9215, 11354, 9217, 11352, 9219, 11350, 9221, 11348, 9223, 11346, 9225, 11344, 9227, 11342, 9229, 11340, 9231, 11338, 9233, 11336, 9235, 11334, 9237, 11332, 9239, 11330, 9241, 11328, 9243, 11326, 9245, 11324, 9247, 11322, 9249, 11320, 9251, 11318, 9253, 11316, 9255, 11314, 9257, 11312, 9259, 11310, 9261, 11308, 9263, 11306, 9265, 11304, 9267, 11302, 9269, 11300, 9271, 11298, 9273, 11296, 9275, 11294, 9277, 11292, 9279, 11290, 9281, 11288, 9283, 11286, 9285, 11284, 9287, 11282, 9289, 11280, 9291, 11278, 9293, 11276, 9295, 11274, 9297, 11272, 9299, 11270, 9301, 11268, 9303, 11266, 9305, 11264, 9307, 11262, 9309, 11260, 9311, 11258, 9313, 11256, 9315, 11254, 9317, 11252, 9319, 11250, 9321, 11248, 9323, 11246, 9325, 11244, 9327, 11242, 9329, 11240, 9331, 11238, 9333, 11236, 9335, 11234, 9337, 11232, 9339, 11230, 9341, 11228, 9343, 11226, 9345, 11224, 9347, 11222, 9349, 11220, 9351, 11218, 9353, 11216, 9355, 11214, 9357, 11212, 9359, 11210, 9361, 11208, 9363, 11206, 9365, 11204, 9367, 11202, 9369, 11200, 9371, 11198, 9373, 11196, 9375, 11194, 9377, 11192, 9379, 11190, 9381, 11188, 9383, 11186, 9385, 11184, 9387, 11182, 9389, 11180, 9391, 11178, 9393, 11176, 9395, 11174, 9397, 11172, 9399, 11170, 9401, 11168, 9403, 11166, 9405, 11164, 9407, 11162, 9409, 11160, 9411, 11158, 9413, 11156, 9415, 11154, 9417, 11152, 9419, 11150, 9421, 11148, 9423, 11146, 9425, 11144, 9427, 11142, 9429, 11140, 9431, 11138, 9433, 11136, 9435, 11134, 9437, 11132, 9439, 11130, 9441, 11128, 9443, 11126, 9445, 11124, 9447, 11122, 9449, 11120, 9451, 11118, 9453, 11116, 9455, 11114, 9457, 11112, 9459, 11110, 9461, 11108, 9463, 11106, 9465, 11104, 9467, 11102, 9469, 11100, 9471, 11098, 9473, 11096, 9475, 11094, 9477, 11092, 9479, 11090, 9481, 11088, 9483, 11086, 9485, 11084, 9487, 11082, 9489, 11080, 9491, 11078, 9493, 11076, 9495, 11074, 9497, 11072, 9499, 11070, 9501, 11068, 9503, 11066, 9505, 11064, 9507, 11062, 9509, 11060, 9511, 11058, 9513, 11056, 9515, 11054, 9517, 11052, 9519, 11050, 9521, 11048, 9523, 11046, 9525, 11044, 9527, 11042, 9529, 11040, 9531, 11038, 9533, 11036, 9535, 11034, 9537, 11032, 9539, 11030, 9541, 11028, 9543, 11026, 9545, 11024, 9547, 11022, 9549, 11020, 9551, 11018, 9553, 11016, 9555, 11014, 9557, 11012, 9559, 11010, 9561, 11008, 9563, 11006, 9565, 11004, 9567, 11002, 9569, 11000, 9571, 10998, 9573, 10996, 9575, 10994, 9577, 10992, 9579, 10990, 9581, 10988, 9583, 10986, 9585, 10984, 9587, 10982, 9589, 10980, 9591, 10978, 9593, 10976, 9595, 10974, 9597, 10972, 9599, 10970, 9601, 10968, 9603, 10966, 9605, 10964, 9607, 10962, 9609, 10960, 9611, 10958, 9613, 10956, 9615, 10954, 9617, 10952, 9619, 10950, 9621, 10948, 9623, 10946, 9625, 10944, 9627, 10942, 9629, 10940, 9631, 10938, 9633, 10936, 9635, 10934, 9637, 10932, 9639, 10930, 9641, 10928, 9643, 10926, 9645, 10924, 9647, 10922, 9649, 10920, 9651, 10918, 9653, 10916, 9655, 10914, 9657, 10912, 9659, 10910, 9661, 10908, 9663, 10906, 9665, 10904, 9667, 10902, 9669, 10900, 9671, 10898, 9673, 10896, 9675, 10894, 9677, 10892, 9679, 10890, 9681, 10888, 9683, 10886, 9685, 10884, 9687, 10882, 9689, 10880, 9691, 10878, 9693, 10876, 9695, 10874, 9697, 10872, 9699, 10870, 9701, 10868, 9703, 10866, 9705, 10864, 9707, 10862, 9709, 10860, 9711, 10858, 9713, 10856, 9715, 10854, 9717, 10852, 9719, 10850, 9721, 10848, 9723, 10846, 9725, 10844, 9727, 10842, 9729, 10840, 9731, 10838, 9733, 10836, 9735, 10834, 9737, 10832, 9739, 10830, 9741, 10828, 9743, 10826, 9745, 10824, 9747, 10822, 9749, 10820, 9751, 10818, 9753, 10816, 9755, 10814, 9757, 10812, 9759, 10810, 9761, 10808, 9763, 10806, 9765, 10804, 9767, 10802, 9769, 10800, 9771, 10798, 9773, 10796, 9775, 10794, 9777, 10792, 9779, 10790, 9781, 10788, 9783, 10786, 9785, 10784, 9787, 10782, 9789, 10780, 9791, 10778, 9793, 10776, 9795, 10774, 9797, 10772, 9799, 10770, 9801, 10768, 9803, 10766, 9805, 10764, 9807, 10762, 9809, 10760, 9811, 10758, 9813, 10756, 9815, 10754, 9817, 10752, 9819, 10750, 9821, 10748, 9823, 10746, 9825, 10744, 9827, 10742, 9829, 10740, 9831, 10738, 9833, 10736, 9835, 10734, 9837, 10732, 9839, 10730, 9841, 10728, 9843, 10726, 9845, 10724, 9847, 10722, 9849, 10720, 9851, 10718, 9853, 10716, 9855, 10714, 9857, 10712, 9859, 10710, 9861, 10708, 9863, 10706, 9865, 10704, 9867, 10702, 9869, 10700, 9871, 10698, 9873, 10696, 9875, 10694, 9877, 10692, 9879, 10690, 9881, 10688, 9883, 10686, 9885, 10684, 9887, 10682, 9889, 10680, 9891, 10678, 9893, 10676, 9895, 10674, 9897, 10672, 9899, 10670, 9901, 10668, 9903, 10666, 9905, 10664, 9907, 10662, 9909, 10660, 9911, 10658, 9913, 10656, 9915, 10654, 9917, 10652, 9919, 10650, 9921, 10648, 9923, 10646, 9925, 10644, 9927, 10642, 9929, 10640, 9931, 10638, 9933, 10636, 9935, 10634, 9937, 10632, 9939, 10630, 9941, 10628, 9943, 10626, 9945, 10624, 9947, 10622, 9949, 10620, 9951, 10618, 9953, 10616, 9955, 10614, 9957, 10612, 9959, 10610, 9961, 10608, 9963, 10606, 9965, 10604, 9967, 10602, 9969, 10600, 9971, 10598, 9973, 10596, 9975, 10594, 9977, 10592, 9979, 10590, 9981, 10588, 9983, 10586, 9985, 10584, 9987, 10582, 9989, 10580, 9991, 10578, 9993, 10576, 9995, 10574, 9997, 10572, 9999, 10570, 10001, 10568, 10003, 10566, 10005, 10564, 10007, 10562, 10009, 10560, 10011, 10558, 10013, 10556, 10015, 10554, 10017, 10552, 10019, 10550, 10021, 10548, 10023, 10546, 10025, 10544, 10027, 10542, 10029, 10540, 10031, 10538, 10033, 10536, 10035, 10534, 10037, 10532, 10039, 10530, 10041, 10528, 10043, 10526, 10045, 10524, 10047, 10522, 10049, 10520, 10051, 10518, 10053, 10516, 10055, 10514, 10057, 10512, 10059, 10510, 10061, 10508, 10063, 10506, 10065, 10504, 10067, 10502, 10069, 10500, 10071, 10498, 10073, 10496, 10075, 10494, 10077, 10492, 10079, 10490, 10081, 10488, 10083, 10486, 10085, 10484, 10087, 10482, 10089, 10480, 10091, 10478, 10093, 10476, 10095, 10474, 10097, 10472, 10099, 10470, 10101, 10468, 10103, 10466, 10105, 10464, 10107, 10462, 10109, 10460, 10111, 10458, 10113, 10456, 10115, 10454, 10117, 10452, 10119, 10450, 10121, 10448, 10123, 10446, 10125, 10444, 10127, 10442, 10129, 10440, 10131, 10438, 10133, 10436, 10135, 10434, 10137, 10432, 10139, 10430, 10141, 10428, 10143, 10426, 10145, 10424, 10147, 10422, 10149, 10420, 10151, 10418, 10153, 10416, 10155, 10414, 10157, 10412, 10159, 10410, 10161, 10408, 10163, 10406, 10165, 10404, 10167, 10402, 10169, 10400, 10171, 10398, 10173, 10396, 10175, 10394, 10177, 10392, 10179, 10390, 10181, 10388, 10183, 10386, 10185, 10384, 10187, 10382, 10189, 10380, 10191, 10378, 10193, 10376, 10195, 10374, 10197, 10372, 10199, 10370, 10201, 10368, 10203, 10366, 10205, 10364, 10207, 10362, 10209, 10360, 10211, 10358, 10213, 10356, 10215, 10354, 10217, 10352, 10219, 10350, 10221, 10348, 10223, 10346, 10225, 10344, 10227, 10342, 10229, 10340, 10231, 10338, 10233, 10336, 10235, 10334, 10237, 10332, 10239, 10330, 10241, 10328, 10243, 10326, 10245, 10324, 10247, 10322, 10249, 10320, 10251, 10318, 10253, 10316, 10255, 10314, 10257, 10312, 10259, 10310, 10261, 10308, 10263, 10306, 10265, 10304, 10267, 10302, 10269, 10300, 10271, 10298, 10273, 10296, 10275, 10294, 10277, 10292, 10279, 10290, 10281, 10288, 10283, 10286, 10285, 10284, 10287, 10282, 10289, 10280, 10291, 10278, 10293, 10276, 10295, 10274, 10297, 10272, 10299, 10270, 10301, 10268, 10303, 10266, 10305, 10264, 10307, 10262, 10309, 10260, 10311, 10258, 10313, 10256, 10315, 10254, 10317, 10252, 10319, 10250, 10321, 10248, 10323, 10246, 10325, 10244, 10327, 10242, 10329, 10240, 10331, 10238, 10333, 10236, 10335, 10234, 10337, 10232, 10339, 10230, 10341, 10228, 10343, 10226, 10345, 10224, 10347, 10222, 10349, 10220, 10351, 10218, 10353, 10216, 10355, 10214, 10357, 10212, 10359, 10210, 10361, 10208, 10363, 10206, 10365, 10204, 10367, 10202, 10369, 10200, 10371, 10198, 10373, 10196, 10375, 10194, 10377, 10192, 10379, 10190, 10381, 10188, 10383, 10186, 10385, 10184, 10387, 10182, 10389, 10180, 10391, 10178, 10393, 10176, 10395, 10174, 10397, 10172, 10399, 10170, 10401, 10168, 10403, 10166, 10405, 10164, 10407, 10162, 10409, 10160, 10411, 10158, 10413, 10156, 10415, 10154, 10417, 10152, 10419, 10150, 10421, 10148, 10423, 10146, 10425, 10144, 10427, 10142, 10429, 10140, 10431, 10138, 10433, 10136, 10435, 10134, 10437, 10132, 10439, 10130, 10441, 10128, 10443, 10126, 10445, 10124, 10447, 10122, 10449, 10120, 10451, 10118, 10453, 10116, 10455, 10114, 10457, 10112, 10459, 10110, 10461, 10108, 10463, 10106, 10465, 10104, 10467, 10102, 10469, 10100, 10471, 10098, 10473, 10096, 10475, 10094, 10477, 10092, 10479, 10090, 10481, 10088, 10483, 10086, 10485, 10084, 10487, 10082, 10489, 10080, 10491, 10078, 10493, 10076, 10495, 10074, 10497, 10072, 10499, 10070, 10501, 10068, 10503, 10066, 10505, 10064, 10507, 10062, 10509, 10060, 10511, 10058, 10513, 10056, 10515, 10054, 10517, 10052, 10519, 10050, 10521, 10048, 10523, 10046, 10525, 10044, 10527, 10042, 10529, 10040, 10531, 10038, 10533, 10036, 10535, 10034, 10537, 10032, 10539, 10030, 10541, 10028, 10543, 10026, 10545, 10024, 10547, 10022, 10549, 10020, 10551, 10018, 10553, 10016, 10555, 10014, 10557, 10012, 10559, 10010, 10561, 10008, 10563, 10006, 10565, 10004, 10567, 10002, 10569, 10000, 10571, 9998, 10573, 9996, 10575, 9994, 10577, 9992, 10579, 9990, 10581, 9988, 10583, 9986, 10585, 9984, 10587, 9982, 10589, 9980, 10591, 9978, 10593, 9976, 10595, 9974, 10597, 9972, 10599, 9970, 10601, 9968, 10603, 9966, 10605, 9964, 10607, 9962, 10609, 9960, 10611, 9958, 10613, 9956, 10615, 9954, 10617, 9952, 10619, 9950, 10621, 9948, 10623, 9946, 10625, 9944, 10627, 9942, 10629, 9940, 10631, 9938, 10633, 9936, 10635, 9934, 10637, 9932, 10639, 9930, 10641, 9928, 10643, 9926, 10645, 9924, 10647, 9922, 10649, 9920, 10651, 9918, 10653, 9916, 10655, 9914, 10657, 9912, 10659, 9910, 10661, 9908, 10663, 9906, 10665, 9904, 10667, 9902, 10669, 9900, 10671, 9898, 10673, 9896, 10675, 9894, 10677, 9892, 10679, 9890, 10681, 9888, 10683, 9886, 10685, 9884, 10687, 9882, 10689, 9880, 10691, 9878, 10693, 9876, 10695, 9874, 10697, 9872, 10699, 9870, 10701, 9868, 10703, 9866, 10705, 9864, 10707, 9862, 10709, 9860, 10711, 9858, 10713, 9856, 10715, 9854, 10717, 9852, 10719, 9850, 10721, 9848, 10723, 9846, 10725, 9844, 10727, 9842, 10729, 9840, 10731, 9838, 10733, 9836, 10735, 9834, 10737, 9832, 10739, 9830, 10741, 9828, 10743, 9826, 10745, 9824, 10747, 9822, 10749, 9820, 10751, 9818, 10753, 9816, 10755, 9814, 10757, 9812, 10759, 9810, 10761, 9808, 10763, 9806, 10765, 9804, 10767, 9802, 10769, 9800, 10771, 9798, 10773, 9796, 10775, 9794, 10777, 9792, 10779, 9790, 10781, 9788, 10783, 9786, 10785, 9784, 10787, 9782, 10789, 9780, 10791, 9778, 10793, 9776, 10795, 9774, 10797, 9772, 10799, 9770, 10801, 9768, 10803, 9766, 10805, 9764, 10807, 9762, 10809, 9760, 10811, 9758, 10813, 9756, 10815, 9754, 10817, 9752, 10819, 9750, 10821, 9748, 10823, 9746, 10825, 9744, 10827, 9742, 10829, 9740, 10831, 9738, 10833, 9736, 10835, 9734, 10837, 9732, 10839, 9730, 10841, 9728, 10843, 9726, 10845, 9724, 10847, 9722, 10849, 9720, 10851, 9718, 10853, 9716, 10855, 9714, 10857, 9712, 10859, 9710, 10861, 9708, 10863, 9706, 10865, 9704, 10867, 9702, 10869, 9700, 10871, 9698, 10873, 9696, 10875, 9694, 10877, 9692, 10879, 9690, 10881, 9688, 10883, 9686, 10885, 9684, 10887, 9682, 10889, 9680, 10891, 9678, 10893, 9676, 10895, 9674, 10897, 9672, 10899, 9670, 10901, 9668, 10903, 9666, 10905, 9664, 10907, 9662, 10909, 9660, 10911, 9658, 10913, 9656, 10915, 9654, 10917, 9652, 10919, 9650, 10921, 9648, 10923, 9646, 10925, 9644, 10927, 9642, 10929, 9640, 10931, 9638, 10933, 9636, 10935, 9634, 10937, 9632, 10939, 9630, 10941, 9628, 10943, 9626, 10945, 9624, 10947, 9622, 10949, 9620, 10951, 9618, 10953, 9616, 10955, 9614, 10957, 9612, 10959, 9610, 10961, 9608, 10963, 9606, 10965, 9604, 10967, 9602, 10969, 9600, 10971, 9598, 10973, 9596, 10975, 9594, 10977, 9592, 10979, 9590, 10981, 9588, 10983, 9586, 10985, 9584, 10987, 9582, 10989, 9580, 10991, 9578, 10993, 9576, 10995, 9574, 10997, 9572, 10999, 9570, 11001, 9568, 11003, 9566, 11005, 9564, 11007, 9562, 11009, 9560, 11011, 9558, 11013, 9556, 11015, 9554, 11017, 9552, 11019, 9550, 11021, 9548, 11023, 9546, 11025, 9544, 11027, 9542, 11029, 9540, 11031, 9538, 11033, 9536, 11035, 9534, 11037, 9532, 11039, 9530, 11041, 9528, 11043, 9526, 11045, 9524, 11047, 9522, 11049, 9520, 11051, 9518, 11053, 9516, 11055, 9514, 11057, 9512, 11059, 9510, 11061, 9508, 11063, 9506, 11065, 9504, 11067, 9502, 11069, 9500, 11071, 9498, 11073, 9496, 11075, 9494, 11077, 9492, 11079, 9490, 11081, 9488, 11083, 9486, 11085, 9484, 11087, 9482, 11089, 9480, 11091, 9478, 11093, 9476, 11095, 9474, 11097, 9472, 11099, 9470, 11101, 9468, 11103, 9466, 11105, 9464, 11107, 9462, 11109, 9460, 11111, 9458, 11113, 9456, 11115, 9454, 11117, 9452, 11119, 9450, 11121, 9448, 11123, 9446, 11125, 9444, 11127, 9442, 11129, 9440, 11131, 9438, 11133, 9436, 11135, 9434, 11137, 9432, 11139, 9430, 11141, 9428, 11143, 9426, 11145, 9424, 11147, 9422, 11149, 9420, 11151, 9418, 11153, 9416, 11155, 9414, 11157, 9412, 11159, 9410, 11161, 9408, 11163, 9406, 11165, 9404, 11167, 9402, 11169, 9400, 11171, 9398, 11173, 9396, 11175, 9394, 11177, 9392, 11179, 9390, 11181, 9388, 11183, 9386, 11185, 9384, 11187, 9382, 11189, 9380, 11191, 9378, 11193, 9376, 11195, 9374, 11197, 9372, 11199, 9370, 11201, 9368, 11203, 9366, 11205, 9364, 11207, 9362, 11209, 9360, 11211, 9358, 11213, 9356, 11215, 9354, 11217, 9352, 11219, 9350, 11221, 9348, 11223, 9346, 11225, 9344, 11227, 9342, 11229, 9340, 11231, 9338, 11233, 9336, 11235, 9334, 11237, 9332, 11239, 9330, 11241, 9328, 11243, 9326, 11245, 9324, 11247, 9322, 11249, 9320, 11251, 9318, 11253, 9316, 11255, 9314, 11257, 9312, 11259, 9310, 11261, 9308, 11263, 9306, 11265, 9304, 11267, 9302, 11269, 9300, 11271, 9298, 11273, 9296, 11275, 9294, 11277, 9292, 11279, 9290, 11281, 9288, 11283, 9286, 11285, 9284, 11287, 9282, 11289, 9280, 11291, 9278, 11293, 9276, 11295, 9274, 11297, 9272, 11299, 9270, 11301, 9268, 11303, 9266, 11305, 9264, 11307, 9262, 11309, 9260, 11311, 9258, 11313, 9256, 11315, 9254, 11317, 9252, 11319, 9250, 11321, 9248, 11323, 9246, 11325, 9244, 11327, 9242, 11329, 9240, 11331, 9238, 11333, 9236, 11335, 9234, 11337, 9232, 11339, 9230, 11341, 9228, 11343, 9226, 11345, 9224, 11347, 9222, 11349, 9220, 11351, 9218, 11353, 9216, 11355, 9214, 11357, 9212, 11359, 9210, 11361, 9208, 11363, 9206, 11365, 9204, 11367, 9202, 11369, 9200, 11371, 9198, 11373, 9196, 11375, 9194, 11377, 9192, 11379, 9190, 11381, 9188, 11383, 9186, 11385, 9184, 11387, 9182, 11389, 9180, 11391, 9178, 11393, 9176, 11395, 9174, 11397, 9172, 11399, 9170, 11401, 9168, 11403, 9166, 11405, 9164, 11407, 9162, 11409, 9160, 11411, 9158, 11413, 9156, 11415, 9154, 11417, 9152, 11419, 9150, 11421, 9148, 11423, 9146, 11425, 9144, 11427, 9142, 11429, 9140, 11431, 9138, 11433, 9136, 11435, 9134, 11437, 9132, 11439, 9130, 11441, 9128, 11443, 9126, 11445, 9124, 11447, 9122, 11449, 9120, 11451, 9118, 11453, 9116, 11455, 9114, 11457, 9112, 11459, 9110, 11461, 9108, 11463, 9106, 11465, 9104, 11467, 9102, 11469, 9100, 11471, 9098, 11473, 9096, 11475, 9094, 11477, 9092, 11479, 9090, 11481, 9088, 11483, 9086, 11485, 9084, 11487, 9082, 11489, 9080, 11491, 9078, 11493, 9076, 11495, 9074, 11497, 9072, 11499, 9070, 11501, 9068, 11503, 9066, 11505, 9064, 11507, 9062, 11509, 9060, 11511, 9058, 11513, 9056, 11515, 9054, 11517, 9052, 11519, 9050, 11521, 9048, 11523, 9046, 11525, 9044, 11527, 9042, 11529, 9040, 11531, 9038, 11533, 9036, 11535, 9034, 11537, 9032, 11539, 9030, 11541, 9028, 11543, 9026, 11545, 9024, 11547, 9022, 11549, 9020, 11551, 9018, 11553, 9016, 11555, 9014, 11557, 9012, 11559, 9010, 11561, 9008, 11563, 9006, 11565, 9004, 11567, 9002, 11569, 9000, 11571, 8998, 11573, 8996, 11575, 8994, 11577, 8992, 11579, 8990, 11581, 8988, 11583, 8986, 11585, 8984, 11587, 8982, 11589, 8980, 11591, 8978, 11593, 8976, 11595, 8974, 11597, 8972, 11599, 8970, 11601, 8968, 11603, 8966, 11605, 8964, 11607, 8962, 11609, 8960, 11611, 8958, 11613, 8956, 11615, 8954, 11617, 8952, 11619, 8950, 11621, 8948, 11623, 8946, 11625, 8944, 11627, 8942, 11629, 8940, 11631, 8938, 11633, 8936, 11635, 8934, 11637, 8932, 11639, 8930, 11641, 8928, 11643, 8926, 11645, 8924, 11647, 8922, 11649, 8920, 11651, 8918, 11653, 8916, 11655, 8914, 11657, 8912, 11659, 8910, 11661, 8908, 11663, 8906, 11665, 8904, 11667, 8902, 11669, 8900, 11671, 8898, 11673, 8896, 11675, 8894, 11677, 8892, 11679, 8890, 11681, 8888, 11683, 8886, 11685, 8884, 11687, 8882, 11689, 8880, 11691, 8878, 11693, 8876, 11695, 8874, 11697, 8872, 11699, 8870, 11701, 8868, 11703, 8866, 11705, 8864, 11707, 8862, 11709, 8860, 11711, 8858, 11713, 8856, 11715, 8854, 11717, 8852, 11719, 8850, 11721, 8848, 11723, 8846, 11725, 8844, 11727, 8842, 11729, 8840, 11731, 8838, 11733, 8836, 11735, 8834, 11737, 8832, 11739, 8830, 11741, 8828, 11743, 8826, 11745, 8824, 11747, 8822, 11749, 8820, 11751, 8818, 11753, 8816, 11755, 8814, 11757, 8812, 11759, 8810, 11761, 8808, 11763, 8806, 11765, 8804, 11767, 8802, 11769, 8800, 11771, 8798, 11773, 8796, 11775, 8794, 11777, 8792, 11779, 8790, 11781, 8788, 11783, 8786, 11785, 8784, 11787, 8782, 11789, 8780, 11791, 8778, 11793, 8776, 11795, 8774, 11797, 8772, 11799, 8770, 11801, 8768, 11803, 8766, 11805, 8764, 11807, 8762, 11809, 8760, 11811, 8758, 11813, 8756, 11815, 8754, 11817, 8752, 11819, 8750, 11821, 8748, 11823, 8746, 11825, 8744, 11827, 8742, 11829, 8740, 11831, 8738, 11833, 8736, 11835, 8734, 11837, 8732, 11839, 8730, 11841, 8728, 11843, 8726, 11845, 8724, 11847, 8722, 11849, 8720, 11851, 8718, 11853, 8716, 11855, 8714, 11857, 8712, 11859, 8710, 11861, 8708, 11863, 8706, 11865, 8704, 11867, 8702, 11869, 8700, 11871, 8698, 11873, 8696, 11875, 8694, 11877, 8692, 11879, 8690, 11881, 8688, 11883, 8686, 11885, 8684, 11887, 8682, 11889, 8680, 11891, 8678, 11893, 8676, 11895, 8674, 11897, 8672, 11899, 8670, 11901, 8668, 11903, 8666, 11905, 8664, 11907, 8662, 11909, 8660, 11911, 8658, 11913, 8656, 11915, 8654, 11917, 8652, 11919, 8650, 11921, 8648, 11923, 8646, 11925, 8644, 11927, 8642, 11929, 8640, 11931, 8638, 11933, 8636, 11935, 8634, 11937, 8632, 11939, 8630, 11941, 8628, 11943, 8626, 11945, 8624, 11947, 8622, 11949, 8620, 11951, 8618, 11953, 8616, 11955, 8614, 11957, 8612, 11959, 8610, 11961, 8608, 11963, 8606, 11965, 8604, 11967, 8602, 11969, 8600, 11971, 8598, 11973, 8596, 11975, 8594, 11977, 8592, 11979, 8590, 11981, 8588, 11983, 8586, 11985, 8584, 11987, 8582, 11989, 8580, 11991, 8578, 11993, 8576, 11995, 8574, 11997, 8572, 11999, 8570, 12001, 8568, 12003, 8566, 12005, 8564, 12007, 8562, 12009, 8560, 12011, 8558, 12013, 8556, 12015, 8554, 12017, 8552, 12019, 8550, 12021, 8548, 12023, 8546, 12025, 8544, 12027, 8542, 12029, 8540, 12031, 8538, 12033, 8536, 12035, 8534, 12037, 8532, 12039, 8530, 12041, 8528, 12043, 8526, 12045, 8524, 12047, 8522, 12049, 8520, 12051, 8518, 12053, 8516, 12055, 8514, 12057, 8512, 12059, 8510, 12061, 8508, 12063, 8506, 12065, 8504, 12067, 8502, 12069, 8500, 12071, 8498, 12073, 8496, 12075, 8494, 12077, 8492, 12079, 8490, 12081, 8488, 12083, 8486, 12085, 8484, 12087, 8482, 12089, 8480, 12091, 8478, 12093, 8476, 12095, 8474, 12097, 8472, 12099, 8470, 12101, 8468, 12103, 8466, 12105, 8464, 12107, 8462, 12109, 8460, 12111, 8458, 12113, 8456, 12115, 8454, 12117, 8452, 12119, 8450, 12121, 8448, 12123, 8446, 12125, 8444, 12127, 8442, 12129, 8440, 12131, 8438, 12133, 8436, 12135, 8434, 12137, 8432, 12139, 8430, 12141, 8428, 12143, 8426, 12145, 8424, 12147, 8422, 12149, 8420, 12151, 8418, 12153, 8416, 12155, 8414, 12157, 8412, 12159, 8410, 12161, 8408, 12163, 8406, 12165, 8404, 12167, 8402, 12169, 8400, 12171, 8398, 12173, 8396, 12175, 8394, 12177, 8392, 12179, 8390, 12181, 8388, 12183, 8386, 12185, 8384, 12187, 8382, 12189, 8380, 12191, 8378, 12193, 8376, 12195, 8374, 12197, 8372, 12199, 8370, 12201, 8368, 12203, 8366, 12205, 8364, 12207, 8362, 12209, 8360, 12211, 8358, 12213, 8356, 12215, 8354, 12217, 8352, 12219, 8350, 12221, 8348, 12223, 8346, 12225, 8344, 12227, 8342, 12229, 8340, 12231, 8338, 12233, 8336, 12235, 8334, 12237, 8332, 12239, 8330, 12241, 8328, 12243, 8326, 12245, 8324, 12247, 8322, 12249, 8320, 12251, 8318, 12253, 8316, 12255, 8314, 12257, 8312, 12259, 8310, 12261, 8308, 12263, 8306, 12265, 8304, 12267, 8302, 12269, 8300, 12271, 8298, 12273, 8296, 12275, 8294, 12277, 8292, 12279, 8290, 12281, 8288, 12283, 8286, 12285, 8284, 12287, 8282, 12289, 8280, 12291, 8278, 12293, 8276, 12295, 8274, 12297, 8272, 12299, 8270, 12301, 8268, 12303, 8266, 12305, 8264, 12307, 8262, 12309, 8260, 12311, 8258, 12313, 8256, 12315, 8254, 12317, 8252, 12319, 8250, 12321, 8248, 12323, 8246, 12325, 8244, 12327, 8242, 12329, 8240, 12331, 8238, 12333, 8236, 12335, 8234, 12337, 8232, 12339, 8230, 12341, 8228, 12343, 8226, 12345, 8224, 12347, 8222, 12349, 8220, 12351, 8218, 12353, 8216, 12355, 8214, 12357, 8212, 12359, 8210, 12361, 8208, 12363, 8206, 12365, 8204, 12367, 8202, 12369, 8200, 12371, 8198, 12373, 8196, 12375, 8194, 12377, 8192, 12379, 8190, 12381, 8188, 12383, 8186, 12385, 8184, 12387, 8182, 12389, 8180, 12391, 8178, 12393, 8176, 12395, 8174, 12397, 8172, 12399, 8170, 12401, 8168, 12403, 8166, 12405, 8164, 12407, 8162, 12409, 8160, 12411, 8158, 12413, 8156, 12415, 8154, 12417, 8152, 12419, 8150, 12421, 8148, 12423, 8146, 12425, 8144, 12427, 8142, 12429, 8140, 12431, 8138, 12433, 8136, 12435, 8134, 12437, 8132, 12439, 8130, 12441, 8128, 12443, 8126, 12445, 8124, 12447, 8122, 12449, 8120, 12451, 8118, 12453, 8116, 12455, 8114, 12457, 8112, 12459, 8110, 12461, 8108, 12463, 8106, 12465, 8104, 12467, 8102, 12469, 8100, 12471, 8098, 12473, 8096, 12475, 8094, 12477, 8092, 12479, 8090, 12481, 8088, 12483, 8086, 12485, 8084, 12487, 8082, 12489, 8080, 12491, 8078, 12493, 8076, 12495, 8074, 12497, 8072, 12499, 8070, 12501, 8068, 12503, 8066, 12505, 8064, 12507, 8062, 12509, 8060, 12511, 8058, 12513, 8056, 12515, 8054, 12517, 8052, 12519, 8050, 12521, 8048, 12523, 8046, 12525, 8044, 12527, 8042, 12529, 8040, 12531, 8038, 12533, 8036, 12535, 8034, 12537, 8032, 12539, 8030, 12541, 8028, 12543, 8026, 12545, 8024, 12547, 8022, 12549, 8020, 12551, 8018, 12553, 8016, 12555, 8014, 12557, 8012, 12559, 8010, 12561, 8008, 12563, 8006, 12565, 8004, 12567, 8002, 12569, 8000, 12571, 7998, 12573, 7996, 12575, 7994, 12577, 7992, 12579, 7990, 12581, 7988, 12583, 7986, 12585, 7984, 12587, 7982, 12589, 7980, 12591, 7978, 12593, 7976, 12595, 7974, 12597, 7972, 12599, 7970, 12601, 7968, 12603, 7966, 12605, 7964, 12607, 7962, 12609, 7960, 12611, 7958, 12613, 7956, 12615, 7954, 12617, 7952, 12619, 7950, 12621, 7948, 12623, 7946, 12625, 7944, 12627, 7942, 12629, 7940, 12631, 7938, 12633, 7936, 12635, 7934, 12637, 7932, 12639, 7930, 12641, 7928, 12643, 7926, 12645, 7924, 12647, 7922, 12649, 7920, 12651, 7918, 12653, 7916, 12655, 7914, 12657, 7912, 12659, 7910, 12661, 7908, 12663, 7906, 12665, 7904, 12667, 7902, 12669, 7900, 12671, 7898, 12673, 7896, 12675, 7894, 12677, 7892, 12679, 7890, 12681, 7888, 12683, 7886, 12685, 7884, 12687, 7882, 12689, 7880, 12691, 7878, 12693, 7876, 12695, 7874, 12697, 7872, 12699, 7870, 12701, 7868, 12703, 7866, 12705, 7864, 12707, 7862, 12709, 7860, 12711, 7858, 12713, 7856, 12715, 7854, 12717, 7852, 12719, 7850, 12721, 7848, 12723, 7846, 12725, 7844, 12727, 7842, 12729, 7840, 12731, 7838, 12733, 7836, 12735, 7834, 12737, 7832, 12739, 7830, 12741, 7828, 12743, 7826, 12745, 7824, 12747, 7822, 12749, 7820, 12751, 7818, 12753, 7816, 12755, 7814, 12757, 7812, 12759, 7810, 12761, 7808, 12763, 7806, 12765, 7804, 12767, 7802, 12769, 7800, 12771, 7798, 12773, 7796, 12775, 7794, 12777, 7792, 12779, 7790, 12781, 7788, 12783, 7786, 12785, 7784, 12787, 7782, 12789, 7780, 12791, 7778, 12793, 7776, 12795, 7774, 12797, 7772, 12799, 7770, 12801, 7768, 12803, 7766, 12805, 7764, 12807, 7762, 12809, 7760, 12811, 7758, 12813, 7756, 12815, 7754, 12817, 7752, 12819, 7750, 12821, 7748, 12823, 7746, 12825, 7744, 12827, 7742, 12829, 7740, 12831, 7738, 12833, 7736, 12835, 7734, 12837, 7732, 12839, 7730, 12841, 7728, 12843, 7726, 12845, 7724, 12847, 7722, 12849, 7720, 12851, 7718, 12853, 7716, 12855, 7714, 12857, 7712, 12859, 7710, 12861, 7708, 12863, 7706, 12865, 7704, 12867, 7702, 12869, 7700, 12871, 7698, 12873, 7696, 12875, 7694, 12877, 7692, 12879, 7690, 12881, 7688, 12883, 7686, 12885, 7684, 12887, 7682, 12889, 7680, 12891, 7678, 12893, 7676, 12895, 7674, 12897, 7672, 12899, 7670, 12901, 7668, 12903, 7666, 12905, 7664, 12907, 7662, 12909, 7660, 12911, 7658, 12913, 7656, 12915, 7654, 12917, 7652, 12919, 7650, 12921, 7648, 12923, 7646, 12925, 7644, 12927, 7642, 12929, 7640, 12931, 7638, 12933, 7636, 12935, 7634, 12937, 7632, 12939, 7630, 12941, 7628, 12943, 7626, 12945, 7624, 12947, 7622, 12949, 7620, 12951, 7618, 12953, 7616, 12955, 7614, 12957, 7612, 12959, 7610, 12961, 7608, 12963, 7606, 12965, 7604, 12967, 7602, 12969, 7600, 12971, 7598, 12973, 7596, 12975, 7594, 12977, 7592, 12979, 7590, 12981, 7588, 12983, 7586, 12985, 7584, 12987, 7582, 12989, 7580, 12991, 7578, 12993, 7576, 12995, 7574, 12997, 7572, 12999, 7570, 13001, 7568, 13003, 7566, 13005, 7564, 13007, 7562, 13009, 7560, 13011, 7558, 13013, 7556, 13015, 7554, 13017, 7552, 13019, 7550, 13021, 7548, 13023, 7546, 13025, 7544, 13027, 7542, 13029, 7540, 13031, 7538, 13033, 7536, 13035, 7534, 13037, 7532, 13039, 7530, 13041, 7528, 13043, 7526, 13045, 7524, 13047, 7522, 13049, 7520, 13051, 7518, 13053, 7516, 13055, 7514, 13057, 7512, 13059, 7510, 13061, 7508, 13063, 7506, 13065, 7504, 13067, 7502, 13069, 7500, 13071, 7498, 13073, 7496, 13075, 7494, 13077, 7492, 13079, 7490, 13081, 7488, 13083, 7486, 13085, 7484, 13087, 7482, 13089, 7480, 13091, 7478, 13093, 7476, 13095, 7474, 13097, 7472, 13099, 7470, 13101, 7468, 13103, 7466, 13105, 7464, 13107, 7462, 13109, 7460, 13111, 7458, 13113, 7456, 13115, 7454, 13117, 7452, 13119, 7450, 13121, 7448, 13123, 7446, 13125, 7444, 13127, 7442, 13129, 7440, 13131, 7438, 13133, 7436, 13135, 7434, 13137, 7432, 13139, 7430, 13141, 7428, 13143, 7426, 13145, 7424, 13147, 7422, 13149, 7420, 13151, 7418, 13153, 7416, 13155, 7414, 13157, 7412, 13159, 7410, 13161, 7408, 13163, 7406, 13165, 7404, 13167, 7402, 13169, 7400, 13171, 7398, 13173, 7396, 13175, 7394, 13177, 7392, 13179, 7390, 13181, 7388, 13183, 7386, 13185, 7384, 13187, 7382, 13189, 7380, 13191, 7378, 13193, 7376, 13195, 7374, 13197, 7372, 13199, 7370, 13201, 7368, 13203, 7366, 13205, 7364, 13207, 7362, 13209, 7360, 13211, 7358, 13213, 7356, 13215, 7354, 13217, 7352, 13219, 7350, 13221, 7348, 13223, 7346, 13225, 7344, 13227, 7342, 13229, 7340, 13231, 7338, 13233, 7336, 13235, 7334, 13237, 7332, 13239, 7330, 13241, 7328, 13243, 7326, 13245, 7324, 13247, 7322, 13249, 7320, 13251, 7318, 13253, 7316, 13255, 7314, 13257, 7312, 13259, 7310, 13261, 7308, 13263, 7306, 13265, 7304, 13267, 7302, 13269, 7300, 13271, 7298, 13273, 7296, 13275, 7294, 13277, 7292, 13279, 7290, 13281, 7288, 13283, 7286, 13285, 7284, 13287, 7282, 13289, 7280, 13291, 7278, 13293, 7276, 13295, 7274, 13297, 7272, 13299, 7270, 13301, 7268, 13303, 7266, 13305, 7264, 13307, 7262, 13309, 7260, 13311, 7258, 13313, 7256, 13315, 7254, 13317, 7252, 13319, 7250, 13321, 7248, 13323, 7246, 13325, 7244, 13327, 7242, 13329, 7240, 13331, 7238, 13333, 7236, 13335, 7234, 13337, 7232, 13339, 7230, 13341, 7228, 13343, 7226, 13345, 7224, 13347, 7222, 13349, 7220, 13351, 7218, 13353, 7216, 13355, 7214, 13357, 7212, 13359, 7210, 13361, 7208, 13363, 7206, 13365, 7204, 13367, 7202, 13369, 7200, 13371, 7198, 13373, 7196, 13375, 7194, 13377, 7192, 13379, 7190, 13381, 7188, 13383, 7186, 13385, 7184, 13387, 7182, 13389, 7180, 13391, 7178, 13393, 7176, 13395, 7174, 13397, 7172, 13399, 7170, 13401, 7168, 13403, 7166, 13405, 7164, 13407, 7162, 13409, 7160, 13411, 7158, 13413, 7156, 13415, 7154, 13417, 7152, 13419, 7150, 13421, 7148, 13423, 7146, 13425, 7144, 13427, 7142, 13429, 7140, 13431, 7138, 13433, 7136, 13435, 7134, 13437, 7132, 13439, 7130, 13441, 7128, 13443, 7126, 13445, 7124, 13447, 7122, 13449, 7120, 13451, 7118, 13453, 7116, 13455, 7114, 13457, 7112, 13459, 7110, 13461, 7108, 13463, 7106, 13465, 7104, 13467, 7102, 13469, 7100, 13471, 7098, 13473, 7096, 13475, 7094, 13477, 7092, 13479, 7090, 13481, 7088, 13483, 7086, 13485, 7084, 13487, 7082, 13489, 7080, 13491, 7078, 13493, 7076, 13495, 7074, 13497, 7072, 13499, 7070, 13501, 7068, 13503, 7066, 13505, 7064, 13507, 7062, 13509, 7060, 13511, 7058, 13513, 7056, 13515, 7054, 13517, 7052, 13519, 7050, 13521, 7048, 13523, 7046, 13525, 7044, 13527, 7042, 13529, 7040, 13531, 7038, 13533, 7036, 13535, 7034, 13537, 7032, 13539, 7030, 13541, 7028, 13543, 7026, 13545, 7024, 13547, 7022, 13549, 7020, 13551, 7018, 13553, 7016, 13555, 7014, 13557, 7012, 13559, 7010, 13561, 7008, 13563, 7006, 13565, 7004, 13567, 7002, 13569, 7000, 13571, 6998, 13573, 6996, 13575, 6994, 13577, 6992, 13579, 6990, 13581, 6988, 13583, 6986, 13585, 6984, 13587, 6982, 13589, 6980, 13591, 6978, 13593, 6976, 13595, 6974, 13597, 6972, 13599, 6970, 13601, 6968, 13603, 6966, 13605, 6964, 13607, 6962, 13609, 6960, 13611, 6958, 13613, 6956, 13615, 6954, 13617, 6952, 13619, 6950, 13621, 6948, 13623, 6946, 13625, 6944, 13627, 6942, 13629, 6940, 13631, 6938, 13633, 6936, 13635, 6934, 13637, 6932, 13639, 6930, 13641, 6928, 13643, 6926, 13645, 6924, 13647, 6922, 13649, 6920, 13651, 6918, 13653, 6916, 13655, 6914, 13657, 6912, 13659, 6910, 13661, 6908, 13663, 6906, 13665, 6904, 13667, 6902, 13669, 6900, 13671, 6898, 13673, 6896, 13675, 6894, 13677, 6892, 13679, 6890, 13681, 6888, 13683, 6886, 13685, 6884, 13687, 6882, 13689, 6880, 13691, 6878, 13693, 6876, 13695, 6874, 13697, 6872, 13699, 6870, 13701, 6868, 13703, 6866, 13705, 6864, 13707, 6862, 13709, 6860, 13711, 6858, 13713, 6856, 13715, 6854, 13717, 6852, 13719, 6850, 13721, 6848, 13723, 6846, 13725, 6844, 13727, 6842, 13729, 6840, 13731, 6838, 13733, 6836, 13735, 6834, 13737, 6832, 13739, 6830, 13741, 6828, 13743, 6826, 13745, 6824, 13747, 6822, 13749, 6820, 13751, 6818, 13753, 6816, 13755, 6814, 13757, 6812, 13759, 6810, 13761, 6808, 13763, 6806, 13765, 6804, 13767, 6802, 13769, 6800, 13771, 6798, 13773, 6796, 13775, 6794, 13777, 6792, 13779, 6790, 13781, 6788, 13783, 6786, 13785, 6784, 13787, 6782, 13789, 6780, 13791, 6778, 13793, 6776, 13795, 6774, 13797, 6772, 13799, 6770, 13801, 6768, 13803, 6766, 13805, 6764, 13807, 6762, 13809, 6760, 13811, 6758, 13813, 6756, 13815, 6754, 13817, 6752, 13819, 6750, 13821, 6748, 13823, 6746, 13825, 6744, 13827, 6742, 13829, 6740, 13831, 6738, 13833, 6736, 13835, 6734, 13837, 6732, 13839, 6730, 13841, 6728, 13843, 6726, 13845, 6724, 13847, 6722, 13849, 6720, 13851, 6718, 13853, 6716, 13855, 6714, 13857, 6712, 13859, 6710, 13861, 6708, 13863, 6706, 13865, 6704, 13867, 6702, 13869, 6700, 13871, 6698, 13873, 6696, 13875, 6694, 13877, 6692, 13879, 6690, 13881, 6688, 13883, 6686, 13885, 6684, 13887, 6682, 13889, 6680, 13891, 6678, 13893, 6676, 13895, 6674, 13897, 6672, 13899, 6670, 13901, 6668, 13903, 6666, 13905, 6664, 13907, 6662, 13909, 6660, 13911, 6658, 13913, 6656, 13915, 6654, 13917, 6652, 13919, 6650, 13921, 6648, 13923, 6646, 13925, 6644, 13927, 6642, 13929, 6640, 13931, 6638, 13933, 6636, 13935, 6634, 13937, 6632, 13939, 6630, 13941, 6628, 13943, 6626, 13945, 6624, 13947, 6622, 13949, 6620, 13951, 6618, 13953, 6616, 13955, 6614, 13957, 6612, 13959, 6610, 13961, 6608, 13963, 6606, 13965, 6604, 13967, 6602, 13969, 6600, 13971, 6598, 13973, 6596, 13975, 6594, 13977, 6592, 13979, 6590, 13981, 6588, 13983, 6586, 13985, 6584, 13987, 6582, 13989, 6580, 13991, 6578, 13993, 6576, 13995, 6574, 13997, 6572, 13999, 6570, 14001, 6568, 14003, 6566, 14005, 6564, 14007, 6562, 14009, 6560, 14011, 6558, 14013, 6556, 14015, 6554, 14017, 6552, 14019, 6550, 14021, 6548, 14023, 6546, 14025, 6544, 14027, 6542, 14029, 6540, 14031, 6538, 14033, 6536, 14035, 6534, 14037, 6532, 14039, 6530, 14041, 6528, 14043, 6526, 14045, 6524, 14047, 6522, 14049, 6520, 14051, 6518, 14053, 6516, 14055, 6514, 14057, 6512, 14059, 6510, 14061, 6508, 14063, 6506, 14065, 6504, 14067, 6502, 14069, 6500, 14071, 6498, 14073, 6496, 14075, 6494, 14077, 6492, 14079, 6490, 14081, 6488, 14083, 6486, 14085, 6484, 14087, 6482, 14089, 6480, 14091, 6478, 14093, 6476, 14095, 6474, 14097, 6472, 14099, 6470, 14101, 6468, 14103, 6466, 14105, 6464, 14107, 6462, 14109, 6460, 14111, 6458, 14113, 6456, 14115, 6454, 14117, 6452, 14119, 6450, 14121, 6448, 14123, 6446, 14125, 6444, 14127, 6442, 14129, 6440, 14131, 6438, 14133, 6436, 14135, 6434, 14137, 6432, 14139, 6430, 14141, 6428, 14143, 6426, 14145, 6424, 14147, 6422, 14149, 6420, 14151, 6418, 14153, 6416, 14155, 6414, 14157, 6412, 14159, 6410, 14161, 6408, 14163, 6406, 14165, 6404, 14167, 6402, 14169, 6400, 14171, 6398, 14173, 6396, 14175, 6394, 14177, 6392, 14179, 6390, 14181, 6388, 14183, 6386, 14185, 6384, 14187, 6382, 14189, 6380, 14191, 6378, 14193, 6376, 14195, 6374, 14197, 6372, 14199, 6370, 14201, 6368, 14203, 6366, 14205, 6364, 14207, 6362, 14209, 6360, 14211, 6358, 14213, 6356, 14215, 6354, 14217, 6352, 14219, 6350, 14221, 6348, 14223, 6346, 14225, 6344, 14227, 6342, 14229, 6340, 14231, 6338, 14233, 6336, 14235, 6334, 14237, 6332, 14239, 6330, 14241, 6328, 14243, 6326, 14245, 6324, 14247, 6322, 14249, 6320, 14251, 6318, 14253, 6316, 14255, 6314, 14257, 6312, 14259, 6310, 14261, 6308, 14263, 6306, 14265, 6304, 14267, 6302, 14269, 6300, 14271, 6298, 14273, 6296, 14275, 6294, 14277, 6292, 14279, 6290, 14281, 6288, 14283, 6286, 14285, 6284, 14287, 6282, 14289, 6280, 14291, 6278, 14293, 6276, 14295, 6274, 14297, 6272, 14299, 6270, 14301, 6268, 14303, 6266, 14305, 6264, 14307, 6262, 14309, 6260, 14311, 6258, 14313, 6256, 14315, 6254, 14317, 6252, 14319, 6250, 14321, 6248, 14323, 6246, 14325, 6244, 14327, 6242, 14329, 6240, 14331, 6238, 14333, 6236, 14335, 6234, 14337, 6232, 14339, 6230, 14341, 6228, 14343, 6226, 14345, 6224, 14347, 6222, 14349, 6220, 14351, 6218, 14353, 6216, 14355, 6214, 14357, 6212, 14359, 6210, 14361, 6208, 14363, 6206, 14365, 6204, 14367, 6202, 14369, 6200, 14371, 6198, 14373, 6196, 14375, 6194, 14377, 6192, 14379, 6190, 14381, 6188, 14383, 6186, 14385, 6184, 14387, 6182, 14389, 6180, 14391, 6178, 14393, 6176, 14395, 6174, 14397, 6172, 14399, 6170, 14401, 6168, 14403, 6166, 14405, 6164, 14407, 6162, 14409, 6160, 14411, 6158, 14413, 6156, 14415, 6154, 14417, 6152, 14419, 6150, 14421, 6148, 14423, 6146, 14425, 6144, 14427, 6142, 14429, 6140, 14431, 6138, 14433, 6136, 14435, 6134, 14437, 6132, 14439, 6130, 14441, 6128, 14443, 6126, 14445, 6124, 14447, 6122, 14449, 6120, 14451, 6118, 14453, 6116, 14455, 6114, 14457, 6112, 14459, 6110, 14461, 6108, 14463, 6106, 14465, 6104, 14467, 6102, 14469, 6100, 14471, 6098, 14473, 6096, 14475, 6094, 14477, 6092, 14479, 6090, 14481, 6088, 14483, 6086, 14485, 6084, 14487, 6082, 14489, 6080, 14491, 6078, 14493, 6076, 14495, 6074, 14497, 6072, 14499, 6070, 14501, 6068, 14503, 6066, 14505, 6064, 14507, 6062, 14509, 6060, 14511, 6058, 14513, 6056, 14515, 6054, 14517, 6052, 14519, 6050, 14521, 6048, 14523, 6046, 14525, 6044, 14527, 6042, 14529, 6040, 14531, 6038, 14533, 6036, 14535, 6034, 14537, 6032, 14539, 6030, 14541, 6028, 14543, 6026, 14545, 6024, 14547, 6022, 14549, 6020, 14551, 6018, 14553, 6016, 14555, 6014, 14557, 6012, 14559, 6010, 14561, 6008, 14563, 6006, 14565, 6004, 14567, 6002, 14569, 6000, 14571, 5998, 14573, 5996, 14575, 5994, 14577, 5992, 14579, 5990, 14581, 5988, 14583, 5986, 14585, 5984, 14587, 5982, 14589, 5980, 14591, 5978, 14593, 5976, 14595, 5974, 14597, 5972, 14599, 5970, 14601, 5968, 14603, 5966, 14605, 5964, 14607, 5962, 14609, 5960, 14611, 5958, 14613, 5956, 14615, 5954, 14617, 5952, 14619, 5950, 14621, 5948, 14623, 5946, 14625, 5944, 14627, 5942, 14629, 5940, 14631, 5938, 14633, 5936, 14635, 5934, 14637, 5932, 14639, 5930, 14641, 5928, 14643, 5926, 14645, 5924, 14647, 5922, 14649, 5920, 14651, 5918, 14653, 5916, 14655, 5914, 14657, 5912, 14659, 5910, 14661, 5908, 14663, 5906, 14665, 5904, 14667, 5902, 14669, 5900, 14671, 5898, 14673, 5896, 14675, 5894, 14677, 5892, 14679, 5890, 14681, 5888, 14683, 5886, 14685, 5884, 14687, 5882, 14689, 5880, 14691, 5878, 14693, 5876, 14695, 5874, 14697, 5872, 14699, 5870, 14701, 5868, 14703, 5866, 14705, 5864, 14707, 5862, 14709, 5860, 14711, 5858, 14713, 5856, 14715, 5854, 14717, 5852, 14719, 5850, 14721, 5848, 14723, 5846, 14725, 5844, 14727, 5842, 14729, 5840, 14731, 5838, 14733, 5836, 14735, 5834, 14737, 5832, 14739, 5830, 14741, 5828, 14743, 5826, 14745, 5824, 14747, 5822, 14749, 5820, 14751, 5818, 14753, 5816, 14755, 5814, 14757, 5812, 14759, 5810, 14761, 5808, 14763, 5806, 14765, 5804, 14767, 5802, 14769, 5800, 14771, 5798, 14773, 5796, 14775, 5794, 14777, 5792, 14779, 5790, 14781, 5788, 14783, 5786, 14785, 5784, 14787, 5782, 14789, 5780, 14791, 5778, 14793, 5776, 14795, 5774, 14797, 5772, 14799, 5770, 14801, 5768, 14803, 5766, 14805, 5764, 14807, 5762, 14809, 5760, 14811, 5758, 14813, 5756, 14815, 5754, 14817, 5752, 14819, 5750, 14821, 5748, 14823, 5746, 14825, 5744, 14827, 5742, 14829, 5740, 14831, 5738, 14833, 5736, 14835, 5734, 14837, 5732, 14839, 5730, 14841, 5728, 14843, 5726, 14845, 5724, 14847, 5722, 14849, 5720, 14851, 5718, 14853, 5716, 14855, 5714, 14857, 5712, 14859, 5710, 14861, 5708, 14863, 5706, 14865, 5704, 14867, 5702, 14869, 5700, 14871, 5698, 14873, 5696, 14875, 5694, 14877, 5692, 14879, 5690, 14881, 5688, 14883, 5686, 14885, 5684, 14887, 5682, 14889, 5680, 14891, 5678, 14893, 5676, 14895, 5674, 14897, 5672, 14899, 5670, 14901, 5668, 14903, 5666, 14905, 5664, 14907, 5662, 14909, 5660, 14911, 5658, 14913, 5656, 14915, 5654, 14917, 5652, 14919, 5650, 14921, 5648, 14923, 5646, 14925, 5644, 14927, 5642, 14929, 5640, 14931, 5638, 14933, 5636, 14935, 5634, 14937, 5632, 14939, 5630, 14941, 5628, 14943, 5626, 14945, 5624, 14947, 5622, 14949, 5620, 14951, 5618, 14953, 5616, 14955, 5614, 14957, 5612, 14959, 5610, 14961, 5608, 14963, 5606, 14965, 5604, 14967, 5602, 14969, 5600, 14971, 5598, 14973, 5596, 14975, 5594, 14977, 5592, 14979, 5590, 14981, 5588, 14983, 5586, 14985, 5584, 14987, 5582, 14989, 5580, 14991, 5578, 14993, 5576, 14995, 5574, 14997, 5572, 14999, 5570, 15001, 5568, 15003, 5566, 15005, 5564, 15007, 5562, 15009, 5560, 15011, 5558, 15013, 5556, 15015, 5554, 15017, 5552, 15019, 5550, 15021, 5548, 15023, 5546, 15025, 5544, 15027, 5542, 15029, 5540, 15031, 5538, 15033, 5536, 15035, 5534, 15037, 5532, 15039, 5530, 15041, 5528, 15043, 5526, 15045, 5524, 15047, 5522, 15049, 5520, 15051, 5518, 15053, 5516, 15055, 5514, 15057, 5512, 15059, 5510, 15061, 5508, 15063, 5506, 15065, 5504, 15067, 5502, 15069, 5500, 15071, 5498, 15073, 5496, 15075, 5494, 15077, 5492, 15079, 5490, 15081, 5488, 15083, 5486, 15085, 5484, 15087, 5482, 15089, 5480, 15091, 5478, 15093, 5476, 15095, 5474, 15097, 5472, 15099, 5470, 15101, 5468, 15103, 5466, 15105, 5464, 15107, 5462, 15109, 5460, 15111, 5458, 15113, 5456, 15115, 5454, 15117, 5452, 15119, 5450, 15121, 5448, 15123, 5446, 15125, 5444, 15127, 5442, 15129, 5440, 15131, 5438, 15133, 5436, 15135, 5434, 15137, 5432, 15139, 5430, 15141, 5428, 15143, 5426, 15145, 5424, 15147, 5422, 15149, 5420, 15151, 5418, 15153, 5416, 15155, 5414, 15157, 5412, 15159, 5410, 15161, 5408, 15163, 5406, 15165, 5404, 15167, 5402, 15169, 5400, 15171, 5398, 15173, 5396, 15175, 5394, 15177, 5392, 15179, 5390, 15181, 5388, 15183, 5386, 15185, 5384, 15187, 5382, 15189, 5380, 15191, 5378, 15193, 5376, 15195, 5374, 15197, 5372, 15199, 5370, 15201, 5368, 15203, 5366, 15205, 5364, 15207, 5362, 15209, 5360, 15211, 5358, 15213, 5356, 15215, 5354, 15217, 5352, 15219, 5350, 15221, 5348, 15223, 5346, 15225, 5344, 15227, 5342, 15229, 5340, 15231, 5338, 15233, 5336, 15235, 5334, 15237, 5332, 15239, 5330, 15241, 5328, 15243, 5326, 15245, 5324, 15247, 5322, 15249, 5320, 15251, 5318, 15253, 5316, 15255, 5314, 15257, 5312, 15259, 5310, 15261, 5308, 15263, 5306, 15265, 5304, 15267, 5302, 15269, 5300, 15271, 5298, 15273, 5296, 15275, 5294, 15277, 5292, 15279, 5290, 15281, 5288, 15283, 5286, 15285, 5284, 15287, 5282, 15289, 5280, 15291, 5278, 15293, 5276, 15295, 5274, 15297, 5272, 15299, 5270, 15301, 5268, 15303, 5266, 15305, 5264, 15307, 5262, 15309, 5260, 15311, 5258, 15313, 5256, 15315, 5254, 15317, 5252, 15319, 5250, 15321, 5248, 15323, 5246, 15325, 5244, 15327, 5242, 15329, 5240, 15331, 5238, 15333, 5236, 15335, 5234, 15337, 5232, 15339, 5230, 15341, 5228, 15343, 5226, 15345, 5224, 15347, 5222, 15349, 5220, 15351, 5218, 15353, 5216, 15355, 5214, 15357, 5212, 15359, 5210, 15361, 5208, 15363, 5206, 15365, 5204, 15367, 5202, 15369, 5200, 15371, 5198, 15373, 5196, 15375, 5194, 15377, 5192, 15379, 5190, 15381, 5188, 15383, 5186, 15385, 5184, 15387, 5182, 15389, 5180, 15391, 5178, 15393, 5176, 15395, 5174, 15397, 5172, 15399, 5170, 15401, 5168, 15403, 5166, 15405, 5164, 15407, 5162, 15409, 5160, 15411, 5158, 15413, 5156, 15415, 5154, 15417, 5152, 15419, 5150, 15421, 5148, 15423, 5146, 15425, 5144, 15427, 5142, 15429, 5140, 15431, 5138, 15433, 5136, 15435, 5134, 15437, 5132, 15439, 5130, 15441, 5128, 15443, 5126, 15445, 5124, 15447, 5122, 15449, 5120, 15451, 5118, 15453, 5116, 15455, 5114, 15457, 5112, 15459, 5110, 15461, 5108, 15463, 5106, 15465, 5104, 15467, 5102, 15469, 5100, 15471, 5098, 15473, 5096, 15475, 5094, 15477, 5092, 15479, 5090, 15481, 5088, 15483, 5086, 15485, 5084, 15487, 5082, 15489, 5080, 15491, 5078, 15493, 5076, 15495, 5074, 15497, 5072, 15499, 5070, 15501, 5068, 15503, 5066, 15505, 5064, 15507, 5062, 15509, 5060, 15511, 5058, 15513, 5056, 15515, 5054, 15517, 5052, 15519, 5050, 15521, 5048, 15523, 5046, 15525, 5044, 15527, 5042, 15529, 5040, 15531, 5038, 15533, 5036, 15535, 5034, 15537, 5032, 15539, 5030, 15541, 5028, 15543, 5026, 15545, 5024, 15547, 5022, 15549, 5020, 15551, 5018, 15553, 5016, 15555, 5014, 15557, 5012, 15559, 5010, 15561, 5008, 15563, 5006, 15565, 5004, 15567, 5002, 15569, 5000, 15571, 4998, 15573, 4996, 15575, 4994, 15577, 4992, 15579, 4990, 15581, 4988, 15583, 4986, 15585, 4984, 15587, 4982, 15589, 4980, 15591, 4978, 15593, 4976, 15595, 4974, 15597, 4972, 15599, 4970, 15601, 4968, 15603, 4966, 15605, 4964, 15607, 4962, 15609, 4960, 15611, 4958, 15613, 4956, 15615, 4954, 15617, 4952, 15619, 4950, 15621, 4948, 15623, 4946, 15625, 4944, 15627, 4942, 15629, 4940, 15631, 4938, 15633, 4936, 15635, 4934, 15637, 4932, 15639, 4930, 15641, 4928, 15643, 4926, 15645, 4924, 15647, 4922, 15649, 4920, 15651, 4918, 15653, 4916, 15655, 4914, 15657, 4912, 15659, 4910, 15661, 4908, 15663, 4906, 15665, 4904, 15667, 4902, 15669, 4900, 15671, 4898, 15673, 4896, 15675, 4894, 15677, 4892, 15679, 4890, 15681, 4888, 15683, 4886, 15685, 4884, 15687, 4882, 15689, 4880, 15691, 4878, 15693, 4876, 15695, 4874, 15697, 4872, 15699, 4870, 15701, 4868, 15703, 4866, 15705, 4864, 15707, 4862, 15709, 4860, 15711, 4858, 15713, 4856, 15715, 4854, 15717, 4852, 15719, 4850, 15721, 4848, 15723, 4846, 15725, 4844, 15727, 4842, 15729, 4840, 15731, 4838, 15733, 4836, 15735, 4834, 15737, 4832, 15739, 4830, 15741, 4828, 15743, 4826, 15745, 4824, 15747, 4822, 15749, 4820, 15751, 4818, 15753, 4816, 15755, 4814, 15757, 4812, 15759, 4810, 15761, 4808, 15763, 4806, 15765, 4804, 15767, 4802, 15769, 4800, 15771, 4798, 15773, 4796, 15775, 4794, 15777, 4792, 15779, 4790, 15781, 4788, 15783, 4786, 15785, 4784, 15787, 4782, 15789, 4780, 15791, 4778, 15793, 4776, 15795, 4774, 15797, 4772, 15799, 4770, 15801, 4768, 15803, 4766, 15805, 4764, 15807, 4762, 15809, 4760, 15811, 4758, 15813, 4756, 15815, 4754, 15817, 4752, 15819, 4750, 15821, 4748, 15823, 4746, 15825, 4744, 15827, 4742, 15829, 4740, 15831, 4738, 15833, 4736, 15835, 4734, 15837, 4732, 15839, 4730, 15841, 4728, 15843, 4726, 15845, 4724, 15847, 4722, 15849, 4720, 15851, 4718, 15853, 4716, 15855, 4714, 15857, 4712, 15859, 4710, 15861, 4708, 15863, 4706, 15865, 4704, 15867, 4702, 15869, 4700, 15871, 4698, 15873, 4696, 15875, 4694, 15877, 4692, 15879, 4690, 15881, 4688, 15883, 4686, 15885, 4684, 15887, 4682, 15889, 4680, 15891, 4678, 15893, 4676, 15895, 4674, 15897, 4672, 15899, 4670, 15901, 4668, 15903, 4666, 15905, 4664, 15907, 4662, 15909, 4660, 15911, 4658, 15913, 4656, 15915, 4654, 15917, 4652, 15919, 4650, 15921, 4648, 15923, 4646, 15925, 4644, 15927, 4642, 15929, 4640, 15931, 4638, 15933, 4636, 15935, 4634, 15937, 4632, 15939, 4630, 15941, 4628, 15943, 4626, 15945, 4624, 15947, 4622, 15949, 4620, 15951, 4618, 15953, 4616, 15955, 4614, 15957, 4612, 15959, 4610, 15961, 4608, 15963, 4606, 15965, 4604, 15967, 4602, 15969, 4600, 15971, 4598, 15973, 4596, 15975, 4594, 15977, 4592, 15979, 4590, 15981, 4588, 15983, 4586, 15985, 4584, 15987, 4582, 15989, 4580, 15991, 4578, 15993, 4576, 15995, 4574, 15997, 4572, 15999, 4570, 16001, 4568, 16003, 4566, 16005, 4564, 16007, 4562, 16009, 4560, 16011, 4558, 16013, 4556, 16015, 4554, 16017, 4552, 16019, 4550, 16021, 4548, 16023, 4546, 16025, 4544, 16027, 4542, 16029, 4540, 16031, 4538, 16033, 4536, 16035, 4534, 16037, 4532, 16039, 4530, 16041, 4528, 16043, 4526, 16045, 4524, 16047, 4522, 16049, 4520, 16051, 4518, 16053, 4516, 16055, 4514, 16057, 4512, 16059, 4510, 16061, 4508, 16063, 4506, 16065, 4504, 16067, 4502, 16069, 4500, 16071, 4498, 16073, 4496, 16075, 4494, 16077, 4492, 16079, 4490, 16081, 4488, 16083, 4486, 16085, 4484, 16087, 4482, 16089, 4480, 16091, 4478, 16093, 4476, 16095, 4474, 16097, 4472, 16099, 4470, 16101, 4468, 16103, 4466, 16105, 4464, 16107, 4462, 16109, 4460, 16111, 4458, 16113, 4456, 16115, 4454, 16117, 4452, 16119, 4450, 16121, 4448, 16123, 4446, 16125, 4444, 16127, 4442, 16129, 4440, 16131, 4438, 16133, 4436, 16135, 4434, 16137, 4432, 16139, 4430, 16141, 4428, 16143, 4426, 16145, 4424, 16147, 4422, 16149, 4420, 16151, 4418, 16153, 4416, 16155, 4414, 16157, 4412, 16159, 4410, 16161, 4408, 16163, 4406, 16165, 4404, 16167, 4402, 16169, 4400, 16171, 4398, 16173, 4396, 16175, 4394, 16177, 4392, 16179, 4390, 16181, 4388, 16183, 4386, 16185, 4384, 16187, 4382, 16189, 4380, 16191, 4378, 16193, 4376, 16195, 4374, 16197, 4372, 16199, 4370, 16201, 4368, 16203, 4366, 16205, 4364, 16207, 4362, 16209, 4360, 16211, 4358, 16213, 4356, 16215, 4354, 16217, 4352, 16219, 4350, 16221, 4348, 16223, 4346, 16225, 4344, 16227, 4342, 16229, 4340, 16231, 4338, 16233, 4336, 16235, 4334, 16237, 4332, 16239, 4330, 16241, 4328, 16243, 4326, 16245, 4324, 16247, 4322, 16249, 4320, 16251, 4318, 16253, 4316, 16255, 4314, 16257, 4312, 16259, 4310, 16261, 4308, 16263, 4306, 16265, 4304, 16267, 4302, 16269, 4300, 16271, 4298, 16273, 4296, 16275, 4294, 16277, 4292, 16279, 4290, 16281, 4288, 16283, 4286, 16285, 4284, 16287, 4282, 16289, 4280, 16291, 4278, 16293, 4276, 16295, 4274, 16297, 4272, 16299, 4270, 16301, 4268, 16303, 4266, 16305, 4264, 16307, 4262, 16309, 4260, 16311, 4258, 16313, 4256, 16315, 4254, 16317, 4252, 16319, 4250, 16321, 4248, 16323, 4246, 16325, 4244, 16327, 4242, 16329, 4240, 16331, 4238, 16333, 4236, 16335, 4234, 16337, 4232, 16339, 4230, 16341, 4228, 16343, 4226, 16345, 4224, 16347, 4222, 16349, 4220, 16351, 4218, 16353, 4216, 16355, 4214, 16357, 4212, 16359, 4210, 16361, 4208, 16363, 4206, 16365, 4204, 16367, 4202, 16369, 4200, 16371, 4198, 16373, 4196, 16375, 4194, 16377, 4192, 16379, 4190, 16381, 4188, 16383, 4186, 16385, 4184, 16387, 4182, 16389, 4180, 16391, 4178, 16393, 4176, 16395, 4174, 16397, 4172, 16399, 4170, 16401, 4168, 16403, 4166, 16405, 4164, 16407, 4162, 16409, 4160, 16411, 4158, 16413, 4156, 16415, 4154, 16417, 4152, 16419, 4150, 16421, 4148, 16423, 4146, 16425, 4144, 16427, 4142, 16429, 4140, 16431, 4138, 16433, 4136, 16435, 4134, 16437, 4132, 16439, 4130, 16441, 4128, 16443, 4126, 16445, 4124, 16447, 4122, 16449, 4120, 16451, 4118, 16453, 4116, 16455, 4114, 16457, 4112, 16459, 4110, 16461, 4108, 16463, 4106, 16465, 4104, 16467, 4102, 16469, 4100, 16471, 4098, 16473, 4096, 16475, 4094, 16477, 4092, 16479, 4090, 16481, 4088, 16483, 4086, 16485, 4084, 16487, 4082, 16489, 4080, 16491, 4078, 16493, 4076, 16495, 4074, 16497, 4072, 16499, 4070, 16501, 4068, 16503, 4066, 16505, 4064, 16507, 4062, 16509, 4060, 16511, 4058, 16513, 4056, 16515, 4054, 16517, 4052, 16519, 4050, 16521, 4048, 16523, 4046, 16525, 4044, 16527, 4042, 16529, 4040, 16531, 4038, 16533, 4036, 16535, 4034, 16537, 4032, 16539, 4030, 16541, 4028, 16543, 4026, 16545, 4024, 16547, 4022, 16549, 4020, 16551, 4018, 16553, 4016, 16555, 4014, 16557, 4012, 16559, 4010, 16561, 4008, 16563, 4006, 16565, 4004, 16567, 4002, 16569, 4000, 16571, 3998, 16573, 3996, 16575, 3994, 16577, 3992, 16579, 3990, 16581, 3988, 16583, 3986, 16585, 3984, 16587, 3982, 16589, 3980, 16591, 3978, 16593, 3976, 16595, 3974, 16597, 3972, 16599, 3970, 16601, 3968, 16603, 3966, 16605, 3964, 16607, 3962, 16609, 3960, 16611, 3958, 16613, 3956, 16615, 3954, 16617, 3952, 16619, 3950, 16621, 3948, 16623, 3946, 16625, 3944, 16627, 3942, 16629, 3940, 16631, 3938, 16633, 3936, 16635, 3934, 16637, 3932, 16639, 3930, 16641, 3928, 16643, 3926, 16645, 3924, 16647, 3922, 16649, 3920, 16651, 3918, 16653, 3916, 16655, 3914, 16657, 3912, 16659, 3910, 16661, 3908, 16663, 3906, 16665, 3904, 16667, 3902, 16669, 3900, 16671, 3898, 16673, 3896, 16675, 3894, 16677, 3892, 16679, 3890, 16681, 3888, 16683, 3886, 16685, 3884, 16687, 3882, 16689, 3880, 16691, 3878, 16693, 3876, 16695, 3874, 16697, 3872, 16699, 3870, 16701, 3868, 16703, 3866, 16705, 3864, 16707, 3862, 16709, 3860, 16711, 3858, 16713, 3856, 16715, 3854, 16717, 3852, 16719, 3850, 16721, 3848, 16723, 3846, 16725, 3844, 16727, 3842, 16729, 3840, 16731, 3838, 16733, 3836, 16735, 3834, 16737, 3832, 16739, 3830, 16741, 3828, 16743, 3826, 16745, 3824, 16747, 3822, 16749, 3820, 16751, 3818, 16753, 3816, 16755, 3814, 16757, 3812, 16759, 3810, 16761, 3808, 16763, 3806, 16765, 3804, 16767, 3802, 16769, 3800, 16771, 3798, 16773, 3796, 16775, 3794, 16777, 3792, 16779, 3790, 16781, 3788, 16783, 3786, 16785, 3784, 16787, 3782, 16789, 3780, 16791, 3778, 16793, 3776, 16795, 3774, 16797, 3772, 16799, 3770, 16801, 3768, 16803, 3766, 16805, 3764, 16807, 3762, 16809, 3760, 16811, 3758, 16813, 3756, 16815, 3754, 16817, 3752, 16819, 3750, 16821, 3748, 16823, 3746, 16825, 3744, 16827, 3742, 16829, 3740, 16831, 3738, 16833, 3736, 16835, 3734, 16837, 3732, 16839, 3730, 16841, 3728, 16843, 3726, 16845, 3724, 16847, 3722, 16849, 3720, 16851, 3718, 16853, 3716, 16855, 3714, 16857, 3712, 16859, 3710, 16861, 3708, 16863, 3706, 16865, 3704, 16867, 3702, 16869, 3700, 16871, 3698, 16873, 3696, 16875, 3694, 16877, 3692, 16879, 3690, 16881, 3688, 16883, 3686, 16885, 3684, 16887, 3682, 16889, 3680, 16891, 3678, 16893, 3676, 16895, 3674, 16897, 3672, 16899, 3670, 16901, 3668, 16903, 3666, 16905, 3664, 16907, 3662, 16909, 3660, 16911, 3658, 16913, 3656, 16915, 3654, 16917, 3652, 16919, 3650, 16921, 3648, 16923, 3646, 16925, 3644, 16927, 3642, 16929, 3640, 16931, 3638, 16933, 3636, 16935, 3634, 16937, 3632, 16939, 3630, 16941, 3628, 16943, 3626, 16945, 3624, 16947, 3622, 16949, 3620, 16951, 3618, 16953, 3616, 16955, 3614, 16957, 3612, 16959, 3610, 16961, 3608, 16963, 3606, 16965, 3604, 16967, 3602, 16969, 3600, 16971, 3598, 16973, 3596, 16975, 3594, 16977, 3592, 16979, 3590, 16981, 3588, 16983, 3586, 16985, 3584, 16987, 3582, 16989, 3580, 16991, 3578, 16993, 3576, 16995, 3574, 16997, 3572, 16999, 3570, 17001, 3568, 17003, 3566, 17005, 3564, 17007, 3562, 17009, 3560, 17011, 3558, 17013, 3556, 17015, 3554, 17017, 3552, 17019, 3550, 17021, 3548, 17023, 3546, 17025, 3544, 17027, 3542, 17029, 3540, 17031, 3538, 17033, 3536, 17035, 3534, 17037, 3532, 17039, 3530, 17041, 3528, 17043, 3526, 17045, 3524, 17047, 3522, 17049, 3520, 17051, 3518, 17053, 3516, 17055, 3514, 17057, 3512, 17059, 3510, 17061, 3508, 17063, 3506, 17065, 3504, 17067, 3502, 17069, 3500, 17071, 3498, 17073, 3496, 17075, 3494, 17077, 3492, 17079, 3490, 17081, 3488, 17083, 3486, 17085, 3484, 17087, 3482, 17089, 3480, 17091, 3478, 17093, 3476, 17095, 3474, 17097, 3472, 17099, 3470, 17101, 3468, 17103, 3466, 17105, 3464, 17107, 3462, 17109, 3460, 17111, 3458, 17113, 3456, 17115, 3454, 17117, 3452, 17119, 3450, 17121, 3448, 17123, 3446, 17125, 3444, 17127, 3442, 17129, 3440, 17131, 3438, 17133, 3436, 17135, 3434, 17137, 3432, 17139, 3430, 17141, 3428, 17143, 3426, 17145, 3424, 17147, 3422, 17149, 3420, 17151, 3418, 17153, 3416, 17155, 3414, 17157, 3412, 17159, 3410, 17161, 3408, 17163, 3406, 17165, 3404, 17167, 3402, 17169, 3400, 17171, 3398, 17173, 3396, 17175, 3394, 17177, 3392, 17179, 3390, 17181, 3388, 17183, 3386, 17185, 3384, 17187, 3382, 17189, 3380, 17191, 3378, 17193, 3376, 17195, 3374, 17197, 3372, 17199, 3370, 17201, 3368, 17203, 3366, 17205, 3364, 17207, 3362, 17209, 3360, 17211, 3358, 17213, 3356, 17215, 3354, 17217, 3352, 17219, 3350, 17221, 3348, 17223, 3346, 17225, 3344, 17227, 3342, 17229, 3340, 17231, 3338, 17233, 3336, 17235, 3334, 17237, 3332, 17239, 3330, 17241, 3328, 17243, 3326, 17245, 3324, 17247, 3322, 17249, 3320, 17251, 3318, 17253, 3316, 17255, 3314, 17257, 3312, 17259, 3310, 17261, 3308, 17263, 3306, 17265, 3304, 17267, 3302, 17269, 3300, 17271, 3298, 17273, 3296, 17275, 3294, 17277, 3292, 17279, 3290, 17281, 3288, 17283, 3286, 17285, 3284, 17287, 3282, 17289, 3280, 17291, 3278, 17293, 3276, 17295, 3274, 17297, 3272, 17299, 3270, 17301, 3268, 17303, 3266, 17305, 3264, 17307, 3262, 17309, 3260, 17311, 3258, 17313, 3256, 17315, 3254, 17317, 3252, 17319, 3250, 17321, 3248, 17323, 3246, 17325, 3244, 17327, 3242, 17329, 3240, 17331, 3238, 17333, 3236, 17335, 3234, 17337, 3232, 17339, 3230, 17341, 3228, 17343, 3226, 17345, 3224, 17347, 3222, 17349, 3220, 17351, 3218, 17353, 3216, 17355, 3214, 17357, 3212, 17359, 3210, 17361, 3208, 17363, 3206, 17365, 3204, 17367, 3202, 17369, 3200, 17371, 3198, 17373, 3196, 17375, 3194, 17377, 3192, 17379, 3190, 17381, 3188, 17383, 3186, 17385, 3184, 17387, 3182, 17389, 3180, 17391, 3178, 17393, 3176, 17395, 3174, 17397, 3172, 17399, 3170, 17401, 3168, 17403, 3166, 17405, 3164, 17407, 3162, 17409, 3160, 17411, 3158, 17413, 3156, 17415, 3154, 17417, 3152, 17419, 3150, 17421, 3148, 17423, 3146, 17425, 3144, 17427, 3142, 17429, 3140, 17431, 3138, 17433, 3136, 17435, 3134, 17437, 3132, 17439, 3130, 17441, 3128, 17443, 3126, 17445, 3124, 17447, 3122, 17449, 3120, 17451, 3118, 17453, 3116, 17455, 3114, 17457, 3112, 17459, 3110, 17461, 3108, 17463, 3106, 17465, 3104, 17467, 3102, 17469, 3100, 17471, 3098, 17473, 3096, 17475, 3094, 17477, 3092, 17479, 3090, 17481, 3088, 17483, 3086, 17485, 3084, 17487, 3082, 17489, 3080, 17491, 3078, 17493, 3076, 17495, 3074, 17497, 3072, 17499, 3070, 17501, 3068, 17503, 3066, 17505, 3064, 17507, 3062, 17509, 3060, 17511, 3058, 17513, 3056, 17515, 3054, 17517, 3052, 17519, 3050, 17521, 3048, 17523, 3046, 17525, 3044, 17527, 3042, 17529, 3040, 17531, 3038, 17533, 3036, 17535, 3034, 17537, 3032, 17539, 3030, 17541, 3028, 17543, 3026, 17545, 3024, 17547, 3022, 17549, 3020, 17551, 3018, 17553, 3016, 17555, 3014, 17557, 3012, 17559, 3010, 17561, 3008, 17563, 3006, 17565, 3004, 17567, 3002, 17569, 3000, 17571, 2998, 17573, 2996, 17575, 2994, 17577, 2992, 17579, 2990, 17581, 2988, 17583, 2986, 17585, 2984, 17587, 2982, 17589, 2980, 17591, 2978, 17593, 2976, 17595, 2974, 17597, 2972, 17599, 2970, 17601, 2968, 17603, 2966, 17605, 2964, 17607, 2962, 17609, 2960, 17611, 2958, 17613, 2956, 17615, 2954, 17617, 2952, 17619, 2950, 17621, 2948, 17623, 2946, 17625, 2944, 17627, 2942, 17629, 2940, 17631, 2938, 17633, 2936, 17635, 2934, 17637, 2932, 17639, 2930, 17641, 2928, 17643, 2926, 17645, 2924, 17647, 2922, 17649, 2920, 17651, 2918, 17653, 2916, 17655, 2914, 17657, 2912, 17659, 2910, 17661, 2908, 17663, 2906, 17665, 2904, 17667, 2902, 17669, 2900, 17671, 2898, 17673, 2896, 17675, 2894, 17677, 2892, 17679, 2890, 17681, 2888, 17683, 2886, 17685, 2884, 17687, 2882, 17689, 2880, 17691, 2878, 17693, 2876, 17695, 2874, 17697, 2872, 17699, 2870, 17701, 2868, 17703, 2866, 17705, 2864, 17707, 2862, 17709, 2860, 17711, 2858, 17713, 2856, 17715, 2854, 17717, 2852, 17719, 2850, 17721, 2848, 17723, 2846, 17725, 2844, 17727, 2842, 17729, 2840, 17731, 2838, 17733, 2836, 17735, 2834, 17737, 2832, 17739, 2830, 17741, 2828, 17743, 2826, 17745, 2824, 17747, 2822, 17749, 2820, 17751, 2818, 17753, 2816, 17755, 2814, 17757, 2812, 17759, 2810, 17761, 2808, 17763, 2806, 17765, 2804, 17767, 2802, 17769, 2800, 17771, 2798, 17773, 2796, 17775, 2794, 17777, 2792, 17779, 2790, 17781, 2788, 17783, 2786, 17785, 2784, 17787, 2782, 17789, 2780, 17791, 2778, 17793, 2776, 17795, 2774, 17797, 2772, 17799, 2770, 17801, 2768, 17803, 2766, 17805, 2764, 17807, 2762, 17809, 2760, 17811, 2758, 17813, 2756, 17815, 2754, 17817, 2752, 17819, 2750, 17821, 2748, 17823, 2746, 17825, 2744, 17827, 2742, 17829, 2740, 17831, 2738, 17833, 2736, 17835, 2734, 17837, 2732, 17839, 2730, 17841, 2728, 17843, 2726, 17845, 2724, 17847, 2722, 17849, 2720, 17851, 2718, 17853, 2716, 17855, 2714, 17857, 2712, 17859, 2710, 17861, 2708, 17863, 2706, 17865, 2704, 17867, 2702, 17869, 2700, 17871, 2698, 17873, 2696, 17875, 2694, 17877, 2692, 17879, 2690, 17881, 2688, 17883, 2686, 17885, 2684, 17887, 2682, 17889, 2680, 17891, 2678, 17893, 2676, 17895, 2674, 17897, 2672, 17899, 2670, 17901, 2668, 17903, 2666, 17905, 2664, 17907, 2662, 17909, 2660, 17911, 2658, 17913, 2656, 17915, 2654, 17917, 2652, 17919, 2650, 17921, 2648, 17923, 2646, 17925, 2644, 17927, 2642, 17929, 2640, 17931, 2638, 17933, 2636, 17935, 2634, 17937, 2632, 17939, 2630, 17941, 2628, 17943, 2626, 17945, 2624, 17947, 2622, 17949, 2620, 17951, 2618, 17953, 2616, 17955, 2614, 17957, 2612, 17959, 2610, 17961, 2608, 17963, 2606, 17965, 2604, 17967, 2602, 17969, 2600, 17971, 2598, 17973, 2596, 17975, 2594, 17977, 2592, 17979, 2590, 17981, 2588, 17983, 2586, 17985, 2584, 17987, 2582, 17989, 2580, 17991, 2578, 17993, 2576, 17995, 2574, 17997, 2572, 17999, 2570, 18001, 2568, 18003, 2566, 18005, 2564, 18007, 2562, 18009, 2560, 18011, 2558, 18013, 2556, 18015, 2554, 18017, 2552, 18019, 2550, 18021, 2548, 18023, 2546, 18025, 2544, 18027, 2542, 18029, 2540, 18031, 2538, 18033, 2536, 18035, 2534, 18037, 2532, 18039, 2530, 18041, 2528, 18043, 2526, 18045, 2524, 18047, 2522, 18049, 2520, 18051, 2518, 18053, 2516, 18055, 2514, 18057, 2512, 18059, 2510, 18061, 2508, 18063, 2506, 18065, 2504, 18067, 2502, 18069, 2500, 18071, 2498, 18073, 2496, 18075, 2494, 18077, 2492, 18079, 2490, 18081, 2488, 18083, 2486, 18085, 2484, 18087, 2482, 18089, 2480, 18091, 2478, 18093, 2476, 18095, 2474, 18097, 2472, 18099, 2470, 18101, 2468, 18103, 2466, 18105, 2464, 18107, 2462, 18109, 2460, 18111, 2458, 18113, 2456, 18115, 2454, 18117, 2452, 18119, 2450, 18121, 2448, 18123, 2446, 18125, 2444, 18127, 2442, 18129, 2440, 18131, 2438, 18133, 2436, 18135, 2434, 18137, 2432, 18139, 2430, 18141, 2428, 18143, 2426, 18145, 2424, 18147, 2422, 18149, 2420, 18151, 2418, 18153, 2416, 18155, 2414, 18157, 2412, 18159, 2410, 18161, 2408, 18163, 2406, 18165, 2404, 18167, 2402, 18169, 2400, 18171, 2398, 18173, 2396, 18175, 2394, 18177, 2392, 18179, 2390, 18181, 2388, 18183, 2386, 18185, 2384, 18187, 2382, 18189, 2380, 18191, 2378, 18193, 2376, 18195, 2374, 18197, 2372, 18199, 2370, 18201, 2368, 18203, 2366, 18205, 2364, 18207, 2362, 18209, 2360, 18211, 2358, 18213, 2356, 18215, 2354, 18217, 2352, 18219, 2350, 18221, 2348, 18223, 2346, 18225, 2344, 18227, 2342, 18229, 2340, 18231, 2338, 18233, 2336, 18235, 2334, 18237, 2332, 18239, 2330, 18241, 2328, 18243, 2326, 18245, 2324, 18247, 2322, 18249, 2320, 18251, 2318, 18253, 2316, 18255, 2314, 18257, 2312, 18259, 2310, 18261, 2308, 18263, 2306, 18265, 2304, 18267, 2302, 18269, 2300, 18271, 2298, 18273, 2296, 18275, 2294, 18277, 2292, 18279, 2290, 18281, 2288, 18283, 2286, 18285, 2284, 18287, 2282, 18289, 2280, 18291, 2278, 18293, 2276, 18295, 2274, 18297, 2272, 18299, 2270, 18301, 2268, 18303, 2266, 18305, 2264, 18307, 2262, 18309, 2260, 18311, 2258, 18313, 2256, 18315, 2254, 18317, 2252, 18319, 2250, 18321, 2248, 18323, 2246, 18325, 2244, 18327, 2242, 18329, 2240, 18331, 2238, 18333, 2236, 18335, 2234, 18337, 2232, 18339, 2230, 18341, 2228, 18343, 2226, 18345, 2224, 18347, 2222, 18349, 2220, 18351, 2218, 18353, 2216, 18355, 2214, 18357, 2212, 18359, 2210, 18361, 2208, 18363, 2206, 18365, 2204, 18367, 2202, 18369, 2200, 18371, 2198, 18373, 2196, 18375, 2194, 18377, 2192, 18379, 2190, 18381, 2188, 18383, 2186, 18385, 2184, 18387, 2182, 18389, 2180, 18391, 2178, 18393, 2176, 18395, 2174, 18397, 2172, 18399, 2170, 18401, 2168, 18403, 2166, 18405, 2164, 18407, 2162, 18409, 2160, 18411, 2158, 18413, 2156, 18415, 2154, 18417, 2152, 18419, 2150, 18421, 2148, 18423, 2146, 18425, 2144, 18427, 2142, 18429, 2140, 18431, 2138, 18433, 2136, 18435, 2134, 18437, 2132, 18439, 2130, 18441, 2128, 18443, 2126, 18445, 2124, 18447, 2122, 18449, 2120, 18451, 2118, 18453, 2116, 18455, 2114, 18457, 2112, 18459, 2110, 18461, 2108, 18463, 2106, 18465, 2104, 18467, 2102, 18469, 2100, 18471, 2098, 18473, 2096, 18475, 2094, 18477, 2092, 18479, 2090, 18481, 2088, 18483, 2086, 18485, 2084, 18487, 2082, 18489, 2080, 18491, 2078, 18493, 2076, 18495, 2074, 18497, 2072, 18499, 2070, 18501, 2068, 18503, 2066, 18505, 2064, 18507, 2062, 18509, 2060, 18511, 2058, 18513, 2056, 18515, 2054, 18517, 2052, 18519, 2050, 18521, 2048, 18523, 2046, 18525, 2044, 18527, 2042, 18529, 2040, 18531, 2038, 18533, 2036, 18535, 2034, 18537, 2032, 18539, 2030, 18541, 2028, 18543, 2026, 18545, 2024, 18547, 2022, 18549, 2020, 18551, 2018, 18553, 2016, 18555, 2014, 18557, 2012, 18559, 2010, 18561, 2008, 18563, 2006, 18565, 2004, 18567, 2002, 18569, 2000, 18571, 1998, 18573, 1996, 18575, 1994, 18577, 1992, 18579, 1990, 18581, 1988, 18583, 1986, 18585, 1984, 18587, 1982, 18589, 1980, 18591, 1978, 18593, 1976, 18595, 1974, 18597, 1972, 18599, 1970, 18601, 1968, 18603, 1966, 18605, 1964, 18607, 1962, 18609, 1960, 18611, 1958, 18613, 1956, 18615, 1954, 18617, 1952, 18619, 1950, 18621, 1948, 18623, 1946, 18625, 1944, 18627, 1942, 18629, 1940, 18631, 1938, 18633, 1936, 18635, 1934, 18637, 1932, 18639, 1930, 18641, 1928, 18643, 1926, 18645, 1924, 18647, 1922, 18649, 1920, 18651, 1918, 18653, 1916, 18655, 1914, 18657, 1912, 18659, 1910, 18661, 1908, 18663, 1906, 18665, 1904, 18667, 1902, 18669, 1900, 18671, 1898, 18673, 1896, 18675, 1894, 18677, 1892, 18679, 1890, 18681, 1888, 18683, 1886, 18685, 1884, 18687, 1882, 18689, 1880, 18691, 1878, 18693, 1876, 18695, 1874, 18697, 1872, 18699, 1870, 18701, 1868, 18703, 1866, 18705, 1864, 18707, 1862, 18709, 1860, 18711, 1858, 18713, 1856, 18715, 1854, 18717, 1852, 18719, 1850, 18721, 1848, 18723, 1846, 18725, 1844, 18727, 1842, 18729, 1840, 18731, 1838, 18733, 1836, 18735, 1834, 18737, 1832, 18739, 1830, 18741, 1828, 18743, 1826, 18745, 1824, 18747, 1822, 18749, 1820, 18751, 1818, 18753, 1816, 18755, 1814, 18757, 1812, 18759, 1810, 18761, 1808, 18763, 1806, 18765, 1804, 18767, 1802, 18769, 1800, 18771, 1798, 18773, 1796, 18775, 1794, 18777, 1792, 18779, 1790, 18781, 1788, 18783, 1786, 18785, 1784, 18787, 1782, 18789, 1780, 18791, 1778, 18793, 1776, 18795, 1774, 18797, 1772, 18799, 1770, 18801, 1768, 18803, 1766, 18805, 1764, 18807, 1762, 18809, 1760, 18811, 1758, 18813, 1756, 18815, 1754, 18817, 1752, 18819, 1750, 18821, 1748, 18823, 1746, 18825, 1744, 18827, 1742, 18829, 1740, 18831, 1738, 18833, 1736, 18835, 1734, 18837, 1732, 18839, 1730, 18841, 1728, 18843, 1726, 18845, 1724, 18847, 1722, 18849, 1720, 18851, 1718, 18853, 1716, 18855, 1714, 18857, 1712, 18859, 1710, 18861, 1708, 18863, 1706, 18865, 1704, 18867, 1702, 18869, 1700, 18871, 1698, 18873, 1696, 18875, 1694, 18877, 1692, 18879, 1690, 18881, 1688, 18883, 1686, 18885, 1684, 18887, 1682, 18889, 1680, 18891, 1678, 18893, 1676, 18895, 1674, 18897, 1672, 18899, 1670, 18901, 1668, 18903, 1666, 18905, 1664, 18907, 1662, 18909, 1660, 18911, 1658, 18913, 1656, 18915, 1654, 18917, 1652, 18919, 1650, 18921, 1648, 18923, 1646, 18925, 1644, 18927, 1642, 18929, 1640, 18931, 1638, 18933, 1636, 18935, 1634, 18937, 1632, 18939, 1630, 18941, 1628, 18943, 1626, 18945, 1624, 18947, 1622, 18949, 1620, 18951, 1618, 18953, 1616, 18955, 1614, 18957, 1612, 18959, 1610, 18961, 1608, 18963, 1606, 18965, 1604, 18967, 1602, 18969, 1600, 18971, 1598, 18973, 1596, 18975, 1594, 18977, 1592, 18979, 1590, 18981, 1588, 18983, 1586, 18985, 1584, 18987, 1582, 18989, 1580, 18991, 1578, 18993, 1576, 18995, 1574, 18997, 1572, 18999, 1570, 19001, 1568, 19003, 1566, 19005, 1564, 19007, 1562, 19009, 1560, 19011, 1558, 19013, 1556, 19015, 1554, 19017, 1552, 19019, 1550, 19021, 1548, 19023, 1546, 19025, 1544, 19027, 1542, 19029, 1540, 19031, 1538, 19033, 1536, 19035, 1534, 19037, 1532, 19039, 1530, 19041, 1528, 19043, 1526, 19045, 1524, 19047, 1522, 19049, 1520, 19051, 1518, 19053, 1516, 19055, 1514, 19057, 1512, 19059, 1510, 19061, 1508, 19063, 1506, 19065, 1504, 19067, 1502, 19069, 1500, 19071, 1498, 19073, 1496, 19075, 1494, 19077, 1492, 19079, 1490, 19081, 1488, 19083, 1486, 19085, 1484, 19087, 1482, 19089, 1480, 19091, 1478, 19093, 1476, 19095, 1474, 19097, 1472, 19099, 1470, 19101, 1468, 19103, 1466, 19105, 1464, 19107, 1462, 19109, 1460, 19111, 1458, 19113, 1456, 19115, 1454, 19117, 1452, 19119, 1450, 19121, 1448, 19123, 1446, 19125, 1444, 19127, 1442, 19129, 1440, 19131, 1438, 19133, 1436, 19135, 1434, 19137, 1432, 19139, 1430, 19141, 1428, 19143, 1426, 19145, 1424, 19147, 1422, 19149, 1420, 19151, 1418, 19153, 1416, 19155, 1414, 19157, 1412, 19159, 1410, 19161, 1408, 19163, 1406, 19165, 1404, 19167, 1402, 19169, 1400, 19171, 1398, 19173, 1396, 19175, 1394, 19177, 1392, 19179, 1390, 19181, 1388, 19183, 1386, 19185, 1384, 19187, 1382, 19189, 1380, 19191, 1378, 19193, 1376, 19195, 1374, 19197, 1372, 19199, 1370, 19201, 1368, 19203, 1366, 19205, 1364, 19207, 1362, 19209, 1360, 19211, 1358, 19213, 1356, 19215, 1354, 19217, 1352, 19219, 1350, 19221, 1348, 19223, 1346, 19225, 1344, 19227, 1342, 19229, 1340, 19231, 1338, 19233, 1336, 19235, 1334, 19237, 1332, 19239, 1330, 19241, 1328, 19243, 1326, 19245, 1324, 19247, 1322, 19249, 1320, 19251, 1318, 19253, 1316, 19255, 1314, 19257, 1312, 19259, 1310, 19261, 1308, 19263, 1306, 19265, 1304, 19267, 1302, 19269, 1300, 19271, 1298, 19273, 1296, 19275, 1294, 19277, 1292, 19279, 1290, 19281, 1288, 19283, 1286, 19285, 1284, 19287, 1282, 19289, 1280, 19291, 1278, 19293, 1276, 19295, 1274, 19297, 1272, 19299, 1270, 19301, 1268, 19303, 1266, 19305, 1264, 19307, 1262, 19309, 1260, 19311, 1258, 19313, 1256, 19315, 1254, 19317, 1252, 19319, 1250, 19321, 1248, 19323, 1246, 19325, 1244, 19327, 1242, 19329, 1240, 19331, 1238, 19333, 1236, 19335, 1234, 19337, 1232, 19339, 1230, 19341, 1228, 19343, 1226, 19345, 1224, 19347, 1222, 19349, 1220, 19351, 1218, 19353, 1216, 19355, 1214, 19357, 1212, 19359, 1210, 19361, 1208, 19363, 1206, 19365, 1204, 19367, 1202, 19369, 1200, 19371, 1198, 19373, 1196, 19375, 1194, 19377, 1192, 19379, 1190, 19381, 1188, 19383, 1186, 19385, 1184, 19387, 1182, 19389, 1180, 19391, 1178, 19393, 1176, 19395, 1174, 19397, 1172, 19399, 1170, 19401, 1168, 19403, 1166, 19405, 1164, 19407, 1162, 19409, 1160, 19411, 1158, 19413, 1156, 19415, 1154, 19417, 1152, 19419, 1150, 19421, 1148, 19423, 1146, 19425, 1144, 19427, 1142, 19429, 1140, 19431, 1138, 19433, 1136, 19435, 1134, 19437, 1132, 19439, 1130, 19441, 1128, 19443, 1126, 19445, 1124, 19447, 1122, 19449, 1120, 19451, 1118, 19453, 1116, 19455, 1114, 19457, 1112, 19459, 1110, 19461, 1108, 19463, 1106, 19465, 1104, 19467, 1102, 19469, 1100, 19471, 1098, 19473, 1096, 19475, 1094, 19477, 1092, 19479, 1090, 19481, 1088, 19483, 1086, 19485, 1084, 19487, 1082, 19489, 1080, 19491, 1078, 19493, 1076, 19495, 1074, 19497, 1072, 19499, 1070, 19501, 1068, 19503, 1066, 19505, 1064, 19507, 1062, 19509, 1060, 19511, 1058, 19513, 1056, 19515, 1054, 19517, 1052, 19519, 1050, 19521, 1048, 19523, 1046, 19525, 1044, 19527, 1042, 19529, 1040, 19531, 1038, 19533, 1036, 19535, 1034, 19537, 1032, 19539, 1030, 19541, 1028, 19543, 1026, 19545, 1024, 19547, 1022, 19549, 1020, 19551, 1018, 19553, 1016, 19555, 1014, 19557, 1012, 19559, 1010, 19561, 1008, 19563, 1006, 19565, 1004, 19567, 1002, 19569, 1000, 19571, 998, 19573, 996, 19575, 994, 19577, 992, 19579, 990, 19581, 988, 19583, 986, 19585, 984, 19587, 982, 19589, 980, 19591, 978, 19593, 976, 19595, 974, 19597, 972, 19599, 970, 19601, 968, 19603, 966, 19605, 964, 19607, 962, 19609, 960, 19611, 958, 19613, 956, 19615, 954, 19617, 952, 19619, 950, 19621, 948, 19623, 946, 19625, 944, 19627, 942, 19629, 940, 19631, 938, 19633, 936, 19635, 934, 19637, 932, 19639, 930, 19641, 928, 19643, 926, 19645, 924, 19647, 922, 19649, 920, 19651, 918, 19653, 916, 19655, 914, 19657, 912, 19659, 910, 19661, 908, 19663, 906, 19665, 904, 19667, 902, 19669, 900, 19671, 898, 19673, 896, 19675, 894, 19677, 892, 19679, 890, 19681, 888, 19683, 886, 19685, 884, 19687, 882, 19689, 880, 19691, 878, 19693, 876, 19695, 874, 19697, 872, 19699, 870, 19701, 868, 19703, 866, 19705, 864, 19707, 862, 19709, 860, 19711, 858, 19713, 856, 19715, 854, 19717, 852, 19719, 850, 19721, 848, 19723, 846, 19725, 844, 19727, 842, 19729, 840, 19731, 838, 19733, 836, 19735, 834, 19737, 832, 19739, 830, 19741, 828, 19743, 826, 19745, 824, 19747, 822, 19749, 820, 19751, 818, 19753, 816, 19755, 814, 19757, 812, 19759, 810, 19761, 808, 19763, 806, 19765, 804, 19767, 802, 19769, 800, 19771, 798, 19773, 796, 19775, 794, 19777, 792, 19779, 790, 19781, 788, 19783, 786, 19785, 784, 19787, 782, 19789, 780, 19791, 778, 19793, 776, 19795, 774, 19797, 772, 19799, 770, 19801, 768, 19803, 766, 19805, 764, 19807, 762, 19809, 760, 19811, 758, 19813, 756, 19815, 754, 19817, 752, 19819, 750, 19821, 748, 19823, 746, 19825, 744, 19827, 742, 19829, 740, 19831, 738, 19833, 736, 19835, 734, 19837, 732, 19839, 730, 19841, 728, 19843, 726, 19845, 724, 19847, 722, 19849, 720, 19851, 718, 19853, 716, 19855, 714, 19857, 712, 19859, 710, 19861, 708, 19863, 706, 19865, 704, 19867, 702, 19869, 700, 19871, 698, 19873, 696, 19875, 694, 19877, 692, 19879, 690, 19881, 688, 19883, 686, 19885, 684, 19887, 682, 19889, 680, 19891, 678, 19893, 676, 19895, 674, 19897, 672, 19899, 670, 19901, 668, 19903, 666, 19905, 664, 19907, 662, 19909, 660, 19911, 658, 19913, 656, 19915, 654, 19917, 652, 19919, 650, 19921, 648, 19923, 646, 19925, 644, 19927, 642, 19929, 640, 19931, 638, 19933, 636, 19935, 634, 19937, 632, 19939, 630, 19941, 628, 19943, 626, 19945, 624, 19947, 622, 19949, 620, 19951, 618, 19953, 616, 19955, 614, 19957, 612, 19959, 610, 19961, 608, 19963, 606, 19965, 604, 19967, 602, 19969, 600, 19971, 598, 19973, 596, 19975, 594, 19977, 592, 19979, 590, 19981, 588, 19983, 586, 19985, 584, 19987, 582, 19989, 580, 19991, 578, 19993, 576, 19995, 574, 19997, 572, 19999, 570, 20001, 568, 20003, 566, 20005, 564, 20007, 562, 20009, 560, 20011, 558, 20013, 556, 20015, 554, 20017, 552, 20019, 550, 20021, 548, 20023, 546, 20025, 544, 20027, 542, 20029, 540, 20031, 538, 20033, 536, 20035, 534, 20037, 532, 20039, 530, 20041, 528, 20043, 526, 20045, 524, 20047, 522, 20049, 520, 20051, 518, 20053, 516, 20055, 514, 20057, 512, 20059, 510, 20061, 508, 20063, 506, 20065, 504, 20067, 502, 20069, 500, 20071, 498, 20073, 496, 20075, 494, 20077, 492, 20079, 490, 20081, 488, 20083, 486, 20085, 484, 20087, 482, 20089, 480, 20091, 478, 20093, 476, 20095, 474, 20097, 472, 20099, 470, 20101, 468, 20103, 466, 20105, 464, 20107, 462, 20109, 460, 20111, 458, 20113, 456, 20115, 454, 20117, 452, 20119, 450, 20121, 448, 20123, 446, 20125, 444, 20127, 442, 20129, 440, 20131, 438, 20133, 436, 20135, 434, 20137, 432, 20139, 430, 20141, 428, 20143, 426, 20145, 424, 20147, 422, 20149, 420, 20151, 418, 20153, 416, 20155, 414, 20157, 412, 20159, 410, 20161, 408, 20163, 406, 20165, 404, 20167, 402, 20169, 400, 20171, 398, 20173, 396, 20175, 394, 20177, 392, 20179, 390, 20181, 388, 20183, 386, 20185, 384, 20187, 382, 20189, 380, 20191, 378, 20193, 376, 20195, 374, 20197, 372, 20199, 370, 20201, 368, 20203, 366, 20205, 364, 20207, 362, 20209, 360, 20211, 358, 20213, 356, 20215, 354, 20217, 352, 20219, 350, 20221, 348, 20223, 346, 20225, 344, 20227, 342, 20229, 340, 20231, 338, 20233, 336, 20235, 334, 20237, 332, 20239, 330, 20241, 328, 20243, 326, 20245, 324, 20247, 322, 20249, 320, 20251, 318, 20253, 316, 20255, 314, 20257, 312, 20259, 310, 20261, 308, 20263, 306, 20265, 304, 20267, 302, 20269, 300, 20271, 298, 20273, 296, 20275, 294, 20277, 292, 20279, 290, 20281, 288, 20283, 286, 20285, 284, 20287, 282, 20289, 280, 20291, 278, 20293, 276, 20295, 274, 20297, 272, 20299, 270, 20301, 268, 20303, 266, 20305, 264, 20307, 262, 20309, 260, 20311, 258, 20313, 256, 20315, 254, 20317, 252, 20319, 250, 20321, 248, 20323, 246, 20325, 244, 20327, 242, 20329, 240, 20331, 238, 20333, 236, 20335, 234, 20337, 232, 20339, 230, 20341, 228, 20343, 226, 20345, 224, 20347, 222, 20349, 220, 20351, 218, 20353, 216, 20355, 214, 20357, 212, 20359, 210, 20361, 208, 20363, 206, 20365, 204, 20367, 202, 20369, 200, 20371, 198, 20373, 196, 20375, 194, 20377, 192, 20379, 190, 20381, 188, 20383, 186, 20385, 184, 20387, 182, 20389, 180, 20391, 178, 20393, 176, 20395, 174, 20397, 172, 20399, 170, 20401, 168, 20403, 166, 20405, 164, 20407, 162, 20409, 160, 20411, 158, 20413, 156, 20415, 154, 20417, 152, 20419, 150, 20421, 148, 20423, 146, 20425, 144, 20427, 142, 20429, 140, 20431, 138, 20433, 136, 20435, 134, 20437, 132, 20439, 130, 20441, 128, 20443, 126, 20445, 124, 20447, 122, 20449, 120, 20451, 118, 20453, 116, 20455, 114, 20457, 112, 20459, 110, 20461, 108, 20463, 106, 20465, 104, 20467, 102, 20469, 100, 20471, 98, 20473, 96, 20475, 94, 20477, 92, 20479, 90, 20481, 88, 20483, 86, 20485, 84, 20487, 82, 20489, 80, 20491, 78, 20493, 76, 20495, 74, 20497, 72, 20499, 70, 20501, 68, 20503, 66, 20505, 64, 20507, 62, 20509, 60, 20511, 58, 20513, 56, 20515, 54, 20517, 52, 20519, 50, 20521, 48, 20523, 46, 20525, 44, 20527, 42, 20529, 40, 20531, 38, 20533, 36, 20535, 34, 20537, 32, 20539, 30, 20541, 28, 20543, 26, 20545, 24, 20547, 22, 20549, 20, 20551, 18, 20553, 16, 20555, 14, 20557, 12, 20559, 10, 20561, 8, 20563, 6, 20565, 4, 20567, 2, 20569]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s5/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s5/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-s5/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0aa8e5543a611a4e20b6f03b73b85d18549f90b0 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 20570, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s5/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l6-s5/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prime-graph-coloring-l4-s1/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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-rlve-prime-graph-coloring-l4-s1/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ce9b162d64bb2e12a2622de1970ba2581851e29e --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 282, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s1/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..80a01584b77b98f514606b3dcf42a6ed1db92ae8 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 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-l4-s1/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s1/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + sieve = [True] * (n + 1) + sieve[0] = False + if n >= 1: + sieve[1] = False + for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: + for j in range(i * i, n + 1, i): + sieve[j] = False + for p in range(2, n): + if sieve[p]: + for u in range(n - p): + if c[u] == c[u + p]: + raise Invalid(f"vertices {u + 1} and {u + p + 1} (difference {p}) share a colour") + return None, {} diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s1/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ce9b162d64bb2e12a2622de1970ba2581851e29e --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 282, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s1/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s1/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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-rlve-prime-graph-coloring-l4-s6/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s6/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..96f4694dbd35f6f6d93e422bdf41317e282dcb24 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 120, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s6/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f624b13eb1b0c3f7cfd8a35fe1b780cc3a4a03ab --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 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]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s6/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s6/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + sieve = [True] * (n + 1) + sieve[0] = False + if n >= 1: + sieve[1] = False + for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: + for j in range(i * i, n + 1, i): + sieve[j] = False + for p in range(2, n): + if sieve[p]: + for u in range(n - p): + if c[u] == c[u + p]: + raise Invalid(f"vertices {u + 1} and {u + p + 1} (difference {p}) share a colour") + return None, {} diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s6/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..96f4694dbd35f6f6d93e422bdf41317e282dcb24 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 120, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s6/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s6/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s8/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s8/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b546980f522d02300cdd273171ae672745009ad1 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 107, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s8/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..08b139e1777d3c202f32fb107d690474ed8f8795 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 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-l4-s8/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s8/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + sieve = [True] * (n + 1) + sieve[0] = False + if n >= 1: + sieve[1] = False + for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: + for j in range(i * i, n + 1, i): + sieve[j] = False + for p in range(2, n): + if sieve[p]: + for u in range(n - p): + if c[u] == c[u + p]: + raise Invalid(f"vertices {u + 1} and {u + p + 1} (difference {p}) share a colour") + return None, {} diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s8/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b546980f522d02300cdd273171ae672745009ad1 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 107, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s8/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prime-graph-coloring-l4-s8/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l4-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-recursive-sequence-sum-l2-s4/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l2-s4/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..560646fc08b4b5f1fae7358f208dee5371a0b382 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"F0": 15, "A": 7, "B": 1754, "S": 290116595, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l2-s4/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a5d01273ca527142b7658f0944f247d3ac4f6499 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [2, 3, 4, 6, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l2-s4/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-s4/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-l2-s4/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..560646fc08b4b5f1fae7358f208dee5371a0b382 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"F0": 15, "A": 7, "B": 1754, "S": 290116595, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l2-s4/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l2-s4/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-round-robin-scores-l2-s0/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l2-s0/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a5b97c57150d1cc2fc334c4258f5a52d79a398fa --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"W": [3, 9, 5, 5, 9, 4], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l2-s0/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bf1af90ba76fd0a880004f6f1a7e128fb4167b9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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' +{"A": ["001011", "201211", "110111", "201001", "111202", "111100"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l2-s0/tests/check.py b/tasks/construct-rlve-round-robin-scores-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l2-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-l2-s0/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a5b97c57150d1cc2fc334c4258f5a52d79a398fa --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"W": [3, 9, 5, 5, 9, 4], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l2-s0/tests/run.py b/tasks/construct-rlve-round-robin-scores-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l2-s0/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l2-s7/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l2-s7/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..62d19f88c74514d384d1af918ca11c1e083b2654 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"W": [9, 7, 12, 0, 9, 7], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l2-s7/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..20567c55ff39f683958921d1247efa700f7bacec --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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' +{"A": ["020202", "002201", "200222", "000000", "220200", "010220"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l2-s7/tests/check.py b/tasks/construct-rlve-round-robin-scores-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l2-s7/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l2-s7/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..62d19f88c74514d384d1af918ca11c1e083b2654 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"W": [9, 7, 12, 0, 9, 7], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l2-s7/tests/run.py b/tasks/construct-rlve-round-robin-scores-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l2-s7/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l6-s6/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l6-s6/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fa2a4cf3ce559c49d73cb8b58fa1f0a4cf962656 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"W": [21, 27, 25, 31, 28, 26, 25, 28, 15, 24, 24, 35, 32, 29, 23, 25, 26, 32, 34, 28, 25, 34, 31, 26, 22], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l6-s6/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..88eebca5314155f74e41d67696fc797febbbe4ca --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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' +{"A": ["0010111011111011101211111", "2011111111111120111111111", "1101111010122111010012111", "2110022111111111212111001", "1112011111111112111111111", "1110101111200111112110112", "1110110111100111111122111", "2121111021110011110110211", "1111111001110100100000111", "1121111110111111011110111", "1111101111011121111110111", "1101122111101112211221111", "1101122221110111111211101", "2111111211111011101101022", "1011111121011100101110112", "1211011121101120110011110", "1120111112101111011111111", "2111111121111221101111111", "1120101221111112110221111", "0121111121100112110021111", "1111110121101211110001012", "1101120222211121111110111", "1112111011111211111121021", "1112111111112011111111001", "1111101111111002111101110"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l6-s6/tests/check.py b/tasks/construct-rlve-round-robin-scores-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l6-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-l6-s6/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fa2a4cf3ce559c49d73cb8b58fa1f0a4cf962656 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"W": [21, 27, 25, 31, 28, 26, 25, 28, 15, 24, 24, 35, 32, 29, 23, 25, 26, 32, 34, 28, 25, 34, 31, 26, 22], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l6-s6/tests/run.py b/tasks/construct-rlve-round-robin-scores-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l6-s6/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l6-s8/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l6-s8/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..62cfda12b63ddf6278df7a6305e359134873e497 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"W": [32, 25, 24, 35, 24, 30, 30, 25, 24, 26, 27, 21, 25, 28, 30, 23, 30, 24, 33, 23, 24, 25, 26, 25, 24], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l6-s8/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..181e572d8bdd89b3688af6a95eee01031836d64f --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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' +{"A": ["0111112212112111111120011", "1021111111111111111011111", "1000111110111112110112111", "1120202111021211101211112", "1110021111110101121110111", "1112001121011111111121121", "0110110111111211112211112", "0111111011111111211111111", "1111101101111111111111201", "0121111110211111011111111", "1112121110011111111111111", "1110111111101011111101111", "0111211111110110211011111", "1110110111121011111122111", "1111211111111101111212111", "1101111111112110011111011", "1111111012110112021112111", "1112011111111111000112101", "1121110111111111120221121", "1210110111112101110011110", "0111101111121011110101211", "2101211111111001001110121", "2111111101111112111101011", "1111101121111111120110101", "1110110111111111111211110"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l6-s8/tests/check.py b/tasks/construct-rlve-round-robin-scores-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l6-s8/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l6-s8/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..62cfda12b63ddf6278df7a6305e359134873e497 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"W": [32, 25, 24, 35, 24, 30, 30, 25, 24, 26, 27, 21, 25, 28, 30, 23, 30, 24, 33, 23, 24, 25, 26, 25, 24], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l6-s8/tests/run.py b/tasks/construct-rlve-round-robin-scores-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l6-s8/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-shortest-path-count-l1-s4/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l1-s4/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0805bc07c0052e28680b4adb484ad6861c5c7653 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"K": 36, "n_max": 37, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l1-s4/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4b37c65da0177a644e3f2a553cccd546e2523c6c --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 18, "adj": ["NNYYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNN", "NNYYNNYYNNNNNNYNNN", "NNYYNNYYNNNNNNYNNN", "NNNNYYNNYYNNNNNNNN", "NNNNYYNNYYNNNNNNNN", "NNNNNNYYNNYYNNNNNN", "NNNNNNYYNNYYNNNNNN", "NNNNNNNNYYNNNNNNNY", "NNNNNNNNYYNNNNNNNY", "NNNNNNNNNNNNNYNNNN", "NNNNNNNNNNNNYNYNNN", "NNNNYYNNNNNNNYNYNN", "NNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNYNY", "NYNNNNNNNNYYNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l1-s4/tests/check.py b/tasks/construct-rlve-shortest-path-count-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l1-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-l1-s4/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0805bc07c0052e28680b4adb484ad6861c5c7653 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"K": 36, "n_max": 37, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l1-s4/tests/run.py b/tasks/construct-rlve-shortest-path-count-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l1-s4/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s6/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s6/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..94e13f41738ad505d9db457191b0a15bb60318c3 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"K": 376, "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-s6/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a73f318daa3b35cdfe42b4c4bba0315877438b2f --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 27, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNYNNNNN", "NNNNYYNNYYNNNNNNNNNNNYNNNNN", "NNNNNNYYNNYYNNNNNNNNNNYNNNN", "NNNNNNYYNNYYNNNNNNNNNNYNNNN", "NNNNNNNNYYNNYYNNNNNNNNNYNNN", "NNNNNNNNYYNNYYNNNNNNNNNYNNN", "NNNNNNNNNNYYNNYYNNNNNNNNYNN", "NNNNNNNNNNYYNNYYNNNNNNNNYNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNN", "NNNNNNNNNNNNNNYYNNNNNNNNNNY", "NNNNNNNNNNNNNNYYNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNYYNNNNNNNNNNNNYNYNNNN", "NNNNNNNNYYNNNNNNNNNNNYNYNNN", "NNNNNNNNNNYYNNNNNNNNNNYNYNN", "NNNNNNNNNNNNYYNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNYYNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l2-s6/tests/check.py b/tasks/construct-rlve-shortest-path-count-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s6/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-s6/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..94e13f41738ad505d9db457191b0a15bb60318c3 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"K": 376, "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-s6/tests/run.py b/tasks/construct-rlve-shortest-path-count-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s6/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l5-s2/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l5-s2/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bce819cfa8dac61c2d98b630f53387c6a77df1e9 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"K": 21995696772858, "n_max": 273, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l5-s2/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..df09a47caae74e8146cf997b7979a43fd09974ed --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 135, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l5-s2/tests/check.py b/tasks/construct-rlve-shortest-path-count-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l5-s2/tests/check.py @@ -0,0 +1,34 @@ +from run import Invalid, as_int + + +def check(inst, ans): + n = as_int(ans.get("n"), "n", lo=2, hi=inst["n_max"]) + adj = ans.get("adj") + if not isinstance(adj, list) or len(adj) != n: + raise Invalid(f"adj must be a list of {n} strings") + for r in adj: + if not isinstance(r, str) or len(r) != n or set(r) - {"Y", "N"}: + raise Invalid("each row must be a string of length n over {'Y','N'}") + for i in range(n): + if adj[i][i] != "N": + raise Invalid("self-loop") + for j in range(i + 1, n): + if adj[i][j] != adj[j][i]: + raise Invalid("matrix not symmetric") + nb = [[j for j in range(n) if adj[i][j] == "Y"] for i in range(n)] + dist = [-1] * n + cnt = [0] * n + dist[0], cnt[0] = 0, 1 + q = [0] + for u in q: # BFS with exact (Python int) path counts + for v in nb[u]: + if dist[v] < 0: + dist[v] = dist[u] + 1 + q.append(v) + if dist[v] == dist[u] + 1: + cnt[v] += cnt[u] + if dist[1] < 0: + raise Invalid("vertex 2 is unreachable from vertex 1") + if cnt[1] != inst["K"]: + raise Invalid(f"{cnt[1]} shortest paths, need {inst['K']}") + return None, {} diff --git a/tasks/construct-rlve-shortest-path-count-l5-s2/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bce819cfa8dac61c2d98b630f53387c6a77df1e9 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"K": 21995696772858, "n_max": 273, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l5-s2/tests/run.py b/tasks/construct-rlve-shortest-path-count-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l5-s2/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l5-s5/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d4e5e9d675db3d2c5d877f7c1fcecc832361332a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 141, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l5-s5/tests/check.py b/tasks/construct-rlve-shortest-path-count-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l5-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-l5-s5/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c04ff8181d31e1849f12500558bb13f96007a751 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"K": 91589818790713, "n_max": 285, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l5-s5/tests/run.py b/tasks/construct-rlve-shortest-path-count-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l5-s5/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l6-s9/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l6-s9/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d2b2415bf40c4e6523a05456bcdbcfc347c82c4f --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"K": 557650159044146215, "n_max": 357, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l6-s9/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f6d6c99868d014a9985525d100089d913b0f8475 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 177, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l6-s9/tests/check.py b/tasks/construct-rlve-shortest-path-count-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s9/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-s9/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d2b2415bf40c4e6523a05456bcdbcfc347c82c4f --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"K": 557650159044146215, "n_max": 357, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l6-s9/tests/run.py b/tasks/construct-rlve-shortest-path-count-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l6-s9/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-smallest-enclosing-circle-l2-s1/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l2-s1/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0de65f46227574cc4a203f20d81dac4b0cacd3e3 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"points": [[0, 16], [4, 13], [5, 10], [6, 8], [9, 5], [9, 10], [13, 2], [14, 9]], "r_opt": 9.5524865872714, "r2_num": 365, "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-l2-s1/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fa1c999f3e9161a0298d04ddb427ad4f854f8921 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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": 6.5, "y": 9.0, "r": 9.5524865882714} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l2-s1/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l2-s1/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l2-s1/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0de65f46227574cc4a203f20d81dac4b0cacd3e3 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"points": [[0, 16], [4, 13], [5, 10], [6, 8], [9, 5], [9, 10], [13, 2], [14, 9]], "r_opt": 9.5524865872714, "r2_num": 365, "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-l2-s1/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l2-s1/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l2-s6/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l2-s6/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c053fab478fa25fd2dd1af0a12a04cd3372809ec --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"points": [[0, 7], [0, 8], [1, 7], [3, 13], [4, 9], [5, 6], [7, 16], [16, 6]], "r_opt": 8.142740270522989, "r2_num": 3023605, "r2_den": 45602, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l2-s6/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..052694ec99868b5e59cf70b05dd4619dec14d520 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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": 8.089403973509933, "y": 7.930463576158941, "r": 8.142740271522989} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l2-s6/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l2-s6/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l2-s6/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c053fab478fa25fd2dd1af0a12a04cd3372809ec --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"points": [[0, 7], [0, 8], [1, 7], [3, 13], [4, 9], [5, 6], [7, 16], [16, 6]], "r_opt": 8.142740270522989, "r2_num": 3023605, "r2_den": 45602, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l2-s6/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l2-s6/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s2/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s2/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b4c1701d144731dbeb8a26b3e586fb3e644c5d6f --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"points": [[0, 57], [1, 91], [4, 109], [5, 11], [5, 70], [7, 45], [15, 81], [16, 98], [20, 120], [23, 42], [24, 70], [26, 12], [26, 17], [28, 45], [30, 13], [31, 25], [32, 65], [33, 25], [34, 79], [35, 38], [35, 100], [37, 92], [37, 112], [43, 21], [44, 95], [48, 66], [50, 10], [51, 65], [57, 4], [60, 36], [60, 60], [62, 19], [64, 92], [67, 2], [67, 75], [69, 17], [69, 62], [71, 64], [74, 91], [76, 53], [81, 4], [81, 85], [83, 90], [83, 107], [89, 21], [92, 31], [94, 47], [100, 100], [103, 13], [103, 117], [104, 90], [105, 31], [109, 3], [110, 64], [111, 68], [111, 98], [112, 12], [113, 26], [113, 59], [118, 78]], "r_opt": 74.62996042085996, "r2_num": 39748462465, "r2_den": 7136642, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s2/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e310c423b87135d28487baea773feb73424738c7 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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' +{"x": 57.987030174695605, "y": 57.47300158814188, "r": 74.62996042185996} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s2/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s2/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-s2/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b4c1701d144731dbeb8a26b3e586fb3e644c5d6f --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"points": [[0, 57], [1, 91], [4, 109], [5, 11], [5, 70], [7, 45], [15, 81], [16, 98], [20, 120], [23, 42], [24, 70], [26, 12], [26, 17], [28, 45], [30, 13], [31, 25], [32, 65], [33, 25], [34, 79], [35, 38], [35, 100], [37, 92], [37, 112], [43, 21], [44, 95], [48, 66], [50, 10], [51, 65], [57, 4], [60, 36], [60, 60], [62, 19], [64, 92], [67, 2], [67, 75], [69, 17], [69, 62], [71, 64], [74, 91], [76, 53], [81, 4], [81, 85], [83, 90], [83, 107], [89, 21], [92, 31], [94, 47], [100, 100], [103, 13], [103, 117], [104, 90], [105, 31], [109, 3], [110, 64], [111, 68], [111, 98], [112, 12], [113, 26], [113, 59], [118, 78]], "r_opt": 74.62996042085996, "r2_num": 39748462465, "r2_den": 7136642, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s2/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s2/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l6-s7/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l6-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l6-s7/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l6-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..53f6fd99492d3c4772762aa91d35c4e38948fcc3 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l6-s7/environment/instance.json @@ -0,0 +1 @@ +{"points": [[1, 89], [1, 155], [5, 73], [5, 128], [9, 212], [15, 219], [20, 150], [25, 10], [25, 46], [27, 113], [28, 59], [30, 129], [31, 229], [32, 219], [37, 141], [43, 46], [43, 209], [49, 126], [50, 31], [53, 31], [56, 93], [56, 237], [57, 206], [58, 143], [61, 117], [65, 233], [67, 119], [67, 196], [71, 23], [71, 65], [72, 137], [74, 42], [77, 130], [79, 111], [79, 227], [81, 169], [82, 136], [90, 65], [90, 125], [93, 83], [95, 5], [97, 48], [97, 84], [98, 44], [101, 5], [102, 108], [110, 156], [114, 201], [116, 184], [117, 70], [123, 7], [123, 9], [125, 195], [129, 169], [131, 69], [133, 92], [134, 30], [134, 163], [137, 76], [137, 229], [138, 68], [143, 32], [144, 134], [144, 224], [148, 161], [149, 40], [149, 192], [150, 210], [152, 91], [153, 41], [154, 64], [154, 215], [156, 171], [157, 230], [158, 152], [158, 223], [161, 227], [162, 125], [167, 209], [169, 144], [170, 191], [170, 196], [171, 226], [172, 61], [175, 44], [180, 88], [181, 237], [182, 28], [184, 165], [187, 47], [188, 157], [192, 88], [192, 180], [194, 41], [194, 102], [196, 148], [196, 156], [198, 146], [198, 235], [199, 131], [203, 80], [203, 213], [206, 164], [215, 202], [216, 45], [219, 148], [221, 116], [222, 4], [222, 189], [223, 197], [225, 183], [225, 184], [227, 118], [228, 8], [230, 201], [235, 116], [235, 162], [236, 48], [236, 102], [240, 165]], "r_opt": 149.90830530694421, "r2_num": 44945, "r2_den": 2, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l6-s7/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l6-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bc1541f609b85cee4adcce7818399f73382468d9 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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' +{"x": 121.5, "y": 113.5, "r": 149.9083053079442} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l6-s7/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l6-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l6-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-l6-s7/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l6-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..53f6fd99492d3c4772762aa91d35c4e38948fcc3 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l6-s7/tests/instance.json @@ -0,0 +1 @@ +{"points": [[1, 89], [1, 155], [5, 73], [5, 128], [9, 212], [15, 219], [20, 150], [25, 10], [25, 46], [27, 113], [28, 59], [30, 129], [31, 229], [32, 219], [37, 141], [43, 46], [43, 209], [49, 126], [50, 31], [53, 31], [56, 93], [56, 237], [57, 206], [58, 143], [61, 117], [65, 233], [67, 119], [67, 196], [71, 23], [71, 65], [72, 137], [74, 42], [77, 130], [79, 111], [79, 227], [81, 169], [82, 136], [90, 65], [90, 125], [93, 83], [95, 5], [97, 48], [97, 84], [98, 44], [101, 5], [102, 108], [110, 156], [114, 201], [116, 184], [117, 70], [123, 7], [123, 9], [125, 195], [129, 169], [131, 69], [133, 92], [134, 30], [134, 163], [137, 76], [137, 229], [138, 68], [143, 32], [144, 134], [144, 224], [148, 161], [149, 40], [149, 192], [150, 210], [152, 91], [153, 41], [154, 64], [154, 215], [156, 171], [157, 230], [158, 152], [158, 223], [161, 227], [162, 125], [167, 209], [169, 144], [170, 191], [170, 196], [171, 226], [172, 61], [175, 44], [180, 88], [181, 237], [182, 28], [184, 165], [187, 47], [188, 157], [192, 88], [192, 180], [194, 41], [194, 102], [196, 148], [196, 156], [198, 146], [198, 235], [199, 131], [203, 80], [203, 213], [206, 164], [215, 202], [216, 45], [219, 148], [221, 116], [222, 4], [222, 189], [223, 197], [225, 183], [225, 184], [227, 118], [228, 8], [230, 201], [235, 116], [235, 162], [236, 48], [236, 102], [240, 165]], "r_opt": 149.90830530694421, "r2_num": 44945, "r2_den": 2, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l6-s7/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l6-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l6-s7/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l6-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l6-s9/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l6-s9/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6a771ac7f67bc7026119deb0a3fb4afae9711d2c --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"points": [[1, 222], [2, 38], [2, 174], [8, 32], [9, 56], [11, 134], [12, 15], [12, 211], [13, 50], [13, 204], [21, 206], [22, 160], [26, 183], [26, 220], [30, 129], [30, 235], [31, 147], [33, 175], [34, 178], [35, 36], [38, 220], [41, 146], [43, 23], [43, 211], [47, 61], [47, 124], [48, 31], [54, 236], [54, 240], [55, 11], [55, 90], [65, 44], [67, 11], [68, 22], [69, 152], [71, 146], [73, 143], [73, 152], [74, 110], [77, 169], [79, 202], [80, 7], [84, 71], [86, 207], [88, 45], [89, 74], [89, 219], [92, 221], [93, 46], [93, 214], [98, 131], [101, 168], [105, 188], [107, 41], [109, 51], [110, 73], [110, 169], [114, 26], [116, 102], [117, 191], [121, 27], [124, 80], [126, 132], [128, 64], [129, 15], [129, 102], [130, 39], [134, 230], [135, 234], [137, 0], [143, 181], [144, 233], [145, 58], [145, 73], [149, 240], [150, 36], [151, 139], [153, 123], [154, 5], [155, 190], [156, 111], [159, 164], [164, 55], [167, 177], [168, 38], [170, 70], [173, 232], [174, 137], [175, 223], [177, 33], [177, 151], [180, 98], [181, 167], [182, 131], [184, 22], [189, 239], [193, 94], [198, 207], [206, 170], [206, 184], [207, 156], [210, 223], [212, 92], [214, 156], [216, 47], [218, 9], [220, 27], [223, 53], [227, 26], [228, 64], [230, 10], [232, 33], [233, 135], [234, 204], [235, 108], [237, 132], [237, 202], [238, 24], [239, 148], [240, 67]], "r_opt": 156.03284910556494, "r2_num": 97385, "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-l6-s9/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..35c8ef9d4608a3b0c841dc6a8a1ab40f84c007d2 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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": 115.5, "y": 116.0, "r": 156.03284910656492} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l6-s9/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l6-s9/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l6-s9/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6a771ac7f67bc7026119deb0a3fb4afae9711d2c --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"points": [[1, 222], [2, 38], [2, 174], [8, 32], [9, 56], [11, 134], [12, 15], [12, 211], [13, 50], [13, 204], [21, 206], [22, 160], [26, 183], [26, 220], [30, 129], [30, 235], [31, 147], [33, 175], [34, 178], [35, 36], [38, 220], [41, 146], [43, 23], [43, 211], [47, 61], [47, 124], [48, 31], [54, 236], [54, 240], [55, 11], [55, 90], [65, 44], [67, 11], [68, 22], [69, 152], [71, 146], [73, 143], [73, 152], [74, 110], [77, 169], [79, 202], [80, 7], [84, 71], [86, 207], [88, 45], [89, 74], [89, 219], [92, 221], [93, 46], [93, 214], [98, 131], [101, 168], [105, 188], [107, 41], [109, 51], [110, 73], [110, 169], [114, 26], [116, 102], [117, 191], [121, 27], [124, 80], [126, 132], [128, 64], [129, 15], [129, 102], [130, 39], [134, 230], [135, 234], [137, 0], [143, 181], [144, 233], [145, 58], [145, 73], [149, 240], [150, 36], [151, 139], [153, 123], [154, 5], [155, 190], [156, 111], [159, 164], [164, 55], [167, 177], [168, 38], [170, 70], [173, 232], [174, 137], [175, 223], [177, 33], [177, 151], [180, 98], [181, 167], [182, 131], [184, 22], [189, 239], [193, 94], [198, 207], [206, 170], [206, 184], [207, 156], [210, 223], [212, 92], [214, 156], [216, 47], [218, 9], [220, 27], [223, 53], [227, 26], [228, 64], [230, 10], [232, 33], [233, 135], [234, 204], [235, 108], [237, 132], [237, 202], [238, 24], [239, 148], [240, 67]], "r_opt": 156.03284910556494, "r2_num": 97385, "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-l6-s9/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l6-s9/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-subgraph-isomorphism-l6-s2/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-rlve-subgraph-isomorphism-l6-s2/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..45efc0e7820b3b142ad8adda0fcb9fc8d80443fd --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"n1": 22, "n2": 36, "edges1": [[16, 21], [7, 11], [1, 19], [1, 18], [0, 2], [6, 14], [5, 21], [4, 17], [3, 18], [11, 18], [2, 7], [6, 15], [10, 12], [10, 21], [11, 16], [2, 16], [2, 5], [9, 14], [2, 15], [0, 14], [2, 12], [6, 11], [1, 21], [19, 21], [3, 6], [2, 18], [7, 20], [0, 3], [6, 20], [16, 20], [8, 17], [8, 21], [7, 14], [9, 20], [4, 8], [16, 18], [1, 10], [17, 19], [3, 7], [17, 21], [9, 11], [7, 18], [7, 17], [13, 20], [8, 19], [13, 17], [15, 16], [8, 20], [7, 15], [5, 19], [6, 21], [9, 21], [1, 2], [14, 19], [4, 13], [20, 21], [8, 9], [5, 15], [17, 20], [16, 19], [9, 16], [12, 15], [1, 15], [7, 12], [0, 8], [1, 4], [13, 14], [7, 16], [10, 17], [9, 17], [4, 15], [4, 12], [4, 18], [2, 10], [5, 17], [15, 18], [6, 12], [9, 10], [15, 20], [15, 17], [2, 19], [1, 8], [0, 17], [8, 15], [3, 14], [6, 8], [9, 15], [18, 20], [0, 16], [1, 12], [2, 4], [9, 12], [6, 13], [2, 9], [1, 6], [3, 11], [14, 20], [5, 9], [10, 16], [1, 13], [14, 18], [4, 20], [0, 19], [17, 18]], "edges2": [[21, 31], [9, 20], [2, 12], [13, 28], [5, 22], [16, 27], [1, 14], [0, 16], [6, 10], [7, 16], [21, 28], [13, 15], [2, 19], [7, 15], [26, 30], [20, 23], [3, 31], [12, 32], [10, 21], [4, 5], [5, 23], [5, 34], [17, 34], [2, 26], [3, 25], [22, 29], [15, 19], [9, 26], [11, 27], [4, 13], [19, 34], [4, 18], [3, 23], [11, 12], [1, 23], [26, 29], [1, 7], [18, 32], [1, 11], [9, 29], [1, 20], [14, 32], [20, 26], [13, 27], [19, 21], [11, 20], [24, 25], [27, 33], [15, 20], [6, 20], [24, 34], [26, 35], [6, 11], [12, 27], [21, 23], [15, 35], [19, 24], [30, 35], [8, 26], [17, 26], [0, 15], [27, 34], [10, 16], [22, 31], [32, 33], [13, 34], [0, 1], [8, 33], [8, 25], [16, 31], [18, 29], [12, 20], [11, 17], [16, 19], [20, 27], [24, 29], [15, 29], [3, 8], [0, 18], [2, 23], [22, 26], [12, 23], [10, 25], [5, 30], [5, 8], [12, 22], [34, 35], [8, 13], [0, 23], [3, 12], [3, 5], [18, 31], [0, 11], [14, 31], [12, 31], [5, 24], [1, 31], [6, 21], [3, 6], [8, 30], [10, 14], [15, 32], [3, 11], [14, 17], [33, 34], [12, 26], [15, 26], [1, 3], [18, 27], [18, 30], [10, 11], [13, 24], [4, 7], [18, 26], [0, 17], [4, 16], [16, 21], [6, 23], [9, 27], [15, 28], [20, 28], [1, 34], [29, 35], [12, 16], [18, 21], [13, 32], [9, 23], [6, 27], [4, 20], [3, 21], [10, 18], [13, 35], [4, 25], [20, 32], [24, 31], [14, 30], [4, 11], [15, 31], [2, 5], [12, 14], [4, 34], [11, 31], [6, 30], [4, 17], [19, 28], [9, 17], [5, 29], [11, 15], [10, 35], [10, 12], [3, 9], [16, 23], [12, 24], [6, 15], [2, 8], [23, 33], [10, 24], [9, 30], [27, 30], [2, 17], [20, 33], [14, 21], [14, 20], [4, 14], [22, 30], [9, 31], [22, 34], [15, 16], [15, 21], [10, 30], [3, 20], [10, 15], [23, 27], [0, 9], [13, 30], [2, 15], [2, 14], [0, 35], [25, 28], [3, 10], [17, 35], [17, 21], [18, 35], [8, 11], [3, 24], [5, 7], [23, 34], [11, 18], [23, 25], [12, 18], [14, 18], [16, 33], [11, 29], [9, 14], [13, 14], [1, 26], [24, 28], [6, 31], [7, 32], [23, 26], [25, 29], [21, 25], [16, 17], [3, 14], [15, 25], [12, 30], [28, 35], [23, 31], [1, 15], [19, 31], [22, 27], [19, 20], [0, 26], [19, 27], [19, 25], [27, 32], [19, 29], [20, 31], [23, 30], [1, 21], [7, 34], [13, 33], [4, 9], [6, 34], [3, 35], [7, 23], [28, 34], [21, 32], [21, 34], [2, 7], [8, 23], [6, 22], [26, 31], [16, 28], [6, 12], [4, 33], [15, 34], [2, 31], [5, 15], [30, 31], [9, 33], [21, 29], [4, 8], [13, 17], [8, 21], [18, 24], [2, 29], [6, 14], [22, 25], [7, 14], [1, 2], [1, 28], [2, 24], [19, 35], [11, 13], [25, 30], [29, 31], [20, 30], [23, 32], [4, 22], [24, 26], [2, 34], [9, 12], [1, 12], [22, 28], [26, 32], [12, 34], [5, 10], [2, 9], [3, 7], [12, 19], [13, 22], [0, 6], [14, 16], [11, 19], [9, 13], [9, 11], [4, 23], [3, 18], [25, 26], [0, 31], [13, 31], [7, 11]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l6-s2/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..15cdbdb894086fa0d3dafdb75ef70f178b20249d --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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' +{"p": [8, 15, 26, 33, 1, 24, 16, 9, 21, 18, 35, 27, 0, 7, 4, 31, 30, 3, 20, 25, 14, 10]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l6-s2/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l6-s2/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n1, n2 = inst["n1"], inst["n2"] + p = int_list(ans.get("p"), n1, 0, n2 - 1, "p") + if len(set(p)) != n1: + raise Invalid("p is not injective") + e1 = {(min(u, v), max(u, v)) for u, v in inst["edges1"]} + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + for u in range(n1): + for v in range(u + 1, n1): + a, b = min(p[u], p[v]), max(p[u], p[v]) + if ((u, v) in e1) != ((a, b) in e2): + raise Invalid(f"pair ({u}, {v}) is not preserved") + return None, {} diff --git a/tasks/construct-rlve-subgraph-isomorphism-l6-s2/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..45efc0e7820b3b142ad8adda0fcb9fc8d80443fd --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"n1": 22, "n2": 36, "edges1": [[16, 21], [7, 11], [1, 19], [1, 18], [0, 2], [6, 14], [5, 21], [4, 17], [3, 18], [11, 18], [2, 7], [6, 15], [10, 12], [10, 21], [11, 16], [2, 16], [2, 5], [9, 14], [2, 15], [0, 14], [2, 12], [6, 11], [1, 21], [19, 21], [3, 6], [2, 18], [7, 20], [0, 3], [6, 20], [16, 20], [8, 17], [8, 21], [7, 14], [9, 20], [4, 8], [16, 18], [1, 10], [17, 19], [3, 7], [17, 21], [9, 11], [7, 18], [7, 17], [13, 20], [8, 19], [13, 17], [15, 16], [8, 20], [7, 15], [5, 19], [6, 21], [9, 21], [1, 2], [14, 19], [4, 13], [20, 21], [8, 9], [5, 15], [17, 20], [16, 19], [9, 16], [12, 15], [1, 15], [7, 12], [0, 8], [1, 4], [13, 14], [7, 16], [10, 17], [9, 17], [4, 15], [4, 12], [4, 18], [2, 10], [5, 17], [15, 18], [6, 12], [9, 10], [15, 20], [15, 17], [2, 19], [1, 8], [0, 17], [8, 15], [3, 14], [6, 8], [9, 15], [18, 20], [0, 16], [1, 12], [2, 4], [9, 12], [6, 13], [2, 9], [1, 6], [3, 11], [14, 20], [5, 9], [10, 16], [1, 13], [14, 18], [4, 20], [0, 19], [17, 18]], "edges2": [[21, 31], [9, 20], [2, 12], [13, 28], [5, 22], [16, 27], [1, 14], [0, 16], [6, 10], [7, 16], [21, 28], [13, 15], [2, 19], [7, 15], [26, 30], [20, 23], [3, 31], [12, 32], [10, 21], [4, 5], [5, 23], [5, 34], [17, 34], [2, 26], [3, 25], [22, 29], [15, 19], [9, 26], [11, 27], [4, 13], [19, 34], [4, 18], [3, 23], [11, 12], [1, 23], [26, 29], [1, 7], [18, 32], [1, 11], [9, 29], [1, 20], [14, 32], [20, 26], [13, 27], [19, 21], [11, 20], [24, 25], [27, 33], [15, 20], [6, 20], [24, 34], [26, 35], [6, 11], [12, 27], [21, 23], [15, 35], [19, 24], [30, 35], [8, 26], [17, 26], [0, 15], [27, 34], [10, 16], [22, 31], [32, 33], [13, 34], [0, 1], [8, 33], [8, 25], [16, 31], [18, 29], [12, 20], [11, 17], [16, 19], [20, 27], [24, 29], [15, 29], [3, 8], [0, 18], [2, 23], [22, 26], [12, 23], [10, 25], [5, 30], [5, 8], [12, 22], [34, 35], [8, 13], [0, 23], [3, 12], [3, 5], [18, 31], [0, 11], [14, 31], [12, 31], [5, 24], [1, 31], [6, 21], [3, 6], [8, 30], [10, 14], [15, 32], [3, 11], [14, 17], [33, 34], [12, 26], [15, 26], [1, 3], [18, 27], [18, 30], [10, 11], [13, 24], [4, 7], [18, 26], [0, 17], [4, 16], [16, 21], [6, 23], [9, 27], [15, 28], [20, 28], [1, 34], [29, 35], [12, 16], [18, 21], [13, 32], [9, 23], [6, 27], [4, 20], [3, 21], [10, 18], [13, 35], [4, 25], [20, 32], [24, 31], [14, 30], [4, 11], [15, 31], [2, 5], [12, 14], [4, 34], [11, 31], [6, 30], [4, 17], [19, 28], [9, 17], [5, 29], [11, 15], [10, 35], [10, 12], [3, 9], [16, 23], [12, 24], [6, 15], [2, 8], [23, 33], [10, 24], [9, 30], [27, 30], [2, 17], [20, 33], [14, 21], [14, 20], [4, 14], [22, 30], [9, 31], [22, 34], [15, 16], [15, 21], [10, 30], [3, 20], [10, 15], [23, 27], [0, 9], [13, 30], [2, 15], [2, 14], [0, 35], [25, 28], [3, 10], [17, 35], [17, 21], [18, 35], [8, 11], [3, 24], [5, 7], [23, 34], [11, 18], [23, 25], [12, 18], [14, 18], [16, 33], [11, 29], [9, 14], [13, 14], [1, 26], [24, 28], [6, 31], [7, 32], [23, 26], [25, 29], [21, 25], [16, 17], [3, 14], [15, 25], [12, 30], [28, 35], [23, 31], [1, 15], [19, 31], [22, 27], [19, 20], [0, 26], [19, 27], [19, 25], [27, 32], [19, 29], [20, 31], [23, 30], [1, 21], [7, 34], [13, 33], [4, 9], [6, 34], [3, 35], [7, 23], [28, 34], [21, 32], [21, 34], [2, 7], [8, 23], [6, 22], [26, 31], [16, 28], [6, 12], [4, 33], [15, 34], [2, 31], [5, 15], [30, 31], [9, 33], [21, 29], [4, 8], [13, 17], [8, 21], [18, 24], [2, 29], [6, 14], [22, 25], [7, 14], [1, 2], [1, 28], [2, 24], [19, 35], [11, 13], [25, 30], [29, 31], [20, 30], [23, 32], [4, 22], [24, 26], [2, 34], [9, 12], [1, 12], [22, 28], [26, 32], [12, 34], [5, 10], [2, 9], [3, 7], [12, 19], [13, 22], [0, 6], [14, 16], [11, 19], [9, 13], [9, 11], [4, 23], [3, 18], [25, 26], [0, 31], [13, 31], [7, 11]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l6-s2/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-rlve-subgraph-isomorphism-l6-s2/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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/optimize-ae-p24-de-bruijn-sharma-n5/environment/Dockerfile b/tasks/optimize-ae-p24-de-bruijn-sharma-n5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p24-de-bruijn-sharma-n5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==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-p24-de-bruijn-sharma-n5/environment/instance.json b/tasks/optimize-ae-p24-de-bruijn-sharma-n5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f449bc42e8ea64d9055b262841e9c06b10d930e9 --- /dev/null +++ b/tasks/optimize-ae-p24-de-bruijn-sharma-n5/environment/instance.json @@ -0,0 +1 @@ +{"n": 5, "direction": "maximize", "family": "ae_p24_de_bruijn_sharma", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p24-de-bruijn-sharma-n5/solution/solve.sh b/tasks/optimize-ae-p24-de-bruijn-sharma-n5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f8a12f0429d91bcfb0266ed45cb38005e3558ba1 --- /dev/null +++ b/tasks/optimize-ae-p24-de-bruijn-sharma-n5/solution/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.0, 0.0], [3.0, 0.0], [-2.0, 0.0], [-2.0, 0.0], [-2.0, 0.0]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p24-de-bruijn-sharma-n5/tests/check.py b/tasks/optimize-ae-p24-de-bruijn-sharma-n5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c56dd69deab535ec10e4eef53515f04c7dfea583 --- /dev/null +++ b/tasks/optimize-ae-p24-de-bruijn-sharma-n5/tests/check.py @@ -0,0 +1,29 @@ +"""de Bruijn-Sharma problem, x-intercept: maximise sum |xi|^4 / sum |z|^4 over degree-n polynomials with +zeros summing to 0 (xi = critical points). Each polynomial P excludes all (alpha, 0) with alpha below its ratio. + +Upstream (de_bruijn_sharma_problem.ipynb) rejected |sum z| > 1e-9 in absolute terms (not scale invariant) and +scored a region area; here the zero-sum condition is relative and the roots are re-centred before scoring. +Critical points come from numpy's companion-matrix eigenvalues (float64). +""" +import numpy as np + +from run import Invalid, float_matrix + + +def check(inst, ans): + n = inst["n"] + Z = np.array(float_matrix(ans.get("roots"), n, 2, "roots")) + z = Z[:, 0] + 1j * Z[:, 1] + if np.abs(z).max() > 1e3: + raise Invalid("roots must satisfy |z| <= 1000") + s1 = np.abs(z).sum() + if s1 < 1e-6: + raise Invalid("all roots are (nearly) zero") + if abs(z.sum()) > 1e-9 * s1: + raise Invalid("the roots must sum to zero (|sum z| <= 1e-9 * sum |z|)") + z = z - z.mean() + xi = np.roots(np.polyder(np.poly(z))) + if len(xi) != n - 1 or not np.all(np.isfinite(xi)): + raise Invalid("could not compute the critical points") + c4 = float(np.sum(np.abs(z) ** 4)) + return float(np.sum(np.abs(xi) ** 4)) / c4, {} diff --git a/tasks/optimize-ae-p24-de-bruijn-sharma-n5/tests/instance.json b/tasks/optimize-ae-p24-de-bruijn-sharma-n5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..704a703c4a6d9b7711e7bce7d33b46c2b8cd1b8d --- /dev/null +++ b/tasks/optimize-ae-p24-de-bruijn-sharma-n5/tests/instance.json @@ -0,0 +1 @@ +{"n": 5, "direction": "maximize", "best_known": 0.5428571428571428, "baseline": 0.35999999999999993, "family": "ae_p24_de_bruijn_sharma", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p24-de-bruijn-sharma-n5/tests/run.py b/tasks/optimize-ae-p24-de-bruijn-sharma-n5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p24-de-bruijn-sharma-n5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/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-p24-de-bruijn-sharma-n5/tests/test.sh b/tasks/optimize-ae-p24-de-bruijn-sharma-n5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p24-de-bruijn-sharma-n5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/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-p29-block-stacking-n5/environment/Dockerfile b/tasks/optimize-ae-p29-block-stacking-n5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p29-block-stacking-n5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==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-p29-block-stacking-n5/environment/instance.json b/tasks/optimize-ae-p29-block-stacking-n5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9776291cddd9984174f9dc4bb46597ed5a6cca4b --- /dev/null +++ b/tasks/optimize-ae-p29-block-stacking-n5/environment/instance.json @@ -0,0 +1 @@ +{"n": 5, "direction": "maximize", "family": "ae_p29_block_stacking", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p29-block-stacking-n5/solution/solve.sh b/tasks/optimize-ae-p29-block-stacking-n5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f32090253af1061f72951bd1e5c61913581b73dc --- /dev/null +++ b/tasks/optimize-ae-p29-block-stacking-n5/solution/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.0999999999, 0.224999999775, 0.391666666275, 0.641666666025, 1.141666665525]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p29-block-stacking-n5/tests/check.py b/tasks/optimize-ae-p29-block-stacking-n5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0936f9a12cbe14efd9acc0331b8d8feef14c7ad6 --- /dev/null +++ b/tasks/optimize-ae-p29-block-stacking-n5/tests/check.py @@ -0,0 +1,23 @@ +"""Block stacking (overhang) problem, closed form of the constraints; checked in exact rational arithmetic. + +Upstream (block_stacking_problem.ipynb) used a float tolerance of 100*eps on every constraint, which lets a +submission exceed the true optimum H_n/2 by accumulated slack; here all constraints are exact (non-strict). +""" +from fractions import Fraction + +from run import Invalid, float_list + + +def check(inst, ans): + n = inst["n"] + x = [Fraction(v) for v in float_list(ans.get("x"), n, "x")] + xs = [Fraction(0)] + x # x_0 = 0 + for i in range(n): + if xs[i + 1] < xs[i]: + raise Invalid(f"need x_{i} <= x_{i + 1}") + tail = Fraction(0) + for i in range(n - 1, -1, -1): # tail = x_{i+1} + ... + x_n + tail += xs[i + 1] + if tail > (n - i) * (xs[i] + Fraction(1, 2)): + raise Invalid(f"stability constraint violated at i = {i}") + return float(xs[n]), {} diff --git a/tasks/optimize-ae-p29-block-stacking-n5/tests/instance.json b/tasks/optimize-ae-p29-block-stacking-n5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..113bfa4cebf3b5bf478c9e27f90fd7f777fc29ae --- /dev/null +++ b/tasks/optimize-ae-p29-block-stacking-n5/tests/instance.json @@ -0,0 +1 @@ +{"n": 5, "direction": "maximize", "best_known": 1.1416666666666666, "baseline": 0.0, "family": "ae_p29_block_stacking", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p29-block-stacking-n5/tests/run.py b/tasks/optimize-ae-p29-block-stacking-n5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p29-block-stacking-n5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/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-p29-block-stacking-n5/tests/test.sh b/tasks/optimize-ae-p29-block-stacking-n5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p29-block-stacking-n5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/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-p60-no5-on-sphere-n9/environment/Dockerfile b/tasks/optimize-ae-p60-no5-on-sphere-n9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==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-p60-no5-on-sphere-n9/environment/instance.json b/tasks/optimize-ae-p60-no5-on-sphere-n9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3c51f21d2e4be2bbe4aa44e378d00f320d9275af --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n9/environment/instance.json @@ -0,0 +1 @@ +{"n": 9, "max_points": 36, "direction": "maximize", "family": "ae_p60_no5_on_sphere", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p60-no5-on-sphere-n9/solution/solve.sh b/tasks/optimize-ae-p60-no5-on-sphere-n9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c4255bcda1398ff5805eb90e6f7514ad8bc4c2d1 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n9/solution/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": [[3, 6, 8], [7, 1, 8], [1, 8, 0], [0, 2, 1], [0, 0, 1], [0, 1, 7], [7, 0, 5], [1, 3, 3], [1, 3, 7], [8, 6, 0], [6, 1, 2], [6, 3, 6], [7, 7, 0], [8, 5, 8], [2, 0, 8], [8, 3, 1], [4, 8, 7], [5, 4, 6], [5, 7, 2], [5, 2, 3], [1, 7, 4], [2, 1, 7], [0, 8, 6], [2, 2, 4], [3, 2, 0], [7, 8, 5]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p60-no5-on-sphere-n9/tests/check.py b/tasks/optimize-ae-p60-no5-on-sphere-n9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..535715270fb95983b4b3896cda93a8746da1a961 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n9/tests/check.py @@ -0,0 +1,53 @@ +"""No 5 points of an n x n x n grid subset on a common sphere or plane (AlphaEvolve problem 60). + +Exact int64 test: five points are co-spherical/co-planar iff det[x, y, z, x^2+y^2+z^2, 1] = 0, evaluated as the +4x4 determinant of differences (entries <= 3(n-1)^2, so |det| < 2^40). Upstream used float det + np.isclose.""" +import itertools + +import numpy as np + +from run import Invalid, int_list + + +def det4(m): + a, b, c, d = m[:, 0], m[:, 1], m[:, 2], m[:, 3] + + def det3(r0, r1, r2, i, j, k): + return (r0[:, i] * (r1[:, j] * r2[:, k] - r1[:, k] * r2[:, j]) + - r0[:, j] * (r1[:, i] * r2[:, k] - r1[:, k] * r2[:, i]) + + r0[:, k] * (r1[:, i] * r2[:, j] - r1[:, j] * r2[:, i])) + return (a[:, 0] * det3(b, c, d, 1, 2, 3) - a[:, 1] * det3(b, c, d, 0, 2, 3) + + a[:, 2] * det3(b, c, d, 0, 1, 3) - a[:, 3] * det3(b, c, d, 0, 1, 2)) + + +def lifted(p): + a = np.array(p, dtype=np.int64) + return np.concatenate([a, (a * a).sum(1, keepdims=True)], axis=1) + + +def bad_five(rows, combos): + """rows: (m, 4) lifted points; combos: (N, 5) index array. Returns mask of degenerate 5-sets.""" + base = rows[combos[:, 0]] + m = np.stack([rows[combos[:, i]] - base for i in range(1, 5)], axis=1) + return det4(m) == 0 + + +def check(inst, ans): + n = inst["n"] + pts = ans.get("points") + if not isinstance(pts, list) or not (1 <= len(pts) <= inst["max_points"]): + raise Invalid(f"points must be a list of 1..{inst['max_points']} [x, y, z] triples") + p = [tuple(int_list(q, 3, 0, n - 1, "point")) for q in pts] + if len(set(p)) != len(p): + raise Invalid("points must be distinct") + rows = lifted(p) + it = itertools.combinations(range(len(p)), 5) + while True: + chunk = np.array(list(itertools.islice(it, 200000)), dtype=np.int64) + if len(chunk) == 0: + break + bad = bad_five(rows, chunk) + if bad.any(): + q = [p[i] for i in chunk[np.argmax(bad)]] + raise Invalid(f"points {q} lie on a common sphere or plane") + return float(len(p)), {"size": len(p)} diff --git a/tasks/optimize-ae-p60-no5-on-sphere-n9/tests/instance.json b/tasks/optimize-ae-p60-no5-on-sphere-n9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ab536278740ae01fe4db7f53948fa1a1453e55f --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n9/tests/instance.json @@ -0,0 +1 @@ +{"n": 9, "max_points": 36, "direction": "maximize", "best_known": 26.0, "baseline": 19.0, "family": "ae_p60_no5_on_sphere", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p60-no5-on-sphere-n9/tests/run.py b/tasks/optimize-ae-p60-no5-on-sphere-n9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/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-p60-no5-on-sphere-n9/tests/test.sh b/tasks/optimize-ae-p60-no5-on-sphere-n9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/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-min-distance-ratio-2d-n16/environment/Dockerfile b/tasks/optimize-ea-min-distance-ratio-2d-n16/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ea-min-distance-ratio-2d-n16/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/optimize-ea-min-distance-ratio-2d-n16/environment/instance.json b/tasks/optimize-ea-min-distance-ratio-2d-n16/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4ef8e8796ffbf0bf0f5b2ef9a4f79831684f6634 --- /dev/null +++ b/tasks/optimize-ea-min-distance-ratio-2d-n16/environment/instance.json @@ -0,0 +1 @@ +{"n": 16, "direction": "minimize", "family": "ea_min_distance_ratio_16", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ea-min-distance-ratio-2d-n16/solution/solve.sh b/tasks/optimize-ea-min-distance-ratio-2d-n16/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7b3785a3c6ef341f82936556c09d84a2edf8873e --- /dev/null +++ b/tasks/optimize-ea-min-distance-ratio-2d-n16/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"vectors": [[-1.47975561, 0.98098357], [0.851848075446, 0.07211038457], [-0.734611602961, 1.647887168108], [0.151273184884, -1.789755757508], [-0.715592895553, 0.335960046209], [-1.545477112098, -0.918920851705], [1.733002311024, -0.451602182759], [-1.823092802796, 0.041771361583], [1.73113866218, 0.548396080844], [1.155331899164, 1.365981900229], [0.404917250668, -0.822458136148], [-0.580950766088, -0.654934245514], [0.168877531232, 0.802556300522], [0.253914996742, 1.798934055119], [-0.834594831872, -1.622231866873], [1.2637717, -1.33467785]]} +RLMATH_EOF diff --git a/tasks/optimize-ea-min-distance-ratio-2d-n16/tests/check.py b/tasks/optimize-ea-min-distance-ratio-2d-n16/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..85f09ce2dd1be5ced4e978559511eb501b10dffa --- /dev/null +++ b/tasks/optimize-ea-min-distance-ratio-2d-n16/tests/check.py @@ -0,0 +1,18 @@ +"""Minimize (max distance / min distance)^2 for 16 points in the plane (EinsteinArena min-distance-ratio-2d, MIT). + +Float objective, ported from the upstream verifier (distinctness: min distance > 1e-12).""" +import numpy as np + +from run import Invalid, float_matrix + + +def check(inst, ans): + n = inst["n"] + v = np.array(float_matrix(ans.get("vectors"), n, 2, "vectors")) + d = np.sqrt(((v[:, None, :] - v[None, :, :]) ** 2).sum(-1))[np.triu_indices(n, 1)] + if d.min() < 1e-12: + raise Invalid("points must be distinct (min distance < 1e-12)") + r = float((d.max() / d.min()) ** 2) + if not np.isfinite(r): + raise Invalid("non-finite ratio") + return r, {} diff --git a/tasks/optimize-ea-min-distance-ratio-2d-n16/tests/instance.json b/tasks/optimize-ea-min-distance-ratio-2d-n16/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6a59e067f646ccb67f16fcaaad3ab8cd366541ea --- /dev/null +++ b/tasks/optimize-ea-min-distance-ratio-2d-n16/tests/instance.json @@ -0,0 +1 @@ +{"n": 16, "direction": "minimize", "best_known": 12.889229907717521, "baseline": 17.999999999999996, "family": "ea_min_distance_ratio_16", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ea-min-distance-ratio-2d-n16/tests/run.py b/tasks/optimize-ea-min-distance-ratio-2d-n16/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ea-min-distance-ratio-2d-n16/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/optimize-ea-min-distance-ratio-2d-n16/tests/test.sh b/tasks/optimize-ea-min-distance-ratio-2d-n16/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ea-min-distance-ratio-2d-n16/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt