diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s3/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s3/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..56ad4bec395334d8a748614f9e4c117a2f45b7b4 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"N": 106, "t": 30, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s3/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f9848cb6502c7576b66a66141097812e4f679002 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [360, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 36, 36, 36, 37, 37, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39, 41, 41, 42, 43, 43, 46, 46, 46, 46, 47, 47, 49, 49, 49, 49, 49, 49, 49, 49, 53, 53, 58, 58, 58, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s3/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s3/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s3/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..56ad4bec395334d8a748614f9e4c117a2f45b7b4 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"N": 106, "t": 30, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s3/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s3/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s4/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s4/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a35a8bd1e2e18e095df773a460f65fe60770edeb --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"N": 110, "t": 31, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s4/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4cb7c92036cca2d95283e49f1daa944fdba430b --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [186, 31, 31, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 37, 37, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 43, 43, 46, 46, 46, 46, 47, 47, 53, 53, 58, 58, 58, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s4/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s4/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s4/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a35a8bd1e2e18e095df773a460f65fe60770edeb --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"N": 110, "t": 31, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s4/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s4/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l5-s7/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l5-s7/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2d15c3c523d7a19a4cf3ff0305318dc17a706a43 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"N": 3059, "t": 980, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l5-s7/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3fa9dbe3c182a0085173685b771e0a7122b1f079 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [9800, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 980, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 981, 982, 982, 982, 982, 982, 982, 983, 983, 983, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 984, 985, 985, 985, 985, 985, 985, 985, 985, 985, 985, 985, 985, 985, 985, 985, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 986, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 987, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 988, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 989, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 991, 991, 991, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 992, 993, 993, 993, 993, 993, 993, 993, 993, 993, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 994, 995, 995, 995, 995, 995, 995, 995, 995, 995, 995, 995, 995, 995, 995, 995, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 996, 997, 997, 997, 998, 998, 998, 998, 998, 998, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1002, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1004, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1005, 1006, 1006, 1006, 1006, 1006, 1006, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1007, 1009, 1009, 1009, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1011, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1013, 1013, 1013, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1014, 1015, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1016, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1017, 1018, 1018, 1018, 1018, 1018, 1018, 1019, 1019, 1019, 1021, 1021, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1022, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1027, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1028, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1031, 1031, 1033, 1033, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1035, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1037, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1038, 1039, 1039, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1041, 1042, 1042, 1042, 1042, 1042, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1043, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1044, 1046, 1046, 1046, 1046, 1046, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1047, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1049, 1049, 1051, 1051, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1052, 1053, 1055, 1055, 1055, 1055, 1055, 1055, 1055, 1055, 1055, 1055, 1055, 1055, 1055, 1055, 1057, 1057, 1057, 1057, 1057, 1057, 1057, 1057, 1057, 1057, 1057, 1057, 1057, 1057, 1057, 1057, 1057, 1057, 1057, 1057, 1059, 1059, 1059, 1059, 1059, 1059, 1059, 1059, 1061, 1061, 1063, 1063, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1068, 1069, 1069, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1070, 1073, 1074, 1074, 1074, 1074, 1074, 1074, 1074, 1074, 1074, 1074, 1074, 1074, 1074, 1074, 1074, 1074, 1074, 1076, 1076, 1076, 1076, 1076, 1076, 1076, 1076, 1076, 1076, 1076, 1077, 1077, 1077, 1077, 1077, 1077, 1077, 1077, 1082, 1082, 1082, 1082, 1082, 1084, 1084, 1084, 1084, 1084, 1084, 1084, 1084, 1084, 1084, 1084, 1086, 1086, 1086, 1086, 1086, 1086, 1086, 1086, 1086, 1086, 1086, 1086, 1086, 1086, 1086, 1086, 1087, 1087, 1091, 1091, 1093, 1093, 1094, 1094, 1094, 1094, 1094, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1096, 1097, 1097, 1099, 1099, 1099, 1099, 1099, 1099, 1099, 1099, 1099, 1099, 1099, 1099, 1099, 1099, 1099, 1099, 1099, 1099, 1099, 1101, 1101, 1101, 1101, 1101, 1101, 1101, 1101, 1103, 1103, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1108, 1109, 1109, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1112, 1114, 1114, 1114, 1114, 1114, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1115, 1117, 1117, 1119, 1119, 1119, 1119, 1119, 1119, 1119, 1119, 1123, 1123, 1124, 1124, 1124, 1124, 1124, 1124, 1124, 1124, 1124, 1124, 1126, 1126, 1126, 1126, 1126, 1129, 1129, 1132, 1132, 1132, 1132, 1132, 1132, 1132, 1132, 1132, 1132, 1135, 1135, 1135, 1135, 1135, 1135, 1135, 1135, 1135, 1135, 1135, 1135, 1135, 1137, 1137, 1137, 1137, 1137, 1137, 1137, 1137, 1138, 1138, 1138, 1138, 1138, 1141, 1141, 1141, 1141, 1141, 1141, 1141, 1141, 1141, 1141, 1141, 1141, 1141, 1141, 1141, 1141, 1141, 1141, 1142, 1142, 1142, 1142, 1142, 1145, 1145, 1145, 1145, 1145, 1145, 1145, 1145, 1145, 1145, 1145, 1145, 1145, 1146, 1146, 1146, 1146, 1146, 1146, 1146, 1146, 1146, 1146, 1146, 1146, 1146, 1146, 1146, 1146, 1149, 1149, 1149, 1149, 1149, 1149, 1149, 1151, 1151, 1153, 1153, 1154, 1154, 1154, 1154, 1154, 1157, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1158, 1163, 1163, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1165, 1167, 1167, 1167, 1167, 1167, 1167, 1167, 1171, 1171, 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1172, 1174, 1174, 1174, 1174, 1174, 1181, 1181, 1185, 1186, 1186, 1186, 1186, 1186, 1187, 1187, 1191, 1191, 1191, 1191, 1191, 1191, 1191, 1193, 1193, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195, 1198, 1198, 1198, 1198, 1198, 1201, 1201, 1202, 1202, 1202, 1202, 1202, 1203, 1203, 1203, 1203, 1203, 1203, 1203, 1205, 1205, 1205, 1205, 1205, 1205, 1205, 1205, 1205, 1205, 1205, 1205, 1213, 1213, 1214, 1214, 1214, 1214, 1214, 1217, 1217, 1223, 1223, 1226, 1226, 1226, 1226, 1227, 1227, 1227, 1227, 1227, 1227, 1227, 1228, 1228, 1228, 1228, 1228, 1228, 1228, 1228, 1228, 1229, 1229, 1231, 1231, 1234, 1234, 1234, 1234, 1237, 1237, 1238, 1238, 1238, 1238, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1244, 1249, 1249, 1252, 1252, 1252, 1252, 1252, 1252, 1252, 1252, 1252, 1257, 1257, 1257, 1257, 1257, 1257, 1257, 1259, 1259, 1262, 1262, 1262, 1262, 1263, 1263, 1263, 1263, 1263, 1263, 1263, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1277, 1277, 1279, 1279, 1282, 1282, 1282, 1282, 1283, 1283, 1286, 1286, 1286, 1286, 1289, 1289, 1291, 1291, 1293, 1293, 1293, 1293, 1293, 1293, 1293, 1294, 1294, 1294, 1294, 1297, 1297, 1299, 1299, 1299, 1299, 1299, 1299, 1299, 1301, 1301, 1303, 1303, 1306, 1306, 1306, 1306, 1307, 1307, 1317, 1317, 1317, 1317, 1317, 1317, 1318, 1318, 1318, 1318, 1319, 1319, 1321, 1321, 1322, 1322, 1322, 1322, 1327, 1327, 1329, 1329, 1329, 1329, 1329, 1329, 1346, 1346, 1346, 1346, 1347, 1347, 1347, 1347, 1347, 1347, 1354, 1354, 1354, 1354, 1361, 1361, 1366, 1366, 1366, 1366, 1367, 1367, 1371, 1371, 1371, 1371, 1371, 1371, 1373, 1373, 1381, 1381, 1382, 1382, 1382, 1382, 1383, 1383, 1383, 1383, 1383, 1383, 1389, 1389, 1389, 1389, 1389, 1389, 1399, 1399, 1401, 1401, 1401, 1401, 1401, 1401, 1402, 1402, 1402, 1402, 1409, 1409, 1418, 1418, 1418, 1418, 1423, 1423, 1427, 1427, 1429, 1429, 1433, 1433, 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, 1466, 1466, 1466, 1466, 1471, 1471, 1478, 1478, 1478, 1478, 1481, 1481, 1483, 1483, 1486, 1486, 1486, 1486, 1487, 1487, 1489, 1489, 1493, 1493, 1499, 1499, 1502, 1502, 1502, 1502, 1511, 1511, 1514, 1514, 1514, 1514, 1522, 1522, 1522, 1522, 1523, 1523, 1531, 1538, 1538, 1538, 1543, 1546, 1546, 1546, 1549, 1553, 1559, 1567, 1571, 1574, 1574, 1574, 1579, 1583, 1594, 1594, 1594, 1597, 1601, 1607, 1609, 1613, 1618, 1618, 1618, 1619, 1621, 1622, 1622, 1622, 1627, 1637, 1642, 1642, 1642, 1646, 1646, 1646, 1654, 1654, 1654, 1657, 1658, 1658, 1658, 1663, 1667, 1669, 1678, 1678, 1678, 1693, 1697, 1699, 1706, 1706, 1706, 1709, 1714, 1714, 1714, 1718, 1718, 1718, 1721, 1723, 1726, 1726, 1726, 1733, 1741, 1747, 1753, 1754, 1754, 1754, 1759, 1762, 1762, 1762, 1766, 1766, 1766, 1774, 1774, 1774, 1777, 1783, 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, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 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]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l5-s7/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l5-s7/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l5-s7/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2d15c3c523d7a19a4cf3ff0305318dc17a706a43 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"N": 3059, "t": 980, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l5-s7/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l5-s7/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s2/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s2/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..70925007a9c97800c3eeae6cdcf577fd54f2c569 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"N": 6230, "t": 2021, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s2/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2c8c76c0463f1551596c55c3837508caaf360db6 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [94987, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2022, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2024, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2025, 2026, 2026, 2026, 2026, 2026, 2026, 2027, 2027, 2027, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2028, 2029, 2029, 2029, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2030, 2031, 2031, 2031, 2031, 2031, 2031, 2031, 2031, 2031, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2033, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2034, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2035, 2036, 2036, 2036, 2036, 2036, 2036, 2036, 2036, 2036, 2036, 2036, 2036, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2037, 2038, 2038, 2038, 2038, 2038, 2038, 2039, 2039, 2039, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2041, 2042, 2042, 2042, 2042, 2042, 2042, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2043, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2044, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2045, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2046, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2049, 2049, 2049, 2049, 2049, 2049, 2049, 2049, 2049, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2051, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2052, 2053, 2053, 2053, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2054, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2055, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2056, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2058, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2059, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2060, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2061, 2062, 2062, 2062, 2062, 2062, 2062, 2063, 2063, 2063, 2064, 2064, 2064, 2064, 2064, 2064, 2064, 2064, 2064, 2064, 2064, 2064, 2064, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2065, 2066, 2066, 2066, 2066, 2066, 2066, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2067, 2069, 2069, 2069, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2071, 2072, 2073, 2073, 2073, 2073, 2073, 2073, 2073, 2073, 2073, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2074, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2075, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2076, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2077, 2078, 2078, 2078, 2078, 2078, 2079, 2081, 2081, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2082, 2083, 2083, 2084, 2084, 2084, 2084, 2084, 2084, 2084, 2084, 2084, 2084, 2084, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2085, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2086, 2087, 2087, 2088, 2089, 2089, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091, 2092, 2092, 2092, 2092, 2092, 2092, 2092, 2092, 2092, 2092, 2092, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2094, 2095, 2095, 2095, 2095, 2095, 2095, 2095, 2095, 2095, 2095, 2095, 2095, 2095, 2095, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2096, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2097, 2098, 2098, 2098, 2098, 2098, 2099, 2099, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2101, 2102, 2102, 2102, 2102, 2102, 2103, 2103, 2103, 2103, 2103, 2103, 2103, 2103, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2104, 2105, 2105, 2105, 2105, 2105, 2105, 2105, 2105, 2105, 2105, 2105, 2105, 2105, 2105, 2107, 2108, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2110, 2111, 2111, 2113, 2113, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2114, 2115, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2118, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2119, 2120, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2121, 2122, 2122, 2122, 2122, 2122, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2126, 2126, 2126, 2126, 2126, 2127, 2127, 2127, 2127, 2127, 2127, 2127, 2127, 2129, 2129, 2131, 2131, 2137, 2137, 2138, 2138, 2138, 2138, 2138, 2141, 2141, 2143, 2143, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2148, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2149, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2151, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2152, 2153, 2153, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2155, 2155, 2155, 2155, 2155, 2155, 2155, 2155, 2155, 2155, 2155, 2155, 2155, 2155, 2157, 2157, 2157, 2157, 2157, 2157, 2157, 2157, 2161, 2161, 2163, 2163, 2164, 2164, 2164, 2164, 2164, 2164, 2164, 2164, 2164, 2164, 2164, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2168, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2169, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2171, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2172, 2174, 2174, 2174, 2174, 2174, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2177, 2179, 2179, 2181, 2181, 2181, 2181, 2181, 2181, 2181, 2181, 2182, 2182, 2182, 2182, 2182, 2186, 2186, 2186, 2186, 2186, 2188, 2188, 2188, 2188, 2188, 2188, 2188, 2188, 2188, 2188, 2188, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2189, 2191, 2191, 2191, 2191, 2191, 2191, 2191, 2191, 2191, 2191, 2191, 2191, 2191, 2191, 2191, 2191, 2191, 2191, 2191, 2194, 2194, 2194, 2194, 2194, 2195, 2195, 2195, 2195, 2195, 2195, 2195, 2195, 2195, 2195, 2195, 2195, 2195, 2195, 2197, 2199, 2199, 2199, 2199, 2199, 2199, 2199, 2199, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2202, 2203, 2203, 2206, 2206, 2206, 2206, 2206, 2207, 2207, 2213, 2213, 2215, 2215, 2215, 2215, 2215, 2215, 2215, 2215, 2215, 2215, 2215, 2215, 2215, 2215, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2216, 2217, 2217, 2217, 2217, 2217, 2217, 2217, 2217, 2218, 2218, 2218, 2218, 2218, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2219, 2221, 2221, 2228, 2228, 2228, 2228, 2228, 2228, 2228, 2228, 2228, 2228, 2228, 2229, 2229, 2229, 2229, 2229, 2229, 2229, 2229, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2230, 2234, 2234, 2234, 2234, 2234, 2237, 2237, 2238, 2238, 2238, 2238, 2238, 2238, 2238, 2238, 2238, 2238, 2238, 2238, 2238, 2238, 2238, 2238, 2239, 2239, 2243, 2243, 2245, 2245, 2245, 2245, 2245, 2245, 2245, 2245, 2245, 2245, 2245, 2245, 2245, 2246, 2246, 2246, 2246, 2246, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2248, 2251, 2251, 2252, 2252, 2252, 2252, 2252, 2252, 2252, 2252, 2252, 2252, 2252, 2253, 2253, 2253, 2253, 2253, 2253, 2253, 2253, 2258, 2258, 2258, 2258, 2258, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2259, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2264, 2267, 2267, 2269, 2269, 2271, 2271, 2271, 2271, 2271, 2271, 2271, 2271, 2273, 2273, 2274, 2274, 2274, 2274, 2274, 2274, 2274, 2274, 2274, 2274, 2274, 2274, 2274, 2274, 2274, 2274, 2276, 2276, 2276, 2276, 2276, 2276, 2276, 2276, 2276, 2276, 2281, 2281, 2283, 2283, 2283, 2283, 2283, 2283, 2283, 2283, 2284, 2284, 2284, 2284, 2284, 2284, 2284, 2284, 2284, 2284, 2285, 2285, 2285, 2285, 2285, 2285, 2285, 2285, 2285, 2285, 2285, 2285, 2285, 2287, 2287, 2293, 2293, 2297, 2297, 2298, 2298, 2298, 2298, 2298, 2298, 2298, 2298, 2298, 2298, 2298, 2298, 2298, 2298, 2298, 2302, 2302, 2302, 2302, 2302, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2306, 2306, 2306, 2306, 2306, 2307, 2307, 2307, 2307, 2307, 2307, 2307, 2307, 2308, 2308, 2308, 2308, 2308, 2308, 2308, 2308, 2308, 2308, 2309, 2309, 2311, 2311, 2315, 2315, 2315, 2315, 2315, 2315, 2315, 2315, 2315, 2315, 2315, 2315, 2315, 2317, 2317, 2317, 2317, 2317, 2317, 2317, 2317, 2317, 2317, 2317, 2317, 2317, 2317, 2317, 2317, 2317, 2317, 2319, 2319, 2319, 2319, 2319, 2319, 2319, 2319, 2326, 2326, 2326, 2326, 2326, 2333, 2333, 2334, 2334, 2334, 2334, 2334, 2334, 2334, 2334, 2334, 2334, 2334, 2334, 2334, 2334, 2334, 2334, 2335, 2335, 2335, 2335, 2335, 2335, 2335, 2335, 2335, 2335, 2335, 2335, 2335, 2339, 2339, 2341, 2341, 2342, 2342, 2342, 2342, 2342, 2347, 2347, 2348, 2348, 2348, 2348, 2348, 2348, 2348, 2348, 2348, 2348, 2351, 2351, 2357, 2357, 2361, 2361, 2361, 2361, 2361, 2361, 2361, 2362, 2362, 2362, 2362, 2362, 2371, 2371, 2372, 2372, 2372, 2372, 2372, 2372, 2372, 2372, 2372, 2372, 2374, 2374, 2374, 2374, 2374, 2377, 2377, 2381, 2381, 2382, 2382, 2382, 2382, 2382, 2382, 2382, 2382, 2382, 2382, 2382, 2382, 2382, 2382, 2382, 2383, 2383, 2386, 2386, 2386, 2386, 2386, 2389, 2389, 2391, 2391, 2391, 2391, 2391, 2391, 2391, 2393, 2393, 2395, 2395, 2395, 2395, 2395, 2395, 2395, 2395, 2395, 2395, 2395, 2395, 2395, 2396, 2396, 2396, 2396, 2396, 2396, 2396, 2396, 2396, 2396, 2399, 2399, 2402, 2402, 2402, 2402, 2402, 2404, 2404, 2404, 2404, 2404, 2404, 2404, 2404, 2404, 2404, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2411, 2411, 2417, 2417, 2423, 2423, 2426, 2426, 2426, 2426, 2426, 2427, 2427, 2427, 2427, 2427, 2427, 2427, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2434, 2434, 2434, 2434, 2434, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2437, 2437, 2441, 2441, 2446, 2446, 2446, 2446, 2446, 2447, 2447, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2458, 2458, 2458, 2458, 2458, 2459, 2459, 2462, 2462, 2462, 2462, 2462, 2463, 2463, 2463, 2463, 2463, 2463, 2463, 2467, 2467, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2469, 2469, 2469, 2469, 2469, 2469, 2469, 2473, 2473, 2474, 2474, 2474, 2474, 2474, 2476, 2476, 2476, 2476, 2476, 2476, 2476, 2476, 2476, 2476, 2477, 2477, 2481, 2481, 2481, 2481, 2481, 2481, 2481, 2487, 2487, 2487, 2487, 2487, 2487, 2487, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2498, 2498, 2498, 2498, 2503, 2503, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2517, 2517, 2517, 2517, 2517, 2517, 2517, 2518, 2518, 2518, 2518, 2521, 2521, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2531, 2531, 2537, 2539, 2539, 2543, 2543, 2549, 2549, 2551, 2551, 2554, 2554, 2554, 2554, 2557, 2557, 2558, 2558, 2558, 2558, 2559, 2559, 2559, 2559, 2559, 2559, 2559, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2566, 2566, 2566, 2566, 2571, 2571, 2571, 2571, 2571, 2571, 2571, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2577, 2577, 2577, 2577, 2577, 2577, 2577, 2578, 2578, 2578, 2578, 2579, 2579, 2582, 2582, 2582, 2582, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2589, 2589, 2589, 2589, 2589, 2589, 2589, 2591, 2591, 2593, 2593, 2594, 2594, 2594, 2594, 2602, 2602, 2602, 2602, 2606, 2606, 2606, 2606, 2609, 2609, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2614, 2614, 2614, 2614, 2617, 2617, 2621, 2621, 2631, 2631, 2631, 2631, 2631, 2631, 2631, 2633, 2633, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2638, 2638, 2638, 2638, 2642, 2642, 2642, 2642, 2643, 2643, 2643, 2643, 2643, 2643, 2643, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2647, 2647, 2649, 2649, 2649, 2649, 2649, 2649, 2649, 2654, 2654, 2654, 2654, 2657, 2657, 2659, 2659, 2661, 2661, 2661, 2661, 2661, 2661, 2661, 2663, 2663, 2671, 2671, 2677, 2677, 2681, 2683, 2683, 2687, 2687, 2689, 2689, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2693, 2693, 2699, 2699, 2707, 2707, 2711, 2711, 2713, 2713, 2719, 2719, 2721, 2721, 2721, 2721, 2721, 2721, 2722, 2722, 2722, 2722, 2729, 2729, 2731, 2731, 2733, 2733, 2733, 2733, 2733, 2733, 2734, 2734, 2734, 2734, 2741, 2741, 2746, 2746, 2746, 2746, 2749, 2749, 2753, 2753, 2757, 2757, 2757, 2757, 2757, 2757, 2762, 2762, 2762, 2762, 2767, 2767, 2777, 2777, 2787, 2787, 2787, 2787, 2787, 2787, 2789, 2789, 2791, 2791, 2797, 2797, 2798, 2798, 2798, 2798, 2801, 2801, 2803, 2803, 2811, 2811, 2811, 2811, 2811, 2811, 2818, 2818, 2818, 2818, 2819, 2819, 2823, 2823, 2823, 2823, 2823, 2823, 2833, 2833, 2837, 2837, 2841, 2841, 2841, 2841, 2841, 2841, 2843, 2843, 2846, 2846, 2846, 2846, 2851, 2851, 2854, 2854, 2854, 2854, 2857, 2857, 2858, 2858, 2858, 2858, 2859, 2859, 2859, 2859, 2859, 2859, 2861, 2861, 2866, 2866, 2866, 2866, 2878, 2878, 2878, 2878, 2879, 2879, 2887, 2887, 2894, 2894, 2894, 2894, 2897, 2897, 2901, 2901, 2901, 2901, 2901, 2901, 2902, 2902, 2902, 2902, 2903, 2903, 2906, 2906, 2906, 2906, 2909, 2909, 2913, 2913, 2913, 2913, 2913, 2913, 2917, 2917, 2918, 2918, 2918, 2918, 2927, 2927, 2931, 2931, 2931, 2931, 2931, 2931, 2939, 2939, 2942, 2942, 2942, 2942, 2949, 2949, 2949, 2949, 2949, 2949, 2953, 2953, 2957, 2957, 2962, 2962, 2962, 2962, 2963, 2963, 2966, 2966, 2966, 2966, 2969, 2969, 2971, 2971, 2973, 2973, 2973, 2973, 2973, 2973, 2974, 2974, 2974, 2974, 2978, 2978, 2978, 2978, 2986, 2986, 2986, 2986, 2991, 2991, 2991, 2991, 2991, 2991, 2998, 2998, 2998, 2998, 2999, 2999, 3001, 3001, 3011, 3011, 3019, 3019, 3022, 3022, 3022, 3022, 3023, 3023, 3027, 3027, 3027, 3027, 3027, 3027, 3037, 3037, 3041, 3041, 3046, 3046, 3046, 3046, 3049, 3049, 3061, 3061, 3062, 3062, 3062, 3062, 3067, 3067, 3079, 3079, 3083, 3083, 3086, 3086, 3086, 3086, 3089, 3089, 3098, 3098, 3098, 3098, 3106, 3106, 3106, 3106, 3109, 3109, 3118, 3118, 3118, 3119, 3121, 3134, 3134, 3134, 3137, 3142, 3142, 3142, 3158, 3158, 3158, 3163, 3166, 3166, 3166, 3167, 3169, 3181, 3187, 3191, 3194, 3194, 3194, 3202, 3202, 3202, 3203, 3209, 3214, 3214, 3214, 3217, 3218, 3218, 3218, 3221, 3226, 3226, 3226, 3229, 3238, 3238, 3238, 3242, 3242, 3242, 3251, 3253, 3254, 3254, 3254, 3257, 3259, 3271, 3274, 3274, 3274, 3299, 3301, 3307, 3313, 3314, 3314, 3314, 3319, 3323, 3326, 3326, 3326, 3329, 3331, 3334, 3334, 3334, 3338, 3338, 3338, 3343, 3347, 3359, 3361, 3371, 3373, 3386, 3386, 3386, 3389, 3391, 3394, 3394, 3394, 3398, 3398, 3398, 3407, 3413, 3418, 3418, 3418, 3433, 3442, 3442, 3442, 3446, 3446, 3446, 3449, 3457, 3461, 3463, 3466, 3466, 3466, 3467, 3469, 3482, 3482, 3482, 3491, 3494, 3494, 3494, 3499, 3506, 3506, 3506, 3511, 3517, 3518, 3518, 3518, 3527, 3529, 3533, 3539, 3541, 3547, 3554, 3554, 3554, 3557, 3559, 3566, 3566, 3566, 3571, 3574, 3574, 3574, 3578, 3578, 3578, 3581, 3583, 3593, 3602, 3602, 3602, 3607, 3613, 3617, 3622, 3622, 3622, 3623, 3631, 3637, 3643, 3646, 3646, 3646, 3659, 3662, 3662, 3662, 3671, 3673, 3677, 3691, 3694, 3694, 3694, 3697, 3701, 3709, 3719, 3722, 3722, 3722, 3727, 3733, 3734, 3734, 3734, 3739, 3742, 3742, 3742, 3746, 3746, 3746, 3754, 3754, 3754, 3758, 3758, 3758, 3761, 3767, 3769, 3778, 3778, 3778, 3779, 3793, 3797, 3802, 3802, 3802, 3803, 3814, 3814, 3814, 3821, 3823, 3826, 3826, 3826, 3833, 3847, 3851, 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, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 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]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s2/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s2/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-s2/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..70925007a9c97800c3eeae6cdcf577fd54f2c569 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"N": 6230, "t": 2021, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s2/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s2/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p52-erdos-squarefree-l1-s4/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l1-s4/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..960a74d3d868c28944cc23f1a355e8ef54063fb1 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"N": 54, "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-s4/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..64edc60b2777c8ab206ef2453c453061679e49f0 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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' +{"A": [7, 32]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l1-s4/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l1-s4/tests/check.py @@ -0,0 +1,38 @@ +"""Erdos squarefree problem (AlphaEvolve problem 52): A in [1, N], |A| >= t, ab+1 NOT squarefree for all a, b in A +(a = b included). The repo's problem page says "square-free"; the notebook and the Erdos problem ask for +"never squarefree", which is what we check. Exact: for every pair we find a prime p with p^2 | ab+1.""" +import numpy as np + +from run import Invalid, int_list + + +def _primes(n): + s = np.ones(n + 1, dtype=bool) + s[:2] = False + for i in range(2, int(n ** .5) + 1): + if s[i]: + s[i * i::i] = False + return np.nonzero(s)[0] + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + a = ans.get("A") + if not isinstance(a, list) or not (t <= len(a) <= 2 * t + 20): + raise Invalid(f"A must be a list of {t}..{2 * t + 20} integers") + int_list(a, None, 1, n, "A") + if len(set(a)) != len(a): + raise Invalid("A must consist of distinct integers") + x = np.array(sorted(a), dtype=np.int64) + iu, ju = np.triu_indices(len(x)) + va, vb = x[iu], x[ju] + left = np.ones(len(iu), dtype=bool) # pairs without a square divisor found yet + for p in _primes(int((n * n + 1) ** .5) + 1): + q = int(p) * int(p) + idx = np.nonzero(left)[0] + hit = ((va[idx] % q) * (vb[idx] % q) + 1) % q == 0 + left[idx[hit]] = False + if not left.any(): + return None, {"size": len(a)} + k = int(np.nonzero(left)[0][0]) + raise Invalid(f"{int(va[k])}*{int(vb[k])}+1 = {int(va[k]) * int(vb[k]) + 1} is squarefree") diff --git a/tasks/construct-ae-p52-erdos-squarefree-l1-s4/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..960a74d3d868c28944cc23f1a355e8ef54063fb1 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"N": 54, "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-s4/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l1-s4/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l2-s1/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s1/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..00760d94b202f144604565e7dc4930ce89f11187 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"N": 124, "t": 5, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s1/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b6c050b7f1a69fce328d246ba66a8611e0c1111e --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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' +{"A": [7, 32, 57, 82, 107]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s1/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s1/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-s1/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..00760d94b202f144604565e7dc4930ce89f11187 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"N": 124, "t": 5, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s1/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s1/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s8/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s8/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..84d0415137ece4c4f44758ea7a688fe697ca106d --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"N": 207, "t": 9, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s8/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..33f0b9274cfe2a3c82f15e9f907733e9551af897 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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' +{"A": [7, 32, 57, 82, 107, 132, 157, 182, 207]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s8/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s8/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-s8/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..84d0415137ece4c4f44758ea7a688fe697ca106d --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"N": 207, "t": 9, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s8/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s8/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/environment/Dockerfile b/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/environment/instance.json b/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..42f09e9808ccb7e224be04f87b669a6fe11767d3 --- /dev/null +++ b/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 9, "max_tiles": 12, "family": "ae_p65_imo2025_p6_tiling", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/solution/solve.sh b/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fb58bceba7e9a3bb727c133976204fb519d203ea --- /dev/null +++ b/tasks/construct-ae-p65-imo2025-p6-tiling-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' +{"tiles": [[0, 0, 3, 2], [0, 3, 1, 6], [1, 2, 3, 3], [1, 6, 1, 3], [2, 5, 3, 3], [3, 0, 3, 1], [3, 8, 6, 1], [4, 1, 3, 3], [5, 4, 3, 3], [6, 7, 3, 1], [7, 0, 2, 3], [8, 3, 1, 3]]} +RLMATH_EOF diff --git a/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/tests/check.py b/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..401de49cfa895e6f1c47b996fa5e8bdc8fc609e4 --- /dev/null +++ b/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/tests/check.py @@ -0,0 +1,24 @@ +"""IMO 2025 Problem 6 variant (AlphaEvolve problem 65): at most T rectangular tiles on an n x n grid, no overlaps, +every row and every column has exactly one uncovered unit square.""" +import numpy as np + +from run import Invalid, int_list + + +def check(inst, ans): + n, cap = inst["n"], inst["max_tiles"] + tiles = ans.get("tiles") + if not isinstance(tiles, list) or not (1 <= len(tiles) <= cap): + raise Invalid(f"tiles must be a list of 1..{cap} [row, col, height, width] entries") + cover = np.zeros((n, n), dtype=np.int32) + for t in tiles: + r, c, h, w = int_list(t, 4, 0, n, "tile") + if h < 1 or w < 1 or r + h > n or c + w > n: + raise Invalid(f"tile {t} is empty or leaves the grid") + cover[r:r + h, c:c + w] += 1 + if cover.max() > 1: + raise Invalid("tiles overlap") + free = cover == 0 + if not (free.sum(axis=1) == 1).all() or not (free.sum(axis=0) == 1).all(): + raise Invalid("some row or column does not have exactly one uncovered square") + return None, {"tiles": len(tiles)} diff --git a/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/tests/instance.json b/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..42f09e9808ccb7e224be04f87b669a6fe11767d3 --- /dev/null +++ b/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 9, "max_tiles": 12, "family": "ae_p65_imo2025_p6_tiling", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/tests/run.py b/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/tests/test.sh b/tasks/construct-ae-p65-imo2025-p6-tiling-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p65-imo2025-p6-tiling-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-all-interval-l1-s1/environment/Dockerfile b/tasks/construct-mc-all-interval-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-all-interval-l1-s1/environment/instance.json b/tasks/construct-mc-all-interval-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f9a1095199b5b913d326c0c19329b93273d37211 --- /dev/null +++ b/tasks/construct-mc-all-interval-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 4, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l1-s1/solution/solve.sh b/tasks/construct-mc-all-interval-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b90d403c3ad5b2848eb0e461b9dbec719ebb3b57 --- /dev/null +++ b/tasks/construct-mc-all-interval-l1-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [0, 3, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l1-s1/tests/check.py b/tasks/construct-mc-all-interval-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l1-s1/tests/check.py @@ -0,0 +1,17 @@ +"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + d = [abs(x[i + 1] - x[i]) for i in range(n - 1)] + if sorted(d) != list(range(1, n)): + raise Invalid("consecutive differences are not a permutation of 1..n-1") + seqs = {"x": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-all-interval-l1-s1/tests/instance.json b/tasks/construct-mc-all-interval-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f9a1095199b5b913d326c0c19329b93273d37211 --- /dev/null +++ b/tasks/construct-mc-all-interval-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 4, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l1-s1/tests/run.py b/tasks/construct-mc-all-interval-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-all-interval-l1-s1/tests/test.sh b/tasks/construct-mc-all-interval-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-all-interval-l2-s3/environment/Dockerfile b/tasks/construct-mc-all-interval-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-all-interval-l2-s3/environment/instance.json b/tasks/construct-mc-all-interval-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1e500b61bb9b4f4f1595d13f8eefd245694b7b67 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 9, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l2-s3/solution/solve.sh b/tasks/construct-mc-all-interval-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..da0770f82c348ae7ebc37ae6f8e0007241e109bf --- /dev/null +++ b/tasks/construct-mc-all-interval-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": [0, 8, 1, 7, 2, 6, 3, 5, 4]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l2-s3/tests/check.py b/tasks/construct-mc-all-interval-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s3/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-s3/tests/instance.json b/tasks/construct-mc-all-interval-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1e500b61bb9b4f4f1595d13f8eefd245694b7b67 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 9, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l2-s3/tests/run.py b/tasks/construct-mc-all-interval-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-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-all-interval-l2-s3/tests/test.sh b/tasks/construct-mc-all-interval-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-all-interval-l6-s2/environment/Dockerfile b/tasks/construct-mc-all-interval-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-all-interval-l6-s2/environment/instance.json b/tasks/construct-mc-all-interval-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aa32179a5922bf74253a5c317c3ef42e407210d7 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 104, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s2/solution/solve.sh b/tasks/construct-mc-all-interval-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..31b7545a9be91acba9c0f0fec9e88f7b1d229e8f --- /dev/null +++ b/tasks/construct-mc-all-interval-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' +{"x": [0, 103, 1, 102, 2, 101, 3, 100, 4, 99, 5, 98, 6, 97, 7, 96, 8, 95, 9, 94, 10, 93, 11, 92, 12, 91, 13, 90, 14, 89, 15, 88, 16, 87, 17, 86, 18, 85, 19, 84, 20, 83, 21, 82, 22, 81, 23, 80, 24, 79, 25, 78, 26, 77, 27, 76, 28, 75, 29, 74, 30, 73, 31, 72, 32, 71, 33, 70, 34, 69, 35, 68, 36, 67, 37, 66, 38, 65, 39, 64, 40, 63, 41, 62, 42, 61, 43, 60, 44, 59, 45, 58, 46, 57, 47, 56, 48, 55, 49, 54, 50, 53, 51, 52]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l6-s2/tests/check.py b/tasks/construct-mc-all-interval-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s2/tests/check.py @@ -0,0 +1,17 @@ +"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + d = [abs(x[i + 1] - x[i]) for i in range(n - 1)] + if sorted(d) != list(range(1, n)): + raise Invalid("consecutive differences are not a permutation of 1..n-1") + seqs = {"x": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-all-interval-l6-s2/tests/instance.json b/tasks/construct-mc-all-interval-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aa32179a5922bf74253a5c317c3ef42e407210d7 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 104, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s2/tests/run.py b/tasks/construct-mc-all-interval-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-all-interval-l6-s2/tests/test.sh b/tasks/construct-mc-all-interval-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-all-interval-l6-s5/environment/Dockerfile b/tasks/construct-mc-all-interval-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-all-interval-l6-s5/environment/instance.json b/tasks/construct-mc-all-interval-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d35ffa759e80b8d4804f11973285b1e352aa27bd --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 128, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s5/solution/solve.sh b/tasks/construct-mc-all-interval-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5d02e363f467eed9ec0b6ff94aa0bdc7540a3444 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [0, 127, 1, 126, 2, 125, 3, 124, 4, 123, 5, 122, 6, 121, 7, 120, 8, 119, 9, 118, 10, 117, 11, 116, 12, 115, 13, 114, 14, 113, 15, 112, 16, 111, 17, 110, 18, 109, 19, 108, 20, 107, 21, 106, 22, 105, 23, 104, 24, 103, 25, 102, 26, 101, 27, 100, 28, 99, 29, 98, 30, 97, 31, 96, 32, 95, 33, 94, 34, 93, 35, 92, 36, 91, 37, 90, 38, 89, 39, 88, 40, 87, 41, 86, 42, 85, 43, 84, 44, 83, 45, 82, 46, 81, 47, 80, 48, 79, 49, 78, 50, 77, 51, 76, 52, 75, 53, 74, 54, 73, 55, 72, 56, 71, 57, 70, 58, 69, 59, 68, 60, 67, 61, 66, 62, 65, 63, 64]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l6-s5/tests/check.py b/tasks/construct-mc-all-interval-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s5/tests/check.py @@ -0,0 +1,17 @@ +"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + d = [abs(x[i + 1] - x[i]) for i in range(n - 1)] + if sorted(d) != list(range(1, n)): + raise Invalid("consecutive differences are not a permutation of 1..n-1") + seqs = {"x": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-all-interval-l6-s5/tests/instance.json b/tasks/construct-mc-all-interval-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d35ffa759e80b8d4804f11973285b1e352aa27bd --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 128, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s5/tests/run.py b/tasks/construct-mc-all-interval-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-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-all-interval-l6-s5/tests/test.sh b/tasks/construct-mc-all-interval-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-mc-antimagic-square-l6-s0/environment/Dockerfile b/tasks/construct-mc-antimagic-square-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-antimagic-square-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-antimagic-square-l6-s0/environment/instance.json b/tasks/construct-mc-antimagic-square-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..926331bce1dc5fee862953f8a6c60c43620b222c --- /dev/null +++ b/tasks/construct-mc-antimagic-square-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 9, "family": "mc_antimagic_square", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-antimagic-square-l6-s0/solution/solve.sh b/tasks/construct-mc-antimagic-square-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d1b84c638f178ceaf0a73286b784f945ef82ea65 --- /dev/null +++ b/tasks/construct-mc-antimagic-square-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' +{"grid": [[14, 45, 64, 49, 48, 41, 19, 67, 25], [58, 17, 69, 23, 73, 18, 77, 8, 34], [78, 24, 74, 3, 16, 52, 21, 68, 32], [50, 75, 5, 56, 65, 43, 6, 39, 27], [10, 71, 9, 61, 7, 79, 53, 29, 46], [31, 37, 1, 80, 51, 26, 76, 28, 44], [35, 30, 81, 36, 22, 11, 70, 15, 60], [59, 62, 4, 38, 63, 20, 2, 55, 66], [40, 12, 57, 13, 33, 72, 47, 54, 42]]} +RLMATH_EOF diff --git a/tasks/construct-mc-antimagic-square-l6-s0/tests/check.py b/tasks/construct-mc-antimagic-square-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c86a40bef203632c61a8ba237cae03eb53251a6 --- /dev/null +++ b/tasks/construct-mc-antimagic-square-l6-s0/tests/check.py @@ -0,0 +1,20 @@ +"""Antimagic square of order n (MathConstraint antimagic_square, CC-BY-4.0): the numbers 1..n^2 in an +n x n grid whose 2n+2 line sums (rows, columns, both main diagonals) are 2n+2 consecutive integers.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + g = ans.get("grid") + if not isinstance(g, list) or len(g) != n: + raise Invalid(f"grid must be a list of {n} rows") + g = [int_list(r, n, 1, n * n, "grid row") for r in g] + flat = [v for r in g for v in r] + if sorted(flat) != list(range(1, n * n + 1)): + raise Invalid(f"grid must contain each of 1..{n * n} exactly once") + sums = [sum(r) for r in g] + [sum(g[i][j] for i in range(n)) for j in range(n)] + sums += [sum(g[i][i] for i in range(n)), sum(g[i][n - 1 - i] for i in range(n))] + s = sorted(sums) + if any(s[i + 1] != s[i] + 1 for i in range(len(s) - 1)): + raise Invalid(f"line sums {sums} are not {2 * n + 2} consecutive integers") + return None, {} diff --git a/tasks/construct-mc-antimagic-square-l6-s0/tests/instance.json b/tasks/construct-mc-antimagic-square-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..926331bce1dc5fee862953f8a6c60c43620b222c --- /dev/null +++ b/tasks/construct-mc-antimagic-square-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 9, "family": "mc_antimagic_square", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-antimagic-square-l6-s0/tests/run.py b/tasks/construct-mc-antimagic-square-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-antimagic-square-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-antimagic-square-l6-s0/tests/test.sh b/tasks/construct-mc-antimagic-square-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-antimagic-square-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-debruijn-l1-s1/environment/Dockerfile b/tasks/construct-mc-debruijn-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-debruijn-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-debruijn-l1-s1/environment/instance.json b/tasks/construct-mc-debruijn-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..17d042371d2aaafa2e5687cddf602e536b6ce3f8 --- /dev/null +++ b/tasks/construct-mc-debruijn-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"b": 2, "n": 3, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l1-s1/solution/solve.sh b/tasks/construct-mc-debruijn-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f3718b2c16cf206f136e65f01f998d9942aa33ac --- /dev/null +++ b/tasks/construct-mc-debruijn-l1-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"seq": [0, 0, 0, 1, 0, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-debruijn-l1-s1/tests/check.py b/tasks/construct-mc-debruijn-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c9d6f0177d2b3bde8306d74939ee9704c1501a23 --- /dev/null +++ b/tasks/construct-mc-debruijn-l1-s1/tests/check.py @@ -0,0 +1,15 @@ +"""De Bruijn sequence B(b, n) (MathConstraint debruijn, CC-BY-4.0). Accepts any valid cyclic sequence.""" +from run import Invalid, int_list + + +def check(inst, ans): + b, n = inst["b"], inst["n"] + m = b ** n + x = int_list(ans.get("seq"), m, 0, b - 1, "seq") + seen = set() + for i in range(m): + w = tuple(x[(i + k) % m] for k in range(n)) + if w in seen: + raise Invalid(f"window {w} occurs twice") + seen.add(w) + return None, {} diff --git a/tasks/construct-mc-debruijn-l1-s1/tests/instance.json b/tasks/construct-mc-debruijn-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..17d042371d2aaafa2e5687cddf602e536b6ce3f8 --- /dev/null +++ b/tasks/construct-mc-debruijn-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"b": 2, "n": 3, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l1-s1/tests/run.py b/tasks/construct-mc-debruijn-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-debruijn-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-debruijn-l1-s1/tests/test.sh b/tasks/construct-mc-debruijn-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-debruijn-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-debruijn-l5-s0/environment/Dockerfile b/tasks/construct-mc-debruijn-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-debruijn-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-debruijn-l5-s0/environment/instance.json b/tasks/construct-mc-debruijn-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..035119a84eec08c46402fb232e56bba6b1e44480 --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"b": 3, "n": 6, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l5-s0/solution/solve.sh b/tasks/construct-mc-debruijn-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d1c8b266d88b0dcaf18248312b04e6db45268e9f --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"seq": [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 2, 2, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 2, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 2, 0, 0, 0, 1, 2, 1, 0, 0, 0, 1, 2, 2, 0, 0, 0, 2, 0, 1, 0, 0, 0, 2, 0, 2, 0, 0, 0, 2, 1, 1, 0, 0, 0, 2, 1, 2, 0, 0, 0, 2, 2, 1, 0, 0, 0, 2, 2, 2, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 2, 0, 0, 1, 0, 2, 1, 0, 0, 1, 0, 2, 2, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 2, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 2, 0, 0, 1, 1, 2, 1, 0, 0, 1, 1, 2, 2, 0, 0, 1, 2, 0, 1, 0, 0, 1, 2, 0, 2, 0, 0, 1, 2, 1, 1, 0, 0, 1, 2, 1, 2, 0, 0, 1, 2, 2, 1, 0, 0, 1, 2, 2, 2, 0, 0, 2, 0, 0, 2, 0, 1, 1, 0, 0, 2, 0, 1, 2, 0, 0, 2, 0, 2, 1, 0, 0, 2, 0, 2, 2, 0, 0, 2, 1, 0, 1, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 1, 1, 0, 0, 2, 1, 1, 2, 0, 0, 2, 1, 2, 1, 0, 0, 2, 1, 2, 2, 0, 0, 2, 2, 0, 1, 0, 0, 2, 2, 0, 2, 0, 0, 2, 2, 1, 1, 0, 0, 2, 2, 1, 2, 0, 0, 2, 2, 2, 1, 0, 0, 2, 2, 2, 2, 0, 1, 0, 1, 0, 1, 0, 2, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 2, 0, 1, 0, 1, 2, 1, 0, 1, 0, 1, 2, 2, 0, 1, 0, 2, 0, 2, 0, 1, 0, 2, 1, 1, 0, 1, 0, 2, 1, 2, 0, 1, 0, 2, 2, 1, 0, 1, 0, 2, 2, 2, 0, 1, 1, 0, 1, 1, 0, 1, 2, 0, 1, 1, 0, 2, 1, 0, 1, 1, 0, 2, 2, 0, 1, 1, 1, 0, 2, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 2, 0, 1, 1, 1, 2, 1, 0, 1, 1, 1, 2, 2, 0, 1, 1, 2, 0, 2, 0, 1, 1, 2, 1, 1, 0, 1, 1, 2, 1, 2, 0, 1, 1, 2, 2, 1, 0, 1, 1, 2, 2, 2, 0, 1, 2, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 2, 2, 0, 1, 2, 1, 0, 2, 0, 1, 2, 1, 1, 1, 0, 1, 2, 1, 1, 2, 0, 1, 2, 1, 2, 1, 0, 1, 2, 1, 2, 2, 0, 1, 2, 2, 0, 2, 0, 1, 2, 2, 1, 1, 0, 1, 2, 2, 1, 2, 0, 1, 2, 2, 2, 1, 0, 1, 2, 2, 2, 2, 0, 2, 0, 2, 0, 2, 1, 1, 0, 2, 0, 2, 1, 2, 0, 2, 0, 2, 2, 1, 0, 2, 0, 2, 2, 2, 0, 2, 1, 0, 2, 1, 0, 2, 2, 0, 2, 1, 1, 1, 1, 0, 2, 1, 1, 1, 2, 0, 2, 1, 1, 2, 1, 0, 2, 1, 1, 2, 2, 0, 2, 1, 2, 1, 1, 0, 2, 1, 2, 1, 2, 0, 2, 1, 2, 2, 1, 0, 2, 1, 2, 2, 2, 0, 2, 2, 0, 2, 2, 1, 1, 1, 0, 2, 2, 1, 1, 2, 0, 2, 2, 1, 2, 1, 0, 2, 2, 1, 2, 2, 0, 2, 2, 2, 1, 1, 0, 2, 2, 2, 1, 2, 0, 2, 2, 2, 2, 1, 0, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 2, 2, 1, 1, 2, 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-mc-debruijn-l5-s0/tests/check.py b/tasks/construct-mc-debruijn-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c9d6f0177d2b3bde8306d74939ee9704c1501a23 --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s0/tests/check.py @@ -0,0 +1,15 @@ +"""De Bruijn sequence B(b, n) (MathConstraint debruijn, CC-BY-4.0). Accepts any valid cyclic sequence.""" +from run import Invalid, int_list + + +def check(inst, ans): + b, n = inst["b"], inst["n"] + m = b ** n + x = int_list(ans.get("seq"), m, 0, b - 1, "seq") + seen = set() + for i in range(m): + w = tuple(x[(i + k) % m] for k in range(n)) + if w in seen: + raise Invalid(f"window {w} occurs twice") + seen.add(w) + return None, {} diff --git a/tasks/construct-mc-debruijn-l5-s0/tests/instance.json b/tasks/construct-mc-debruijn-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..035119a84eec08c46402fb232e56bba6b1e44480 --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"b": 3, "n": 6, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l5-s0/tests/run.py b/tasks/construct-mc-debruijn-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-debruijn-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-debruijn-l5-s0/tests/test.sh b/tasks/construct-mc-debruijn-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-debruijn-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-debruijn-l6-s2/environment/Dockerfile b/tasks/construct-mc-debruijn-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-debruijn-l6-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-debruijn-l6-s2/environment/instance.json b/tasks/construct-mc-debruijn-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a1a06bc6f681fdc8b8e87b3479ecf8bb459c6056 --- /dev/null +++ b/tasks/construct-mc-debruijn-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"b": 3, "n": 7, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l6-s2/solution/solve.sh b/tasks/construct-mc-debruijn-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3d67da4928ac520dc91bd2bd83b0df1ce9f4b95a --- /dev/null +++ b/tasks/construct-mc-debruijn-l6-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"seq": [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 1, 2, 1, 0, 0, 0, 0, 1, 2, 2, 0, 0, 0, 0, 2, 0, 1, 0, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 2, 1, 1, 0, 0, 0, 0, 2, 1, 2, 0, 0, 0, 0, 2, 2, 1, 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 2, 0, 0, 0, 1, 0, 2, 1, 0, 0, 0, 1, 0, 2, 2, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 2, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 2, 0, 0, 0, 1, 1, 2, 1, 0, 0, 0, 1, 1, 2, 2, 0, 0, 0, 1, 2, 0, 1, 0, 0, 0, 1, 2, 0, 2, 0, 0, 0, 1, 2, 1, 1, 0, 0, 0, 1, 2, 1, 2, 0, 0, 0, 1, 2, 2, 1, 0, 0, 0, 1, 2, 2, 2, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 2, 0, 1, 1, 0, 0, 0, 2, 0, 1, 2, 0, 0, 0, 2, 0, 2, 1, 0, 0, 0, 2, 0, 2, 2, 0, 0, 0, 2, 1, 0, 1, 0, 0, 0, 2, 1, 0, 2, 0, 0, 0, 2, 1, 1, 1, 0, 0, 0, 2, 1, 1, 2, 0, 0, 0, 2, 1, 2, 1, 0, 0, 0, 2, 1, 2, 2, 0, 0, 0, 2, 2, 0, 1, 0, 0, 0, 2, 2, 0, 2, 0, 0, 0, 2, 2, 1, 1, 0, 0, 0, 2, 2, 1, 2, 0, 0, 0, 2, 2, 2, 1, 0, 0, 0, 2, 2, 2, 2, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 2, 0, 0, 1, 0, 0, 2, 1, 0, 0, 1, 0, 0, 2, 2, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 2, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 2, 0, 0, 1, 0, 1, 2, 1, 0, 0, 1, 0, 1, 2, 2, 0, 0, 1, 0, 2, 0, 1, 0, 0, 1, 0, 2, 0, 2, 0, 0, 1, 0, 2, 1, 1, 0, 0, 1, 0, 2, 1, 2, 0, 0, 1, 0, 2, 2, 1, 0, 0, 1, 0, 2, 2, 2, 0, 0, 1, 1, 0, 0, 2, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 2, 0, 0, 1, 1, 0, 2, 1, 0, 0, 1, 1, 0, 2, 2, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 2, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 2, 0, 0, 1, 1, 1, 2, 1, 0, 0, 1, 1, 1, 2, 2, 0, 0, 1, 1, 2, 0, 1, 0, 0, 1, 1, 2, 0, 2, 0, 0, 1, 1, 2, 1, 1, 0, 0, 1, 1, 2, 1, 2, 0, 0, 1, 1, 2, 2, 1, 0, 0, 1, 1, 2, 2, 2, 0, 0, 1, 2, 0, 0, 2, 0, 0, 1, 2, 0, 1, 1, 0, 0, 1, 2, 0, 1, 2, 0, 0, 1, 2, 0, 2, 1, 0, 0, 1, 2, 0, 2, 2, 0, 0, 1, 2, 1, 0, 1, 0, 0, 1, 2, 1, 0, 2, 0, 0, 1, 2, 1, 1, 1, 0, 0, 1, 2, 1, 1, 2, 0, 0, 1, 2, 1, 2, 1, 0, 0, 1, 2, 1, 2, 2, 0, 0, 1, 2, 2, 0, 1, 0, 0, 1, 2, 2, 0, 2, 0, 0, 1, 2, 2, 1, 1, 0, 0, 1, 2, 2, 1, 2, 0, 0, 1, 2, 2, 2, 1, 0, 0, 1, 2, 2, 2, 2, 0, 0, 2, 0, 0, 2, 1, 0, 0, 2, 0, 0, 2, 2, 0, 0, 2, 0, 1, 0, 1, 0, 0, 2, 0, 1, 0, 2, 0, 0, 2, 0, 1, 1, 1, 0, 0, 2, 0, 1, 1, 2, 0, 0, 2, 0, 1, 2, 1, 0, 0, 2, 0, 1, 2, 2, 0, 0, 2, 0, 2, 0, 1, 0, 0, 2, 0, 2, 0, 2, 0, 0, 2, 0, 2, 1, 1, 0, 0, 2, 0, 2, 1, 2, 0, 0, 2, 0, 2, 2, 1, 0, 0, 2, 0, 2, 2, 2, 0, 0, 2, 1, 0, 1, 1, 0, 0, 2, 1, 0, 1, 2, 0, 0, 2, 1, 0, 2, 1, 0, 0, 2, 1, 0, 2, 2, 0, 0, 2, 1, 1, 0, 1, 0, 0, 2, 1, 1, 0, 2, 0, 0, 2, 1, 1, 1, 1, 0, 0, 2, 1, 1, 1, 2, 0, 0, 2, 1, 1, 2, 1, 0, 0, 2, 1, 1, 2, 2, 0, 0, 2, 1, 2, 0, 1, 0, 0, 2, 1, 2, 0, 2, 0, 0, 2, 1, 2, 1, 1, 0, 0, 2, 1, 2, 1, 2, 0, 0, 2, 1, 2, 2, 1, 0, 0, 2, 1, 2, 2, 2, 0, 0, 2, 2, 0, 1, 1, 0, 0, 2, 2, 0, 1, 2, 0, 0, 2, 2, 0, 2, 1, 0, 0, 2, 2, 0, 2, 2, 0, 0, 2, 2, 1, 0, 1, 0, 0, 2, 2, 1, 0, 2, 0, 0, 2, 2, 1, 1, 1, 0, 0, 2, 2, 1, 1, 2, 0, 0, 2, 2, 1, 2, 1, 0, 0, 2, 2, 1, 2, 2, 0, 0, 2, 2, 2, 0, 1, 0, 0, 2, 2, 2, 0, 2, 0, 0, 2, 2, 2, 1, 1, 0, 0, 2, 2, 2, 1, 2, 0, 0, 2, 2, 2, 2, 1, 0, 0, 2, 2, 2, 2, 2, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 2, 0, 1, 0, 1, 0, 2, 1, 0, 1, 0, 1, 0, 2, 2, 0, 1, 0, 1, 1, 0, 2, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 2, 0, 1, 0, 1, 1, 2, 1, 0, 1, 0, 1, 1, 2, 2, 0, 1, 0, 1, 2, 0, 2, 0, 1, 0, 1, 2, 1, 1, 0, 1, 0, 1, 2, 1, 2, 0, 1, 0, 1, 2, 2, 1, 0, 1, 0, 1, 2, 2, 2, 0, 1, 0, 2, 0, 1, 1, 0, 1, 0, 2, 0, 1, 2, 0, 1, 0, 2, 0, 2, 1, 0, 1, 0, 2, 0, 2, 2, 0, 1, 0, 2, 1, 0, 2, 0, 1, 0, 2, 1, 1, 1, 0, 1, 0, 2, 1, 1, 2, 0, 1, 0, 2, 1, 2, 1, 0, 1, 0, 2, 1, 2, 2, 0, 1, 0, 2, 2, 0, 2, 0, 1, 0, 2, 2, 1, 1, 0, 1, 0, 2, 2, 1, 2, 0, 1, 0, 2, 2, 2, 1, 0, 1, 0, 2, 2, 2, 2, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 2, 0, 1, 1, 0, 1, 2, 1, 0, 1, 1, 0, 1, 2, 2, 0, 1, 1, 0, 2, 0, 2, 0, 1, 1, 0, 2, 1, 1, 0, 1, 1, 0, 2, 1, 2, 0, 1, 1, 0, 2, 2, 1, 0, 1, 1, 0, 2, 2, 2, 0, 1, 1, 1, 0, 1, 2, 0, 1, 1, 1, 0, 2, 1, 0, 1, 1, 1, 0, 2, 2, 0, 1, 1, 1, 1, 0, 2, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 2, 0, 1, 1, 1, 1, 2, 1, 0, 1, 1, 1, 1, 2, 2, 0, 1, 1, 1, 2, 0, 2, 0, 1, 1, 1, 2, 1, 1, 0, 1, 1, 1, 2, 1, 2, 0, 1, 1, 1, 2, 2, 1, 0, 1, 1, 1, 2, 2, 2, 0, 1, 1, 2, 0, 1, 2, 0, 1, 1, 2, 0, 2, 1, 0, 1, 1, 2, 0, 2, 2, 0, 1, 1, 2, 1, 0, 2, 0, 1, 1, 2, 1, 1, 1, 0, 1, 1, 2, 1, 1, 2, 0, 1, 1, 2, 1, 2, 1, 0, 1, 1, 2, 1, 2, 2, 0, 1, 1, 2, 2, 0, 2, 0, 1, 1, 2, 2, 1, 1, 0, 1, 1, 2, 2, 1, 2, 0, 1, 1, 2, 2, 2, 1, 0, 1, 1, 2, 2, 2, 2, 0, 1, 2, 0, 1, 2, 1, 0, 1, 2, 0, 1, 2, 2, 0, 1, 2, 0, 2, 0, 2, 0, 1, 2, 0, 2, 1, 1, 0, 1, 2, 0, 2, 1, 2, 0, 1, 2, 0, 2, 2, 1, 0, 1, 2, 0, 2, 2, 2, 0, 1, 2, 1, 0, 2, 1, 0, 1, 2, 1, 0, 2, 2, 0, 1, 2, 1, 1, 0, 2, 0, 1, 2, 1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 2, 0, 1, 2, 1, 1, 2, 1, 0, 1, 2, 1, 1, 2, 2, 0, 1, 2, 1, 2, 0, 2, 0, 1, 2, 1, 2, 1, 1, 0, 1, 2, 1, 2, 1, 2, 0, 1, 2, 1, 2, 2, 1, 0, 1, 2, 1, 2, 2, 2, 0, 1, 2, 2, 0, 2, 1, 0, 1, 2, 2, 0, 2, 2, 0, 1, 2, 2, 1, 0, 2, 0, 1, 2, 2, 1, 1, 1, 0, 1, 2, 2, 1, 1, 2, 0, 1, 2, 2, 1, 2, 1, 0, 1, 2, 2, 1, 2, 2, 0, 1, 2, 2, 2, 0, 2, 0, 1, 2, 2, 2, 1, 1, 0, 1, 2, 2, 2, 1, 2, 0, 1, 2, 2, 2, 2, 1, 0, 1, 2, 2, 2, 2, 2, 0, 2, 0, 2, 0, 2, 1, 0, 2, 0, 2, 0, 2, 2, 0, 2, 0, 2, 1, 1, 1, 0, 2, 0, 2, 1, 1, 2, 0, 2, 0, 2, 1, 2, 1, 0, 2, 0, 2, 1, 2, 2, 0, 2, 0, 2, 2, 1, 1, 0, 2, 0, 2, 2, 1, 2, 0, 2, 0, 2, 2, 2, 1, 0, 2, 0, 2, 2, 2, 2, 0, 2, 1, 0, 2, 1, 1, 0, 2, 1, 0, 2, 1, 2, 0, 2, 1, 0, 2, 2, 1, 0, 2, 1, 0, 2, 2, 2, 0, 2, 1, 1, 0, 2, 2, 0, 2, 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, 1, 2, 0, 2, 1, 1, 1, 2, 1, 0, 2, 1, 1, 1, 2, 2, 0, 2, 1, 1, 2, 1, 1, 0, 2, 1, 1, 2, 1, 2, 0, 2, 1, 1, 2, 2, 1, 0, 2, 1, 1, 2, 2, 2, 0, 2, 1, 2, 0, 2, 2, 0, 2, 1, 2, 1, 1, 1, 0, 2, 1, 2, 1, 1, 2, 0, 2, 1, 2, 1, 2, 1, 0, 2, 1, 2, 1, 2, 2, 0, 2, 1, 2, 2, 1, 1, 0, 2, 1, 2, 2, 1, 2, 0, 2, 1, 2, 2, 2, 1, 0, 2, 1, 2, 2, 2, 2, 0, 2, 2, 0, 2, 2, 1, 0, 2, 2, 0, 2, 2, 2, 0, 2, 2, 1, 1, 1, 1, 0, 2, 2, 1, 1, 1, 2, 0, 2, 2, 1, 1, 2, 1, 0, 2, 2, 1, 1, 2, 2, 0, 2, 2, 1, 2, 1, 1, 0, 2, 2, 1, 2, 1, 2, 0, 2, 2, 1, 2, 2, 1, 0, 2, 2, 1, 2, 2, 2, 0, 2, 2, 2, 1, 1, 1, 0, 2, 2, 2, 1, 1, 2, 0, 2, 2, 2, 1, 2, 1, 0, 2, 2, 2, 1, 2, 2, 0, 2, 2, 2, 2, 1, 1, 0, 2, 2, 2, 2, 1, 2, 0, 2, 2, 2, 2, 2, 1, 0, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 2, 2, 1, 1, 1, 2, 2, 1, 2, 1, 1, 1, 2, 2, 2, 2, 1, 1, 2, 1, 1, 2, 2, 1, 1, 2, 1, 2, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1, 1, 2, 2, 1, 2, 2, 1, 1, 2, 2, 2, 1, 2, 1, 1, 2, 2, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-mc-debruijn-l6-s2/tests/check.py b/tasks/construct-mc-debruijn-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c9d6f0177d2b3bde8306d74939ee9704c1501a23 --- /dev/null +++ b/tasks/construct-mc-debruijn-l6-s2/tests/check.py @@ -0,0 +1,15 @@ +"""De Bruijn sequence B(b, n) (MathConstraint debruijn, CC-BY-4.0). Accepts any valid cyclic sequence.""" +from run import Invalid, int_list + + +def check(inst, ans): + b, n = inst["b"], inst["n"] + m = b ** n + x = int_list(ans.get("seq"), m, 0, b - 1, "seq") + seen = set() + for i in range(m): + w = tuple(x[(i + k) % m] for k in range(n)) + if w in seen: + raise Invalid(f"window {w} occurs twice") + seen.add(w) + return None, {} diff --git a/tasks/construct-mc-debruijn-l6-s2/tests/instance.json b/tasks/construct-mc-debruijn-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a1a06bc6f681fdc8b8e87b3479ecf8bb459c6056 --- /dev/null +++ b/tasks/construct-mc-debruijn-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"b": 3, "n": 7, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l6-s2/tests/run.py b/tasks/construct-mc-debruijn-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-debruijn-l6-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-debruijn-l6-s2/tests/test.sh b/tasks/construct-mc-debruijn-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-debruijn-l6-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-golomb-l3-s0/environment/Dockerfile b/tasks/construct-mc-golomb-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-golomb-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-golomb-l3-s0/environment/instance.json b/tasks/construct-mc-golomb-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..877dc8558f26ac80e8db1185330b059e95778db6 --- /dev/null +++ b/tasks/construct-mc-golomb-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 10, "max_length": 55, "fixed": [], "family": "mc_golomb", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-golomb-l3-s0/solution/solve.sh b/tasks/construct-mc-golomb-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4b55de176852ecf089f8e938bce39ef10f68eb1b --- /dev/null +++ b/tasks/construct-mc-golomb-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' +{"marks": [0, 2, 14, 21, 29, 32, 45, 49, 54, 55]} +RLMATH_EOF diff --git a/tasks/construct-mc-golomb-l3-s0/tests/check.py b/tasks/construct-mc-golomb-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..84aedd6e33fee7271543bfa49ab05128e23c31ee --- /dev/null +++ b/tasks/construct-mc-golomb-l3-s0/tests/check.py @@ -0,0 +1,27 @@ +"""Golomb ruler with n marks and length <= L (MathConstraint golomb, CC-BY-4.0, reframed as a decision +problem with the target length stated). Accepts any valid ruler. +Upstream note: the upstream prompt states no length bound and its verifier re-solves the optimisation +model with the marks fixed, which returns OPTIMUM for any Golomb ruler, so any ruler (e.g. 0,1,3,7,15,..) +was accepted. Here the length bound is part of the instance and enforced.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, L = inst["n"], inst["max_length"] + a = int_list(ans.get("marks"), n, 0, L, "marks") + if a[0] != 0: + raise Invalid("first mark must be 0") + if any(a[i] >= a[i + 1] for i in range(n - 1)): + raise Invalid("marks must be strictly increasing") + for name, i, v in inst.get("fixed", []): + if a[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + seen = set() + for i, j in itertools.combinations(range(n), 2): + d = a[j] - a[i] + if d in seen: + raise Invalid(f"difference {d} occurs twice") + seen.add(d) + return None, {"length": a[-1]} diff --git a/tasks/construct-mc-golomb-l3-s0/tests/instance.json b/tasks/construct-mc-golomb-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..877dc8558f26ac80e8db1185330b059e95778db6 --- /dev/null +++ b/tasks/construct-mc-golomb-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 10, "max_length": 55, "fixed": [], "family": "mc_golomb", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-golomb-l3-s0/tests/run.py b/tasks/construct-mc-golomb-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-golomb-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-golomb-l3-s0/tests/test.sh b/tasks/construct-mc-golomb-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-golomb-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-graceful-graph-l2-s0/environment/Dockerfile b/tasks/construct-mc-graceful-graph-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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-graceful-graph-l2-s0/environment/instance.json b/tasks/construct-mc-graceful-graph-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5842d804be61f8663d04595d4c863e9e33985cea --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"k": 3, "p": 3, "num_vertices": 9, "edges": [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [7, 8], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8]], "fixed": [], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l2-s0/solution/solve.sh b/tasks/construct-mc-graceful-graph-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a576b264cc5c3a4a792342523d74a7611f36d07b --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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' +{"labels": [2, 12, 0, 1, 6, 15, 14, 3, 7]} +RLMATH_EOF diff --git a/tasks/construct-mc-graceful-graph-l2-s0/tests/check.py b/tasks/construct-mc-graceful-graph-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f4d33af1d63c0495c3b32d34db6ae10f0fb45923 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l2-s0/tests/check.py @@ -0,0 +1,19 @@ +"""Graceful labelling of K_k x P_p (MathConstraint graceful_graph, CC-BY-4.0): distinct vertex labels in +0..m (m = number of edges) whose edge differences |l(u) - l(v)| are all distinct.""" +from run import Invalid, int_list + + +def check(inst, ans): + nv, edges = inst["num_vertices"], inst["edges"] + m = len(edges) + x = int_list(ans.get("labels"), nv, 0, m, "labels") + if len(set(x)) != nv: + raise Invalid("vertex labels must be distinct") + d = [abs(x[u] - x[v]) for u, v in edges] + if len(set(d)) != m: + raise Invalid("edge labels are not distinct") + seqs = {"labels": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-graceful-graph-l2-s0/tests/instance.json b/tasks/construct-mc-graceful-graph-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5842d804be61f8663d04595d4c863e9e33985cea --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"k": 3, "p": 3, "num_vertices": 9, "edges": [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [7, 8], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8]], "fixed": [], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l2-s0/tests/run.py b/tasks/construct-mc-graceful-graph-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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-graceful-graph-l2-s0/tests/test.sh b/tasks/construct-mc-graceful-graph-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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-graceful-graph-l5-s3/environment/Dockerfile b/tasks/construct-mc-graceful-graph-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-graceful-graph-l5-s3/environment/instance.json b/tasks/construct-mc-graceful-graph-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d7d1868c27681593f9a5ff097a808974680d51f9 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"k": 3, "p": 10, "num_vertices": 30, "edges": [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [13, 14], [15, 16], [15, 17], [16, 17], [18, 19], [18, 20], [19, 20], [21, 22], [21, 23], [22, 23], [24, 25], [24, 26], [25, 26], [27, 28], [27, 29], [28, 29], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16], [14, 17], [15, 18], [16, 19], [17, 20], [18, 21], [19, 22], [20, 23], [21, 24], [22, 25], [23, 26], [24, 27], [25, 28], [26, 29]], "fixed": [], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l5-s3/solution/solve.sh b/tasks/construct-mc-graceful-graph-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..61a34252ca6a09abfb751f6e41c64e62026ea5eb --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"labels": [39, 51, 20, 10, 35, 53, 45, 9, 30, 23, 50, 6, 37, 3, 57, 5, 55, 0, 16, 7, 56, 24, 52, 14, 54, 15, 8, 1, 2, 4]} +RLMATH_EOF diff --git a/tasks/construct-mc-graceful-graph-l5-s3/tests/check.py b/tasks/construct-mc-graceful-graph-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f4d33af1d63c0495c3b32d34db6ae10f0fb45923 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s3/tests/check.py @@ -0,0 +1,19 @@ +"""Graceful labelling of K_k x P_p (MathConstraint graceful_graph, CC-BY-4.0): distinct vertex labels in +0..m (m = number of edges) whose edge differences |l(u) - l(v)| are all distinct.""" +from run import Invalid, int_list + + +def check(inst, ans): + nv, edges = inst["num_vertices"], inst["edges"] + m = len(edges) + x = int_list(ans.get("labels"), nv, 0, m, "labels") + if len(set(x)) != nv: + raise Invalid("vertex labels must be distinct") + d = [abs(x[u] - x[v]) for u, v in edges] + if len(set(d)) != m: + raise Invalid("edge labels are not distinct") + seqs = {"labels": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-graceful-graph-l5-s3/tests/instance.json b/tasks/construct-mc-graceful-graph-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d7d1868c27681593f9a5ff097a808974680d51f9 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"k": 3, "p": 10, "num_vertices": 30, "edges": [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [13, 14], [15, 16], [15, 17], [16, 17], [18, 19], [18, 20], [19, 20], [21, 22], [21, 23], [22, 23], [24, 25], [24, 26], [25, 26], [27, 28], [27, 29], [28, 29], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16], [14, 17], [15, 18], [16, 19], [17, 20], [18, 21], [19, 22], [20, 23], [21, 24], [22, 25], [23, 26], [24, 27], [25, 28], [26, 29]], "fixed": [], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l5-s3/tests/run.py b/tasks/construct-mc-graceful-graph-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-graceful-graph-l5-s3/tests/test.sh b/tasks/construct-mc-graceful-graph-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-graph-k-coloring-l1-s4/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-mc-graph-k-coloring-l1-s4/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..717d8fc484d2c1d07a3da5272fe4a494e2375e8f --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 3, "edges": [[0, 5], [0, 7], [0, 9], [0, 12], [0, 15], [1, 9], [2, 4], [2, 12], [2, 15], [2, 17], [2, 19], [3, 6], [3, 9], [3, 15], [3, 16], [4, 10], [4, 13], [5, 9], [5, 10], [6, 8], [6, 16], [6, 17], [7, 11], [8, 9], [8, 14], [8, 18], [9, 17], [10, 19], [12, 15], [12, 17]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l1-s4/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d9376e8e6cfa6abd861003f05f7beda69fb6ee07 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [1, 1, 1, 1, 0, 0, 2, 0, 0, 2, 1, 1, 2, 2, 2, 0, 0, 0, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l1-s4/tests/check.py b/tasks/construct-mc-graph-k-coloring-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s4/tests/check.py @@ -0,0 +1,11 @@ +"""Proper k-colouring of a given graph (MathConstraint graph_k_coloring, CC-BY-4.0). Any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-mc-graph-k-coloring-l1-s4/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..717d8fc484d2c1d07a3da5272fe4a494e2375e8f --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 3, "edges": [[0, 5], [0, 7], [0, 9], [0, 12], [0, 15], [1, 9], [2, 4], [2, 12], [2, 15], [2, 17], [2, 19], [3, 6], [3, 9], [3, 15], [3, 16], [4, 10], [4, 13], [5, 9], [5, 10], [6, 8], [6, 16], [6, 17], [7, 11], [8, 9], [8, 14], [8, 18], [9, 17], [10, 19], [12, 15], [12, 17]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l1-s4/tests/run.py b/tasks/construct-mc-graph-k-coloring-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-mc-graph-k-coloring-l1-s4/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-mc-hadamard-l2-s0/environment/Dockerfile b/tasks/construct-mc-hadamard-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-hadamard-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-hadamard-l2-s0/environment/instance.json b/tasks/construct-mc-hadamard-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1b17b04b8cb213a9dc51b97eb67f0bda2c4f2b07 --- /dev/null +++ b/tasks/construct-mc-hadamard-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 13, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l2-s0/solution/solve.sh b/tasks/construct-mc-hadamard-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..57f6d453966acccf7c18b4451e46d99703ce3051 --- /dev/null +++ b/tasks/construct-mc-hadamard-l2-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [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]} +RLMATH_EOF diff --git a/tasks/construct-mc-hadamard-l2-s0/tests/check.py b/tasks/construct-mc-hadamard-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..fc4b93160fd7473dd14935db9d712e52abdd00c2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l2-s0/tests/check.py @@ -0,0 +1,18 @@ +"""Legendre pair of odd length n (MathConstraint hadamard, CC-BY-4.0): x, y in {-1,+1}^n with +sum(x) = sum(y) = 1 and PAF_x(k) + PAF_y(k) = -2 for k = 1..(n-1)/2 (periodic autocorrelation).""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, -1, 1, "x") + y = int_list(ans.get("y"), n, -1, 1, "y") + if 0 in x or 0 in y: + raise Invalid("entries must be -1 or +1") + if sum(x) != 1 or sum(y) != 1: + raise Invalid("sum(x) and sum(y) must both equal 1") + for k in range(1, (n - 1) // 2 + 1): + p = sum(x[i] * x[(i + k) % n] for i in range(n)) + sum(y[i] * y[(i + k) % n] for i in range(n)) + if p != -2: + raise Invalid(f"PAF_x({k}) + PAF_y({k}) = {p}, need -2") + return None, {} diff --git a/tasks/construct-mc-hadamard-l2-s0/tests/instance.json b/tasks/construct-mc-hadamard-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1b17b04b8cb213a9dc51b97eb67f0bda2c4f2b07 --- /dev/null +++ b/tasks/construct-mc-hadamard-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 13, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l2-s0/tests/run.py b/tasks/construct-mc-hadamard-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-hadamard-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-hadamard-l2-s0/tests/test.sh b/tasks/construct-mc-hadamard-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-hadamard-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-hadamard-l5-s3/environment/Dockerfile b/tasks/construct-mc-hadamard-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-hadamard-l5-s3/environment/instance.json b/tasks/construct-mc-hadamard-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a70809c35e4f86bbdb90674ca9edd4d68fb28202 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 43, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l5-s3/solution/solve.sh b/tasks/construct-mc-hadamard-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8fe131da472d2944a1f5519c8850569877a427d2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [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]} +RLMATH_EOF diff --git a/tasks/construct-mc-hadamard-l5-s3/tests/check.py b/tasks/construct-mc-hadamard-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..fc4b93160fd7473dd14935db9d712e52abdd00c2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s3/tests/check.py @@ -0,0 +1,18 @@ +"""Legendre pair of odd length n (MathConstraint hadamard, CC-BY-4.0): x, y in {-1,+1}^n with +sum(x) = sum(y) = 1 and PAF_x(k) + PAF_y(k) = -2 for k = 1..(n-1)/2 (periodic autocorrelation).""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, -1, 1, "x") + y = int_list(ans.get("y"), n, -1, 1, "y") + if 0 in x or 0 in y: + raise Invalid("entries must be -1 or +1") + if sum(x) != 1 or sum(y) != 1: + raise Invalid("sum(x) and sum(y) must both equal 1") + for k in range(1, (n - 1) // 2 + 1): + p = sum(x[i] * x[(i + k) % n] for i in range(n)) + sum(y[i] * y[(i + k) % n] for i in range(n)) + if p != -2: + raise Invalid(f"PAF_x({k}) + PAF_y({k}) = {p}, need -2") + return None, {} diff --git a/tasks/construct-mc-hadamard-l5-s3/tests/instance.json b/tasks/construct-mc-hadamard-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a70809c35e4f86bbdb90674ca9edd4d68fb28202 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 43, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l5-s3/tests/run.py b/tasks/construct-mc-hadamard-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-hadamard-l5-s3/tests/test.sh b/tasks/construct-mc-hadamard-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-hadamard-l5-s4/environment/Dockerfile b/tasks/construct-mc-hadamard-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-hadamard-l5-s4/environment/instance.json b/tasks/construct-mc-hadamard-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6648da5f846a5a74b93f4a9c1b2d9be0ec1a53d0 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 47, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l5-s4/solution/solve.sh b/tasks/construct-mc-hadamard-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1c22372c0132eb7d176a560c0848444eb5ce60a7 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"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], "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]} +RLMATH_EOF diff --git a/tasks/construct-mc-hadamard-l5-s4/tests/check.py b/tasks/construct-mc-hadamard-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..fc4b93160fd7473dd14935db9d712e52abdd00c2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s4/tests/check.py @@ -0,0 +1,18 @@ +"""Legendre pair of odd length n (MathConstraint hadamard, CC-BY-4.0): x, y in {-1,+1}^n with +sum(x) = sum(y) = 1 and PAF_x(k) + PAF_y(k) = -2 for k = 1..(n-1)/2 (periodic autocorrelation).""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, -1, 1, "x") + y = int_list(ans.get("y"), n, -1, 1, "y") + if 0 in x or 0 in y: + raise Invalid("entries must be -1 or +1") + if sum(x) != 1 or sum(y) != 1: + raise Invalid("sum(x) and sum(y) must both equal 1") + for k in range(1, (n - 1) // 2 + 1): + p = sum(x[i] * x[(i + k) % n] for i in range(n)) + sum(y[i] * y[(i + k) % n] for i in range(n)) + if p != -2: + raise Invalid(f"PAF_x({k}) + PAF_y({k}) = {p}, need -2") + return None, {} diff --git a/tasks/construct-mc-hadamard-l5-s4/tests/instance.json b/tasks/construct-mc-hadamard-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6648da5f846a5a74b93f4a9c1b2d9be0ec1a53d0 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 47, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l5-s4/tests/run.py b/tasks/construct-mc-hadamard-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-hadamard-l5-s4/tests/test.sh b/tasks/construct-mc-hadamard-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-hadamard-l6-s8/environment/Dockerfile b/tasks/construct-mc-hadamard-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-hadamard-l6-s8/environment/instance.json b/tasks/construct-mc-hadamard-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6e5eeed072ef1d9de81a5f6e03d15af1d40cd573 --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 59, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l6-s8/solution/solve.sh b/tasks/construct-mc-hadamard-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4b39ce5ff433fc2c63af228c8e6b9293dd101d05 --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [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]} +RLMATH_EOF diff --git a/tasks/construct-mc-hadamard-l6-s8/tests/check.py b/tasks/construct-mc-hadamard-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..fc4b93160fd7473dd14935db9d712e52abdd00c2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s8/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-s8/tests/instance.json b/tasks/construct-mc-hadamard-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6e5eeed072ef1d9de81a5f6e03d15af1d40cd573 --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 59, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l6-s8/tests/run.py b/tasks/construct-mc-hadamard-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-hadamard-l6-s8/tests/test.sh b/tasks/construct-mc-hadamard-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-hadamard-l6-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-langford-l5-s2/environment/Dockerfile b/tasks/construct-mc-langford-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-langford-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-langford-l5-s2/environment/instance.json b/tasks/construct-mc-langford-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..014cfdd327d939f1af508eb1d67ea1f07cae0041 --- /dev/null +++ b/tasks/construct-mc-langford-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 36, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l5-s2/solution/solve.sh b/tasks/construct-mc-langford-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e76aaed75a4781be7e26c001537750cff47d438c --- /dev/null +++ b/tasks/construct-mc-langford-l5-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"seq": [11, 13, 29, 35, 31, 34, 36, 17, 33, 18, 5, 2, 11, 6, 2, 13, 5, 19, 30, 32, 6, 28, 23, 24, 9, 17, 14, 16, 18, 21, 22, 25, 29, 26, 9, 27, 31, 19, 20, 35, 34, 14, 33, 36, 16, 1, 23, 1, 24, 30, 28, 21, 32, 22, 15, 10, 8, 25, 12, 20, 26, 7, 4, 27, 3, 8, 10, 4, 3, 7, 15, 12]} +RLMATH_EOF diff --git a/tasks/construct-mc-langford-l5-s2/tests/check.py b/tasks/construct-mc-langford-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4672d7eacf321991933cb280d6c940f1c4a67935 --- /dev/null +++ b/tasks/construct-mc-langford-l5-s2/tests/check.py @@ -0,0 +1,17 @@ +"""Langford sequence L(2, n) (MathConstraint langford, CC-BY-4.0). Accepts any valid sequence.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + seq = int_list(ans.get("seq"), 2 * n, 1, n, "seq") + for v in range(1, n + 1): + pos = [i for i, s in enumerate(seq) if s == v] + if len(pos) != 2: + raise Invalid(f"value {v} occurs {len(pos)} times (need exactly 2)") + if pos[1] - pos[0] != v + 1: + raise Invalid(f"the two copies of {v} are {pos[1] - pos[0]} positions apart (need {v + 1})") + for name, i, v in inst.get("fixed", []): + if seq[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-langford-l5-s2/tests/instance.json b/tasks/construct-mc-langford-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..014cfdd327d939f1af508eb1d67ea1f07cae0041 --- /dev/null +++ b/tasks/construct-mc-langford-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 36, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l5-s2/tests/run.py b/tasks/construct-mc-langford-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-langford-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-langford-l5-s2/tests/test.sh b/tasks/construct-mc-langford-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-langford-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-low-autocorrelation-l3-s1/environment/Dockerfile b/tasks/construct-mc-low-autocorrelation-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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-low-autocorrelation-l3-s1/environment/instance.json b/tasks/construct-mc-low-autocorrelation-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..913b787324c033014bcae2db7ff5d05479e620a3 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 19, "bound": 46, "fixed": [["seq", 4, -1], ["seq", 12, 1], ["seq", 13, -1], ["c", 1, -1], ["c", 2, 0], ["c", 7, -3]], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l3-s1/solution/solve.sh b/tasks/construct-mc-low-autocorrelation-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d0b20d2d723271fdd07ca36ce126f3ec3f25324b --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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' +{"seq": [1, -1, -1, 1, -1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-low-autocorrelation-l3-s1/tests/check.py b/tasks/construct-mc-low-autocorrelation-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8456f7b1c0ff0c9fb4bc9ae5a49074c8afa7d1aa --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s1/tests/check.py @@ -0,0 +1,20 @@ +"""+-1 sequence of length n with aperiodic autocorrelation energy sum_k C_k^2 <= bound +(MathConstraint low_autocorrelation, CC-BY-4.0). Exact integer arithmetic.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, bound = inst["n"], inst["bound"] + s = int_list(ans.get("seq"), n, -1, 1, "seq") + if any(v == 0 for v in s): + raise Invalid("entries must be -1 or +1") + c = [sum(s[i] * s[i + k] for i in range(n - k)) for k in range(1, n)] + e = sum(v * v for v in c) + # fixed values: seq[i] or c[k] (c[k] is the autocorrelation at shift k+1, as upstream) + seqs = {"seq": s, "c": c} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + if e > bound: + raise Invalid(f"energy {e} exceeds the bound {bound}") + return None, {"energy": e} diff --git a/tasks/construct-mc-low-autocorrelation-l3-s1/tests/instance.json b/tasks/construct-mc-low-autocorrelation-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..913b787324c033014bcae2db7ff5d05479e620a3 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 19, "bound": 46, "fixed": [["seq", 4, -1], ["seq", 12, 1], ["seq", 13, -1], ["c", 1, -1], ["c", 2, 0], ["c", 7, -3]], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l3-s1/tests/run.py b/tasks/construct-mc-low-autocorrelation-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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-low-autocorrelation-l3-s1/tests/test.sh b/tasks/construct-mc-low-autocorrelation-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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-max-clique-l3-s1/environment/Dockerfile b/tasks/construct-mc-max-clique-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-clique-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-max-clique-l3-s1/environment/instance.json b/tasks/construct-mc-max-clique-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3c89d6ca8d673932e5a600f9388c1066e28a4503 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 52, "k": 5, "edges": [[0, 5], [0, 8], [0, 16], [0, 22], [0, 26], [0, 27], [0, 28], [0, 30], [0, 31], [0, 34], [0, 35], [0, 36], [0, 37], [0, 38], [0, 41], [0, 43], [0, 48], [0, 49], [0, 50], [0, 51], [1, 2], [1, 3], [1, 5], [1, 7], [1, 10], [1, 13], [1, 14], [1, 16], [1, 20], [1, 22], [1, 25], [1, 27], [1, 28], [1, 31], [1, 32], [1, 35], [1, 37], [1, 41], [1, 42], [1, 43], [1, 48], [1, 49], [1, 51], [2, 3], [2, 8], [2, 9], [2, 12], [2, 15], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 25], [2, 26], [2, 28], [2, 32], [2, 38], [2, 39], [2, 45], [2, 47], [2, 49], [2, 50], [3, 7], [3, 9], [3, 11], [3, 13], [3, 15], [3, 17], [3, 18], [3, 20], [3, 21], [3, 22], [3, 23], [3, 25], [3, 26], [3, 30], [3, 34], [3, 40], [3, 41], [3, 44], [3, 47], [3, 48], [3, 49], [3, 51], [4, 5], [4, 8], [4, 12], [4, 14], [4, 15], [4, 16], [4, 17], [4, 22], [4, 23], [4, 24], [4, 25], [4, 27], [4, 31], [4, 42], [4, 43], [4, 44], [4, 46], [4, 47], [4, 48], [4, 50], [4, 51], [5, 6], [5, 7], [5, 8], [5, 10], [5, 14], [5, 16], [5, 23], [5, 26], [5, 28], [5, 29], [5, 30], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [5, 40], [5, 41], [5, 44], [5, 45], [5, 46], [5, 49], [5, 50], [6, 7], [6, 9], [6, 10], [6, 11], [6, 13], [6, 18], [6, 21], [6, 23], [6, 24], [6, 27], [6, 28], [6, 30], [6, 31], [6, 36], [6, 45], [6, 48], [6, 49], [6, 51], [7, 8], [7, 9], [7, 10], [7, 14], [7, 15], [7, 16], [7, 17], [7, 22], [7, 23], [7, 25], [7, 26], [7, 27], [7, 30], [7, 37], [7, 43], [7, 44], [7, 46], [7, 48], [7, 49], [8, 9], [8, 12], [8, 14], [8, 18], [8, 20], [8, 22], [8, 24], [8, 29], [8, 31], [8, 37], [8, 40], [8, 41], [8, 43], [8, 46], [8, 48], [9, 14], [9, 15], [9, 20], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [9, 30], [9, 34], [9, 37], [9, 39], [9, 40], [9, 41], [9, 43], [9, 44], [9, 51], [10, 11], [10, 13], [10, 20], [10, 22], [10, 23], [10, 24], [10, 25], [10, 29], [10, 36], [10, 39], [10, 40], [10, 41], [10, 42], [10, 43], [10, 48], [10, 49], [10, 51], [11, 13], [11, 16], [11, 19], [11, 20], [11, 21], [11, 23], [11, 24], [11, 26], [11, 27], [11, 29], [11, 31], [11, 32], [11, 34], [11, 35], [11, 38], [11, 42], [11, 46], [11, 48], [11, 49], [11, 51], [12, 13], [12, 15], [12, 17], [12, 19], [12, 21], [12, 24], [12, 25], [12, 32], [12, 35], [12, 36], [12, 37], [12, 39], [12, 40], [12, 41], [12, 43], [12, 46], [12, 47], [12, 48], [12, 49], [13, 18], [13, 19], [13, 23], [13, 25], [13, 26], [13, 29], [13, 30], [13, 32], [13, 34], [13, 36], [13, 38], [13, 41], [13, 42], [13, 45], [14, 16], [14, 18], [14, 19], [14, 21], [14, 24], [14, 29], [14, 30], [14, 33], [14, 34], [14, 35], [14, 37], [14, 39], [14, 40], [14, 44], [14, 45], [14, 48], [15, 16], [15, 17], [15, 19], [15, 20], [15, 23], [15, 28], [15, 30], [15, 32], [15, 36], [15, 37], [15, 38], [15, 39], [15, 46], [15, 47], [15, 48], [16, 18], [16, 20], [16, 23], [16, 24], [16, 26], [16, 28], [16, 29], [16, 35], [16, 36], [16, 43], [16, 44], [16, 50], [16, 51], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 25], [17, 27], [17, 30], [17, 38], [17, 42], [17, 50], [17, 51], [18, 19], [18, 20], [18, 21], [18, 27], [18, 28], [18, 29], [18, 30], [18, 35], [18, 41], [18, 42], [18, 43], [18, 47], [18, 49], [18, 50], [18, 51], [19, 20], [19, 26], [19, 36], [19, 37], [19, 39], [19, 43], [19, 44], [19, 47], [19, 49], [20, 22], [20, 27], [20, 35], [20, 38], [20, 39], [20, 40], [20, 41], [20, 44], [20, 45], [20, 50], [21, 23], [21, 24], [21, 26], [21, 27], [21, 28], [21, 29], [21, 33], [21, 37], [21, 42], [21, 43], [21, 44], [21, 46], [21, 47], [21, 50], [22, 23], [22, 26], [22, 31], [22, 33], [22, 35], [22, 44], [22, 45], [22, 47], [23, 24], [23, 25], [23, 29], [23, 35], [23, 37], [23, 39], [23, 42], [23, 44], [23, 45], [23, 51], [24, 26], [24, 31], [24, 34], [24, 35], [24, 40], [24, 42], [24, 43], [24, 44], [24, 45], [25, 31], [25, 32], [25, 36], [25, 38], [25, 42], [25, 44], [25, 45], [25, 49], [25, 51], [26, 27], [26, 32], [26, 34], [26, 38], [26, 40], [26, 42], [26, 43], [26, 47], [27, 32], [27, 34], [27, 37], [27, 38], [27, 39], [27, 41], [27, 42], [27, 43], [28, 29], [28, 30], [28, 32], [28, 36], [28, 46], [28, 49], [29, 30], [29, 31], [29, 32], [29, 34], [29, 35], [29, 36], [29, 38], [29, 42], [29, 44], [29, 45], [29, 48], [30, 36], [30, 38], [30, 42], [30, 43], [30, 44], [30, 45], [30, 46], [30, 48], [30, 51], [31, 32], [31, 33], [31, 37], [31, 38], [31, 42], [31, 44], [31, 45], [31, 48], [31, 49], [31, 50], [31, 51], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 38], [32, 42], [32, 43], [32, 44], [32, 49], [32, 50], [33, 34], [33, 35], [33, 41], [33, 43], [33, 50], [33, 51], [34, 35], [34, 36], [34, 39], [34, 40], [34, 47], [34, 49], [35, 38], [35, 47], [35, 48], [35, 49], [36, 41], [36, 45], [36, 46], [36, 47], [36, 48], [37, 40], [37, 41], [37, 43], [37, 44], [37, 45], [37, 49], [37, 50], [37, 51], [38, 43], [38, 47], [38, 48], [38, 51], [39, 40], [39, 44], [39, 45], [39, 49], [39, 51], [40, 42], [40, 44], [40, 45], [40, 46], [40, 47], [40, 48], [41, 44], [41, 45], [41, 46], [41, 47], [41, 49], [42, 43], [42, 44], [42, 45], [43, 45], [43, 46], [43, 47], [44, 49], [44, 50], [44, 51], [45, 47], [45, 50], [45, 51], [46, 48], [46, 49], [46, 51], [47, 51], [49, 50]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l3-s1/solution/solve.sh b/tasks/construct-mc-max-clique-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e2cf35ba7eee25db099d95fed1032909f845dc61 --- /dev/null +++ b/tasks/construct-mc-max-clique-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' +{"clique": [8, 12, 40, 46, 48]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-clique-l3-s1/tests/check.py b/tasks/construct-mc-max-clique-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3f70dbd5b155a3514c2102aa4ad460201495210 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s1/tests/check.py @@ -0,0 +1,18 @@ +"""Clique of size >= k in a given graph (MathConstraint max_clique decision version, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"clique has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) not in E: + raise Invalid(f"vertices {u} and {v} are not adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-clique-l3-s1/tests/instance.json b/tasks/construct-mc-max-clique-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3c89d6ca8d673932e5a600f9388c1066e28a4503 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 52, "k": 5, "edges": [[0, 5], [0, 8], [0, 16], [0, 22], [0, 26], [0, 27], [0, 28], [0, 30], [0, 31], [0, 34], [0, 35], [0, 36], [0, 37], [0, 38], [0, 41], [0, 43], [0, 48], [0, 49], [0, 50], [0, 51], [1, 2], [1, 3], [1, 5], [1, 7], [1, 10], [1, 13], [1, 14], [1, 16], [1, 20], [1, 22], [1, 25], [1, 27], [1, 28], [1, 31], [1, 32], [1, 35], [1, 37], [1, 41], [1, 42], [1, 43], [1, 48], [1, 49], [1, 51], [2, 3], [2, 8], [2, 9], [2, 12], [2, 15], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 25], [2, 26], [2, 28], [2, 32], [2, 38], [2, 39], [2, 45], [2, 47], [2, 49], [2, 50], [3, 7], [3, 9], [3, 11], [3, 13], [3, 15], [3, 17], [3, 18], [3, 20], [3, 21], [3, 22], [3, 23], [3, 25], [3, 26], [3, 30], [3, 34], [3, 40], [3, 41], [3, 44], [3, 47], [3, 48], [3, 49], [3, 51], [4, 5], [4, 8], [4, 12], [4, 14], [4, 15], [4, 16], [4, 17], [4, 22], [4, 23], [4, 24], [4, 25], [4, 27], [4, 31], [4, 42], [4, 43], [4, 44], [4, 46], [4, 47], [4, 48], [4, 50], [4, 51], [5, 6], [5, 7], [5, 8], [5, 10], [5, 14], [5, 16], [5, 23], [5, 26], [5, 28], [5, 29], [5, 30], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [5, 40], [5, 41], [5, 44], [5, 45], [5, 46], [5, 49], [5, 50], [6, 7], [6, 9], [6, 10], [6, 11], [6, 13], [6, 18], [6, 21], [6, 23], [6, 24], [6, 27], [6, 28], [6, 30], [6, 31], [6, 36], [6, 45], [6, 48], [6, 49], [6, 51], [7, 8], [7, 9], [7, 10], [7, 14], [7, 15], [7, 16], [7, 17], [7, 22], [7, 23], [7, 25], [7, 26], [7, 27], [7, 30], [7, 37], [7, 43], [7, 44], [7, 46], [7, 48], [7, 49], [8, 9], [8, 12], [8, 14], [8, 18], [8, 20], [8, 22], [8, 24], [8, 29], [8, 31], [8, 37], [8, 40], [8, 41], [8, 43], [8, 46], [8, 48], [9, 14], [9, 15], [9, 20], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [9, 30], [9, 34], [9, 37], [9, 39], [9, 40], [9, 41], [9, 43], [9, 44], [9, 51], [10, 11], [10, 13], [10, 20], [10, 22], [10, 23], [10, 24], [10, 25], [10, 29], [10, 36], [10, 39], [10, 40], [10, 41], [10, 42], [10, 43], [10, 48], [10, 49], [10, 51], [11, 13], [11, 16], [11, 19], [11, 20], [11, 21], [11, 23], [11, 24], [11, 26], [11, 27], [11, 29], [11, 31], [11, 32], [11, 34], [11, 35], [11, 38], [11, 42], [11, 46], [11, 48], [11, 49], [11, 51], [12, 13], [12, 15], [12, 17], [12, 19], [12, 21], [12, 24], [12, 25], [12, 32], [12, 35], [12, 36], [12, 37], [12, 39], [12, 40], [12, 41], [12, 43], [12, 46], [12, 47], [12, 48], [12, 49], [13, 18], [13, 19], [13, 23], [13, 25], [13, 26], [13, 29], [13, 30], [13, 32], [13, 34], [13, 36], [13, 38], [13, 41], [13, 42], [13, 45], [14, 16], [14, 18], [14, 19], [14, 21], [14, 24], [14, 29], [14, 30], [14, 33], [14, 34], [14, 35], [14, 37], [14, 39], [14, 40], [14, 44], [14, 45], [14, 48], [15, 16], [15, 17], [15, 19], [15, 20], [15, 23], [15, 28], [15, 30], [15, 32], [15, 36], [15, 37], [15, 38], [15, 39], [15, 46], [15, 47], [15, 48], [16, 18], [16, 20], [16, 23], [16, 24], [16, 26], [16, 28], [16, 29], [16, 35], [16, 36], [16, 43], [16, 44], [16, 50], [16, 51], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 25], [17, 27], [17, 30], [17, 38], [17, 42], [17, 50], [17, 51], [18, 19], [18, 20], [18, 21], [18, 27], [18, 28], [18, 29], [18, 30], [18, 35], [18, 41], [18, 42], [18, 43], [18, 47], [18, 49], [18, 50], [18, 51], [19, 20], [19, 26], [19, 36], [19, 37], [19, 39], [19, 43], [19, 44], [19, 47], [19, 49], [20, 22], [20, 27], [20, 35], [20, 38], [20, 39], [20, 40], [20, 41], [20, 44], [20, 45], [20, 50], [21, 23], [21, 24], [21, 26], [21, 27], [21, 28], [21, 29], [21, 33], [21, 37], [21, 42], [21, 43], [21, 44], [21, 46], [21, 47], [21, 50], [22, 23], [22, 26], [22, 31], [22, 33], [22, 35], [22, 44], [22, 45], [22, 47], [23, 24], [23, 25], [23, 29], [23, 35], [23, 37], [23, 39], [23, 42], [23, 44], [23, 45], [23, 51], [24, 26], [24, 31], [24, 34], [24, 35], [24, 40], [24, 42], [24, 43], [24, 44], [24, 45], [25, 31], [25, 32], [25, 36], [25, 38], [25, 42], [25, 44], [25, 45], [25, 49], [25, 51], [26, 27], [26, 32], [26, 34], [26, 38], [26, 40], [26, 42], [26, 43], [26, 47], [27, 32], [27, 34], [27, 37], [27, 38], [27, 39], [27, 41], [27, 42], [27, 43], [28, 29], [28, 30], [28, 32], [28, 36], [28, 46], [28, 49], [29, 30], [29, 31], [29, 32], [29, 34], [29, 35], [29, 36], [29, 38], [29, 42], [29, 44], [29, 45], [29, 48], [30, 36], [30, 38], [30, 42], [30, 43], [30, 44], [30, 45], [30, 46], [30, 48], [30, 51], [31, 32], [31, 33], [31, 37], [31, 38], [31, 42], [31, 44], [31, 45], [31, 48], [31, 49], [31, 50], [31, 51], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 38], [32, 42], [32, 43], [32, 44], [32, 49], [32, 50], [33, 34], [33, 35], [33, 41], [33, 43], [33, 50], [33, 51], [34, 35], [34, 36], [34, 39], [34, 40], [34, 47], [34, 49], [35, 38], [35, 47], [35, 48], [35, 49], [36, 41], [36, 45], [36, 46], [36, 47], [36, 48], [37, 40], [37, 41], [37, 43], [37, 44], [37, 45], [37, 49], [37, 50], [37, 51], [38, 43], [38, 47], [38, 48], [38, 51], [39, 40], [39, 44], [39, 45], [39, 49], [39, 51], [40, 42], [40, 44], [40, 45], [40, 46], [40, 47], [40, 48], [41, 44], [41, 45], [41, 46], [41, 47], [41, 49], [42, 43], [42, 44], [42, 45], [43, 45], [43, 46], [43, 47], [44, 49], [44, 50], [44, 51], [45, 47], [45, 50], [45, 51], [46, 48], [46, 49], [46, 51], [47, 51], [49, 50]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l3-s1/tests/run.py b/tasks/construct-mc-max-clique-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-clique-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-max-clique-l3-s1/tests/test.sh b/tasks/construct-mc-max-clique-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-clique-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-max-clique-l3-s6/environment/Dockerfile b/tasks/construct-mc-max-clique-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-clique-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-clique-l3-s6/environment/instance.json b/tasks/construct-mc-max-clique-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..29baed4614a1cb290ec7547d7e7f3920db3ef3b7 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 46, "k": 7, "edges": [[0, 6], [0, 7], [0, 9], [0, 10], [0, 12], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 30], [0, 32], [0, 33], [0, 36], [0, 37], [0, 39], [0, 41], [0, 42], [0, 43], [0, 44], [1, 3], [1, 4], [1, 5], [1, 7], [1, 8], [1, 9], [1, 10], [1, 12], [1, 13], [1, 14], [1, 15], [1, 18], [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, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 41], [1, 42], [1, 43], [1, 44], [1, 45], [2, 3], [2, 4], [2, 7], [2, 8], [2, 9], [2, 13], [2, 14], [2, 15], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 26], [2, 27], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 36], [2, 39], [2, 40], [2, 41], [3, 5], [3, 7], [3, 8], [3, 10], [3, 12], [3, 13], [3, 14], [3, 16], [3, 18], [3, 19], [3, 21], [3, 22], [3, 24], [3, 27], [3, 28], [3, 29], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 40], [3, 42], [3, 43], [3, 44], [4, 7], [4, 11], [4, 12], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 23], [4, 24], [4, 25], [4, 26], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 44], [4, 45], [5, 6], [5, 8], [5, 9], [5, 10], [5, 18], [5, 20], [5, 21], [5, 22], [5, 23], [5, 25], [5, 26], [5, 27], [5, 28], [5, 29], [5, 30], [5, 33], [5, 36], [5, 38], [5, 39], [5, 40], [5, 41], [5, 42], [5, 43], [5, 44], [5, 45], [6, 7], [6, 10], [6, 11], [6, 12], [6, 14], [6, 16], [6, 18], [6, 19], [6, 20], [6, 23], [6, 25], [6, 27], [6, 28], [6, 31], [6, 33], [6, 34], [6, 36], [6, 37], [6, 40], [6, 42], [6, 43], [6, 45], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 14], [7, 15], [7, 16], [7, 18], [7, 23], [7, 29], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [7, 39], [7, 40], [7, 43], [7, 44], [8, 12], [8, 13], [8, 14], [8, 18], [8, 20], [8, 23], [8, 24], [8, 25], [8, 27], [8, 28], [8, 29], [8, 32], [8, 34], [8, 37], [8, 38], [8, 39], [8, 40], [8, 41], [8, 43], [8, 45], [9, 11], [9, 12], [9, 14], [9, 15], [9, 16], [9, 18], [9, 19], [9, 20], [9, 24], [9, 27], [9, 28], [9, 29], [9, 31], [9, 32], [9, 34], [9, 36], [9, 37], [9, 38], [9, 39], [9, 40], [9, 41], [9, 42], [9, 43], [9, 44], [10, 12], [10, 14], [10, 15], [10, 17], [10, 20], [10, 21], [10, 22], [10, 28], [10, 32], [10, 33], [10, 35], [10, 37], [10, 38], [10, 40], [10, 43], [11, 12], [11, 13], [11, 14], [11, 19], [11, 20], [11, 21], [11, 25], [11, 26], [11, 27], [11, 28], [11, 30], [11, 31], [11, 32], [11, 33], [11, 36], [11, 37], [11, 39], [11, 41], [11, 42], [11, 43], [11, 45], [12, 14], [12, 15], [12, 16], [12, 18], [12, 19], [12, 20], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [12, 38], [12, 40], [12, 41], [12, 42], [12, 43], [12, 44], [12, 45], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 24], [13, 27], [13, 28], [13, 29], [13, 30], [13, 31], [13, 32], [13, 35], [13, 36], [13, 37], [13, 38], [13, 39], [13, 40], [13, 41], [13, 42], [13, 43], [13, 45], [14, 15], [14, 16], [14, 17], [14, 19], [14, 21], [14, 23], [14, 25], [14, 26], [14, 29], [14, 32], [14, 33], [14, 36], [14, 37], [14, 44], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 28], [15, 29], [15, 30], [15, 32], [15, 34], [15, 35], [15, 36], [15, 37], [15, 39], [15, 40], [15, 41], [15, 43], [15, 44], [15, 45], [16, 18], [16, 21], [16, 22], [16, 23], [16, 25], [16, 26], [16, 29], [16, 31], [16, 32], [16, 34], [16, 35], [16, 36], [16, 38], [16, 39], [16, 41], [16, 43], [16, 44], [16, 45], [17, 18], [17, 19], [17, 24], [17, 25], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 36], [17, 37], [17, 39], [17, 40], [17, 41], [17, 42], [17, 43], [17, 44], [17, 45], [18, 19], [18, 22], [18, 23], [18, 25], [18, 28], [18, 29], [18, 30], [18, 32], [18, 33], [18, 34], [18, 35], [18, 37], [18, 38], [18, 42], [18, 43], [18, 45], [19, 21], [19, 23], [19, 24], [19, 26], [19, 27], [19, 28], [19, 29], [19, 30], [19, 31], [19, 32], [19, 33], [19, 34], [19, 35], [19, 38], [19, 39], [19, 41], [19, 42], [20, 23], [20, 25], [20, 26], [20, 27], [20, 28], [20, 31], [20, 33], [20, 35], [20, 36], [20, 39], [20, 40], [20, 41], [20, 43], [20, 44], [20, 45], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 29], [21, 31], [21, 33], [21, 34], [21, 35], [21, 40], [21, 41], [21, 42], [21, 43], [21, 44], [21, 45], [22, 26], [22, 28], [22, 31], [22, 32], [22, 33], [22, 35], [22, 36], [22, 38], [22, 41], [22, 42], [22, 43], [22, 44], [22, 45], [23, 24], [23, 28], [23, 29], [23, 30], [23, 31], [23, 32], [23, 33], [23, 34], [23, 36], [23, 37], [23, 40], [23, 42], [24, 25], [24, 26], [24, 28], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [24, 36], [24, 37], [24, 38], [24, 39], [24, 42], [24, 43], [24, 44], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 34], [25, 36], [25, 41], [25, 42], [25, 45], [26, 27], [26, 28], [26, 29], [26, 31], [26, 32], [26, 33], [26, 34], [26, 37], [26, 40], [26, 41], [26, 43], [26, 45], [27, 29], [27, 31], [27, 32], [27, 33], [27, 34], [27, 38], [27, 39], [27, 40], [27, 41], [27, 43], [27, 45], [28, 29], [28, 30], [28, 31], [28, 32], [28, 35], [28, 37], [28, 39], [28, 40], [28, 42], [28, 43], [28, 44], [28, 45], [29, 30], [29, 33], [29, 35], [29, 36], [29, 37], [29, 38], [29, 41], [29, 44], [29, 45], [30, 31], [30, 32], [30, 34], [30, 37], [30, 38], [30, 42], [30, 44], [31, 32], [31, 33], [31, 34], [31, 35], [31, 36], [31, 38], [31, 39], [31, 40], [31, 41], [31, 42], [32, 33], [32, 34], [32, 35], [32, 37], [32, 38], [32, 40], [32, 41], [32, 43], [32, 44], [32, 45], [33, 34], [33, 35], [33, 37], [33, 38], [33, 39], [33, 40], [33, 41], [33, 43], [33, 44], [33, 45], [34, 35], [34, 38], [34, 39], [34, 41], [34, 44], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 42], [35, 44], [36, 39], [36, 40], [36, 41], [36, 42], [36, 43], [36, 45], [37, 40], [37, 41], [37, 43], [37, 45], [38, 39], [38, 41], [38, 43], [38, 44], [38, 45], [39, 40], [39, 41], [39, 42], [39, 43], [39, 44], [39, 45], [40, 41], [40, 42], [40, 43], [40, 44], [41, 42], [41, 44], [41, 45], [42, 43], [42, 44], [43, 44]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l3-s6/solution/solve.sh b/tasks/construct-mc-max-clique-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5d35de93d864bdfd28b02b998460183aea12927d --- /dev/null +++ b/tasks/construct-mc-max-clique-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' +{"clique": [33, 34, 35, 38, 39, 41, 44]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-clique-l3-s6/tests/check.py b/tasks/construct-mc-max-clique-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3f70dbd5b155a3514c2102aa4ad460201495210 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s6/tests/check.py @@ -0,0 +1,18 @@ +"""Clique of size >= k in a given graph (MathConstraint max_clique decision version, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"clique has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) not in E: + raise Invalid(f"vertices {u} and {v} are not adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-clique-l3-s6/tests/instance.json b/tasks/construct-mc-max-clique-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..29baed4614a1cb290ec7547d7e7f3920db3ef3b7 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 46, "k": 7, "edges": [[0, 6], [0, 7], [0, 9], [0, 10], [0, 12], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 30], [0, 32], [0, 33], [0, 36], [0, 37], [0, 39], [0, 41], [0, 42], [0, 43], [0, 44], [1, 3], [1, 4], [1, 5], [1, 7], [1, 8], [1, 9], [1, 10], [1, 12], [1, 13], [1, 14], [1, 15], [1, 18], [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, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 41], [1, 42], [1, 43], [1, 44], [1, 45], [2, 3], [2, 4], [2, 7], [2, 8], [2, 9], [2, 13], [2, 14], [2, 15], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 26], [2, 27], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 36], [2, 39], [2, 40], [2, 41], [3, 5], [3, 7], [3, 8], [3, 10], [3, 12], [3, 13], [3, 14], [3, 16], [3, 18], [3, 19], [3, 21], [3, 22], [3, 24], [3, 27], [3, 28], [3, 29], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 40], [3, 42], [3, 43], [3, 44], [4, 7], [4, 11], [4, 12], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 23], [4, 24], [4, 25], [4, 26], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 44], [4, 45], [5, 6], [5, 8], [5, 9], [5, 10], [5, 18], [5, 20], [5, 21], [5, 22], [5, 23], [5, 25], [5, 26], [5, 27], [5, 28], [5, 29], [5, 30], [5, 33], [5, 36], [5, 38], [5, 39], [5, 40], [5, 41], [5, 42], [5, 43], [5, 44], [5, 45], [6, 7], [6, 10], [6, 11], [6, 12], [6, 14], [6, 16], [6, 18], [6, 19], [6, 20], [6, 23], [6, 25], [6, 27], [6, 28], [6, 31], [6, 33], [6, 34], [6, 36], [6, 37], [6, 40], [6, 42], [6, 43], [6, 45], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 14], [7, 15], [7, 16], [7, 18], [7, 23], [7, 29], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [7, 39], [7, 40], [7, 43], [7, 44], [8, 12], [8, 13], [8, 14], [8, 18], [8, 20], [8, 23], [8, 24], [8, 25], [8, 27], [8, 28], [8, 29], [8, 32], [8, 34], [8, 37], [8, 38], [8, 39], [8, 40], [8, 41], [8, 43], [8, 45], [9, 11], [9, 12], [9, 14], [9, 15], [9, 16], [9, 18], [9, 19], [9, 20], [9, 24], [9, 27], [9, 28], [9, 29], [9, 31], [9, 32], [9, 34], [9, 36], [9, 37], [9, 38], [9, 39], [9, 40], [9, 41], [9, 42], [9, 43], [9, 44], [10, 12], [10, 14], [10, 15], [10, 17], [10, 20], [10, 21], [10, 22], [10, 28], [10, 32], [10, 33], [10, 35], [10, 37], [10, 38], [10, 40], [10, 43], [11, 12], [11, 13], [11, 14], [11, 19], [11, 20], [11, 21], [11, 25], [11, 26], [11, 27], [11, 28], [11, 30], [11, 31], [11, 32], [11, 33], [11, 36], [11, 37], [11, 39], [11, 41], [11, 42], [11, 43], [11, 45], [12, 14], [12, 15], [12, 16], [12, 18], [12, 19], [12, 20], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [12, 38], [12, 40], [12, 41], [12, 42], [12, 43], [12, 44], [12, 45], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 24], [13, 27], [13, 28], [13, 29], [13, 30], [13, 31], [13, 32], [13, 35], [13, 36], [13, 37], [13, 38], [13, 39], [13, 40], [13, 41], [13, 42], [13, 43], [13, 45], [14, 15], [14, 16], [14, 17], [14, 19], [14, 21], [14, 23], [14, 25], [14, 26], [14, 29], [14, 32], [14, 33], [14, 36], [14, 37], [14, 44], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 28], [15, 29], [15, 30], [15, 32], [15, 34], [15, 35], [15, 36], [15, 37], [15, 39], [15, 40], [15, 41], [15, 43], [15, 44], [15, 45], [16, 18], [16, 21], [16, 22], [16, 23], [16, 25], [16, 26], [16, 29], [16, 31], [16, 32], [16, 34], [16, 35], [16, 36], [16, 38], [16, 39], [16, 41], [16, 43], [16, 44], [16, 45], [17, 18], [17, 19], [17, 24], [17, 25], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 36], [17, 37], [17, 39], [17, 40], [17, 41], [17, 42], [17, 43], [17, 44], [17, 45], [18, 19], [18, 22], [18, 23], [18, 25], [18, 28], [18, 29], [18, 30], [18, 32], [18, 33], [18, 34], [18, 35], [18, 37], [18, 38], [18, 42], [18, 43], [18, 45], [19, 21], [19, 23], [19, 24], [19, 26], [19, 27], [19, 28], [19, 29], [19, 30], [19, 31], [19, 32], [19, 33], [19, 34], [19, 35], [19, 38], [19, 39], [19, 41], [19, 42], [20, 23], [20, 25], [20, 26], [20, 27], [20, 28], [20, 31], [20, 33], [20, 35], [20, 36], [20, 39], [20, 40], [20, 41], [20, 43], [20, 44], [20, 45], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 29], [21, 31], [21, 33], [21, 34], [21, 35], [21, 40], [21, 41], [21, 42], [21, 43], [21, 44], [21, 45], [22, 26], [22, 28], [22, 31], [22, 32], [22, 33], [22, 35], [22, 36], [22, 38], [22, 41], [22, 42], [22, 43], [22, 44], [22, 45], [23, 24], [23, 28], [23, 29], [23, 30], [23, 31], [23, 32], [23, 33], [23, 34], [23, 36], [23, 37], [23, 40], [23, 42], [24, 25], [24, 26], [24, 28], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [24, 36], [24, 37], [24, 38], [24, 39], [24, 42], [24, 43], [24, 44], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 34], [25, 36], [25, 41], [25, 42], [25, 45], [26, 27], [26, 28], [26, 29], [26, 31], [26, 32], [26, 33], [26, 34], [26, 37], [26, 40], [26, 41], [26, 43], [26, 45], [27, 29], [27, 31], [27, 32], [27, 33], [27, 34], [27, 38], [27, 39], [27, 40], [27, 41], [27, 43], [27, 45], [28, 29], [28, 30], [28, 31], [28, 32], [28, 35], [28, 37], [28, 39], [28, 40], [28, 42], [28, 43], [28, 44], [28, 45], [29, 30], [29, 33], [29, 35], [29, 36], [29, 37], [29, 38], [29, 41], [29, 44], [29, 45], [30, 31], [30, 32], [30, 34], [30, 37], [30, 38], [30, 42], [30, 44], [31, 32], [31, 33], [31, 34], [31, 35], [31, 36], [31, 38], [31, 39], [31, 40], [31, 41], [31, 42], [32, 33], [32, 34], [32, 35], [32, 37], [32, 38], [32, 40], [32, 41], [32, 43], [32, 44], [32, 45], [33, 34], [33, 35], [33, 37], [33, 38], [33, 39], [33, 40], [33, 41], [33, 43], [33, 44], [33, 45], [34, 35], [34, 38], [34, 39], [34, 41], [34, 44], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 42], [35, 44], [36, 39], [36, 40], [36, 41], [36, 42], [36, 43], [36, 45], [37, 40], [37, 41], [37, 43], [37, 45], [38, 39], [38, 41], [38, 43], [38, 44], [38, 45], [39, 40], [39, 41], [39, 42], [39, 43], [39, 44], [39, 45], [40, 41], [40, 42], [40, 43], [40, 44], [41, 42], [41, 44], [41, 45], [42, 43], [42, 44], [43, 44]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l3-s6/tests/run.py b/tasks/construct-mc-max-clique-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-clique-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-clique-l3-s6/tests/test.sh b/tasks/construct-mc-max-clique-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-clique-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-s1/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-max-independent-set-l3-s1/environment/instance.json b/tasks/construct-mc-max-independent-set-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..87deca068a1fee58be7ee0f2769d248426362312 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 45, "k": 11, "edges": [[0, 11], [0, 16], [0, 17], [0, 19], [0, 22], [0, 25], [0, 26], [0, 27], [0, 31], [0, 32], [0, 34], [0, 36], [0, 37], [0, 40], [0, 44], [1, 2], [1, 4], [1, 10], [1, 11], [1, 14], [1, 18], [1, 19], [1, 20], [1, 21], [1, 28], [1, 30], [1, 37], [1, 39], [1, 40], [1, 42], [2, 3], [2, 7], [2, 13], [2, 14], [2, 18], [2, 22], [2, 33], [2, 37], [2, 41], [2, 43], [3, 4], [3, 14], [3, 16], [3, 19], [3, 22], [3, 25], [3, 32], [3, 34], [3, 37], [3, 39], [3, 42], [3, 43], [4, 7], [4, 9], [4, 12], [4, 22], [4, 24], [4, 29], [4, 30], [4, 39], [4, 43], [5, 6], [5, 7], [5, 12], [5, 14], [5, 27], [5, 28], [5, 30], [5, 35], [5, 37], [5, 39], [6, 8], [6, 9], [6, 15], [6, 18], [6, 19], [6, 27], [6, 36], [6, 40], [6, 41], [6, 44], [7, 8], [7, 9], [7, 11], [7, 14], [7, 16], [7, 17], [7, 20], [7, 25], [7, 28], [7, 29], [7, 31], [7, 39], [8, 21], [8, 28], [8, 30], [8, 31], [8, 35], [8, 36], [8, 38], [8, 39], [8, 42], [8, 43], [9, 12], [9, 14], [9, 16], [9, 20], [9, 21], [9, 31], [9, 37], [9, 38], [10, 13], [10, 18], [10, 23], [10, 38], [10, 42], [11, 13], [11, 15], [11, 16], [11, 19], [11, 23], [11, 24], [11, 25], [11, 31], [11, 35], [11, 38], [11, 43], [12, 13], [12, 19], [12, 20], [12, 23], [12, 24], [12, 28], [12, 30], [12, 32], [12, 33], [12, 38], [12, 39], [12, 40], [12, 41], [12, 44], [13, 21], [13, 32], [14, 17], [14, 18], [14, 30], [14, 32], [14, 33], [14, 35], [14, 37], [14, 42], [14, 44], [15, 18], [15, 19], [15, 30], [15, 31], [15, 32], [15, 35], [15, 37], [16, 22], [16, 24], [16, 26], [16, 30], [16, 35], [16, 37], [16, 41], [17, 22], [17, 23], [17, 26], [17, 38], [17, 41], [18, 20], [18, 24], [18, 29], [18, 31], [18, 33], [18, 37], [19, 20], [19, 21], [19, 24], [19, 32], [19, 40], [19, 41], [19, 42], [20, 29], [20, 30], [20, 31], [20, 43], [21, 23], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 33], [21, 41], [21, 42], [22, 28], [22, 29], [22, 31], [22, 39], [22, 44], [23, 28], [23, 29], [23, 31], [23, 34], [23, 36], [23, 38], [23, 41], [23, 42], [23, 43], [24, 25], [24, 27], [24, 30], [24, 32], [24, 40], [24, 43], [25, 27], [25, 33], [25, 34], [25, 39], [25, 43], [26, 30], [26, 31], [26, 36], [26, 39], [26, 42], [26, 44], [27, 32], [27, 34], [27, 38], [28, 32], [28, 33], [28, 34], [28, 38], [28, 44], [29, 33], [29, 36], [29, 38], [29, 40], [29, 41], [29, 42], [30, 34], [30, 36], [30, 41], [31, 32], [31, 33], [31, 36], [31, 41], [31, 42], [32, 34], [32, 39], [32, 43], [33, 38], [33, 39], [33, 42], [34, 37], [34, 38], [34, 41], [35, 36], [35, 38], [36, 37], [36, 41], [37, 38], [37, 41], [38, 39], [38, 42], [40, 43], [42, 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-s1/solution/solve.sh b/tasks/construct-mc-max-independent-set-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..80bc74b54c7869aa28158ff5199b3b11d40ccca6 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"independent_set": [2, 4, 5, 10, 11, 17, 20, 34, 36, 40, 44]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l3-s1/tests/check.py b/tasks/construct-mc-max-independent-set-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s1/tests/check.py @@ -0,0 +1,18 @@ +"""Independent set of size >= k in a given graph (MathConstraint max_independent_set, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"set has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) in E: + raise Invalid(f"vertices {u} and {v} are adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-independent-set-l3-s1/tests/instance.json b/tasks/construct-mc-max-independent-set-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..87deca068a1fee58be7ee0f2769d248426362312 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 45, "k": 11, "edges": [[0, 11], [0, 16], [0, 17], [0, 19], [0, 22], [0, 25], [0, 26], [0, 27], [0, 31], [0, 32], [0, 34], [0, 36], [0, 37], [0, 40], [0, 44], [1, 2], [1, 4], [1, 10], [1, 11], [1, 14], [1, 18], [1, 19], [1, 20], [1, 21], [1, 28], [1, 30], [1, 37], [1, 39], [1, 40], [1, 42], [2, 3], [2, 7], [2, 13], [2, 14], [2, 18], [2, 22], [2, 33], [2, 37], [2, 41], [2, 43], [3, 4], [3, 14], [3, 16], [3, 19], [3, 22], [3, 25], [3, 32], [3, 34], [3, 37], [3, 39], [3, 42], [3, 43], [4, 7], [4, 9], [4, 12], [4, 22], [4, 24], [4, 29], [4, 30], [4, 39], [4, 43], [5, 6], [5, 7], [5, 12], [5, 14], [5, 27], [5, 28], [5, 30], [5, 35], [5, 37], [5, 39], [6, 8], [6, 9], [6, 15], [6, 18], [6, 19], [6, 27], [6, 36], [6, 40], [6, 41], [6, 44], [7, 8], [7, 9], [7, 11], [7, 14], [7, 16], [7, 17], [7, 20], [7, 25], [7, 28], [7, 29], [7, 31], [7, 39], [8, 21], [8, 28], [8, 30], [8, 31], [8, 35], [8, 36], [8, 38], [8, 39], [8, 42], [8, 43], [9, 12], [9, 14], [9, 16], [9, 20], [9, 21], [9, 31], [9, 37], [9, 38], [10, 13], [10, 18], [10, 23], [10, 38], [10, 42], [11, 13], [11, 15], [11, 16], [11, 19], [11, 23], [11, 24], [11, 25], [11, 31], [11, 35], [11, 38], [11, 43], [12, 13], [12, 19], [12, 20], [12, 23], [12, 24], [12, 28], [12, 30], [12, 32], [12, 33], [12, 38], [12, 39], [12, 40], [12, 41], [12, 44], [13, 21], [13, 32], [14, 17], [14, 18], [14, 30], [14, 32], [14, 33], [14, 35], [14, 37], [14, 42], [14, 44], [15, 18], [15, 19], [15, 30], [15, 31], [15, 32], [15, 35], [15, 37], [16, 22], [16, 24], [16, 26], [16, 30], [16, 35], [16, 37], [16, 41], [17, 22], [17, 23], [17, 26], [17, 38], [17, 41], [18, 20], [18, 24], [18, 29], [18, 31], [18, 33], [18, 37], [19, 20], [19, 21], [19, 24], [19, 32], [19, 40], [19, 41], [19, 42], [20, 29], [20, 30], [20, 31], [20, 43], [21, 23], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 33], [21, 41], [21, 42], [22, 28], [22, 29], [22, 31], [22, 39], [22, 44], [23, 28], [23, 29], [23, 31], [23, 34], [23, 36], [23, 38], [23, 41], [23, 42], [23, 43], [24, 25], [24, 27], [24, 30], [24, 32], [24, 40], [24, 43], [25, 27], [25, 33], [25, 34], [25, 39], [25, 43], [26, 30], [26, 31], [26, 36], [26, 39], [26, 42], [26, 44], [27, 32], [27, 34], [27, 38], [28, 32], [28, 33], [28, 34], [28, 38], [28, 44], [29, 33], [29, 36], [29, 38], [29, 40], [29, 41], [29, 42], [30, 34], [30, 36], [30, 41], [31, 32], [31, 33], [31, 36], [31, 41], [31, 42], [32, 34], [32, 39], [32, 43], [33, 38], [33, 39], [33, 42], [34, 37], [34, 38], [34, 41], [35, 36], [35, 38], [36, 37], [36, 41], [37, 38], [37, 41], [38, 39], [38, 42], [40, 43], [42, 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-s1/tests/run.py b/tasks/construct-mc-max-independent-set-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-max-independent-set-l3-s1/tests/test.sh b/tasks/construct-mc-max-independent-set-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l3-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-max-independent-set-l4-s2/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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-independent-set-l4-s2/environment/instance.json b/tasks/construct-mc-max-independent-set-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..752c2e51e798d878d09176d562844a5105de8e14 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 7], [0, 10], [0, 13], [0, 14], [0, 16], [0, 19], [0, 21], [0, 24], [0, 26], [0, 32], [0, 40], [0, 42], [0, 43], [0, 45], [0, 59], [1, 12], [1, 13], [1, 15], [1, 16], [1, 17], [1, 20], [1, 22], [1, 28], [1, 31], [1, 46], [1, 52], [1, 54], [1, 57], [2, 3], [2, 4], [2, 11], [2, 14], [2, 19], [2, 26], [2, 27], [2, 28], [2, 30], [2, 46], [2, 47], [2, 48], [2, 49], [2, 51], [2, 56], [2, 58], [3, 4], [3, 7], [3, 12], [3, 15], [3, 17], [3, 18], [3, 21], [3, 22], [3, 31], [3, 35], [3, 36], [3, 37], [3, 45], [3, 51], [3, 53], [3, 54], [3, 56], [3, 58], [4, 5], [4, 14], [4, 17], [4, 19], [4, 22], [4, 23], [4, 29], [4, 30], [4, 31], [4, 32], [4, 36], [4, 40], [4, 43], [4, 48], [4, 49], [4, 54], [4, 55], [4, 57], [5, 9], [5, 10], [5, 17], [5, 18], [5, 19], [5, 20], [5, 23], [5, 30], [5, 31], [5, 33], [5, 35], [5, 36], [5, 37], [5, 38], [5, 39], [5, 43], [5, 48], [5, 56], [5, 58], [6, 7], [6, 9], [6, 16], [6, 18], [6, 20], [6, 23], [6, 26], [6, 31], [6, 41], [6, 46], [6, 47], [6, 54], [6, 59], [7, 12], [7, 16], [7, 18], [7, 24], [7, 27], [7, 30], [7, 31], [7, 36], [7, 38], [7, 44], [7, 45], [7, 49], [7, 50], [7, 53], [7, 55], [7, 57], [8, 12], [8, 23], [8, 24], [8, 27], [8, 32], [8, 34], [8, 36], [8, 41], [8, 43], [8, 44], [8, 47], [8, 50], [8, 51], [8, 55], [8, 56], [8, 58], [8, 59], [9, 13], [9, 15], [9, 21], [9, 26], [9, 28], [9, 30], [9, 45], [9, 47], [9, 50], [10, 19], [10, 21], [10, 25], [10, 38], [10, 58], [11, 24], [11, 34], [11, 38], [11, 41], [11, 45], [11, 49], [11, 53], [11, 59], [12, 16], [12, 25], [12, 26], [12, 29], [12, 42], [12, 48], [12, 55], [12, 57], [12, 59], [13, 17], [13, 30], [13, 35], [13, 36], [13, 40], [13, 44], [13, 46], [13, 47], [13, 53], [13, 55], [14, 15], [14, 17], [14, 18], [14, 20], [14, 23], [14, 24], [14, 25], [14, 26], [14, 29], [14, 33], [14, 36], [14, 37], [14, 39], [14, 41], [14, 43], [14, 47], [14, 53], [14, 58], [15, 17], [15, 19], [15, 26], [15, 27], [15, 28], [15, 38], [15, 40], [15, 47], [15, 49], [15, 50], [15, 51], [15, 55], [15, 57], [16, 24], [16, 26], [16, 33], [16, 34], [16, 37], [16, 38], [16, 39], [16, 40], [16, 46], [16, 47], [16, 51], [16, 52], [16, 55], [16, 57], [17, 18], [17, 20], [17, 25], [17, 28], [17, 33], [17, 35], [17, 39], [17, 40], [17, 43], [17, 47], [17, 53], [17, 54], [17, 59], [18, 20], [18, 21], [18, 23], [18, 24], [18, 27], [18, 28], [18, 31], [18, 43], [18, 58], [19, 25], [19, 31], [19, 32], [19, 36], [19, 45], [19, 47], [19, 51], [19, 53], [19, 54], [19, 56], [19, 57], [19, 58], [19, 59], [20, 23], [20, 40], [20, 43], [20, 45], [20, 46], [20, 47], [20, 49], [21, 22], [21, 26], [21, 32], [21, 38], [21, 39], [21, 45], [21, 51], [21, 54], [21, 59], [22, 24], [22, 30], [22, 36], [22, 37], [22, 38], [22, 43], [22, 48], [22, 50], [22, 56], [22, 57], [22, 58], [23, 25], [23, 27], [23, 28], [23, 30], [23, 34], [23, 35], [23, 36], [23, 40], [23, 49], [23, 50], [23, 53], [23, 55], [23, 56], [24, 29], [24, 38], [24, 39], [24, 47], [24, 51], [24, 54], [24, 55], [24, 58], [24, 59], [25, 26], [25, 29], [25, 31], [25, 32], [25, 39], [25, 44], [25, 45], [25, 47], [25, 52], [25, 55], [25, 57], [26, 27], [26, 28], [26, 31], [26, 39], [26, 41], [26, 46], [26, 47], [26, 48], [26, 50], [26, 51], [26, 58], [27, 37], [27, 38], [27, 41], [27, 43], [27, 44], [27, 46], [27, 49], [27, 57], [28, 29], [28, 34], [28, 35], [28, 40], [28, 42], [28, 46], [28, 51], [28, 54], [28, 56], [28, 58], [29, 33], [29, 43], [29, 44], [29, 46], [29, 51], [29, 52], [29, 53], [29, 57], [30, 31], [30, 32], [30, 35], [30, 36], [30, 37], [30, 42], [30, 43], [30, 47], [30, 51], [31, 32], [31, 37], [31, 38], [31, 41], [31, 44], [31, 46], [31, 50], [31, 57], [32, 33], [32, 36], [32, 43], [32, 47], [32, 55], [32, 58], [33, 47], [33, 49], [33, 53], [33, 59], [34, 37], [34, 39], [34, 42], [34, 49], [34, 51], [34, 52], [34, 57], [35, 38], [35, 39], [35, 41], [35, 43], [35, 45], [35, 49], [35, 50], [35, 57], [35, 58], [36, 38], [36, 42], [36, 44], [36, 51], [36, 52], [36, 53], [36, 54], [36, 56], [37, 40], [37, 41], [37, 42], [37, 46], [37, 48], [37, 55], [37, 56], [37, 58], [38, 42], [38, 44], [38, 45], [38, 47], [38, 52], [38, 54], [38, 55], [39, 40], [39, 50], [39, 52], [39, 53], [39, 54], [39, 56], [40, 41], [40, 48], [40, 56], [40, 59], [41, 46], [41, 49], [41, 51], [41, 56], [42, 48], [42, 53], [43, 50], [43, 54], [43, 57], [43, 59], [44, 54], [44, 55], [45, 49], [45, 52], [45, 57], [46, 53], [46, 56], [47, 49], [47, 51], [47, 53], [47, 54], [48, 50], [48, 54], [48, 59], [49, 50], [49, 51], [49, 53], [49, 58], [50, 58], [51, 52], [51, 53], [51, 54], [51, 57], [52, 56], [52, 57], [53, 54], [53, 55], [54, 57], [55, 56], [55, 58], [56, 58]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s2/solution/solve.sh b/tasks/construct-mc-max-independent-set-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c593d687676732799ff1cf484b1a41e204af8e51 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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' +{"independent_set": [2, 10, 13, 15, 16, 18, 22, 29, 32, 41, 42, 45, 54, 59]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l4-s2/tests/check.py b/tasks/construct-mc-max-independent-set-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s2/tests/check.py @@ -0,0 +1,18 @@ +"""Independent set of size >= k in a given graph (MathConstraint max_independent_set, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"set has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) in E: + raise Invalid(f"vertices {u} and {v} are adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-independent-set-l4-s2/tests/instance.json b/tasks/construct-mc-max-independent-set-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..752c2e51e798d878d09176d562844a5105de8e14 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 7], [0, 10], [0, 13], [0, 14], [0, 16], [0, 19], [0, 21], [0, 24], [0, 26], [0, 32], [0, 40], [0, 42], [0, 43], [0, 45], [0, 59], [1, 12], [1, 13], [1, 15], [1, 16], [1, 17], [1, 20], [1, 22], [1, 28], [1, 31], [1, 46], [1, 52], [1, 54], [1, 57], [2, 3], [2, 4], [2, 11], [2, 14], [2, 19], [2, 26], [2, 27], [2, 28], [2, 30], [2, 46], [2, 47], [2, 48], [2, 49], [2, 51], [2, 56], [2, 58], [3, 4], [3, 7], [3, 12], [3, 15], [3, 17], [3, 18], [3, 21], [3, 22], [3, 31], [3, 35], [3, 36], [3, 37], [3, 45], [3, 51], [3, 53], [3, 54], [3, 56], [3, 58], [4, 5], [4, 14], [4, 17], [4, 19], [4, 22], [4, 23], [4, 29], [4, 30], [4, 31], [4, 32], [4, 36], [4, 40], [4, 43], [4, 48], [4, 49], [4, 54], [4, 55], [4, 57], [5, 9], [5, 10], [5, 17], [5, 18], [5, 19], [5, 20], [5, 23], [5, 30], [5, 31], [5, 33], [5, 35], [5, 36], [5, 37], [5, 38], [5, 39], [5, 43], [5, 48], [5, 56], [5, 58], [6, 7], [6, 9], [6, 16], [6, 18], [6, 20], [6, 23], [6, 26], [6, 31], [6, 41], [6, 46], [6, 47], [6, 54], [6, 59], [7, 12], [7, 16], [7, 18], [7, 24], [7, 27], [7, 30], [7, 31], [7, 36], [7, 38], [7, 44], [7, 45], [7, 49], [7, 50], [7, 53], [7, 55], [7, 57], [8, 12], [8, 23], [8, 24], [8, 27], [8, 32], [8, 34], [8, 36], [8, 41], [8, 43], [8, 44], [8, 47], [8, 50], [8, 51], [8, 55], [8, 56], [8, 58], [8, 59], [9, 13], [9, 15], [9, 21], [9, 26], [9, 28], [9, 30], [9, 45], [9, 47], [9, 50], [10, 19], [10, 21], [10, 25], [10, 38], [10, 58], [11, 24], [11, 34], [11, 38], [11, 41], [11, 45], [11, 49], [11, 53], [11, 59], [12, 16], [12, 25], [12, 26], [12, 29], [12, 42], [12, 48], [12, 55], [12, 57], [12, 59], [13, 17], [13, 30], [13, 35], [13, 36], [13, 40], [13, 44], [13, 46], [13, 47], [13, 53], [13, 55], [14, 15], [14, 17], [14, 18], [14, 20], [14, 23], [14, 24], [14, 25], [14, 26], [14, 29], [14, 33], [14, 36], [14, 37], [14, 39], [14, 41], [14, 43], [14, 47], [14, 53], [14, 58], [15, 17], [15, 19], [15, 26], [15, 27], [15, 28], [15, 38], [15, 40], [15, 47], [15, 49], [15, 50], [15, 51], [15, 55], [15, 57], [16, 24], [16, 26], [16, 33], [16, 34], [16, 37], [16, 38], [16, 39], [16, 40], [16, 46], [16, 47], [16, 51], [16, 52], [16, 55], [16, 57], [17, 18], [17, 20], [17, 25], [17, 28], [17, 33], [17, 35], [17, 39], [17, 40], [17, 43], [17, 47], [17, 53], [17, 54], [17, 59], [18, 20], [18, 21], [18, 23], [18, 24], [18, 27], [18, 28], [18, 31], [18, 43], [18, 58], [19, 25], [19, 31], [19, 32], [19, 36], [19, 45], [19, 47], [19, 51], [19, 53], [19, 54], [19, 56], [19, 57], [19, 58], [19, 59], [20, 23], [20, 40], [20, 43], [20, 45], [20, 46], [20, 47], [20, 49], [21, 22], [21, 26], [21, 32], [21, 38], [21, 39], [21, 45], [21, 51], [21, 54], [21, 59], [22, 24], [22, 30], [22, 36], [22, 37], [22, 38], [22, 43], [22, 48], [22, 50], [22, 56], [22, 57], [22, 58], [23, 25], [23, 27], [23, 28], [23, 30], [23, 34], [23, 35], [23, 36], [23, 40], [23, 49], [23, 50], [23, 53], [23, 55], [23, 56], [24, 29], [24, 38], [24, 39], [24, 47], [24, 51], [24, 54], [24, 55], [24, 58], [24, 59], [25, 26], [25, 29], [25, 31], [25, 32], [25, 39], [25, 44], [25, 45], [25, 47], [25, 52], [25, 55], [25, 57], [26, 27], [26, 28], [26, 31], [26, 39], [26, 41], [26, 46], [26, 47], [26, 48], [26, 50], [26, 51], [26, 58], [27, 37], [27, 38], [27, 41], [27, 43], [27, 44], [27, 46], [27, 49], [27, 57], [28, 29], [28, 34], [28, 35], [28, 40], [28, 42], [28, 46], [28, 51], [28, 54], [28, 56], [28, 58], [29, 33], [29, 43], [29, 44], [29, 46], [29, 51], [29, 52], [29, 53], [29, 57], [30, 31], [30, 32], [30, 35], [30, 36], [30, 37], [30, 42], [30, 43], [30, 47], [30, 51], [31, 32], [31, 37], [31, 38], [31, 41], [31, 44], [31, 46], [31, 50], [31, 57], [32, 33], [32, 36], [32, 43], [32, 47], [32, 55], [32, 58], [33, 47], [33, 49], [33, 53], [33, 59], [34, 37], [34, 39], [34, 42], [34, 49], [34, 51], [34, 52], [34, 57], [35, 38], [35, 39], [35, 41], [35, 43], [35, 45], [35, 49], [35, 50], [35, 57], [35, 58], [36, 38], [36, 42], [36, 44], [36, 51], [36, 52], [36, 53], [36, 54], [36, 56], [37, 40], [37, 41], [37, 42], [37, 46], [37, 48], [37, 55], [37, 56], [37, 58], [38, 42], [38, 44], [38, 45], [38, 47], [38, 52], [38, 54], [38, 55], [39, 40], [39, 50], [39, 52], [39, 53], [39, 54], [39, 56], [40, 41], [40, 48], [40, 56], [40, 59], [41, 46], [41, 49], [41, 51], [41, 56], [42, 48], [42, 53], [43, 50], [43, 54], [43, 57], [43, 59], [44, 54], [44, 55], [45, 49], [45, 52], [45, 57], [46, 53], [46, 56], [47, 49], [47, 51], [47, 53], [47, 54], [48, 50], [48, 54], [48, 59], [49, 50], [49, 51], [49, 53], [49, 58], [50, 58], [51, 52], [51, 53], [51, 54], [51, 57], [52, 56], [52, 57], [53, 54], [53, 55], [54, 57], [55, 56], [55, 58], [56, 58]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s2/tests/run.py b/tasks/construct-mc-max-independent-set-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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-independent-set-l4-s2/tests/test.sh b/tasks/construct-mc-max-independent-set-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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-independent-set-l4-s5/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l4-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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-independent-set-l4-s5/environment/instance.json b/tasks/construct-mc-max-independent-set-l4-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ac83e2eb7301dc2c2410b3141d671e2a5cca66d7 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 1], [0, 5], [0, 10], [0, 16], [0, 18], [0, 21], [0, 22], [0, 25], [0, 31], [0, 33], [0, 34], [0, 40], [0, 54], [0, 57], [0, 59], [1, 7], [1, 10], [1, 11], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 27], [1, 28], [1, 31], [1, 33], [1, 39], [1, 41], [1, 43], [1, 47], [1, 48], [1, 54], [2, 4], [2, 8], [2, 12], [2, 13], [2, 15], [2, 17], [2, 23], [2, 24], [2, 27], [2, 31], [2, 33], [2, 34], [2, 38], [2, 41], [2, 42], [2, 43], [2, 47], [2, 49], [2, 51], [2, 54], [2, 57], [2, 59], [3, 4], [3, 21], [3, 28], [3, 30], [3, 33], [3, 35], [3, 37], [3, 42], [3, 44], [3, 47], [3, 48], [3, 49], [3, 50], [3, 51], [3, 54], [3, 55], [3, 56], [3, 57], [4, 6], [4, 7], [4, 12], [4, 25], [4, 30], [4, 34], [4, 40], [4, 44], [4, 45], [4, 46], [4, 47], [5, 17], [5, 20], [5, 21], [5, 22], [5, 24], [5, 25], [5, 26], [5, 30], [5, 31], [5, 36], [5, 37], [5, 39], [5, 51], [5, 52], [5, 55], [5, 56], [6, 7], [6, 9], [6, 15], [6, 16], [6, 18], [6, 20], [6, 21], [6, 23], [6, 27], [6, 33], [6, 36], [6, 37], [6, 38], [6, 42], [6, 44], [6, 45], [6, 47], [6, 52], [6, 53], [6, 59], [7, 11], [7, 12], [7, 15], [7, 16], [7, 20], [7, 21], [7, 25], [7, 26], [7, 32], [7, 33], [7, 40], [7, 42], [7, 47], [7, 49], [7, 55], [7, 56], [7, 59], [8, 9], [8, 10], [8, 11], [8, 13], [8, 14], [8, 18], [8, 22], [8, 26], [8, 35], [8, 40], [8, 42], [8, 44], [8, 53], [9, 11], [9, 12], [9, 14], [9, 15], [9, 18], [9, 22], [9, 25], [9, 32], [9, 34], [9, 38], [9, 42], [9, 46], [9, 49], [9, 55], [10, 11], [10, 17], [10, 18], [10, 21], [10, 24], [10, 25], [10, 26], [10, 34], [10, 35], [10, 38], [10, 39], [10, 41], [10, 48], [10, 49], [10, 54], [10, 56], [11, 15], [11, 21], [11, 26], [11, 27], [11, 29], [11, 31], [11, 34], [11, 36], [11, 37], [11, 43], [11, 48], [11, 55], [11, 57], [11, 58], [12, 14], [12, 15], [12, 17], [12, 20], [12, 30], [12, 32], [12, 35], [12, 36], [12, 40], [12, 43], [12, 47], [12, 49], [12, 51], [12, 54], [12, 55], [12, 59], [13, 14], [13, 16], [13, 18], [13, 19], [13, 23], [13, 29], [13, 31], [13, 34], [13, 39], [13, 42], [13, 46], [13, 47], [13, 51], [13, 53], [13, 55], [13, 56], [14, 18], [14, 29], [14, 31], [14, 38], [14, 44], [14, 49], [14, 53], [15, 16], [15, 18], [15, 24], [15, 27], [15, 31], [15, 32], [15, 35], [15, 48], [15, 50], [15, 52], [15, 55], [16, 18], [16, 25], [16, 33], [16, 39], [16, 52], [16, 53], [16, 56], [17, 18], [17, 20], [17, 22], [17, 24], [17, 27], [17, 35], [17, 45], [17, 48], [18, 20], [18, 22], [18, 23], [18, 24], [18, 36], [18, 47], [18, 57], [19, 25], [19, 27], [19, 28], [19, 32], [19, 35], [19, 39], [19, 40], [19, 48], [20, 25], [20, 27], [20, 28], [20, 39], [20, 41], [20, 43], [20, 44], [20, 46], [20, 48], [20, 51], [20, 53], [20, 59], [21, 22], [21, 30], [21, 31], [21, 39], [21, 45], [21, 47], [21, 52], [21, 57], [22, 44], [22, 47], [22, 48], [22, 55], [22, 56], [23, 30], [23, 33], [23, 35], [23, 36], [23, 37], [23, 39], [23, 40], [23, 41], [23, 42], [23, 47], [23, 49], [23, 52], [23, 56], [23, 57], [24, 30], [24, 33], [24, 34], [24, 35], [24, 37], [24, 42], [24, 43], [24, 47], [24, 48], [24, 59], [25, 32], [25, 36], [25, 38], [25, 40], [25, 42], [25, 44], [25, 45], [25, 48], [25, 49], [25, 50], [25, 55], [25, 57], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 39], [26, 41], [26, 43], [26, 55], [26, 56], [27, 31], [27, 36], [27, 39], [27, 41], [27, 47], [27, 48], [27, 53], [27, 54], [27, 57], [28, 29], [28, 34], [28, 48], [28, 54], [28, 56], [29, 36], [29, 37], [29, 41], [29, 42], [29, 50], [29, 56], [30, 34], [30, 40], [30, 42], [30, 43], [30, 46], [30, 47], [30, 49], [30, 55], [31, 34], [31, 36], [31, 38], [31, 44], [31, 47], [31, 49], [31, 51], [31, 54], [31, 55], [31, 57], [32, 35], [32, 45], [32, 52], [32, 55], [32, 56], [33, 39], [33, 41], [33, 44], [33, 46], [33, 51], [33, 54], [33, 57], [34, 35], [34, 39], [34, 42], [34, 46], [34, 47], [34, 51], [34, 53], [35, 37], [35, 38], [35, 39], [35, 41], [35, 45], [35, 49], [35, 54], [35, 58], [36, 39], [36, 41], [36, 44], [36, 48], [36, 57], [37, 42], [37, 47], [37, 52], [37, 56], [38, 44], [38, 50], [38, 52], [38, 59], [39, 41], [39, 42], [39, 47], [39, 51], [39, 55], [39, 56], [40, 41], [40, 47], [40, 48], [40, 49], [40, 55], [41, 42], [41, 43], [41, 45], [41, 46], [41, 47], [41, 51], [41, 53], [41, 55], [41, 58], [41, 59], [42, 46], [42, 54], [42, 55], [42, 59], [43, 44], [43, 48], [43, 53], [43, 54], [43, 55], [44, 46], [44, 47], [44, 51], [44, 55], [44, 56], [45, 48], [45, 51], [45, 55], [45, 58], [46, 47], [46, 48], [46, 51], [46, 52], [46, 53], [46, 58], [47, 50], [47, 58], [48, 49], [48, 50], [48, 52], [48, 57], [48, 59], [49, 52], [49, 53], [49, 54], [49, 57], [50, 53], [51, 56], [51, 57], [52, 53], [52, 55], [52, 57], [53, 58], [54, 55], [54, 59], [55, 57], [56, 58], [57, 58]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s5/solution/solve.sh b/tasks/construct-mc-max-independent-set-l4-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..84bab6f20c74cce14545e552dbbbddb27f293f43 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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' +{"independent_set": [4, 8, 16, 17, 19, 21, 36, 37, 49, 50, 51, 55, 58, 59]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l4-s5/tests/check.py b/tasks/construct-mc-max-independent-set-l4-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s5/tests/check.py @@ -0,0 +1,18 @@ +"""Independent set of size >= k in a given graph (MathConstraint max_independent_set, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"set has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) in E: + raise Invalid(f"vertices {u} and {v} are adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-independent-set-l4-s5/tests/instance.json b/tasks/construct-mc-max-independent-set-l4-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ac83e2eb7301dc2c2410b3141d671e2a5cca66d7 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 1], [0, 5], [0, 10], [0, 16], [0, 18], [0, 21], [0, 22], [0, 25], [0, 31], [0, 33], [0, 34], [0, 40], [0, 54], [0, 57], [0, 59], [1, 7], [1, 10], [1, 11], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 27], [1, 28], [1, 31], [1, 33], [1, 39], [1, 41], [1, 43], [1, 47], [1, 48], [1, 54], [2, 4], [2, 8], [2, 12], [2, 13], [2, 15], [2, 17], [2, 23], [2, 24], [2, 27], [2, 31], [2, 33], [2, 34], [2, 38], [2, 41], [2, 42], [2, 43], [2, 47], [2, 49], [2, 51], [2, 54], [2, 57], [2, 59], [3, 4], [3, 21], [3, 28], [3, 30], [3, 33], [3, 35], [3, 37], [3, 42], [3, 44], [3, 47], [3, 48], [3, 49], [3, 50], [3, 51], [3, 54], [3, 55], [3, 56], [3, 57], [4, 6], [4, 7], [4, 12], [4, 25], [4, 30], [4, 34], [4, 40], [4, 44], [4, 45], [4, 46], [4, 47], [5, 17], [5, 20], [5, 21], [5, 22], [5, 24], [5, 25], [5, 26], [5, 30], [5, 31], [5, 36], [5, 37], [5, 39], [5, 51], [5, 52], [5, 55], [5, 56], [6, 7], [6, 9], [6, 15], [6, 16], [6, 18], [6, 20], [6, 21], [6, 23], [6, 27], [6, 33], [6, 36], [6, 37], [6, 38], [6, 42], [6, 44], [6, 45], [6, 47], [6, 52], [6, 53], [6, 59], [7, 11], [7, 12], [7, 15], [7, 16], [7, 20], [7, 21], [7, 25], [7, 26], [7, 32], [7, 33], [7, 40], [7, 42], [7, 47], [7, 49], [7, 55], [7, 56], [7, 59], [8, 9], [8, 10], [8, 11], [8, 13], [8, 14], [8, 18], [8, 22], [8, 26], [8, 35], [8, 40], [8, 42], [8, 44], [8, 53], [9, 11], [9, 12], [9, 14], [9, 15], [9, 18], [9, 22], [9, 25], [9, 32], [9, 34], [9, 38], [9, 42], [9, 46], [9, 49], [9, 55], [10, 11], [10, 17], [10, 18], [10, 21], [10, 24], [10, 25], [10, 26], [10, 34], [10, 35], [10, 38], [10, 39], [10, 41], [10, 48], [10, 49], [10, 54], [10, 56], [11, 15], [11, 21], [11, 26], [11, 27], [11, 29], [11, 31], [11, 34], [11, 36], [11, 37], [11, 43], [11, 48], [11, 55], [11, 57], [11, 58], [12, 14], [12, 15], [12, 17], [12, 20], [12, 30], [12, 32], [12, 35], [12, 36], [12, 40], [12, 43], [12, 47], [12, 49], [12, 51], [12, 54], [12, 55], [12, 59], [13, 14], [13, 16], [13, 18], [13, 19], [13, 23], [13, 29], [13, 31], [13, 34], [13, 39], [13, 42], [13, 46], [13, 47], [13, 51], [13, 53], [13, 55], [13, 56], [14, 18], [14, 29], [14, 31], [14, 38], [14, 44], [14, 49], [14, 53], [15, 16], [15, 18], [15, 24], [15, 27], [15, 31], [15, 32], [15, 35], [15, 48], [15, 50], [15, 52], [15, 55], [16, 18], [16, 25], [16, 33], [16, 39], [16, 52], [16, 53], [16, 56], [17, 18], [17, 20], [17, 22], [17, 24], [17, 27], [17, 35], [17, 45], [17, 48], [18, 20], [18, 22], [18, 23], [18, 24], [18, 36], [18, 47], [18, 57], [19, 25], [19, 27], [19, 28], [19, 32], [19, 35], [19, 39], [19, 40], [19, 48], [20, 25], [20, 27], [20, 28], [20, 39], [20, 41], [20, 43], [20, 44], [20, 46], [20, 48], [20, 51], [20, 53], [20, 59], [21, 22], [21, 30], [21, 31], [21, 39], [21, 45], [21, 47], [21, 52], [21, 57], [22, 44], [22, 47], [22, 48], [22, 55], [22, 56], [23, 30], [23, 33], [23, 35], [23, 36], [23, 37], [23, 39], [23, 40], [23, 41], [23, 42], [23, 47], [23, 49], [23, 52], [23, 56], [23, 57], [24, 30], [24, 33], [24, 34], [24, 35], [24, 37], [24, 42], [24, 43], [24, 47], [24, 48], [24, 59], [25, 32], [25, 36], [25, 38], [25, 40], [25, 42], [25, 44], [25, 45], [25, 48], [25, 49], [25, 50], [25, 55], [25, 57], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 39], [26, 41], [26, 43], [26, 55], [26, 56], [27, 31], [27, 36], [27, 39], [27, 41], [27, 47], [27, 48], [27, 53], [27, 54], [27, 57], [28, 29], [28, 34], [28, 48], [28, 54], [28, 56], [29, 36], [29, 37], [29, 41], [29, 42], [29, 50], [29, 56], [30, 34], [30, 40], [30, 42], [30, 43], [30, 46], [30, 47], [30, 49], [30, 55], [31, 34], [31, 36], [31, 38], [31, 44], [31, 47], [31, 49], [31, 51], [31, 54], [31, 55], [31, 57], [32, 35], [32, 45], [32, 52], [32, 55], [32, 56], [33, 39], [33, 41], [33, 44], [33, 46], [33, 51], [33, 54], [33, 57], [34, 35], [34, 39], [34, 42], [34, 46], [34, 47], [34, 51], [34, 53], [35, 37], [35, 38], [35, 39], [35, 41], [35, 45], [35, 49], [35, 54], [35, 58], [36, 39], [36, 41], [36, 44], [36, 48], [36, 57], [37, 42], [37, 47], [37, 52], [37, 56], [38, 44], [38, 50], [38, 52], [38, 59], [39, 41], [39, 42], [39, 47], [39, 51], [39, 55], [39, 56], [40, 41], [40, 47], [40, 48], [40, 49], [40, 55], [41, 42], [41, 43], [41, 45], [41, 46], [41, 47], [41, 51], [41, 53], [41, 55], [41, 58], [41, 59], [42, 46], [42, 54], [42, 55], [42, 59], [43, 44], [43, 48], [43, 53], [43, 54], [43, 55], [44, 46], [44, 47], [44, 51], [44, 55], [44, 56], [45, 48], [45, 51], [45, 55], [45, 58], [46, 47], [46, 48], [46, 51], [46, 52], [46, 53], [46, 58], [47, 50], [47, 58], [48, 49], [48, 50], [48, 52], [48, 57], [48, 59], [49, 52], [49, 53], [49, 54], [49, 57], [50, 53], [51, 56], [51, 57], [52, 53], [52, 55], [52, 57], [53, 58], [54, 55], [54, 59], [55, 57], [56, 58], [57, 58]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s5/tests/run.py b/tasks/construct-mc-max-independent-set-l4-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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-independent-set-l4-s5/tests/test.sh b/tasks/construct-mc-max-independent-set-l4-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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-number-partitioning-l4-s1/environment/Dockerfile b/tasks/construct-mc-number-partitioning-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-number-partitioning-l4-s1/environment/instance.json b/tasks/construct-mc-number-partitioning-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..530bfac619daf84c246f61871ae7cd6be8243344 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 27, "k": 3, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l4-s1/solution/solve.sh b/tasks/construct-mc-number-partitioning-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e4770a0dbbb103e4e84cf72fa374a83104504734 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [0, 2, 1, 1, 0, 2, 2, 1, 0, 0, 1, 2, 2, 1, 0, 0, 1, 2, 2, 1, 0, 0, 1, 2, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-number-partitioning-l4-s1/tests/check.py b/tasks/construct-mc-number-partitioning-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..67793721db8ba7d3c3979ea0e1e07091491ffa7e --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s1/tests/check.py @@ -0,0 +1,14 @@ +"""Partition {1..n} into k subsets of equal sum (MathConstraint number_partitioning, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + x = int_list(ans.get("x"), n, 0, k - 1, "x") + target = n * (n + 1) // 2 // k + sums = [0] * k + for i, s in enumerate(x): + sums[s] += i + 1 + if any(t != target for t in sums): + raise Invalid(f"subset sums {sums} are not all {target}") + return None, {} diff --git a/tasks/construct-mc-number-partitioning-l4-s1/tests/instance.json b/tasks/construct-mc-number-partitioning-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..530bfac619daf84c246f61871ae7cd6be8243344 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 27, "k": 3, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l4-s1/tests/run.py b/tasks/construct-mc-number-partitioning-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-number-partitioning-l4-s1/tests/test.sh b/tasks/construct-mc-number-partitioning-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-ortholatin-l6-s1/environment/Dockerfile b/tasks/construct-mc-ortholatin-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ortholatin-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-ortholatin-l6-s1/environment/instance.json b/tasks/construct-mc-ortholatin-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e609b56dff83c71d5c78f5c435d67f214f524bec --- /dev/null +++ b/tasks/construct-mc-ortholatin-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 24, "family": "mc_ortholatin", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ortholatin-l6-s1/solution/solve.sh b/tasks/construct-mc-ortholatin-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ecb215b41cf68d88d773bcd2b2e534160790ec6 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l6-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"X": [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23], [1, 2, 0, 4, 5, 3, 7, 8, 6, 10, 11, 9, 13, 14, 12, 16, 17, 15, 19, 20, 18, 22, 23, 21], [2, 0, 1, 5, 3, 4, 8, 6, 7, 11, 9, 10, 14, 12, 13, 17, 15, 16, 20, 18, 19, 23, 21, 22], [3, 4, 5, 0, 1, 2, 9, 10, 11, 6, 7, 8, 15, 16, 17, 12, 13, 14, 21, 22, 23, 18, 19, 20], [4, 5, 3, 1, 2, 0, 10, 11, 9, 7, 8, 6, 16, 17, 15, 13, 14, 12, 22, 23, 21, 19, 20, 18], [5, 3, 4, 2, 0, 1, 11, 9, 10, 8, 6, 7, 17, 15, 16, 14, 12, 13, 23, 21, 22, 20, 18, 19], [6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 18, 19, 20, 21, 22, 23, 12, 13, 14, 15, 16, 17], [7, 8, 6, 10, 11, 9, 1, 2, 0, 4, 5, 3, 19, 20, 18, 22, 23, 21, 13, 14, 12, 16, 17, 15], [8, 6, 7, 11, 9, 10, 2, 0, 1, 5, 3, 4, 20, 18, 19, 23, 21, 22, 14, 12, 13, 17, 15, 16], [9, 10, 11, 6, 7, 8, 3, 4, 5, 0, 1, 2, 21, 22, 23, 18, 19, 20, 15, 16, 17, 12, 13, 14], [10, 11, 9, 7, 8, 6, 4, 5, 3, 1, 2, 0, 22, 23, 21, 19, 20, 18, 16, 17, 15, 13, 14, 12], [11, 9, 10, 8, 6, 7, 5, 3, 4, 2, 0, 1, 23, 21, 22, 20, 18, 19, 17, 15, 16, 14, 12, 13], [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [13, 14, 12, 16, 17, 15, 19, 20, 18, 22, 23, 21, 1, 2, 0, 4, 5, 3, 7, 8, 6, 10, 11, 9], [14, 12, 13, 17, 15, 16, 20, 18, 19, 23, 21, 22, 2, 0, 1, 5, 3, 4, 8, 6, 7, 11, 9, 10], [15, 16, 17, 12, 13, 14, 21, 22, 23, 18, 19, 20, 3, 4, 5, 0, 1, 2, 9, 10, 11, 6, 7, 8], [16, 17, 15, 13, 14, 12, 22, 23, 21, 19, 20, 18, 4, 5, 3, 1, 2, 0, 10, 11, 9, 7, 8, 6], [17, 15, 16, 14, 12, 13, 23, 21, 22, 20, 18, 19, 5, 3, 4, 2, 0, 1, 11, 9, 10, 8, 6, 7], [18, 19, 20, 21, 22, 23, 12, 13, 14, 15, 16, 17, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5], [19, 20, 18, 22, 23, 21, 13, 14, 12, 16, 17, 15, 7, 8, 6, 10, 11, 9, 1, 2, 0, 4, 5, 3], [20, 18, 19, 23, 21, 22, 14, 12, 13, 17, 15, 16, 8, 6, 7, 11, 9, 10, 2, 0, 1, 5, 3, 4], [21, 22, 23, 18, 19, 20, 15, 16, 17, 12, 13, 14, 9, 10, 11, 6, 7, 8, 3, 4, 5, 0, 1, 2], [22, 23, 21, 19, 20, 18, 16, 17, 15, 13, 14, 12, 10, 11, 9, 7, 8, 6, 4, 5, 3, 1, 2, 0], [23, 21, 22, 20, 18, 19, 17, 15, 16, 14, 12, 13, 11, 9, 10, 8, 6, 7, 5, 3, 4, 2, 0, 1]], "Y": [[0, 2, 1, 3, 5, 4, 6, 8, 7, 9, 11, 10, 12, 14, 13, 15, 17, 16, 18, 20, 19, 21, 23, 22], [1, 0, 2, 4, 3, 5, 7, 6, 8, 10, 9, 11, 13, 12, 14, 16, 15, 17, 19, 18, 20, 22, 21, 23], [2, 1, 0, 5, 4, 3, 8, 7, 6, 11, 10, 9, 14, 13, 12, 17, 16, 15, 20, 19, 18, 23, 22, 21], [6, 8, 7, 9, 11, 10, 0, 2, 1, 3, 5, 4, 18, 20, 19, 21, 23, 22, 12, 14, 13, 15, 17, 16], [7, 6, 8, 10, 9, 11, 1, 0, 2, 4, 3, 5, 19, 18, 20, 22, 21, 23, 13, 12, 14, 16, 15, 17], [8, 7, 6, 11, 10, 9, 2, 1, 0, 5, 4, 3, 20, 19, 18, 23, 22, 21, 14, 13, 12, 17, 16, 15], [12, 14, 13, 15, 17, 16, 18, 20, 19, 21, 23, 22, 0, 2, 1, 3, 5, 4, 6, 8, 7, 9, 11, 10], [13, 12, 14, 16, 15, 17, 19, 18, 20, 22, 21, 23, 1, 0, 2, 4, 3, 5, 7, 6, 8, 10, 9, 11], [14, 13, 12, 17, 16, 15, 20, 19, 18, 23, 22, 21, 2, 1, 0, 5, 4, 3, 8, 7, 6, 11, 10, 9], [18, 20, 19, 21, 23, 22, 12, 14, 13, 15, 17, 16, 6, 8, 7, 9, 11, 10, 0, 2, 1, 3, 5, 4], [19, 18, 20, 22, 21, 23, 13, 12, 14, 16, 15, 17, 7, 6, 8, 10, 9, 11, 1, 0, 2, 4, 3, 5], [20, 19, 18, 23, 22, 21, 14, 13, 12, 17, 16, 15, 8, 7, 6, 11, 10, 9, 2, 1, 0, 5, 4, 3], [9, 11, 10, 6, 8, 7, 3, 5, 4, 0, 2, 1, 21, 23, 22, 18, 20, 19, 15, 17, 16, 12, 14, 13], [10, 9, 11, 7, 6, 8, 4, 3, 5, 1, 0, 2, 22, 21, 23, 19, 18, 20, 16, 15, 17, 13, 12, 14], [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12], [3, 5, 4, 0, 2, 1, 9, 11, 10, 6, 8, 7, 15, 17, 16, 12, 14, 13, 21, 23, 22, 18, 20, 19], [4, 3, 5, 1, 0, 2, 10, 9, 11, 7, 6, 8, 16, 15, 17, 13, 12, 14, 22, 21, 23, 19, 18, 20], [5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6, 17, 16, 15, 14, 13, 12, 23, 22, 21, 20, 19, 18], [21, 23, 22, 18, 20, 19, 15, 17, 16, 12, 14, 13, 9, 11, 10, 6, 8, 7, 3, 5, 4, 0, 2, 1], [22, 21, 23, 19, 18, 20, 16, 15, 17, 13, 12, 14, 10, 9, 11, 7, 6, 8, 4, 3, 5, 1, 0, 2], [23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [15, 17, 16, 12, 14, 13, 21, 23, 22, 18, 20, 19, 3, 5, 4, 0, 2, 1, 9, 11, 10, 6, 8, 7], [16, 15, 17, 13, 12, 14, 22, 21, 23, 19, 18, 20, 4, 3, 5, 1, 0, 2, 10, 9, 11, 7, 6, 8], [17, 16, 15, 14, 13, 12, 23, 22, 21, 20, 19, 18, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6]]} +RLMATH_EOF diff --git a/tasks/construct-mc-ortholatin-l6-s1/tests/check.py b/tasks/construct-mc-ortholatin-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a5418a59fae1c86318eee903e90d75b36d8a3306 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l6-s1/tests/check.py @@ -0,0 +1,25 @@ +"""Pair of orthogonal Latin squares of order n (MathConstraint ortholatin, CC-BY-4.0).""" +from run import Invalid, int_list + + +def _square(v, n, name): + if not isinstance(v, list) or len(v) != n: + raise Invalid(f"{name} must be a list of {n} rows") + S = [int_list(r, n, 0, n - 1, f"{name} row") for r in v] + full = list(range(n)) + for i in range(n): + if sorted(S[i]) != full: + raise Invalid(f"{name}: row {i} is not a permutation of 0..{n - 1}") + if sorted(S[r][i] for r in range(n)) != full: + raise Invalid(f"{name}: column {i} is not a permutation of 0..{n - 1}") + return S + + +def check(inst, ans): + n = inst["n"] + X = _square(ans.get("X"), n, "X") + Y = _square(ans.get("Y"), n, "Y") + pairs = {(X[i][j], Y[i][j]) for i in range(n) for j in range(n)} + if len(pairs) != n * n: + raise Invalid("X and Y are not orthogonal (some ordered pair repeats)") + return None, {} diff --git a/tasks/construct-mc-ortholatin-l6-s1/tests/instance.json b/tasks/construct-mc-ortholatin-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e609b56dff83c71d5c78f5c435d67f214f524bec --- /dev/null +++ b/tasks/construct-mc-ortholatin-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 24, "family": "mc_ortholatin", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ortholatin-l6-s1/tests/run.py b/tasks/construct-mc-ortholatin-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ortholatin-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-ortholatin-l6-s1/tests/test.sh b/tasks/construct-mc-ortholatin-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ortholatin-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-pysms-chromatic-girth-l2-s0/environment/Dockerfile b/tasks/construct-mc-pysms-chromatic-girth-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-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-chromatic-girth-l2-s0/environment/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c26cd06d95850f86bf53fca0e92fffc24f130c2b --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 15, "required_edges": [], "max_chromatic_number": 5, "min_edges": 10, "min_girth": 7, "family": "mc_pysms_chromatic_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-chromatic-girth-l2-s0/solution/solve.sh b/tasks/construct-mc-pysms-chromatic-girth-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ba0a0e451ed96e6080af029e5d2627b86a9c851c --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-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, 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]], "coloring": [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-chromatic-girth-l2-s0/tests/check.py b/tasks/construct-mc-pysms-chromatic-girth-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-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-chromatic-girth-l2-s0/tests/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c26cd06d95850f86bf53fca0e92fffc24f130c2b --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 15, "required_edges": [], "max_chromatic_number": 5, "min_edges": 10, "min_girth": 7, "family": "mc_pysms_chromatic_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-chromatic-girth-l2-s0/tests/run.py b/tasks/construct-mc-pysms-chromatic-girth-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-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-chromatic-girth-l2-s0/tests/test.sh b/tasks/construct-mc-pysms-chromatic-girth-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-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-degree-bounds-l2-s0/environment/Dockerfile b/tasks/construct-mc-pysms-degree-bounds-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-degree-bounds-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-degree-bounds-l2-s0/environment/instance.json b/tasks/construct-mc-pysms-degree-bounds-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7e681edec1fe03c22e9a5fd4f096c16b23a30b1d --- /dev/null +++ b/tasks/construct-mc-pysms-degree-bounds-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 11, "required_edges": [[2, 8], [2, 6], [2, 10], [3, 8], [0, 10]], "max_degree": 5, "min_degree": 1, "family": "mc_pysms_degree_bounds", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-degree-bounds-l2-s0/solution/solve.sh b/tasks/construct-mc-pysms-degree-bounds-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7253b74e07ee8ae2e02ba7e4bd9370f597e88307 --- /dev/null +++ b/tasks/construct-mc-pysms-degree-bounds-l2-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 7], [0, 8], [0, 9], [0, 10], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [3, 5], [3, 7], [3, 8], [3, 9], [3, 10], [4, 5], [4, 6], [4, 8], [4, 9], [4, 10], [5, 6], [5, 7]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-degree-bounds-l2-s0/tests/check.py b/tasks/construct-mc-pysms-degree-bounds-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-degree-bounds-l2-s0/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-degree-bounds-l2-s0/tests/instance.json b/tasks/construct-mc-pysms-degree-bounds-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7e681edec1fe03c22e9a5fd4f096c16b23a30b1d --- /dev/null +++ b/tasks/construct-mc-pysms-degree-bounds-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 11, "required_edges": [[2, 8], [2, 6], [2, 10], [3, 8], [0, 10]], "max_degree": 5, "min_degree": 1, "family": "mc_pysms_degree_bounds", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-degree-bounds-l2-s0/tests/run.py b/tasks/construct-mc-pysms-degree-bounds-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-degree-bounds-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-degree-bounds-l2-s0/tests/test.sh b/tasks/construct-mc-pysms-degree-bounds-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-degree-bounds-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-girth-degree-l1-s2/environment/Dockerfile b/tasks/construct-mc-pysms-girth-degree-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-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-pysms-girth-degree-l1-s2/environment/instance.json b/tasks/construct-mc-pysms-girth-degree-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..080d67234ad3bf2da9c9d18f15844f3b8578dcfa --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 10, "required_edges": [], "max_degree": 3, "min_degree": 2, "min_girth": 5, "family": "mc_pysms_girth_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-girth-degree-l1-s2/solution/solve.sh b/tasks/construct-mc-pysms-girth-degree-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..167c50fb47d85c02d46de183e91659859551915c --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-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' +{"edges": [[0, 8], [0, 9], [1, 7], [1, 9], [2, 6], [2, 9], [3, 6], [3, 7], [3, 8], [4, 5], [4, 8], [5, 7]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-girth-degree-l1-s2/tests/check.py b/tasks/construct-mc-pysms-girth-degree-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l1-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-girth-degree-l1-s2/tests/instance.json b/tasks/construct-mc-pysms-girth-degree-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..080d67234ad3bf2da9c9d18f15844f3b8578dcfa --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 10, "required_edges": [], "max_degree": 3, "min_degree": 2, "min_girth": 5, "family": "mc_pysms_girth_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-girth-degree-l1-s2/tests/run.py b/tasks/construct-mc-pysms-girth-degree-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-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-pysms-girth-degree-l1-s2/tests/test.sh b/tasks/construct-mc-pysms-girth-degree-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-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-pysms-min-degree-l5-s0/environment/Dockerfile b/tasks/construct-mc-pysms-min-degree-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-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-degree-l5-s0/environment/instance.json b/tasks/construct-mc-pysms-min-degree-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ee57ed110ab8b2d79f903cdc59204bc341ace2df --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 18, "required_edges": [[3, 15], [11, 13], [13, 17], [2, 11], [11, 17], [2, 12], [7, 17], [9, 17], [3, 5], [0, 16], [1, 14], [7, 9], [0, 9], [6, 11], [3, 11], [0, 2], [1, 17], [4, 8], [5, 15], [1, 15], [2, 15], [15, 17], [4, 16], [0, 8], [4, 6], [8, 13], [13, 14], [2, 10], [6, 13], [9, 12]], "min_degree": 5, "family": "mc_pysms_min_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-degree-l5-s0/solution/solve.sh b/tasks/construct-mc-pysms-min-degree-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..eb6e7062cc9837f07c0c2fa725d985e6483a6394 --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-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-degree-l5-s0/tests/check.py b/tasks/construct-mc-pysms-min-degree-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-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-degree-l5-s0/tests/instance.json b/tasks/construct-mc-pysms-min-degree-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ee57ed110ab8b2d79f903cdc59204bc341ace2df --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 18, "required_edges": [[3, 15], [11, 13], [13, 17], [2, 11], [11, 17], [2, 12], [7, 17], [9, 17], [3, 5], [0, 16], [1, 14], [7, 9], [0, 9], [6, 11], [3, 11], [0, 2], [1, 17], [4, 8], [5, 15], [1, 15], [2, 15], [15, 17], [4, 16], [0, 8], [4, 6], [8, 13], [13, 14], [2, 10], [6, 13], [9, 12]], "min_degree": 5, "family": "mc_pysms_min_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-degree-l5-s0/tests/run.py b/tasks/construct-mc-pysms-min-degree-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-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-degree-l5-s0/tests/test.sh b/tasks/construct-mc-pysms-min-degree-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-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-girth-l4-s2/environment/Dockerfile b/tasks/construct-mc-pysms-min-girth-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-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-pysms-min-girth-l4-s2/environment/instance.json b/tasks/construct-mc-pysms-min-girth-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..322b96282d34d7152826d2c428af7e7dac21b55b --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 17, "required_edges": [], "min_girth": 4, "family": "mc_pysms_min_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-girth-l4-s2/solution/solve.sh b/tasks/construct-mc-pysms-min-girth-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5d1f37e5d69ab188c08f4a0aba571b2a79b84a86 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-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' +{"edges": [[0, 16], [1, 16], [2, 16], [3, 16], [4, 16], [5, 16], [6, 16], [7, 16], [8, 16], [9, 16], [10, 16], [11, 16], [12, 16], [13, 16], [14, 16], [15, 16]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-min-girth-l4-s2/tests/check.py b/tasks/construct-mc-pysms-min-girth-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l4-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-min-girth-l4-s2/tests/instance.json b/tasks/construct-mc-pysms-min-girth-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..322b96282d34d7152826d2c428af7e7dac21b55b --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 17, "required_edges": [], "min_girth": 4, "family": "mc_pysms_min_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-girth-l4-s2/tests/run.py b/tasks/construct-mc-pysms-min-girth-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-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-pysms-min-girth-l4-s2/tests/test.sh b/tasks/construct-mc-pysms-min-girth-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-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-quasigroup-idempotent-l1-s0/environment/Dockerfile b/tasks/construct-mc-quasigroup-idempotent-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-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-quasigroup-idempotent-l1-s0/environment/instance.json b/tasks/construct-mc-quasigroup-idempotent-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e76a28dd7ae5128cd50a4be1b1690240267b100d --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 4, "family": "mc_quasigroup_idempotent", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-quasigroup-idempotent-l1-s0/solution/solve.sh b/tasks/construct-mc-quasigroup-idempotent-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..82d1e6cfd8e1c5ff85e4283dae33f99e23a88a7c --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-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' +{"table": [[0, 3, 1, 2], [2, 1, 3, 0], [3, 0, 2, 1], [1, 2, 0, 3]]} +RLMATH_EOF diff --git a/tasks/construct-mc-quasigroup-idempotent-l1-s0/tests/check.py b/tasks/construct-mc-quasigroup-idempotent-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4563f2e9a90050cdd7c56dfc33831acde74c9ef2 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l1-s0/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-l1-s0/tests/instance.json b/tasks/construct-mc-quasigroup-idempotent-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e76a28dd7ae5128cd50a4be1b1690240267b100d --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 4, "family": "mc_quasigroup_idempotent", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-quasigroup-idempotent-l1-s0/tests/run.py b/tasks/construct-mc-quasigroup-idempotent-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-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-quasigroup-idempotent-l1-s0/tests/test.sh b/tasks/construct-mc-quasigroup-idempotent-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-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-ramsey-l3-s8/environment/Dockerfile b/tasks/construct-mc-ramsey-l3-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-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-ramsey-l3-s8/environment/instance.json b/tasks/construct-mc-ramsey-l3-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..316d0383a487ab0cc58644d613c8c18ca1bcef16 --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 16, "r": 4, "s": 4, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l3-s8/solution/solve.sh b/tasks/construct-mc-ramsey-l3-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f4e87542501bc592a1b342c6158f83dcbc0c3d1b --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 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-s8/tests/check.py b/tasks/construct-mc-ramsey-l3-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s8/tests/check.py @@ -0,0 +1,31 @@ +"""Two-colouring of the edges of K_n with no colour-0 K_r and no colour-1 K_s (MathConstraint ramsey, +CC-BY-4.0). Adapted from pilot/grader.py check_ramsey; adds the optional fixed edge colours.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, r, s = inst["n"], inst["r"], inst["s"] + edges = list(itertools.combinations(range(n), 2)) + col = int_list(ans.get("colors"), len(edges), 0, 1, "colors") + for name, i, v in inst.get("fixed", []): + if col[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + c = {e: col[i] for i, e in enumerate(edges)} + for k, colour in ((r, 0), (s, 1)): + adj = {v: {u for u in range(n) if u != v and c[(min(u, v), max(u, v))] == colour} for v in range(n)} + + def grow(size, cand): + if size == k: + return True + if size + len(cand) < k: + return False + for v in sorted(cand): + if grow(size + 1, {u for u in cand if u > v} & adj[v]): + return True + return False + + if grow(0, set(range(n))): + raise Invalid(f"monochromatic K_{k} in colour {colour}") + return None, {} diff --git a/tasks/construct-mc-ramsey-l3-s8/tests/instance.json b/tasks/construct-mc-ramsey-l3-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..316d0383a487ab0cc58644d613c8c18ca1bcef16 --- /dev/null +++ b/tasks/construct-mc-ramsey-l3-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 16, "r": 4, "s": 4, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l3-s8/tests/run.py b/tasks/construct-mc-ramsey-l3-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-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-ramsey-l3-s8/tests/test.sh b/tasks/construct-mc-ramsey-l3-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-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-ramsey-l4-s5/environment/Dockerfile b/tasks/construct-mc-ramsey-l4-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-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-ramsey-l4-s5/environment/instance.json b/tasks/construct-mc-ramsey-l4-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5884b315dafa8c26f6e83509210d29a762c531ad --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 19, "r": 3, "s": 7, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s5/solution/solve.sh b/tasks/construct-mc-ramsey-l4-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..25c054cd2e7076e6717cb776ddd0cb182851d385 --- /dev/null +++ b/tasks/construct-mc-ramsey-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' +{"colors": [1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-ramsey-l4-s5/tests/check.py b/tasks/construct-mc-ramsey-l4-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s5/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-s5/tests/instance.json b/tasks/construct-mc-ramsey-l4-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5884b315dafa8c26f6e83509210d29a762c531ad --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 19, "r": 3, "s": 7, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s5/tests/run.py b/tasks/construct-mc-ramsey-l4-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-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-ramsey-l4-s5/tests/test.sh b/tasks/construct-mc-ramsey-l4-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-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-social-golfers-l2-s2/environment/Dockerfile b/tasks/construct-mc-social-golfers-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l2-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-social-golfers-l2-s2/environment/instance.json b/tasks/construct-mc-social-golfers-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..327bd0cebcd1bcb4e7576b287405e72f6aea830c --- /dev/null +++ b/tasks/construct-mc-social-golfers-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"n_groups": 9, "group_size": 3, "n_weeks": 6, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l2-s2/solution/solve.sh b/tasks/construct-mc-social-golfers-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..005d1c3dfff77496849d5ec5897fbd39789ff90a --- /dev/null +++ b/tasks/construct-mc-social-golfers-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' +{"schedule": [[0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8], [0, 1, 2, 2, 3, 4, 3, 4, 5, 3, 4, 5, 5, 6, 7, 6, 7, 8, 6, 8, 7, 1, 0, 2, 8, 1, 0], [1, 0, 2, 3, 2, 4, 3, 5, 4, 4, 3, 5, 6, 5, 7, 7, 8, 6, 8, 7, 6, 1, 8, 0, 1, 2, 0], [2, 3, 4, 3, 2, 4, 4, 5, 6, 5, 7, 8, 7, 6, 8, 7, 5, 6, 8, 0, 1, 0, 1, 2, 3, 1, 0], [2, 1, 3, 2, 4, 5, 6, 3, 4, 7, 8, 5, 6, 8, 7, 5, 8, 7, 6, 1, 0, 4, 1, 0, 0, 2, 3], [0, 1, 2, 3, 1, 0, 4, 1, 2, 3, 2, 4, 0, 3, 5, 6, 4, 7, 7, 8, 6, 6, 5, 8, 5, 8, 7]]} +RLMATH_EOF diff --git a/tasks/construct-mc-social-golfers-l2-s2/tests/check.py b/tasks/construct-mc-social-golfers-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..73977815b7b6094a8491075b6dc2ae1293e44930 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l2-s2/tests/check.py @@ -0,0 +1,25 @@ +"""Social golfer problem (MathConstraint social_golfers, CSPLib prob010, CC-BY-4.0): each week partition +the g*s players into g groups of size s; no two players share a group in more than one week.""" +from run import Invalid, int_list + + +def check(inst, ans): + g, s, w = inst["n_groups"], inst["group_size"], inst["n_weeks"] + P = g * s + sched = ans.get("schedule") + if not isinstance(sched, list) or len(sched) != w: + raise Invalid(f"schedule must be a list of {w} weeks") + met = set() + for wk, row in enumerate(sched): + row = int_list(row, P, 0, g - 1, f"week {wk}") + groups = [[p for p in range(P) if row[p] == grp] for grp in range(g)] + for grp, mem in enumerate(groups): + if len(mem) != s: + raise Invalid(f"week {wk}: group {grp} has {len(mem)} players, need {s}") + for i in range(s): + for j in range(i + 1, s): + pr = (mem[i], mem[j]) + if pr in met: + raise Invalid(f"players {pr} play together in more than one week") + met.add(pr) + return None, {} diff --git a/tasks/construct-mc-social-golfers-l2-s2/tests/instance.json b/tasks/construct-mc-social-golfers-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..327bd0cebcd1bcb4e7576b287405e72f6aea830c --- /dev/null +++ b/tasks/construct-mc-social-golfers-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"n_groups": 9, "group_size": 3, "n_weeks": 6, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l2-s2/tests/run.py b/tasks/construct-mc-social-golfers-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-social-golfers-l2-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-social-golfers-l2-s2/tests/test.sh b/tasks/construct-mc-social-golfers-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l2-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-social-golfers-l5-s1/environment/Dockerfile b/tasks/construct-mc-social-golfers-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-social-golfers-l5-s1/environment/instance.json b/tasks/construct-mc-social-golfers-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..96f60a74e9c90573744da99cf89df7493498bdf9 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"n_groups": 8, "group_size": 4, "n_weeks": 7, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l5-s1/solution/solve.sh b/tasks/construct-mc-social-golfers-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d9149ee6fbdff33756ac05a1d40908745f836084 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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' +{"schedule": [[0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7], [6, 4, 7, 2, 5, 1, 2, 4, 7, 5, 3, 0, 0, 6, 1, 2, 7, 3, 1, 0, 6, 4, 7, 5, 0, 1, 2, 3, 6, 5, 4, 3], [7, 5, 6, 4, 5, 3, 6, 0, 3, 7, 4, 6, 1, 0, 2, 7, 2, 0, 1, 3, 5, 4, 1, 2, 7, 4, 2, 1, 6, 0, 3, 5], [1, 0, 2, 6, 1, 3, 0, 2, 1, 2, 0, 4, 7, 3, 6, 4, 3, 6, 4, 5, 7, 5, 6, 0, 3, 7, 5, 1, 5, 7, 4, 2], [5, 1, 7, 3, 4, 2, 0, 5, 6, 1, 2, 3, 4, 3, 0, 2, 4, 6, 1, 5, 0, 4, 5, 7, 0, 6, 1, 7, 6, 2, 7, 3], [0, 5, 1, 2, 1, 3, 0, 2, 2, 3, 1, 5, 4, 1, 5, 7, 0, 4, 6, 7, 2, 6, 3, 7, 6, 7, 4, 5, 3, 6, 4, 0], [3, 7, 0, 4, 4, 3, 6, 2, 5, 6, 2, 3, 5, 7, 0, 1, 1, 6, 2, 0, 1, 6, 7, 5, 4, 7, 3, 1, 2, 0, 4, 5]]} +RLMATH_EOF diff --git a/tasks/construct-mc-social-golfers-l5-s1/tests/check.py b/tasks/construct-mc-social-golfers-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..73977815b7b6094a8491075b6dc2ae1293e44930 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s1/tests/check.py @@ -0,0 +1,25 @@ +"""Social golfer problem (MathConstraint social_golfers, CSPLib prob010, CC-BY-4.0): each week partition +the g*s players into g groups of size s; no two players share a group in more than one week.""" +from run import Invalid, int_list + + +def check(inst, ans): + g, s, w = inst["n_groups"], inst["group_size"], inst["n_weeks"] + P = g * s + sched = ans.get("schedule") + if not isinstance(sched, list) or len(sched) != w: + raise Invalid(f"schedule must be a list of {w} weeks") + met = set() + for wk, row in enumerate(sched): + row = int_list(row, P, 0, g - 1, f"week {wk}") + groups = [[p for p in range(P) if row[p] == grp] for grp in range(g)] + for grp, mem in enumerate(groups): + if len(mem) != s: + raise Invalid(f"week {wk}: group {grp} has {len(mem)} players, need {s}") + for i in range(s): + for j in range(i + 1, s): + pr = (mem[i], mem[j]) + if pr in met: + raise Invalid(f"players {pr} play together in more than one week") + met.add(pr) + return None, {} diff --git a/tasks/construct-mc-social-golfers-l5-s1/tests/instance.json b/tasks/construct-mc-social-golfers-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..96f60a74e9c90573744da99cf89df7493498bdf9 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"n_groups": 8, "group_size": 4, "n_weeks": 7, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l5-s1/tests/run.py b/tasks/construct-mc-social-golfers-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-social-golfers-l5-s1/tests/test.sh b/tasks/construct-mc-social-golfers-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-van-der-waerden-l4-s7/environment/Dockerfile b/tasks/construct-mc-van-der-waerden-l4-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-van-der-waerden-l4-s7/environment/instance.json b/tasks/construct-mc-van-der-waerden-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..50029443d55ba8cc8ceb3128fc6f516b5e9ee3dc --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"k": 3, "L": 4, "n": 80, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l4-s7/solution/solve.sh b/tasks/construct-mc-van-der-waerden-l4-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..79315f39cfe7d3811a1cf7cdb45f0b675e492826 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 1, 2, 2, 1, 0, 0, 0, 1, 0, 1, 2, 1, 0, 2, 0, 0, 1, 1, 1, 2, 2, 1, 0, 2, 1, 0, 0, 0, 1, 1, 1, 2, 1, 1, 2, 1, 0, 1, 2, 0, 2, 0, 2, 2, 0, 0, 1, 2, 0, 2, 2, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 2, 1, 1, 2, 1, 1, 2, 2, 2, 0, 2, 2, 0, 0, 0, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-van-der-waerden-l4-s7/tests/check.py b/tasks/construct-mc-van-der-waerden-l4-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9853b089b6ac1773d80eac8e9e02ceb4019ad41f --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s7/tests/check.py @@ -0,0 +1,15 @@ +"""k-colouring of {1..n} with no monochromatic L-term arithmetic progression (MathConstraint +van_der_waerden, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k, L = inst["n"], inst["k"], inst["L"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + for a in range(n): + for d in range(1, n): + if a + (L - 1) * d >= n: + break + if all(c[a + j * d] == c[a] for j in range(1, L)): + raise Invalid(f"monochromatic progression {[a + 1 + j * d for j in range(L)]}") + return None, {} diff --git a/tasks/construct-mc-van-der-waerden-l4-s7/tests/instance.json b/tasks/construct-mc-van-der-waerden-l4-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..50029443d55ba8cc8ceb3128fc6f516b5e9ee3dc --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s7/tests/instance.json @@ -0,0 +1 @@ +{"k": 3, "L": 4, "n": 80, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l4-s7/tests/run.py b/tasks/construct-mc-van-der-waerden-l4-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-van-der-waerden-l4-s7/tests/test.sh b/tasks/construct-mc-van-der-waerden-l4-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-vertex-cover-l1-s1/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-vertex-cover-l1-s1/environment/instance.json b/tasks/construct-mc-vertex-cover-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..171ff053c4812623b7c9557123031c3ec59f2740 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 6], [1, 4], [1, 12], [2, 7], [3, 9], [3, 12], [3, 17], [3, 18], [4, 6], [4, 10], [4, 14], [5, 6], [5, 19], [6, 7], [6, 11], [6, 15], [6, 16], [7, 11], [7, 16], [7, 17], [8, 14], [8, 16], [9, 12], [9, 13], [9, 19], [10, 12], [10, 18], [12, 17], [13, 15], [13, 16], [15, 16]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s1/solution/solve.sh b/tasks/construct-mc-vertex-cover-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ecc03877a8c2197fd5c02b488452bf7a508ef8d3 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [3, 4, 6, 7, 10, 12, 13, 14, 15, 16, 19]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l1-s1/tests/check.py b/tasks/construct-mc-vertex-cover-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s1/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l1-s1/tests/instance.json b/tasks/construct-mc-vertex-cover-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..171ff053c4812623b7c9557123031c3ec59f2740 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 6], [1, 4], [1, 12], [2, 7], [3, 9], [3, 12], [3, 17], [3, 18], [4, 6], [4, 10], [4, 14], [5, 6], [5, 19], [6, 7], [6, 11], [6, 15], [6, 16], [7, 11], [7, 16], [7, 17], [8, 14], [8, 16], [9, 12], [9, 13], [9, 19], [10, 12], [10, 18], [12, 17], [13, 15], [13, 16], [15, 16]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s1/tests/run.py b/tasks/construct-mc-vertex-cover-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-vertex-cover-l1-s1/tests/test.sh b/tasks/construct-mc-vertex-cover-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-vertex-cover-l1-s6/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l1-s6/environment/instance.json b/tasks/construct-mc-vertex-cover-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..293fda8b2b3ded740968e08f3bd6385b8f5f4803 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 2], [0, 7], [0, 13], [0, 15], [1, 5], [1, 7], [1, 10], [1, 17], [3, 6], [3, 12], [3, 16], [3, 19], [4, 6], [4, 18], [4, 19], [5, 6], [5, 12], [5, 17], [7, 11], [7, 19], [8, 10], [8, 11], [10, 12], [10, 16], [11, 16], [11, 17], [12, 13], [12, 16], [13, 16], [14, 18], [15, 19], [16, 17]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s6/solution/solve.sh b/tasks/construct-mc-vertex-cover-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..dea19085aa195063d360c7347d3af92448618b4e --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [0, 1, 4, 6, 7, 8, 12, 16, 17, 18, 19]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l1-s6/tests/check.py b/tasks/construct-mc-vertex-cover-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s6/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l1-s6/tests/instance.json b/tasks/construct-mc-vertex-cover-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..293fda8b2b3ded740968e08f3bd6385b8f5f4803 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 2], [0, 7], [0, 13], [0, 15], [1, 5], [1, 7], [1, 10], [1, 17], [3, 6], [3, 12], [3, 16], [3, 19], [4, 6], [4, 18], [4, 19], [5, 6], [5, 12], [5, 17], [7, 11], [7, 19], [8, 10], [8, 11], [10, 12], [10, 16], [11, 16], [11, 17], [12, 13], [12, 16], [13, 16], [14, 18], [15, 19], [16, 17]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s6/tests/run.py b/tasks/construct-mc-vertex-cover-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l1-s6/tests/test.sh b/tasks/construct-mc-vertex-cover-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l1-s8/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-vertex-cover-l1-s8/environment/instance.json b/tasks/construct-mc-vertex-cover-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..16ee1a5003266b538ffe1e1b7b1c7a4350eafd15 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 4], [0, 7], [0, 9], [0, 10], [1, 17], [2, 8], [2, 11], [3, 15], [4, 6], [4, 7], [4, 12], [4, 19], [5, 13], [6, 12], [6, 18], [7, 11], [7, 16], [8, 16], [9, 12], [9, 13], [9, 15], [10, 13], [10, 18], [11, 12], [11, 13], [12, 17], [13, 14], [13, 19], [16, 17], [17, 19]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s8/solution/solve.sh b/tasks/construct-mc-vertex-cover-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c8cd8ddb7c5bb809a4f5765a180bee5136ed3171 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [0, 1, 2, 4, 7, 12, 13, 15, 16, 18, 19]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l1-s8/tests/check.py b/tasks/construct-mc-vertex-cover-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s8/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l1-s8/tests/instance.json b/tasks/construct-mc-vertex-cover-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..16ee1a5003266b538ffe1e1b7b1c7a4350eafd15 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 4], [0, 7], [0, 9], [0, 10], [1, 17], [2, 8], [2, 11], [3, 15], [4, 6], [4, 7], [4, 12], [4, 19], [5, 13], [6, 12], [6, 18], [7, 11], [7, 16], [8, 16], [9, 12], [9, 13], [9, 15], [10, 13], [10, 18], [11, 12], [11, 13], [12, 17], [13, 14], [13, 19], [16, 17], [17, 19]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s8/tests/run.py b/tasks/construct-mc-vertex-cover-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-vertex-cover-l1-s8/tests/test.sh b/tasks/construct-mc-vertex-cover-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-vertex-cover-l5-s7/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-vertex-cover-l5-s7/environment/instance.json b/tasks/construct-mc-vertex-cover-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ff6ac17bba87435db2aeef49daafbce7b8881879 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 2], [0, 5], [0, 6], [0, 22], [0, 26], [0, 46], [0, 54], [0, 55], [0, 60], [0, 83], [0, 84], [1, 4], [1, 11], [1, 12], [1, 19], [1, 20], [1, 36], [1, 42], [1, 44], [1, 53], [1, 54], [1, 55], [1, 56], [1, 58], [1, 62], [1, 73], [1, 79], [1, 83], [1, 84], [1, 86], [2, 18], [2, 28], [2, 33], [2, 44], [2, 57], [2, 75], [3, 5], [3, 7], [3, 23], [3, 27], [3, 31], [3, 35], [3, 39], [3, 42], [3, 52], [3, 59], [3, 62], [3, 64], [3, 70], [3, 87], [4, 9], [4, 18], [4, 19], [4, 42], [4, 43], [4, 58], [4, 60], [4, 63], [4, 71], [4, 72], [4, 73], [4, 74], [4, 81], [4, 84], [4, 86], [5, 10], [5, 13], [5, 18], [5, 23], [5, 28], [5, 34], [5, 42], [5, 46], [5, 50], [5, 53], [5, 54], [5, 60], [5, 62], [5, 72], [5, 73], [5, 79], [5, 84], [5, 87], [5, 88], [5, 89], [6, 9], [6, 10], [6, 12], [6, 14], [6, 17], [6, 24], [6, 25], [6, 27], [6, 32], [6, 35], [6, 47], [6, 51], [6, 52], [6, 60], [6, 67], [6, 69], [6, 76], [6, 82], [7, 26], [7, 39], [7, 41], [7, 42], [7, 78], [8, 17], [8, 40], [8, 48], [9, 12], [9, 13], [9, 17], [9, 21], [9, 22], [9, 24], [9, 28], [9, 35], [9, 49], [9, 50], [9, 52], [9, 61], [9, 71], [9, 73], [9, 79], [10, 44], [10, 47], [10, 51], [10, 53], [10, 63], [10, 69], [11, 14], [11, 22], [11, 26], [11, 38], [11, 44], [11, 59], [11, 61], [11, 82], [11, 85], [12, 18], [12, 19], [12, 36], [12, 37], [12, 42], [12, 44], [12, 47], [12, 51], [12, 67], [12, 72], [13, 26], [13, 35], [13, 36], [13, 51], [13, 66], [13, 78], [13, 79], [13, 81], [13, 84], [13, 86], [14, 15], [14, 26], [14, 30], [14, 34], [14, 39], [14, 44], [14, 76], [14, 77], [14, 81], [14, 82], [15, 22], [15, 50], [15, 51], [15, 52], [15, 53], [15, 54], [15, 69], [15, 83], [16, 22], [16, 37], [16, 54], [16, 56], [16, 73], [16, 79], [16, 84], [16, 85], [17, 21], [17, 22], [17, 43], [17, 54], [17, 75], [17, 86], [17, 88], [18, 32], [18, 34], [18, 37], [18, 41], [18, 50], [18, 55], [18, 56], [18, 69], [18, 82], [19, 26], [19, 27], [19, 28], [19, 46], [19, 77], [19, 86], [20, 40], [20, 57], [20, 86], [21, 22], [21, 29], [21, 34], [21, 44], [21, 46], [21, 50], [21, 60], [21, 67], [21, 75], [21, 81], [21, 89], [22, 25], [22, 27], [22, 55], [22, 56], [22, 62], [22, 72], [22, 74], [22, 75], [22, 82], [23, 34], [23, 43], [23, 45], [23, 49], [23, 58], [23, 63], [23, 67], [23, 74], [23, 89], [24, 25], [24, 26], [24, 31], [24, 32], [24, 35], [24, 50], [24, 61], [24, 69], [24, 77], [24, 78], [24, 81], [24, 85], [25, 31], [25, 32], [25, 48], [25, 54], [25, 76], [25, 80], [25, 84], [25, 89], [26, 29], [26, 39], [26, 40], [26, 46], [26, 49], [26, 59], [26, 61], [26, 63], [26, 70], [26, 71], [26, 88], [27, 42], [27, 52], [27, 60], [27, 65], [27, 66], [27, 86], [28, 30], [28, 38], [28, 43], [28, 45], [28, 49], [28, 56], [28, 58], [28, 71], [28, 75], [28, 82], [28, 86], [28, 87], [29, 31], [29, 34], [29, 36], [29, 38], [29, 39], [29, 43], [29, 46], [29, 51], [29, 52], [29, 68], [29, 77], [29, 84], [29, 87], [30, 31], [30, 37], [30, 39], [30, 41], [30, 44], [30, 48], [30, 49], [30, 52], [30, 56], [30, 57], [30, 63], [30, 78], [30, 83], [31, 32], [31, 42], [31, 44], [31, 45], [31, 58], [31, 63], [31, 65], [31, 73], [31, 81], [32, 33], [32, 36], [32, 37], [32, 39], [32, 41], [32, 51], [32, 59], [32, 76], [32, 81], [33, 51], [33, 53], [33, 54], [33, 65], [33, 66], [33, 78], [33, 80], [33, 81], [33, 88], [34, 37], [34, 41], [34, 43], [34, 47], [34, 48], [34, 63], [34, 75], [34, 77], [35, 41], [35, 58], [35, 67], [35, 73], [35, 81], [36, 38], [36, 51], [36, 58], [36, 60], [36, 64], [36, 66], [36, 80], [37, 39], [37, 56], [37, 58], [37, 61], [37, 66], [37, 69], [37, 81], [38, 48], [38, 52], [38, 67], [38, 68], [38, 74], [38, 76], [38, 78], [38, 80], [38, 84], [38, 85], [39, 43], [39, 47], [39, 48], [39, 49], [39, 50], [39, 55], [39, 63], [39, 69], [39, 74], [39, 81], [39, 82], [40, 44], [40, 50], [40, 54], [40, 56], [40, 58], [40, 68], [40, 69], [40, 73], [40, 88], [40, 89], [41, 49], [41, 54], [41, 62], [41, 63], [41, 67], [41, 89], [42, 46], [42, 58], [42, 65], [42, 66], [42, 69], [42, 77], [42, 82], [43, 50], [43, 59], [44, 45], [44, 61], [44, 65], [44, 67], [44, 72], [44, 74], [44, 78], [45, 76], [45, 86], [46, 60], [46, 77], [47, 57], [47, 58], [47, 70], [47, 71], [47, 73], [47, 75], [48, 52], [48, 56], [48, 71], [48, 78], [48, 80], [48, 84], [48, 86], [49, 50], [49, 58], [49, 77], [50, 52], [50, 71], [50, 73], [50, 85], [50, 86], [51, 61], [51, 86], [52, 73], [52, 75], [52, 80], [53, 57], [53, 58], [53, 77], [54, 58], [54, 60], [54, 63], [54, 72], [54, 74], [55, 74], [55, 84], [56, 58], [56, 60], [56, 61], [56, 67], [56, 70], [56, 75], [56, 76], [56, 80], [56, 88], [57, 67], [57, 69], [57, 70], [57, 73], [57, 74], [57, 86], [58, 62], [58, 64], [58, 65], [58, 68], [58, 74], [58, 78], [58, 81], [58, 85], [59, 80], [59, 81], [59, 84], [59, 89], [60, 62], [60, 63], [60, 83], [61, 75], [61, 79], [61, 82], [61, 87], [62, 67], [62, 85], [63, 73], [63, 81], [63, 88], [64, 88], [65, 68], [65, 69], [66, 71], [66, 73], [66, 77], [66, 86], [66, 88], [67, 69], [67, 74], [67, 77], [68, 85], [70, 71], [70, 80], [70, 81], [70, 86], [70, 88], [71, 72], [71, 73], [71, 79], [71, 81], [72, 74], [72, 89], [73, 75], [73, 78], [73, 79], [73, 82], [73, 89], [74, 77], [74, 84], [74, 87], [75, 76], [75, 79], [75, 85], [75, 89], [76, 83], [77, 83], [78, 83], [79, 85], [80, 88], [82, 87], [84, 89]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s7/solution/solve.sh b/tasks/construct-mc-vertex-cover-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5c34b0cb4bf01363a44b9e84e082cb337ef85f57 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [0, 1, 3, 4, 5, 6, 9, 10, 11, 12, 13, 15, 16, 17, 18, 20, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 41, 42, 43, 44, 46, 48, 50, 54, 57, 58, 60, 61, 65, 67, 70, 71, 73, 74, 75, 76, 77, 78, 80, 81, 82, 84, 85, 86, 88, 89]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l5-s7/tests/check.py b/tasks/construct-mc-vertex-cover-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s7/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-s7/tests/instance.json b/tasks/construct-mc-vertex-cover-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ff6ac17bba87435db2aeef49daafbce7b8881879 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 2], [0, 5], [0, 6], [0, 22], [0, 26], [0, 46], [0, 54], [0, 55], [0, 60], [0, 83], [0, 84], [1, 4], [1, 11], [1, 12], [1, 19], [1, 20], [1, 36], [1, 42], [1, 44], [1, 53], [1, 54], [1, 55], [1, 56], [1, 58], [1, 62], [1, 73], [1, 79], [1, 83], [1, 84], [1, 86], [2, 18], [2, 28], [2, 33], [2, 44], [2, 57], [2, 75], [3, 5], [3, 7], [3, 23], [3, 27], [3, 31], [3, 35], [3, 39], [3, 42], [3, 52], [3, 59], [3, 62], [3, 64], [3, 70], [3, 87], [4, 9], [4, 18], [4, 19], [4, 42], [4, 43], [4, 58], [4, 60], [4, 63], [4, 71], [4, 72], [4, 73], [4, 74], [4, 81], [4, 84], [4, 86], [5, 10], [5, 13], [5, 18], [5, 23], [5, 28], [5, 34], [5, 42], [5, 46], [5, 50], [5, 53], [5, 54], [5, 60], [5, 62], [5, 72], [5, 73], [5, 79], [5, 84], [5, 87], [5, 88], [5, 89], [6, 9], [6, 10], [6, 12], [6, 14], [6, 17], [6, 24], [6, 25], [6, 27], [6, 32], [6, 35], [6, 47], [6, 51], [6, 52], [6, 60], [6, 67], [6, 69], [6, 76], [6, 82], [7, 26], [7, 39], [7, 41], [7, 42], [7, 78], [8, 17], [8, 40], [8, 48], [9, 12], [9, 13], [9, 17], [9, 21], [9, 22], [9, 24], [9, 28], [9, 35], [9, 49], [9, 50], [9, 52], [9, 61], [9, 71], [9, 73], [9, 79], [10, 44], [10, 47], [10, 51], [10, 53], [10, 63], [10, 69], [11, 14], [11, 22], [11, 26], [11, 38], [11, 44], [11, 59], [11, 61], [11, 82], [11, 85], [12, 18], [12, 19], [12, 36], [12, 37], [12, 42], [12, 44], [12, 47], [12, 51], [12, 67], [12, 72], [13, 26], [13, 35], [13, 36], [13, 51], [13, 66], [13, 78], [13, 79], [13, 81], [13, 84], [13, 86], [14, 15], [14, 26], [14, 30], [14, 34], [14, 39], [14, 44], [14, 76], [14, 77], [14, 81], [14, 82], [15, 22], [15, 50], [15, 51], [15, 52], [15, 53], [15, 54], [15, 69], [15, 83], [16, 22], [16, 37], [16, 54], [16, 56], [16, 73], [16, 79], [16, 84], [16, 85], [17, 21], [17, 22], [17, 43], [17, 54], [17, 75], [17, 86], [17, 88], [18, 32], [18, 34], [18, 37], [18, 41], [18, 50], [18, 55], [18, 56], [18, 69], [18, 82], [19, 26], [19, 27], [19, 28], [19, 46], [19, 77], [19, 86], [20, 40], [20, 57], [20, 86], [21, 22], [21, 29], [21, 34], [21, 44], [21, 46], [21, 50], [21, 60], [21, 67], [21, 75], [21, 81], [21, 89], [22, 25], [22, 27], [22, 55], [22, 56], [22, 62], [22, 72], [22, 74], [22, 75], [22, 82], [23, 34], [23, 43], [23, 45], [23, 49], [23, 58], [23, 63], [23, 67], [23, 74], [23, 89], [24, 25], [24, 26], [24, 31], [24, 32], [24, 35], [24, 50], [24, 61], [24, 69], [24, 77], [24, 78], [24, 81], [24, 85], [25, 31], [25, 32], [25, 48], [25, 54], [25, 76], [25, 80], [25, 84], [25, 89], [26, 29], [26, 39], [26, 40], [26, 46], [26, 49], [26, 59], [26, 61], [26, 63], [26, 70], [26, 71], [26, 88], [27, 42], [27, 52], [27, 60], [27, 65], [27, 66], [27, 86], [28, 30], [28, 38], [28, 43], [28, 45], [28, 49], [28, 56], [28, 58], [28, 71], [28, 75], [28, 82], [28, 86], [28, 87], [29, 31], [29, 34], [29, 36], [29, 38], [29, 39], [29, 43], [29, 46], [29, 51], [29, 52], [29, 68], [29, 77], [29, 84], [29, 87], [30, 31], [30, 37], [30, 39], [30, 41], [30, 44], [30, 48], [30, 49], [30, 52], [30, 56], [30, 57], [30, 63], [30, 78], [30, 83], [31, 32], [31, 42], [31, 44], [31, 45], [31, 58], [31, 63], [31, 65], [31, 73], [31, 81], [32, 33], [32, 36], [32, 37], [32, 39], [32, 41], [32, 51], [32, 59], [32, 76], [32, 81], [33, 51], [33, 53], [33, 54], [33, 65], [33, 66], [33, 78], [33, 80], [33, 81], [33, 88], [34, 37], [34, 41], [34, 43], [34, 47], [34, 48], [34, 63], [34, 75], [34, 77], [35, 41], [35, 58], [35, 67], [35, 73], [35, 81], [36, 38], [36, 51], [36, 58], [36, 60], [36, 64], [36, 66], [36, 80], [37, 39], [37, 56], [37, 58], [37, 61], [37, 66], [37, 69], [37, 81], [38, 48], [38, 52], [38, 67], [38, 68], [38, 74], [38, 76], [38, 78], [38, 80], [38, 84], [38, 85], [39, 43], [39, 47], [39, 48], [39, 49], [39, 50], [39, 55], [39, 63], [39, 69], [39, 74], [39, 81], [39, 82], [40, 44], [40, 50], [40, 54], [40, 56], [40, 58], [40, 68], [40, 69], [40, 73], [40, 88], [40, 89], [41, 49], [41, 54], [41, 62], [41, 63], [41, 67], [41, 89], [42, 46], [42, 58], [42, 65], [42, 66], [42, 69], [42, 77], [42, 82], [43, 50], [43, 59], [44, 45], [44, 61], [44, 65], [44, 67], [44, 72], [44, 74], [44, 78], [45, 76], [45, 86], [46, 60], [46, 77], [47, 57], [47, 58], [47, 70], [47, 71], [47, 73], [47, 75], [48, 52], [48, 56], [48, 71], [48, 78], [48, 80], [48, 84], [48, 86], [49, 50], [49, 58], [49, 77], [50, 52], [50, 71], [50, 73], [50, 85], [50, 86], [51, 61], [51, 86], [52, 73], [52, 75], [52, 80], [53, 57], [53, 58], [53, 77], [54, 58], [54, 60], [54, 63], [54, 72], [54, 74], [55, 74], [55, 84], [56, 58], [56, 60], [56, 61], [56, 67], [56, 70], [56, 75], [56, 76], [56, 80], [56, 88], [57, 67], [57, 69], [57, 70], [57, 73], [57, 74], [57, 86], [58, 62], [58, 64], [58, 65], [58, 68], [58, 74], [58, 78], [58, 81], [58, 85], [59, 80], [59, 81], [59, 84], [59, 89], [60, 62], [60, 63], [60, 83], [61, 75], [61, 79], [61, 82], [61, 87], [62, 67], [62, 85], [63, 73], [63, 81], [63, 88], [64, 88], [65, 68], [65, 69], [66, 71], [66, 73], [66, 77], [66, 86], [66, 88], [67, 69], [67, 74], [67, 77], [68, 85], [70, 71], [70, 80], [70, 81], [70, 86], [70, 88], [71, 72], [71, 73], [71, 79], [71, 81], [72, 74], [72, 89], [73, 75], [73, 78], [73, 79], [73, 82], [73, 89], [74, 77], [74, 84], [74, 87], [75, 76], [75, 79], [75, 85], [75, 89], [76, 83], [77, 83], [78, 83], [79, 85], [80, 88], [82, 87], [84, 89]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s7/tests/run.py b/tasks/construct-mc-vertex-cover-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-vertex-cover-l5-s7/tests/test.sh b/tasks/construct-mc-vertex-cover-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-vertex-cover-l5-s9/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l5-s9/environment/instance.json b/tasks/construct-mc-vertex-cover-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2cfc444030a585f8ea912667ea9bcc84d10eebd2 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 14], [0, 16], [0, 31], [0, 39], [0, 44], [0, 46], [0, 57], [0, 60], [0, 71], [0, 74], [0, 76], [0, 80], [0, 81], [1, 7], [1, 10], [1, 11], [1, 15], [1, 30], [1, 31], [1, 44], [1, 45], [1, 53], [1, 58], [1, 62], [1, 64], [1, 71], [2, 7], [2, 11], [2, 22], [2, 23], [2, 38], [2, 40], [2, 49], [2, 58], [2, 59], [2, 63], [2, 76], [3, 6], [3, 12], [3, 16], [3, 36], [3, 47], [3, 56], [3, 57], [3, 70], [3, 75], [3, 78], [3, 86], [4, 28], [4, 47], [4, 57], [4, 62], [4, 79], [4, 84], [4, 87], [4, 88], [5, 9], [5, 14], [5, 16], [5, 25], [5, 29], [5, 34], [5, 41], [5, 46], [5, 50], [5, 51], [5, 54], [5, 55], [5, 57], [5, 69], [5, 74], [5, 80], [5, 87], [6, 16], [6, 22], [6, 26], [6, 28], [6, 36], [6, 37], [6, 43], [7, 18], [7, 22], [7, 25], [7, 27], [7, 31], [7, 32], [7, 34], [7, 36], [7, 46], [7, 58], [7, 63], [7, 64], [7, 70], [7, 75], [7, 84], [8, 21], [8, 25], [8, 26], [8, 39], [8, 40], [8, 41], [8, 42], [8, 43], [8, 44], [8, 53], [8, 59], [8, 60], [8, 61], [8, 65], [8, 67], [8, 70], [8, 89], [9, 10], [9, 11], [9, 20], [9, 34], [9, 35], [9, 37], [9, 40], [9, 43], [9, 57], [9, 59], [9, 63], [9, 69], [9, 72], [9, 73], [9, 79], [9, 84], [10, 14], [10, 26], [10, 29], [10, 40], [10, 45], [10, 64], [10, 74], [10, 83], [11, 12], [11, 13], [11, 29], [11, 30], [11, 42], [11, 52], [11, 65], [11, 69], [11, 71], [11, 78], [11, 89], [12, 13], [12, 17], [12, 19], [12, 20], [12, 22], [12, 38], [12, 40], [12, 48], [12, 52], [12, 53], [12, 57], [12, 61], [12, 62], [12, 65], [12, 67], [12, 72], [12, 73], [12, 82], [12, 87], [12, 88], [13, 22], [13, 23], [13, 24], [13, 28], [13, 34], [13, 42], [13, 47], [13, 48], [13, 52], [13, 56], [13, 75], [13, 81], [13, 88], [14, 30], [14, 32], [14, 34], [14, 40], [14, 44], [14, 45], [14, 47], [14, 57], [14, 59], [14, 64], [14, 68], [14, 82], [15, 17], [15, 20], [15, 29], [15, 34], [15, 36], [15, 42], [15, 44], [15, 52], [15, 53], [15, 67], [15, 68], [15, 74], [15, 80], [15, 82], [16, 30], [16, 35], [16, 36], [16, 37], [16, 41], [16, 53], [16, 71], [16, 73], [16, 83], [16, 89], [17, 38], [17, 39], [17, 44], [17, 47], [17, 78], [17, 87], [17, 88], [18, 20], [18, 22], [18, 32], [18, 34], [18, 36], [18, 41], [18, 45], [18, 47], [18, 49], [18, 57], [18, 67], [18, 84], [18, 87], [18, 88], [19, 34], [19, 37], [19, 45], [19, 64], [19, 71], [19, 73], [19, 81], [20, 34], [20, 36], [20, 41], [20, 42], [20, 46], [20, 48], [20, 56], [20, 58], [20, 83], [20, 86], [21, 23], [21, 29], [21, 30], [21, 31], [21, 32], [21, 45], [21, 49], [21, 56], [21, 57], [21, 58], [21, 66], [21, 70], [21, 84], [21, 87], [22, 23], [22, 27], [22, 32], [22, 34], [22, 37], [22, 38], [22, 48], [22, 54], [22, 57], [22, 64], [22, 66], [22, 68], [22, 77], [22, 78], [23, 27], [23, 36], [23, 44], [23, 51], [23, 61], [23, 75], [24, 52], [24, 53], [24, 61], [24, 85], [24, 87], [25, 28], [25, 37], [25, 49], [25, 51], [25, 54], [25, 64], [25, 70], [25, 83], [26, 32], [26, 36], [26, 42], [26, 79], [26, 84], [27, 49], [27, 52], [27, 79], [27, 89], [28, 41], [28, 64], [29, 30], [29, 33], [29, 35], [29, 40], [29, 41], [29, 42], [29, 45], [29, 55], [29, 70], [29, 72], [29, 77], [29, 80], [29, 81], [29, 88], [30, 31], [30, 36], [30, 37], [30, 41], [30, 52], [30, 56], [30, 58], [30, 61], [30, 65], [30, 79], [30, 81], [30, 83], [31, 34], [31, 44], [31, 46], [31, 47], [31, 55], [31, 57], [31, 75], [31, 78], [31, 86], [32, 41], [32, 45], [32, 52], [32, 60], [32, 63], [32, 67], [32, 70], [32, 72], [32, 78], [32, 79], [32, 81], [33, 36], [33, 42], [33, 55], [33, 56], [33, 62], [33, 69], [33, 82], [34, 39], [34, 45], [34, 54], [34, 61], [34, 62], [34, 66], [34, 72], [34, 76], [34, 78], [34, 81], [34, 83], [34, 84], [34, 86], [34, 89], [35, 43], [35, 45], [35, 52], [35, 59], [35, 69], [35, 72], [35, 79], [35, 81], [35, 84], [35, 89], [36, 38], [36, 48], [36, 56], [36, 59], [36, 62], [36, 63], [36, 64], [36, 68], [36, 80], [36, 84], [37, 45], [37, 61], [37, 77], [37, 84], [38, 42], [38, 64], [39, 41], [39, 52], [39, 61], [39, 83], [39, 88], [40, 41], [40, 51], [40, 54], [40, 57], [40, 58], [40, 63], [40, 72], [40, 76], [40, 79], [40, 83], [40, 86], [41, 46], [41, 49], [41, 52], [41, 66], [41, 83], [42, 45], [42, 49], [42, 55], [42, 56], [42, 65], [42, 72], [42, 73], [42, 74], [42, 79], [42, 83], [42, 86], [43, 68], [43, 79], [43, 85], [43, 87], [43, 89], [44, 48], [44, 75], [44, 87], [45, 46], [45, 52], [45, 55], [45, 60], [45, 65], [45, 79], [45, 84], [46, 48], [46, 61], [46, 76], [46, 83], [46, 88], [47, 50], [47, 53], [47, 59], [47, 66], [47, 69], [47, 83], [47, 84], [48, 53], [48, 58], [48, 59], [48, 62], [48, 71], [48, 72], [48, 73], [48, 81], [48, 87], [49, 55], [49, 63], [49, 64], [49, 66], [49, 71], [49, 79], [49, 87], [49, 89], [50, 88], [51, 52], [51, 57], [51, 61], [51, 66], [51, 68], [51, 74], [51, 77], [51, 80], [51, 87], [52, 64], [52, 70], [52, 72], [52, 83], [52, 84], [52, 86], [52, 88], [53, 57], [53, 58], [53, 67], [53, 72], [53, 75], [53, 82], [54, 65], [54, 69], [54, 78], [54, 80], [55, 62], [55, 64], [55, 73], [55, 78], [56, 58], [56, 66], [56, 71], [56, 73], [56, 81], [56, 88], [57, 67], [57, 72], [57, 77], [58, 68], [58, 74], [58, 75], [58, 86], [59, 64], [59, 78], [59, 82], [59, 89], [61, 67], [61, 70], [61, 74], [61, 80], [62, 67], [62, 69], [62, 78], [62, 80], [62, 84], [63, 71], [63, 84], [63, 89], [64, 76], [64, 84], [64, 89], [66, 74], [67, 77], [68, 69], [68, 85], [68, 89], [69, 73], [69, 82], [70, 73], [70, 78], [70, 79], [70, 82], [71, 87], [71, 88], [72, 81], [72, 84], [73, 75], [73, 76], [73, 77], [75, 79], [76, 82], [76, 85], [76, 87], [77, 81], [77, 88], [78, 79], [78, 83], [81, 82], [81, 84], [81, 89], [82, 87], [83, 85], [85, 87], [85, 88]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s9/solution/solve.sh b/tasks/construct-mc-vertex-cover-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6c7c0a88d181ade07fbd69f8838b91c4e97020e3 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [0, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 17, 20, 21, 22, 23, 25, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 40, 41, 42, 44, 45, 47, 48, 49, 51, 52, 53, 54, 57, 58, 59, 61, 62, 64, 66, 67, 68, 71, 73, 76, 78, 79, 81, 82, 83, 84, 85, 87, 88, 89]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l5-s9/tests/check.py b/tasks/construct-mc-vertex-cover-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s9/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-s9/tests/instance.json b/tasks/construct-mc-vertex-cover-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2cfc444030a585f8ea912667ea9bcc84d10eebd2 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 14], [0, 16], [0, 31], [0, 39], [0, 44], [0, 46], [0, 57], [0, 60], [0, 71], [0, 74], [0, 76], [0, 80], [0, 81], [1, 7], [1, 10], [1, 11], [1, 15], [1, 30], [1, 31], [1, 44], [1, 45], [1, 53], [1, 58], [1, 62], [1, 64], [1, 71], [2, 7], [2, 11], [2, 22], [2, 23], [2, 38], [2, 40], [2, 49], [2, 58], [2, 59], [2, 63], [2, 76], [3, 6], [3, 12], [3, 16], [3, 36], [3, 47], [3, 56], [3, 57], [3, 70], [3, 75], [3, 78], [3, 86], [4, 28], [4, 47], [4, 57], [4, 62], [4, 79], [4, 84], [4, 87], [4, 88], [5, 9], [5, 14], [5, 16], [5, 25], [5, 29], [5, 34], [5, 41], [5, 46], [5, 50], [5, 51], [5, 54], [5, 55], [5, 57], [5, 69], [5, 74], [5, 80], [5, 87], [6, 16], [6, 22], [6, 26], [6, 28], [6, 36], [6, 37], [6, 43], [7, 18], [7, 22], [7, 25], [7, 27], [7, 31], [7, 32], [7, 34], [7, 36], [7, 46], [7, 58], [7, 63], [7, 64], [7, 70], [7, 75], [7, 84], [8, 21], [8, 25], [8, 26], [8, 39], [8, 40], [8, 41], [8, 42], [8, 43], [8, 44], [8, 53], [8, 59], [8, 60], [8, 61], [8, 65], [8, 67], [8, 70], [8, 89], [9, 10], [9, 11], [9, 20], [9, 34], [9, 35], [9, 37], [9, 40], [9, 43], [9, 57], [9, 59], [9, 63], [9, 69], [9, 72], [9, 73], [9, 79], [9, 84], [10, 14], [10, 26], [10, 29], [10, 40], [10, 45], [10, 64], [10, 74], [10, 83], [11, 12], [11, 13], [11, 29], [11, 30], [11, 42], [11, 52], [11, 65], [11, 69], [11, 71], [11, 78], [11, 89], [12, 13], [12, 17], [12, 19], [12, 20], [12, 22], [12, 38], [12, 40], [12, 48], [12, 52], [12, 53], [12, 57], [12, 61], [12, 62], [12, 65], [12, 67], [12, 72], [12, 73], [12, 82], [12, 87], [12, 88], [13, 22], [13, 23], [13, 24], [13, 28], [13, 34], [13, 42], [13, 47], [13, 48], [13, 52], [13, 56], [13, 75], [13, 81], [13, 88], [14, 30], [14, 32], [14, 34], [14, 40], [14, 44], [14, 45], [14, 47], [14, 57], [14, 59], [14, 64], [14, 68], [14, 82], [15, 17], [15, 20], [15, 29], [15, 34], [15, 36], [15, 42], [15, 44], [15, 52], [15, 53], [15, 67], [15, 68], [15, 74], [15, 80], [15, 82], [16, 30], [16, 35], [16, 36], [16, 37], [16, 41], [16, 53], [16, 71], [16, 73], [16, 83], [16, 89], [17, 38], [17, 39], [17, 44], [17, 47], [17, 78], [17, 87], [17, 88], [18, 20], [18, 22], [18, 32], [18, 34], [18, 36], [18, 41], [18, 45], [18, 47], [18, 49], [18, 57], [18, 67], [18, 84], [18, 87], [18, 88], [19, 34], [19, 37], [19, 45], [19, 64], [19, 71], [19, 73], [19, 81], [20, 34], [20, 36], [20, 41], [20, 42], [20, 46], [20, 48], [20, 56], [20, 58], [20, 83], [20, 86], [21, 23], [21, 29], [21, 30], [21, 31], [21, 32], [21, 45], [21, 49], [21, 56], [21, 57], [21, 58], [21, 66], [21, 70], [21, 84], [21, 87], [22, 23], [22, 27], [22, 32], [22, 34], [22, 37], [22, 38], [22, 48], [22, 54], [22, 57], [22, 64], [22, 66], [22, 68], [22, 77], [22, 78], [23, 27], [23, 36], [23, 44], [23, 51], [23, 61], [23, 75], [24, 52], [24, 53], [24, 61], [24, 85], [24, 87], [25, 28], [25, 37], [25, 49], [25, 51], [25, 54], [25, 64], [25, 70], [25, 83], [26, 32], [26, 36], [26, 42], [26, 79], [26, 84], [27, 49], [27, 52], [27, 79], [27, 89], [28, 41], [28, 64], [29, 30], [29, 33], [29, 35], [29, 40], [29, 41], [29, 42], [29, 45], [29, 55], [29, 70], [29, 72], [29, 77], [29, 80], [29, 81], [29, 88], [30, 31], [30, 36], [30, 37], [30, 41], [30, 52], [30, 56], [30, 58], [30, 61], [30, 65], [30, 79], [30, 81], [30, 83], [31, 34], [31, 44], [31, 46], [31, 47], [31, 55], [31, 57], [31, 75], [31, 78], [31, 86], [32, 41], [32, 45], [32, 52], [32, 60], [32, 63], [32, 67], [32, 70], [32, 72], [32, 78], [32, 79], [32, 81], [33, 36], [33, 42], [33, 55], [33, 56], [33, 62], [33, 69], [33, 82], [34, 39], [34, 45], [34, 54], [34, 61], [34, 62], [34, 66], [34, 72], [34, 76], [34, 78], [34, 81], [34, 83], [34, 84], [34, 86], [34, 89], [35, 43], [35, 45], [35, 52], [35, 59], [35, 69], [35, 72], [35, 79], [35, 81], [35, 84], [35, 89], [36, 38], [36, 48], [36, 56], [36, 59], [36, 62], [36, 63], [36, 64], [36, 68], [36, 80], [36, 84], [37, 45], [37, 61], [37, 77], [37, 84], [38, 42], [38, 64], [39, 41], [39, 52], [39, 61], [39, 83], [39, 88], [40, 41], [40, 51], [40, 54], [40, 57], [40, 58], [40, 63], [40, 72], [40, 76], [40, 79], [40, 83], [40, 86], [41, 46], [41, 49], [41, 52], [41, 66], [41, 83], [42, 45], [42, 49], [42, 55], [42, 56], [42, 65], [42, 72], [42, 73], [42, 74], [42, 79], [42, 83], [42, 86], [43, 68], [43, 79], [43, 85], [43, 87], [43, 89], [44, 48], [44, 75], [44, 87], [45, 46], [45, 52], [45, 55], [45, 60], [45, 65], [45, 79], [45, 84], [46, 48], [46, 61], [46, 76], [46, 83], [46, 88], [47, 50], [47, 53], [47, 59], [47, 66], [47, 69], [47, 83], [47, 84], [48, 53], [48, 58], [48, 59], [48, 62], [48, 71], [48, 72], [48, 73], [48, 81], [48, 87], [49, 55], [49, 63], [49, 64], [49, 66], [49, 71], [49, 79], [49, 87], [49, 89], [50, 88], [51, 52], [51, 57], [51, 61], [51, 66], [51, 68], [51, 74], [51, 77], [51, 80], [51, 87], [52, 64], [52, 70], [52, 72], [52, 83], [52, 84], [52, 86], [52, 88], [53, 57], [53, 58], [53, 67], [53, 72], [53, 75], [53, 82], [54, 65], [54, 69], [54, 78], [54, 80], [55, 62], [55, 64], [55, 73], [55, 78], [56, 58], [56, 66], [56, 71], [56, 73], [56, 81], [56, 88], [57, 67], [57, 72], [57, 77], [58, 68], [58, 74], [58, 75], [58, 86], [59, 64], [59, 78], [59, 82], [59, 89], [61, 67], [61, 70], [61, 74], [61, 80], [62, 67], [62, 69], [62, 78], [62, 80], [62, 84], [63, 71], [63, 84], [63, 89], [64, 76], [64, 84], [64, 89], [66, 74], [67, 77], [68, 69], [68, 85], [68, 89], [69, 73], [69, 82], [70, 73], [70, 78], [70, 79], [70, 82], [71, 87], [71, 88], [72, 81], [72, 84], [73, 75], [73, 76], [73, 77], [75, 79], [76, 82], [76, 85], [76, 87], [77, 81], [77, 88], [78, 79], [78, 83], [81, 82], [81, 84], [81, 89], [82, 87], [83, 85], [85, 87], [85, 88]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s9/tests/run.py b/tasks/construct-mc-vertex-cover-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l5-s9/tests/test.sh b/tasks/construct-mc-vertex-cover-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l6-s2/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l6-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-vertex-cover-l6-s2/environment/instance.json b/tasks/construct-mc-vertex-cover-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..64877d8e5aec2ea9897ccc3928c8f1126d4a9a56 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 140, "k": 107, "edges": [[0, 5], [0, 14], [0, 23], [0, 45], [0, 47], [0, 60], [0, 61], [0, 69], [0, 73], [0, 86], [0, 87], [0, 98], [0, 100], [0, 106], [0, 115], [0, 116], [0, 117], [0, 132], [1, 10], [1, 19], [1, 55], [1, 60], [1, 86], [1, 91], [1, 95], [1, 99], [1, 102], [1, 108], [1, 109], [1, 113], [1, 135], [1, 136], [2, 8], [2, 9], [2, 11], [2, 14], [2, 18], [2, 19], [2, 32], [2, 34], [2, 52], [2, 68], [2, 101], [2, 102], [2, 103], [2, 106], [2, 116], [2, 118], [2, 121], [2, 122], [2, 128], [2, 136], [3, 10], [3, 13], [3, 14], [3, 38], [3, 47], [3, 49], [3, 50], [3, 56], [3, 68], [3, 81], [3, 96], [3, 105], [3, 107], [3, 116], [3, 129], [3, 130], [3, 134], [3, 135], [4, 13], [4, 29], [4, 38], [4, 39], [4, 46], [4, 56], [4, 66], [4, 76], [4, 78], [4, 89], [4, 92], [4, 94], [4, 97], [4, 101], [4, 109], [4, 113], [4, 120], [4, 139], [5, 29], [5, 30], [5, 32], [5, 36], [5, 49], [5, 53], [5, 58], [5, 67], [5, 70], [5, 82], [5, 85], [5, 95], [5, 102], [5, 106], [5, 110], [5, 111], [5, 123], [5, 133], [6, 8], [6, 20], [6, 21], [6, 38], [6, 40], [6, 46], [6, 54], [6, 57], [6, 58], [6, 63], [6, 64], [6, 74], [6, 78], [6, 79], [6, 86], [6, 106], [6, 107], [6, 113], [6, 115], [6, 139], [7, 10], [7, 15], [7, 24], [7, 31], [7, 52], [7, 53], [7, 59], [7, 68], [7, 78], [7, 101], [7, 103], [7, 107], [7, 115], [8, 11], [8, 18], [8, 28], [8, 48], [8, 51], [8, 57], [8, 64], [8, 71], [8, 75], [8, 77], [8, 92], [8, 114], [8, 115], [8, 120], [8, 125], [8, 135], [9, 17], [9, 26], [9, 29], [9, 35], [9, 38], [9, 55], [9, 64], [9, 83], [9, 85], [9, 93], [9, 103], [9, 105], [9, 109], [9, 119], [9, 137], [10, 12], [10, 24], [10, 30], [10, 42], [10, 46], [10, 47], [10, 56], [10, 74], [10, 83], [10, 90], [10, 95], [10, 96], [10, 103], [10, 113], [10, 114], [10, 127], [10, 133], [10, 137], [11, 24], [11, 26], [11, 33], [11, 46], [11, 48], [11, 52], [11, 55], [11, 67], [11, 73], [11, 79], [11, 85], [11, 92], [11, 107], [11, 109], [11, 125], [12, 13], [12, 14], [12, 17], [12, 22], [12, 31], [12, 34], [12, 36], [12, 45], [12, 48], [12, 52], [12, 61], [12, 62], [12, 64], [12, 82], [12, 86], [12, 88], [12, 89], [12, 98], [12, 110], [12, 113], [12, 128], [13, 24], [13, 25], [13, 31], [13, 37], [13, 46], [13, 64], [13, 69], [13, 70], [13, 75], [13, 78], [13, 82], [13, 83], [13, 84], [13, 93], [13, 101], [13, 107], [13, 120], [13, 123], [13, 135], [14, 19], [14, 28], [14, 29], [14, 31], [14, 40], [14, 47], [14, 48], [14, 65], [14, 72], [14, 78], [14, 89], [14, 91], [14, 101], [14, 104], [14, 112], [14, 115], [14, 116], [14, 128], [15, 27], [15, 36], [15, 39], [15, 42], [15, 46], [15, 50], [15, 55], [15, 59], [15, 67], [15, 71], [15, 72], [15, 80], [15, 82], [15, 85], [15, 86], [15, 87], [15, 101], [15, 110], [15, 138], [16, 23], [16, 24], [16, 26], [16, 43], [16, 44], [16, 45], [16, 58], [16, 60], [16, 62], [16, 66], [16, 76], [16, 79], [16, 83], [16, 86], [16, 87], [16, 89], [16, 90], [16, 111], [16, 113], [16, 121], [16, 138], [17, 21], [17, 35], [17, 37], [17, 53], [17, 62], [17, 65], [17, 67], [17, 87], [17, 96], [17, 103], [17, 108], [17, 109], [17, 136], [17, 137], [17, 138], [18, 22], [18, 23], [18, 29], [18, 39], [18, 41], [18, 43], [18, 46], [18, 63], [18, 70], [18, 81], [18, 83], [18, 85], [18, 103], [18, 106], [18, 110], [18, 120], [18, 135], [18, 136], [19, 22], [19, 30], [19, 36], [19, 50], [19, 60], [19, 65], [19, 71], [19, 74], [19, 76], [19, 83], [19, 88], [19, 102], [19, 109], [20, 41], [20, 46], [20, 58], [20, 60], [20, 61], [20, 69], [20, 72], [20, 75], [20, 76], [20, 77], [20, 90], [20, 95], [20, 111], [20, 113], [20, 115], [20, 128], [20, 137], [21, 23], [21, 36], [21, 40], [21, 51], [21, 54], [21, 77], [21, 79], [21, 81], [21, 88], [21, 97], [21, 98], [21, 102], [21, 118], [21, 119], [21, 122], [21, 123], [22, 38], [22, 40], [22, 41], [22, 63], [22, 73], [22, 82], [22, 90], [22, 92], [22, 103], [22, 114], [22, 119], [22, 122], [22, 124], [22, 126], [22, 128], [22, 129], [23, 29], [23, 59], [23, 72], [23, 76], [23, 86], [23, 95], [23, 97], [23, 110], [23, 117], [23, 126], [23, 132], [23, 139], [24, 48], [24, 50], [24, 58], [24, 61], [24, 62], [24, 66], [24, 79], [24, 87], [24, 89], [24, 100], [24, 108], [24, 114], [24, 125], [24, 132], [25, 26], [25, 36], [25, 58], [25, 61], [25, 78], [25, 79], [25, 82], [25, 84], [25, 86], [25, 97], [25, 108], [25, 121], [25, 129], [25, 138], [26, 29], [26, 30], [26, 53], [26, 54], [26, 56], [26, 57], [26, 66], [26, 71], [26, 73], [26, 91], [26, 98], [26, 99], [26, 116], [26, 119], [26, 132], [26, 133], [27, 28], [27, 36], [27, 49], [27, 51], [27, 73], [27, 78], [27, 93], [28, 33], [28, 39], [28, 65], [28, 73], [28, 80], [28, 83], [28, 85], [28, 87], [28, 88], [28, 90], [28, 92], [28, 112], [28, 121], [28, 126], [29, 33], [29, 43], [29, 51], [29, 52], [29, 54], [29, 61], [29, 64], [29, 67], [29, 68], [29, 69], [29, 77], [29, 86], [29, 91], [29, 95], [29, 98], [29, 99], [29, 101], [29, 120], [29, 128], [29, 136], [30, 44], [30, 53], [30, 59], [30, 61], [30, 62], [30, 72], [30, 78], [30, 84], [30, 85], [30, 89], [30, 91], [30, 95], [30, 96], [30, 104], [30, 116], [30, 122], [30, 129], [30, 132], [31, 51], [31, 52], [31, 60], [31, 79], [31, 82], [31, 87], [31, 88], [31, 92], [31, 98], [31, 104], [31, 106], [31, 122], [31, 131], [31, 135], [32, 35], [32, 39], [32, 40], [32, 43], [32, 47], [32, 58], [32, 62], [32, 69], [32, 81], [32, 84], [32, 87], [32, 88], [32, 98], [32, 112], [32, 127], [32, 129], [33, 40], [33, 43], [33, 44], [33, 53], [33, 54], [33, 72], [33, 73], [33, 75], [33, 77], [33, 79], [33, 84], [33, 86], [33, 89], [33, 90], [33, 97], [33, 105], [33, 109], [33, 110], [33, 111], [33, 112], [33, 117], [33, 118], [33, 126], [33, 127], [33, 128], [33, 129], [33, 131], [34, 39], [34, 46], [34, 53], [34, 62], [34, 85], [34, 91], [34, 92], [34, 94], [34, 111], [34, 116], [34, 125], [35, 41], [35, 44], [35, 50], [35, 51], [35, 53], [35, 85], [35, 91], [35, 100], [35, 101], [35, 123], [35, 126], [36, 37], [36, 43], [36, 47], [36, 50], [36, 52], [36, 55], [36, 57], [36, 77], [36, 84], [36, 110], [36, 133], [37, 39], [37, 40], [37, 42], [37, 64], [37, 66], [37, 68], [37, 82], [37, 83], [37, 85], [37, 87], [37, 95], [37, 122], [37, 129], [37, 131], [38, 47], [38, 48], [38, 50], [38, 53], [38, 62], [38, 64], [38, 67], [38, 75], [38, 82], [38, 84], [38, 87], [38, 88], [38, 89], [38, 105], [38, 122], [38, 123], [38, 128], [38, 133], [38, 136], [39, 41], [39, 45], [39, 46], [39, 49], [39, 52], [39, 66], [39, 81], [39, 82], [39, 85], [39, 88], [39, 99], [39, 100], [39, 113], [39, 118], [39, 119], [39, 126], [39, 133], [40, 50], [40, 54], [40, 55], [40, 59], [40, 61], [40, 71], [40, 74], [40, 76], [40, 82], [40, 99], [40, 102], [40, 111], [40, 120], [40, 122], [40, 124], [40, 127], [40, 130], [40, 131], [40, 133], [40, 134], [41, 44], [41, 58], [41, 68], [41, 70], [41, 78], [41, 101], [41, 109], [41, 111], [41, 118], [41, 119], [41, 126], [42, 44], [42, 49], [42, 53], [42, 64], [42, 81], [42, 88], [42, 112], [42, 113], [42, 117], [42, 119], [42, 125], [42, 127], [42, 129], [43, 47], [43, 56], [43, 64], [43, 65], [43, 72], [43, 85], [43, 88], [43, 89], [43, 93], [43, 99], [43, 107], [43, 110], [43, 118], [43, 120], [43, 138], [44, 47], [44, 72], [44, 89], [44, 95], [44, 100], [44, 126], [44, 129], [44, 136], [45, 46], [45, 52], [45, 54], [45, 61], [45, 76], [45, 78], [45, 87], [45, 96], [45, 104], [45, 110], [45, 122], [46, 71], [46, 110], [46, 119], [46, 120], [46, 123], [46, 127], [46, 134], [46, 135], [47, 50], [47, 53], [47, 67], [47, 69], [47, 78], [47, 81], [47, 85], [47, 116], [47, 136], [48, 57], [48, 71], [48, 76], [48, 77], [48, 83], [48, 95], [48, 97], [48, 109], [48, 120], [48, 121], [48, 134], [49, 51], [49, 62], [49, 68], [49, 69], [49, 73], [49, 76], [49, 79], [49, 81], [49, 99], [49, 100], [49, 111], [49, 114], [49, 115], [49, 138], [50, 60], [50, 61], [50, 65], [50, 69], [50, 70], [50, 73], [50, 74], [50, 81], [50, 101], [50, 103], [50, 107], [50, 121], [50, 127], [50, 129], [50, 132], [50, 137], [50, 139], [51, 52], [51, 57], [51, 75], [51, 79], [51, 80], [51, 87], [51, 91], [51, 104], [51, 106], [51, 110], [51, 115], [51, 118], [51, 119], [51, 132], [51, 138], [51, 139], [52, 59], [52, 61], [52, 64], [52, 65], [52, 69], [52, 73], [52, 81], [52, 85], [52, 107], [52, 108], [52, 121], [53, 58], [53, 61], [53, 69], [53, 75], [53, 77], [53, 87], [53, 90], [53, 106], [53, 114], [53, 115], [53, 117], [53, 118], [53, 119], [53, 132], [54, 57], [54, 64], [54, 76], [54, 83], [54, 91], [54, 95], [54, 96], [54, 104], [54, 130], [54, 133], [54, 137], [54, 138], [55, 65], [55, 67], [55, 69], [55, 71], [55, 76], [55, 94], [55, 114], [55, 115], [55, 116], [55, 119], [55, 135], [55, 139], [56, 61], [56, 64], [56, 69], [56, 76], [56, 81], [56, 86], [56, 87], [56, 90], [56, 95], [56, 109], [56, 117], [56, 118], [56, 138], [57, 58], [57, 64], [57, 81], [57, 95], [57, 126], [57, 127], [57, 130], [57, 137], [57, 139], [58, 64], [58, 65], [58, 69], [58, 80], [58, 99], [58, 112], [58, 113], [58, 116], [58, 117], [58, 122], [58, 124], [58, 126], [58, 127], [58, 129], [58, 133], [59, 67], [59, 74], [59, 75], [59, 76], [59, 93], [59, 104], [59, 111], [59, 112], [59, 115], [59, 121], [59, 135], [59, 139], [60, 65], [60, 79], [60, 90], [60, 93], [60, 95], [60, 98], [60, 100], [60, 107], [60, 110], [60, 114], [60, 118], [60, 128], [61, 67], [61, 77], [61, 80], [61, 81], [61, 84], [61, 85], [61, 91], [61, 94], [61, 99], [61, 103], [61, 107], [61, 112], [61, 124], [62, 65], [62, 81], [62, 103], [62, 110], [62, 116], [62, 118], [62, 124], [62, 125], [62, 138], [63, 69], [63, 74], [63, 83], [63, 90], [63, 96], [63, 97], [63, 101], [63, 103], [63, 108], [63, 116], [63, 122], [63, 128], [64, 67], [64, 70], [64, 84], [64, 90], [64, 92], [64, 108], [64, 119], [64, 122], [64, 125], [64, 138], [64, 139], [65, 67], [65, 72], [65, 79], [65, 88], [65, 91], [65, 102], [65, 109], [65, 124], [65, 125], [65, 127], [65, 128], [65, 136], [66, 79], [66, 82], [66, 85], [66, 87], [66, 89], [66, 91], [66, 95], [66, 107], [66, 108], [66, 112], [66, 118], [66, 119], [66, 122], [66, 125], [66, 127], [66, 136], [67, 73], [67, 78], [67, 93], [67, 100], [67, 102], [67, 114], [67, 116], [67, 118], [67, 119], [67, 131], [67, 133], [67, 134], [68, 71], [68, 77], [68, 80], [68, 98], [68, 99], [68, 116], [68, 118], [68, 119], [68, 128], [69, 72], [69, 73], [69, 83], [69, 89], [69, 96], [69, 99], [69, 100], [69, 103], [69, 106], [69, 108], [69, 109], [69, 111], [69, 116], [69, 117], [69, 125], [69, 129], [69, 131], [69, 132], [69, 133], [69, 139], [70, 71], [70, 73], [70, 79], [70, 84], [70, 88], [70, 93], [70, 94], [70, 99], [70, 108], [70, 116], [70, 122], [70, 129], [70, 131], [71, 74], [71, 89], [71, 94], [71, 105], [71, 108], [71, 127], [71, 130], [71, 132], [71, 138], [71, 139], [72, 76], [72, 79], [72, 83], [72, 85], [72, 87], [72, 89], [72, 118], [72, 121], [72, 133], [73, 75], [73, 80], [73, 82], [73, 85], [73, 90], [73, 93], [73, 115], [73, 123], [73, 136], [74, 76], [74, 78], [74, 82], [74, 83], [74, 85], [74, 86], [74, 91], [74, 92], [74, 103], [74, 104], [74, 105], [74, 106], [74, 113], [74, 115], [74, 116], [74, 118], [74, 125], [74, 126], [74, 132], [74, 135], [75, 98], [75, 110], [75, 117], [75, 122], [75, 126], [75, 139], [76, 90], [76, 112], [76, 114], [76, 131], [77, 78], [77, 85], [77, 87], [77, 92], [77, 113], [77, 118], [77, 139], [78, 80], [78, 86], [78, 103], [78, 108], [78, 111], [78, 118], [78, 120], [78, 129], [79, 88], [79, 90], [79, 119], [79, 131], [80, 81], [80, 83], [80, 86], [80, 96], [80, 98], [81, 87], [81, 89], [81, 94], [81, 97], [81, 98], [81, 107], [81, 109], [81, 122], [81, 124], [81, 130], [81, 135], [81, 136], [82, 87], [82, 100], [82, 102], [82, 110], [82, 111], [82, 122], [82, 125], [83, 113], [83, 116], [83, 120], [83, 122], [83, 136], [84, 91], [84, 104], [84, 106], [84, 107], [84, 114], [84, 115], [84, 122], [84, 129], [85, 99], [85, 102], [85, 108], [85, 113], [85, 118], [85, 128], [85, 131], [85, 133], [85, 134], [85, 138], [86, 97], [86, 106], [86, 107], [86, 109], [86, 115], [86, 119], [86, 121], [86, 122], [86, 124], [86, 131], [87, 99], [87, 104], [87, 117], [87, 120], [87, 125], [87, 132], [88, 89], [88, 97], [88, 105], [88, 110], [88, 111], [88, 115], [88, 121], [89, 120], [89, 126], [89, 128], [89, 130], [89, 134], [90, 94], [90, 109], [90, 121], [90, 123], [90, 124], [90, 127], [90, 131], [90, 133], [90, 136], [91, 111], [91, 126], [92, 103], [92, 110], [92, 120], [92, 124], [92, 129], [92, 133], [92, 135], [93, 101], [93, 112], [93, 125], [93, 132], [93, 133], [93, 139], [94, 99], [94, 102], [94, 104], [94, 111], [94, 113], [95, 101], [95, 104], [95, 114], [95, 121], [95, 127], [95, 129], [95, 138], [96, 108], [96, 109], [96, 128], [96, 129], [97, 100], [97, 109], [97, 110], [97, 112], [97, 115], [97, 127], [97, 128], [97, 136], [97, 137], [98, 115], [98, 118], [98, 127], [98, 128], [98, 130], [98, 133], [98, 135], [99, 103], [99, 104], [99, 115], [99, 118], [99, 127], [99, 136], [100, 126], [100, 131], [101, 115], [101, 130], [102, 111], [102, 118], [102, 138], [103, 110], [103, 118], [103, 127], [104, 105], [104, 114], [104, 115], [104, 117], [104, 121], [105, 107], [105, 111], [105, 112], [105, 116], [105, 120], [105, 138], [105, 139], [106, 127], [107, 109], [107, 120], [107, 123], [107, 126], [107, 130], [108, 113], [108, 115], [108, 123], [108, 125], [108, 126], [108, 134], [108, 137], [108, 138], [108, 139], [109, 128], [109, 130], [109, 133], [109, 139], [110, 121], [110, 124], [110, 131], [111, 112], [111, 119], [111, 121], [112, 113], [112, 116], [112, 121], [112, 122], [112, 134], [112, 138], [113, 114], [113, 122], [113, 126], [113, 135], [114, 122], [114, 126], [114, 128], [114, 131], [114, 132], [115, 120], [115, 121], [115, 122], [115, 128], [115, 135], [116, 119], [116, 135], [117, 120], [117, 125], [117, 139], [118, 122], [118, 128], [118, 135], [118, 136], [118, 138], [119, 120], [119, 128], [119, 132], [119, 134], [121, 124], [121, 125], [121, 130], [121, 138], [122, 125], [123, 126], [123, 128], [127, 128], [127, 131], [127, 134], [127, 139], [128, 130], [128, 134], [129, 133], [129, 136], [130, 137], [131, 132], [131, 139], [133, 136], [133, 137], [133, 139], [135, 136], [135, 138], [136, 139]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l6-s2/solution/solve.sh b/tasks/construct-mc-vertex-cover-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..13142897e184f396c3b9d6100845faa9f09ef7b2 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 13, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 28, 29, 31, 33, 35, 36, 37, 38, 39, 40, 43, 44, 46, 47, 48, 49, 51, 52, 53, 54, 55, 58, 59, 60, 61, 62, 64, 65, 67, 68, 69, 70, 72, 73, 74, 76, 78, 79, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 101, 103, 104, 105, 107, 108, 109, 110, 111, 112, 113, 115, 116, 117, 118, 119, 121, 122, 125, 126, 127, 128, 129, 130, 131, 132, 136, 137, 138, 139]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l6-s2/tests/check.py b/tasks/construct-mc-vertex-cover-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l6-s2/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l6-s2/tests/instance.json b/tasks/construct-mc-vertex-cover-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..64877d8e5aec2ea9897ccc3928c8f1126d4a9a56 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 140, "k": 107, "edges": [[0, 5], [0, 14], [0, 23], [0, 45], [0, 47], [0, 60], [0, 61], [0, 69], [0, 73], [0, 86], [0, 87], [0, 98], [0, 100], [0, 106], [0, 115], [0, 116], [0, 117], [0, 132], [1, 10], [1, 19], [1, 55], [1, 60], [1, 86], [1, 91], [1, 95], [1, 99], [1, 102], [1, 108], [1, 109], [1, 113], [1, 135], [1, 136], [2, 8], [2, 9], [2, 11], [2, 14], [2, 18], [2, 19], [2, 32], [2, 34], [2, 52], [2, 68], [2, 101], [2, 102], [2, 103], [2, 106], [2, 116], [2, 118], [2, 121], [2, 122], [2, 128], [2, 136], [3, 10], [3, 13], [3, 14], [3, 38], [3, 47], [3, 49], [3, 50], [3, 56], [3, 68], [3, 81], [3, 96], [3, 105], [3, 107], [3, 116], [3, 129], [3, 130], [3, 134], [3, 135], [4, 13], [4, 29], [4, 38], [4, 39], [4, 46], [4, 56], [4, 66], [4, 76], [4, 78], [4, 89], [4, 92], [4, 94], [4, 97], [4, 101], [4, 109], [4, 113], [4, 120], [4, 139], [5, 29], [5, 30], [5, 32], [5, 36], [5, 49], [5, 53], [5, 58], [5, 67], [5, 70], [5, 82], [5, 85], [5, 95], [5, 102], [5, 106], [5, 110], [5, 111], [5, 123], [5, 133], [6, 8], [6, 20], [6, 21], [6, 38], [6, 40], [6, 46], [6, 54], [6, 57], [6, 58], [6, 63], [6, 64], [6, 74], [6, 78], [6, 79], [6, 86], [6, 106], [6, 107], [6, 113], [6, 115], [6, 139], [7, 10], [7, 15], [7, 24], [7, 31], [7, 52], [7, 53], [7, 59], [7, 68], [7, 78], [7, 101], [7, 103], [7, 107], [7, 115], [8, 11], [8, 18], [8, 28], [8, 48], [8, 51], [8, 57], [8, 64], [8, 71], [8, 75], [8, 77], [8, 92], [8, 114], [8, 115], [8, 120], [8, 125], [8, 135], [9, 17], [9, 26], [9, 29], [9, 35], [9, 38], [9, 55], [9, 64], [9, 83], [9, 85], [9, 93], [9, 103], [9, 105], [9, 109], [9, 119], [9, 137], [10, 12], [10, 24], [10, 30], [10, 42], [10, 46], [10, 47], [10, 56], [10, 74], [10, 83], [10, 90], [10, 95], [10, 96], [10, 103], [10, 113], [10, 114], [10, 127], [10, 133], [10, 137], [11, 24], [11, 26], [11, 33], [11, 46], [11, 48], [11, 52], [11, 55], [11, 67], [11, 73], [11, 79], [11, 85], [11, 92], [11, 107], [11, 109], [11, 125], [12, 13], [12, 14], [12, 17], [12, 22], [12, 31], [12, 34], [12, 36], [12, 45], [12, 48], [12, 52], [12, 61], [12, 62], [12, 64], [12, 82], [12, 86], [12, 88], [12, 89], [12, 98], [12, 110], [12, 113], [12, 128], [13, 24], [13, 25], [13, 31], [13, 37], [13, 46], [13, 64], [13, 69], [13, 70], [13, 75], [13, 78], [13, 82], [13, 83], [13, 84], [13, 93], [13, 101], [13, 107], [13, 120], [13, 123], [13, 135], [14, 19], [14, 28], [14, 29], [14, 31], [14, 40], [14, 47], [14, 48], [14, 65], [14, 72], [14, 78], [14, 89], [14, 91], [14, 101], [14, 104], [14, 112], [14, 115], [14, 116], [14, 128], [15, 27], [15, 36], [15, 39], [15, 42], [15, 46], [15, 50], [15, 55], [15, 59], [15, 67], [15, 71], [15, 72], [15, 80], [15, 82], [15, 85], [15, 86], [15, 87], [15, 101], [15, 110], [15, 138], [16, 23], [16, 24], [16, 26], [16, 43], [16, 44], [16, 45], [16, 58], [16, 60], [16, 62], [16, 66], [16, 76], [16, 79], [16, 83], [16, 86], [16, 87], [16, 89], [16, 90], [16, 111], [16, 113], [16, 121], [16, 138], [17, 21], [17, 35], [17, 37], [17, 53], [17, 62], [17, 65], [17, 67], [17, 87], [17, 96], [17, 103], [17, 108], [17, 109], [17, 136], [17, 137], [17, 138], [18, 22], [18, 23], [18, 29], [18, 39], [18, 41], [18, 43], [18, 46], [18, 63], [18, 70], [18, 81], [18, 83], [18, 85], [18, 103], [18, 106], [18, 110], [18, 120], [18, 135], [18, 136], [19, 22], [19, 30], [19, 36], [19, 50], [19, 60], [19, 65], [19, 71], [19, 74], [19, 76], [19, 83], [19, 88], [19, 102], [19, 109], [20, 41], [20, 46], [20, 58], [20, 60], [20, 61], [20, 69], [20, 72], [20, 75], [20, 76], [20, 77], [20, 90], [20, 95], [20, 111], [20, 113], [20, 115], [20, 128], [20, 137], [21, 23], [21, 36], [21, 40], [21, 51], [21, 54], [21, 77], [21, 79], [21, 81], [21, 88], [21, 97], [21, 98], [21, 102], [21, 118], [21, 119], [21, 122], [21, 123], [22, 38], [22, 40], [22, 41], [22, 63], [22, 73], [22, 82], [22, 90], [22, 92], [22, 103], [22, 114], [22, 119], [22, 122], [22, 124], [22, 126], [22, 128], [22, 129], [23, 29], [23, 59], [23, 72], [23, 76], [23, 86], [23, 95], [23, 97], [23, 110], [23, 117], [23, 126], [23, 132], [23, 139], [24, 48], [24, 50], [24, 58], [24, 61], [24, 62], [24, 66], [24, 79], [24, 87], [24, 89], [24, 100], [24, 108], [24, 114], [24, 125], [24, 132], [25, 26], [25, 36], [25, 58], [25, 61], [25, 78], [25, 79], [25, 82], [25, 84], [25, 86], [25, 97], [25, 108], [25, 121], [25, 129], [25, 138], [26, 29], [26, 30], [26, 53], [26, 54], [26, 56], [26, 57], [26, 66], [26, 71], [26, 73], [26, 91], [26, 98], [26, 99], [26, 116], [26, 119], [26, 132], [26, 133], [27, 28], [27, 36], [27, 49], [27, 51], [27, 73], [27, 78], [27, 93], [28, 33], [28, 39], [28, 65], [28, 73], [28, 80], [28, 83], [28, 85], [28, 87], [28, 88], [28, 90], [28, 92], [28, 112], [28, 121], [28, 126], [29, 33], [29, 43], [29, 51], [29, 52], [29, 54], [29, 61], [29, 64], [29, 67], [29, 68], [29, 69], [29, 77], [29, 86], [29, 91], [29, 95], [29, 98], [29, 99], [29, 101], [29, 120], [29, 128], [29, 136], [30, 44], [30, 53], [30, 59], [30, 61], [30, 62], [30, 72], [30, 78], [30, 84], [30, 85], [30, 89], [30, 91], [30, 95], [30, 96], [30, 104], [30, 116], [30, 122], [30, 129], [30, 132], [31, 51], [31, 52], [31, 60], [31, 79], [31, 82], [31, 87], [31, 88], [31, 92], [31, 98], [31, 104], [31, 106], [31, 122], [31, 131], [31, 135], [32, 35], [32, 39], [32, 40], [32, 43], [32, 47], [32, 58], [32, 62], [32, 69], [32, 81], [32, 84], [32, 87], [32, 88], [32, 98], [32, 112], [32, 127], [32, 129], [33, 40], [33, 43], [33, 44], [33, 53], [33, 54], [33, 72], [33, 73], [33, 75], [33, 77], [33, 79], [33, 84], [33, 86], [33, 89], [33, 90], [33, 97], [33, 105], [33, 109], [33, 110], [33, 111], [33, 112], [33, 117], [33, 118], [33, 126], [33, 127], [33, 128], [33, 129], [33, 131], [34, 39], [34, 46], [34, 53], [34, 62], [34, 85], [34, 91], [34, 92], [34, 94], [34, 111], [34, 116], [34, 125], [35, 41], [35, 44], [35, 50], [35, 51], [35, 53], [35, 85], [35, 91], [35, 100], [35, 101], [35, 123], [35, 126], [36, 37], [36, 43], [36, 47], [36, 50], [36, 52], [36, 55], [36, 57], [36, 77], [36, 84], [36, 110], [36, 133], [37, 39], [37, 40], [37, 42], [37, 64], [37, 66], [37, 68], [37, 82], [37, 83], [37, 85], [37, 87], [37, 95], [37, 122], [37, 129], [37, 131], [38, 47], [38, 48], [38, 50], [38, 53], [38, 62], [38, 64], [38, 67], [38, 75], [38, 82], [38, 84], [38, 87], [38, 88], [38, 89], [38, 105], [38, 122], [38, 123], [38, 128], [38, 133], [38, 136], [39, 41], [39, 45], [39, 46], [39, 49], [39, 52], [39, 66], [39, 81], [39, 82], [39, 85], [39, 88], [39, 99], [39, 100], [39, 113], [39, 118], [39, 119], [39, 126], [39, 133], [40, 50], [40, 54], [40, 55], [40, 59], [40, 61], [40, 71], [40, 74], [40, 76], [40, 82], [40, 99], [40, 102], [40, 111], [40, 120], [40, 122], [40, 124], [40, 127], [40, 130], [40, 131], [40, 133], [40, 134], [41, 44], [41, 58], [41, 68], [41, 70], [41, 78], [41, 101], [41, 109], [41, 111], [41, 118], [41, 119], [41, 126], [42, 44], [42, 49], [42, 53], [42, 64], [42, 81], [42, 88], [42, 112], [42, 113], [42, 117], [42, 119], [42, 125], [42, 127], [42, 129], [43, 47], [43, 56], [43, 64], [43, 65], [43, 72], [43, 85], [43, 88], [43, 89], [43, 93], [43, 99], [43, 107], [43, 110], [43, 118], [43, 120], [43, 138], [44, 47], [44, 72], [44, 89], [44, 95], [44, 100], [44, 126], [44, 129], [44, 136], [45, 46], [45, 52], [45, 54], [45, 61], [45, 76], [45, 78], [45, 87], [45, 96], [45, 104], [45, 110], [45, 122], [46, 71], [46, 110], [46, 119], [46, 120], [46, 123], [46, 127], [46, 134], [46, 135], [47, 50], [47, 53], [47, 67], [47, 69], [47, 78], [47, 81], [47, 85], [47, 116], [47, 136], [48, 57], [48, 71], [48, 76], [48, 77], [48, 83], [48, 95], [48, 97], [48, 109], [48, 120], [48, 121], [48, 134], [49, 51], [49, 62], [49, 68], [49, 69], [49, 73], [49, 76], [49, 79], [49, 81], [49, 99], [49, 100], [49, 111], [49, 114], [49, 115], [49, 138], [50, 60], [50, 61], [50, 65], [50, 69], [50, 70], [50, 73], [50, 74], [50, 81], [50, 101], [50, 103], [50, 107], [50, 121], [50, 127], [50, 129], [50, 132], [50, 137], [50, 139], [51, 52], [51, 57], [51, 75], [51, 79], [51, 80], [51, 87], [51, 91], [51, 104], [51, 106], [51, 110], [51, 115], [51, 118], [51, 119], [51, 132], [51, 138], [51, 139], [52, 59], [52, 61], [52, 64], [52, 65], [52, 69], [52, 73], [52, 81], [52, 85], [52, 107], [52, 108], [52, 121], [53, 58], [53, 61], [53, 69], [53, 75], [53, 77], [53, 87], [53, 90], [53, 106], [53, 114], [53, 115], [53, 117], [53, 118], [53, 119], [53, 132], [54, 57], [54, 64], [54, 76], [54, 83], [54, 91], [54, 95], [54, 96], [54, 104], [54, 130], [54, 133], [54, 137], [54, 138], [55, 65], [55, 67], [55, 69], [55, 71], [55, 76], [55, 94], [55, 114], [55, 115], [55, 116], [55, 119], [55, 135], [55, 139], [56, 61], [56, 64], [56, 69], [56, 76], [56, 81], [56, 86], [56, 87], [56, 90], [56, 95], [56, 109], [56, 117], [56, 118], [56, 138], [57, 58], [57, 64], [57, 81], [57, 95], [57, 126], [57, 127], [57, 130], [57, 137], [57, 139], [58, 64], [58, 65], [58, 69], [58, 80], [58, 99], [58, 112], [58, 113], [58, 116], [58, 117], [58, 122], [58, 124], [58, 126], [58, 127], [58, 129], [58, 133], [59, 67], [59, 74], [59, 75], [59, 76], [59, 93], [59, 104], [59, 111], [59, 112], [59, 115], [59, 121], [59, 135], [59, 139], [60, 65], [60, 79], [60, 90], [60, 93], [60, 95], [60, 98], [60, 100], [60, 107], [60, 110], [60, 114], [60, 118], [60, 128], [61, 67], [61, 77], [61, 80], [61, 81], [61, 84], [61, 85], [61, 91], [61, 94], [61, 99], [61, 103], [61, 107], [61, 112], [61, 124], [62, 65], [62, 81], [62, 103], [62, 110], [62, 116], [62, 118], [62, 124], [62, 125], [62, 138], [63, 69], [63, 74], [63, 83], [63, 90], [63, 96], [63, 97], [63, 101], [63, 103], [63, 108], [63, 116], [63, 122], [63, 128], [64, 67], [64, 70], [64, 84], [64, 90], [64, 92], [64, 108], [64, 119], [64, 122], [64, 125], [64, 138], [64, 139], [65, 67], [65, 72], [65, 79], [65, 88], [65, 91], [65, 102], [65, 109], [65, 124], [65, 125], [65, 127], [65, 128], [65, 136], [66, 79], [66, 82], [66, 85], [66, 87], [66, 89], [66, 91], [66, 95], [66, 107], [66, 108], [66, 112], [66, 118], [66, 119], [66, 122], [66, 125], [66, 127], [66, 136], [67, 73], [67, 78], [67, 93], [67, 100], [67, 102], [67, 114], [67, 116], [67, 118], [67, 119], [67, 131], [67, 133], [67, 134], [68, 71], [68, 77], [68, 80], [68, 98], [68, 99], [68, 116], [68, 118], [68, 119], [68, 128], [69, 72], [69, 73], [69, 83], [69, 89], [69, 96], [69, 99], [69, 100], [69, 103], [69, 106], [69, 108], [69, 109], [69, 111], [69, 116], [69, 117], [69, 125], [69, 129], [69, 131], [69, 132], [69, 133], [69, 139], [70, 71], [70, 73], [70, 79], [70, 84], [70, 88], [70, 93], [70, 94], [70, 99], [70, 108], [70, 116], [70, 122], [70, 129], [70, 131], [71, 74], [71, 89], [71, 94], [71, 105], [71, 108], [71, 127], [71, 130], [71, 132], [71, 138], [71, 139], [72, 76], [72, 79], [72, 83], [72, 85], [72, 87], [72, 89], [72, 118], [72, 121], [72, 133], [73, 75], [73, 80], [73, 82], [73, 85], [73, 90], [73, 93], [73, 115], [73, 123], [73, 136], [74, 76], [74, 78], [74, 82], [74, 83], [74, 85], [74, 86], [74, 91], [74, 92], [74, 103], [74, 104], [74, 105], [74, 106], [74, 113], [74, 115], [74, 116], [74, 118], [74, 125], [74, 126], [74, 132], [74, 135], [75, 98], [75, 110], [75, 117], [75, 122], [75, 126], [75, 139], [76, 90], [76, 112], [76, 114], [76, 131], [77, 78], [77, 85], [77, 87], [77, 92], [77, 113], [77, 118], [77, 139], [78, 80], [78, 86], [78, 103], [78, 108], [78, 111], [78, 118], [78, 120], [78, 129], [79, 88], [79, 90], [79, 119], [79, 131], [80, 81], [80, 83], [80, 86], [80, 96], [80, 98], [81, 87], [81, 89], [81, 94], [81, 97], [81, 98], [81, 107], [81, 109], [81, 122], [81, 124], [81, 130], [81, 135], [81, 136], [82, 87], [82, 100], [82, 102], [82, 110], [82, 111], [82, 122], [82, 125], [83, 113], [83, 116], [83, 120], [83, 122], [83, 136], [84, 91], [84, 104], [84, 106], [84, 107], [84, 114], [84, 115], [84, 122], [84, 129], [85, 99], [85, 102], [85, 108], [85, 113], [85, 118], [85, 128], [85, 131], [85, 133], [85, 134], [85, 138], [86, 97], [86, 106], [86, 107], [86, 109], [86, 115], [86, 119], [86, 121], [86, 122], [86, 124], [86, 131], [87, 99], [87, 104], [87, 117], [87, 120], [87, 125], [87, 132], [88, 89], [88, 97], [88, 105], [88, 110], [88, 111], [88, 115], [88, 121], [89, 120], [89, 126], [89, 128], [89, 130], [89, 134], [90, 94], [90, 109], [90, 121], [90, 123], [90, 124], [90, 127], [90, 131], [90, 133], [90, 136], [91, 111], [91, 126], [92, 103], [92, 110], [92, 120], [92, 124], [92, 129], [92, 133], [92, 135], [93, 101], [93, 112], [93, 125], [93, 132], [93, 133], [93, 139], [94, 99], [94, 102], [94, 104], [94, 111], [94, 113], [95, 101], [95, 104], [95, 114], [95, 121], [95, 127], [95, 129], [95, 138], [96, 108], [96, 109], [96, 128], [96, 129], [97, 100], [97, 109], [97, 110], [97, 112], [97, 115], [97, 127], [97, 128], [97, 136], [97, 137], [98, 115], [98, 118], [98, 127], [98, 128], [98, 130], [98, 133], [98, 135], [99, 103], [99, 104], [99, 115], [99, 118], [99, 127], [99, 136], [100, 126], [100, 131], [101, 115], [101, 130], [102, 111], [102, 118], [102, 138], [103, 110], [103, 118], [103, 127], [104, 105], [104, 114], [104, 115], [104, 117], [104, 121], [105, 107], [105, 111], [105, 112], [105, 116], [105, 120], [105, 138], [105, 139], [106, 127], [107, 109], [107, 120], [107, 123], [107, 126], [107, 130], [108, 113], [108, 115], [108, 123], [108, 125], [108, 126], [108, 134], [108, 137], [108, 138], [108, 139], [109, 128], [109, 130], [109, 133], [109, 139], [110, 121], [110, 124], [110, 131], [111, 112], [111, 119], [111, 121], [112, 113], [112, 116], [112, 121], [112, 122], [112, 134], [112, 138], [113, 114], [113, 122], [113, 126], [113, 135], [114, 122], [114, 126], [114, 128], [114, 131], [114, 132], [115, 120], [115, 121], [115, 122], [115, 128], [115, 135], [116, 119], [116, 135], [117, 120], [117, 125], [117, 139], [118, 122], [118, 128], [118, 135], [118, 136], [118, 138], [119, 120], [119, 128], [119, 132], [119, 134], [121, 124], [121, 125], [121, 130], [121, 138], [122, 125], [123, 126], [123, 128], [127, 128], [127, 131], [127, 134], [127, 139], [128, 130], [128, 134], [129, 133], [129, 136], [130, 137], [131, 132], [131, 139], [133, 136], [133, 137], [133, 139], [135, 136], [135, 138], [136, 139]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l6-s2/tests/run.py b/tasks/construct-mc-vertex-cover-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l6-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-vertex-cover-l6-s2/tests/test.sh b/tasks/construct-mc-vertex-cover-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-l5-s0/environment/Dockerfile b/tasks/construct-nppc-3col-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-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-3col-l5-s0/environment/instance.json b/tasks/construct-nppc-3col-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..144fbb0e73861c70c359327b15065c9bd79fd5da --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 60, "edges": [[0, 3], [0, 10], [0, 24], [0, 30], [0, 39], [0, 41], [0, 44], [0, 48], [1, 7], [1, 21], [1, 22], [1, 33], [1, 34], [1, 39], [2, 12], [2, 43], [2, 49], [3, 13], [3, 48], [3, 55], [3, 57], [4, 5], [4, 7], [4, 20], [4, 21], [4, 32], [4, 42], [4, 52], [5, 15], [5, 18], [5, 19], [5, 29], [5, 33], [5, 35], [5, 47], [5, 58], [6, 16], [6, 29], [6, 44], [6, 52], [6, 53], [6, 59], [7, 8], [7, 12], [7, 13], [7, 26], [7, 29], [7, 35], [7, 50], [7, 54], [7, 56], [8, 11], [8, 24], [8, 50], [8, 51], [9, 29], [9, 34], [9, 49], [9, 50], [9, 59], [10, 12], [10, 13], [10, 14], [10, 36], [10, 37], [10, 41], [10, 44], [10, 50], [11, 24], [11, 26], [11, 27], [11, 36], [11, 38], [12, 17], [12, 18], [12, 25], [12, 27], [12, 28], [12, 32], [12, 37], [12, 38], [13, 14], [13, 22], [13, 26], [13, 36], [13, 37], [14, 31], [14, 50], [14, 55], [14, 57], [14, 58], [15, 29], [15, 32], [15, 34], [15, 36], [15, 37], [15, 59], [16, 33], [16, 43], [16, 51], [16, 58], [16, 59], [17, 23], [18, 32], [18, 35], [18, 44], [18, 53], [18, 58], [19, 34], [19, 36], [19, 37], [19, 40], [19, 50], [20, 31], [20, 47], [20, 49], [21, 27], [21, 33], [21, 43], [21, 45], [21, 50], [22, 29], [22, 43], [22, 50], [22, 51], [23, 58], [24, 26], [24, 29], [24, 30], [24, 36], [24, 44], [24, 56], [25, 30], [25, 32], [25, 34], [25, 35], [25, 51], [26, 38], [26, 45], [26, 56], [27, 31], [27, 34], [27, 59], [28, 29], [28, 43], [28, 53], [28, 56], [29, 32], [30, 42], [30, 45], [30, 56], [31, 45], [31, 55], [31, 57], [32, 48], [32, 50], [33, 37], [33, 46], [33, 50], [33, 53], [33, 56], [33, 59], [34, 43], [34, 51], [34, 57], [35, 55], [36, 42], [36, 43], [36, 49], [36, 54], [36, 58], [37, 48], [37, 53], [37, 56], [38, 43], [38, 46], [38, 47], [38, 49], [38, 51], [38, 53], [38, 58], [39, 56], [40, 48], [41, 49], [42, 44], [43, 55], [44, 45], [44, 55], [44, 58], [44, 59], [46, 48], [46, 54], [46, 55], [46, 58], [48, 49], [48, 59], [49, 55], [51, 57], [52, 55], [52, 57]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l5-s0/solution/solve.sh b/tasks/construct-nppc-3col-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..53ebb2398444e2bef3420dcdaa48b681c8e5a31f --- /dev/null +++ b/tasks/construct-nppc-3col-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' +{"coloring": [1, 1, 0, 0, 1, 0, 2, 2, 0, 2, 2, 1, 1, 1, 0, 2, 0, 0, 2, 2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 1, 0, 1, 0, 2, 0, 1, 0, 0, 2, 0, 1, 0, 2, 1, 0, 2, 0, 1, 2, 1, 1, 1, 0, 1, 1, 2, 1, 2, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l5-s0/tests/check.py b/tasks/construct-nppc-3col-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s0/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-l5-s0/tests/instance.json b/tasks/construct-nppc-3col-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..144fbb0e73861c70c359327b15065c9bd79fd5da --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 60, "edges": [[0, 3], [0, 10], [0, 24], [0, 30], [0, 39], [0, 41], [0, 44], [0, 48], [1, 7], [1, 21], [1, 22], [1, 33], [1, 34], [1, 39], [2, 12], [2, 43], [2, 49], [3, 13], [3, 48], [3, 55], [3, 57], [4, 5], [4, 7], [4, 20], [4, 21], [4, 32], [4, 42], [4, 52], [5, 15], [5, 18], [5, 19], [5, 29], [5, 33], [5, 35], [5, 47], [5, 58], [6, 16], [6, 29], [6, 44], [6, 52], [6, 53], [6, 59], [7, 8], [7, 12], [7, 13], [7, 26], [7, 29], [7, 35], [7, 50], [7, 54], [7, 56], [8, 11], [8, 24], [8, 50], [8, 51], [9, 29], [9, 34], [9, 49], [9, 50], [9, 59], [10, 12], [10, 13], [10, 14], [10, 36], [10, 37], [10, 41], [10, 44], [10, 50], [11, 24], [11, 26], [11, 27], [11, 36], [11, 38], [12, 17], [12, 18], [12, 25], [12, 27], [12, 28], [12, 32], [12, 37], [12, 38], [13, 14], [13, 22], [13, 26], [13, 36], [13, 37], [14, 31], [14, 50], [14, 55], [14, 57], [14, 58], [15, 29], [15, 32], [15, 34], [15, 36], [15, 37], [15, 59], [16, 33], [16, 43], [16, 51], [16, 58], [16, 59], [17, 23], [18, 32], [18, 35], [18, 44], [18, 53], [18, 58], [19, 34], [19, 36], [19, 37], [19, 40], [19, 50], [20, 31], [20, 47], [20, 49], [21, 27], [21, 33], [21, 43], [21, 45], [21, 50], [22, 29], [22, 43], [22, 50], [22, 51], [23, 58], [24, 26], [24, 29], [24, 30], [24, 36], [24, 44], [24, 56], [25, 30], [25, 32], [25, 34], [25, 35], [25, 51], [26, 38], [26, 45], [26, 56], [27, 31], [27, 34], [27, 59], [28, 29], [28, 43], [28, 53], [28, 56], [29, 32], [30, 42], [30, 45], [30, 56], [31, 45], [31, 55], [31, 57], [32, 48], [32, 50], [33, 37], [33, 46], [33, 50], [33, 53], [33, 56], [33, 59], [34, 43], [34, 51], [34, 57], [35, 55], [36, 42], [36, 43], [36, 49], [36, 54], [36, 58], [37, 48], [37, 53], [37, 56], [38, 43], [38, 46], [38, 47], [38, 49], [38, 51], [38, 53], [38, 58], [39, 56], [40, 48], [41, 49], [42, 44], [43, 55], [44, 45], [44, 55], [44, 58], [44, 59], [46, 48], [46, 54], [46, 55], [46, 58], [48, 49], [48, 59], [49, 55], [51, 57], [52, 55], [52, 57]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l5-s0/tests/run.py b/tasks/construct-nppc-3col-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-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-3col-l5-s0/tests/test.sh b/tasks/construct-nppc-3col-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-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-bandwidth-l3-s2/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-bandwidth-l3-s2/environment/instance.json b/tasks/construct-nppc-bandwidth-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e73639d73c8d9ce5fa181533b10acce5b051bb59 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 2], [0, 3], [1, 3], [2, 7], [3, 4], [3, 6], [4, 7], [5, 6]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s2/solution/solve.sh b/tasks/construct-nppc-bandwidth-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..76dcd8aa4b2b3d9e20c5394fcad73635963414f1 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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' +{"layout": [2, 5, 0, 4, 3, 7, 6, 1]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l3-s2/tests/check.py b/tasks/construct-nppc-bandwidth-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s2/tests/check.py @@ -0,0 +1,14 @@ +"""Bandwidth <= b: layout must be a permutation of 0..n-1 with |p[u]-p[v]| <= b on every edge.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, b = inst["num_nodes"], inst["bandwidth"] + # upstream NPPC verifier compares sorted(layout) to range(n), which also accepts floats/bools + p = int_list(ans.get("layout"), n, 0, n - 1, "layout") + if len(set(p)) != n: + raise Invalid("layout is not a permutation of 0..n-1") + for u, v in inst["edges"]: + if abs(p[u] - p[v]) > b: + raise Invalid(f"edge ({u},{v}) has stretch {abs(p[u] - p[v])} > {b}") + return None, {} diff --git a/tasks/construct-nppc-bandwidth-l3-s2/tests/instance.json b/tasks/construct-nppc-bandwidth-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e73639d73c8d9ce5fa181533b10acce5b051bb59 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 2], [0, 3], [1, 3], [2, 7], [3, 4], [3, 6], [4, 7], [5, 6]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s2/tests/run.py b/tasks/construct-nppc-bandwidth-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-bandwidth-l3-s2/tests/test.sh b/tasks/construct-nppc-bandwidth-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-bandwidth-l3-s5/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l3-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-nppc-bandwidth-l3-s5/environment/instance.json b/tasks/construct-nppc-bandwidth-l3-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..739eab8010298722ab7c503d51b2025574b30343 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s5/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 2], [0, 3], [0, 7], [1, 2], [2, 3], [3, 5], [4, 7], [5, 6]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s5/solution/solve.sh b/tasks/construct-nppc-bandwidth-l3-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..405262658a5a5ff6e3f1fd5fa1c96962e0ba1710 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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' +{"layout": [5, 1, 3, 4, 7, 2, 0, 6]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l3-s5/tests/check.py b/tasks/construct-nppc-bandwidth-l3-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s5/tests/check.py @@ -0,0 +1,14 @@ +"""Bandwidth <= b: layout must be a permutation of 0..n-1 with |p[u]-p[v]| <= b on every edge.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, b = inst["num_nodes"], inst["bandwidth"] + # upstream NPPC verifier compares sorted(layout) to range(n), which also accepts floats/bools + p = int_list(ans.get("layout"), n, 0, n - 1, "layout") + if len(set(p)) != n: + raise Invalid("layout is not a permutation of 0..n-1") + for u, v in inst["edges"]: + if abs(p[u] - p[v]) > b: + raise Invalid(f"edge ({u},{v}) has stretch {abs(p[u] - p[v])} > {b}") + return None, {} diff --git a/tasks/construct-nppc-bandwidth-l3-s5/tests/instance.json b/tasks/construct-nppc-bandwidth-l3-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..739eab8010298722ab7c503d51b2025574b30343 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s5/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 2], [0, 3], [0, 7], [1, 2], [2, 3], [3, 5], [4, 7], [5, 6]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s5/tests/run.py b/tasks/construct-nppc-bandwidth-l3-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-bandwidth-l3-s5/tests/test.sh b/tasks/construct-nppc-bandwidth-l3-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-nppc-bandwidth-l4-s1/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-nppc-bandwidth-l4-s1/environment/instance.json b/tasks/construct-nppc-bandwidth-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bd5aa613037bde488dadcb7bdacff9c24343111f --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 20, "bandwidth": 3, "edges": [[0, 4], [0, 6], [0, 7], [0, 8], [0, 12], [0, 16], [1, 2], [1, 15], [1, 19], [2, 13], [2, 15], [3, 5], [3, 8], [3, 11], [4, 6], [4, 8], [4, 12], [4, 16], [4, 18], [5, 11], [6, 8], [6, 11], [7, 10], [7, 12], [7, 19], [8, 11], [9, 13], [9, 14], [9, 17], [9, 19], [10, 12], [10, 14], [10, 16], [10, 19], [11, 18], [12, 16], [13, 15], [14, 16], [14, 17], [17, 19]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l4-s1/solution/solve.sh b/tasks/construct-nppc-bandwidth-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..dfd495a79d10fc2d26a28c4f3499a93f83e4d8bb --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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' +{"layout": [12, 3, 0, 18, 13, 19, 14, 9, 15, 4, 8, 17, 11, 2, 7, 1, 10, 5, 16, 6]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l4-s1/tests/check.py b/tasks/construct-nppc-bandwidth-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s1/tests/check.py @@ -0,0 +1,14 @@ +"""Bandwidth <= b: layout must be a permutation of 0..n-1 with |p[u]-p[v]| <= b on every edge.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, b = inst["num_nodes"], inst["bandwidth"] + # upstream NPPC verifier compares sorted(layout) to range(n), which also accepts floats/bools + p = int_list(ans.get("layout"), n, 0, n - 1, "layout") + if len(set(p)) != n: + raise Invalid("layout is not a permutation of 0..n-1") + for u, v in inst["edges"]: + if abs(p[u] - p[v]) > b: + raise Invalid(f"edge ({u},{v}) has stretch {abs(p[u] - p[v])} > {b}") + return None, {} diff --git a/tasks/construct-nppc-bandwidth-l4-s1/tests/instance.json b/tasks/construct-nppc-bandwidth-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bd5aa613037bde488dadcb7bdacff9c24343111f --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 20, "bandwidth": 3, "edges": [[0, 4], [0, 6], [0, 7], [0, 8], [0, 12], [0, 16], [1, 2], [1, 15], [1, 19], [2, 13], [2, 15], [3, 5], [3, 8], [3, 11], [4, 6], [4, 8], [4, 12], [4, 16], [4, 18], [5, 11], [6, 8], [6, 11], [7, 10], [7, 12], [7, 19], [8, 11], [9, 13], [9, 14], [9, 17], [9, 19], [10, 12], [10, 14], [10, 16], [10, 19], [11, 18], [12, 16], [13, 15], [14, 16], [14, 17], [17, 19]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l4-s1/tests/run.py b/tasks/construct-nppc-bandwidth-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-nppc-bandwidth-l4-s1/tests/test.sh b/tasks/construct-nppc-bandwidth-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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-nppc-clique-l1-s7/environment/Dockerfile b/tasks/construct-nppc-clique-l1-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l1-s7/environment/instance.json b/tasks/construct-nppc-clique-l1-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c2e4e4dd88c0233d49f9d8ab6377c54256d300f6 --- /dev/null +++ b/tasks/construct-nppc-clique-l1-s7/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "k": 4, "edges": [[0, 1], [0, 3], [0, 6], [1, 3], [1, 4], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 6], [3, 7], [4, 6], [4, 7], [5, 6], [6, 7]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l1-s7/solution/solve.sh b/tasks/construct-nppc-clique-l1-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f73949fa6859640ede79684da0f756779f6ab224 --- /dev/null +++ b/tasks/construct-nppc-clique-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' +{"clique": [0, 1, 3, 6]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l1-s7/tests/check.py b/tasks/construct-nppc-clique-l1-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l1-s7/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l1-s7/tests/instance.json b/tasks/construct-nppc-clique-l1-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c2e4e4dd88c0233d49f9d8ab6377c54256d300f6 --- /dev/null +++ b/tasks/construct-nppc-clique-l1-s7/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "k": 4, "edges": [[0, 1], [0, 3], [0, 6], [1, 3], [1, 4], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 6], [3, 7], [4, 6], [4, 7], [5, 6], [6, 7]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l1-s7/tests/run.py b/tasks/construct-nppc-clique-l1-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l1-s7/tests/test.sh b/tasks/construct-nppc-clique-l1-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l2-s5/environment/Dockerfile b/tasks/construct-nppc-clique-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-clique-l2-s5/environment/instance.json b/tasks/construct-nppc-clique-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..29db8b9c022e1c8229154ca4ca14c3a9174e800f --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 2], [0, 3], [0, 4], [0, 6], [0, 8], [0, 9], [0, 10], [0, 12], [0, 13], [1, 3], [1, 6], [1, 7], [1, 8], [1, 10], [2, 6], [2, 11], [2, 13], [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], [4, 13], [5, 6], [5, 11], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [7, 8], [7, 9], [7, 11], [8, 9], [8, 10], [8, 11], [8, 12], [9, 10], [9, 11], [9, 12], [9, 13], [10, 12]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s5/solution/solve.sh b/tasks/construct-nppc-clique-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d27345102c54895f7556e7a66be1310ead272ebb --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [0, 4, 6, 8, 9, 10, 12]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l2-s5/tests/check.py b/tasks/construct-nppc-clique-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s5/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-s5/tests/instance.json b/tasks/construct-nppc-clique-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..29db8b9c022e1c8229154ca4ca14c3a9174e800f --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 2], [0, 3], [0, 4], [0, 6], [0, 8], [0, 9], [0, 10], [0, 12], [0, 13], [1, 3], [1, 6], [1, 7], [1, 8], [1, 10], [2, 6], [2, 11], [2, 13], [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], [4, 13], [5, 6], [5, 11], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [7, 8], [7, 9], [7, 11], [8, 9], [8, 10], [8, 11], [8, 12], [9, 10], [9, 11], [9, 12], [9, 13], [10, 12]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s5/tests/run.py b/tasks/construct-nppc-clique-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l2-s5/tests/test.sh b/tasks/construct-nppc-clique-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l6-s3/environment/Dockerfile b/tasks/construct-nppc-clique-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l6-s3/environment/instance.json b/tasks/construct-nppc-clique-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..65f36f7193d97913ad8a8578478ca7f8f24d1d5b --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 2], [0, 4], [0, 5], [0, 8], [0, 10], [0, 11], [0, 12], [0, 13], [0, 15], [0, 16], [0, 17], [0, 19], [0, 20], [0, 22], [0, 23], [0, 24], [0, 26], [0, 27], [0, 28], [0, 29], [0, 30], [0, 33], [0, 35], [0, 38], [0, 40], [0, 41], [0, 44], [0, 46], [0, 47], [0, 48], [0, 49], [0, 50], [0, 53], [0, 55], [0, 56], [0, 60], [0, 61], [0, 65], [0, 69], [0, 70], [0, 73], [0, 75], [0, 76], [0, 77], [0, 78], [0, 82], [0, 83], [0, 84], [0, 85], [0, 86], [0, 90], [0, 95], [0, 97], [0, 98], [1, 2], [1, 3], [1, 4], [1, 9], [1, 10], [1, 12], [1, 15], [1, 16], [1, 17], [1, 19], [1, 20], [1, 22], [1, 24], [1, 25], [1, 27], [1, 28], [1, 29], [1, 32], [1, 34], [1, 35], [1, 37], [1, 41], [1, 43], [1, 44], [1, 48], [1, 50], [1, 51], [1, 52], [1, 53], [1, 54], [1, 57], [1, 58], [1, 59], [1, 61], [1, 62], [1, 63], [1, 64], [1, 66], [1, 68], [1, 72], [1, 75], [1, 76], [1, 77], [1, 79], [1, 82], [1, 83], [1, 84], [1, 85], [1, 86], [1, 87], [1, 88], [1, 90], [1, 92], [1, 95], [1, 96], [1, 97], [1, 99], [2, 4], [2, 6], [2, 8], [2, 9], [2, 10], [2, 11], [2, 13], [2, 14], [2, 16], [2, 18], [2, 19], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 27], [2, 28], [2, 30], [2, 31], [2, 32], [2, 38], [2, 42], [2, 43], [2, 52], [2, 57], [2, 58], [2, 59], [2, 60], [2, 62], [2, 65], [2, 66], [2, 69], [2, 70], [2, 71], [2, 74], [2, 76], [2, 78], [2, 79], [2, 80], [2, 82], [2, 84], [2, 86], [2, 88], [2, 90], [2, 93], [2, 96], [2, 98], [2, 99], [3, 4], [3, 5], [3, 8], [3, 9], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 30], [3, 31], [3, 32], [3, 34], [3, 36], [3, 37], [3, 39], [3, 42], [3, 46], [3, 47], [3, 53], [3, 56], [3, 60], [3, 61], [3, 65], [3, 69], [3, 71], [3, 72], [3, 74], [3, 75], [3, 77], [3, 78], [3, 81], [3, 86], [3, 87], [3, 88], [3, 90], [3, 92], [3, 94], [3, 96], [3, 99], [4, 8], [4, 9], [4, 10], [4, 11], [4, 13], [4, 14], [4, 15], [4, 23], [4, 26], [4, 28], [4, 29], [4, 33], [4, 35], [4, 40], [4, 41], [4, 45], [4, 47], [4, 48], [4, 49], [4, 53], [4, 55], [4, 60], [4, 61], [4, 63], [4, 65], [4, 69], [4, 70], [4, 74], [4, 78], [4, 79], [4, 82], [4, 84], [4, 85], [4, 86], [4, 88], [4, 89], [4, 90], [4, 91], [4, 93], [4, 96], [4, 97], [4, 99], [5, 7], [5, 8], [5, 9], [5, 10], [5, 12], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 23], [5, 25], [5, 26], [5, 28], [5, 29], [5, 30], [5, 33], [5, 39], [5, 42], [5, 44], [5, 46], [5, 48], [5, 53], [5, 57], [5, 60], [5, 63], [5, 65], [5, 67], [5, 68], [5, 70], [5, 71], [5, 72], [5, 73], [5, 74], [5, 76], [5, 77], [5, 79], [5, 80], [5, 82], [5, 85], [5, 89], [5, 91], [5, 92], [5, 94], [5, 95], [5, 97], [5, 99], [6, 9], [6, 10], [6, 11], [6, 12], [6, 20], [6, 21], [6, 23], [6, 26], [6, 28], [6, 31], [6, 32], [6, 33], [6, 37], [6, 41], [6, 42], [6, 43], [6, 44], [6, 48], [6, 49], [6, 57], [6, 59], [6, 61], [6, 62], [6, 63], [6, 64], [6, 67], [6, 70], [6, 71], [6, 73], [6, 76], [6, 77], [6, 78], [6, 79], [6, 80], [6, 81], [6, 83], [6, 85], [6, 87], [6, 88], [6, 89], [6, 92], [6, 93], [6, 96], [7, 10], [7, 12], [7, 14], [7, 16], [7, 18], [7, 19], [7, 21], [7, 25], [7, 26], [7, 28], [7, 29], [7, 31], [7, 32], [7, 36], [7, 37], [7, 38], [7, 41], [7, 42], [7, 43], [7, 46], [7, 48], [7, 51], [7, 52], [7, 53], [7, 54], [7, 55], [7, 57], [7, 58], [7, 60], [7, 61], [7, 63], [7, 64], [7, 68], [7, 69], [7, 71], [7, 73], [7, 75], [7, 76], [7, 77], [7, 79], [7, 80], [7, 82], [7, 91], [7, 97], [8, 12], [8, 14], [8, 17], [8, 18], [8, 21], [8, 22], [8, 24], [8, 27], [8, 29], [8, 31], [8, 32], [8, 34], [8, 35], [8, 38], [8, 42], [8, 44], [8, 45], [8, 46], [8, 47], [8, 48], [8, 50], [8, 53], [8, 55], [8, 57], [8, 61], [8, 65], [8, 67], [8, 68], [8, 69], [8, 70], [8, 74], [8, 75], [8, 77], [8, 79], [8, 80], [8, 81], [8, 84], [8, 85], [8, 91], [8, 92], [8, 93], [8, 96], [8, 99], [9, 12], [9, 13], [9, 14], [9, 16], [9, 17], [9, 18], [9, 25], [9, 26], [9, 28], [9, 33], [9, 35], [9, 36], [9, 37], [9, 39], [9, 40], [9, 41], [9, 42], [9, 44], [9, 46], [9, 49], [9, 52], [9, 53], [9, 54], [9, 56], [9, 57], [9, 59], [9, 60], [9, 61], [9, 62], [9, 64], [9, 65], [9, 67], [9, 68], [9, 69], [9, 70], [9, 74], [9, 75], [9, 76], [9, 77], [9, 78], [9, 80], [9, 82], [9, 83], [9, 86], [9, 90], [9, 92], [9, 93], [9, 94], [9, 97], [10, 13], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 21], [10, 24], [10, 26], [10, 27], [10, 28], [10, 29], [10, 30], [10, 31], [10, 32], [10, 35], [10, 37], [10, 38], [10, 39], [10, 40], [10, 42], [10, 47], [10, 50], [10, 51], [10, 54], [10, 56], [10, 57], [10, 59], [10, 60], [10, 63], [10, 64], [10, 65], [10, 66], [10, 67], [10, 68], [10, 69], [10, 73], [10, 74], [10, 75], [10, 76], [10, 77], [10, 79], [10, 80], [10, 81], [10, 82], [10, 83], [10, 84], [10, 85], [10, 90], [10, 91], [10, 92], [10, 93], [10, 94], [10, 99], [11, 14], [11, 16], [11, 17], [11, 18], [11, 19], [11, 21], [11, 24], [11, 26], [11, 27], [11, 28], [11, 30], [11, 33], [11, 34], [11, 37], [11, 40], [11, 42], [11, 43], [11, 44], [11, 45], [11, 49], [11, 51], [11, 52], [11, 53], [11, 54], [11, 57], [11, 58], [11, 59], [11, 61], [11, 63], [11, 64], [11, 71], [11, 72], [11, 73], [11, 76], [11, 77], [11, 78], [11, 79], [11, 80], [11, 81], [11, 82], [11, 83], [11, 85], [11, 86], [11, 88], [11, 89], [11, 91], [11, 95], [12, 13], [12, 14], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 32], [12, 34], [12, 36], [12, 37], [12, 38], [12, 40], [12, 42], [12, 43], [12, 45], [12, 47], [12, 49], [12, 50], [12, 51], [12, 54], [12, 55], [12, 56], [12, 57], [12, 58], [12, 59], [12, 64], [12, 66], [12, 67], [12, 70], [12, 71], [12, 73], [12, 78], [12, 79], [12, 82], [12, 83], [12, 85], [12, 87], [12, 88], [12, 89], [12, 92], [12, 93], [12, 94], [12, 95], [12, 96], [12, 97], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 25], [13, 27], [13, 31], [13, 33], [13, 35], [13, 36], [13, 37], [13, 39], [13, 40], [13, 41], [13, 43], [13, 44], [13, 45], [13, 46], [13, 49], [13, 50], [13, 53], [13, 54], [13, 55], [13, 56], [13, 57], [13, 62], [13, 64], [13, 67], [13, 70], [13, 71], [13, 72], [13, 73], [13, 74], [13, 75], [13, 76], [13, 80], [13, 81], [13, 82], [13, 84], [13, 92], [13, 93], [13, 96], [13, 97], [13, 98], [13, 99], [14, 16], [14, 17], [14, 20], [14, 24], [14, 27], [14, 29], [14, 31], [14, 33], [14, 35], [14, 40], [14, 42], [14, 49], [14, 53], [14, 54], [14, 59], [14, 60], [14, 61], [14, 62], [14, 64], [14, 66], [14, 67], [14, 69], [14, 70], [14, 72], [14, 76], [14, 77], [14, 79], [14, 80], [14, 84], [14, 87], [14, 94], [14, 98], [15, 17], [15, 18], [15, 20], [15, 21], [15, 24], [15, 26], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [15, 36], [15, 37], [15, 42], [15, 45], [15, 48], [15, 50], [15, 51], [15, 53], [15, 54], [15, 55], [15, 56], [15, 58], [15, 60], [15, 61], [15, 62], [15, 64], [15, 65], [15, 68], [15, 69], [15, 71], [15, 72], [15, 74], [15, 75], [15, 76], [15, 77], [15, 78], [15, 79], [15, 80], [15, 81], [15, 82], [15, 83], [15, 84], [15, 85], [15, 88], [15, 89], [15, 90], [15, 91], [15, 92], [15, 93], [15, 94], [15, 99], [16, 21], [16, 23], [16, 25], [16, 27], [16, 29], [16, 30], [16, 32], [16, 33], [16, 34], [16, 35], [16, 40], [16, 41], [16, 46], [16, 51], [16, 52], [16, 53], [16, 54], [16, 56], [16, 57], [16, 60], [16, 64], [16, 66], [16, 69], [16, 70], [16, 72], [16, 73], [16, 74], [16, 75], [16, 76], [16, 78], [16, 79], [16, 80], [16, 81], [16, 82], [16, 83], [16, 85], [16, 87], [16, 90], [16, 92], [16, 93], [16, 94], [16, 95], [16, 96], [16, 97], [16, 99], [17, 20], [17, 21], [17, 23], [17, 25], [17, 29], [17, 32], [17, 34], [17, 36], [17, 41], [17, 42], [17, 43], [17, 44], [17, 48], [17, 52], [17, 53], [17, 55], [17, 56], [17, 59], [17, 60], [17, 61], [17, 63], [17, 64], [17, 67], [17, 69], [17, 70], [17, 71], [17, 74], [17, 75], [17, 79], [17, 82], [17, 84], [17, 85], [17, 87], [17, 88], [17, 89], [17, 90], [17, 91], [17, 92], [17, 94], [17, 95], [17, 97], [17, 98], [17, 99], [18, 22], [18, 23], [18, 25], [18, 30], [18, 32], [18, 33], [18, 34], [18, 35], [18, 39], [18, 41], [18, 43], [18, 44], [18, 45], [18, 47], [18, 49], [18, 50], [18, 51], [18, 52], [18, 54], [18, 56], [18, 57], [18, 58], [18, 59], [18, 62], [18, 65], [18, 67], [18, 68], [18, 69], [18, 70], [18, 71], [18, 76], [18, 78], [18, 80], [18, 83], [18, 86], [18, 90], [18, 91], [18, 92], [18, 94], [18, 95], [19, 20], [19, 21], [19, 23], [19, 24], [19, 25], [19, 26], [19, 31], [19, 32], [19, 34], [19, 35], [19, 37], [19, 38], [19, 39], [19, 40], [19, 42], [19, 43], [19, 45], [19, 48], [19, 50], [19, 53], [19, 54], [19, 56], [19, 61], [19, 62], [19, 63], [19, 64], [19, 68], [19, 70], [19, 74], [19, 79], [19, 81], [19, 82], [19, 84], [19, 85], [19, 86], [19, 88], [19, 91], [19, 94], [19, 95], [19, 96], [19, 99], [20, 23], [20, 24], [20, 25], [20, 28], [20, 29], [20, 31], [20, 33], [20, 34], [20, 35], [20, 39], [20, 41], [20, 43], [20, 44], [20, 45], [20, 50], [20, 51], [20, 53], [20, 55], [20, 58], [20, 59], [20, 60], [20, 61], [20, 63], [20, 65], [20, 66], [20, 67], [20, 69], [20, 70], [20, 72], [20, 73], [20, 74], [20, 78], [20, 82], [20, 85], [20, 86], [20, 87], [20, 95], [20, 97], [20, 98], [21, 23], [21, 26], [21, 30], [21, 31], [21, 32], [21, 39], [21, 42], [21, 45], [21, 46], [21, 47], [21, 49], [21, 51], [21, 52], [21, 53], [21, 54], [21, 55], [21, 57], [21, 63], [21, 64], [21, 67], [21, 68], [21, 69], [21, 71], [21, 73], [21, 77], [21, 81], [21, 83], [21, 86], [21, 88], [21, 89], [21, 90], [21, 91], [21, 95], [21, 96], [21, 98], [22, 24], [22, 26], [22, 28], [22, 29], [22, 30], [22, 31], [22, 32], [22, 34], [22, 35], [22, 39], [22, 41], [22, 42], [22, 43], [22, 45], [22, 49], [22, 52], [22, 53], [22, 54], [22, 55], [22, 56], [22, 57], [22, 58], [22, 61], [22, 62], [22, 63], [22, 65], [22, 66], [22, 67], [22, 68], [22, 71], [22, 73], [22, 74], [22, 75], [22, 76], [22, 77], [22, 78], [22, 79], [22, 80], [22, 81], [22, 83], [22, 84], [22, 85], [22, 86], [22, 87], [22, 88], [22, 89], [22, 90], [22, 91], [22, 92], [22, 96], [22, 97], [22, 98], [23, 24], [23, 25], [23, 26], [23, 27], [23, 30], [23, 32], [23, 33], [23, 34], [23, 36], [23, 37], [23, 39], [23, 44], [23, 45], [23, 47], [23, 49], [23, 53], [23, 55], [23, 57], [23, 60], [23, 63], [23, 65], [23, 66], [23, 67], [23, 68], [23, 72], [23, 73], [23, 75], [23, 76], [23, 78], [23, 81], [23, 84], [23, 85], [23, 86], [23, 92], [23, 94], [23, 95], [23, 96], [23, 97], [23, 98], [23, 99], [24, 25], [24, 26], [24, 28], [24, 29], [24, 31], [24, 32], [24, 33], [24, 35], [24, 39], [24, 40], [24, 43], [24, 45], [24, 47], [24, 49], [24, 50], [24, 51], [24, 53], [24, 54], [24, 55], [24, 57], [24, 61], [24, 62], [24, 63], [24, 65], [24, 68], [24, 69], [24, 74], [24, 75], [24, 76], [24, 77], [24, 78], [24, 79], [24, 83], [24, 84], [24, 85], [24, 87], [24, 89], [24, 92], [24, 97], [24, 99], [25, 26], [25, 27], [25, 29], [25, 30], [25, 32], [25, 35], [25, 37], [25, 39], [25, 41], [25, 42], [25, 46], [25, 47], [25, 49], [25, 51], [25, 54], [25, 55], [25, 56], [25, 57], [25, 58], [25, 59], [25, 61], [25, 64], [25, 66], [25, 70], [25, 71], [25, 73], [25, 76], [25, 78], [25, 79], [25, 82], [25, 84], [25, 90], [25, 91], [25, 93], [25, 94], [25, 95], [25, 96], [25, 97], [25, 99], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 35], [26, 40], [26, 43], [26, 44], [26, 47], [26, 50], [26, 51], [26, 53], [26, 54], [26, 59], [26, 60], [26, 61], [26, 65], [26, 66], [26, 67], [26, 68], [26, 69], [26, 71], [26, 73], [26, 74], [26, 75], [26, 76], [26, 79], [26, 80], [26, 81], [26, 84], [26, 85], [26, 86], [26, 90], [26, 91], [26, 92], [26, 93], [26, 96], [26, 97], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 34], [27, 35], [27, 36], [27, 40], [27, 42], [27, 43], [27, 44], [27, 46], [27, 47], [27, 48], [27, 51], [27, 52], [27, 54], [27, 61], [27, 62], [27, 65], [27, 68], [27, 70], [27, 73], [27, 78], [27, 80], [27, 82], [27, 84], [27, 86], [27, 87], [27, 88], [27, 91], [27, 92], [27, 94], [27, 97], [27, 99], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 35], [28, 37], [28, 40], [28, 46], [28, 48], [28, 50], [28, 51], [28, 53], [28, 54], [28, 57], [28, 58], [28, 60], [28, 62], [28, 63], [28, 64], [28, 65], [28, 66], [28, 67], [28, 68], [28, 69], [28, 71], [28, 72], [28, 74], [28, 75], [28, 76], [28, 77], [28, 78], [28, 80], [28, 81], [28, 82], [28, 83], [28, 84], [28, 85], [28, 87], [28, 90], [28, 91], [28, 92], [28, 93], [28, 96], [28, 99], [29, 33], [29, 34], [29, 36], [29, 44], [29, 46], [29, 47], [29, 49], [29, 51], [29, 52], [29, 53], [29, 54], [29, 55], [29, 56], [29, 57], [29, 60], [29, 63], [29, 65], [29, 66], [29, 69], [29, 72], [29, 74], [29, 75], [29, 81], [29, 82], [29, 84], [29, 90], [29, 92], [29, 93], [29, 96], [29, 97], [29, 98], [30, 31], [30, 34], [30, 35], [30, 36], [30, 38], [30, 39], [30, 41], [30, 43], [30, 44], [30, 45], [30, 50], [30, 51], [30, 55], [30, 56], [30, 59], [30, 60], [30, 61], [30, 65], [30, 66], [30, 68], [30, 69], [30, 70], [30, 72], [30, 74], [30, 76], [30, 77], [30, 78], [30, 79], [30, 80], [30, 81], [30, 84], [30, 85], [30, 87], [30, 88], [30, 90], [30, 91], [30, 92], [30, 93], [30, 95], [30, 96], [30, 97], [31, 34], [31, 35], [31, 42], [31, 44], [31, 45], [31, 47], [31, 48], [31, 50], [31, 51], [31, 53], [31, 55], [31, 57], [31, 58], [31, 60], [31, 61], [31, 62], [31, 63], [31, 65], [31, 66], [31, 67], [31, 68], [31, 69], [31, 70], [31, 74], [31, 76], [31, 77], [31, 78], [31, 80], [31, 81], [31, 82], [31, 84], [31, 85], [31, 87], [31, 90], [31, 91], [31, 92], [31, 93], [31, 94], [31, 96], [31, 99], [32, 33], [32, 35], [32, 37], [32, 39], [32, 41], [32, 46], [32, 47], [32, 50], [32, 51], [32, 53], [32, 55], [32, 58], [32, 61], [32, 62], [32, 63], [32, 66], [32, 68], [32, 70], [32, 72], [32, 74], [32, 75], [32, 78], [32, 80], [32, 82], [32, 86], [32, 87], [32, 88], [32, 89], [32, 90], [32, 93], [32, 94], [32, 97], [32, 98], [32, 99], [33, 35], [33, 36], [33, 38], [33, 40], [33, 42], [33, 43], [33, 44], [33, 45], [33, 47], [33, 49], [33, 50], [33, 52], [33, 53], [33, 54], [33, 57], [33, 58], [33, 59], [33, 60], [33, 61], [33, 63], [33, 64], [33, 67], [33, 69], [33, 70], [33, 74], [33, 77], [33, 79], [33, 82], [33, 84], [33, 85], [33, 87], [33, 90], [33, 91], [33, 93], [33, 98], [34, 36], [34, 40], [34, 43], [34, 44], [34, 49], [34, 52], [34, 55], [34, 61], [34, 64], [34, 65], [34, 67], [34, 68], [34, 70], [34, 71], [34, 72], [34, 75], [34, 76], [34, 77], [34, 80], [34, 81], [34, 82], [34, 83], [34, 84], [34, 86], [34, 91], [34, 92], [34, 93], [34, 94], [34, 96], [34, 97], [34, 98], [34, 99], [35, 36], [35, 37], [35, 39], [35, 41], [35, 43], [35, 46], [35, 47], [35, 51], [35, 52], [35, 54], [35, 59], [35, 60], [35, 65], [35, 67], [35, 69], [35, 70], [35, 71], [35, 72], [35, 73], [35, 77], [35, 78], [35, 85], [35, 86], [35, 88], [35, 90], [35, 92], [35, 93], [35, 97], [35, 98], [35, 99], [36, 38], [36, 39], [36, 40], [36, 41], [36, 42], [36, 43], [36, 44], [36, 49], [36, 51], [36, 53], [36, 54], [36, 55], [36, 56], [36, 58], [36, 59], [36, 63], [36, 66], [36, 68], [36, 69], [36, 70], [36, 71], [36, 72], [36, 77], [36, 79], [36, 82], [36, 85], [36, 86], [36, 87], [36, 88], [36, 89], [36, 93], [36, 95], [36, 97], [37, 38], [37, 41], [37, 42], [37, 50], [37, 51], [37, 54], [37, 55], [37, 56], [37, 60], [37, 64], [37, 69], [37, 70], [37, 71], [37, 72], [37, 74], [37, 75], [37, 76], [37, 77], [37, 78], [37, 80], [37, 81], [37, 89], [37, 90], [37, 91], [37, 93], [37, 96], [37, 97], [37, 99], [38, 42], [38, 43], [38, 45], [38, 46], [38, 47], [38, 48], [38, 50], [38, 51], [38, 53], [38, 54], [38, 55], [38, 57], [38, 63], [38, 65], [38, 67], [38, 68], [38, 71], [38, 72], [38, 73], [38, 78], [38, 81], [38, 84], [38, 87], [38, 89], [38, 90], [38, 91], [38, 93], [38, 96], [39, 44], [39, 46], [39, 47], [39, 49], [39, 50], [39, 51], [39, 54], [39, 59], [39, 60], [39, 61], [39, 62], [39, 63], [39, 70], [39, 71], [39, 72], [39, 73], [39, 74], [39, 75], [39, 76], [39, 81], [39, 84], [39, 85], [39, 87], [39, 90], [39, 92], [39, 93], [39, 94], [39, 97], [39, 99], [40, 42], [40, 44], [40, 45], [40, 47], [40, 49], [40, 50], [40, 51], [40, 53], [40, 55], [40, 56], [40, 57], [40, 63], [40, 64], [40, 65], [40, 69], [40, 70], [40, 71], [40, 73], [40, 75], [40, 78], [40, 79], [40, 82], [40, 83], [40, 89], [40, 90], [40, 92], [40, 93], [40, 98], [40, 99], [41, 42], [41, 46], [41, 47], [41, 50], [41, 51], [41, 53], [41, 54], [41, 55], [41, 59], [41, 60], [41, 61], [41, 62], [41, 67], [41, 69], [41, 73], [41, 76], [41, 77], [41, 78], [41, 79], [41, 81], [41, 82], [41, 83], [41, 85], [41, 91], [41, 92], [41, 94], [41, 97], [41, 99], [42, 44], [42, 47], [42, 48], [42, 49], [42, 51], [42, 52], [42, 53], [42, 54], [42, 55], [42, 56], [42, 58], [42, 59], [42, 62], [42, 64], [42, 67], [42, 69], [42, 74], [42, 76], [42, 77], [42, 80], [42, 81], [42, 82], [42, 83], [42, 86], [42, 87], [42, 90], [42, 97], [42, 98], [43, 48], [43, 51], [43, 53], [43, 54], [43, 58], [43, 62], [43, 63], [43, 65], [43, 66], [43, 69], [43, 71], [43, 72], [43, 73], [43, 77], [43, 79], [43, 80], [43, 82], [43, 85], [43, 86], [43, 87], [43, 88], [43, 90], [43, 91], [43, 94], [43, 95], [43, 96], [43, 97], [44, 45], [44, 46], [44, 47], [44, 50], [44, 52], [44, 56], [44, 59], [44, 60], [44, 61], [44, 63], [44, 65], [44, 67], [44, 70], [44, 71], [44, 72], [44, 75], [44, 76], [44, 77], [44, 80], [44, 81], [44, 82], [44, 84], [44, 85], [44, 86], [44, 87], [44, 89], [44, 91], [44, 92], [44, 93], [44, 94], [44, 97], [44, 98], [45, 46], [45, 47], [45, 48], [45, 52], [45, 54], [45, 56], [45, 58], [45, 59], [45, 60], [45, 62], [45, 63], [45, 64], [45, 66], [45, 68], [45, 70], [45, 76], [45, 78], [45, 80], [45, 81], [45, 85], [45, 96], [45, 98], [45, 99], [46, 47], [46, 49], [46, 51], [46, 53], [46, 54], [46, 59], [46, 61], [46, 64], [46, 65], [46, 67], [46, 68], [46, 69], [46, 70], [46, 72], [46, 73], [46, 74], [46, 76], [46, 78], [46, 80], [46, 81], [46, 82], [46, 83], [46, 84], [46, 86], [46, 87], [46, 90], [46, 91], [46, 93], [46, 95], [46, 97], [46, 98], [47, 49], [47, 52], [47, 56], [47, 57], [47, 58], [47, 59], [47, 63], [47, 64], [47, 67], [47, 68], [47, 71], [47, 74], [47, 75], [47, 77], [47, 80], [47, 83], [47, 87], [47, 89], [47, 90], [47, 91], [47, 92], [47, 93], [48, 51], [48, 53], [48, 56], [48, 59], [48, 61], [48, 63], [48, 67], [48, 68], [48, 69], [48, 72], [48, 73], [48, 78], [48, 84], [48, 85], [48, 87], [48, 88], [48, 90], [48, 92], [48, 94], [48, 95], [48, 98], [49, 50], [49, 51], [49, 52], [49, 54], [49, 56], [49, 58], [49, 59], [49, 60], [49, 66], [49, 69], [49, 72], [49, 74], [49, 75], [49, 77], [49, 79], [49, 81], [49, 85], [49, 86], [49, 87], [49, 88], [49, 89], [49, 90], [49, 91], [49, 93], [49, 95], [49, 96], [49, 98], [50, 51], [50, 53], [50, 63], [50, 65], [50, 68], [50, 73], [50, 74], [50, 78], [50, 80], [50, 81], [50, 82], [50, 83], [50, 89], [50, 95], [50, 97], [50, 99], [51, 52], [51, 53], [51, 56], [51, 59], [51, 60], [51, 61], [51, 63], [51, 64], [51, 65], [51, 66], [51, 68], [51, 69], [51, 71], [51, 72], [51, 74], [51, 76], [51, 77], [51, 79], [51, 80], [51, 81], [51, 84], [51, 85], [51, 86], [51, 87], [51, 88], [51, 89], [51, 90], [51, 91], [51, 92], [51, 94], [51, 95], [51, 96], [51, 97], [51, 98], [51, 99], [52, 53], [52, 56], [52, 57], [52, 60], [52, 61], [52, 65], [52, 66], [52, 67], [52, 68], [52, 72], [52, 76], [52, 78], [52, 79], [52, 81], [52, 82], [52, 83], [52, 85], [52, 86], [52, 87], [52, 90], [52, 91], [52, 95], [52, 96], [52, 99], [53, 54], [53, 56], [53, 57], [53, 60], [53, 61], [53, 63], [53, 64], [53, 65], [53, 66], [53, 67], [53, 69], [53, 70], [53, 71], [53, 72], [53, 74], [53, 75], [53, 76], [53, 80], [53, 82], [53, 83], [53, 86], [53, 87], [53, 88], [53, 91], [53, 92], [53, 95], [53, 99], [54, 58], [54, 59], [54, 60], [54, 62], [54, 66], [54, 67], [54, 68], [54, 70], [54, 71], [54, 72], [54, 73], [54, 75], [54, 78], [54, 79], [54, 80], [54, 81], [54, 83], [54, 85], [54, 86], [54, 87], [54, 92], [54, 94], [54, 96], [54, 97], [54, 98], [55, 56], [55, 57], [55, 58], [55, 59], [55, 60], [55, 61], [55, 62], [55, 63], [55, 65], [55, 66], [55, 68], [55, 69], [55, 71], [55, 72], [55, 74], [55, 75], [55, 79], [55, 80], [55, 82], [55, 85], [55, 89], [55, 90], [55, 93], [55, 94], [56, 58], [56, 59], [56, 61], [56, 62], [56, 63], [56, 64], [56, 66], [56, 68], [56, 74], [56, 78], [56, 82], [56, 84], [56, 87], [56, 88], [56, 89], [56, 90], [56, 91], [56, 92], [56, 94], [56, 95], [57, 60], [57, 62], [57, 64], [57, 65], [57, 66], [57, 67], [57, 69], [57, 73], [57, 75], [57, 76], [57, 77], [57, 78], [57, 79], [57, 83], [57, 84], [57, 85], [57, 86], [57, 87], [57, 89], [57, 90], [57, 91], [57, 93], [57, 97], [57, 99], [58, 59], [58, 65], [58, 67], [58, 68], [58, 69], [58, 70], [58, 71], [58, 73], [58, 74], [58, 77], [58, 78], [58, 79], [58, 82], [58, 88], [58, 90], [58, 91], [58, 92], [58, 93], [58, 98], [58, 99], [59, 60], [59, 62], [59, 64], [59, 68], [59, 71], [59, 72], [59, 74], [59, 76], [59, 78], [59, 84], [59, 85], [59, 91], [59, 92], [59, 93], [59, 95], [59, 97], [60, 62], [60, 63], [60, 65], [60, 67], [60, 68], [60, 69], [60, 72], [60, 74], [60, 75], [60, 76], [60, 77], [60, 78], [60, 79], [60, 80], [60, 81], [60, 83], [60, 84], [60, 85], [60, 86], [60, 87], [60, 88], [60, 89], [60, 90], [60, 91], [60, 92], [60, 93], [60, 94], [60, 95], [60, 96], [60, 97], [61, 64], [61, 66], [61, 67], [61, 68], [61, 69], [61, 70], [61, 71], [61, 73], [61, 74], [61, 75], [61, 76], [61, 78], [61, 80], [61, 83], [61, 85], [61, 86], [61, 87], [61, 88], [61, 97], [61, 99], [62, 64], [62, 68], [62, 69], [62, 70], [62, 71], [62, 72], [62, 74], [62, 76], [62, 77], [62, 78], [62, 79], [62, 81], [62, 82], [62, 83], [62, 84], [62, 86], [62, 87], [62, 89], [62, 91], [62, 92], [62, 94], [62, 95], [62, 99], [63, 67], [63, 70], [63, 71], [63, 73], [63, 74], [63, 75], [63, 76], [63, 78], [63, 80], [63, 81], [63, 82], [63, 83], [63, 85], [63, 86], [63, 88], [63, 90], [63, 92], [63, 93], [63, 94], [63, 99], [64, 66], [64, 67], [64, 68], [64, 70], [64, 71], [64, 73], [64, 78], [64, 87], [64, 88], [64, 91], [64, 92], [64, 93], [64, 98], [65, 67], [65, 68], [65, 69], [65, 72], [65, 74], [65, 75], [65, 76], [65, 77], [65, 80], [65, 81], [65, 82], [65, 84], [65, 85], [65, 87], [65, 90], [65, 91], [65, 92], [65, 94], [65, 95], [65, 96], [65, 97], [66, 67], [66, 70], [66, 75], [66, 76], [66, 77], [66, 80], [66, 91], [66, 92], [66, 93], [66, 96], [66, 97], [66, 99], [67, 68], [67, 70], [67, 73], [67, 74], [67, 78], [67, 79], [67, 80], [67, 81], [67, 84], [67, 88], [67, 91], [67, 93], [67, 94], [67, 95], [67, 96], [67, 97], [68, 69], [68, 71], [68, 74], [68, 76], [68, 79], [68, 80], [68, 81], [68, 82], [68, 84], [68, 85], [68, 88], [68, 89], [68, 90], [68, 91], [68, 92], [68, 93], [68, 94], [68, 96], [69, 72], [69, 74], [69, 76], [69, 79], [69, 80], [69, 81], [69, 84], [69, 85], [69, 86], [69, 88], [69, 90], [69, 91], [69, 92], [69, 93], [69, 94], [69, 96], [69, 97], [69, 99], [70, 72], [70, 74], [70, 76], [70, 77], [70, 87], [70, 88], [70, 89], [70, 90], [70, 97], [70, 98], [71, 75], [71, 76], [71, 81], [71, 84], [71, 85], [71, 86], [71, 88], [71, 89], [71, 90], [71, 93], [71, 95], [71, 96], [71, 98], [72, 74], [72, 76], [72, 77], [72, 85], [72, 86], [72, 87], [72, 88], [72, 89], [72, 90], [72, 91], [72, 93], [72, 97], [72, 99], [73, 75], [73, 76], [73, 78], [73, 79], [73, 80], [73, 82], [73, 84], [73, 86], [73, 89], [73, 90], [73, 96], [73, 97], [73, 98], [74, 75], [74, 76], [74, 79], [74, 80], [74, 81], [74, 82], [74, 84], [74, 85], [74, 88], [74, 89], [74, 90], [74, 91], [74, 92], [74, 93], [74, 94], [74, 96], [74, 97], [75, 78], [75, 79], [75, 82], [75, 83], [75, 84], [75, 86], [75, 87], [75, 89], [75, 92], [75, 93], [75, 94], [75, 96], [75, 97], [75, 98], [75, 99], [76, 78], [76, 79], [76, 80], [76, 81], [76, 82], [76, 83], [76, 84], [76, 85], [76, 86], [76, 87], [76, 88], [76, 89], [76, 90], [76, 91], [76, 92], [76, 93], [76, 95], [76, 96], [76, 97], [76, 98], [76, 99], [77, 80], [77, 84], [77, 85], [77, 89], [77, 92], [77, 95], [77, 96], [77, 97], [77, 98], [78, 79], [78, 80], [78, 81], [78, 82], [78, 87], [78, 91], [78, 93], [78, 94], [78, 95], [78, 96], [78, 99], [79, 82], [79, 83], [79, 84], [79, 86], [79, 87], [79, 88], [79, 89], [79, 91], [79, 94], [79, 96], [79, 98], [79, 99], [80, 81], [80, 83], [80, 84], [80, 85], [80, 86], [80, 89], [80, 90], [80, 91], [80, 92], [80, 93], [80, 95], [80, 96], [80, 97], [81, 82], [81, 83], [81, 84], [81, 85], [81, 86], [81, 87], [81, 88], [81, 89], [81, 90], [81, 91], [81, 92], [81, 94], [81, 95], [81, 98], [81, 99], [82, 83], [82, 84], [82, 89], [82, 92], [82, 93], [82, 94], [82, 98], [82, 99], [83, 84], [83, 85], [83, 87], [83, 88], [83, 91], [83, 92], [83, 93], [83, 94], [83, 96], [83, 97], [83, 99], [84, 85], [84, 87], [84, 89], [84, 90], [84, 91], [84, 92], [84, 97], [84, 98], [84, 99], [85, 88], [85, 89], [85, 90], [85, 91], [85, 92], [85, 96], [85, 98], [85, 99], [86, 89], [86, 94], [86, 95], [87, 88], [87, 90], [87, 93], [87, 99], [88, 89], [88, 91], [88, 96], [89, 96], [89, 97], [90, 91], [90, 92], [90, 96], [90, 97], [90, 99], [91, 92], [91, 93], [91, 94], [91, 95], [91, 96], [91, 97], [92, 93], [92, 95], [92, 96], [93, 94], [93, 96], [93, 99], [94, 95], [94, 97], [94, 99], [95, 96], [95, 98], [95, 99], [96, 97], [97, 99], [98, 99]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s3/solution/solve.sh b/tasks/construct-nppc-clique-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..911827931f86be6cf499ab389a12c74fd9943aea --- /dev/null +++ b/tasks/construct-nppc-clique-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' +{"clique": [10, 15, 26, 28, 30, 31, 51, 60, 65, 68, 69, 74, 76, 80, 81, 84, 85, 90, 91, 92]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l6-s3/tests/check.py b/tasks/construct-nppc-clique-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s3/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l6-s3/tests/instance.json b/tasks/construct-nppc-clique-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..65f36f7193d97913ad8a8578478ca7f8f24d1d5b --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 2], [0, 4], [0, 5], [0, 8], [0, 10], [0, 11], [0, 12], [0, 13], [0, 15], [0, 16], [0, 17], [0, 19], [0, 20], [0, 22], [0, 23], [0, 24], [0, 26], [0, 27], [0, 28], [0, 29], [0, 30], [0, 33], [0, 35], [0, 38], [0, 40], [0, 41], [0, 44], [0, 46], [0, 47], [0, 48], [0, 49], [0, 50], [0, 53], [0, 55], [0, 56], [0, 60], [0, 61], [0, 65], [0, 69], [0, 70], [0, 73], [0, 75], [0, 76], [0, 77], [0, 78], [0, 82], [0, 83], [0, 84], [0, 85], [0, 86], [0, 90], [0, 95], [0, 97], [0, 98], [1, 2], [1, 3], [1, 4], [1, 9], [1, 10], [1, 12], [1, 15], [1, 16], [1, 17], [1, 19], [1, 20], [1, 22], [1, 24], [1, 25], [1, 27], [1, 28], [1, 29], [1, 32], [1, 34], [1, 35], [1, 37], [1, 41], [1, 43], [1, 44], [1, 48], [1, 50], [1, 51], [1, 52], [1, 53], [1, 54], [1, 57], [1, 58], [1, 59], [1, 61], [1, 62], [1, 63], [1, 64], [1, 66], [1, 68], [1, 72], [1, 75], [1, 76], [1, 77], [1, 79], [1, 82], [1, 83], [1, 84], [1, 85], [1, 86], [1, 87], [1, 88], [1, 90], [1, 92], [1, 95], [1, 96], [1, 97], [1, 99], [2, 4], [2, 6], [2, 8], [2, 9], [2, 10], [2, 11], [2, 13], [2, 14], [2, 16], [2, 18], [2, 19], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 27], [2, 28], [2, 30], [2, 31], [2, 32], [2, 38], [2, 42], [2, 43], [2, 52], [2, 57], [2, 58], [2, 59], [2, 60], [2, 62], [2, 65], [2, 66], [2, 69], [2, 70], [2, 71], [2, 74], [2, 76], [2, 78], [2, 79], [2, 80], [2, 82], [2, 84], [2, 86], [2, 88], [2, 90], [2, 93], [2, 96], [2, 98], [2, 99], [3, 4], [3, 5], [3, 8], [3, 9], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 30], [3, 31], [3, 32], [3, 34], [3, 36], [3, 37], [3, 39], [3, 42], [3, 46], [3, 47], [3, 53], [3, 56], [3, 60], [3, 61], [3, 65], [3, 69], [3, 71], [3, 72], [3, 74], [3, 75], [3, 77], [3, 78], [3, 81], [3, 86], [3, 87], [3, 88], [3, 90], [3, 92], [3, 94], [3, 96], [3, 99], [4, 8], [4, 9], [4, 10], [4, 11], [4, 13], [4, 14], [4, 15], [4, 23], [4, 26], [4, 28], [4, 29], [4, 33], [4, 35], [4, 40], [4, 41], [4, 45], [4, 47], [4, 48], [4, 49], [4, 53], [4, 55], [4, 60], [4, 61], [4, 63], [4, 65], [4, 69], [4, 70], [4, 74], [4, 78], [4, 79], [4, 82], [4, 84], [4, 85], [4, 86], [4, 88], [4, 89], [4, 90], [4, 91], [4, 93], [4, 96], [4, 97], [4, 99], [5, 7], [5, 8], [5, 9], [5, 10], [5, 12], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 23], [5, 25], [5, 26], [5, 28], [5, 29], [5, 30], [5, 33], [5, 39], [5, 42], [5, 44], [5, 46], [5, 48], [5, 53], [5, 57], [5, 60], [5, 63], [5, 65], [5, 67], [5, 68], [5, 70], [5, 71], [5, 72], [5, 73], [5, 74], [5, 76], [5, 77], [5, 79], [5, 80], [5, 82], [5, 85], [5, 89], [5, 91], [5, 92], [5, 94], [5, 95], [5, 97], [5, 99], [6, 9], [6, 10], [6, 11], [6, 12], [6, 20], [6, 21], [6, 23], [6, 26], [6, 28], [6, 31], [6, 32], [6, 33], [6, 37], [6, 41], [6, 42], [6, 43], [6, 44], [6, 48], [6, 49], [6, 57], [6, 59], [6, 61], [6, 62], [6, 63], [6, 64], [6, 67], [6, 70], [6, 71], [6, 73], [6, 76], [6, 77], [6, 78], [6, 79], [6, 80], [6, 81], [6, 83], [6, 85], [6, 87], [6, 88], [6, 89], [6, 92], [6, 93], [6, 96], [7, 10], [7, 12], [7, 14], [7, 16], [7, 18], [7, 19], [7, 21], [7, 25], [7, 26], [7, 28], [7, 29], [7, 31], [7, 32], [7, 36], [7, 37], [7, 38], [7, 41], [7, 42], [7, 43], [7, 46], [7, 48], [7, 51], [7, 52], [7, 53], [7, 54], [7, 55], [7, 57], [7, 58], [7, 60], [7, 61], [7, 63], [7, 64], [7, 68], [7, 69], [7, 71], [7, 73], [7, 75], [7, 76], [7, 77], [7, 79], [7, 80], [7, 82], [7, 91], [7, 97], [8, 12], [8, 14], [8, 17], [8, 18], [8, 21], [8, 22], [8, 24], [8, 27], [8, 29], [8, 31], [8, 32], [8, 34], [8, 35], [8, 38], [8, 42], [8, 44], [8, 45], [8, 46], [8, 47], [8, 48], [8, 50], [8, 53], [8, 55], [8, 57], [8, 61], [8, 65], [8, 67], [8, 68], [8, 69], [8, 70], [8, 74], [8, 75], [8, 77], [8, 79], [8, 80], [8, 81], [8, 84], [8, 85], [8, 91], [8, 92], [8, 93], [8, 96], [8, 99], [9, 12], [9, 13], [9, 14], [9, 16], [9, 17], [9, 18], [9, 25], [9, 26], [9, 28], [9, 33], [9, 35], [9, 36], [9, 37], [9, 39], [9, 40], [9, 41], [9, 42], [9, 44], [9, 46], [9, 49], [9, 52], [9, 53], [9, 54], [9, 56], [9, 57], [9, 59], [9, 60], [9, 61], [9, 62], [9, 64], [9, 65], [9, 67], [9, 68], [9, 69], [9, 70], [9, 74], [9, 75], [9, 76], [9, 77], [9, 78], [9, 80], [9, 82], [9, 83], [9, 86], [9, 90], [9, 92], [9, 93], [9, 94], [9, 97], [10, 13], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 21], [10, 24], [10, 26], [10, 27], [10, 28], [10, 29], [10, 30], [10, 31], [10, 32], [10, 35], [10, 37], [10, 38], [10, 39], [10, 40], [10, 42], [10, 47], [10, 50], [10, 51], [10, 54], [10, 56], [10, 57], [10, 59], [10, 60], [10, 63], [10, 64], [10, 65], [10, 66], [10, 67], [10, 68], [10, 69], [10, 73], [10, 74], [10, 75], [10, 76], [10, 77], [10, 79], [10, 80], [10, 81], [10, 82], [10, 83], [10, 84], [10, 85], [10, 90], [10, 91], [10, 92], [10, 93], [10, 94], [10, 99], [11, 14], [11, 16], [11, 17], [11, 18], [11, 19], [11, 21], [11, 24], [11, 26], [11, 27], [11, 28], [11, 30], [11, 33], [11, 34], [11, 37], [11, 40], [11, 42], [11, 43], [11, 44], [11, 45], [11, 49], [11, 51], [11, 52], [11, 53], [11, 54], [11, 57], [11, 58], [11, 59], [11, 61], [11, 63], [11, 64], [11, 71], [11, 72], [11, 73], [11, 76], [11, 77], [11, 78], [11, 79], [11, 80], [11, 81], [11, 82], [11, 83], [11, 85], [11, 86], [11, 88], [11, 89], [11, 91], [11, 95], [12, 13], [12, 14], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 32], [12, 34], [12, 36], [12, 37], [12, 38], [12, 40], [12, 42], [12, 43], [12, 45], [12, 47], [12, 49], [12, 50], [12, 51], [12, 54], [12, 55], [12, 56], [12, 57], [12, 58], [12, 59], [12, 64], [12, 66], [12, 67], [12, 70], [12, 71], [12, 73], [12, 78], [12, 79], [12, 82], [12, 83], [12, 85], [12, 87], [12, 88], [12, 89], [12, 92], [12, 93], [12, 94], [12, 95], [12, 96], [12, 97], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 25], [13, 27], [13, 31], [13, 33], [13, 35], [13, 36], [13, 37], [13, 39], [13, 40], [13, 41], [13, 43], [13, 44], [13, 45], [13, 46], [13, 49], [13, 50], [13, 53], [13, 54], [13, 55], [13, 56], [13, 57], [13, 62], [13, 64], [13, 67], [13, 70], [13, 71], [13, 72], [13, 73], [13, 74], [13, 75], [13, 76], [13, 80], [13, 81], [13, 82], [13, 84], [13, 92], [13, 93], [13, 96], [13, 97], [13, 98], [13, 99], [14, 16], [14, 17], [14, 20], [14, 24], [14, 27], [14, 29], [14, 31], [14, 33], [14, 35], [14, 40], [14, 42], [14, 49], [14, 53], [14, 54], [14, 59], [14, 60], [14, 61], [14, 62], [14, 64], [14, 66], [14, 67], [14, 69], [14, 70], [14, 72], [14, 76], [14, 77], [14, 79], [14, 80], [14, 84], [14, 87], [14, 94], [14, 98], [15, 17], [15, 18], [15, 20], [15, 21], [15, 24], [15, 26], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [15, 36], [15, 37], [15, 42], [15, 45], [15, 48], [15, 50], [15, 51], [15, 53], [15, 54], [15, 55], [15, 56], [15, 58], [15, 60], [15, 61], [15, 62], [15, 64], [15, 65], [15, 68], [15, 69], [15, 71], [15, 72], [15, 74], [15, 75], [15, 76], [15, 77], [15, 78], [15, 79], [15, 80], [15, 81], [15, 82], [15, 83], [15, 84], [15, 85], [15, 88], [15, 89], [15, 90], [15, 91], [15, 92], [15, 93], [15, 94], [15, 99], [16, 21], [16, 23], [16, 25], [16, 27], [16, 29], [16, 30], [16, 32], [16, 33], [16, 34], [16, 35], [16, 40], [16, 41], [16, 46], [16, 51], [16, 52], [16, 53], [16, 54], [16, 56], [16, 57], [16, 60], [16, 64], [16, 66], [16, 69], [16, 70], [16, 72], [16, 73], [16, 74], [16, 75], [16, 76], [16, 78], [16, 79], [16, 80], [16, 81], [16, 82], [16, 83], [16, 85], [16, 87], [16, 90], [16, 92], [16, 93], [16, 94], [16, 95], [16, 96], [16, 97], [16, 99], [17, 20], [17, 21], [17, 23], [17, 25], [17, 29], [17, 32], [17, 34], [17, 36], [17, 41], [17, 42], [17, 43], [17, 44], [17, 48], [17, 52], [17, 53], [17, 55], [17, 56], [17, 59], [17, 60], [17, 61], [17, 63], [17, 64], [17, 67], [17, 69], [17, 70], [17, 71], [17, 74], [17, 75], [17, 79], [17, 82], [17, 84], [17, 85], [17, 87], [17, 88], [17, 89], [17, 90], [17, 91], [17, 92], [17, 94], [17, 95], [17, 97], [17, 98], [17, 99], [18, 22], [18, 23], [18, 25], [18, 30], [18, 32], [18, 33], [18, 34], [18, 35], [18, 39], [18, 41], [18, 43], [18, 44], [18, 45], [18, 47], [18, 49], [18, 50], [18, 51], [18, 52], [18, 54], [18, 56], [18, 57], [18, 58], [18, 59], [18, 62], [18, 65], [18, 67], [18, 68], [18, 69], [18, 70], [18, 71], [18, 76], [18, 78], [18, 80], [18, 83], [18, 86], [18, 90], [18, 91], [18, 92], [18, 94], [18, 95], [19, 20], [19, 21], [19, 23], [19, 24], [19, 25], [19, 26], [19, 31], [19, 32], [19, 34], [19, 35], [19, 37], [19, 38], [19, 39], [19, 40], [19, 42], [19, 43], [19, 45], [19, 48], [19, 50], [19, 53], [19, 54], [19, 56], [19, 61], [19, 62], [19, 63], [19, 64], [19, 68], [19, 70], [19, 74], [19, 79], [19, 81], [19, 82], [19, 84], [19, 85], [19, 86], [19, 88], [19, 91], [19, 94], [19, 95], [19, 96], [19, 99], [20, 23], [20, 24], [20, 25], [20, 28], [20, 29], [20, 31], [20, 33], [20, 34], [20, 35], [20, 39], [20, 41], [20, 43], [20, 44], [20, 45], [20, 50], [20, 51], [20, 53], [20, 55], [20, 58], [20, 59], [20, 60], [20, 61], [20, 63], [20, 65], [20, 66], [20, 67], [20, 69], [20, 70], [20, 72], [20, 73], [20, 74], [20, 78], [20, 82], [20, 85], [20, 86], [20, 87], [20, 95], [20, 97], [20, 98], [21, 23], [21, 26], [21, 30], [21, 31], [21, 32], [21, 39], [21, 42], [21, 45], [21, 46], [21, 47], [21, 49], [21, 51], [21, 52], [21, 53], [21, 54], [21, 55], [21, 57], [21, 63], [21, 64], [21, 67], [21, 68], [21, 69], [21, 71], [21, 73], [21, 77], [21, 81], [21, 83], [21, 86], [21, 88], [21, 89], [21, 90], [21, 91], [21, 95], [21, 96], [21, 98], [22, 24], [22, 26], [22, 28], [22, 29], [22, 30], [22, 31], [22, 32], [22, 34], [22, 35], [22, 39], [22, 41], [22, 42], [22, 43], [22, 45], [22, 49], [22, 52], [22, 53], [22, 54], [22, 55], [22, 56], [22, 57], [22, 58], [22, 61], [22, 62], [22, 63], [22, 65], [22, 66], [22, 67], [22, 68], [22, 71], [22, 73], [22, 74], [22, 75], [22, 76], [22, 77], [22, 78], [22, 79], [22, 80], [22, 81], [22, 83], [22, 84], [22, 85], [22, 86], [22, 87], [22, 88], [22, 89], [22, 90], [22, 91], [22, 92], [22, 96], [22, 97], [22, 98], [23, 24], [23, 25], [23, 26], [23, 27], [23, 30], [23, 32], [23, 33], [23, 34], [23, 36], [23, 37], [23, 39], [23, 44], [23, 45], [23, 47], [23, 49], [23, 53], [23, 55], [23, 57], [23, 60], [23, 63], [23, 65], [23, 66], [23, 67], [23, 68], [23, 72], [23, 73], [23, 75], [23, 76], [23, 78], [23, 81], [23, 84], [23, 85], [23, 86], [23, 92], [23, 94], [23, 95], [23, 96], [23, 97], [23, 98], [23, 99], [24, 25], [24, 26], [24, 28], [24, 29], [24, 31], [24, 32], [24, 33], [24, 35], [24, 39], [24, 40], [24, 43], [24, 45], [24, 47], [24, 49], [24, 50], [24, 51], [24, 53], [24, 54], [24, 55], [24, 57], [24, 61], [24, 62], [24, 63], [24, 65], [24, 68], [24, 69], [24, 74], [24, 75], [24, 76], [24, 77], [24, 78], [24, 79], [24, 83], [24, 84], [24, 85], [24, 87], [24, 89], [24, 92], [24, 97], [24, 99], [25, 26], [25, 27], [25, 29], [25, 30], [25, 32], [25, 35], [25, 37], [25, 39], [25, 41], [25, 42], [25, 46], [25, 47], [25, 49], [25, 51], [25, 54], [25, 55], [25, 56], [25, 57], [25, 58], [25, 59], [25, 61], [25, 64], [25, 66], [25, 70], [25, 71], [25, 73], [25, 76], [25, 78], [25, 79], [25, 82], [25, 84], [25, 90], [25, 91], [25, 93], [25, 94], [25, 95], [25, 96], [25, 97], [25, 99], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 35], [26, 40], [26, 43], [26, 44], [26, 47], [26, 50], [26, 51], [26, 53], [26, 54], [26, 59], [26, 60], [26, 61], [26, 65], [26, 66], [26, 67], [26, 68], [26, 69], [26, 71], [26, 73], [26, 74], [26, 75], [26, 76], [26, 79], [26, 80], [26, 81], [26, 84], [26, 85], [26, 86], [26, 90], [26, 91], [26, 92], [26, 93], [26, 96], [26, 97], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 34], [27, 35], [27, 36], [27, 40], [27, 42], [27, 43], [27, 44], [27, 46], [27, 47], [27, 48], [27, 51], [27, 52], [27, 54], [27, 61], [27, 62], [27, 65], [27, 68], [27, 70], [27, 73], [27, 78], [27, 80], [27, 82], [27, 84], [27, 86], [27, 87], [27, 88], [27, 91], [27, 92], [27, 94], [27, 97], [27, 99], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 35], [28, 37], [28, 40], [28, 46], [28, 48], [28, 50], [28, 51], [28, 53], [28, 54], [28, 57], [28, 58], [28, 60], [28, 62], [28, 63], [28, 64], [28, 65], [28, 66], [28, 67], [28, 68], [28, 69], [28, 71], [28, 72], [28, 74], [28, 75], [28, 76], [28, 77], [28, 78], [28, 80], [28, 81], [28, 82], [28, 83], [28, 84], [28, 85], [28, 87], [28, 90], [28, 91], [28, 92], [28, 93], [28, 96], [28, 99], [29, 33], [29, 34], [29, 36], [29, 44], [29, 46], [29, 47], [29, 49], [29, 51], [29, 52], [29, 53], [29, 54], [29, 55], [29, 56], [29, 57], [29, 60], [29, 63], [29, 65], [29, 66], [29, 69], [29, 72], [29, 74], [29, 75], [29, 81], [29, 82], [29, 84], [29, 90], [29, 92], [29, 93], [29, 96], [29, 97], [29, 98], [30, 31], [30, 34], [30, 35], [30, 36], [30, 38], [30, 39], [30, 41], [30, 43], [30, 44], [30, 45], [30, 50], [30, 51], [30, 55], [30, 56], [30, 59], [30, 60], [30, 61], [30, 65], [30, 66], [30, 68], [30, 69], [30, 70], [30, 72], [30, 74], [30, 76], [30, 77], [30, 78], [30, 79], [30, 80], [30, 81], [30, 84], [30, 85], [30, 87], [30, 88], [30, 90], [30, 91], [30, 92], [30, 93], [30, 95], [30, 96], [30, 97], [31, 34], [31, 35], [31, 42], [31, 44], [31, 45], [31, 47], [31, 48], [31, 50], [31, 51], [31, 53], [31, 55], [31, 57], [31, 58], [31, 60], [31, 61], [31, 62], [31, 63], [31, 65], [31, 66], [31, 67], [31, 68], [31, 69], [31, 70], [31, 74], [31, 76], [31, 77], [31, 78], [31, 80], [31, 81], [31, 82], [31, 84], [31, 85], [31, 87], [31, 90], [31, 91], [31, 92], [31, 93], [31, 94], [31, 96], [31, 99], [32, 33], [32, 35], [32, 37], [32, 39], [32, 41], [32, 46], [32, 47], [32, 50], [32, 51], [32, 53], [32, 55], [32, 58], [32, 61], [32, 62], [32, 63], [32, 66], [32, 68], [32, 70], [32, 72], [32, 74], [32, 75], [32, 78], [32, 80], [32, 82], [32, 86], [32, 87], [32, 88], [32, 89], [32, 90], [32, 93], [32, 94], [32, 97], [32, 98], [32, 99], [33, 35], [33, 36], [33, 38], [33, 40], [33, 42], [33, 43], [33, 44], [33, 45], [33, 47], [33, 49], [33, 50], [33, 52], [33, 53], [33, 54], [33, 57], [33, 58], [33, 59], [33, 60], [33, 61], [33, 63], [33, 64], [33, 67], [33, 69], [33, 70], [33, 74], [33, 77], [33, 79], [33, 82], [33, 84], [33, 85], [33, 87], [33, 90], [33, 91], [33, 93], [33, 98], [34, 36], [34, 40], [34, 43], [34, 44], [34, 49], [34, 52], [34, 55], [34, 61], [34, 64], [34, 65], [34, 67], [34, 68], [34, 70], [34, 71], [34, 72], [34, 75], [34, 76], [34, 77], [34, 80], [34, 81], [34, 82], [34, 83], [34, 84], [34, 86], [34, 91], [34, 92], [34, 93], [34, 94], [34, 96], [34, 97], [34, 98], [34, 99], [35, 36], [35, 37], [35, 39], [35, 41], [35, 43], [35, 46], [35, 47], [35, 51], [35, 52], [35, 54], [35, 59], [35, 60], [35, 65], [35, 67], [35, 69], [35, 70], [35, 71], [35, 72], [35, 73], [35, 77], [35, 78], [35, 85], [35, 86], [35, 88], [35, 90], [35, 92], [35, 93], [35, 97], [35, 98], [35, 99], [36, 38], [36, 39], [36, 40], [36, 41], [36, 42], [36, 43], [36, 44], [36, 49], [36, 51], [36, 53], [36, 54], [36, 55], [36, 56], [36, 58], [36, 59], [36, 63], [36, 66], [36, 68], [36, 69], [36, 70], [36, 71], [36, 72], [36, 77], [36, 79], [36, 82], [36, 85], [36, 86], [36, 87], [36, 88], [36, 89], [36, 93], [36, 95], [36, 97], [37, 38], [37, 41], [37, 42], [37, 50], [37, 51], [37, 54], [37, 55], [37, 56], [37, 60], [37, 64], [37, 69], [37, 70], [37, 71], [37, 72], [37, 74], [37, 75], [37, 76], [37, 77], [37, 78], [37, 80], [37, 81], [37, 89], [37, 90], [37, 91], [37, 93], [37, 96], [37, 97], [37, 99], [38, 42], [38, 43], [38, 45], [38, 46], [38, 47], [38, 48], [38, 50], [38, 51], [38, 53], [38, 54], [38, 55], [38, 57], [38, 63], [38, 65], [38, 67], [38, 68], [38, 71], [38, 72], [38, 73], [38, 78], [38, 81], [38, 84], [38, 87], [38, 89], [38, 90], [38, 91], [38, 93], [38, 96], [39, 44], [39, 46], [39, 47], [39, 49], [39, 50], [39, 51], [39, 54], [39, 59], [39, 60], [39, 61], [39, 62], [39, 63], [39, 70], [39, 71], [39, 72], [39, 73], [39, 74], [39, 75], [39, 76], [39, 81], [39, 84], [39, 85], [39, 87], [39, 90], [39, 92], [39, 93], [39, 94], [39, 97], [39, 99], [40, 42], [40, 44], [40, 45], [40, 47], [40, 49], [40, 50], [40, 51], [40, 53], [40, 55], [40, 56], [40, 57], [40, 63], [40, 64], [40, 65], [40, 69], [40, 70], [40, 71], [40, 73], [40, 75], [40, 78], [40, 79], [40, 82], [40, 83], [40, 89], [40, 90], [40, 92], [40, 93], [40, 98], [40, 99], [41, 42], [41, 46], [41, 47], [41, 50], [41, 51], [41, 53], [41, 54], [41, 55], [41, 59], [41, 60], [41, 61], [41, 62], [41, 67], [41, 69], [41, 73], [41, 76], [41, 77], [41, 78], [41, 79], [41, 81], [41, 82], [41, 83], [41, 85], [41, 91], [41, 92], [41, 94], [41, 97], [41, 99], [42, 44], [42, 47], [42, 48], [42, 49], [42, 51], [42, 52], [42, 53], [42, 54], [42, 55], [42, 56], [42, 58], [42, 59], [42, 62], [42, 64], [42, 67], [42, 69], [42, 74], [42, 76], [42, 77], [42, 80], [42, 81], [42, 82], [42, 83], [42, 86], [42, 87], [42, 90], [42, 97], [42, 98], [43, 48], [43, 51], [43, 53], [43, 54], [43, 58], [43, 62], [43, 63], [43, 65], [43, 66], [43, 69], [43, 71], [43, 72], [43, 73], [43, 77], [43, 79], [43, 80], [43, 82], [43, 85], [43, 86], [43, 87], [43, 88], [43, 90], [43, 91], [43, 94], [43, 95], [43, 96], [43, 97], [44, 45], [44, 46], [44, 47], [44, 50], [44, 52], [44, 56], [44, 59], [44, 60], [44, 61], [44, 63], [44, 65], [44, 67], [44, 70], [44, 71], [44, 72], [44, 75], [44, 76], [44, 77], [44, 80], [44, 81], [44, 82], [44, 84], [44, 85], [44, 86], [44, 87], [44, 89], [44, 91], [44, 92], [44, 93], [44, 94], [44, 97], [44, 98], [45, 46], [45, 47], [45, 48], [45, 52], [45, 54], [45, 56], [45, 58], [45, 59], [45, 60], [45, 62], [45, 63], [45, 64], [45, 66], [45, 68], [45, 70], [45, 76], [45, 78], [45, 80], [45, 81], [45, 85], [45, 96], [45, 98], [45, 99], [46, 47], [46, 49], [46, 51], [46, 53], [46, 54], [46, 59], [46, 61], [46, 64], [46, 65], [46, 67], [46, 68], [46, 69], [46, 70], [46, 72], [46, 73], [46, 74], [46, 76], [46, 78], [46, 80], [46, 81], [46, 82], [46, 83], [46, 84], [46, 86], [46, 87], [46, 90], [46, 91], [46, 93], [46, 95], [46, 97], [46, 98], [47, 49], [47, 52], [47, 56], [47, 57], [47, 58], [47, 59], [47, 63], [47, 64], [47, 67], [47, 68], [47, 71], [47, 74], [47, 75], [47, 77], [47, 80], [47, 83], [47, 87], [47, 89], [47, 90], [47, 91], [47, 92], [47, 93], [48, 51], [48, 53], [48, 56], [48, 59], [48, 61], [48, 63], [48, 67], [48, 68], [48, 69], [48, 72], [48, 73], [48, 78], [48, 84], [48, 85], [48, 87], [48, 88], [48, 90], [48, 92], [48, 94], [48, 95], [48, 98], [49, 50], [49, 51], [49, 52], [49, 54], [49, 56], [49, 58], [49, 59], [49, 60], [49, 66], [49, 69], [49, 72], [49, 74], [49, 75], [49, 77], [49, 79], [49, 81], [49, 85], [49, 86], [49, 87], [49, 88], [49, 89], [49, 90], [49, 91], [49, 93], [49, 95], [49, 96], [49, 98], [50, 51], [50, 53], [50, 63], [50, 65], [50, 68], [50, 73], [50, 74], [50, 78], [50, 80], [50, 81], [50, 82], [50, 83], [50, 89], [50, 95], [50, 97], [50, 99], [51, 52], [51, 53], [51, 56], [51, 59], [51, 60], [51, 61], [51, 63], [51, 64], [51, 65], [51, 66], [51, 68], [51, 69], [51, 71], [51, 72], [51, 74], [51, 76], [51, 77], [51, 79], [51, 80], [51, 81], [51, 84], [51, 85], [51, 86], [51, 87], [51, 88], [51, 89], [51, 90], [51, 91], [51, 92], [51, 94], [51, 95], [51, 96], [51, 97], [51, 98], [51, 99], [52, 53], [52, 56], [52, 57], [52, 60], [52, 61], [52, 65], [52, 66], [52, 67], [52, 68], [52, 72], [52, 76], [52, 78], [52, 79], [52, 81], [52, 82], [52, 83], [52, 85], [52, 86], [52, 87], [52, 90], [52, 91], [52, 95], [52, 96], [52, 99], [53, 54], [53, 56], [53, 57], [53, 60], [53, 61], [53, 63], [53, 64], [53, 65], [53, 66], [53, 67], [53, 69], [53, 70], [53, 71], [53, 72], [53, 74], [53, 75], [53, 76], [53, 80], [53, 82], [53, 83], [53, 86], [53, 87], [53, 88], [53, 91], [53, 92], [53, 95], [53, 99], [54, 58], [54, 59], [54, 60], [54, 62], [54, 66], [54, 67], [54, 68], [54, 70], [54, 71], [54, 72], [54, 73], [54, 75], [54, 78], [54, 79], [54, 80], [54, 81], [54, 83], [54, 85], [54, 86], [54, 87], [54, 92], [54, 94], [54, 96], [54, 97], [54, 98], [55, 56], [55, 57], [55, 58], [55, 59], [55, 60], [55, 61], [55, 62], [55, 63], [55, 65], [55, 66], [55, 68], [55, 69], [55, 71], [55, 72], [55, 74], [55, 75], [55, 79], [55, 80], [55, 82], [55, 85], [55, 89], [55, 90], [55, 93], [55, 94], [56, 58], [56, 59], [56, 61], [56, 62], [56, 63], [56, 64], [56, 66], [56, 68], [56, 74], [56, 78], [56, 82], [56, 84], [56, 87], [56, 88], [56, 89], [56, 90], [56, 91], [56, 92], [56, 94], [56, 95], [57, 60], [57, 62], [57, 64], [57, 65], [57, 66], [57, 67], [57, 69], [57, 73], [57, 75], [57, 76], [57, 77], [57, 78], [57, 79], [57, 83], [57, 84], [57, 85], [57, 86], [57, 87], [57, 89], [57, 90], [57, 91], [57, 93], [57, 97], [57, 99], [58, 59], [58, 65], [58, 67], [58, 68], [58, 69], [58, 70], [58, 71], [58, 73], [58, 74], [58, 77], [58, 78], [58, 79], [58, 82], [58, 88], [58, 90], [58, 91], [58, 92], [58, 93], [58, 98], [58, 99], [59, 60], [59, 62], [59, 64], [59, 68], [59, 71], [59, 72], [59, 74], [59, 76], [59, 78], [59, 84], [59, 85], [59, 91], [59, 92], [59, 93], [59, 95], [59, 97], [60, 62], [60, 63], [60, 65], [60, 67], [60, 68], [60, 69], [60, 72], [60, 74], [60, 75], [60, 76], [60, 77], [60, 78], [60, 79], [60, 80], [60, 81], [60, 83], [60, 84], [60, 85], [60, 86], [60, 87], [60, 88], [60, 89], [60, 90], [60, 91], [60, 92], [60, 93], [60, 94], [60, 95], [60, 96], [60, 97], [61, 64], [61, 66], [61, 67], [61, 68], [61, 69], [61, 70], [61, 71], [61, 73], [61, 74], [61, 75], [61, 76], [61, 78], [61, 80], [61, 83], [61, 85], [61, 86], [61, 87], [61, 88], [61, 97], [61, 99], [62, 64], [62, 68], [62, 69], [62, 70], [62, 71], [62, 72], [62, 74], [62, 76], [62, 77], [62, 78], [62, 79], [62, 81], [62, 82], [62, 83], [62, 84], [62, 86], [62, 87], [62, 89], [62, 91], [62, 92], [62, 94], [62, 95], [62, 99], [63, 67], [63, 70], [63, 71], [63, 73], [63, 74], [63, 75], [63, 76], [63, 78], [63, 80], [63, 81], [63, 82], [63, 83], [63, 85], [63, 86], [63, 88], [63, 90], [63, 92], [63, 93], [63, 94], [63, 99], [64, 66], [64, 67], [64, 68], [64, 70], [64, 71], [64, 73], [64, 78], [64, 87], [64, 88], [64, 91], [64, 92], [64, 93], [64, 98], [65, 67], [65, 68], [65, 69], [65, 72], [65, 74], [65, 75], [65, 76], [65, 77], [65, 80], [65, 81], [65, 82], [65, 84], [65, 85], [65, 87], [65, 90], [65, 91], [65, 92], [65, 94], [65, 95], [65, 96], [65, 97], [66, 67], [66, 70], [66, 75], [66, 76], [66, 77], [66, 80], [66, 91], [66, 92], [66, 93], [66, 96], [66, 97], [66, 99], [67, 68], [67, 70], [67, 73], [67, 74], [67, 78], [67, 79], [67, 80], [67, 81], [67, 84], [67, 88], [67, 91], [67, 93], [67, 94], [67, 95], [67, 96], [67, 97], [68, 69], [68, 71], [68, 74], [68, 76], [68, 79], [68, 80], [68, 81], [68, 82], [68, 84], [68, 85], [68, 88], [68, 89], [68, 90], [68, 91], [68, 92], [68, 93], [68, 94], [68, 96], [69, 72], [69, 74], [69, 76], [69, 79], [69, 80], [69, 81], [69, 84], [69, 85], [69, 86], [69, 88], [69, 90], [69, 91], [69, 92], [69, 93], [69, 94], [69, 96], [69, 97], [69, 99], [70, 72], [70, 74], [70, 76], [70, 77], [70, 87], [70, 88], [70, 89], [70, 90], [70, 97], [70, 98], [71, 75], [71, 76], [71, 81], [71, 84], [71, 85], [71, 86], [71, 88], [71, 89], [71, 90], [71, 93], [71, 95], [71, 96], [71, 98], [72, 74], [72, 76], [72, 77], [72, 85], [72, 86], [72, 87], [72, 88], [72, 89], [72, 90], [72, 91], [72, 93], [72, 97], [72, 99], [73, 75], [73, 76], [73, 78], [73, 79], [73, 80], [73, 82], [73, 84], [73, 86], [73, 89], [73, 90], [73, 96], [73, 97], [73, 98], [74, 75], [74, 76], [74, 79], [74, 80], [74, 81], [74, 82], [74, 84], [74, 85], [74, 88], [74, 89], [74, 90], [74, 91], [74, 92], [74, 93], [74, 94], [74, 96], [74, 97], [75, 78], [75, 79], [75, 82], [75, 83], [75, 84], [75, 86], [75, 87], [75, 89], [75, 92], [75, 93], [75, 94], [75, 96], [75, 97], [75, 98], [75, 99], [76, 78], [76, 79], [76, 80], [76, 81], [76, 82], [76, 83], [76, 84], [76, 85], [76, 86], [76, 87], [76, 88], [76, 89], [76, 90], [76, 91], [76, 92], [76, 93], [76, 95], [76, 96], [76, 97], [76, 98], [76, 99], [77, 80], [77, 84], [77, 85], [77, 89], [77, 92], [77, 95], [77, 96], [77, 97], [77, 98], [78, 79], [78, 80], [78, 81], [78, 82], [78, 87], [78, 91], [78, 93], [78, 94], [78, 95], [78, 96], [78, 99], [79, 82], [79, 83], [79, 84], [79, 86], [79, 87], [79, 88], [79, 89], [79, 91], [79, 94], [79, 96], [79, 98], [79, 99], [80, 81], [80, 83], [80, 84], [80, 85], [80, 86], [80, 89], [80, 90], [80, 91], [80, 92], [80, 93], [80, 95], [80, 96], [80, 97], [81, 82], [81, 83], [81, 84], [81, 85], [81, 86], [81, 87], [81, 88], [81, 89], [81, 90], [81, 91], [81, 92], [81, 94], [81, 95], [81, 98], [81, 99], [82, 83], [82, 84], [82, 89], [82, 92], [82, 93], [82, 94], [82, 98], [82, 99], [83, 84], [83, 85], [83, 87], [83, 88], [83, 91], [83, 92], [83, 93], [83, 94], [83, 96], [83, 97], [83, 99], [84, 85], [84, 87], [84, 89], [84, 90], [84, 91], [84, 92], [84, 97], [84, 98], [84, 99], [85, 88], [85, 89], [85, 90], [85, 91], [85, 92], [85, 96], [85, 98], [85, 99], [86, 89], [86, 94], [86, 95], [87, 88], [87, 90], [87, 93], [87, 99], [88, 89], [88, 91], [88, 96], [89, 96], [89, 97], [90, 91], [90, 92], [90, 96], [90, 97], [90, 99], [91, 92], [91, 93], [91, 94], [91, 95], [91, 96], [91, 97], [92, 93], [92, 95], [92, 96], [93, 94], [93, 96], [93, 99], [94, 95], [94, 97], [94, 99], [95, 96], [95, 98], [95, 99], [96, 97], [97, 99], [98, 99]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s3/tests/run.py b/tasks/construct-nppc-clique-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l6-s3/tests/test.sh b/tasks/construct-nppc-clique-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l6-s4/environment/Dockerfile b/tasks/construct-nppc-clique-l6-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-clique-l6-s4/environment/instance.json b/tasks/construct-nppc-clique-l6-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9847518742ab49cd0c26f8a4b7ddd67e10cf01c8 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s4/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 1], [0, 4], [0, 5], [0, 6], [0, 7], [0, 9], [0, 10], [0, 11], [0, 13], [0, 15], [0, 19], [0, 21], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [0, 38], [0, 40], [0, 41], [0, 42], [0, 44], [0, 45], [0, 46], [0, 47], [0, 51], [0, 54], [0, 55], [0, 57], [0, 58], [0, 61], [0, 63], [0, 64], [0, 65], [0, 66], [0, 68], [0, 71], [0, 72], [0, 73], [0, 75], [0, 76], [0, 77], [0, 78], [0, 79], [0, 80], [0, 81], [0, 84], [0, 85], [0, 87], [0, 88], [0, 89], [0, 91], [0, 92], [0, 93], [0, 95], [0, 97], [0, 98], [1, 3], [1, 4], [1, 13], [1, 14], [1, 18], [1, 26], [1, 27], [1, 29], [1, 32], [1, 34], [1, 35], [1, 37], [1, 38], [1, 42], [1, 45], [1, 48], [1, 50], [1, 52], [1, 54], [1, 56], [1, 58], [1, 59], [1, 67], [1, 68], [1, 69], [1, 70], [1, 73], [1, 78], [1, 81], [1, 84], [1, 87], [1, 88], [1, 89], [1, 90], [1, 91], [1, 94], [1, 97], [1, 98], [2, 4], [2, 5], [2, 8], [2, 10], [2, 12], [2, 15], [2, 21], [2, 22], [2, 23], [2, 24], [2, 26], [2, 27], [2, 28], [2, 32], [2, 36], [2, 38], [2, 42], [2, 43], [2, 44], [2, 45], [2, 46], [2, 47], [2, 49], [2, 50], [2, 53], [2, 55], [2, 56], [2, 58], [2, 61], [2, 67], [2, 69], [2, 71], [2, 73], [2, 74], [2, 76], [2, 77], [2, 78], [2, 79], [2, 81], [2, 82], [2, 83], [2, 86], [2, 88], [2, 89], [2, 94], [2, 99], [3, 4], [3, 5], [3, 6], [3, 8], [3, 9], [3, 10], [3, 11], [3, 14], [3, 15], [3, 17], [3, 30], [3, 31], [3, 32], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [3, 40], [3, 42], [3, 54], [3, 55], [3, 57], [3, 59], [3, 61], [3, 62], [3, 63], [3, 65], [3, 68], [3, 73], [3, 75], [3, 76], [3, 77], [3, 78], [3, 80], [3, 83], [3, 85], [3, 87], [3, 90], [3, 93], [3, 94], [3, 95], [3, 98], [3, 99], [4, 5], [4, 6], [4, 7], [4, 9], [4, 11], [4, 14], [4, 15], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 24], [4, 25], [4, 27], [4, 28], [4, 30], [4, 31], [4, 33], [4, 34], [4, 37], [4, 38], [4, 39], [4, 41], [4, 43], [4, 45], [4, 46], [4, 48], [4, 49], [4, 51], [4, 56], [4, 58], [4, 61], [4, 64], [4, 65], [4, 66], [4, 73], [4, 74], [4, 75], [4, 77], [4, 78], [4, 79], [4, 82], [4, 83], [4, 85], [4, 87], [4, 90], [4, 93], [4, 94], [4, 96], [4, 97], [4, 98], [4, 99], [5, 6], [5, 7], [5, 8], [5, 10], [5, 11], [5, 13], [5, 14], [5, 15], [5, 17], [5, 19], [5, 20], [5, 21], [5, 26], [5, 28], [5, 30], [5, 31], [5, 32], [5, 34], [5, 37], [5, 38], [5, 39], [5, 41], [5, 42], [5, 46], [5, 47], [5, 48], [5, 50], [5, 51], [5, 52], [5, 55], [5, 56], [5, 60], [5, 61], [5, 62], [5, 63], [5, 65], [5, 70], [5, 72], [5, 74], [5, 75], [5, 77], [5, 78], [5, 80], [5, 82], [5, 83], [5, 85], [5, 88], [5, 89], [5, 90], [5, 91], [5, 92], [5, 95], [5, 96], [5, 97], [5, 98], [5, 99], [6, 7], [6, 10], [6, 11], [6, 12], [6, 15], [6, 18], [6, 19], [6, 21], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 28], [6, 29], [6, 30], [6, 31], [6, 33], [6, 34], [6, 36], [6, 37], [6, 38], [6, 40], [6, 41], [6, 42], [6, 43], [6, 46], [6, 48], [6, 49], [6, 52], [6, 53], [6, 56], [6, 57], [6, 60], [6, 62], [6, 64], [6, 65], [6, 66], [6, 70], [6, 71], [6, 73], [6, 74], [6, 77], [6, 78], [6, 79], [6, 82], [6, 84], [6, 85], [6, 86], [6, 87], [6, 91], [6, 92], [6, 93], [6, 95], [6, 96], [6, 97], [6, 98], [7, 9], [7, 10], [7, 11], [7, 12], [7, 15], [7, 17], [7, 19], [7, 21], [7, 22], [7, 23], [7, 25], [7, 28], [7, 30], [7, 31], [7, 36], [7, 38], [7, 41], [7, 45], [7, 46], [7, 50], [7, 53], [7, 56], [7, 57], [7, 58], [7, 59], [7, 61], [7, 64], [7, 65], [7, 66], [7, 68], [7, 69], [7, 71], [7, 72], [7, 74], [7, 77], [7, 78], [7, 80], [7, 82], [7, 83], [7, 85], [7, 86], [7, 95], [7, 96], [7, 98], [8, 10], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 19], [8, 20], [8, 24], [8, 25], [8, 27], [8, 28], [8, 30], [8, 32], [8, 34], [8, 39], [8, 44], [8, 45], [8, 47], [8, 52], [8, 53], [8, 54], [8, 57], [8, 58], [8, 61], [8, 64], [8, 65], [8, 67], [8, 70], [8, 73], [8, 76], [8, 82], [8, 85], [8, 88], [8, 89], [8, 91], [8, 95], [8, 98], [8, 99], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 20], [9, 21], [9, 23], [9, 27], [9, 35], [9, 36], [9, 37], [9, 42], [9, 43], [9, 46], [9, 47], [9, 48], [9, 49], [9, 51], [9, 52], [9, 53], [9, 56], [9, 59], [9, 60], [9, 61], [9, 62], [9, 63], [9, 64], [9, 67], [9, 68], [9, 69], [9, 71], [9, 73], [9, 75], [9, 76], [9, 79], [9, 83], [9, 84], [9, 85], [9, 90], [9, 92], [9, 94], [9, 96], [9, 97], [9, 99], [10, 11], [10, 12], [10, 14], [10, 15], [10, 16], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 25], [10, 27], [10, 29], [10, 30], [10, 34], [10, 35], [10, 38], [10, 40], [10, 42], [10, 43], [10, 46], [10, 47], [10, 48], [10, 50], [10, 53], [10, 54], [10, 55], [10, 56], [10, 57], [10, 58], [10, 59], [10, 64], [10, 65], [10, 67], [10, 69], [10, 72], [10, 73], [10, 74], [10, 75], [10, 77], [10, 78], [10, 80], [10, 81], [10, 85], [10, 86], [10, 87], [10, 88], [10, 89], [10, 90], [10, 93], [10, 94], [10, 96], [10, 98], [11, 12], [11, 15], [11, 16], [11, 18], [11, 19], [11, 21], [11, 25], [11, 28], [11, 29], [11, 30], [11, 31], [11, 34], [11, 36], [11, 37], [11, 38], [11, 39], [11, 40], [11, 41], [11, 42], [11, 43], [11, 46], [11, 48], [11, 49], [11, 53], [11, 54], [11, 55], [11, 58], [11, 59], [11, 62], [11, 64], [11, 65], [11, 67], [11, 71], [11, 72], [11, 74], [11, 75], [11, 77], [11, 78], [11, 79], [11, 80], [11, 84], [11, 85], [11, 86], [11, 87], [11, 90], [11, 92], [11, 94], [11, 96], [11, 97], [11, 98], [12, 13], [12, 16], [12, 17], [12, 18], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 26], [12, 27], [12, 28], [12, 29], [12, 30], [12, 32], [12, 33], [12, 35], [12, 42], [12, 44], [12, 45], [12, 46], [12, 47], [12, 48], [12, 49], [12, 56], [12, 57], [12, 60], [12, 62], [12, 66], [12, 68], [12, 70], [12, 73], [12, 75], [12, 76], [12, 82], [12, 83], [12, 87], [12, 88], [12, 89], [12, 90], [12, 92], [12, 95], [12, 97], [13, 18], [13, 20], [13, 22], [13, 23], [13, 24], [13, 26], [13, 27], [13, 28], [13, 30], [13, 31], [13, 35], [13, 36], [13, 38], [13, 39], [13, 40], [13, 41], [13, 42], [13, 47], [13, 51], [13, 53], [13, 55], [13, 56], [13, 58], [13, 60], [13, 63], [13, 65], [13, 66], [13, 67], [13, 68], [13, 70], [13, 73], [13, 74], [13, 77], [13, 78], [13, 80], [13, 81], [13, 82], [13, 83], [13, 85], [13, 87], [13, 90], [13, 91], [13, 93], [13, 94], [13, 95], [13, 96], [13, 99], [14, 18], [14, 21], [14, 23], [14, 24], [14, 28], [14, 30], [14, 32], [14, 33], [14, 34], [14, 35], [14, 36], [14, 38], [14, 42], [14, 43], [14, 45], [14, 48], [14, 49], [14, 50], [14, 51], [14, 52], [14, 53], [14, 59], [14, 61], [14, 63], [14, 67], [14, 69], [14, 70], [14, 74], [14, 75], [14, 76], [14, 77], [14, 78], [14, 80], [14, 81], [14, 85], [14, 88], [14, 91], [14, 93], [14, 95], [15, 16], [15, 17], [15, 18], [15, 19], [15, 21], [15, 22], [15, 23], [15, 27], [15, 28], [15, 30], [15, 31], [15, 32], [15, 34], [15, 35], [15, 36], [15, 38], [15, 39], [15, 40], [15, 41], [15, 42], [15, 44], [15, 46], [15, 47], [15, 48], [15, 50], [15, 51], [15, 52], [15, 53], [15, 54], [15, 55], [15, 57], [15, 60], [15, 63], [15, 64], [15, 65], [15, 66], [15, 67], [15, 68], [15, 70], [15, 71], [15, 72], [15, 73], [15, 74], [15, 75], [15, 76], [15, 77], [15, 78], [15, 79], [15, 81], [15, 82], [15, 84], [15, 85], [15, 90], [15, 91], [15, 94], [15, 95], [15, 96], [15, 98], [16, 17], [16, 20], [16, 26], [16, 28], [16, 29], [16, 31], [16, 34], [16, 36], [16, 37], [16, 38], [16, 39], [16, 40], [16, 42], [16, 43], [16, 45], [16, 48], [16, 49], [16, 50], [16, 53], [16, 54], [16, 56], [16, 57], [16, 59], [16, 60], [16, 61], [16, 62], [16, 63], [16, 65], [16, 67], [16, 68], [16, 71], [16, 72], [16, 73], [16, 74], [16, 76], [16, 82], [16, 83], [16, 87], [16, 88], [16, 90], [16, 93], [16, 94], [16, 95], [16, 96], [16, 97], [16, 98], [16, 99], [17, 20], [17, 24], [17, 27], [17, 28], [17, 33], [17, 34], [17, 35], [17, 39], [17, 41], [17, 42], [17, 43], [17, 44], [17, 45], [17, 47], [17, 48], [17, 52], [17, 53], [17, 54], [17, 57], [17, 58], [17, 59], [17, 64], [17, 65], [17, 66], [17, 68], [17, 69], [17, 71], [17, 75], [17, 76], [17, 79], [17, 81], [17, 82], [17, 83], [17, 84], [17, 85], [17, 86], [17, 90], [17, 91], [17, 93], [17, 94], [17, 95], [17, 99], [18, 19], [18, 21], [18, 23], [18, 24], [18, 25], [18, 26], [18, 30], [18, 38], [18, 40], [18, 41], [18, 42], [18, 46], [18, 49], [18, 53], [18, 54], [18, 57], [18, 60], [18, 61], [18, 62], [18, 63], [18, 66], [18, 67], [18, 68], [18, 70], [18, 72], [18, 73], [18, 74], [18, 75], [18, 76], [18, 77], [18, 82], [18, 84], [18, 85], [18, 87], [18, 88], [18, 90], [18, 92], [18, 93], [18, 97], [19, 21], [19, 22], [19, 23], [19, 25], [19, 28], [19, 30], [19, 31], [19, 37], [19, 38], [19, 41], [19, 46], [19, 47], [19, 50], [19, 52], [19, 54], [19, 55], [19, 56], [19, 58], [19, 60], [19, 61], [19, 63], [19, 65], [19, 66], [19, 67], [19, 69], [19, 71], [19, 74], [19, 77], [19, 78], [19, 79], [19, 80], [19, 83], [19, 84], [19, 85], [19, 90], [19, 92], [19, 93], [19, 95], [19, 97], [19, 98], [20, 24], [20, 25], [20, 26], [20, 28], [20, 29], [20, 31], [20, 34], [20, 45], [20, 46], [20, 47], [20, 49], [20, 50], [20, 51], [20, 53], [20, 54], [20, 55], [20, 56], [20, 57], [20, 61], [20, 62], [20, 67], [20, 68], [20, 70], [20, 71], [20, 72], [20, 73], [20, 74], [20, 78], [20, 81], [20, 88], [20, 90], [20, 93], [20, 95], [20, 98], [20, 99], [21, 22], [21, 23], [21, 24], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 33], [21, 36], [21, 37], [21, 38], [21, 40], [21, 41], [21, 42], [21, 44], [21, 46], [21, 47], [21, 49], [21, 50], [21, 52], [21, 56], [21, 58], [21, 59], [21, 60], [21, 61], [21, 62], [21, 65], [21, 69], [21, 71], [21, 72], [21, 74], [21, 75], [21, 77], [21, 78], [21, 82], [21, 83], [21, 84], [21, 85], [21, 87], [21, 88], [21, 89], [21, 90], [21, 91], [21, 93], [21, 95], [21, 96], [21, 97], [21, 98], [21, 99], [22, 25], [22, 29], [22, 33], [22, 34], [22, 35], [22, 40], [22, 41], [22, 42], [22, 45], [22, 46], [22, 49], [22, 51], [22, 61], [22, 64], [22, 66], [22, 67], [22, 68], [22, 69], [22, 72], [22, 73], [22, 75], [22, 77], [22, 79], [22, 80], [22, 83], [22, 89], [22, 91], [22, 92], [22, 94], [22, 98], [22, 99], [23, 25], [23, 31], [23, 32], [23, 34], [23, 35], [23, 39], [23, 41], [23, 42], [23, 43], [23, 44], [23, 45], [23, 46], [23, 47], [23, 49], [23, 52], [23, 55], [23, 61], [23, 64], [23, 65], [23, 67], [23, 69], [23, 76], [23, 78], [23, 80], [23, 81], [23, 82], [23, 83], [23, 84], [23, 89], [23, 91], [23, 93], [23, 97], [23, 98], [24, 26], [24, 27], [24, 28], [24, 29], [24, 31], [24, 34], [24, 36], [24, 37], [24, 41], [24, 42], [24, 43], [24, 44], [24, 46], [24, 47], [24, 48], [24, 51], [24, 54], [24, 58], [24, 61], [24, 62], [24, 63], [24, 65], [24, 68], [24, 71], [24, 72], [24, 76], [24, 78], [24, 82], [24, 84], [24, 86], [24, 87], [24, 89], [24, 91], [24, 92], [24, 93], [24, 95], [24, 96], [24, 97], [24, 99], [25, 26], [25, 28], [25, 29], [25, 30], [25, 33], [25, 36], [25, 38], [25, 40], [25, 41], [25, 42], [25, 43], [25, 44], [25, 47], [25, 48], [25, 54], [25, 55], [25, 56], [25, 57], [25, 58], [25, 59], [25, 67], [25, 68], [25, 70], [25, 73], [25, 74], [25, 75], [25, 76], [25, 77], [25, 78], [25, 79], [25, 82], [25, 86], [25, 88], [25, 91], [25, 92], [25, 93], [25, 94], [25, 96], [25, 97], [25, 99], [26, 28], [26, 38], [26, 40], [26, 41], [26, 43], [26, 46], [26, 47], [26, 48], [26, 50], [26, 54], [26, 55], [26, 56], [26, 57], [26, 59], [26, 61], [26, 69], [26, 70], [26, 71], [26, 75], [26, 76], [26, 77], [26, 78], [26, 79], [26, 80], [26, 81], [26, 82], [26, 83], [26, 84], [26, 85], [26, 86], [26, 87], [26, 88], [26, 89], [26, 91], [26, 93], [26, 97], [26, 98], [26, 99], [27, 31], [27, 34], [27, 37], [27, 41], [27, 42], [27, 45], [27, 49], [27, 54], [27, 55], [27, 59], [27, 60], [27, 63], [27, 65], [27, 66], [27, 67], [27, 72], [27, 75], [27, 79], [27, 81], [27, 82], [27, 83], [27, 84], [27, 86], [27, 87], [27, 88], [27, 89], [27, 90], [27, 91], [27, 93], [27, 96], [27, 97], [27, 98], [27, 99], [28, 30], [28, 31], [28, 32], [28, 33], [28, 35], [28, 37], [28, 38], [28, 39], [28, 41], [28, 46], [28, 47], [28, 48], [28, 49], [28, 52], [28, 54], [28, 55], [28, 56], [28, 61], [28, 63], [28, 65], [28, 66], [28, 69], [28, 70], [28, 71], [28, 73], [28, 74], [28, 75], [28, 76], [28, 77], [28, 78], [28, 79], [28, 81], [28, 84], [28, 85], [28, 92], [28, 93], [28, 95], [28, 98], [28, 99], [29, 33], [29, 34], [29, 35], [29, 36], [29, 37], [29, 38], [29, 39], [29, 41], [29, 43], [29, 45], [29, 46], [29, 49], [29, 52], [29, 54], [29, 60], [29, 61], [29, 66], [29, 67], [29, 69], [29, 71], [29, 72], [29, 74], [29, 78], [29, 79], [29, 80], [29, 82], [29, 84], [29, 85], [29, 86], [29, 87], [29, 91], [29, 92], [29, 93], [29, 95], [29, 96], [29, 97], [30, 31], [30, 32], [30, 36], [30, 37], [30, 38], [30, 40], [30, 41], [30, 42], [30, 43], [30, 44], [30, 45], [30, 46], [30, 47], [30, 48], [30, 51], [30, 52], [30, 53], [30, 56], [30, 57], [30, 59], [30, 60], [30, 62], [30, 64], [30, 65], [30, 67], [30, 68], [30, 71], [30, 73], [30, 74], [30, 76], [30, 77], [30, 78], [30, 80], [30, 82], [30, 84], [30, 85], [30, 86], [30, 87], [30, 88], [30, 89], [30, 90], [30, 91], [30, 92], [30, 95], [30, 98], [30, 99], [31, 32], [31, 33], [31, 35], [31, 36], [31, 37], [31, 38], [31, 40], [31, 41], [31, 42], [31, 44], [31, 45], [31, 46], [31, 47], [31, 49], [31, 51], [31, 55], [31, 56], [31, 57], [31, 59], [31, 60], [31, 62], [31, 63], [31, 64], [31, 65], [31, 66], [31, 68], [31, 74], [31, 76], [31, 77], [31, 78], [31, 80], [31, 83], [31, 84], [31, 85], [31, 86], [31, 87], [31, 88], [31, 90], [31, 92], [31, 94], [31, 95], [31, 96], [31, 97], [31, 98], [32, 33], [32, 35], [32, 38], [32, 39], [32, 40], [32, 42], [32, 44], [32, 47], [32, 48], [32, 49], [32, 50], [32, 54], [32, 55], [32, 56], [32, 59], [32, 60], [32, 61], [32, 63], [32, 64], [32, 67], [32, 68], [32, 69], [32, 70], [32, 74], [32, 75], [32, 78], [32, 80], [32, 83], [32, 85], [32, 86], [32, 87], [32, 88], [32, 89], [32, 90], [32, 91], [32, 93], [32, 99], [33, 37], [33, 38], [33, 42], [33, 47], [33, 48], [33, 49], [33, 50], [33, 51], [33, 53], [33, 54], [33, 55], [33, 56], [33, 57], [33, 60], [33, 61], [33, 65], [33, 67], [33, 68], [33, 69], [33, 72], [33, 73], [33, 74], [33, 75], [33, 77], [33, 78], [33, 79], [33, 80], [33, 82], [33, 84], [33, 87], [33, 90], [33, 91], [33, 92], [33, 93], [33, 95], [33, 96], [33, 99], [34, 35], [34, 37], [34, 39], [34, 40], [34, 41], [34, 45], [34, 47], [34, 50], [34, 51], [34, 53], [34, 55], [34, 57], [34, 61], [34, 64], [34, 65], [34, 66], [34, 68], [34, 72], [34, 73], [34, 74], [34, 76], [34, 78], [34, 80], [34, 85], [34, 86], [34, 87], [34, 88], [34, 89], [34, 92], [34, 93], [34, 94], [34, 95], [34, 96], [34, 98], [34, 99], [35, 36], [35, 37], [35, 42], [35, 43], [35, 44], [35, 45], [35, 46], [35, 47], [35, 48], [35, 54], [35, 55], [35, 56], [35, 58], [35, 59], [35, 61], [35, 62], [35, 63], [35, 64], [35, 65], [35, 66], [35, 67], [35, 68], [35, 70], [35, 71], [35, 72], [35, 73], [35, 75], [35, 76], [35, 79], [35, 82], [35, 83], [35, 84], [35, 87], [35, 88], [35, 89], [35, 90], [35, 93], [35, 94], [35, 95], [35, 97], [35, 99], [36, 37], [36, 38], [36, 41], [36, 42], [36, 44], [36, 45], [36, 49], [36, 52], [36, 53], [36, 54], [36, 57], [36, 62], [36, 64], [36, 65], [36, 67], [36, 68], [36, 69], [36, 70], [36, 71], [36, 72], [36, 73], [36, 76], [36, 81], [36, 82], [36, 86], [36, 87], [36, 89], [36, 90], [36, 92], [36, 93], [36, 95], [36, 96], [37, 40], [37, 43], [37, 50], [37, 51], [37, 52], [37, 54], [37, 55], [37, 56], [37, 58], [37, 61], [37, 62], [37, 63], [37, 64], [37, 66], [37, 67], [37, 68], [37, 70], [37, 72], [37, 74], [37, 75], [37, 76], [37, 82], [37, 84], [37, 86], [37, 89], [37, 90], [37, 92], [37, 93], [37, 94], [37, 96], [37, 98], [37, 99], [38, 39], [38, 41], [38, 42], [38, 43], [38, 45], [38, 46], [38, 47], [38, 50], [38, 51], [38, 53], [38, 54], [38, 60], [38, 61], [38, 63], [38, 64], [38, 65], [38, 66], [38, 68], [38, 69], [38, 72], [38, 74], [38, 77], [38, 78], [38, 79], [38, 82], [38, 84], [38, 85], [38, 86], [38, 90], [38, 93], [38, 95], [38, 97], [38, 98], [38, 99], [39, 40], [39, 46], [39, 47], [39, 49], [39, 50], [39, 51], [39, 54], [39, 58], [39, 64], [39, 65], [39, 66], [39, 67], [39, 69], [39, 73], [39, 74], [39, 75], [39, 76], [39, 77], [39, 79], [39, 80], [39, 81], [39, 82], [39, 84], [39, 88], [39, 92], [39, 93], [39, 94], [39, 96], [39, 97], [39, 99], [40, 43], [40, 44], [40, 45], [40, 52], [40, 55], [40, 58], [40, 61], [40, 62], [40, 64], [40, 65], [40, 66], [40, 67], [40, 71], [40, 73], [40, 77], [40, 78], [40, 79], [40, 81], [40, 83], [40, 86], [40, 87], [40, 88], [40, 93], [40, 94], [40, 95], [40, 97], [40, 98], [41, 42], [41, 43], [41, 46], [41, 49], [41, 51], [41, 53], [41, 54], [41, 59], [41, 62], [41, 64], [41, 65], [41, 67], [41, 69], [41, 72], [41, 77], [41, 78], [41, 80], [41, 82], [41, 83], [41, 84], [41, 85], [41, 86], [41, 87], [41, 88], [41, 89], [41, 91], [41, 95], [41, 97], [41, 98], [41, 99], [42, 44], [42, 45], [42, 46], [42, 47], [42, 49], [42, 50], [42, 53], [42, 56], [42, 58], [42, 60], [42, 61], [42, 64], [42, 70], [42, 71], [42, 72], [42, 75], [42, 77], [42, 78], [42, 79], [42, 80], [42, 81], [42, 82], [42, 84], [42, 87], [42, 89], [42, 92], [42, 96], [43, 45], [43, 48], [43, 49], [43, 50], [43, 51], [43, 53], [43, 56], [43, 57], [43, 58], [43, 63], [43, 64], [43, 66], [43, 68], [43, 70], [43, 72], [43, 75], [43, 77], [43, 79], [43, 80], [43, 81], [43, 83], [43, 90], [43, 91], [43, 93], [43, 95], [43, 96], [43, 97], [43, 98], [44, 45], [44, 46], [44, 47], [44, 48], [44, 49], [44, 50], [44, 53], [44, 54], [44, 55], [44, 56], [44, 60], [44, 64], [44, 66], [44, 67], [44, 69], [44, 70], [44, 71], [44, 73], [44, 74], [44, 76], [44, 78], [44, 80], [44, 81], [44, 84], [44, 86], [44, 87], [44, 88], [44, 89], [44, 90], [44, 92], [44, 94], [44, 99], [45, 51], [45, 58], [45, 59], [45, 63], [45, 64], [45, 66], [45, 67], [45, 68], [45, 71], [45, 72], [45, 73], [45, 74], [45, 79], [45, 81], [45, 84], [45, 86], [45, 88], [45, 89], [45, 94], [45, 96], [45, 97], [45, 98], [45, 99], [46, 49], [46, 50], [46, 51], [46, 53], [46, 56], [46, 59], [46, 60], [46, 65], [46, 66], [46, 67], [46, 69], [46, 70], [46, 71], [46, 77], [46, 78], [46, 79], [46, 80], [46, 81], [46, 84], [46, 85], [46, 89], [46, 91], [46, 93], [46, 94], [46, 95], [46, 97], [46, 98], [47, 48], [47, 49], [47, 50], [47, 52], [47, 54], [47, 55], [47, 59], [47, 60], [47, 62], [47, 64], [47, 65], [47, 67], [47, 68], [47, 73], [47, 74], [47, 75], [47, 78], [47, 80], [47, 83], [47, 84], [47, 87], [47, 88], [47, 90], [47, 92], [47, 95], [47, 97], [48, 54], [48, 55], [48, 58], [48, 59], [48, 60], [48, 70], [48, 71], [48, 72], [48, 73], [48, 74], [48, 77], [48, 80], [48, 81], [48, 82], [48, 84], [48, 85], [48, 87], [48, 89], [48, 91], [48, 93], [48, 94], [48, 96], [48, 97], [49, 51], [49, 52], [49, 54], [49, 56], [49, 57], [49, 58], [49, 59], [49, 60], [49, 61], [49, 62], [49, 68], [49, 69], [49, 72], [49, 74], [49, 75], [49, 77], [49, 79], [49, 81], [49, 82], [49, 85], [49, 90], [49, 91], [49, 92], [49, 94], [49, 97], [49, 98], [50, 51], [50, 52], [50, 53], [50, 55], [50, 56], [50, 62], [50, 66], [50, 69], [50, 72], [50, 75], [50, 76], [50, 79], [50, 82], [50, 85], [50, 86], [50, 89], [50, 95], [50, 97], [51, 60], [51, 61], [51, 62], [51, 63], [51, 65], [51, 66], [51, 68], [51, 69], [51, 70], [51, 71], [51, 73], [51, 74], [51, 75], [51, 78], [51, 79], [51, 81], [51, 84], [51, 86], [51, 88], [51, 90], [51, 91], [51, 97], [52, 54], [52, 57], [52, 60], [52, 62], [52, 65], [52, 66], [52, 67], [52, 69], [52, 72], [52, 73], [52, 75], [52, 76], [52, 83], [52, 84], [52, 85], [52, 86], [52, 88], [52, 89], [52, 92], [52, 98], [52, 99], [53, 55], [53, 58], [53, 60], [53, 63], [53, 67], [53, 69], [53, 70], [53, 74], [53, 75], [53, 76], [53, 83], [53, 84], [53, 87], [53, 89], [53, 90], [53, 91], [53, 93], [53, 96], [53, 99], [54, 56], [54, 57], [54, 59], [54, 60], [54, 61], [54, 63], [54, 64], [54, 65], [54, 66], [54, 68], [54, 69], [54, 70], [54, 72], [54, 74], [54, 76], [54, 77], [54, 78], [54, 79], [54, 81], [54, 82], [54, 83], [54, 84], [54, 88], [54, 89], [54, 90], [54, 92], [54, 96], [54, 97], [55, 56], [55, 60], [55, 61], [55, 63], [55, 68], [55, 70], [55, 71], [55, 72], [55, 80], [55, 81], [55, 82], [55, 86], [55, 88], [55, 89], [55, 90], [55, 91], [55, 92], [55, 94], [55, 95], [55, 96], [55, 97], [55, 98], [55, 99], [56, 57], [56, 58], [56, 59], [56, 61], [56, 62], [56, 63], [56, 64], [56, 66], [56, 69], [56, 71], [56, 73], [56, 74], [56, 75], [56, 76], [56, 77], [56, 78], [56, 83], [56, 84], [56, 86], [56, 88], [56, 90], [56, 96], [56, 97], [56, 98], [56, 99], [57, 60], [57, 61], [57, 62], [57, 64], [57, 66], [57, 69], [57, 70], [57, 74], [57, 75], [57, 76], [57, 77], [57, 78], [57, 81], [57, 82], [57, 85], [57, 88], [57, 89], [57, 91], [57, 92], [57, 93], [57, 95], [57, 97], [57, 99], [58, 60], [58, 63], [58, 64], [58, 66], [58, 69], [58, 72], [58, 75], [58, 77], [58, 78], [58, 79], [58, 80], [58, 81], [58, 88], [58, 90], [58, 92], [58, 96], [58, 97], [59, 61], [59, 64], [59, 65], [59, 67], [59, 69], [59, 70], [59, 71], [59, 73], [59, 74], [59, 75], [59, 77], [59, 79], [59, 80], [59, 82], [59, 83], [59, 88], [59, 92], [59, 94], [59, 95], [59, 96], [60, 62], [60, 63], [60, 64], [60, 65], [60, 67], [60, 68], [60, 70], [60, 74], [60, 75], [60, 77], [60, 78], [60, 79], [60, 80], [60, 81], [60, 82], [60, 84], [60, 85], [60, 86], [60, 89], [60, 90], [60, 92], [60, 93], [60, 95], [60, 98], [60, 99], [61, 62], [61, 64], [61, 65], [61, 68], [61, 69], [61, 70], [61, 71], [61, 82], [61, 87], [61, 89], [61, 91], [61, 92], [61, 93], [61, 95], [61, 96], [61, 97], [61, 98], [62, 65], [62, 66], [62, 67], [62, 68], [62, 70], [62, 71], [62, 80], [62, 81], [62, 82], [62, 85], [62, 86], [62, 87], [62, 95], [62, 97], [62, 99], [63, 64], [63, 65], [63, 69], [63, 71], [63, 74], [63, 75], [63, 78], [63, 80], [63, 81], [63, 84], [63, 87], [63, 88], [63, 89], [63, 92], [63, 94], [63, 96], [63, 98], [64, 65], [64, 69], [64, 71], [64, 74], [64, 77], [64, 79], [64, 84], [64, 85], [64, 89], [64, 92], [64, 97], [64, 99], [65, 68], [65, 70], [65, 71], [65, 73], [65, 74], [65, 75], [65, 76], [65, 77], [65, 78], [65, 79], [65, 80], [65, 81], [65, 83], [65, 84], [65, 85], [65, 89], [65, 90], [65, 91], [65, 92], [65, 96], [65, 97], [65, 98], [66, 69], [66, 71], [66, 73], [66, 74], [66, 75], [66, 77], [66, 81], [66, 84], [66, 85], [66, 86], [66, 88], [66, 90], [66, 92], [66, 94], [66, 95], [66, 99], [67, 70], [67, 72], [67, 74], [67, 75], [67, 77], [67, 80], [67, 83], [67, 86], [67, 87], [67, 88], [67, 90], [67, 91], [67, 92], [67, 93], [67, 95], [67, 96], [67, 99], [68, 69], [68, 71], [68, 72], [68, 73], [68, 77], [68, 80], [68, 84], [68, 86], [68, 88], [68, 89], [68, 99], [69, 71], [69, 75], [69, 76], [69, 79], [69, 81], [69, 84], [69, 85], [69, 86], [69, 89], [69, 94], [69, 99], [70, 71], [70, 72], [70, 73], [70, 74], [70, 75], [70, 83], [70, 84], [70, 86], [70, 88], [70, 89], [70, 94], [70, 95], [70, 97], [70, 98], [70, 99], [71, 76], [71, 77], [71, 78], [71, 80], [71, 82], [71, 83], [71, 84], [71, 85], [71, 86], [71, 87], [71, 88], [71, 91], [71, 93], [71, 95], [71, 96], [71, 97], [72, 74], [72, 75], [72, 76], [72, 79], [72, 80], [72, 81], [72, 82], [72, 84], [72, 85], [72, 88], [72, 89], [72, 90], [72, 93], [72, 96], [72, 98], [73, 74], [73, 75], [73, 77], [73, 79], [73, 80], [73, 85], [73, 86], [73, 88], [73, 89], [73, 93], [73, 94], [73, 96], [73, 97], [73, 98], [73, 99], [74, 75], [74, 77], [74, 79], [74, 86], [74, 89], [74, 91], [74, 94], [74, 98], [75, 76], [75, 77], [75, 78], [75, 81], [75, 83], [75, 84], [75, 85], [75, 86], [75, 87], [75, 89], [75, 90], [75, 91], [75, 92], [75, 94], [75, 95], [75, 98], [76, 80], [76, 83], [76, 84], [76, 85], [76, 89], [76, 90], [76, 98], [77, 78], [77, 79], [77, 81], [77, 82], [77, 84], [77, 85], [77, 86], [77, 88], [77, 89], [77, 94], [77, 97], [77, 98], [78, 81], [78, 82], [78, 83], [78, 85], [78, 90], [78, 91], [78, 92], [78, 93], [78, 94], [78, 95], [78, 97], [78, 98], [79, 85], [79, 87], [79, 90], [79, 91], [79, 92], [79, 93], [79, 94], [79, 95], [79, 96], [79, 97], [80, 82], [80, 84], [80, 86], [80, 87], [80, 89], [80, 91], [80, 92], [80, 93], [80, 94], [80, 95], [80, 96], [80, 97], [80, 98], [80, 99], [81, 83], [81, 84], [81, 85], [81, 87], [81, 88], [81, 91], [81, 92], [81, 97], [81, 98], [82, 83], [82, 89], [82, 92], [82, 94], [82, 97], [83, 84], [83, 85], [83, 86], [83, 92], [83, 93], [83, 95], [83, 96], [83, 99], [84, 87], [84, 88], [84, 89], [84, 93], [84, 94], [84, 95], [84, 99], [85, 97], [85, 98], [85, 99], [86, 88], [86, 90], [86, 95], [86, 96], [86, 97], [86, 98], [87, 88], [87, 89], [87, 90], [87, 91], [87, 93], [87, 95], [87, 96], [87, 99], [88, 89], [88, 90], [88, 94], [88, 95], [88, 96], [89, 90], [89, 93], [89, 94], [89, 95], [89, 96], [89, 97], [89, 98], [90, 93], [90, 96], [90, 99], [91, 92], [91, 93], [91, 96], [91, 97], [91, 98], [92, 99], [93, 95], [93, 97], [94, 95], [94, 97], [95, 97], [95, 98], [96, 98], [97, 98], [97, 99], [98, 99]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s4/solution/solve.sh b/tasks/construct-nppc-clique-l6-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c31cd92447c858fc425efdad24d14e923d17f05a --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [0, 4, 5, 6, 7, 11, 15, 19, 21, 28, 30, 31, 38, 41, 46, 65, 77, 78, 85, 98]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l6-s4/tests/check.py b/tasks/construct-nppc-clique-l6-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s4/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l6-s4/tests/instance.json b/tasks/construct-nppc-clique-l6-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9847518742ab49cd0c26f8a4b7ddd67e10cf01c8 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s4/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 1], [0, 4], [0, 5], [0, 6], [0, 7], [0, 9], [0, 10], [0, 11], [0, 13], [0, 15], [0, 19], [0, 21], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [0, 38], [0, 40], [0, 41], [0, 42], [0, 44], [0, 45], [0, 46], [0, 47], [0, 51], [0, 54], [0, 55], [0, 57], [0, 58], [0, 61], [0, 63], [0, 64], [0, 65], [0, 66], [0, 68], [0, 71], [0, 72], [0, 73], [0, 75], [0, 76], [0, 77], [0, 78], [0, 79], [0, 80], [0, 81], [0, 84], [0, 85], [0, 87], [0, 88], [0, 89], [0, 91], [0, 92], [0, 93], [0, 95], [0, 97], [0, 98], [1, 3], [1, 4], [1, 13], [1, 14], [1, 18], [1, 26], [1, 27], [1, 29], [1, 32], [1, 34], [1, 35], [1, 37], [1, 38], [1, 42], [1, 45], [1, 48], [1, 50], [1, 52], [1, 54], [1, 56], [1, 58], [1, 59], [1, 67], [1, 68], [1, 69], [1, 70], [1, 73], [1, 78], [1, 81], [1, 84], [1, 87], [1, 88], [1, 89], [1, 90], [1, 91], [1, 94], [1, 97], [1, 98], [2, 4], [2, 5], [2, 8], [2, 10], [2, 12], [2, 15], [2, 21], [2, 22], [2, 23], [2, 24], [2, 26], [2, 27], [2, 28], [2, 32], [2, 36], [2, 38], [2, 42], [2, 43], [2, 44], [2, 45], [2, 46], [2, 47], [2, 49], [2, 50], [2, 53], [2, 55], [2, 56], [2, 58], [2, 61], [2, 67], [2, 69], [2, 71], [2, 73], [2, 74], [2, 76], [2, 77], [2, 78], [2, 79], [2, 81], [2, 82], [2, 83], [2, 86], [2, 88], [2, 89], [2, 94], [2, 99], [3, 4], [3, 5], [3, 6], [3, 8], [3, 9], [3, 10], [3, 11], [3, 14], [3, 15], [3, 17], [3, 30], [3, 31], [3, 32], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [3, 40], [3, 42], [3, 54], [3, 55], [3, 57], [3, 59], [3, 61], [3, 62], [3, 63], [3, 65], [3, 68], [3, 73], [3, 75], [3, 76], [3, 77], [3, 78], [3, 80], [3, 83], [3, 85], [3, 87], [3, 90], [3, 93], [3, 94], [3, 95], [3, 98], [3, 99], [4, 5], [4, 6], [4, 7], [4, 9], [4, 11], [4, 14], [4, 15], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 24], [4, 25], [4, 27], [4, 28], [4, 30], [4, 31], [4, 33], [4, 34], [4, 37], [4, 38], [4, 39], [4, 41], [4, 43], [4, 45], [4, 46], [4, 48], [4, 49], [4, 51], [4, 56], [4, 58], [4, 61], [4, 64], [4, 65], [4, 66], [4, 73], [4, 74], [4, 75], [4, 77], [4, 78], [4, 79], [4, 82], [4, 83], [4, 85], [4, 87], [4, 90], [4, 93], [4, 94], [4, 96], [4, 97], [4, 98], [4, 99], [5, 6], [5, 7], [5, 8], [5, 10], [5, 11], [5, 13], [5, 14], [5, 15], [5, 17], [5, 19], [5, 20], [5, 21], [5, 26], [5, 28], [5, 30], [5, 31], [5, 32], [5, 34], [5, 37], [5, 38], [5, 39], [5, 41], [5, 42], [5, 46], [5, 47], [5, 48], [5, 50], [5, 51], [5, 52], [5, 55], [5, 56], [5, 60], [5, 61], [5, 62], [5, 63], [5, 65], [5, 70], [5, 72], [5, 74], [5, 75], [5, 77], [5, 78], [5, 80], [5, 82], [5, 83], [5, 85], [5, 88], [5, 89], [5, 90], [5, 91], [5, 92], [5, 95], [5, 96], [5, 97], [5, 98], [5, 99], [6, 7], [6, 10], [6, 11], [6, 12], [6, 15], [6, 18], [6, 19], [6, 21], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 28], [6, 29], [6, 30], [6, 31], [6, 33], [6, 34], [6, 36], [6, 37], [6, 38], [6, 40], [6, 41], [6, 42], [6, 43], [6, 46], [6, 48], [6, 49], [6, 52], [6, 53], [6, 56], [6, 57], [6, 60], [6, 62], [6, 64], [6, 65], [6, 66], [6, 70], [6, 71], [6, 73], [6, 74], [6, 77], [6, 78], [6, 79], [6, 82], [6, 84], [6, 85], [6, 86], [6, 87], [6, 91], [6, 92], [6, 93], [6, 95], [6, 96], [6, 97], [6, 98], [7, 9], [7, 10], [7, 11], [7, 12], [7, 15], [7, 17], [7, 19], [7, 21], [7, 22], [7, 23], [7, 25], [7, 28], [7, 30], [7, 31], [7, 36], [7, 38], [7, 41], [7, 45], [7, 46], [7, 50], [7, 53], [7, 56], [7, 57], [7, 58], [7, 59], [7, 61], [7, 64], [7, 65], [7, 66], [7, 68], [7, 69], [7, 71], [7, 72], [7, 74], [7, 77], [7, 78], [7, 80], [7, 82], [7, 83], [7, 85], [7, 86], [7, 95], [7, 96], [7, 98], [8, 10], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 19], [8, 20], [8, 24], [8, 25], [8, 27], [8, 28], [8, 30], [8, 32], [8, 34], [8, 39], [8, 44], [8, 45], [8, 47], [8, 52], [8, 53], [8, 54], [8, 57], [8, 58], [8, 61], [8, 64], [8, 65], [8, 67], [8, 70], [8, 73], [8, 76], [8, 82], [8, 85], [8, 88], [8, 89], [8, 91], [8, 95], [8, 98], [8, 99], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 20], [9, 21], [9, 23], [9, 27], [9, 35], [9, 36], [9, 37], [9, 42], [9, 43], [9, 46], [9, 47], [9, 48], [9, 49], [9, 51], [9, 52], [9, 53], [9, 56], [9, 59], [9, 60], [9, 61], [9, 62], [9, 63], [9, 64], [9, 67], [9, 68], [9, 69], [9, 71], [9, 73], [9, 75], [9, 76], [9, 79], [9, 83], [9, 84], [9, 85], [9, 90], [9, 92], [9, 94], [9, 96], [9, 97], [9, 99], [10, 11], [10, 12], [10, 14], [10, 15], [10, 16], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 25], [10, 27], [10, 29], [10, 30], [10, 34], [10, 35], [10, 38], [10, 40], [10, 42], [10, 43], [10, 46], [10, 47], [10, 48], [10, 50], [10, 53], [10, 54], [10, 55], [10, 56], [10, 57], [10, 58], [10, 59], [10, 64], [10, 65], [10, 67], [10, 69], [10, 72], [10, 73], [10, 74], [10, 75], [10, 77], [10, 78], [10, 80], [10, 81], [10, 85], [10, 86], [10, 87], [10, 88], [10, 89], [10, 90], [10, 93], [10, 94], [10, 96], [10, 98], [11, 12], [11, 15], [11, 16], [11, 18], [11, 19], [11, 21], [11, 25], [11, 28], [11, 29], [11, 30], [11, 31], [11, 34], [11, 36], [11, 37], [11, 38], [11, 39], [11, 40], [11, 41], [11, 42], [11, 43], [11, 46], [11, 48], [11, 49], [11, 53], [11, 54], [11, 55], [11, 58], [11, 59], [11, 62], [11, 64], [11, 65], [11, 67], [11, 71], [11, 72], [11, 74], [11, 75], [11, 77], [11, 78], [11, 79], [11, 80], [11, 84], [11, 85], [11, 86], [11, 87], [11, 90], [11, 92], [11, 94], [11, 96], [11, 97], [11, 98], [12, 13], [12, 16], [12, 17], [12, 18], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 26], [12, 27], [12, 28], [12, 29], [12, 30], [12, 32], [12, 33], [12, 35], [12, 42], [12, 44], [12, 45], [12, 46], [12, 47], [12, 48], [12, 49], [12, 56], [12, 57], [12, 60], [12, 62], [12, 66], [12, 68], [12, 70], [12, 73], [12, 75], [12, 76], [12, 82], [12, 83], [12, 87], [12, 88], [12, 89], [12, 90], [12, 92], [12, 95], [12, 97], [13, 18], [13, 20], [13, 22], [13, 23], [13, 24], [13, 26], [13, 27], [13, 28], [13, 30], [13, 31], [13, 35], [13, 36], [13, 38], [13, 39], [13, 40], [13, 41], [13, 42], [13, 47], [13, 51], [13, 53], [13, 55], [13, 56], [13, 58], [13, 60], [13, 63], [13, 65], [13, 66], [13, 67], [13, 68], [13, 70], [13, 73], [13, 74], [13, 77], [13, 78], [13, 80], [13, 81], [13, 82], [13, 83], [13, 85], [13, 87], [13, 90], [13, 91], [13, 93], [13, 94], [13, 95], [13, 96], [13, 99], [14, 18], [14, 21], [14, 23], [14, 24], [14, 28], [14, 30], [14, 32], [14, 33], [14, 34], [14, 35], [14, 36], [14, 38], [14, 42], [14, 43], [14, 45], [14, 48], [14, 49], [14, 50], [14, 51], [14, 52], [14, 53], [14, 59], [14, 61], [14, 63], [14, 67], [14, 69], [14, 70], [14, 74], [14, 75], [14, 76], [14, 77], [14, 78], [14, 80], [14, 81], [14, 85], [14, 88], [14, 91], [14, 93], [14, 95], [15, 16], [15, 17], [15, 18], [15, 19], [15, 21], [15, 22], [15, 23], [15, 27], [15, 28], [15, 30], [15, 31], [15, 32], [15, 34], [15, 35], [15, 36], [15, 38], [15, 39], [15, 40], [15, 41], [15, 42], [15, 44], [15, 46], [15, 47], [15, 48], [15, 50], [15, 51], [15, 52], [15, 53], [15, 54], [15, 55], [15, 57], [15, 60], [15, 63], [15, 64], [15, 65], [15, 66], [15, 67], [15, 68], [15, 70], [15, 71], [15, 72], [15, 73], [15, 74], [15, 75], [15, 76], [15, 77], [15, 78], [15, 79], [15, 81], [15, 82], [15, 84], [15, 85], [15, 90], [15, 91], [15, 94], [15, 95], [15, 96], [15, 98], [16, 17], [16, 20], [16, 26], [16, 28], [16, 29], [16, 31], [16, 34], [16, 36], [16, 37], [16, 38], [16, 39], [16, 40], [16, 42], [16, 43], [16, 45], [16, 48], [16, 49], [16, 50], [16, 53], [16, 54], [16, 56], [16, 57], [16, 59], [16, 60], [16, 61], [16, 62], [16, 63], [16, 65], [16, 67], [16, 68], [16, 71], [16, 72], [16, 73], [16, 74], [16, 76], [16, 82], [16, 83], [16, 87], [16, 88], [16, 90], [16, 93], [16, 94], [16, 95], [16, 96], [16, 97], [16, 98], [16, 99], [17, 20], [17, 24], [17, 27], [17, 28], [17, 33], [17, 34], [17, 35], [17, 39], [17, 41], [17, 42], [17, 43], [17, 44], [17, 45], [17, 47], [17, 48], [17, 52], [17, 53], [17, 54], [17, 57], [17, 58], [17, 59], [17, 64], [17, 65], [17, 66], [17, 68], [17, 69], [17, 71], [17, 75], [17, 76], [17, 79], [17, 81], [17, 82], [17, 83], [17, 84], [17, 85], [17, 86], [17, 90], [17, 91], [17, 93], [17, 94], [17, 95], [17, 99], [18, 19], [18, 21], [18, 23], [18, 24], [18, 25], [18, 26], [18, 30], [18, 38], [18, 40], [18, 41], [18, 42], [18, 46], [18, 49], [18, 53], [18, 54], [18, 57], [18, 60], [18, 61], [18, 62], [18, 63], [18, 66], [18, 67], [18, 68], [18, 70], [18, 72], [18, 73], [18, 74], [18, 75], [18, 76], [18, 77], [18, 82], [18, 84], [18, 85], [18, 87], [18, 88], [18, 90], [18, 92], [18, 93], [18, 97], [19, 21], [19, 22], [19, 23], [19, 25], [19, 28], [19, 30], [19, 31], [19, 37], [19, 38], [19, 41], [19, 46], [19, 47], [19, 50], [19, 52], [19, 54], [19, 55], [19, 56], [19, 58], [19, 60], [19, 61], [19, 63], [19, 65], [19, 66], [19, 67], [19, 69], [19, 71], [19, 74], [19, 77], [19, 78], [19, 79], [19, 80], [19, 83], [19, 84], [19, 85], [19, 90], [19, 92], [19, 93], [19, 95], [19, 97], [19, 98], [20, 24], [20, 25], [20, 26], [20, 28], [20, 29], [20, 31], [20, 34], [20, 45], [20, 46], [20, 47], [20, 49], [20, 50], [20, 51], [20, 53], [20, 54], [20, 55], [20, 56], [20, 57], [20, 61], [20, 62], [20, 67], [20, 68], [20, 70], [20, 71], [20, 72], [20, 73], [20, 74], [20, 78], [20, 81], [20, 88], [20, 90], [20, 93], [20, 95], [20, 98], [20, 99], [21, 22], [21, 23], [21, 24], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 33], [21, 36], [21, 37], [21, 38], [21, 40], [21, 41], [21, 42], [21, 44], [21, 46], [21, 47], [21, 49], [21, 50], [21, 52], [21, 56], [21, 58], [21, 59], [21, 60], [21, 61], [21, 62], [21, 65], [21, 69], [21, 71], [21, 72], [21, 74], [21, 75], [21, 77], [21, 78], [21, 82], [21, 83], [21, 84], [21, 85], [21, 87], [21, 88], [21, 89], [21, 90], [21, 91], [21, 93], [21, 95], [21, 96], [21, 97], [21, 98], [21, 99], [22, 25], [22, 29], [22, 33], [22, 34], [22, 35], [22, 40], [22, 41], [22, 42], [22, 45], [22, 46], [22, 49], [22, 51], [22, 61], [22, 64], [22, 66], [22, 67], [22, 68], [22, 69], [22, 72], [22, 73], [22, 75], [22, 77], [22, 79], [22, 80], [22, 83], [22, 89], [22, 91], [22, 92], [22, 94], [22, 98], [22, 99], [23, 25], [23, 31], [23, 32], [23, 34], [23, 35], [23, 39], [23, 41], [23, 42], [23, 43], [23, 44], [23, 45], [23, 46], [23, 47], [23, 49], [23, 52], [23, 55], [23, 61], [23, 64], [23, 65], [23, 67], [23, 69], [23, 76], [23, 78], [23, 80], [23, 81], [23, 82], [23, 83], [23, 84], [23, 89], [23, 91], [23, 93], [23, 97], [23, 98], [24, 26], [24, 27], [24, 28], [24, 29], [24, 31], [24, 34], [24, 36], [24, 37], [24, 41], [24, 42], [24, 43], [24, 44], [24, 46], [24, 47], [24, 48], [24, 51], [24, 54], [24, 58], [24, 61], [24, 62], [24, 63], [24, 65], [24, 68], [24, 71], [24, 72], [24, 76], [24, 78], [24, 82], [24, 84], [24, 86], [24, 87], [24, 89], [24, 91], [24, 92], [24, 93], [24, 95], [24, 96], [24, 97], [24, 99], [25, 26], [25, 28], [25, 29], [25, 30], [25, 33], [25, 36], [25, 38], [25, 40], [25, 41], [25, 42], [25, 43], [25, 44], [25, 47], [25, 48], [25, 54], [25, 55], [25, 56], [25, 57], [25, 58], [25, 59], [25, 67], [25, 68], [25, 70], [25, 73], [25, 74], [25, 75], [25, 76], [25, 77], [25, 78], [25, 79], [25, 82], [25, 86], [25, 88], [25, 91], [25, 92], [25, 93], [25, 94], [25, 96], [25, 97], [25, 99], [26, 28], [26, 38], [26, 40], [26, 41], [26, 43], [26, 46], [26, 47], [26, 48], [26, 50], [26, 54], [26, 55], [26, 56], [26, 57], [26, 59], [26, 61], [26, 69], [26, 70], [26, 71], [26, 75], [26, 76], [26, 77], [26, 78], [26, 79], [26, 80], [26, 81], [26, 82], [26, 83], [26, 84], [26, 85], [26, 86], [26, 87], [26, 88], [26, 89], [26, 91], [26, 93], [26, 97], [26, 98], [26, 99], [27, 31], [27, 34], [27, 37], [27, 41], [27, 42], [27, 45], [27, 49], [27, 54], [27, 55], [27, 59], [27, 60], [27, 63], [27, 65], [27, 66], [27, 67], [27, 72], [27, 75], [27, 79], [27, 81], [27, 82], [27, 83], [27, 84], [27, 86], [27, 87], [27, 88], [27, 89], [27, 90], [27, 91], [27, 93], [27, 96], [27, 97], [27, 98], [27, 99], [28, 30], [28, 31], [28, 32], [28, 33], [28, 35], [28, 37], [28, 38], [28, 39], [28, 41], [28, 46], [28, 47], [28, 48], [28, 49], [28, 52], [28, 54], [28, 55], [28, 56], [28, 61], [28, 63], [28, 65], [28, 66], [28, 69], [28, 70], [28, 71], [28, 73], [28, 74], [28, 75], [28, 76], [28, 77], [28, 78], [28, 79], [28, 81], [28, 84], [28, 85], [28, 92], [28, 93], [28, 95], [28, 98], [28, 99], [29, 33], [29, 34], [29, 35], [29, 36], [29, 37], [29, 38], [29, 39], [29, 41], [29, 43], [29, 45], [29, 46], [29, 49], [29, 52], [29, 54], [29, 60], [29, 61], [29, 66], [29, 67], [29, 69], [29, 71], [29, 72], [29, 74], [29, 78], [29, 79], [29, 80], [29, 82], [29, 84], [29, 85], [29, 86], [29, 87], [29, 91], [29, 92], [29, 93], [29, 95], [29, 96], [29, 97], [30, 31], [30, 32], [30, 36], [30, 37], [30, 38], [30, 40], [30, 41], [30, 42], [30, 43], [30, 44], [30, 45], [30, 46], [30, 47], [30, 48], [30, 51], [30, 52], [30, 53], [30, 56], [30, 57], [30, 59], [30, 60], [30, 62], [30, 64], [30, 65], [30, 67], [30, 68], [30, 71], [30, 73], [30, 74], [30, 76], [30, 77], [30, 78], [30, 80], [30, 82], [30, 84], [30, 85], [30, 86], [30, 87], [30, 88], [30, 89], [30, 90], [30, 91], [30, 92], [30, 95], [30, 98], [30, 99], [31, 32], [31, 33], [31, 35], [31, 36], [31, 37], [31, 38], [31, 40], [31, 41], [31, 42], [31, 44], [31, 45], [31, 46], [31, 47], [31, 49], [31, 51], [31, 55], [31, 56], [31, 57], [31, 59], [31, 60], [31, 62], [31, 63], [31, 64], [31, 65], [31, 66], [31, 68], [31, 74], [31, 76], [31, 77], [31, 78], [31, 80], [31, 83], [31, 84], [31, 85], [31, 86], [31, 87], [31, 88], [31, 90], [31, 92], [31, 94], [31, 95], [31, 96], [31, 97], [31, 98], [32, 33], [32, 35], [32, 38], [32, 39], [32, 40], [32, 42], [32, 44], [32, 47], [32, 48], [32, 49], [32, 50], [32, 54], [32, 55], [32, 56], [32, 59], [32, 60], [32, 61], [32, 63], [32, 64], [32, 67], [32, 68], [32, 69], [32, 70], [32, 74], [32, 75], [32, 78], [32, 80], [32, 83], [32, 85], [32, 86], [32, 87], [32, 88], [32, 89], [32, 90], [32, 91], [32, 93], [32, 99], [33, 37], [33, 38], [33, 42], [33, 47], [33, 48], [33, 49], [33, 50], [33, 51], [33, 53], [33, 54], [33, 55], [33, 56], [33, 57], [33, 60], [33, 61], [33, 65], [33, 67], [33, 68], [33, 69], [33, 72], [33, 73], [33, 74], [33, 75], [33, 77], [33, 78], [33, 79], [33, 80], [33, 82], [33, 84], [33, 87], [33, 90], [33, 91], [33, 92], [33, 93], [33, 95], [33, 96], [33, 99], [34, 35], [34, 37], [34, 39], [34, 40], [34, 41], [34, 45], [34, 47], [34, 50], [34, 51], [34, 53], [34, 55], [34, 57], [34, 61], [34, 64], [34, 65], [34, 66], [34, 68], [34, 72], [34, 73], [34, 74], [34, 76], [34, 78], [34, 80], [34, 85], [34, 86], [34, 87], [34, 88], [34, 89], [34, 92], [34, 93], [34, 94], [34, 95], [34, 96], [34, 98], [34, 99], [35, 36], [35, 37], [35, 42], [35, 43], [35, 44], [35, 45], [35, 46], [35, 47], [35, 48], [35, 54], [35, 55], [35, 56], [35, 58], [35, 59], [35, 61], [35, 62], [35, 63], [35, 64], [35, 65], [35, 66], [35, 67], [35, 68], [35, 70], [35, 71], [35, 72], [35, 73], [35, 75], [35, 76], [35, 79], [35, 82], [35, 83], [35, 84], [35, 87], [35, 88], [35, 89], [35, 90], [35, 93], [35, 94], [35, 95], [35, 97], [35, 99], [36, 37], [36, 38], [36, 41], [36, 42], [36, 44], [36, 45], [36, 49], [36, 52], [36, 53], [36, 54], [36, 57], [36, 62], [36, 64], [36, 65], [36, 67], [36, 68], [36, 69], [36, 70], [36, 71], [36, 72], [36, 73], [36, 76], [36, 81], [36, 82], [36, 86], [36, 87], [36, 89], [36, 90], [36, 92], [36, 93], [36, 95], [36, 96], [37, 40], [37, 43], [37, 50], [37, 51], [37, 52], [37, 54], [37, 55], [37, 56], [37, 58], [37, 61], [37, 62], [37, 63], [37, 64], [37, 66], [37, 67], [37, 68], [37, 70], [37, 72], [37, 74], [37, 75], [37, 76], [37, 82], [37, 84], [37, 86], [37, 89], [37, 90], [37, 92], [37, 93], [37, 94], [37, 96], [37, 98], [37, 99], [38, 39], [38, 41], [38, 42], [38, 43], [38, 45], [38, 46], [38, 47], [38, 50], [38, 51], [38, 53], [38, 54], [38, 60], [38, 61], [38, 63], [38, 64], [38, 65], [38, 66], [38, 68], [38, 69], [38, 72], [38, 74], [38, 77], [38, 78], [38, 79], [38, 82], [38, 84], [38, 85], [38, 86], [38, 90], [38, 93], [38, 95], [38, 97], [38, 98], [38, 99], [39, 40], [39, 46], [39, 47], [39, 49], [39, 50], [39, 51], [39, 54], [39, 58], [39, 64], [39, 65], [39, 66], [39, 67], [39, 69], [39, 73], [39, 74], [39, 75], [39, 76], [39, 77], [39, 79], [39, 80], [39, 81], [39, 82], [39, 84], [39, 88], [39, 92], [39, 93], [39, 94], [39, 96], [39, 97], [39, 99], [40, 43], [40, 44], [40, 45], [40, 52], [40, 55], [40, 58], [40, 61], [40, 62], [40, 64], [40, 65], [40, 66], [40, 67], [40, 71], [40, 73], [40, 77], [40, 78], [40, 79], [40, 81], [40, 83], [40, 86], [40, 87], [40, 88], [40, 93], [40, 94], [40, 95], [40, 97], [40, 98], [41, 42], [41, 43], [41, 46], [41, 49], [41, 51], [41, 53], [41, 54], [41, 59], [41, 62], [41, 64], [41, 65], [41, 67], [41, 69], [41, 72], [41, 77], [41, 78], [41, 80], [41, 82], [41, 83], [41, 84], [41, 85], [41, 86], [41, 87], [41, 88], [41, 89], [41, 91], [41, 95], [41, 97], [41, 98], [41, 99], [42, 44], [42, 45], [42, 46], [42, 47], [42, 49], [42, 50], [42, 53], [42, 56], [42, 58], [42, 60], [42, 61], [42, 64], [42, 70], [42, 71], [42, 72], [42, 75], [42, 77], [42, 78], [42, 79], [42, 80], [42, 81], [42, 82], [42, 84], [42, 87], [42, 89], [42, 92], [42, 96], [43, 45], [43, 48], [43, 49], [43, 50], [43, 51], [43, 53], [43, 56], [43, 57], [43, 58], [43, 63], [43, 64], [43, 66], [43, 68], [43, 70], [43, 72], [43, 75], [43, 77], [43, 79], [43, 80], [43, 81], [43, 83], [43, 90], [43, 91], [43, 93], [43, 95], [43, 96], [43, 97], [43, 98], [44, 45], [44, 46], [44, 47], [44, 48], [44, 49], [44, 50], [44, 53], [44, 54], [44, 55], [44, 56], [44, 60], [44, 64], [44, 66], [44, 67], [44, 69], [44, 70], [44, 71], [44, 73], [44, 74], [44, 76], [44, 78], [44, 80], [44, 81], [44, 84], [44, 86], [44, 87], [44, 88], [44, 89], [44, 90], [44, 92], [44, 94], [44, 99], [45, 51], [45, 58], [45, 59], [45, 63], [45, 64], [45, 66], [45, 67], [45, 68], [45, 71], [45, 72], [45, 73], [45, 74], [45, 79], [45, 81], [45, 84], [45, 86], [45, 88], [45, 89], [45, 94], [45, 96], [45, 97], [45, 98], [45, 99], [46, 49], [46, 50], [46, 51], [46, 53], [46, 56], [46, 59], [46, 60], [46, 65], [46, 66], [46, 67], [46, 69], [46, 70], [46, 71], [46, 77], [46, 78], [46, 79], [46, 80], [46, 81], [46, 84], [46, 85], [46, 89], [46, 91], [46, 93], [46, 94], [46, 95], [46, 97], [46, 98], [47, 48], [47, 49], [47, 50], [47, 52], [47, 54], [47, 55], [47, 59], [47, 60], [47, 62], [47, 64], [47, 65], [47, 67], [47, 68], [47, 73], [47, 74], [47, 75], [47, 78], [47, 80], [47, 83], [47, 84], [47, 87], [47, 88], [47, 90], [47, 92], [47, 95], [47, 97], [48, 54], [48, 55], [48, 58], [48, 59], [48, 60], [48, 70], [48, 71], [48, 72], [48, 73], [48, 74], [48, 77], [48, 80], [48, 81], [48, 82], [48, 84], [48, 85], [48, 87], [48, 89], [48, 91], [48, 93], [48, 94], [48, 96], [48, 97], [49, 51], [49, 52], [49, 54], [49, 56], [49, 57], [49, 58], [49, 59], [49, 60], [49, 61], [49, 62], [49, 68], [49, 69], [49, 72], [49, 74], [49, 75], [49, 77], [49, 79], [49, 81], [49, 82], [49, 85], [49, 90], [49, 91], [49, 92], [49, 94], [49, 97], [49, 98], [50, 51], [50, 52], [50, 53], [50, 55], [50, 56], [50, 62], [50, 66], [50, 69], [50, 72], [50, 75], [50, 76], [50, 79], [50, 82], [50, 85], [50, 86], [50, 89], [50, 95], [50, 97], [51, 60], [51, 61], [51, 62], [51, 63], [51, 65], [51, 66], [51, 68], [51, 69], [51, 70], [51, 71], [51, 73], [51, 74], [51, 75], [51, 78], [51, 79], [51, 81], [51, 84], [51, 86], [51, 88], [51, 90], [51, 91], [51, 97], [52, 54], [52, 57], [52, 60], [52, 62], [52, 65], [52, 66], [52, 67], [52, 69], [52, 72], [52, 73], [52, 75], [52, 76], [52, 83], [52, 84], [52, 85], [52, 86], [52, 88], [52, 89], [52, 92], [52, 98], [52, 99], [53, 55], [53, 58], [53, 60], [53, 63], [53, 67], [53, 69], [53, 70], [53, 74], [53, 75], [53, 76], [53, 83], [53, 84], [53, 87], [53, 89], [53, 90], [53, 91], [53, 93], [53, 96], [53, 99], [54, 56], [54, 57], [54, 59], [54, 60], [54, 61], [54, 63], [54, 64], [54, 65], [54, 66], [54, 68], [54, 69], [54, 70], [54, 72], [54, 74], [54, 76], [54, 77], [54, 78], [54, 79], [54, 81], [54, 82], [54, 83], [54, 84], [54, 88], [54, 89], [54, 90], [54, 92], [54, 96], [54, 97], [55, 56], [55, 60], [55, 61], [55, 63], [55, 68], [55, 70], [55, 71], [55, 72], [55, 80], [55, 81], [55, 82], [55, 86], [55, 88], [55, 89], [55, 90], [55, 91], [55, 92], [55, 94], [55, 95], [55, 96], [55, 97], [55, 98], [55, 99], [56, 57], [56, 58], [56, 59], [56, 61], [56, 62], [56, 63], [56, 64], [56, 66], [56, 69], [56, 71], [56, 73], [56, 74], [56, 75], [56, 76], [56, 77], [56, 78], [56, 83], [56, 84], [56, 86], [56, 88], [56, 90], [56, 96], [56, 97], [56, 98], [56, 99], [57, 60], [57, 61], [57, 62], [57, 64], [57, 66], [57, 69], [57, 70], [57, 74], [57, 75], [57, 76], [57, 77], [57, 78], [57, 81], [57, 82], [57, 85], [57, 88], [57, 89], [57, 91], [57, 92], [57, 93], [57, 95], [57, 97], [57, 99], [58, 60], [58, 63], [58, 64], [58, 66], [58, 69], [58, 72], [58, 75], [58, 77], [58, 78], [58, 79], [58, 80], [58, 81], [58, 88], [58, 90], [58, 92], [58, 96], [58, 97], [59, 61], [59, 64], [59, 65], [59, 67], [59, 69], [59, 70], [59, 71], [59, 73], [59, 74], [59, 75], [59, 77], [59, 79], [59, 80], [59, 82], [59, 83], [59, 88], [59, 92], [59, 94], [59, 95], [59, 96], [60, 62], [60, 63], [60, 64], [60, 65], [60, 67], [60, 68], [60, 70], [60, 74], [60, 75], [60, 77], [60, 78], [60, 79], [60, 80], [60, 81], [60, 82], [60, 84], [60, 85], [60, 86], [60, 89], [60, 90], [60, 92], [60, 93], [60, 95], [60, 98], [60, 99], [61, 62], [61, 64], [61, 65], [61, 68], [61, 69], [61, 70], [61, 71], [61, 82], [61, 87], [61, 89], [61, 91], [61, 92], [61, 93], [61, 95], [61, 96], [61, 97], [61, 98], [62, 65], [62, 66], [62, 67], [62, 68], [62, 70], [62, 71], [62, 80], [62, 81], [62, 82], [62, 85], [62, 86], [62, 87], [62, 95], [62, 97], [62, 99], [63, 64], [63, 65], [63, 69], [63, 71], [63, 74], [63, 75], [63, 78], [63, 80], [63, 81], [63, 84], [63, 87], [63, 88], [63, 89], [63, 92], [63, 94], [63, 96], [63, 98], [64, 65], [64, 69], [64, 71], [64, 74], [64, 77], [64, 79], [64, 84], [64, 85], [64, 89], [64, 92], [64, 97], [64, 99], [65, 68], [65, 70], [65, 71], [65, 73], [65, 74], [65, 75], [65, 76], [65, 77], [65, 78], [65, 79], [65, 80], [65, 81], [65, 83], [65, 84], [65, 85], [65, 89], [65, 90], [65, 91], [65, 92], [65, 96], [65, 97], [65, 98], [66, 69], [66, 71], [66, 73], [66, 74], [66, 75], [66, 77], [66, 81], [66, 84], [66, 85], [66, 86], [66, 88], [66, 90], [66, 92], [66, 94], [66, 95], [66, 99], [67, 70], [67, 72], [67, 74], [67, 75], [67, 77], [67, 80], [67, 83], [67, 86], [67, 87], [67, 88], [67, 90], [67, 91], [67, 92], [67, 93], [67, 95], [67, 96], [67, 99], [68, 69], [68, 71], [68, 72], [68, 73], [68, 77], [68, 80], [68, 84], [68, 86], [68, 88], [68, 89], [68, 99], [69, 71], [69, 75], [69, 76], [69, 79], [69, 81], [69, 84], [69, 85], [69, 86], [69, 89], [69, 94], [69, 99], [70, 71], [70, 72], [70, 73], [70, 74], [70, 75], [70, 83], [70, 84], [70, 86], [70, 88], [70, 89], [70, 94], [70, 95], [70, 97], [70, 98], [70, 99], [71, 76], [71, 77], [71, 78], [71, 80], [71, 82], [71, 83], [71, 84], [71, 85], [71, 86], [71, 87], [71, 88], [71, 91], [71, 93], [71, 95], [71, 96], [71, 97], [72, 74], [72, 75], [72, 76], [72, 79], [72, 80], [72, 81], [72, 82], [72, 84], [72, 85], [72, 88], [72, 89], [72, 90], [72, 93], [72, 96], [72, 98], [73, 74], [73, 75], [73, 77], [73, 79], [73, 80], [73, 85], [73, 86], [73, 88], [73, 89], [73, 93], [73, 94], [73, 96], [73, 97], [73, 98], [73, 99], [74, 75], [74, 77], [74, 79], [74, 86], [74, 89], [74, 91], [74, 94], [74, 98], [75, 76], [75, 77], [75, 78], [75, 81], [75, 83], [75, 84], [75, 85], [75, 86], [75, 87], [75, 89], [75, 90], [75, 91], [75, 92], [75, 94], [75, 95], [75, 98], [76, 80], [76, 83], [76, 84], [76, 85], [76, 89], [76, 90], [76, 98], [77, 78], [77, 79], [77, 81], [77, 82], [77, 84], [77, 85], [77, 86], [77, 88], [77, 89], [77, 94], [77, 97], [77, 98], [78, 81], [78, 82], [78, 83], [78, 85], [78, 90], [78, 91], [78, 92], [78, 93], [78, 94], [78, 95], [78, 97], [78, 98], [79, 85], [79, 87], [79, 90], [79, 91], [79, 92], [79, 93], [79, 94], [79, 95], [79, 96], [79, 97], [80, 82], [80, 84], [80, 86], [80, 87], [80, 89], [80, 91], [80, 92], [80, 93], [80, 94], [80, 95], [80, 96], [80, 97], [80, 98], [80, 99], [81, 83], [81, 84], [81, 85], [81, 87], [81, 88], [81, 91], [81, 92], [81, 97], [81, 98], [82, 83], [82, 89], [82, 92], [82, 94], [82, 97], [83, 84], [83, 85], [83, 86], [83, 92], [83, 93], [83, 95], [83, 96], [83, 99], [84, 87], [84, 88], [84, 89], [84, 93], [84, 94], [84, 95], [84, 99], [85, 97], [85, 98], [85, 99], [86, 88], [86, 90], [86, 95], [86, 96], [86, 97], [86, 98], [87, 88], [87, 89], [87, 90], [87, 91], [87, 93], [87, 95], [87, 96], [87, 99], [88, 89], [88, 90], [88, 94], [88, 95], [88, 96], [89, 90], [89, 93], [89, 94], [89, 95], [89, 96], [89, 97], [89, 98], [90, 93], [90, 96], [90, 99], [91, 92], [91, 93], [91, 96], [91, 97], [91, 98], [92, 99], [93, 95], [93, 97], [94, 95], [94, 97], [95, 97], [95, 98], [96, 98], [97, 98], [97, 99], [98, 99]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s4/tests/run.py b/tasks/construct-nppc-clique-l6-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-clique-l6-s4/tests/test.sh b/tasks/construct-nppc-clique-l6-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-dominating-set-l6-s4/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l6-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-dominating-set-l6-s4/environment/instance.json b/tasks/construct-nppc-dominating-set-l6-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c365ac170cf7d5c4e64dc497ba3ba8e01f9fd4c3 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s4/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 300, "k": 20, "edges": [[0, 31], [0, 47], [0, 90], [0, 96], [0, 101], [0, 107], [0, 113], [0, 114], [0, 121], [0, 158], [0, 179], [0, 185], [0, 188], [0, 194], [0, 204], [0, 207], [0, 217], [0, 219], [0, 238], [0, 274], [1, 9], [1, 20], [1, 43], [1, 72], [1, 90], [1, 91], [1, 153], [1, 178], [1, 197], [1, 219], [1, 220], [1, 222], [1, 223], [1, 225], [1, 234], [1, 263], [1, 280], [1, 292], [2, 7], [2, 8], [2, 38], [2, 50], [2, 55], [2, 58], [2, 97], [2, 102], [2, 112], [2, 168], [2, 174], [2, 183], [2, 185], [2, 189], [2, 239], [2, 241], [2, 245], [2, 254], [2, 260], [2, 268], [2, 272], [2, 288], [3, 11], [3, 20], [3, 25], [3, 29], [3, 32], [3, 33], [3, 40], [3, 65], [3, 72], [3, 78], [3, 83], [3, 87], [3, 90], [3, 109], [3, 156], [3, 158], [3, 185], [3, 191], [3, 200], [3, 236], [3, 238], [3, 271], [3, 273], [3, 276], [4, 33], [4, 37], [4, 63], [4, 64], [4, 78], [4, 81], [4, 98], [4, 127], [4, 134], [4, 155], [4, 157], [4, 158], [4, 171], [4, 174], [4, 182], [4, 203], [4, 208], [4, 220], [4, 269], [4, 272], [4, 282], [4, 289], [5, 65], [5, 86], [5, 101], [5, 111], [5, 169], [5, 200], [5, 202], [5, 220], [5, 242], [5, 246], [5, 260], [5, 266], [5, 282], [5, 296], [6, 8], [6, 24], [6, 25], [6, 67], [6, 72], [6, 110], [6, 153], [6, 168], [6, 180], [6, 216], [6, 237], [6, 239], [6, 285], [6, 288], [6, 299], [7, 77], [7, 95], [7, 131], [7, 135], [7, 144], [7, 153], [7, 154], [7, 176], [7, 200], [7, 204], [7, 226], [7, 228], [7, 238], [7, 250], [7, 254], [7, 271], [7, 284], [8, 17], [8, 19], [8, 25], [8, 41], [8, 49], [8, 64], [8, 74], [8, 82], [8, 87], [8, 107], [8, 121], [8, 124], [8, 138], [8, 141], [8, 148], [8, 157], [8, 196], [8, 207], [8, 208], [8, 210], [8, 237], [8, 239], [8, 244], [8, 247], [8, 263], [8, 290], [8, 294], [9, 11], [9, 20], [9, 24], [9, 53], [9, 59], [9, 83], [9, 86], [9, 94], [9, 144], [9, 154], [9, 155], [9, 156], [9, 196], [9, 229], [9, 284], [9, 297], [10, 14], [10, 54], [10, 82], [10, 85], [10, 93], [10, 121], [10, 164], [10, 166], [10, 176], [10, 177], [10, 211], [10, 274], [10, 281], [10, 294], [10, 295], [10, 297], [10, 298], [10, 299], [11, 19], [11, 43], [11, 45], [11, 54], [11, 73], [11, 95], [11, 120], [11, 123], [11, 141], [11, 143], [11, 146], [11, 148], [11, 153], [11, 160], [11, 163], [11, 164], [11, 166], [11, 172], [11, 181], [11, 210], [11, 216], [11, 224], [11, 226], [11, 227], [11, 249], [11, 297], [12, 13], [12, 31], [12, 37], [12, 41], [12, 56], [12, 58], [12, 62], [12, 66], [12, 101], [12, 157], [12, 159], [12, 161], [12, 189], [12, 217], [12, 221], [12, 228], [12, 256], [12, 265], [12, 268], [12, 271], [13, 43], [13, 44], [13, 56], [13, 101], [13, 120], [13, 123], [13, 126], [13, 144], [13, 150], [13, 160], [13, 177], [13, 181], [13, 202], [13, 216], [13, 258], [13, 260], [13, 274], [13, 284], [13, 286], [14, 22], [14, 29], [14, 40], [14, 55], [14, 66], [14, 95], [14, 101], [14, 111], [14, 188], [14, 202], [14, 203], [14, 221], [14, 274], [15, 31], [15, 37], [15, 57], [15, 70], [15, 85], [15, 107], [15, 146], [15, 164], [15, 193], [15, 194], [15, 200], [15, 202], [15, 211], [15, 275], [15, 285], [15, 289], [16, 20], [16, 41], [16, 64], [16, 68], [16, 69], [16, 89], [16, 128], [16, 130], [16, 150], [16, 164], [16, 171], [16, 191], [16, 209], [16, 227], [16, 256], [16, 259], [16, 275], [16, 292], [17, 30], [17, 41], [17, 60], [17, 63], [17, 74], [17, 83], [17, 89], [17, 118], [17, 122], [17, 132], [17, 135], [17, 143], [17, 189], [17, 208], [17, 212], [17, 213], [17, 233], [17, 243], [17, 286], [18, 34], [18, 54], [18, 56], [18, 59], [18, 62], [18, 64], [18, 82], [18, 93], [18, 103], [18, 104], [18, 110], [18, 113], [18, 134], [18, 153], [18, 154], [18, 177], [18, 197], [18, 206], [18, 217], [18, 239], [18, 252], [18, 259], [18, 277], [18, 281], [18, 284], [18, 292], [18, 294], [18, 299], [19, 32], [19, 34], [19, 39], [19, 48], [19, 67], [19, 69], [19, 70], [19, 76], [19, 85], [19, 87], [19, 95], [19, 103], [19, 136], [19, 154], [19, 167], [19, 168], [19, 170], [19, 186], [19, 192], [19, 203], [19, 205], [19, 221], [19, 232], [19, 259], [19, 292], [19, 298], [20, 29], [20, 41], [20, 68], [20, 76], [20, 93], [20, 99], [20, 101], [20, 102], [20, 105], [20, 108], [20, 111], [20, 122], [20, 126], [20, 131], [20, 133], [20, 166], [20, 206], [20, 234], [20, 238], [21, 31], [21, 47], [21, 54], [21, 56], [21, 60], [21, 64], [21, 68], [21, 79], [21, 81], [21, 92], [21, 114], [21, 126], [21, 136], [21, 151], [21, 160], [21, 168], [21, 173], [21, 175], [21, 190], [21, 202], [21, 204], [21, 263], [21, 274], [21, 293], [22, 44], [22, 47], [22, 79], [22, 126], [22, 137], [22, 154], [22, 158], [22, 164], [22, 195], [22, 197], [22, 237], [22, 239], [22, 242], [22, 259], [22, 284], [22, 293], [23, 29], [23, 60], [23, 130], [23, 171], [23, 181], [23, 203], [23, 204], [23, 207], [23, 250], [23, 253], [23, 255], [23, 258], [23, 266], [23, 286], [23, 295], [24, 28], [24, 50], [24, 52], [24, 84], [24, 93], [24, 104], [24, 137], [24, 149], [24, 151], [24, 166], [24, 182], [24, 183], [24, 213], [24, 221], [24, 230], [24, 291], [25, 30], [25, 32], [25, 33], [25, 35], [25, 39], [25, 62], [25, 67], [25, 76], [25, 82], [25, 87], [25, 90], [25, 93], [25, 100], [25, 126], [25, 169], [25, 228], [25, 234], [25, 242], [25, 243], [25, 261], [25, 281], [26, 50], [26, 77], [26, 92], [26, 100], [26, 107], [26, 129], [26, 158], [26, 183], [26, 241], [26, 280], [27, 32], [27, 50], [27, 92], [27, 108], [27, 116], [27, 131], [27, 183], [27, 214], [27, 215], [27, 247], [27, 275], [27, 282], [28, 35], [28, 53], [28, 54], [28, 90], [28, 99], [28, 123], [28, 127], [28, 129], [28, 137], [28, 170], [28, 212], [28, 229], [28, 240], [28, 259], [28, 281], [29, 80], [29, 107], [29, 115], [29, 132], [29, 138], [29, 178], [29, 185], [29, 198], [29, 220], [29, 223], [29, 228], [29, 235], [29, 250], [29, 257], [29, 275], [29, 280], [29, 282], [30, 33], [30, 36], [30, 40], [30, 49], [30, 53], [30, 63], [30, 72], [30, 95], [30, 97], [30, 111], [30, 116], [30, 129], [30, 148], [30, 189], [30, 194], [30, 232], [30, 257], [30, 268], [30, 269], [30, 282], [31, 48], [31, 91], [31, 101], [31, 103], [31, 111], [31, 127], [31, 133], [31, 157], [31, 167], [31, 178], [31, 197], [31, 209], [31, 279], [31, 289], [31, 294], [32, 54], [32, 77], [32, 142], [32, 153], [32, 164], [32, 175], [32, 181], [32, 199], [32, 224], [32, 231], [32, 232], [32, 242], [32, 243], [32, 253], [32, 268], [32, 273], [33, 39], [33, 52], [33, 79], [33, 91], [33, 110], [33, 137], [33, 176], [33, 198], [33, 200], [33, 257], [33, 265], [33, 267], [34, 61], [34, 81], [34, 97], [34, 103], [34, 104], [34, 140], [34, 141], [34, 144], [34, 159], [34, 171], [34, 186], [34, 206], [34, 223], [34, 240], [34, 260], [34, 292], [35, 37], [35, 77], [35, 138], [35, 143], [35, 172], [35, 175], [35, 177], [35, 187], [35, 231], [35, 238], [35, 245], [35, 278], [35, 283], [36, 41], [36, 52], [36, 58], [36, 65], [36, 72], [36, 80], [36, 84], [36, 92], [36, 103], [36, 108], [36, 137], [36, 150], [36, 152], [36, 181], [36, 184], [36, 185], [36, 229], [36, 276], [37, 79], [37, 81], [37, 91], [37, 131], [37, 133], [37, 146], [37, 180], [37, 188], [37, 206], [37, 236], [37, 280], [38, 51], [38, 93], [38, 117], [38, 119], [38, 137], [38, 142], [38, 181], [38, 206], [38, 213], [38, 236], [38, 251], [38, 258], [38, 271], [38, 279], [38, 284], [39, 61], [39, 65], [39, 76], [39, 132], [39, 159], [39, 220], [39, 240], [39, 268], [40, 59], [40, 67], [40, 78], [40, 88], [40, 95], [40, 102], [40, 111], [40, 149], [40, 153], [40, 169], [40, 212], [40, 223], [40, 243], [40, 253], [40, 264], [40, 281], [40, 297], [41, 43], [41, 50], [41, 51], [41, 56], [41, 61], [41, 70], [41, 75], [41, 101], [41, 116], [41, 139], [41, 144], [41, 146], [41, 151], [41, 159], [41, 167], [41, 172], [41, 174], [41, 176], [41, 215], [41, 216], [41, 224], [41, 225], [41, 228], [41, 234], [41, 296], [41, 299], [42, 68], [42, 84], [42, 105], [42, 117], [42, 122], [42, 125], [42, 132], [42, 141], [42, 147], [42, 212], [42, 216], [42, 231], [42, 243], [42, 251], [42, 292], [43, 78], [43, 85], [43, 89], [43, 123], [43, 137], [43, 148], [43, 162], [43, 185], [43, 210], [43, 225], [43, 255], [43, 257], [43, 268], [43, 297], [44, 48], [44, 68], [44, 73], [44, 76], [44, 84], [44, 104], [44, 143], [44, 148], [44, 176], [44, 179], [44, 181], [44, 214], [44, 219], [44, 221], [44, 294], [44, 298], [45, 63], [45, 68], [45, 77], [45, 94], [45, 104], [45, 132], [45, 142], [45, 156], [45, 169], [45, 190], [45, 192], [45, 196], [45, 204], [45, 225], [45, 226], [45, 239], [45, 242], [45, 257], [45, 264], [45, 276], [46, 49], [46, 91], [46, 107], [46, 110], [46, 132], [46, 142], [46, 151], [46, 173], [46, 178], [46, 181], [46, 193], [46, 199], [46, 210], [46, 211], [46, 217], [46, 236], [46, 239], [46, 269], [46, 273], [47, 95], [47, 106], [47, 125], [47, 132], [47, 150], [47, 178], [47, 193], [47, 201], [47, 226], [47, 227], [47, 243], [47, 253], [47, 257], [47, 269], [47, 272], [47, 274], [48, 57], [48, 89], [48, 98], [48, 100], [48, 116], [48, 131], [48, 138], [48, 141], [48, 142], [48, 190], [48, 215], [48, 223], [48, 233], [48, 243], [48, 246], [48, 264], [48, 294], [49, 53], [49, 74], [49, 77], [49, 115], [49, 117], [49, 143], [49, 169], [49, 176], [49, 198], [49, 209], [49, 222], [49, 238], [49, 251], [49, 258], [49, 295], [50, 58], [50, 62], [50, 68], [50, 93], [50, 102], [50, 106], [50, 109], [50, 119], [50, 121], [50, 167], [50, 209], [50, 222], [50, 232], [50, 235], [50, 243], [50, 248], [50, 289], [51, 76], [51, 89], [51, 98], [51, 106], [51, 115], [51, 134], [51, 143], [51, 146], [51, 165], [51, 175], [51, 179], [51, 196], [51, 203], [51, 232], [51, 241], [51, 257], [51, 273], [51, 295], [52, 56], [52, 58], [52, 90], [52, 109], [52, 120], [52, 167], [52, 179], [52, 183], [52, 208], [52, 213], [52, 217], [52, 237], [52, 282], [53, 58], [53, 69], [53, 73], [53, 103], [53, 125], [53, 148], [53, 155], [53, 181], [53, 189], [53, 200], [53, 208], [53, 215], [53, 224], [53, 246], [53, 259], [53, 280], [53, 286], [53, 295], [54, 72], [54, 75], [54, 79], [54, 87], [54, 100], [54, 108], [54, 110], [54, 121], [54, 126], [54, 127], [54, 135], [54, 136], [54, 138], [54, 139], [54, 150], [54, 178], [54, 185], [54, 198], [54, 213], [54, 219], [54, 228], [54, 231], [54, 237], [54, 248], [54, 249], [54, 256], [54, 260], [54, 262], [54, 291], [54, 298], [55, 63], [55, 77], [55, 131], [55, 139], [55, 169], [55, 182], [55, 191], [55, 214], [55, 237], [55, 241], [55, 261], [55, 269], [55, 276], [56, 61], [56, 62], [56, 64], [56, 69], [56, 76], [56, 100], [56, 136], [56, 162], [56, 165], [56, 166], [56, 191], [56, 192], [56, 226], [56, 229], [56, 254], [56, 256], [56, 281], [56, 293], [56, 298], [57, 88], [57, 93], [57, 106], [57, 107], [57, 114], [57, 137], [57, 139], [57, 141], [57, 145], [57, 168], [57, 179], [57, 188], [57, 208], [57, 223], [57, 228], [57, 243], [57, 275], [57, 281], [57, 284], [57, 290], [58, 76], [58, 103], [58, 138], [58, 170], [58, 172], [58, 175], [58, 179], [58, 193], [58, 215], [58, 234], [58, 262], [58, 274], [59, 61], [59, 76], [59, 78], [59, 86], [59, 94], [59, 122], [59, 136], [59, 141], [59, 145], [59, 173], [59, 191], [59, 195], [59, 204], [59, 206], [59, 237], [59, 239], [59, 243], [59, 260], [59, 261], [59, 263], [59, 272], [60, 61], [60, 79], [60, 100], [60, 106], [60, 151], [60, 176], [60, 180], [60, 181], [60, 190], [60, 210], [60, 220], [60, 224], [60, 226], [60, 232], [60, 242], [60, 245], [60, 256], [60, 283], [60, 285], [60, 296], [61, 65], [61, 70], [61, 100], [61, 119], [61, 144], [61, 147], [61, 148], [61, 154], [61, 163], [61, 182], [61, 223], [61, 230], [61, 243], [61, 288], [61, 291], [62, 69], [62, 95], [62, 122], [62, 128], [62, 131], [62, 155], [62, 165], [62, 177], [62, 178], [62, 179], [62, 193], [62, 206], [62, 209], [62, 250], [63, 65], [63, 73], [63, 96], [63, 102], [63, 121], [63, 143], [63, 153], [63, 159], [63, 164], [63, 176], [63, 182], [63, 233], [63, 240], [63, 247], [63, 249], [63, 250], [63, 276], [64, 149], [64, 172], [64, 175], [64, 178], [64, 203], [64, 206], [64, 223], [64, 249], [64, 265], [64, 282], [64, 290], [65, 75], [65, 110], [65, 143], [65, 151], [65, 158], [65, 172], [65, 187], [65, 188], [65, 195], [65, 220], [65, 229], [65, 245], [65, 266], [65, 275], [65, 276], [65, 278], [65, 291], [65, 297], [66, 74], [66, 78], [66, 87], [66, 131], [66, 135], [66, 143], [66, 169], [66, 183], [66, 190], [66, 210], [66, 234], [66, 240], [66, 242], [66, 251], [66, 257], [66, 265], [66, 267], [66, 276], [66, 294], [67, 78], [67, 122], [67, 132], [67, 138], [67, 139], [67, 154], [67, 197], [67, 205], [67, 236], [67, 245], [67, 249], [67, 258], [67, 268], [67, 280], [68, 73], [68, 108], [68, 124], [68, 134], [68, 156], [68, 213], [68, 232], [68, 263], [68, 277], [68, 293], [68, 296], [69, 76], [69, 104], [69, 118], [69, 125], [69, 150], [69, 167], [69, 184], [69, 188], [69, 189], [69, 197], [69, 198], [69, 204], [69, 258], [69, 261], [69, 268], [69, 279], [70, 79], [70, 92], [70, 100], [70, 123], [70, 134], [70, 135], [70, 140], [70, 146], [70, 155], [70, 165], [70, 180], [70, 181], [70, 192], [70, 195], [70, 219], [70, 221], [70, 238], [70, 246], [70, 255], [70, 257], [70, 273], [70, 291], [71, 76], [71, 99], [71, 119], [71, 123], [71, 125], [71, 156], [71, 157], [71, 181], [71, 185], [71, 194], [71, 197], [71, 210], [71, 253], [71, 263], [71, 288], [72, 78], [72, 116], [72, 144], [72, 147], [72, 162], [72, 169], [72, 193], [72, 196], [72, 200], [72, 223], [72, 229], [72, 236], [72, 260], [72, 296], [73, 76], [73, 79], [73, 84], [73, 121], [73, 124], [73, 131], [73, 145], [73, 179], [73, 192], [73, 194], [73, 203], [73, 209], [73, 229], [73, 235], [73, 240], [73, 267], [73, 268], [74, 84], [74, 93], [74, 100], [74, 107], [74, 109], [74, 113], [74, 122], [74, 147], [74, 149], [74, 150], [74, 160], [74, 173], [74, 190], [74, 212], [74, 218], [74, 238], [74, 239], [74, 245], [74, 246], [74, 247], [74, 285], [74, 292], [75, 107], [75, 136], [75, 138], [75, 156], [75, 157], [75, 175], [75, 183], [75, 184], [75, 226], [75, 233], [75, 247], [75, 287], [75, 295], [76, 82], [76, 83], [76, 97], [76, 99], [76, 114], [76, 118], [76, 121], [76, 134], [76, 136], [76, 158], [76, 161], [76, 170], [76, 176], [76, 198], [76, 200], [76, 207], [76, 215], [76, 233], [76, 234], [76, 250], [76, 256], [76, 261], [76, 285], [76, 290], [76, 297], [77, 95], [77, 102], [77, 108], [77, 112], [77, 160], [77, 194], [77, 202], [77, 208], [77, 211], [77, 241], [77, 246], [77, 255], [77, 267], [77, 278], [77, 292], [77, 299], [78, 91], [78, 105], [78, 171], [78, 205], [78, 207], [78, 217], [78, 227], [78, 239], [78, 249], [78, 260], [78, 280], [78, 282], [78, 291], [79, 83], [79, 100], [79, 126], [79, 133], [79, 172], [79, 173], [79, 209], [79, 216], [79, 219], [79, 233], [79, 234], [79, 240], [79, 260], [79, 266], [79, 275], [79, 282], [80, 107], [80, 109], [80, 143], [80, 147], [80, 150], [80, 171], [80, 176], [80, 184], [80, 191], [80, 227], [80, 232], [80, 238], [80, 246], [80, 260], [80, 267], [80, 283], [81, 91], [81, 131], [81, 153], [81, 179], [81, 189], [81, 200], [81, 214], [81, 225], [81, 230], [81, 265], [81, 274], [81, 277], [82, 83], [82, 107], [82, 124], [82, 128], [82, 155], [82, 166], [82, 192], [82, 273], [82, 283], [82, 288], [82, 291], [83, 84], [83, 86], [83, 91], [83, 99], [83, 105], [83, 121], [83, 126], [83, 163], [83, 180], [83, 188], [83, 193], [83, 196], [83, 224], [83, 227], [83, 251], [83, 252], [83, 262], [83, 263], [84, 92], [84, 150], [84, 174], [84, 201], [84, 214], [84, 228], [84, 238], [84, 241], [84, 243], [84, 244], [84, 268], [85, 94], [85, 104], [85, 127], [85, 143], [85, 153], [85, 155], [85, 158], [85, 159], [85, 183], [85, 199], [85, 215], [85, 250], [85, 257], [85, 274], [85, 283], [85, 288], [86, 87], [86, 94], [86, 113], [86, 153], [86, 167], [86, 173], [86, 181], [86, 196], [86, 203], [86, 216], [86, 236], [86, 250], [86, 251], [86, 286], [87, 100], [87, 104], [87, 126], [87, 132], [87, 156], [87, 158], [87, 171], [87, 195], [87, 197], [87, 198], [87, 202], [87, 204], [87, 206], [87, 209], [87, 247], [87, 251], [87, 270], [87, 288], [87, 293], [88, 89], [88, 94], [88, 96], [88, 105], [88, 110], [88, 119], [88, 124], [88, 130], [88, 152], [88, 161], [88, 164], [88, 185], [88, 196], [88, 206], [88, 214], [88, 218], [88, 233], [88, 249], [88, 267], [88, 286], [88, 287], [89, 98], [89, 107], [89, 140], [89, 153], [89, 185], [89, 192], [89, 231], [89, 275], [89, 280], [89, 285], [90, 108], [90, 128], [90, 159], [90, 185], [90, 194], [90, 257], [90, 273], [91, 95], [91, 104], [91, 115], [91, 131], [91, 139], [91, 142], [91, 145], [91, 150], [91, 151], [91, 157], [91, 158], [91, 163], [91, 173], [91, 174], [91, 176], [91, 209], [91, 213], [91, 216], [91, 241], [91, 247], [91, 255], [91, 284], [91, 286], [92, 109], [92, 143], [92, 151], [92, 180], [92, 181], [92, 198], [92, 235], [92, 240], [92, 292], [92, 299], [93, 117], [93, 126], [93, 127], [93, 135], [93, 142], [93, 172], [93, 182], [93, 189], [93, 199], [93, 209], [93, 228], [93, 271], [93, 273], [93, 297], [94, 116], [94, 125], [94, 126], [94, 130], [94, 159], [94, 161], [94, 170], [94, 180], [94, 188], [94, 189], [94, 192], [94, 195], [94, 200], [94, 215], [94, 220], [94, 228], [94, 243], [94, 244], [94, 245], [94, 266], [94, 275], [94, 287], [95, 121], [95, 140], [95, 148], [95, 167], [95, 177], [95, 183], [95, 185], [95, 208], [95, 234], [95, 253], [95, 263], [95, 288], [96, 123], [96, 135], [96, 144], [96, 161], [96, 170], [96, 189], [96, 192], [96, 243], [96, 262], [96, 266], [96, 271], [96, 281], [97, 98], [97, 121], [97, 143], [97, 155], [97, 161], [97, 164], [97, 168], [97, 220], [97, 221], [97, 240], [97, 250], [97, 257], [97, 268], [97, 271], [97, 290], [98, 111], [98, 126], [98, 138], [98, 161], [98, 168], [98, 172], [98, 182], [98, 185], [98, 188], [98, 204], [98, 217], [98, 223], [98, 225], [98, 231], [98, 240], [98, 248], [98, 295], [98, 299], [99, 119], [99, 140], [99, 166], [99, 186], [99, 193], [99, 199], [99, 223], [99, 237], [99, 240], [99, 247], [99, 257], [99, 274], [99, 283], [100, 121], [100, 125], [100, 130], [100, 137], [100, 158], [100, 181], [100, 199], [100, 228], [100, 251], [100, 280], [100, 282], [100, 284], [101, 118], [101, 128], [101, 136], [101, 149], [101, 155], [101, 162], [101, 163], [101, 165], [101, 166], [101, 173], [101, 179], [101, 192], [101, 242], [101, 245], [101, 253], [101, 259], [101, 263], [101, 280], [101, 287], [102, 117], [102, 120], [102, 121], [102, 134], [102, 152], [102, 157], [102, 162], [102, 163], [102, 183], [102, 195], [102, 197], [102, 244], [102, 291], [102, 297], [103, 115], [103, 117], [103, 118], [103, 132], [103, 142], [103, 154], [103, 179], [103, 181], [103, 190], [103, 220], [103, 273], [103, 279], [103, 285], [103, 291], [104, 135], [104, 145], [104, 168], [104, 177], [104, 200], [104, 232], [104, 239], [104, 250], [104, 258], [105, 107], [105, 132], [105, 173], [105, 188], [105, 191], [105, 206], [105, 239], [105, 250], [105, 262], [105, 273], [106, 112], [106, 121], [106, 152], [106, 158], [106, 180], [106, 189], [106, 201], [106, 211], [106, 257], [106, 262], [106, 285], [106, 294], [107, 113], [107, 117], [107, 123], [107, 125], [107, 132], [107, 154], [107, 159], [107, 186], [107, 191], [107, 197], [107, 205], [107, 206], [107, 224], [107, 228], [107, 230], [107, 234], [107, 236], [107, 238], [107, 242], [107, 249], [107, 252], [107, 253], [107, 258], [107, 276], [107, 285], [107, 291], [107, 293], [107, 296], [108, 147], [108, 161], [108, 165], [108, 171], [108, 172], [108, 197], [108, 227], [108, 229], [108, 230], [108, 238], [108, 244], [108, 296], [108, 298], [109, 127], [109, 153], [109, 156], [109, 173], [109, 188], [109, 189], [109, 213], [109, 230], [109, 244], [109, 248], [109, 257], [109, 295], [110, 138], [110, 141], [110, 144], [110, 161], [110, 183], [110, 189], [110, 191], [110, 255], [110, 259], [110, 288], [110, 290], [111, 128], [111, 151], [111, 163], [111, 165], [111, 171], [111, 181], [111, 198], [111, 228], [111, 267], [111, 276], [112, 138], [112, 160], [112, 182], [112, 184], [112, 239], [112, 241], [112, 254], [112, 263], [112, 271], [112, 276], [112, 289], [113, 147], [113, 175], [113, 180], [113, 274], [113, 279], [113, 281], [114, 116], [114, 124], [114, 130], [114, 197], [114, 268], [115, 121], [115, 136], [115, 141], [115, 163], [115, 167], [115, 168], [115, 202], [115, 204], [115, 218], [115, 261], [115, 263], [115, 273], [116, 120], [116, 137], [116, 140], [116, 164], [116, 198], [116, 245], [116, 268], [116, 270], [117, 147], [117, 157], [117, 179], [117, 192], [117, 209], [117, 220], [117, 240], [117, 298], [118, 134], [118, 143], [118, 160], [118, 174], [118, 175], [118, 179], [118, 181], [118, 192], [118, 200], [118, 209], [118, 217], [118, 231], [118, 257], [118, 264], [118, 265], [118, 276], [118, 293], [119, 132], [119, 156], [119, 163], [119, 183], [119, 187], [119, 199], [119, 204], [119, 222], [119, 242], [119, 255], [119, 268], [120, 160], [120, 179], [120, 208], [120, 225], [120, 232], [120, 243], [120, 251], [120, 261], [120, 268], [120, 270], [120, 282], [121, 131], [121, 162], [121, 174], [121, 185], [121, 277], [122, 213], [122, 218], [122, 245], [122, 252], [122, 257], [122, 262], [122, 276], [122, 298], [123, 126], [123, 129], [123, 136], [123, 156], [123, 170], [123, 179], [123, 227], [123, 244], [123, 275], [123, 292], [123, 294], [124, 129], [124, 131], [124, 140], [124, 141], [124, 149], [124, 162], [124, 223], [124, 226], [124, 233], [124, 236], [124, 238], [124, 252], [124, 264], [124, 273], [124, 275], [124, 288], [125, 140], [125, 155], [125, 178], [125, 182], [125, 189], [125, 217], [125, 222], [125, 225], [125, 245], [125, 280], [125, 283], [125, 284], [125, 299], [126, 151], [126, 173], [126, 188], [126, 203], [126, 212], [126, 217], [126, 246], [126, 247], [127, 136], [127, 179], [127, 182], [127, 201], [127, 203], [127, 223], [127, 239], [127, 279], [127, 291], [128, 133], [128, 137], [128, 138], [128, 142], [128, 144], [128, 157], [128, 180], [128, 208], [128, 211], [128, 225], [128, 245], [128, 271], [128, 274], [128, 298], [129, 151], [129, 168], [129, 181], [129, 189], [129, 210], [129, 220], [129, 223], [129, 241], [129, 248], [129, 272], [129, 285], [129, 296], [130, 139], [130, 181], [130, 210], [130, 229], [130, 238], [130, 243], [130, 254], [130, 284], [131, 138], [131, 140], [131, 155], [131, 205], [131, 209], [131, 233], [131, 239], [131, 252], [131, 261], [131, 282], [131, 283], [131, 287], [131, 298], [132, 156], [132, 157], [132, 179], [132, 185], [132, 233], [132, 254], [132, 282], [132, 283], [132, 284], [133, 161], [133, 162], [133, 166], [133, 176], [133, 203], [133, 221], [133, 236], [133, 248], [133, 289], [134, 135], [134, 197], [134, 198], [134, 202], [134, 243], [134, 254], [135, 143], [135, 174], [135, 179], [135, 204], [135, 225], [135, 232], [135, 242], [135, 271], [135, 291], [135, 292], [135, 294], [136, 141], [136, 143], [136, 158], [136, 169], [136, 170], [136, 196], [136, 203], [136, 212], [136, 215], [136, 218], [136, 245], [136, 250], [136, 258], [136, 262], [136, 292], [137, 153], [137, 165], [137, 169], [137, 171], [137, 183], [137, 194], [137, 208], [137, 218], [137, 222], [137, 226], [137, 240], [137, 262], [137, 267], [137, 269], [137, 271], [137, 291], [138, 175], [138, 190], [138, 191], [138, 198], [138, 202], [138, 219], [138, 228], [138, 230], [138, 255], [138, 293], [139, 148], [139, 168], [139, 204], [139, 213], [139, 226], [139, 255], [139, 272], [139, 288], [140, 149], [140, 152], [140, 160], [140, 171], [140, 173], [140, 175], [140, 208], [140, 225], [140, 232], [140, 245], [140, 273], [140, 289], [141, 149], [141, 186], [141, 207], [141, 243], [141, 250], [141, 286], [142, 160], [142, 192], [142, 197], [142, 211], [142, 214], [142, 248], [142, 285], [142, 293], [143, 158], [143, 164], [143, 203], [143, 208], [143, 214], [143, 239], [143, 259], [143, 266], [143, 281], [144, 161], [144, 170], [144, 189], [144, 194], [144, 209], [144, 231], [144, 239], [144, 247], [144, 269], [144, 271], [144, 274], [144, 278], [144, 294], [145, 153], [145, 164], [145, 165], [145, 188], [145, 212], [145, 224], [145, 230], [145, 240], [145, 294], [146, 156], [146, 167], [146, 169], [146, 181], [146, 189], [146, 218], [146, 226], [146, 232], [146, 251], [146, 253], [146, 254], [146, 257], [146, 267], [146, 299], [147, 155], [147, 160], [147, 163], [147, 164], [147, 178], [147, 193], [147, 218], [147, 251], [147, 290], [147, 294], [147, 295], [147, 297], [148, 153], [148, 159], [148, 197], [148, 209], [148, 221], [148, 228], [148, 246], [148, 268], [148, 291], [148, 297], [149, 150], [149, 165], [149, 168], [149, 175], [149, 187], [149, 191], [149, 232], [149, 238], [149, 240], [149, 247], [149, 253], [149, 261], [149, 275], [150, 170], [150, 183], [150, 216], [150, 243], [150, 245], [150, 249], [150, 267], [151, 152], [151, 175], [151, 181], [151, 192], [151, 217], [151, 223], [151, 237], [151, 240], [151, 241], [151, 269], [151, 280], [151, 291], [152, 161], [152, 211], [152, 227], [152, 245], [152, 247], [152, 252], [152, 269], [152, 298], [153, 161], [153, 166], [153, 195], [153, 204], [153, 209], [153, 218], [153, 235], [153, 250], [153, 288], [154, 169], [154, 171], [154, 187], [154, 190], [154, 219], [154, 241], [154, 243], [154, 252], [154, 263], [154, 291], [155, 191], [155, 238], [155, 245], [155, 280], [155, 292], [156, 177], [156, 216], [156, 223], [156, 224], [156, 225], [156, 234], [156, 236], [156, 238], [156, 271], [156, 279], [156, 283], [157, 185], [157, 214], [157, 218], [157, 245], [157, 270], [158, 186], [158, 205], [158, 215], [158, 224], [158, 232], [158, 247], [158, 275], [159, 168], [159, 222], [159, 260], [159, 262], [159, 274], [160, 167], [160, 172], [160, 188], [160, 214], [160, 216], [160, 235], [160, 239], [160, 240], [160, 259], [160, 270], [160, 287], [161, 162], [161, 167], [161, 173], [161, 186], [161, 190], [161, 194], [161, 198], [161, 208], [161, 218], [161, 227], [161, 231], [161, 236], [161, 265], [161, 266], [161, 276], [161, 286], [161, 293], [162, 165], [162, 182], [162, 186], [162, 205], [162, 222], [162, 250], [162, 268], [162, 299], [163, 238], [163, 253], [163, 257], [163, 291], [164, 166], [164, 170], [164, 180], [164, 199], [164, 200], [164, 203], [164, 207], [164, 219], [164, 228], [164, 230], [164, 233], [164, 255], [164, 261], [164, 265], [164, 272], [164, 280], [164, 283], [165, 177], [165, 208], [165, 214], [165, 239], [165, 247], [165, 256], [165, 257], [165, 273], [165, 296], [165, 297], [166, 171], [166, 172], [166, 175], [166, 177], [166, 193], [166, 196], [166, 228], [166, 232], [166, 235], [166, 237], [166, 254], [166, 260], [166, 263], [166, 266], [166, 285], [166, 290], [166, 299], [167, 178], [167, 181], [167, 189], [167, 190], [167, 214], [167, 273], [167, 277], [167, 280], [167, 286], [168, 170], [168, 181], [168, 190], [168, 206], [168, 221], [168, 252], [168, 257], [168, 259], [168, 274], [168, 278], [169, 204], [169, 207], [169, 212], [169, 222], [169, 240], [169, 255], [169, 268], [170, 172], [170, 236], [170, 249], [171, 175], [171, 196], [171, 205], [171, 208], [171, 223], [171, 227], [171, 297], [172, 197], [172, 237], [172, 257], [172, 288], [172, 290], [173, 174], [173, 180], [173, 186], [173, 219], [173, 223], [173, 247], [173, 252], [173, 266], [173, 268], [173, 275], [174, 199], [174, 201], [174, 218], [174, 239], [174, 251], [174, 282], [175, 184], [175, 195], [175, 238], [175, 245], [175, 267], [175, 278], [175, 285], [175, 299], [176, 183], [176, 206], [176, 207], [176, 208], [176, 213], [176, 225], [176, 243], [176, 267], [176, 272], [176, 277], [176, 281], [176, 296], [176, 299], [177, 179], [177, 201], [177, 227], [177, 248], [178, 198], [178, 232], [178, 243], [178, 277], [178, 278], [178, 295], [179, 193], [179, 194], [179, 232], [179, 252], [179, 257], [180, 193], [180, 195], [180, 208], [180, 221], [180, 222], [180, 229], [180, 233], [180, 241], [180, 251], [180, 281], [180, 292], [180, 298], [180, 299], [181, 182], [181, 187], [181, 198], [181, 209], [181, 216], [181, 220], [181, 225], [181, 232], [181, 254], [181, 256], [181, 258], [181, 272], [181, 273], [181, 297], [182, 216], [182, 223], [182, 231], [182, 246], [182, 269], [182, 271], [182, 298], [183, 185], [183, 213], [183, 257], [183, 285], [183, 287], [184, 199], [184, 245], [184, 267], [184, 272], [184, 283], [185, 195], [185, 197], [185, 229], [185, 230], [185, 233], [185, 247], [185, 254], [185, 267], [185, 272], [185, 288], [185, 290], [185, 295], [186, 214], [186, 223], [186, 239], [186, 243], [186, 244], [186, 283], [186, 299], [187, 210], [187, 272], [187, 274], [187, 288], [187, 293], [188, 198], [188, 200], [188, 206], [188, 214], [188, 234], [188, 256], [188, 273], [188, 299], [189, 193], [189, 201], [189, 206], [189, 209], [189, 214], [189, 248], [189, 258], [189, 274], [189, 275], [189, 276], [189, 282], [189, 283], [189, 295], [190, 196], [190, 228], [190, 236], [190, 237], [190, 241], [190, 246], [190, 249], [190, 265], [191, 206], [191, 215], [191, 225], [191, 240], [191, 247], [191, 268], [191, 274], [191, 280], [191, 286], [191, 288], [191, 296], [193, 199], [193, 213], [193, 218], [193, 229], [193, 232], [193, 245], [193, 251], [193, 253], [193, 254], [193, 275], [193, 277], [193, 281], [193, 282], [193, 296], [194, 224], [194, 236], [194, 259], [194, 271], [194, 286], [194, 299], [195, 196], [195, 201], [195, 204], [195, 222], [195, 251], [195, 257], [195, 298], [196, 222], [196, 225], [196, 233], [196, 236], [196, 242], [196, 256], [196, 257], [196, 297], [197, 201], [197, 207], [197, 238], [197, 269], [197, 274], [198, 204], [198, 235], [198, 260], [198, 270], [198, 282], [198, 287], [199, 216], [199, 252], [199, 257], [199, 272], [200, 205], [200, 206], [200, 220], [200, 249], [200, 251], [200, 255], [200, 273], [200, 295], [201, 245], [201, 247], [201, 271], [202, 207], [202, 220], [202, 222], [202, 224], [202, 229], [202, 266], [202, 273], [202, 291], [203, 206], [203, 208], [203, 257], [203, 259], [203, 283], [204, 209], [204, 210], [204, 220], [204, 228], [204, 231], [204, 238], [204, 259], [205, 249], [205, 251], [205, 263], [205, 288], [206, 276], [207, 211], [207, 227], [207, 228], [207, 285], [207, 296], [207, 299], [208, 212], [208, 229], [208, 256], [208, 264], [208, 265], [208, 286], [208, 298], [209, 217], [209, 222], [209, 230], [209, 238], [209, 259], [209, 262], [209, 279], [209, 291], [210, 212], [210, 230], [210, 240], [210, 241], [210, 264], [210, 287], [211, 215], [211, 228], [211, 232], [211, 236], [211, 258], [212, 245], [212, 266], [212, 274], [212, 276], [212, 277], [213, 227], [213, 229], [213, 247], [213, 257], [213, 266], [213, 267], [213, 273], [213, 275], [214, 243], [214, 244], [214, 270], [215, 217], [215, 236], [215, 254], [215, 256], [215, 262], [216, 238], [216, 247], [216, 254], [216, 268], [216, 275], [217, 227], [217, 243], [217, 249], [217, 271], [217, 282], [218, 232], [218, 234], [218, 265], [219, 228], [219, 245], [219, 275], [219, 291], [220, 224], [220, 225], [220, 234], [220, 236], [220, 249], [220, 256], [220, 270], [220, 287], [221, 225], [221, 235], [221, 245], [221, 247], [221, 250], [221, 269], [221, 274], [221, 284], [221, 293], [222, 232], [222, 257], [222, 258], [222, 263], [222, 270], [222, 291], [223, 262], [223, 266], [223, 282], [224, 236], [224, 255], [224, 261], [224, 268], [224, 289], [225, 231], [225, 245], [225, 247], [225, 250], [225, 260], [225, 266], [225, 271], [225, 283], [225, 294], [226, 243], [226, 262], [226, 284], [226, 285], [226, 295], [227, 250], [227, 251], [227, 272], [228, 246], [228, 275], [229, 246], [229, 274], [229, 296], [230, 254], [230, 257], [230, 260], [231, 234], [231, 240], [231, 264], [231, 270], [231, 288], [231, 290], [232, 275], [232, 283], [232, 297], [233, 250], [233, 260], [234, 237], [234, 244], [234, 249], [234, 261], [234, 273], [234, 275], [234, 277], [234, 283], [234, 291], [234, 294], [234, 298], [235, 242], [235, 265], [235, 274], [235, 284], [235, 292], [236, 242], [236, 248], [236, 260], [236, 288], [236, 292], [237, 260], [237, 262], [237, 277], [237, 283], [238, 243], [238, 271], [238, 281], [238, 291], [238, 293], [239, 249], [239, 275], [240, 252], [240, 294], [240, 296], [241, 247], [241, 255], [241, 270], [241, 283], [241, 289], [242, 270], [243, 266], [243, 273], [243, 275], [243, 279], [243, 287], [244, 245], [244, 288], [245, 248], [245, 267], [245, 282], [245, 285], [245, 288], [247, 272], [247, 276], [247, 282], [247, 290], [247, 295], [247, 296], [248, 250], [248, 257], [248, 262], [248, 267], [248, 287], [248, 290], [249, 285], [249, 297], [250, 256], [250, 269], [250, 276], [251, 267], [251, 274], [251, 277], [252, 256], [252, 259], [252, 272], [252, 278], [252, 293], [253, 258], [253, 280], [253, 291], [254, 274], [255, 272], [255, 281], [255, 282], [255, 293], [256, 266], [256, 270], [256, 277], [257, 279], [257, 289], [257, 295], [257, 299], [258, 266], [258, 284], [259, 272], [259, 281], [259, 294], [260, 261], [260, 266], [260, 284], [261, 274], [261, 283], [262, 291], [263, 267], [263, 277], [263, 285], [263, 288], [263, 290], [264, 282], [264, 293], [266, 269], [266, 274], [266, 282], [267, 287], [267, 298], [268, 282], [268, 289], [270, 280], [270, 282], [272, 274], [272, 285], [272, 288], [273, 279], [274, 276], [275, 289], [275, 292], [276, 280], [278, 286], [279, 291], [279, 297], [280, 283], [280, 289], [280, 294], [280, 296], [281, 287], [281, 294], [282, 297], [283, 287], [283, 289], [287, 290], [288, 290], [291, 299], [292, 297], [294, 299], [295, 296]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l6-s4/solution/solve.sh b/tasks/construct-nppc-dominating-set-l6-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cec50b1774d0d893b512838c8bea9d3953e17230 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"dominating_set": [8, 18, 54, 69, 76, 77, 83, 91, 101, 107, 137, 156, 161, 164, 181, 243, 245, 257, 274, 282]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l6-s4/tests/check.py b/tasks/construct-nppc-dominating-set-l6-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s4/tests/check.py @@ -0,0 +1,23 @@ +"""Dominating set of size <= k. Accepts any valid dominating set.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier has no type/range checks (out-of-range labels and floats are silently used) + d = int_list(ans.get("dominating_set"), None, 0, n - 1, "dominating_set") + if len(set(d)) != len(d): + raise Invalid("dominating_set contains duplicates") + if not d or len(d) > k: + raise Invalid(f"dominating_set must have 1..{k} vertices, got {len(d)}") + dom = set(d) + s = set(d) + for u, v in inst["edges"]: + if u in s: + dom.add(v) + if v in s: + dom.add(u) + if len(dom) != n: + miss = min(set(range(n)) - dom) + raise Invalid(f"vertex {miss} is not dominated") + return None, {"size": len(d)} diff --git a/tasks/construct-nppc-dominating-set-l6-s4/tests/instance.json b/tasks/construct-nppc-dominating-set-l6-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c365ac170cf7d5c4e64dc497ba3ba8e01f9fd4c3 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s4/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 300, "k": 20, "edges": [[0, 31], [0, 47], [0, 90], [0, 96], [0, 101], [0, 107], [0, 113], [0, 114], [0, 121], [0, 158], [0, 179], [0, 185], [0, 188], [0, 194], [0, 204], [0, 207], [0, 217], [0, 219], [0, 238], [0, 274], [1, 9], [1, 20], [1, 43], [1, 72], [1, 90], [1, 91], [1, 153], [1, 178], [1, 197], [1, 219], [1, 220], [1, 222], [1, 223], [1, 225], [1, 234], [1, 263], [1, 280], [1, 292], [2, 7], [2, 8], [2, 38], [2, 50], [2, 55], [2, 58], [2, 97], [2, 102], [2, 112], [2, 168], [2, 174], [2, 183], [2, 185], [2, 189], [2, 239], [2, 241], [2, 245], [2, 254], [2, 260], [2, 268], [2, 272], [2, 288], [3, 11], [3, 20], [3, 25], [3, 29], [3, 32], [3, 33], [3, 40], [3, 65], [3, 72], [3, 78], [3, 83], [3, 87], [3, 90], [3, 109], [3, 156], [3, 158], [3, 185], [3, 191], [3, 200], [3, 236], [3, 238], [3, 271], [3, 273], [3, 276], [4, 33], [4, 37], [4, 63], [4, 64], [4, 78], [4, 81], [4, 98], [4, 127], [4, 134], [4, 155], [4, 157], [4, 158], [4, 171], [4, 174], [4, 182], [4, 203], [4, 208], [4, 220], [4, 269], [4, 272], [4, 282], [4, 289], [5, 65], [5, 86], [5, 101], [5, 111], [5, 169], [5, 200], [5, 202], [5, 220], [5, 242], [5, 246], [5, 260], [5, 266], [5, 282], [5, 296], [6, 8], [6, 24], [6, 25], [6, 67], [6, 72], [6, 110], [6, 153], [6, 168], [6, 180], [6, 216], [6, 237], [6, 239], [6, 285], [6, 288], [6, 299], [7, 77], [7, 95], [7, 131], [7, 135], [7, 144], [7, 153], [7, 154], [7, 176], [7, 200], [7, 204], [7, 226], [7, 228], [7, 238], [7, 250], [7, 254], [7, 271], [7, 284], [8, 17], [8, 19], [8, 25], [8, 41], [8, 49], [8, 64], [8, 74], [8, 82], [8, 87], [8, 107], [8, 121], [8, 124], [8, 138], [8, 141], [8, 148], [8, 157], [8, 196], [8, 207], [8, 208], [8, 210], [8, 237], [8, 239], [8, 244], [8, 247], [8, 263], [8, 290], [8, 294], [9, 11], [9, 20], [9, 24], [9, 53], [9, 59], [9, 83], [9, 86], [9, 94], [9, 144], [9, 154], [9, 155], [9, 156], [9, 196], [9, 229], [9, 284], [9, 297], [10, 14], [10, 54], [10, 82], [10, 85], [10, 93], [10, 121], [10, 164], [10, 166], [10, 176], [10, 177], [10, 211], [10, 274], [10, 281], [10, 294], [10, 295], [10, 297], [10, 298], [10, 299], [11, 19], [11, 43], [11, 45], [11, 54], [11, 73], [11, 95], [11, 120], [11, 123], [11, 141], [11, 143], [11, 146], [11, 148], [11, 153], [11, 160], [11, 163], [11, 164], [11, 166], [11, 172], [11, 181], [11, 210], [11, 216], [11, 224], [11, 226], [11, 227], [11, 249], [11, 297], [12, 13], [12, 31], [12, 37], [12, 41], [12, 56], [12, 58], [12, 62], [12, 66], [12, 101], [12, 157], [12, 159], [12, 161], [12, 189], [12, 217], [12, 221], [12, 228], [12, 256], [12, 265], [12, 268], [12, 271], [13, 43], [13, 44], [13, 56], [13, 101], [13, 120], [13, 123], [13, 126], [13, 144], [13, 150], [13, 160], [13, 177], [13, 181], [13, 202], [13, 216], [13, 258], [13, 260], [13, 274], [13, 284], [13, 286], [14, 22], [14, 29], [14, 40], [14, 55], [14, 66], [14, 95], [14, 101], [14, 111], [14, 188], [14, 202], [14, 203], [14, 221], [14, 274], [15, 31], [15, 37], [15, 57], [15, 70], [15, 85], [15, 107], [15, 146], [15, 164], [15, 193], [15, 194], [15, 200], [15, 202], [15, 211], [15, 275], [15, 285], [15, 289], [16, 20], [16, 41], [16, 64], [16, 68], [16, 69], [16, 89], [16, 128], [16, 130], [16, 150], [16, 164], [16, 171], [16, 191], [16, 209], [16, 227], [16, 256], [16, 259], [16, 275], [16, 292], [17, 30], [17, 41], [17, 60], [17, 63], [17, 74], [17, 83], [17, 89], [17, 118], [17, 122], [17, 132], [17, 135], [17, 143], [17, 189], [17, 208], [17, 212], [17, 213], [17, 233], [17, 243], [17, 286], [18, 34], [18, 54], [18, 56], [18, 59], [18, 62], [18, 64], [18, 82], [18, 93], [18, 103], [18, 104], [18, 110], [18, 113], [18, 134], [18, 153], [18, 154], [18, 177], [18, 197], [18, 206], [18, 217], [18, 239], [18, 252], [18, 259], [18, 277], [18, 281], [18, 284], [18, 292], [18, 294], [18, 299], [19, 32], [19, 34], [19, 39], [19, 48], [19, 67], [19, 69], [19, 70], [19, 76], [19, 85], [19, 87], [19, 95], [19, 103], [19, 136], [19, 154], [19, 167], [19, 168], [19, 170], [19, 186], [19, 192], [19, 203], [19, 205], [19, 221], [19, 232], [19, 259], [19, 292], [19, 298], [20, 29], [20, 41], [20, 68], [20, 76], [20, 93], [20, 99], [20, 101], [20, 102], [20, 105], [20, 108], [20, 111], [20, 122], [20, 126], [20, 131], [20, 133], [20, 166], [20, 206], [20, 234], [20, 238], [21, 31], [21, 47], [21, 54], [21, 56], [21, 60], [21, 64], [21, 68], [21, 79], [21, 81], [21, 92], [21, 114], [21, 126], [21, 136], [21, 151], [21, 160], [21, 168], [21, 173], [21, 175], [21, 190], [21, 202], [21, 204], [21, 263], [21, 274], [21, 293], [22, 44], [22, 47], [22, 79], [22, 126], [22, 137], [22, 154], [22, 158], [22, 164], [22, 195], [22, 197], [22, 237], [22, 239], [22, 242], [22, 259], [22, 284], [22, 293], [23, 29], [23, 60], [23, 130], [23, 171], [23, 181], [23, 203], [23, 204], [23, 207], [23, 250], [23, 253], [23, 255], [23, 258], [23, 266], [23, 286], [23, 295], [24, 28], [24, 50], [24, 52], [24, 84], [24, 93], [24, 104], [24, 137], [24, 149], [24, 151], [24, 166], [24, 182], [24, 183], [24, 213], [24, 221], [24, 230], [24, 291], [25, 30], [25, 32], [25, 33], [25, 35], [25, 39], [25, 62], [25, 67], [25, 76], [25, 82], [25, 87], [25, 90], [25, 93], [25, 100], [25, 126], [25, 169], [25, 228], [25, 234], [25, 242], [25, 243], [25, 261], [25, 281], [26, 50], [26, 77], [26, 92], [26, 100], [26, 107], [26, 129], [26, 158], [26, 183], [26, 241], [26, 280], [27, 32], [27, 50], [27, 92], [27, 108], [27, 116], [27, 131], [27, 183], [27, 214], [27, 215], [27, 247], [27, 275], [27, 282], [28, 35], [28, 53], [28, 54], [28, 90], [28, 99], [28, 123], [28, 127], [28, 129], [28, 137], [28, 170], [28, 212], [28, 229], [28, 240], [28, 259], [28, 281], [29, 80], [29, 107], [29, 115], [29, 132], [29, 138], [29, 178], [29, 185], [29, 198], [29, 220], [29, 223], [29, 228], [29, 235], [29, 250], [29, 257], [29, 275], [29, 280], [29, 282], [30, 33], [30, 36], [30, 40], [30, 49], [30, 53], [30, 63], [30, 72], [30, 95], [30, 97], [30, 111], [30, 116], [30, 129], [30, 148], [30, 189], [30, 194], [30, 232], [30, 257], [30, 268], [30, 269], [30, 282], [31, 48], [31, 91], [31, 101], [31, 103], [31, 111], [31, 127], [31, 133], [31, 157], [31, 167], [31, 178], [31, 197], [31, 209], [31, 279], [31, 289], [31, 294], [32, 54], [32, 77], [32, 142], [32, 153], [32, 164], [32, 175], [32, 181], [32, 199], [32, 224], [32, 231], [32, 232], [32, 242], [32, 243], [32, 253], [32, 268], [32, 273], [33, 39], [33, 52], [33, 79], [33, 91], [33, 110], [33, 137], [33, 176], [33, 198], [33, 200], [33, 257], [33, 265], [33, 267], [34, 61], [34, 81], [34, 97], [34, 103], [34, 104], [34, 140], [34, 141], [34, 144], [34, 159], [34, 171], [34, 186], [34, 206], [34, 223], [34, 240], [34, 260], [34, 292], [35, 37], [35, 77], [35, 138], [35, 143], [35, 172], [35, 175], [35, 177], [35, 187], [35, 231], [35, 238], [35, 245], [35, 278], [35, 283], [36, 41], [36, 52], [36, 58], [36, 65], [36, 72], [36, 80], [36, 84], [36, 92], [36, 103], [36, 108], [36, 137], [36, 150], [36, 152], [36, 181], [36, 184], [36, 185], [36, 229], [36, 276], [37, 79], [37, 81], [37, 91], [37, 131], [37, 133], [37, 146], [37, 180], [37, 188], [37, 206], [37, 236], [37, 280], [38, 51], [38, 93], [38, 117], [38, 119], [38, 137], [38, 142], [38, 181], [38, 206], [38, 213], [38, 236], [38, 251], [38, 258], [38, 271], [38, 279], [38, 284], [39, 61], [39, 65], [39, 76], [39, 132], [39, 159], [39, 220], [39, 240], [39, 268], [40, 59], [40, 67], [40, 78], [40, 88], [40, 95], [40, 102], [40, 111], [40, 149], [40, 153], [40, 169], [40, 212], [40, 223], [40, 243], [40, 253], [40, 264], [40, 281], [40, 297], [41, 43], [41, 50], [41, 51], [41, 56], [41, 61], [41, 70], [41, 75], [41, 101], [41, 116], [41, 139], [41, 144], [41, 146], [41, 151], [41, 159], [41, 167], [41, 172], [41, 174], [41, 176], [41, 215], [41, 216], [41, 224], [41, 225], [41, 228], [41, 234], [41, 296], [41, 299], [42, 68], [42, 84], [42, 105], [42, 117], [42, 122], [42, 125], [42, 132], [42, 141], [42, 147], [42, 212], [42, 216], [42, 231], [42, 243], [42, 251], [42, 292], [43, 78], [43, 85], [43, 89], [43, 123], [43, 137], [43, 148], [43, 162], [43, 185], [43, 210], [43, 225], [43, 255], [43, 257], [43, 268], [43, 297], [44, 48], [44, 68], [44, 73], [44, 76], [44, 84], [44, 104], [44, 143], [44, 148], [44, 176], [44, 179], [44, 181], [44, 214], [44, 219], [44, 221], [44, 294], [44, 298], [45, 63], [45, 68], [45, 77], [45, 94], [45, 104], [45, 132], [45, 142], [45, 156], [45, 169], [45, 190], [45, 192], [45, 196], [45, 204], [45, 225], [45, 226], [45, 239], [45, 242], [45, 257], [45, 264], [45, 276], [46, 49], [46, 91], [46, 107], [46, 110], [46, 132], [46, 142], [46, 151], [46, 173], [46, 178], [46, 181], [46, 193], [46, 199], [46, 210], [46, 211], [46, 217], [46, 236], [46, 239], [46, 269], [46, 273], [47, 95], [47, 106], [47, 125], [47, 132], [47, 150], [47, 178], [47, 193], [47, 201], [47, 226], [47, 227], [47, 243], [47, 253], [47, 257], [47, 269], [47, 272], [47, 274], [48, 57], [48, 89], [48, 98], [48, 100], [48, 116], [48, 131], [48, 138], [48, 141], [48, 142], [48, 190], [48, 215], [48, 223], [48, 233], [48, 243], [48, 246], [48, 264], [48, 294], [49, 53], [49, 74], [49, 77], [49, 115], [49, 117], [49, 143], [49, 169], [49, 176], [49, 198], [49, 209], [49, 222], [49, 238], [49, 251], [49, 258], [49, 295], [50, 58], [50, 62], [50, 68], [50, 93], [50, 102], [50, 106], [50, 109], [50, 119], [50, 121], [50, 167], [50, 209], [50, 222], [50, 232], [50, 235], [50, 243], [50, 248], [50, 289], [51, 76], [51, 89], [51, 98], [51, 106], [51, 115], [51, 134], [51, 143], [51, 146], [51, 165], [51, 175], [51, 179], [51, 196], [51, 203], [51, 232], [51, 241], [51, 257], [51, 273], [51, 295], [52, 56], [52, 58], [52, 90], [52, 109], [52, 120], [52, 167], [52, 179], [52, 183], [52, 208], [52, 213], [52, 217], [52, 237], [52, 282], [53, 58], [53, 69], [53, 73], [53, 103], [53, 125], [53, 148], [53, 155], [53, 181], [53, 189], [53, 200], [53, 208], [53, 215], [53, 224], [53, 246], [53, 259], [53, 280], [53, 286], [53, 295], [54, 72], [54, 75], [54, 79], [54, 87], [54, 100], [54, 108], [54, 110], [54, 121], [54, 126], [54, 127], [54, 135], [54, 136], [54, 138], [54, 139], [54, 150], [54, 178], [54, 185], [54, 198], [54, 213], [54, 219], [54, 228], [54, 231], [54, 237], [54, 248], [54, 249], [54, 256], [54, 260], [54, 262], [54, 291], [54, 298], [55, 63], [55, 77], [55, 131], [55, 139], [55, 169], [55, 182], [55, 191], [55, 214], [55, 237], [55, 241], [55, 261], [55, 269], [55, 276], [56, 61], [56, 62], [56, 64], [56, 69], [56, 76], [56, 100], [56, 136], [56, 162], [56, 165], [56, 166], [56, 191], [56, 192], [56, 226], [56, 229], [56, 254], [56, 256], [56, 281], [56, 293], [56, 298], [57, 88], [57, 93], [57, 106], [57, 107], [57, 114], [57, 137], [57, 139], [57, 141], [57, 145], [57, 168], [57, 179], [57, 188], [57, 208], [57, 223], [57, 228], [57, 243], [57, 275], [57, 281], [57, 284], [57, 290], [58, 76], [58, 103], [58, 138], [58, 170], [58, 172], [58, 175], [58, 179], [58, 193], [58, 215], [58, 234], [58, 262], [58, 274], [59, 61], [59, 76], [59, 78], [59, 86], [59, 94], [59, 122], [59, 136], [59, 141], [59, 145], [59, 173], [59, 191], [59, 195], [59, 204], [59, 206], [59, 237], [59, 239], [59, 243], [59, 260], [59, 261], [59, 263], [59, 272], [60, 61], [60, 79], [60, 100], [60, 106], [60, 151], [60, 176], [60, 180], [60, 181], [60, 190], [60, 210], [60, 220], [60, 224], [60, 226], [60, 232], [60, 242], [60, 245], [60, 256], [60, 283], [60, 285], [60, 296], [61, 65], [61, 70], [61, 100], [61, 119], [61, 144], [61, 147], [61, 148], [61, 154], [61, 163], [61, 182], [61, 223], [61, 230], [61, 243], [61, 288], [61, 291], [62, 69], [62, 95], [62, 122], [62, 128], [62, 131], [62, 155], [62, 165], [62, 177], [62, 178], [62, 179], [62, 193], [62, 206], [62, 209], [62, 250], [63, 65], [63, 73], [63, 96], [63, 102], [63, 121], [63, 143], [63, 153], [63, 159], [63, 164], [63, 176], [63, 182], [63, 233], [63, 240], [63, 247], [63, 249], [63, 250], [63, 276], [64, 149], [64, 172], [64, 175], [64, 178], [64, 203], [64, 206], [64, 223], [64, 249], [64, 265], [64, 282], [64, 290], [65, 75], [65, 110], [65, 143], [65, 151], [65, 158], [65, 172], [65, 187], [65, 188], [65, 195], [65, 220], [65, 229], [65, 245], [65, 266], [65, 275], [65, 276], [65, 278], [65, 291], [65, 297], [66, 74], [66, 78], [66, 87], [66, 131], [66, 135], [66, 143], [66, 169], [66, 183], [66, 190], [66, 210], [66, 234], [66, 240], [66, 242], [66, 251], [66, 257], [66, 265], [66, 267], [66, 276], [66, 294], [67, 78], [67, 122], [67, 132], [67, 138], [67, 139], [67, 154], [67, 197], [67, 205], [67, 236], [67, 245], [67, 249], [67, 258], [67, 268], [67, 280], [68, 73], [68, 108], [68, 124], [68, 134], [68, 156], [68, 213], [68, 232], [68, 263], [68, 277], [68, 293], [68, 296], [69, 76], [69, 104], [69, 118], [69, 125], [69, 150], [69, 167], [69, 184], [69, 188], [69, 189], [69, 197], [69, 198], [69, 204], [69, 258], [69, 261], [69, 268], [69, 279], [70, 79], [70, 92], [70, 100], [70, 123], [70, 134], [70, 135], [70, 140], [70, 146], [70, 155], [70, 165], [70, 180], [70, 181], [70, 192], [70, 195], [70, 219], [70, 221], [70, 238], [70, 246], [70, 255], [70, 257], [70, 273], [70, 291], [71, 76], [71, 99], [71, 119], [71, 123], [71, 125], [71, 156], [71, 157], [71, 181], [71, 185], [71, 194], [71, 197], [71, 210], [71, 253], [71, 263], [71, 288], [72, 78], [72, 116], [72, 144], [72, 147], [72, 162], [72, 169], [72, 193], [72, 196], [72, 200], [72, 223], [72, 229], [72, 236], [72, 260], [72, 296], [73, 76], [73, 79], [73, 84], [73, 121], [73, 124], [73, 131], [73, 145], [73, 179], [73, 192], [73, 194], [73, 203], [73, 209], [73, 229], [73, 235], [73, 240], [73, 267], [73, 268], [74, 84], [74, 93], [74, 100], [74, 107], [74, 109], [74, 113], [74, 122], [74, 147], [74, 149], [74, 150], [74, 160], [74, 173], [74, 190], [74, 212], [74, 218], [74, 238], [74, 239], [74, 245], [74, 246], [74, 247], [74, 285], [74, 292], [75, 107], [75, 136], [75, 138], [75, 156], [75, 157], [75, 175], [75, 183], [75, 184], [75, 226], [75, 233], [75, 247], [75, 287], [75, 295], [76, 82], [76, 83], [76, 97], [76, 99], [76, 114], [76, 118], [76, 121], [76, 134], [76, 136], [76, 158], [76, 161], [76, 170], [76, 176], [76, 198], [76, 200], [76, 207], [76, 215], [76, 233], [76, 234], [76, 250], [76, 256], [76, 261], [76, 285], [76, 290], [76, 297], [77, 95], [77, 102], [77, 108], [77, 112], [77, 160], [77, 194], [77, 202], [77, 208], [77, 211], [77, 241], [77, 246], [77, 255], [77, 267], [77, 278], [77, 292], [77, 299], [78, 91], [78, 105], [78, 171], [78, 205], [78, 207], [78, 217], [78, 227], [78, 239], [78, 249], [78, 260], [78, 280], [78, 282], [78, 291], [79, 83], [79, 100], [79, 126], [79, 133], [79, 172], [79, 173], [79, 209], [79, 216], [79, 219], [79, 233], [79, 234], [79, 240], [79, 260], [79, 266], [79, 275], [79, 282], [80, 107], [80, 109], [80, 143], [80, 147], [80, 150], [80, 171], [80, 176], [80, 184], [80, 191], [80, 227], [80, 232], [80, 238], [80, 246], [80, 260], [80, 267], [80, 283], [81, 91], [81, 131], [81, 153], [81, 179], [81, 189], [81, 200], [81, 214], [81, 225], [81, 230], [81, 265], [81, 274], [81, 277], [82, 83], [82, 107], [82, 124], [82, 128], [82, 155], [82, 166], [82, 192], [82, 273], [82, 283], [82, 288], [82, 291], [83, 84], [83, 86], [83, 91], [83, 99], [83, 105], [83, 121], [83, 126], [83, 163], [83, 180], [83, 188], [83, 193], [83, 196], [83, 224], [83, 227], [83, 251], [83, 252], [83, 262], [83, 263], [84, 92], [84, 150], [84, 174], [84, 201], [84, 214], [84, 228], [84, 238], [84, 241], [84, 243], [84, 244], [84, 268], [85, 94], [85, 104], [85, 127], [85, 143], [85, 153], [85, 155], [85, 158], [85, 159], [85, 183], [85, 199], [85, 215], [85, 250], [85, 257], [85, 274], [85, 283], [85, 288], [86, 87], [86, 94], [86, 113], [86, 153], [86, 167], [86, 173], [86, 181], [86, 196], [86, 203], [86, 216], [86, 236], [86, 250], [86, 251], [86, 286], [87, 100], [87, 104], [87, 126], [87, 132], [87, 156], [87, 158], [87, 171], [87, 195], [87, 197], [87, 198], [87, 202], [87, 204], [87, 206], [87, 209], [87, 247], [87, 251], [87, 270], [87, 288], [87, 293], [88, 89], [88, 94], [88, 96], [88, 105], [88, 110], [88, 119], [88, 124], [88, 130], [88, 152], [88, 161], [88, 164], [88, 185], [88, 196], [88, 206], [88, 214], [88, 218], [88, 233], [88, 249], [88, 267], [88, 286], [88, 287], [89, 98], [89, 107], [89, 140], [89, 153], [89, 185], [89, 192], [89, 231], [89, 275], [89, 280], [89, 285], [90, 108], [90, 128], [90, 159], [90, 185], [90, 194], [90, 257], [90, 273], [91, 95], [91, 104], [91, 115], [91, 131], [91, 139], [91, 142], [91, 145], [91, 150], [91, 151], [91, 157], [91, 158], [91, 163], [91, 173], [91, 174], [91, 176], [91, 209], [91, 213], [91, 216], [91, 241], [91, 247], [91, 255], [91, 284], [91, 286], [92, 109], [92, 143], [92, 151], [92, 180], [92, 181], [92, 198], [92, 235], [92, 240], [92, 292], [92, 299], [93, 117], [93, 126], [93, 127], [93, 135], [93, 142], [93, 172], [93, 182], [93, 189], [93, 199], [93, 209], [93, 228], [93, 271], [93, 273], [93, 297], [94, 116], [94, 125], [94, 126], [94, 130], [94, 159], [94, 161], [94, 170], [94, 180], [94, 188], [94, 189], [94, 192], [94, 195], [94, 200], [94, 215], [94, 220], [94, 228], [94, 243], [94, 244], [94, 245], [94, 266], [94, 275], [94, 287], [95, 121], [95, 140], [95, 148], [95, 167], [95, 177], [95, 183], [95, 185], [95, 208], [95, 234], [95, 253], [95, 263], [95, 288], [96, 123], [96, 135], [96, 144], [96, 161], [96, 170], [96, 189], [96, 192], [96, 243], [96, 262], [96, 266], [96, 271], [96, 281], [97, 98], [97, 121], [97, 143], [97, 155], [97, 161], [97, 164], [97, 168], [97, 220], [97, 221], [97, 240], [97, 250], [97, 257], [97, 268], [97, 271], [97, 290], [98, 111], [98, 126], [98, 138], [98, 161], [98, 168], [98, 172], [98, 182], [98, 185], [98, 188], [98, 204], [98, 217], [98, 223], [98, 225], [98, 231], [98, 240], [98, 248], [98, 295], [98, 299], [99, 119], [99, 140], [99, 166], [99, 186], [99, 193], [99, 199], [99, 223], [99, 237], [99, 240], [99, 247], [99, 257], [99, 274], [99, 283], [100, 121], [100, 125], [100, 130], [100, 137], [100, 158], [100, 181], [100, 199], [100, 228], [100, 251], [100, 280], [100, 282], [100, 284], [101, 118], [101, 128], [101, 136], [101, 149], [101, 155], [101, 162], [101, 163], [101, 165], [101, 166], [101, 173], [101, 179], [101, 192], [101, 242], [101, 245], [101, 253], [101, 259], [101, 263], [101, 280], [101, 287], [102, 117], [102, 120], [102, 121], [102, 134], [102, 152], [102, 157], [102, 162], [102, 163], [102, 183], [102, 195], [102, 197], [102, 244], [102, 291], [102, 297], [103, 115], [103, 117], [103, 118], [103, 132], [103, 142], [103, 154], [103, 179], [103, 181], [103, 190], [103, 220], [103, 273], [103, 279], [103, 285], [103, 291], [104, 135], [104, 145], [104, 168], [104, 177], [104, 200], [104, 232], [104, 239], [104, 250], [104, 258], [105, 107], [105, 132], [105, 173], [105, 188], [105, 191], [105, 206], [105, 239], [105, 250], [105, 262], [105, 273], [106, 112], [106, 121], [106, 152], [106, 158], [106, 180], [106, 189], [106, 201], [106, 211], [106, 257], [106, 262], [106, 285], [106, 294], [107, 113], [107, 117], [107, 123], [107, 125], [107, 132], [107, 154], [107, 159], [107, 186], [107, 191], [107, 197], [107, 205], [107, 206], [107, 224], [107, 228], [107, 230], [107, 234], [107, 236], [107, 238], [107, 242], [107, 249], [107, 252], [107, 253], [107, 258], [107, 276], [107, 285], [107, 291], [107, 293], [107, 296], [108, 147], [108, 161], [108, 165], [108, 171], [108, 172], [108, 197], [108, 227], [108, 229], [108, 230], [108, 238], [108, 244], [108, 296], [108, 298], [109, 127], [109, 153], [109, 156], [109, 173], [109, 188], [109, 189], [109, 213], [109, 230], [109, 244], [109, 248], [109, 257], [109, 295], [110, 138], [110, 141], [110, 144], [110, 161], [110, 183], [110, 189], [110, 191], [110, 255], [110, 259], [110, 288], [110, 290], [111, 128], [111, 151], [111, 163], [111, 165], [111, 171], [111, 181], [111, 198], [111, 228], [111, 267], [111, 276], [112, 138], [112, 160], [112, 182], [112, 184], [112, 239], [112, 241], [112, 254], [112, 263], [112, 271], [112, 276], [112, 289], [113, 147], [113, 175], [113, 180], [113, 274], [113, 279], [113, 281], [114, 116], [114, 124], [114, 130], [114, 197], [114, 268], [115, 121], [115, 136], [115, 141], [115, 163], [115, 167], [115, 168], [115, 202], [115, 204], [115, 218], [115, 261], [115, 263], [115, 273], [116, 120], [116, 137], [116, 140], [116, 164], [116, 198], [116, 245], [116, 268], [116, 270], [117, 147], [117, 157], [117, 179], [117, 192], [117, 209], [117, 220], [117, 240], [117, 298], [118, 134], [118, 143], [118, 160], [118, 174], [118, 175], [118, 179], [118, 181], [118, 192], [118, 200], [118, 209], [118, 217], [118, 231], [118, 257], [118, 264], [118, 265], [118, 276], [118, 293], [119, 132], [119, 156], [119, 163], [119, 183], [119, 187], [119, 199], [119, 204], [119, 222], [119, 242], [119, 255], [119, 268], [120, 160], [120, 179], [120, 208], [120, 225], [120, 232], [120, 243], [120, 251], [120, 261], [120, 268], [120, 270], [120, 282], [121, 131], [121, 162], [121, 174], [121, 185], [121, 277], [122, 213], [122, 218], [122, 245], [122, 252], [122, 257], [122, 262], [122, 276], [122, 298], [123, 126], [123, 129], [123, 136], [123, 156], [123, 170], [123, 179], [123, 227], [123, 244], [123, 275], [123, 292], [123, 294], [124, 129], [124, 131], [124, 140], [124, 141], [124, 149], [124, 162], [124, 223], [124, 226], [124, 233], [124, 236], [124, 238], [124, 252], [124, 264], [124, 273], [124, 275], [124, 288], [125, 140], [125, 155], [125, 178], [125, 182], [125, 189], [125, 217], [125, 222], [125, 225], [125, 245], [125, 280], [125, 283], [125, 284], [125, 299], [126, 151], [126, 173], [126, 188], [126, 203], [126, 212], [126, 217], [126, 246], [126, 247], [127, 136], [127, 179], [127, 182], [127, 201], [127, 203], [127, 223], [127, 239], [127, 279], [127, 291], [128, 133], [128, 137], [128, 138], [128, 142], [128, 144], [128, 157], [128, 180], [128, 208], [128, 211], [128, 225], [128, 245], [128, 271], [128, 274], [128, 298], [129, 151], [129, 168], [129, 181], [129, 189], [129, 210], [129, 220], [129, 223], [129, 241], [129, 248], [129, 272], [129, 285], [129, 296], [130, 139], [130, 181], [130, 210], [130, 229], [130, 238], [130, 243], [130, 254], [130, 284], [131, 138], [131, 140], [131, 155], [131, 205], [131, 209], [131, 233], [131, 239], [131, 252], [131, 261], [131, 282], [131, 283], [131, 287], [131, 298], [132, 156], [132, 157], [132, 179], [132, 185], [132, 233], [132, 254], [132, 282], [132, 283], [132, 284], [133, 161], [133, 162], [133, 166], [133, 176], [133, 203], [133, 221], [133, 236], [133, 248], [133, 289], [134, 135], [134, 197], [134, 198], [134, 202], [134, 243], [134, 254], [135, 143], [135, 174], [135, 179], [135, 204], [135, 225], [135, 232], [135, 242], [135, 271], [135, 291], [135, 292], [135, 294], [136, 141], [136, 143], [136, 158], [136, 169], [136, 170], [136, 196], [136, 203], [136, 212], [136, 215], [136, 218], [136, 245], [136, 250], [136, 258], [136, 262], [136, 292], [137, 153], [137, 165], [137, 169], [137, 171], [137, 183], [137, 194], [137, 208], [137, 218], [137, 222], [137, 226], [137, 240], [137, 262], [137, 267], [137, 269], [137, 271], [137, 291], [138, 175], [138, 190], [138, 191], [138, 198], [138, 202], [138, 219], [138, 228], [138, 230], [138, 255], [138, 293], [139, 148], [139, 168], [139, 204], [139, 213], [139, 226], [139, 255], [139, 272], [139, 288], [140, 149], [140, 152], [140, 160], [140, 171], [140, 173], [140, 175], [140, 208], [140, 225], [140, 232], [140, 245], [140, 273], [140, 289], [141, 149], [141, 186], [141, 207], [141, 243], [141, 250], [141, 286], [142, 160], [142, 192], [142, 197], [142, 211], [142, 214], [142, 248], [142, 285], [142, 293], [143, 158], [143, 164], [143, 203], [143, 208], [143, 214], [143, 239], [143, 259], [143, 266], [143, 281], [144, 161], [144, 170], [144, 189], [144, 194], [144, 209], [144, 231], [144, 239], [144, 247], [144, 269], [144, 271], [144, 274], [144, 278], [144, 294], [145, 153], [145, 164], [145, 165], [145, 188], [145, 212], [145, 224], [145, 230], [145, 240], [145, 294], [146, 156], [146, 167], [146, 169], [146, 181], [146, 189], [146, 218], [146, 226], [146, 232], [146, 251], [146, 253], [146, 254], [146, 257], [146, 267], [146, 299], [147, 155], [147, 160], [147, 163], [147, 164], [147, 178], [147, 193], [147, 218], [147, 251], [147, 290], [147, 294], [147, 295], [147, 297], [148, 153], [148, 159], [148, 197], [148, 209], [148, 221], [148, 228], [148, 246], [148, 268], [148, 291], [148, 297], [149, 150], [149, 165], [149, 168], [149, 175], [149, 187], [149, 191], [149, 232], [149, 238], [149, 240], [149, 247], [149, 253], [149, 261], [149, 275], [150, 170], [150, 183], [150, 216], [150, 243], [150, 245], [150, 249], [150, 267], [151, 152], [151, 175], [151, 181], [151, 192], [151, 217], [151, 223], [151, 237], [151, 240], [151, 241], [151, 269], [151, 280], [151, 291], [152, 161], [152, 211], [152, 227], [152, 245], [152, 247], [152, 252], [152, 269], [152, 298], [153, 161], [153, 166], [153, 195], [153, 204], [153, 209], [153, 218], [153, 235], [153, 250], [153, 288], [154, 169], [154, 171], [154, 187], [154, 190], [154, 219], [154, 241], [154, 243], [154, 252], [154, 263], [154, 291], [155, 191], [155, 238], [155, 245], [155, 280], [155, 292], [156, 177], [156, 216], [156, 223], [156, 224], [156, 225], [156, 234], [156, 236], [156, 238], [156, 271], [156, 279], [156, 283], [157, 185], [157, 214], [157, 218], [157, 245], [157, 270], [158, 186], [158, 205], [158, 215], [158, 224], [158, 232], [158, 247], [158, 275], [159, 168], [159, 222], [159, 260], [159, 262], [159, 274], [160, 167], [160, 172], [160, 188], [160, 214], [160, 216], [160, 235], [160, 239], [160, 240], [160, 259], [160, 270], [160, 287], [161, 162], [161, 167], [161, 173], [161, 186], [161, 190], [161, 194], [161, 198], [161, 208], [161, 218], [161, 227], [161, 231], [161, 236], [161, 265], [161, 266], [161, 276], [161, 286], [161, 293], [162, 165], [162, 182], [162, 186], [162, 205], [162, 222], [162, 250], [162, 268], [162, 299], [163, 238], [163, 253], [163, 257], [163, 291], [164, 166], [164, 170], [164, 180], [164, 199], [164, 200], [164, 203], [164, 207], [164, 219], [164, 228], [164, 230], [164, 233], [164, 255], [164, 261], [164, 265], [164, 272], [164, 280], [164, 283], [165, 177], [165, 208], [165, 214], [165, 239], [165, 247], [165, 256], [165, 257], [165, 273], [165, 296], [165, 297], [166, 171], [166, 172], [166, 175], [166, 177], [166, 193], [166, 196], [166, 228], [166, 232], [166, 235], [166, 237], [166, 254], [166, 260], [166, 263], [166, 266], [166, 285], [166, 290], [166, 299], [167, 178], [167, 181], [167, 189], [167, 190], [167, 214], [167, 273], [167, 277], [167, 280], [167, 286], [168, 170], [168, 181], [168, 190], [168, 206], [168, 221], [168, 252], [168, 257], [168, 259], [168, 274], [168, 278], [169, 204], [169, 207], [169, 212], [169, 222], [169, 240], [169, 255], [169, 268], [170, 172], [170, 236], [170, 249], [171, 175], [171, 196], [171, 205], [171, 208], [171, 223], [171, 227], [171, 297], [172, 197], [172, 237], [172, 257], [172, 288], [172, 290], [173, 174], [173, 180], [173, 186], [173, 219], [173, 223], [173, 247], [173, 252], [173, 266], [173, 268], [173, 275], [174, 199], [174, 201], [174, 218], [174, 239], [174, 251], [174, 282], [175, 184], [175, 195], [175, 238], [175, 245], [175, 267], [175, 278], [175, 285], [175, 299], [176, 183], [176, 206], [176, 207], [176, 208], [176, 213], [176, 225], [176, 243], [176, 267], [176, 272], [176, 277], [176, 281], [176, 296], [176, 299], [177, 179], [177, 201], [177, 227], [177, 248], [178, 198], [178, 232], [178, 243], [178, 277], [178, 278], [178, 295], [179, 193], [179, 194], [179, 232], [179, 252], [179, 257], [180, 193], [180, 195], [180, 208], [180, 221], [180, 222], [180, 229], [180, 233], [180, 241], [180, 251], [180, 281], [180, 292], [180, 298], [180, 299], [181, 182], [181, 187], [181, 198], [181, 209], [181, 216], [181, 220], [181, 225], [181, 232], [181, 254], [181, 256], [181, 258], [181, 272], [181, 273], [181, 297], [182, 216], [182, 223], [182, 231], [182, 246], [182, 269], [182, 271], [182, 298], [183, 185], [183, 213], [183, 257], [183, 285], [183, 287], [184, 199], [184, 245], [184, 267], [184, 272], [184, 283], [185, 195], [185, 197], [185, 229], [185, 230], [185, 233], [185, 247], [185, 254], [185, 267], [185, 272], [185, 288], [185, 290], [185, 295], [186, 214], [186, 223], [186, 239], [186, 243], [186, 244], [186, 283], [186, 299], [187, 210], [187, 272], [187, 274], [187, 288], [187, 293], [188, 198], [188, 200], [188, 206], [188, 214], [188, 234], [188, 256], [188, 273], [188, 299], [189, 193], [189, 201], [189, 206], [189, 209], [189, 214], [189, 248], [189, 258], [189, 274], [189, 275], [189, 276], [189, 282], [189, 283], [189, 295], [190, 196], [190, 228], [190, 236], [190, 237], [190, 241], [190, 246], [190, 249], [190, 265], [191, 206], [191, 215], [191, 225], [191, 240], [191, 247], [191, 268], [191, 274], [191, 280], [191, 286], [191, 288], [191, 296], [193, 199], [193, 213], [193, 218], [193, 229], [193, 232], [193, 245], [193, 251], [193, 253], [193, 254], [193, 275], [193, 277], [193, 281], [193, 282], [193, 296], [194, 224], [194, 236], [194, 259], [194, 271], [194, 286], [194, 299], [195, 196], [195, 201], [195, 204], [195, 222], [195, 251], [195, 257], [195, 298], [196, 222], [196, 225], [196, 233], [196, 236], [196, 242], [196, 256], [196, 257], [196, 297], [197, 201], [197, 207], [197, 238], [197, 269], [197, 274], [198, 204], [198, 235], [198, 260], [198, 270], [198, 282], [198, 287], [199, 216], [199, 252], [199, 257], [199, 272], [200, 205], [200, 206], [200, 220], [200, 249], [200, 251], [200, 255], [200, 273], [200, 295], [201, 245], [201, 247], [201, 271], [202, 207], [202, 220], [202, 222], [202, 224], [202, 229], [202, 266], [202, 273], [202, 291], [203, 206], [203, 208], [203, 257], [203, 259], [203, 283], [204, 209], [204, 210], [204, 220], [204, 228], [204, 231], [204, 238], [204, 259], [205, 249], [205, 251], [205, 263], [205, 288], [206, 276], [207, 211], [207, 227], [207, 228], [207, 285], [207, 296], [207, 299], [208, 212], [208, 229], [208, 256], [208, 264], [208, 265], [208, 286], [208, 298], [209, 217], [209, 222], [209, 230], [209, 238], [209, 259], [209, 262], [209, 279], [209, 291], [210, 212], [210, 230], [210, 240], [210, 241], [210, 264], [210, 287], [211, 215], [211, 228], [211, 232], [211, 236], [211, 258], [212, 245], [212, 266], [212, 274], [212, 276], [212, 277], [213, 227], [213, 229], [213, 247], [213, 257], [213, 266], [213, 267], [213, 273], [213, 275], [214, 243], [214, 244], [214, 270], [215, 217], [215, 236], [215, 254], [215, 256], [215, 262], [216, 238], [216, 247], [216, 254], [216, 268], [216, 275], [217, 227], [217, 243], [217, 249], [217, 271], [217, 282], [218, 232], [218, 234], [218, 265], [219, 228], [219, 245], [219, 275], [219, 291], [220, 224], [220, 225], [220, 234], [220, 236], [220, 249], [220, 256], [220, 270], [220, 287], [221, 225], [221, 235], [221, 245], [221, 247], [221, 250], [221, 269], [221, 274], [221, 284], [221, 293], [222, 232], [222, 257], [222, 258], [222, 263], [222, 270], [222, 291], [223, 262], [223, 266], [223, 282], [224, 236], [224, 255], [224, 261], [224, 268], [224, 289], [225, 231], [225, 245], [225, 247], [225, 250], [225, 260], [225, 266], [225, 271], [225, 283], [225, 294], [226, 243], [226, 262], [226, 284], [226, 285], [226, 295], [227, 250], [227, 251], [227, 272], [228, 246], [228, 275], [229, 246], [229, 274], [229, 296], [230, 254], [230, 257], [230, 260], [231, 234], [231, 240], [231, 264], [231, 270], [231, 288], [231, 290], [232, 275], [232, 283], [232, 297], [233, 250], [233, 260], [234, 237], [234, 244], [234, 249], [234, 261], [234, 273], [234, 275], [234, 277], [234, 283], [234, 291], [234, 294], [234, 298], [235, 242], [235, 265], [235, 274], [235, 284], [235, 292], [236, 242], [236, 248], [236, 260], [236, 288], [236, 292], [237, 260], [237, 262], [237, 277], [237, 283], [238, 243], [238, 271], [238, 281], [238, 291], [238, 293], [239, 249], [239, 275], [240, 252], [240, 294], [240, 296], [241, 247], [241, 255], [241, 270], [241, 283], [241, 289], [242, 270], [243, 266], [243, 273], [243, 275], [243, 279], [243, 287], [244, 245], [244, 288], [245, 248], [245, 267], [245, 282], [245, 285], [245, 288], [247, 272], [247, 276], [247, 282], [247, 290], [247, 295], [247, 296], [248, 250], [248, 257], [248, 262], [248, 267], [248, 287], [248, 290], [249, 285], [249, 297], [250, 256], [250, 269], [250, 276], [251, 267], [251, 274], [251, 277], [252, 256], [252, 259], [252, 272], [252, 278], [252, 293], [253, 258], [253, 280], [253, 291], [254, 274], [255, 272], [255, 281], [255, 282], [255, 293], [256, 266], [256, 270], [256, 277], [257, 279], [257, 289], [257, 295], [257, 299], [258, 266], [258, 284], [259, 272], [259, 281], [259, 294], [260, 261], [260, 266], [260, 284], [261, 274], [261, 283], [262, 291], [263, 267], [263, 277], [263, 285], [263, 288], [263, 290], [264, 282], [264, 293], [266, 269], [266, 274], [266, 282], [267, 287], [267, 298], [268, 282], [268, 289], [270, 280], [270, 282], [272, 274], [272, 285], [272, 288], [273, 279], [274, 276], [275, 289], [275, 292], [276, 280], [278, 286], [279, 291], [279, 297], [280, 283], [280, 289], [280, 294], [280, 296], [281, 287], [281, 294], [282, 297], [283, 287], [283, 289], [287, 290], [288, 290], [291, 299], [292, 297], [294, 299], [295, 296]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l6-s4/tests/run.py b/tasks/construct-nppc-dominating-set-l6-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-dominating-set-l6-s4/tests/test.sh b/tasks/construct-nppc-dominating-set-l6-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-independent-set-l3-s5/environment/Dockerfile b/tasks/construct-nppc-independent-set-l3-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-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-nppc-independent-set-l3-s5/environment/instance.json b/tasks/construct-nppc-independent-set-l3-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aefec35f1fe3084f93d82dd07cbaff6f459bb720 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s5/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 7], [0, 11], [0, 12], [0, 16], [0, 17], [0, 18], [1, 3], [1, 12], [1, 13], [2, 3], [2, 4], [2, 5], [2, 7], [2, 9], [2, 11], [2, 12], [2, 13], [2, 15], [2, 16], [2, 20], [2, 22], [3, 5], [3, 8], [3, 10], [3, 11], [3, 13], [3, 14], [3, 16], [3, 17], [3, 18], [3, 19], [3, 21], [3, 23], [4, 7], [4, 8], [4, 11], [4, 18], [5, 11], [5, 12], [5, 13], [5, 14], [5, 16], [5, 18], [6, 7], [6, 8], [6, 10], [6, 12], [6, 13], [6, 14], [6, 18], [7, 10], [7, 12], [7, 13], [7, 15], [7, 17], [7, 20], [7, 21], [7, 22], [7, 23], [8, 10], [8, 11], [8, 16], [8, 17], [8, 20], [8, 21], [8, 23], [9, 10], [9, 11], [10, 11], [10, 15], [10, 16], [10, 19], [10, 20], [10, 23], [11, 13], [11, 16], [11, 17], [11, 18], [11, 19], [11, 22], [11, 23], [12, 14], [12, 15], [12, 17], [12, 20], [13, 20], [13, 21], [13, 22], [14, 15], [14, 16], [14, 21], [14, 22], [15, 16], [16, 17], [16, 23], [17, 18], [17, 19], [17, 23], [18, 20], [18, 21], [18, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s5/solution/solve.sh b/tasks/construct-nppc-independent-set-l3-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f69a80079fa0cadfaf2da804a6c73206a1649afa --- /dev/null +++ b/tasks/construct-nppc-independent-set-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' +{"independent_set": [0, 1, 4, 5, 6, 9, 15, 19, 20, 21, 22, 23]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l3-s5/tests/check.py b/tasks/construct-nppc-independent-set-l3-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s5/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-s5/tests/instance.json b/tasks/construct-nppc-independent-set-l3-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aefec35f1fe3084f93d82dd07cbaff6f459bb720 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s5/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 7], [0, 11], [0, 12], [0, 16], [0, 17], [0, 18], [1, 3], [1, 12], [1, 13], [2, 3], [2, 4], [2, 5], [2, 7], [2, 9], [2, 11], [2, 12], [2, 13], [2, 15], [2, 16], [2, 20], [2, 22], [3, 5], [3, 8], [3, 10], [3, 11], [3, 13], [3, 14], [3, 16], [3, 17], [3, 18], [3, 19], [3, 21], [3, 23], [4, 7], [4, 8], [4, 11], [4, 18], [5, 11], [5, 12], [5, 13], [5, 14], [5, 16], [5, 18], [6, 7], [6, 8], [6, 10], [6, 12], [6, 13], [6, 14], [6, 18], [7, 10], [7, 12], [7, 13], [7, 15], [7, 17], [7, 20], [7, 21], [7, 22], [7, 23], [8, 10], [8, 11], [8, 16], [8, 17], [8, 20], [8, 21], [8, 23], [9, 10], [9, 11], [10, 11], [10, 15], [10, 16], [10, 19], [10, 20], [10, 23], [11, 13], [11, 16], [11, 17], [11, 18], [11, 19], [11, 22], [11, 23], [12, 14], [12, 15], [12, 17], [12, 20], [13, 20], [13, 21], [13, 22], [14, 15], [14, 16], [14, 21], [14, 22], [15, 16], [16, 17], [16, 23], [17, 18], [17, 19], [17, 23], [18, 20], [18, 21], [18, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s5/tests/run.py b/tasks/construct-nppc-independent-set-l3-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-independent-set-l3-s5/tests/test.sh b/tasks/construct-nppc-independent-set-l3-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-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-nppc-quad-diophantine-l1-s1/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l1-s1/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..60de6920c91826939d82ee522cdee6e6d3947bea --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l1-s1/environment/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-l2-s3/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l2-s3/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..33ee0f785406e87d54771476e8b09e9f2b6db824 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"a": 600, "b": 237, "c": 20676252, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s3/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3d4bdf79ff6311ab690d00c80ca1cfc8d7610530 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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": 185, "y": 596} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l2-s3/tests/check.py b/tasks/construct-nppc-quad-diophantine-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s3/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-s3/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..33ee0f785406e87d54771476e8b09e9f2b6db824 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"a": 600, "b": 237, "c": 20676252, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s3/tests/run.py b/tasks/construct-nppc-quad-diophantine-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l2-s3/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l5-s9/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l5-s9/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a72ed30325ea8d1decb23224001ecd6316453cf9 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"a": 8800349, "b": 6412954, "c": 2190197601323440210, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l5-s9/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1729b56b625502aaaf3dafb62930de3497b8eeef --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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' +{"x": 498868, "y": 9522821} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l5-s9/tests/check.py b/tasks/construct-nppc-quad-diophantine-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l5-s9/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l5-s9/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a72ed30325ea8d1decb23224001ecd6316453cf9 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"a": 8800349, "b": 6412954, "c": 2190197601323440210, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l5-s9/tests/run.py b/tasks/construct-nppc-quad-diophantine-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l5-s9/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l6-s2/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l6-s2/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4a23ccfd21505cf9b6aec22fbd9e4795079bc1c0 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"a": 1237432915, "b": 1095508825, "c": 67618899370475198423419290835, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s2/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f7508be59a0b7030df269908ddb2da32b7cac80c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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' +{"x": 7392191632, "y": 4887119115} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l6-s2/tests/check.py b/tasks/construct-nppc-quad-diophantine-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s2/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l6-s2/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4a23ccfd21505cf9b6aec22fbd9e4795079bc1c0 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"a": 1237432915, "b": 1095508825, "c": 67618899370475198423419290835, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s2/tests/run.py b/tasks/construct-nppc-quad-diophantine-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l6-s2/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l6-s5/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l6-s5/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..80162ccface06532c4f700b9bd7e3c09ab29e9f3 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"a": 9827784743, "b": 1297521230, "c": 170925871072130354043696519463, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s5/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..958165f3cf7cef81cabe8fbf035ab59ee0acaf25 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 4170384359, "y": 5716432456} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l6-s5/tests/check.py b/tasks/construct-nppc-quad-diophantine-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s5/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l6-s5/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..80162ccface06532c4f700b9bd7e3c09ab29e9f3 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"a": 9827784743, "b": 1297521230, "c": 170925871072130354043696519463, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s5/tests/run.py b/tasks/construct-nppc-quad-diophantine-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l6-s5/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quadratic-congruence-l1-s1/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l1-s1/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bdb4d7f88b2b637df6f7f302aceac575a6c456e7 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"a": 9, "b": 18, "c": 137, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l1-s1/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..472c4be857beb48959bcae20fb2dcd3fe1476b5d --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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": 69} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l1-s1/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l1-s1/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l1-s1/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bdb4d7f88b2b637df6f7f302aceac575a6c456e7 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"a": 9, "b": 18, "c": 137, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l1-s1/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l1-s1/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l2-s4/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l2-s4/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..477b86cc1992819f9a4f8dd5410c557b8e526691 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"a": 0, "b": 147, "c": 13114, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s4/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..448bc18599658ef691fa83bbb4eab6fc4a2fe940 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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": 6174} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s4/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s4/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-s4/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..477b86cc1992819f9a4f8dd5410c557b8e526691 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"a": 0, "b": 147, "c": 13114, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s4/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l2-s4/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l5-s9/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l5-s9/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..45edec22a028d7c6a0e7da9f0661ebe673aa5c3f --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"a": 3958282488698417668, "b": 7575469236806246299, "c": 7102530124532258728, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l5-s9/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..23c1c2f89fd6685f0d3a294d0b529d1ddbeaf0cd --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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' +{"x": 7097494890560016282} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l5-s9/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l5-s9/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l5-s9/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..45edec22a028d7c6a0e7da9f0661ebe673aa5c3f --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"a": 3958282488698417668, "b": 7575469236806246299, "c": 7102530124532258728, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l5-s9/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l5-s9/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l6-s2/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l6-s2/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fd9434e156744801849490d196938bf3782837d7 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"a": 116757058586784956845388387762449504413262155501, "b": 163682378999643305001128986687253590802264586097, "c": 157691229587311232391096340338894324214503389407, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s2/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f10737aee52d8d21baf1d1b8f4780097c1f2538a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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' +{"x": 157684794827699656837768561542320876530022839838} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s2/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s2/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s2/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fd9434e156744801849490d196938bf3782837d7 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"a": 116757058586784956845388387762449504413262155501, "b": 163682378999643305001128986687253590802264586097, "c": 157691229587311232391096340338894324214503389407, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s2/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l6-s2/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l6-s5/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l6-s5/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fee33ce10897616c9fe76202c754c4588b82ae7b --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"a": 80528802366340258782383235369770509707082011454, "b": 157897939657185658163447453336584125604239801029, "c": 99545841375422446286744653121014064371677176364, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s5/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bc9b58ab6b5f80a1bb655c86ac467e444e460f3e --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 99540853897249993691539252562013622436228496156} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s5/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s5/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s5/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fee33ce10897616c9fe76202c754c4588b82ae7b --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"a": 80528802366340258782383235369770509707082011454, "b": 157897939657185658163447453336584125604239801029, "c": 99545841375422446286744653121014064371677176364, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s5/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l6-s5/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-vertex-cover-l4-s0/environment/Dockerfile b/tasks/construct-nppc-vertex-cover-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l4-s0/environment/instance.json b/tasks/construct-nppc-vertex-cover-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6c010529cbed665c2b6e1b459df9d8008e57c27e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 6], [0, 9], [0, 11], [0, 17], [0, 19], [0, 21], [0, 24], [0, 25], [0, 26], [0, 30], [0, 31], [0, 35], [0, 37], [1, 3], [1, 5], [1, 6], [1, 7], [1, 9], [1, 10], [1, 11], [1, 13], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 31], [1, 32], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [2, 11], [2, 12], [2, 13], [2, 17], [2, 24], [2, 25], [2, 26], [2, 38], [3, 6], [3, 7], [3, 11], [3, 17], [3, 19], [3, 25], [3, 30], [3, 37], [3, 39], [4, 7], [4, 12], [4, 13], [4, 21], [4, 23], [4, 26], [4, 30], [4, 39], [5, 6], [5, 7], [5, 9], [5, 12], [5, 19], [5, 23], [5, 24], [5, 25], [5, 26], [5, 30], [5, 37], [5, 39], [6, 7], [6, 8], [6, 9], [6, 10], [6, 12], [6, 13], [6, 15], [6, 17], [6, 18], [6, 20], [6, 21], [6, 22], [6, 23], [6, 24], [6, 25], [6, 28], [6, 29], [6, 33], [6, 35], [6, 37], [6, 38], [6, 39], [7, 8], [7, 9], [7, 11], [7, 12], [7, 13], [7, 16], [7, 17], [7, 21], [7, 22], [7, 23], [7, 24], [7, 27], [7, 28], [7, 29], [7, 34], [7, 35], [7, 38], [7, 39], [8, 13], [8, 17], [8, 19], [8, 24], [8, 30], [8, 31], [8, 35], [8, 37], [9, 11], [9, 12], [9, 13], [9, 15], [9, 17], [9, 18], [9, 19], [9, 21], [9, 23], [9, 24], [9, 25], [9, 29], [9, 30], [9, 32], [9, 33], [9, 36], [9, 39], [10, 11], [10, 13], [10, 17], [10, 21], [10, 24], [10, 26], [10, 30], [10, 35], [10, 37], [10, 38], [11, 12], [11, 16], [11, 17], [11, 19], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 31], [11, 32], [11, 33], [11, 35], [11, 36], [11, 37], [11, 38], [11, 39], [12, 13], [12, 14], [12, 15], [12, 17], [12, 18], [12, 19], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 30], [12, 32], [12, 37], [12, 38], [13, 16], [13, 17], [13, 19], [13, 21], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 30], [13, 31], [13, 33], [13, 35], [13, 37], [13, 38], [14, 17], [14, 19], [14, 21], [14, 23], [14, 24], [14, 25], [14, 26], [14, 31], [14, 37], [15, 17], [15, 23], [15, 24], [15, 26], [15, 30], [15, 31], [15, 38], [16, 31], [16, 35], [16, 37], [17, 19], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [17, 31], [17, 34], [17, 37], [17, 38], [17, 39], [18, 24], [18, 26], [18, 38], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 28], [19, 29], [19, 30], [19, 31], [19, 32], [19, 33], [19, 35], [19, 36], [19, 37], [19, 38], [19, 39], [20, 21], [20, 23], [20, 26], [20, 30], [20, 35], [20, 39], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 35], [21, 39], [22, 25], [22, 26], [22, 30], [22, 31], [22, 35], [22, 38], [23, 26], [23, 27], [23, 29], [23, 30], [23, 31], [23, 33], [23, 34], [23, 35], [23, 37], [23, 38], [23, 39], [24, 25], [24, 26], [24, 28], [24, 29], [24, 32], [24, 34], [24, 35], [24, 37], [24, 38], [24, 39], [25, 26], [25, 29], [25, 30], [25, 32], [25, 34], [25, 36], [25, 38], [26, 28], [26, 29], [26, 31], [26, 32], [26, 34], [26, 35], [26, 37], [26, 38], [27, 30], [27, 31], [27, 38], [27, 39], [28, 30], [28, 31], [28, 37], [28, 38], [29, 30], [29, 31], [29, 38], [30, 31], [30, 34], [30, 35], [30, 36], [30, 37], [30, 38], [30, 39], [31, 33], [31, 34], [31, 35], [31, 37], [31, 38], [32, 35], [32, 38], [33, 35], [33, 38], [34, 35], [34, 38], [34, 39], [35, 36], [35, 37], [35, 38], [35, 39], [36, 37], [36, 38], [37, 38], [37, 39], [38, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s0/solution/solve.sh b/tasks/construct-nppc-vertex-cover-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8b9c32ccb2bf8132ffea0284d38e1ca5896aa60d --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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' +{"cover": [1, 6, 7, 9, 11, 12, 13, 17, 19, 21, 23, 24, 25, 26, 30, 31, 35, 37, 38, 39]} +RLMATH_EOF diff --git a/tasks/construct-nppc-vertex-cover-l4-s0/tests/check.py b/tasks/construct-nppc-vertex-cover-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d8ed740cc660c4837d941a8d70ea394c3bc9f69e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s0/tests/check.py @@ -0,0 +1,18 @@ +"""Vertex cover of size <= k. Accepts any valid cover.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier converts to a set without type checks (floats/bools slip through and + # duplicates are silently merged); here entries must be distinct ints in range + c = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(c)) != len(c): + raise Invalid("cover contains duplicates") + if len(c) > k: + raise Invalid(f"cover has {len(c)} > {k} vertices") + s = set(c) + for u, v in inst["edges"]: + if u not in s and v not in s: + raise Invalid(f"edge ({u},{v}) not covered") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-vertex-cover-l4-s0/tests/instance.json b/tasks/construct-nppc-vertex-cover-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6c010529cbed665c2b6e1b459df9d8008e57c27e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 6], [0, 9], [0, 11], [0, 17], [0, 19], [0, 21], [0, 24], [0, 25], [0, 26], [0, 30], [0, 31], [0, 35], [0, 37], [1, 3], [1, 5], [1, 6], [1, 7], [1, 9], [1, 10], [1, 11], [1, 13], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 31], [1, 32], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [2, 11], [2, 12], [2, 13], [2, 17], [2, 24], [2, 25], [2, 26], [2, 38], [3, 6], [3, 7], [3, 11], [3, 17], [3, 19], [3, 25], [3, 30], [3, 37], [3, 39], [4, 7], [4, 12], [4, 13], [4, 21], [4, 23], [4, 26], [4, 30], [4, 39], [5, 6], [5, 7], [5, 9], [5, 12], [5, 19], [5, 23], [5, 24], [5, 25], [5, 26], [5, 30], [5, 37], [5, 39], [6, 7], [6, 8], [6, 9], [6, 10], [6, 12], [6, 13], [6, 15], [6, 17], [6, 18], [6, 20], [6, 21], [6, 22], [6, 23], [6, 24], [6, 25], [6, 28], [6, 29], [6, 33], [6, 35], [6, 37], [6, 38], [6, 39], [7, 8], [7, 9], [7, 11], [7, 12], [7, 13], [7, 16], [7, 17], [7, 21], [7, 22], [7, 23], [7, 24], [7, 27], [7, 28], [7, 29], [7, 34], [7, 35], [7, 38], [7, 39], [8, 13], [8, 17], [8, 19], [8, 24], [8, 30], [8, 31], [8, 35], [8, 37], [9, 11], [9, 12], [9, 13], [9, 15], [9, 17], [9, 18], [9, 19], [9, 21], [9, 23], [9, 24], [9, 25], [9, 29], [9, 30], [9, 32], [9, 33], [9, 36], [9, 39], [10, 11], [10, 13], [10, 17], [10, 21], [10, 24], [10, 26], [10, 30], [10, 35], [10, 37], [10, 38], [11, 12], [11, 16], [11, 17], [11, 19], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 31], [11, 32], [11, 33], [11, 35], [11, 36], [11, 37], [11, 38], [11, 39], [12, 13], [12, 14], [12, 15], [12, 17], [12, 18], [12, 19], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 30], [12, 32], [12, 37], [12, 38], [13, 16], [13, 17], [13, 19], [13, 21], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 30], [13, 31], [13, 33], [13, 35], [13, 37], [13, 38], [14, 17], [14, 19], [14, 21], [14, 23], [14, 24], [14, 25], [14, 26], [14, 31], [14, 37], [15, 17], [15, 23], [15, 24], [15, 26], [15, 30], [15, 31], [15, 38], [16, 31], [16, 35], [16, 37], [17, 19], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [17, 31], [17, 34], [17, 37], [17, 38], [17, 39], [18, 24], [18, 26], [18, 38], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 28], [19, 29], [19, 30], [19, 31], [19, 32], [19, 33], [19, 35], [19, 36], [19, 37], [19, 38], [19, 39], [20, 21], [20, 23], [20, 26], [20, 30], [20, 35], [20, 39], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 35], [21, 39], [22, 25], [22, 26], [22, 30], [22, 31], [22, 35], [22, 38], [23, 26], [23, 27], [23, 29], [23, 30], [23, 31], [23, 33], [23, 34], [23, 35], [23, 37], [23, 38], [23, 39], [24, 25], [24, 26], [24, 28], [24, 29], [24, 32], [24, 34], [24, 35], [24, 37], [24, 38], [24, 39], [25, 26], [25, 29], [25, 30], [25, 32], [25, 34], [25, 36], [25, 38], [26, 28], [26, 29], [26, 31], [26, 32], [26, 34], [26, 35], [26, 37], [26, 38], [27, 30], [27, 31], [27, 38], [27, 39], [28, 30], [28, 31], [28, 37], [28, 38], [29, 30], [29, 31], [29, 38], [30, 31], [30, 34], [30, 35], [30, 36], [30, 37], [30, 38], [30, 39], [31, 33], [31, 34], [31, 35], [31, 37], [31, 38], [32, 35], [32, 38], [33, 35], [33, 38], [34, 35], [34, 38], [34, 39], [35, 36], [35, 37], [35, 38], [35, 39], [36, 37], [36, 38], [37, 38], [37, 39], [38, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s0/tests/run.py b/tasks/construct-nppc-vertex-cover-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l4-s0/tests/test.sh b/tasks/construct-nppc-vertex-cover-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l4-s7/environment/Dockerfile b/tasks/construct-nppc-vertex-cover-l4-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l4-s7/environment/instance.json b/tasks/construct-nppc-vertex-cover-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3751782de94d0be09a49142208814e6d1de67fdd --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 2], [0, 3], [0, 4], [0, 7], [0, 8], [0, 9], [0, 11], [0, 13], [0, 15], [0, 16], [0, 17], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 27], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [0, 37], [0, 39], [1, 4], [1, 7], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 24], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 34], [1, 39], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 17], [2, 20], [2, 22], [2, 23], [2, 24], [2, 25], [2, 27], [2, 30], [2, 31], [2, 35], [2, 36], [2, 37], [2, 38], [2, 39], [3, 6], [3, 7], [3, 10], [3, 13], [3, 23], [3, 29], [3, 30], [3, 37], [4, 5], [4, 7], [4, 10], [4, 11], [4, 12], [4, 15], [4, 19], [4, 22], [4, 23], [4, 26], [4, 28], [4, 29], [4, 30], [4, 31], [4, 33], [5, 8], [5, 10], [5, 13], [5, 24], [5, 27], [5, 30], [5, 33], [5, 39], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 13], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [6, 27], [6, 29], [6, 30], [6, 32], [6, 33], [6, 35], [6, 37], [6, 39], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 14], [7, 15], [7, 17], [7, 18], [7, 19], [7, 20], [7, 22], [7, 23], [7, 24], [7, 27], [7, 29], [7, 30], [7, 33], [7, 34], [7, 36], [7, 37], [7, 38], [7, 39], [8, 9], [8, 10], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 20], [8, 21], [8, 23], [8, 24], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [8, 36], [8, 38], [8, 39], [9, 10], [9, 11], [9, 17], [9, 19], [9, 23], [9, 27], [9, 29], [9, 33], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 23], [10, 27], [10, 28], [10, 30], [10, 33], [10, 34], [10, 37], [10, 39], [11, 13], [11, 17], [11, 19], [11, 21], [11, 23], [11, 24], [11, 26], [11, 27], [11, 32], [11, 33], [11, 35], [11, 37], [11, 39], [12, 17], [12, 27], [12, 29], [12, 30], [12, 33], [12, 39], [13, 14], [13, 15], [13, 16], [13, 17], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 25], [13, 27], [13, 29], [13, 30], [13, 33], [13, 34], [13, 38], [13, 39], [14, 17], [14, 23], [14, 29], [14, 30], [14, 37], [14, 39], [15, 17], [15, 19], [15, 27], [15, 29], [15, 33], [15, 37], [15, 39], [16, 17], [16, 19], [16, 23], [16, 24], [16, 27], [16, 33], [16, 37], [17, 18], [17, 19], [17, 21], [17, 22], [17, 23], [17, 24], [17, 26], [17, 27], [17, 28], [17, 30], [17, 31], [17, 32], [17, 33], [17, 37], [17, 38], [17, 39], [18, 23], [18, 24], [18, 27], [18, 29], [18, 30], [18, 33], [18, 39], [19, 25], [19, 27], [19, 29], [19, 30], [19, 32], [19, 35], [19, 37], [19, 39], [20, 23], [20, 29], [20, 30], [20, 37], [20, 39], [21, 23], [21, 24], [21, 30], [21, 37], [21, 39], [22, 23], [22, 24], [22, 27], [22, 39], [23, 25], [23, 26], [23, 29], [23, 32], [23, 33], [23, 34], [23, 35], [23, 36], [23, 38], [23, 39], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 31], [24, 33], [24, 35], [24, 36], [24, 37], [24, 38], [24, 39], [25, 27], [25, 29], [25, 39], [26, 27], [26, 29], [26, 39], [27, 29], [27, 30], [27, 33], [27, 34], [27, 35], [27, 37], [27, 38], [27, 39], [28, 29], [28, 30], [28, 33], [28, 39], [29, 30], [29, 33], [29, 37], [29, 39], [30, 31], [30, 32], [30, 33], [30, 34], [30, 36], [30, 37], [30, 38], [30, 39], [31, 33], [31, 37], [31, 39], [32, 33], [32, 37], [33, 34], [33, 35], [33, 37], [33, 38], [33, 39], [34, 37], [35, 39], [36, 37], [37, 38], [37, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s7/solution/solve.sh b/tasks/construct-nppc-vertex-cover-l4-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..775bb52a7121ba31f2e926e61d3e4529978a1fac --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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' +{"cover": [0, 1, 2, 4, 6, 7, 8, 10, 11, 13, 17, 19, 23, 24, 27, 29, 30, 33, 37, 39]} +RLMATH_EOF diff --git a/tasks/construct-nppc-vertex-cover-l4-s7/tests/check.py b/tasks/construct-nppc-vertex-cover-l4-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d8ed740cc660c4837d941a8d70ea394c3bc9f69e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s7/tests/check.py @@ -0,0 +1,18 @@ +"""Vertex cover of size <= k. Accepts any valid cover.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier converts to a set without type checks (floats/bools slip through and + # duplicates are silently merged); here entries must be distinct ints in range + c = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(c)) != len(c): + raise Invalid("cover contains duplicates") + if len(c) > k: + raise Invalid(f"cover has {len(c)} > {k} vertices") + s = set(c) + for u, v in inst["edges"]: + if u not in s and v not in s: + raise Invalid(f"edge ({u},{v}) not covered") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-vertex-cover-l4-s7/tests/instance.json b/tasks/construct-nppc-vertex-cover-l4-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3751782de94d0be09a49142208814e6d1de67fdd --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s7/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 2], [0, 3], [0, 4], [0, 7], [0, 8], [0, 9], [0, 11], [0, 13], [0, 15], [0, 16], [0, 17], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 27], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [0, 37], [0, 39], [1, 4], [1, 7], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 24], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 34], [1, 39], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 17], [2, 20], [2, 22], [2, 23], [2, 24], [2, 25], [2, 27], [2, 30], [2, 31], [2, 35], [2, 36], [2, 37], [2, 38], [2, 39], [3, 6], [3, 7], [3, 10], [3, 13], [3, 23], [3, 29], [3, 30], [3, 37], [4, 5], [4, 7], [4, 10], [4, 11], [4, 12], [4, 15], [4, 19], [4, 22], [4, 23], [4, 26], [4, 28], [4, 29], [4, 30], [4, 31], [4, 33], [5, 8], [5, 10], [5, 13], [5, 24], [5, 27], [5, 30], [5, 33], [5, 39], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 13], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [6, 27], [6, 29], [6, 30], [6, 32], [6, 33], [6, 35], [6, 37], [6, 39], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 14], [7, 15], [7, 17], [7, 18], [7, 19], [7, 20], [7, 22], [7, 23], [7, 24], [7, 27], [7, 29], [7, 30], [7, 33], [7, 34], [7, 36], [7, 37], [7, 38], [7, 39], [8, 9], [8, 10], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 20], [8, 21], [8, 23], [8, 24], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [8, 36], [8, 38], [8, 39], [9, 10], [9, 11], [9, 17], [9, 19], [9, 23], [9, 27], [9, 29], [9, 33], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 23], [10, 27], [10, 28], [10, 30], [10, 33], [10, 34], [10, 37], [10, 39], [11, 13], [11, 17], [11, 19], [11, 21], [11, 23], [11, 24], [11, 26], [11, 27], [11, 32], [11, 33], [11, 35], [11, 37], [11, 39], [12, 17], [12, 27], [12, 29], [12, 30], [12, 33], [12, 39], [13, 14], [13, 15], [13, 16], [13, 17], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 25], [13, 27], [13, 29], [13, 30], [13, 33], [13, 34], [13, 38], [13, 39], [14, 17], [14, 23], [14, 29], [14, 30], [14, 37], [14, 39], [15, 17], [15, 19], [15, 27], [15, 29], [15, 33], [15, 37], [15, 39], [16, 17], [16, 19], [16, 23], [16, 24], [16, 27], [16, 33], [16, 37], [17, 18], [17, 19], [17, 21], [17, 22], [17, 23], [17, 24], [17, 26], [17, 27], [17, 28], [17, 30], [17, 31], [17, 32], [17, 33], [17, 37], [17, 38], [17, 39], [18, 23], [18, 24], [18, 27], [18, 29], [18, 30], [18, 33], [18, 39], [19, 25], [19, 27], [19, 29], [19, 30], [19, 32], [19, 35], [19, 37], [19, 39], [20, 23], [20, 29], [20, 30], [20, 37], [20, 39], [21, 23], [21, 24], [21, 30], [21, 37], [21, 39], [22, 23], [22, 24], [22, 27], [22, 39], [23, 25], [23, 26], [23, 29], [23, 32], [23, 33], [23, 34], [23, 35], [23, 36], [23, 38], [23, 39], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 31], [24, 33], [24, 35], [24, 36], [24, 37], [24, 38], [24, 39], [25, 27], [25, 29], [25, 39], [26, 27], [26, 29], [26, 39], [27, 29], [27, 30], [27, 33], [27, 34], [27, 35], [27, 37], [27, 38], [27, 39], [28, 29], [28, 30], [28, 33], [28, 39], [29, 30], [29, 33], [29, 37], [29, 39], [30, 31], [30, 32], [30, 33], [30, 34], [30, 36], [30, 37], [30, 38], [30, 39], [31, 33], [31, 37], [31, 39], [32, 33], [32, 37], [33, 34], [33, 35], [33, 37], [33, 38], [33, 39], [34, 37], [35, 39], [36, 37], [37, 38], [37, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s7/tests/run.py b/tasks/construct-nppc-vertex-cover-l4-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l4-s7/tests/test.sh b/tasks/construct-nppc-vertex-cover-l4-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-nppc-vertex-cover-l4-s9/environment/Dockerfile b/tasks/construct-nppc-vertex-cover-l4-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-vertex-cover-l4-s9/environment/instance.json b/tasks/construct-nppc-vertex-cover-l4-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..85c142ddb045bf33e0d7658749a899bffdd28349 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s9/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 2], [0, 3], [0, 6], [0, 8], [0, 17], [0, 31], [0, 32], [0, 35], [1, 2], [1, 3], [1, 4], [1, 6], [1, 7], [1, 8], [1, 9], [1, 11], [1, 17], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 25], [1, 27], [1, 28], [1, 29], [1, 30], [1, 32], [1, 33], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [2, 4], [2, 7], [2, 8], [2, 9], [2, 12], [2, 14], [2, 15], [2, 16], [2, 17], [2, 20], [2, 22], [2, 23], [2, 24], [2, 26], [2, 27], [2, 31], [2, 32], [2, 35], [2, 36], [2, 37], [2, 38], [2, 39], [3, 4], [3, 5], [3, 6], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 17], [3, 18], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 28], [3, 30], [3, 32], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [4, 6], [4, 8], [4, 12], [4, 14], [4, 16], [4, 17], [4, 21], [4, 22], [4, 23], [4, 25], [4, 26], [4, 27], [4, 29], [4, 30], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 37], [4, 39], [5, 6], [5, 8], [5, 15], [5, 18], [5, 21], [5, 22], [5, 23], [5, 31], [5, 32], [5, 34], [5, 35], [5, 39], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 14], [6, 15], [6, 16], [6, 18], [6, 19], [6, 20], [6, 21], [6, 24], [6, 25], [6, 27], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 34], [6, 39], [7, 18], [7, 21], [7, 26], [7, 31], [7, 39], [8, 9], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 20], [8, 21], [8, 22], [8, 23], [8, 26], [8, 27], [8, 28], [8, 30], [8, 31], [8, 32], [8, 33], [8, 36], [8, 37], [8, 38], [8, 39], [9, 15], [9, 22], [9, 25], [9, 27], [9, 31], [9, 32], [9, 35], [10, 15], [10, 21], [10, 22], [10, 23], [10, 26], [10, 35], [10, 39], [11, 22], [11, 23], [11, 27], [11, 32], [11, 39], [12, 17], [12, 18], [12, 22], [12, 23], [12, 26], [12, 27], [12, 35], [12, 39], [13, 15], [13, 21], [13, 22], [13, 25], [13, 32], [13, 35], [13, 39], [14, 22], [14, 23], [14, 31], [14, 32], [14, 35], [14, 39], [15, 16], [15, 17], [15, 18], [15, 19], [15, 21], [15, 22], [15, 23], [15, 26], [15, 27], [15, 29], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [15, 36], [15, 38], [16, 22], [16, 23], [16, 25], [16, 32], [16, 34], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 27], [17, 29], [17, 30], [17, 31], [17, 34], [17, 35], [17, 37], [17, 39], [18, 23], [18, 24], [18, 26], [18, 27], [18, 28], [18, 31], [18, 32], [18, 34], [18, 35], [18, 36], [18, 39], [19, 21], [19, 22], [19, 23], [19, 25], [19, 26], [19, 32], [19, 34], [19, 35], [19, 39], [20, 21], [20, 22], [20, 23], [20, 26], [20, 27], [20, 31], [20, 32], [20, 35], [20, 39], [21, 22], [21, 25], [21, 27], [21, 31], [21, 32], [21, 33], [21, 35], [21, 36], [21, 38], [21, 39], [22, 23], [22, 25], [22, 26], [22, 27], [22, 28], [22, 31], [22, 33], [22, 34], [22, 35], [22, 36], [22, 38], [22, 39], [23, 24], [23, 34], [23, 35], [23, 37], [23, 38], [23, 39], [24, 27], [24, 32], [24, 35], [24, 39], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [25, 32], [25, 34], [25, 38], [26, 27], [26, 29], [26, 30], [26, 31], [26, 34], [26, 36], [26, 39], [27, 29], [27, 30], [27, 31], [27, 32], [27, 34], [27, 35], [27, 36], [27, 38], [27, 39], [28, 32], [28, 34], [28, 35], [28, 39], [29, 31], [29, 35], [30, 31], [30, 32], [30, 34], [30, 35], [30, 39], [31, 32], [31, 34], [31, 37], [31, 38], [31, 39], [32, 33], [32, 34], [32, 35], [32, 37], [33, 35], [34, 38], [34, 39], [35, 36], [35, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s9/solution/solve.sh b/tasks/construct-nppc-vertex-cover-l4-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2abc793d393497ad3a5fc720ce7536af9e580986 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"cover": [1, 2, 3, 4, 6, 8, 15, 17, 18, 21, 22, 23, 25, 26, 27, 31, 32, 34, 35, 39]} +RLMATH_EOF diff --git a/tasks/construct-nppc-vertex-cover-l4-s9/tests/check.py b/tasks/construct-nppc-vertex-cover-l4-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d8ed740cc660c4837d941a8d70ea394c3bc9f69e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s9/tests/check.py @@ -0,0 +1,18 @@ +"""Vertex cover of size <= k. Accepts any valid cover.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier converts to a set without type checks (floats/bools slip through and + # duplicates are silently merged); here entries must be distinct ints in range + c = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(c)) != len(c): + raise Invalid("cover contains duplicates") + if len(c) > k: + raise Invalid(f"cover has {len(c)} > {k} vertices") + s = set(c) + for u, v in inst["edges"]: + if u not in s and v not in s: + raise Invalid(f"edge ({u},{v}) not covered") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-vertex-cover-l4-s9/tests/instance.json b/tasks/construct-nppc-vertex-cover-l4-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..85c142ddb045bf33e0d7658749a899bffdd28349 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s9/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 2], [0, 3], [0, 6], [0, 8], [0, 17], [0, 31], [0, 32], [0, 35], [1, 2], [1, 3], [1, 4], [1, 6], [1, 7], [1, 8], [1, 9], [1, 11], [1, 17], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 25], [1, 27], [1, 28], [1, 29], [1, 30], [1, 32], [1, 33], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [2, 4], [2, 7], [2, 8], [2, 9], [2, 12], [2, 14], [2, 15], [2, 16], [2, 17], [2, 20], [2, 22], [2, 23], [2, 24], [2, 26], [2, 27], [2, 31], [2, 32], [2, 35], [2, 36], [2, 37], [2, 38], [2, 39], [3, 4], [3, 5], [3, 6], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 17], [3, 18], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 28], [3, 30], [3, 32], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [4, 6], [4, 8], [4, 12], [4, 14], [4, 16], [4, 17], [4, 21], [4, 22], [4, 23], [4, 25], [4, 26], [4, 27], [4, 29], [4, 30], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 37], [4, 39], [5, 6], [5, 8], [5, 15], [5, 18], [5, 21], [5, 22], [5, 23], [5, 31], [5, 32], [5, 34], [5, 35], [5, 39], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 14], [6, 15], [6, 16], [6, 18], [6, 19], [6, 20], [6, 21], [6, 24], [6, 25], [6, 27], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 34], [6, 39], [7, 18], [7, 21], [7, 26], [7, 31], [7, 39], [8, 9], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 20], [8, 21], [8, 22], [8, 23], [8, 26], [8, 27], [8, 28], [8, 30], [8, 31], [8, 32], [8, 33], [8, 36], [8, 37], [8, 38], [8, 39], [9, 15], [9, 22], [9, 25], [9, 27], [9, 31], [9, 32], [9, 35], [10, 15], [10, 21], [10, 22], [10, 23], [10, 26], [10, 35], [10, 39], [11, 22], [11, 23], [11, 27], [11, 32], [11, 39], [12, 17], [12, 18], [12, 22], [12, 23], [12, 26], [12, 27], [12, 35], [12, 39], [13, 15], [13, 21], [13, 22], [13, 25], [13, 32], [13, 35], [13, 39], [14, 22], [14, 23], [14, 31], [14, 32], [14, 35], [14, 39], [15, 16], [15, 17], [15, 18], [15, 19], [15, 21], [15, 22], [15, 23], [15, 26], [15, 27], [15, 29], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [15, 36], [15, 38], [16, 22], [16, 23], [16, 25], [16, 32], [16, 34], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 27], [17, 29], [17, 30], [17, 31], [17, 34], [17, 35], [17, 37], [17, 39], [18, 23], [18, 24], [18, 26], [18, 27], [18, 28], [18, 31], [18, 32], [18, 34], [18, 35], [18, 36], [18, 39], [19, 21], [19, 22], [19, 23], [19, 25], [19, 26], [19, 32], [19, 34], [19, 35], [19, 39], [20, 21], [20, 22], [20, 23], [20, 26], [20, 27], [20, 31], [20, 32], [20, 35], [20, 39], [21, 22], [21, 25], [21, 27], [21, 31], [21, 32], [21, 33], [21, 35], [21, 36], [21, 38], [21, 39], [22, 23], [22, 25], [22, 26], [22, 27], [22, 28], [22, 31], [22, 33], [22, 34], [22, 35], [22, 36], [22, 38], [22, 39], [23, 24], [23, 34], [23, 35], [23, 37], [23, 38], [23, 39], [24, 27], [24, 32], [24, 35], [24, 39], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [25, 32], [25, 34], [25, 38], [26, 27], [26, 29], [26, 30], [26, 31], [26, 34], [26, 36], [26, 39], [27, 29], [27, 30], [27, 31], [27, 32], [27, 34], [27, 35], [27, 36], [27, 38], [27, 39], [28, 32], [28, 34], [28, 35], [28, 39], [29, 31], [29, 35], [30, 31], [30, 32], [30, 34], [30, 35], [30, 39], [31, 32], [31, 34], [31, 37], [31, 38], [31, 39], [32, 33], [32, 34], [32, 35], [32, 37], [33, 35], [34, 38], [34, 39], [35, 36], [35, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s9/tests/run.py b/tasks/construct-nppc-vertex-cover-l4-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-vertex-cover-l4-s9/tests/test.sh b/tasks/construct-nppc-vertex-cover-l4-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-intermediate-integration-l1-s1/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s1/environment/instance.json b/tasks/construct-rg-intermediate-integration-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9262533f9f008af2bfc9a6d3fd9352fd3f35dfd6 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "(x - 6)**3", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s1/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b805ccba025a4201d90ccf2217abe10786d612c1 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "x**4/4 - 6*x**3 + 54*x**2 - 216*x + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l1-s1/tests/check.py b/tasks/construct-rg-intermediate-integration-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-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-intermediate-integration-l1-s1/tests/instance.json b/tasks/construct-rg-intermediate-integration-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9262533f9f008af2bfc9a6d3fd9352fd3f35dfd6 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "(x - 6)**3", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s1/tests/run.py b/tasks/construct-rg-intermediate-integration-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s1/tests/test.sh b/tasks/construct-rg-intermediate-integration-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s6/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s6/environment/instance.json b/tasks/construct-rg-intermediate-integration-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e9296675e92223625a6aa8332f5abad4fbd721e1 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-3*(6*x - 9)**2", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s6/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1b10be8691a00dfb5425cf42a15ad10ead609e89 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "-36*x**3 + 162*x**2 - 243*x + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l1-s6/tests/check.py b/tasks/construct-rg-intermediate-integration-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-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-intermediate-integration-l1-s6/tests/instance.json b/tasks/construct-rg-intermediate-integration-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e9296675e92223625a6aa8332f5abad4fbd721e1 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-3*(6*x - 9)**2", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s6/tests/run.py b/tasks/construct-rg-intermediate-integration-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s6/tests/test.sh b/tasks/construct-rg-intermediate-integration-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s8/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s8/environment/instance.json b/tasks/construct-rg-intermediate-integration-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2c5acd10d82446f152c4c46170659c7a012fc237 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-3*(8*x - 8)**4", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s8/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..96b02eaf90ad85af9e12ef02b1a1b593425c273b --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "-12288*x**5/5 + 12288*x**4 - 24576*x**3 + 24576*x**2 - 12288*x + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l1-s8/tests/check.py b/tasks/construct-rg-intermediate-integration-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s8/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-intermediate-integration-l1-s8/tests/instance.json b/tasks/construct-rg-intermediate-integration-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2c5acd10d82446f152c4c46170659c7a012fc237 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-3*(8*x - 8)**4", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s8/tests/run.py b/tasks/construct-rg-intermediate-integration-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s8/tests/test.sh b/tasks/construct-rg-intermediate-integration-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s7/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s7/environment/instance.json b/tasks/construct-rg-intermediate-integration-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e49a78796f72792ff247a0b2690d1dde08e09e18 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "x*sin(x)", "problem_type": "polynomial_exp_trig", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l5-s7/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bbd195b1e2ae9e07ecff002e03200cbc70db89a4 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "-x*cos(x) + sin(x) + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l5-s7/tests/check.py b/tasks/construct-rg-intermediate-integration-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s7/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-intermediate-integration-l5-s7/tests/instance.json b/tasks/construct-rg-intermediate-integration-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e49a78796f72792ff247a0b2690d1dde08e09e18 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "x*sin(x)", "problem_type": "polynomial_exp_trig", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l5-s7/tests/run.py b/tasks/construct-rg-intermediate-integration-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s7/tests/test.sh b/tasks/construct-rg-intermediate-integration-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s9/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s9/environment/instance.json b/tasks/construct-rg-intermediate-integration-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..801175b5c687e819d3c02f0fdb98468c7dd19121 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-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-s9/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..54f893b8836f8da253a742b0e0c6a1b913355f1d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "-sin(x)**2/2 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l5-s9/tests/check.py b/tasks/construct-rg-intermediate-integration-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s9/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-s9/tests/instance.json b/tasks/construct-rg-intermediate-integration-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..801175b5c687e819d3c02f0fdb98468c7dd19121 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-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-s9/tests/run.py b/tasks/construct-rg-intermediate-integration-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s9/tests/test.sh b/tasks/construct-rg-intermediate-integration-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l6-s5/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l6-s5/environment/instance.json b/tasks/construct-rg-intermediate-integration-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9a5b371eea128f22405da70a4046148d008e1249 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "x**3*cos(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-s5/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4be1cd27f7a14d03b05f6827e29474658dceca55 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "x**3*sin(x) + 3*x**2*cos(x) - 6*x*sin(x) - 6*cos(x) + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l6-s5/tests/check.py b/tasks/construct-rg-intermediate-integration-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l6-s5/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-intermediate-integration-l6-s5/tests/instance.json b/tasks/construct-rg-intermediate-integration-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9a5b371eea128f22405da70a4046148d008e1249 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "x**3*cos(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-s5/tests/run.py b/tasks/construct-rg-intermediate-integration-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l6-s5/tests/test.sh b/tasks/construct-rg-intermediate-integration-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-bezout-identity-l3-s8/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l3-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-bezout-identity-l3-s8/environment/instance.json b/tasks/construct-rlve-bezout-identity-l3-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9f0b39b8ee7c364c063a6718ee3d65c1ad94557d --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s8/environment/instance.json @@ -0,0 +1 @@ +{"A": [-469, -105, -322, 427, -462, 196], "target": 7, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s8/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l3-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c89d0497a50d8566966c0ba0cdf1aec25608c9c2 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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' +{"X": [2, -9, 0, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l3-s8/tests/check.py b/tasks/construct-rlve-bezout-identity-l3-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s8/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + X = int_list(ans.get("X"), len(A), name="X") + S = sum(a * x for a, x in zip(A, X)) + if S != inst["target"]: + raise Invalid(f"S = {S}, required {inst['target']}") + return None, {} diff --git a/tasks/construct-rlve-bezout-identity-l3-s8/tests/instance.json b/tasks/construct-rlve-bezout-identity-l3-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9f0b39b8ee7c364c063a6718ee3d65c1ad94557d --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s8/tests/instance.json @@ -0,0 +1 @@ +{"A": [-469, -105, -322, 427, -462, 196], "target": 7, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s8/tests/run.py b/tasks/construct-rlve-bezout-identity-l3-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-bezout-identity-l3-s8/tests/test.sh b/tasks/construct-rlve-bezout-identity-l3-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s2/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s2/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..81e998f9ec11dc73750cec7061a9c081726a37e8 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"mod": 77, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s2/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c7d4e06070fb513f3a25df140242727b6582d26a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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' +{"L": 8, "R": 21} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s2/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s2/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-s2/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..81e998f9ec11dc73750cec7061a9c081726a37e8 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"mod": 77, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s2/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s2/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l2-s7/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l2-s7/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a52bf0a81b39d3333f5f69e5ca75a24b4af59a6e --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"mod": 2498, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l2-s7/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1eac0ccd734aa17145bd8fbf7d8d34197f3093ba --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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' +{"L": 23, "R": 273} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l2-s7/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l2-s7/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l2-s7/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a52bf0a81b39d3333f5f69e5ca75a24b4af59a6e --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"mod": 2498, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l2-s7/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l2-s7/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l5-s3/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s3/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c8550de09fbfa85a858a0570485833d63671c360 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"mod": 806685780153518, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s3/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fef4bda098fa1ad883561c33b537fb6918ff629c --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"L": 153486241228144, "R": 253486241228143} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s3/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s3/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s3/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c8550de09fbfa85a858a0570485833d63671c360 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"mod": 806685780153518, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s3/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s3/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s4/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s4/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..19a4282ffb0663632d07b23741d0345bc671ee46 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"mod": 418967893858583, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s4/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1e4c5dc2707781082e60145c95259c4f42003a8d --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"L": 403486301737328, "R": 503486301737327} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s4/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s4/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s4/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..19a4282ffb0663632d07b23741d0345bc671ee46 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"mod": 418967893858583, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s4/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s4/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s4/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l1-s4/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2e9420c64a2f89486216041b7a984983c7dc0170 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"A": [7, 0, 6, 2], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s4/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5eb9de481ba0d1e0c08f42ce2951dfded0be19df --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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' +{"B": [0, 2, 7, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s4/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s4/tests/check.py @@ -0,0 +1,22 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + n = len(A) + B = int_list(ans.get("B"), n, name="B") + if Counter(B) != Counter(A): + raise Invalid("B is not a permutation of A") + d = [a - b for a, b in zip(A, B)] + # count subsets (including empty and full) with sum 0; the empty and full sets always qualify + ways = Counter({0: 1}) + for x in d: + nxt = Counter(ways) + for s, c in ways.items(): + nxt[s + x] += c + ways = nxt + if ways[0] != 2: + raise Invalid(f"{ways[0] - 2} non-empty proper subsets have equal sums in A and B") + return None, {} diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s4/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2e9420c64a2f89486216041b7a984983c7dc0170 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"A": [7, 0, 6, 2], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s4/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l1-s4/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-even-degree-partition-l4-s5/environment/Dockerfile b/tasks/construct-rlve-even-degree-partition-l4-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-even-degree-partition-l4-s5/environment/instance.json b/tasks/construct-rlve-even-degree-partition-l4-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bfe83278377f524cb5625d8cd3404f94d551d7e1 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "edges": [[0, 1], [0, 3], [0, 8], [0, 9], [0, 11], [0, 14], [0, 17], [1, 4], [1, 8], [1, 11], [1, 15], [1, 16], [1, 17], [2, 8], [2, 13], [2, 14], [2, 15], [3, 4], [3, 5], [3, 15], [3, 16], [4, 6], [4, 9], [4, 11], [4, 15], [4, 17], [5, 15], [6, 7], [6, 13], [7, 8], [7, 9], [7, 12], [8, 10], [8, 13], [10, 11], [10, 12], [10, 13], [11, 13], [11, 17], [12, 14], [12, 17], [13, 17], [14, 15], [14, 17], [15, 16], [15, 17], [16, 17]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l4-s5/solution/solve.sh b/tasks/construct-rlve-even-degree-partition-l4-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..eeebe1c8ad8f7846a8da34977ac7a5332c5adf3c --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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' +{"groups": [1, 1, 2, 1, 1, 2, 2, 2, 2, 1, 2, 1, 1, 2, 1, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-even-degree-partition-l4-s5/tests/check.py b/tasks/construct-rlve-even-degree-partition-l4-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c7f0f71ea6d10264ececcc933b97a4a0e6eaf8e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s5/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + g = int_list(ans.get("groups"), n, 1, 2, "groups") + deg = [0] * n + for u, v in inst["edges"]: + if g[u] == g[v]: + deg[u] += 1 + deg[v] += 1 + for v in range(n): + if deg[v] % 2: + raise Invalid(f"vertex {v} has {deg[v]} same-group neighbours") + return None, {} diff --git a/tasks/construct-rlve-even-degree-partition-l4-s5/tests/instance.json b/tasks/construct-rlve-even-degree-partition-l4-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bfe83278377f524cb5625d8cd3404f94d551d7e1 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "edges": [[0, 1], [0, 3], [0, 8], [0, 9], [0, 11], [0, 14], [0, 17], [1, 4], [1, 8], [1, 11], [1, 15], [1, 16], [1, 17], [2, 8], [2, 13], [2, 14], [2, 15], [3, 4], [3, 5], [3, 15], [3, 16], [4, 6], [4, 9], [4, 11], [4, 15], [4, 17], [5, 15], [6, 7], [6, 13], [7, 8], [7, 9], [7, 12], [8, 10], [8, 13], [10, 11], [10, 12], [10, 13], [11, 13], [11, 17], [12, 14], [12, 17], [13, 17], [14, 15], [14, 17], [15, 16], [15, 17], [16, 17]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l4-s5/tests/run.py b/tasks/construct-rlve-even-degree-partition-l4-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-even-degree-partition-l4-s5/tests/test.sh b/tasks/construct-rlve-even-degree-partition-l4-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s8/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l2-s8/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..72e23dc7d8fb22a9fec3cd6ab04b5c80e24dd1cf --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[3, 4], [2, 4], [3, 5], [2, 3], [1, 2], [5, 7], [2, 6], [1, 5], [0, 2], [3, 6], [0, 1], [0, 7], [4, 7], [1, 6], [0, 3], [4, 5], [1, 7], [1, 3]], "edges2": [[4, 7], [3, 4], [2, 4], [1, 5], [4, 5], [0, 2], [3, 6], [5, 6], [1, 2], [1, 4], [2, 6], [0, 7], [6, 7], [4, 6], [0, 1], [3, 5], [5, 7], [0, 5]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s8/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9bf7b1b2d5340b243a87f2235af2c4956fe10f8e --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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' +{"p": [7, 5, 6, 4, 2, 1, 3, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s8/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s8/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("p"), n, 0, n - 1, "p") + if len(set(p)) != n: + raise Invalid("p is not a permutation") + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + img = {(min(p[u], p[v]), max(p[u], p[v])) for u, v in inst["edges1"]} + if img != e2: + raise Invalid(f"{len(img - e2)} edges of G1 are not mapped onto edges of G2") + return None, {} diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s8/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..72e23dc7d8fb22a9fec3cd6ab04b5c80e24dd1cf --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[3, 4], [2, 4], [3, 5], [2, 3], [1, 2], [5, 7], [2, 6], [1, 5], [0, 2], [3, 6], [0, 1], [0, 7], [4, 7], [1, 6], [0, 3], [4, 5], [1, 7], [1, 3]], "edges2": [[4, 7], [3, 4], [2, 4], [1, 5], [4, 5], [0, 2], [3, 6], [5, 6], [1, 2], [1, 4], [2, 6], [0, 7], [6, 7], [4, 6], [0, 1], [3, 5], [5, 7], [0, 5]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s8/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l2-s8/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-grid-parity-construction-l6-s0/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s0/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d7e6601df8230c0531e0f60831364602347ba959 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["1101010100111000100111", "1100110011001100101101", "0101101010010011101011", "1100100101100100011101", "1101010000110010001111", "0100101110111001001010", "0011100010001110011110", "1101100001111011101000", "1111101110100011001110", "1000110001100100111010", "0100000100010100010011", "1010101100001111110011", "1101011011111110111110", "1011001000110101110110"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s0/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..45bfdc17600c5bdc715b60d458f26603116d0cd9 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["0011001010111100111101", "1001101110100011111110", "0001111101000101101101", "1110111101011100010100", "1001000001101011000110", "1100001111100110110010", "1111111000001010000011", "1000011001110011101000", "1110111111011100100111", "0011101001011011011100", "0011000001111000010111", "0011001111111011111101", "1101011010000110011101", "1111010111001100101010"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s0/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s0/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-l6-s0/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d7e6601df8230c0531e0f60831364602347ba959 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["1101010100111000100111", "1100110011001100101101", "0101101010010011101011", "1100100101100100011101", "1101010000110010001111", "0100101110111001001010", "0011100010001110011110", "1101100001111011101000", "1111101110100011001110", "1000110001100100111010", "0100000100010100010011", "1010101100001111110011", "1101011011111110111110", "1011001000110101110110"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s0/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s0/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-imp-party-l3-s5/tests/run.py b/tasks/construct-rlve-imp-party-l3-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-l3-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-imp-party-l4-s1/environment/Dockerfile b/tasks/construct-rlve-imp-party-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l4-s1/environment/instance.json b/tasks/construct-rlve-imp-party-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..48994e27400fafb5b0c0795ee7b050d4ef64dff2 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 7], [0, 8], [0, 11], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29], [0, 30], [0, 32], [0, 33], [0, 34], [1, 4], [1, 6], [1, 7], [1, 8], [1, 9], [1, 11], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [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, 32], [1, 33], [1, 35], [2, 4], [2, 15], [2, 16], [2, 18], [2, 23], [2, 25], [2, 26], [2, 27], [2, 28], [2, 30], [2, 33], [3, 4], [3, 8], [3, 11], [3, 14], [3, 15], [3, 17], [3, 18], [3, 20], [3, 21], [3, 23], [3, 24], [3, 25], [3, 27], [3, 29], [3, 32], [4, 7], [4, 8], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 20], [4, 21], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [5, 8], [5, 14], [5, 15], [5, 16], [5, 17], [5, 24], [5, 26], [5, 27], [5, 28], [5, 29], [5, 30], [6, 8], [6, 11], [6, 14], [6, 16], [6, 21], [6, 27], [6, 28], [6, 32], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 18], [7, 20], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [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, 31], [8, 32], [8, 33], [8, 35], [9, 11], [9, 14], [9, 16], [9, 17], [9, 20], [9, 25], [9, 33], [10, 14], [10, 16], [10, 18], [10, 20], [10, 24], [10, 29], [10, 32], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 30], [11, 32], [11, 33], [12, 14], [12, 17], [12, 21], [12, 23], [12, 27], [12, 29], [12, 33], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 28], [13, 29], [13, 30], [13, 32], [13, 33], [13, 34], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 35], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 23], [15, 24], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 32], [15, 33], [15, 34], [15, 35], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 32], [16, 33], [16, 35], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [17, 30], [17, 32], [17, 33], [17, 35], [18, 19], [18, 20], [18, 21], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [19, 21], [19, 23], [19, 24], [19, 32], [20, 21], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 33], [20, 34], [20, 35], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [22, 24], [22, 30], [22, 33], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 34], [26, 27], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [27, 28], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [29, 30], [29, 32], [29, 33], [29, 34], [30, 32], [30, 33], [31, 32], [31, 33], [32, 33], [32, 34]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s1/solution/solve.sh b/tasks/construct-rlve-imp-party-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..eb8b41584920297541410898eb9eff685f6b24b7 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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' +{"clique": [0, 4, 7, 8, 17, 20, 21, 24, 26, 27, 28, 29]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l4-s1/tests/check.py b/tasks/construct-rlve-imp-party-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s1/tests/check.py @@ -0,0 +1,14 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + c = int_list(ans.get("clique"), n, 0, 3 * n - 1, "clique") + if len(set(c)) != n: + raise Invalid("vertices must be distinct") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(n): + for j in range(i + 1, n): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-imp-party-l4-s1/tests/instance.json b/tasks/construct-rlve-imp-party-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..48994e27400fafb5b0c0795ee7b050d4ef64dff2 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 7], [0, 8], [0, 11], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29], [0, 30], [0, 32], [0, 33], [0, 34], [1, 4], [1, 6], [1, 7], [1, 8], [1, 9], [1, 11], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [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, 32], [1, 33], [1, 35], [2, 4], [2, 15], [2, 16], [2, 18], [2, 23], [2, 25], [2, 26], [2, 27], [2, 28], [2, 30], [2, 33], [3, 4], [3, 8], [3, 11], [3, 14], [3, 15], [3, 17], [3, 18], [3, 20], [3, 21], [3, 23], [3, 24], [3, 25], [3, 27], [3, 29], [3, 32], [4, 7], [4, 8], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 20], [4, 21], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [5, 8], [5, 14], [5, 15], [5, 16], [5, 17], [5, 24], [5, 26], [5, 27], [5, 28], [5, 29], [5, 30], [6, 8], [6, 11], [6, 14], [6, 16], [6, 21], [6, 27], [6, 28], [6, 32], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 18], [7, 20], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [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, 31], [8, 32], [8, 33], [8, 35], [9, 11], [9, 14], [9, 16], [9, 17], [9, 20], [9, 25], [9, 33], [10, 14], [10, 16], [10, 18], [10, 20], [10, 24], [10, 29], [10, 32], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 30], [11, 32], [11, 33], [12, 14], [12, 17], [12, 21], [12, 23], [12, 27], [12, 29], [12, 33], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 28], [13, 29], [13, 30], [13, 32], [13, 33], [13, 34], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 35], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 23], [15, 24], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 32], [15, 33], [15, 34], [15, 35], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 32], [16, 33], [16, 35], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [17, 30], [17, 32], [17, 33], [17, 35], [18, 19], [18, 20], [18, 21], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [19, 21], [19, 23], [19, 24], [19, 32], [20, 21], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 33], [20, 34], [20, 35], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [22, 24], [22, 30], [22, 33], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 34], [26, 27], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [27, 28], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [29, 30], [29, 32], [29, 33], [29, 34], [30, 32], [30, 33], [31, 32], [31, 33], [32, 33], [32, 34]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s1/tests/run.py b/tasks/construct-rlve-imp-party-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l4-s1/tests/test.sh b/tasks/construct-rlve-imp-party-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l4-s6/environment/Dockerfile b/tasks/construct-rlve-imp-party-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l4-s6/environment/instance.json b/tasks/construct-rlve-imp-party-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8e02af37db848e8dc6b56bea58c8b24a65c66ed5 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 27], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [0, 35], [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], [1, 18], [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, 33], [1, 35], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28], [2, 30], [2, 33], [2, 34], [2, 35], [3, 4], [3, 5], [3, 6], [3, 9], [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], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 30], [3, 33], [3, 34], [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], [4, 18], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 30], [4, 31], [4, 33], [4, 35], [5, 6], [5, 9], [5, 11], [5, 15], [5, 16], [5, 18], [5, 20], [5, 21], [5, 23], [5, 24], [5, 25], [5, 28], [5, 30], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 21], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [6, 34], [7, 9], [7, 10], [7, 12], [7, 14], [7, 15], [7, 16], [7, 18], [7, 21], [7, 23], [7, 24], [7, 25], [7, 27], [7, 28], [7, 33], [8, 9], [8, 10], [8, 11], [8, 12], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 20], [8, 21], [8, 23], [8, 24], [8, 27], [8, 30], [8, 33], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 35], [10, 11], [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, 24], [10, 25], [10, 27], [10, 28], [10, 29], [10, 30], [10, 31], [10, 33], [10, 35], [11, 12], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 30], [11, 31], [11, 33], [12, 13], [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, 28], [12, 29], [12, 30], [12, 32], [12, 33], [12, 34], [12, 35], [13, 14], [13, 16], [13, 17], [13, 18], [13, 20], [13, 21], [13, 23], [13, 24], [13, 25], [13, 27], [13, 28], [14, 15], [14, 16], [14, 17], [14, 18], [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, 35], [15, 16], [15, 17], [15, 18], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 27], [15, 28], [15, 29], [15, 30], [15, 32], [15, 33], [15, 35], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 32], [16, 33], [16, 34], [16, 35], [17, 18], [17, 20], [17, 21], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 33], [17, 34], [17, 35], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 30], [18, 33], [18, 34], [19, 20], [19, 21], [19, 25], [19, 28], [19, 33], [20, 21], [20, 23], [20, 24], [20, 25], [20, 27], [20, 28], [20, 29], [20, 30], [20, 33], [20, 34], [20, 35], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 30], [21, 33], [21, 34], [21, 35], [22, 23], [22, 27], [22, 30], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 31], [23, 33], [23, 34], [24, 25], [24, 26], [24, 27], [24, 28], [24, 30], [24, 32], [24, 33], [24, 34], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [25, 33], [25, 34], [25, 35], [26, 27], [26, 28], [26, 30], [26, 33], [27, 28], [27, 29], [27, 30], [27, 31], [27, 33], [27, 34], [27, 35], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [29, 30], [29, 33], [30, 31], [30, 32], [30, 33], [30, 34], [31, 33], [32, 33], [33, 34]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s6/solution/solve.sh b/tasks/construct-rlve-imp-party-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b358e77245c8745e544429fa8eba13842a465412 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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' +{"clique": [1, 2, 3, 9, 11, 12, 14, 18, 20, 25, 27, 30]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l4-s6/tests/check.py b/tasks/construct-rlve-imp-party-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s6/tests/check.py @@ -0,0 +1,14 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + c = int_list(ans.get("clique"), n, 0, 3 * n - 1, "clique") + if len(set(c)) != n: + raise Invalid("vertices must be distinct") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(n): + for j in range(i + 1, n): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-imp-party-l4-s6/tests/instance.json b/tasks/construct-rlve-imp-party-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8e02af37db848e8dc6b56bea58c8b24a65c66ed5 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 27], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [0, 35], [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], [1, 18], [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, 33], [1, 35], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28], [2, 30], [2, 33], [2, 34], [2, 35], [3, 4], [3, 5], [3, 6], [3, 9], [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], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 30], [3, 33], [3, 34], [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], [4, 18], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 30], [4, 31], [4, 33], [4, 35], [5, 6], [5, 9], [5, 11], [5, 15], [5, 16], [5, 18], [5, 20], [5, 21], [5, 23], [5, 24], [5, 25], [5, 28], [5, 30], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 21], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [6, 34], [7, 9], [7, 10], [7, 12], [7, 14], [7, 15], [7, 16], [7, 18], [7, 21], [7, 23], [7, 24], [7, 25], [7, 27], [7, 28], [7, 33], [8, 9], [8, 10], [8, 11], [8, 12], [8, 14], [8, 15], [8, 16], [8, 17], [8, 18], [8, 20], [8, 21], [8, 23], [8, 24], [8, 27], [8, 30], [8, 33], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 35], [10, 11], [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, 24], [10, 25], [10, 27], [10, 28], [10, 29], [10, 30], [10, 31], [10, 33], [10, 35], [11, 12], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 30], [11, 31], [11, 33], [12, 13], [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, 28], [12, 29], [12, 30], [12, 32], [12, 33], [12, 34], [12, 35], [13, 14], [13, 16], [13, 17], [13, 18], [13, 20], [13, 21], [13, 23], [13, 24], [13, 25], [13, 27], [13, 28], [14, 15], [14, 16], [14, 17], [14, 18], [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, 35], [15, 16], [15, 17], [15, 18], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 27], [15, 28], [15, 29], [15, 30], [15, 32], [15, 33], [15, 35], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 32], [16, 33], [16, 34], [16, 35], [17, 18], [17, 20], [17, 21], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 33], [17, 34], [17, 35], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 30], [18, 33], [18, 34], [19, 20], [19, 21], [19, 25], [19, 28], [19, 33], [20, 21], [20, 23], [20, 24], [20, 25], [20, 27], [20, 28], [20, 29], [20, 30], [20, 33], [20, 34], [20, 35], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 30], [21, 33], [21, 34], [21, 35], [22, 23], [22, 27], [22, 30], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 31], [23, 33], [23, 34], [24, 25], [24, 26], [24, 27], [24, 28], [24, 30], [24, 32], [24, 33], [24, 34], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [25, 33], [25, 34], [25, 35], [26, 27], [26, 28], [26, 30], [26, 33], [27, 28], [27, 29], [27, 30], [27, 31], [27, 33], [27, 34], [27, 35], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [29, 30], [29, 33], [30, 31], [30, 32], [30, 33], [30, 34], [31, 33], [32, 33], [33, 34]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s6/tests/run.py b/tasks/construct-rlve-imp-party-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l4-s6/tests/test.sh b/tasks/construct-rlve-imp-party-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l4-s8/environment/Dockerfile b/tasks/construct-rlve-imp-party-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l4-s8/environment/instance.json b/tasks/construct-rlve-imp-party-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..30378f4272524e4ed6b592d7bef5e1390c9b9ad3 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 5], [0, 7], [0, 8], [0, 9], [0, 11], [0, 13], [0, 14], [0, 16], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [1, 2], [1, 3], [1, 4], [1, 5], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 16], [1, 17], [1, 18], [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, 33], [1, 34], [1, 35], [2, 5], [2, 7], [2, 8], [2, 9], [2, 11], [2, 13], [2, 14], [2, 16], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [3, 5], [3, 7], [3, 8], [3, 9], [3, 11], [3, 13], [3, 14], [3, 16], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 25], [3, 26], [3, 28], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [4, 7], [4, 9], [4, 11], [4, 13], [4, 14], [4, 16], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 28], [5, 29], [5, 30], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [6, 7], [6, 8], [6, 9], [6, 11], [6, 13], [6, 14], [6, 16], [6, 18], [6, 19], [6, 21], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [7, 8], [7, 9], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 31], [7, 32], [7, 33], [7, 34], [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, 31], [8, 32], [8, 33], [8, 34], [8, 35], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 35], [10, 11], [10, 13], [10, 14], [10, 16], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 24], [10, 26], [10, 28], [10, 29], [10, 30], [10, 31], [10, 32], [10, 33], [11, 12], [11, 13], [11, 14], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 35], [12, 13], [12, 14], [12, 18], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 28], [12, 29], [12, 30], [12, 31], [12, 33], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 28], [13, 29], [13, 30], [13, 31], [13, 32], [13, 33], [13, 35], [14, 15], [14, 16], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [15, 16], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 29], [15, 30], [15, 31], [15, 32], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 32], [16, 33], [16, 34], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [19, 30], [19, 31], [19, 32], [19, 33], [19, 35], [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, 33], [20, 34], [20, 35], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 29], [22, 30], [22, 31], [22, 32], [22, 33], [22, 34], [22, 35], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 31], [23, 32], [23, 33], [23, 35], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 34], [26, 27], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 35], [27, 28], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [29, 30], [29, 31], [29, 32], [29, 33], [29, 35], [30, 31], [30, 32], [30, 33], [30, 34], [30, 35], [31, 32], [31, 33], [31, 34], [31, 35], [32, 33], [32, 34], [32, 35], [33, 34], [33, 35]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s8/solution/solve.sh b/tasks/construct-rlve-imp-party-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..09a2cd1af30f589b49a3fe4fee430d670f897347 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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' +{"clique": [1, 5, 8, 9, 21, 22, 24, 26, 28, 30, 31, 32]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l4-s8/tests/check.py b/tasks/construct-rlve-imp-party-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s8/tests/check.py @@ -0,0 +1,14 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + c = int_list(ans.get("clique"), n, 0, 3 * n - 1, "clique") + if len(set(c)) != n: + raise Invalid("vertices must be distinct") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(n): + for j in range(i + 1, n): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-imp-party-l4-s8/tests/instance.json b/tasks/construct-rlve-imp-party-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..30378f4272524e4ed6b592d7bef5e1390c9b9ad3 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 5], [0, 7], [0, 8], [0, 9], [0, 11], [0, 13], [0, 14], [0, 16], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [1, 2], [1, 3], [1, 4], [1, 5], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 16], [1, 17], [1, 18], [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, 33], [1, 34], [1, 35], [2, 5], [2, 7], [2, 8], [2, 9], [2, 11], [2, 13], [2, 14], [2, 16], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [3, 5], [3, 7], [3, 8], [3, 9], [3, 11], [3, 13], [3, 14], [3, 16], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 25], [3, 26], [3, 28], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [4, 7], [4, 9], [4, 11], [4, 13], [4, 14], [4, 16], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 28], [5, 29], [5, 30], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [6, 7], [6, 8], [6, 9], [6, 11], [6, 13], [6, 14], [6, 16], [6, 18], [6, 19], [6, 21], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [7, 8], [7, 9], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 31], [7, 32], [7, 33], [7, 34], [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, 31], [8, 32], [8, 33], [8, 34], [8, 35], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 35], [10, 11], [10, 13], [10, 14], [10, 16], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 24], [10, 26], [10, 28], [10, 29], [10, 30], [10, 31], [10, 32], [10, 33], [11, 12], [11, 13], [11, 14], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 35], [12, 13], [12, 14], [12, 18], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 28], [12, 29], [12, 30], [12, 31], [12, 33], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 28], [13, 29], [13, 30], [13, 31], [13, 32], [13, 33], [13, 35], [14, 15], [14, 16], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [15, 16], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 29], [15, 30], [15, 31], [15, 32], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 30], [16, 31], [16, 32], [16, 33], [16, 34], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [19, 30], [19, 31], [19, 32], [19, 33], [19, 35], [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, 33], [20, 34], [20, 35], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 29], [22, 30], [22, 31], [22, 32], [22, 33], [22, 34], [22, 35], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 31], [23, 32], [23, 33], [23, 35], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 34], [26, 27], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 35], [27, 28], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [29, 30], [29, 31], [29, 32], [29, 33], [29, 35], [30, 31], [30, 32], [30, 33], [30, 34], [30, 35], [31, 32], [31, 33], [31, 34], [31, 35], [32, 33], [32, 34], [32, 35], [33, 34], [33, 35]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s8/tests/run.py b/tasks/construct-rlve-imp-party-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l4-s8/tests/test.sh b/tasks/construct-rlve-imp-party-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-integer-linear-system-l3-s1/environment/Dockerfile b/tasks/construct-rlve-integer-linear-system-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-integer-linear-system-l3-s1/environment/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..89e84217ffafd9957dac7ade4d59a18ce874050f --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 0, 1, 0, 1, 0, 0, 1], [0, 1, 1, 0, 0, 1, 1, 1], [0, 0, 1, 1, 0, 0, 1, 0], [0, 0, 0, 1, 0, 1, 1, 1], [0, 1, 0, 0, 0, 1, 1, 0], [0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [1, 0, 0, 1, 1, 0, 0, 1], [1, 0, 1, 1, 0, 1, 1, 0]], "rhs": [14, 24, 15, 13, 15, 24, 4, 13, 12, 4, 20, 16, 1, 5, 9, 24], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s1/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f32f4a191c2b3f2d110e1f872c968928268248bc --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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' +{"x": [4, 6, 8, 3, 1, 5, 4, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l3-s1/tests/check.py b/tasks/construct-rlve-integer-linear-system-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s1/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = len(inst["coeffs"][0]) + x = int_list(ans.get("x"), n, name="x") + for k, (e, r) in enumerate(zip(inst["coeffs"], inst["rhs"])): + if sum(c * v for c, v in zip(e, x)) != r: + raise Invalid(f"equation {k} is violated") + return None, {} diff --git a/tasks/construct-rlve-integer-linear-system-l3-s1/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..89e84217ffafd9957dac7ade4d59a18ce874050f --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 0, 1, 0, 1, 0, 0, 1], [0, 1, 1, 0, 0, 1, 1, 1], [0, 0, 1, 1, 0, 0, 1, 0], [0, 0, 0, 1, 0, 1, 1, 1], [0, 1, 0, 0, 0, 1, 1, 0], [0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [1, 0, 0, 1, 1, 0, 0, 1], [1, 0, 1, 1, 0, 1, 1, 0]], "rhs": [14, 24, 15, 13, 15, 24, 4, 13, 12, 4, 20, 16, 1, 5, 9, 24], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s1/tests/run.py b/tasks/construct-rlve-integer-linear-system-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-integer-linear-system-l3-s1/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-integer-linear-system-l3-s6/environment/Dockerfile b/tasks/construct-rlve-integer-linear-system-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l3-s6/environment/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..becf83615786cc4a2a1ace97d690fe8d7fe50599 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [[0, 1, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 0, 1, 0, 1], [1, 1, 1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 0, 0, 1, 1], [0, 1, 0, 0, 1, 1, 0, 1], [0, 1, 0, 0, 1, 1, 0, 0], [1, 1, 1, 0, 0, 1, 0, 1], [1, 1, 1, 0, 1, 0, 0, 0], [1, 0, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1, 1, 0], [1, 1, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1, 1], [0, 1, 0, 0, 1, 0, 0, 1], [0, 0, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 1, 1, 0, 0], [1, 0, 1, 0, 0, 0, 0, 0], [1, 0, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0, 0]], "rhs": [19, 10, 31, 37, 25, 20, 12, 19, 15, 15, 20, 23, 21, 15, 23, 18, 14, 16, 5, 17, 19, 17, 24, 6], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s6/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fb2b4419928029f21562c0c24c25acb0ec5c745f --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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": [4, 4, 1, 4, 6, 2, 8, 8]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l3-s6/tests/check.py b/tasks/construct-rlve-integer-linear-system-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s6/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = len(inst["coeffs"][0]) + x = int_list(ans.get("x"), n, name="x") + for k, (e, r) in enumerate(zip(inst["coeffs"], inst["rhs"])): + if sum(c * v for c, v in zip(e, x)) != r: + raise Invalid(f"equation {k} is violated") + return None, {} diff --git a/tasks/construct-rlve-integer-linear-system-l3-s6/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..becf83615786cc4a2a1ace97d690fe8d7fe50599 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [[0, 1, 1, 1, 0, 1, 1, 0], [0, 0, 0, 0, 0, 1, 0, 1], [1, 1, 1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 0, 0, 1, 1], [0, 1, 0, 0, 1, 1, 0, 1], [0, 1, 0, 0, 1, 1, 0, 0], [1, 1, 1, 0, 0, 1, 0, 1], [1, 1, 1, 0, 1, 0, 0, 0], [1, 0, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 1, 1, 0], [1, 1, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1, 1], [0, 1, 0, 0, 1, 0, 0, 1], [0, 0, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 1, 1, 0, 0], [1, 0, 1, 0, 0, 0, 0, 0], [1, 0, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0, 0]], "rhs": [19, 10, 31, 37, 25, 20, 12, 19, 15, 15, 20, 23, 21, 15, 23, 18, 14, 16, 5, 17, 19, 17, 24, 6], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s6/tests/run.py b/tasks/construct-rlve-integer-linear-system-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l3-s6/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l3-s8/environment/Dockerfile b/tasks/construct-rlve-integer-linear-system-l3-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-integer-linear-system-l3-s8/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l3-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a059f72c840638bd6b2397fd65def580305a5e18 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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' +{"x": [2, 5, 3, 6, 4, 1, 1, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l3-s8/tests/check.py b/tasks/construct-rlve-integer-linear-system-l3-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s8/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = len(inst["coeffs"][0]) + x = int_list(ans.get("x"), n, name="x") + for k, (e, r) in enumerate(zip(inst["coeffs"], inst["rhs"])): + if sum(c * v for c, v in zip(e, x)) != r: + raise Invalid(f"equation {k} is violated") + return None, {} diff --git a/tasks/construct-rlve-integer-linear-system-l3-s8/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..da6295c64a8594312ee5521af5d943d9f3bd8bf9 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s8/tests/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-l3-s8/tests/run.py b/tasks/construct-rlve-integer-linear-system-l3-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-integer-linear-system-l3-s8/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l3-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-integer-linear-system-l4-s5/environment/Dockerfile b/tasks/construct-rlve-integer-linear-system-l4-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l4-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-integer-linear-system-l4-s5/environment/instance.json b/tasks/construct-rlve-integer-linear-system-l4-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8dd5aba7383a5ee775f105c36a4422dd5eb6eb03 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l4-s5/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 2], [0, 2, 0, 0, 0, 1, 2, 1, 2, 0, 0, 1], [0, 2, 0, 0, 2, 0, 0, 0, 1, 0, 1, 2], [0, 1, 1, 0, 0, 1, 0, 0, 0, 2, 1, 1], [2, 0, 2, 0, 0, 1, 2, 2, 2, 0, 1, 1], [2, 2, 0, 0, 0, 0, 0, 2, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 2, 0], [0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 2, 0], [0, 1, 1, 2, 2, 2, 1, 2, 0, 0, 2, 0], [1, 2, 0, 0, 1, 1, 1, 0, 0, 0, 0, 2], [1, 1, 1, 0, 1, 2, 0, 0, 0, 0, 2, 2], [0, 2, 1, 1, 0, 0, 1, 0, 0, 2, 0, 0], [0, 2, 1, 0, 1, 1, 2, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 2, 1, 2, 2, 1, 0], [2, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 1], [1, 1, 1, 2, 0, 0, 1, 1, 1, 1, 2, 1], [2, 0, 0, 1, 1, 2, 1, 0, 2, 1, 0, 0], [1, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 2, 0, 1, 0, 2, 1, 1, 1, 0, 2, 1], [1, 1, 2, 2, 1, 0, 0, 1, 0, 0, 0, 0], [2, 2, 1, 0, 0, 0, 1, 1, 0, 2, 1, 0], [1, 2, 2, 0, 1, 0, 1, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 1, 0, 2, 2, 2, 0], [0, 2, 0, 0, 2, 1, 0, 1, 0, 2, 0, 0], [1, 0, 0, 1, 0, 0, 0, 2, 2, 0, 0, 0], [0, 0, 0, 2, 0, 1, 1, 0, 0, 2, 2, 0], [2, 0, 0, 2, 0, 2, 2, 1, 2, 1, 2, 2], [1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1]], "rhs": [42, 84, 56, 38, 100, 61, 13, 31, 94, 71, 65, 50, 71, 54, 44, 73, 80, 36, 91, 57, 73, 63, 34, 63, 46, 40, 110, 51], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l4-s5/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l4-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7dde519c70146862654e99a2ad8235a9c22f26a6 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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' +{"x": [9, 11, 5, 5, 8, 10, 12, 9, 7, 3, 1, 5]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l4-s5/tests/check.py b/tasks/construct-rlve-integer-linear-system-l4-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l4-s5/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = len(inst["coeffs"][0]) + x = int_list(ans.get("x"), n, name="x") + for k, (e, r) in enumerate(zip(inst["coeffs"], inst["rhs"])): + if sum(c * v for c, v in zip(e, x)) != r: + raise Invalid(f"equation {k} is violated") + return None, {} diff --git a/tasks/construct-rlve-integer-linear-system-l4-s5/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l4-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8dd5aba7383a5ee775f105c36a4422dd5eb6eb03 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l4-s5/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 2], [0, 2, 0, 0, 0, 1, 2, 1, 2, 0, 0, 1], [0, 2, 0, 0, 2, 0, 0, 0, 1, 0, 1, 2], [0, 1, 1, 0, 0, 1, 0, 0, 0, 2, 1, 1], [2, 0, 2, 0, 0, 1, 2, 2, 2, 0, 1, 1], [2, 2, 0, 0, 0, 0, 0, 2, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 2, 0], [0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 2, 0], [0, 1, 1, 2, 2, 2, 1, 2, 0, 0, 2, 0], [1, 2, 0, 0, 1, 1, 1, 0, 0, 0, 0, 2], [1, 1, 1, 0, 1, 2, 0, 0, 0, 0, 2, 2], [0, 2, 1, 1, 0, 0, 1, 0, 0, 2, 0, 0], [0, 2, 1, 0, 1, 1, 2, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 2, 1, 2, 2, 1, 0], [2, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 1], [1, 1, 1, 2, 0, 0, 1, 1, 1, 1, 2, 1], [2, 0, 0, 1, 1, 2, 1, 0, 2, 1, 0, 0], [1, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 2, 0, 1, 0, 2, 1, 1, 1, 0, 2, 1], [1, 1, 2, 2, 1, 0, 0, 1, 0, 0, 0, 0], [2, 2, 1, 0, 0, 0, 1, 1, 0, 2, 1, 0], [1, 2, 2, 0, 1, 0, 1, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 1, 0, 2, 2, 2, 0], [0, 2, 0, 0, 2, 1, 0, 1, 0, 2, 0, 0], [1, 0, 0, 1, 0, 0, 0, 2, 2, 0, 0, 0], [0, 0, 0, 2, 0, 1, 1, 0, 0, 2, 2, 0], [2, 0, 0, 2, 0, 2, 2, 1, 2, 1, 2, 2], [1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1]], "rhs": [42, 84, 56, 38, 100, 61, 13, 31, 94, 71, 65, 50, 71, 54, 44, 73, 80, 36, 91, 57, 73, 63, 34, 63, 46, 40, 110, 51], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l4-s5/tests/run.py b/tasks/construct-rlve-integer-linear-system-l4-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l4-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-integer-linear-system-l4-s5/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l4-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l4-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s0/environment/Dockerfile b/tasks/construct-rlve-largest-convex-polygon-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-largest-convex-polygon-l4-s0/environment/instance.json b/tasks/construct-rlve-largest-convex-polygon-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9e9f57fb2e96f0d118777641678f71d79d8ffe8d --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"points": [[2, 14], [16, 16], [7, 7], [14, 17], [1, 11], [12, 16], [3, 7], [1, 15], [18, 10], [17, 3], [13, 0], [18, 12], [15, 3], [8, 2], [7, 5], [0, 14], [14, 15], [13, 11]], "k": 11, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s0/solution/solve.sh b/tasks/construct-rlve-largest-convex-polygon-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..76fca25b3ba3039a32b03d8870e7e06a7b9c3c86 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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' +{"indices": [15, 7, 5, 16, 11, 8, 9, 12, 14, 6, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s0/tests/check.py b/tasks/construct-rlve-largest-convex-polygon-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3a09cc858f41ce5745e4e491188cd42360c65dae --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s0/tests/check.py @@ -0,0 +1,27 @@ +from run import Invalid, int_list + + +def _cross(o, a, b): + return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) + + +def check(inst, ans): + P, k = inst["points"], inst["k"] + idx = int_list(ans.get("indices"), None, 0, len(P) - 1, "indices") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + if len(idx) < k: + raise Invalid(f"{len(idx)} points given, need {k}") + pts = sorted(tuple(P[i]) for i in idx) + lower, upper = [], [] + for p in pts: # monotone chain, strict (collinear points dropped) + while len(lower) >= 2 and _cross(lower[-2], lower[-1], p) <= 0: + lower.pop() + lower.append(p) + for p in reversed(pts): + while len(upper) >= 2 and _cross(upper[-2], upper[-1], p) <= 0: + upper.pop() + upper.append(p) + if len(lower) + len(upper) - 2 != len(pts): + raise Invalid("the chosen points are not in convex position") + return None, {} diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s0/tests/instance.json b/tasks/construct-rlve-largest-convex-polygon-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9e9f57fb2e96f0d118777641678f71d79d8ffe8d --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"points": [[2, 14], [16, 16], [7, 7], [14, 17], [1, 11], [12, 16], [3, 7], [1, 15], [18, 10], [17, 3], [13, 0], [18, 12], [15, 3], [8, 2], [7, 5], [0, 14], [14, 15], [13, 11]], "k": 11, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s0/tests/run.py b/tasks/construct-rlve-largest-convex-polygon-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-largest-convex-polygon-l4-s0/tests/test.sh b/tasks/construct-rlve-largest-convex-polygon-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-largest-rectangle-l6-s0/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-largest-rectangle-l6-s0/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2d56078cd0993303aaa5869fb15c063e93231e03 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"points": [[59, -11], [-51, -43], [33, -40], [21, 60], [5, -54], [-32, 24], [20, 34], [-44, 1], [57, -16], [-35, -16], [-41, 42], [52, 29], [-38, -36], [10, 18], [35, -60], [32, -16], [38, 27], [-50, 17], [-39, 15], [14, -18], [56, -32], [24, -26], [2, 43], [52, -47], [-12, 56], [16, -46], [-22, -34], [-54, 46], [-30, 10], [-6, -21], [-18, 49], [-50, -49], [-40, -8], [-58, -6], [18, 4], [-13, 11], [-19, 57], [36, 27], [-8, -36], [30, -2], [53, -55], [56, -51], [-21, 24], [-35, -42], [44, -33], [60, 42], [26, -6], [-17, -47], [41, 31], [22, -16], [13, -15], [18, 25], [30, -50], [-27, 36], [-3, 44], [-48, -58], [38, 24], [22, -8], [27, 58], [30, 15]], "area": 164, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l6-s0/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0cd0e8d2617051f4ef0cec1cffbb9171e21eeb68 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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' +{"indices": [15, 21, 19, 57]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l6-s0/tests/check.py b/tasks/construct-rlve-largest-rectangle-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s0/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid, int_list + + +def check(inst, ans): + P = inst["points"] + idx = int_list(ans.get("indices"), 4, 0, len(P) - 1, "indices") + if len(set(idx)) != 4: + raise Invalid("indices must be distinct") + A, *rest = [tuple(P[i]) for i in idx] + if len(set([A] + rest)) != 4: + raise Invalid("points must be distinct") + # the vertex farthest from A is opposite; the other two are A's neighbours + rest.sort(key=lambda X: (X[0] - A[0]) ** 2 + (X[1] - A[1]) ** 2) + B, D, C = rest + u = (B[0] - A[0], B[1] - A[1]) + v = (D[0] - A[0], D[1] - A[1]) + if u[0] * v[0] + u[1] * v[1] != 0: + raise Invalid("not a rectangle (no right angle at the first vertex)") + if (B[0] + D[0] - A[0], B[1] + D[1] - A[1]) != C: + raise Invalid("not a rectangle") + area = abs(u[0] * v[1] - u[1] * v[0]) + if area < inst["area"]: + raise Invalid(f"area {area} < {inst['area']}") + return None, {"area": area} diff --git a/tasks/construct-rlve-largest-rectangle-l6-s0/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2d56078cd0993303aaa5869fb15c063e93231e03 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"points": [[59, -11], [-51, -43], [33, -40], [21, 60], [5, -54], [-32, 24], [20, 34], [-44, 1], [57, -16], [-35, -16], [-41, 42], [52, 29], [-38, -36], [10, 18], [35, -60], [32, -16], [38, 27], [-50, 17], [-39, 15], [14, -18], [56, -32], [24, -26], [2, 43], [52, -47], [-12, 56], [16, -46], [-22, -34], [-54, 46], [-30, 10], [-6, -21], [-18, 49], [-50, -49], [-40, -8], [-58, -6], [18, 4], [-13, 11], [-19, 57], [36, 27], [-8, -36], [30, -2], [53, -55], [56, -51], [-21, 24], [-35, -42], [44, -33], [60, 42], [26, -6], [-17, -47], [41, 31], [22, -16], [13, -15], [18, 25], [30, -50], [-27, 36], [-3, 44], [-48, -58], [38, 24], [22, -8], [27, 58], [30, 15]], "area": 164, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l6-s0/tests/run.py b/tasks/construct-rlve-largest-rectangle-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-largest-rectangle-l6-s0/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a72cd0ecf3421b0f882ab824d869e2c118d5ab7c --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"A": ["01", "01"], "B": ["01", "01"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1c0659332884117a306926de80fc5e441a50a280 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [0, 1], "b": [0, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/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-s2/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a72cd0ecf3421b0f882ab824d869e2c118d5ab7c --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"A": ["01", "01"], "B": ["01", "01"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l2-s7/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l2-s7/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..47a5c86273a36143bf7ee79cbe11bfeea159b15c --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"A": ["101", "110", "011"], "B": ["101", "011", "110"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l2-s7/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..88c5702f8d97ebb99d3d42f7b48c07e706cad43e --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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": [0, 2, 1], "b": [0, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l2-s7/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s7/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l2-s7/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..47a5c86273a36143bf7ee79cbe11bfeea159b15c --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"A": ["101", "110", "011"], "B": ["101", "011", "110"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l2-s7/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l2-s7/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l5-s3/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..021a00875c5e7cb2819227c1ccfdcfb42feefa96 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"A": ["0000000000011", "0000000000000", "0010000000000", "0100000000011", "0000000000000", "0011100100000", "0000000000000", "0000100000000", "0000000011000", "0001000001000", "0000000000000", "1100000001100", "0000000000000", "0000000000010", "0010010000000", "0100100000001", "1010000000000"], "B": ["0000101000001", "0000000001000", "0000010001000", "0000000000011", "0000100000000", "0000000000010", "0000000000000", "0000000100100", "0000000000000", "0000000000000", "0000001000011", "1010001100000", "0000000000000", "0000000000000", "0001000100000", "0010000001000", "0101100001000"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7f61a587dd14ee5453c04ec2937a7edd72796fac --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"a": [15, 2, 14, 0, 7, 13, 4, 8, 6, 10, 3, 11, 1, 12, 9, 16, 5], "b": [10, 7, 0, 3, 4, 5, 1, 9, 6, 2, 8, 11, 12]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..021a00875c5e7cb2819227c1ccfdcfb42feefa96 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"A": ["0000000000011", "0000000000000", "0010000000000", "0100000000011", "0000000000000", "0011100100000", "0000000000000", "0000100000000", "0000000011000", "0001000001000", "0000000000000", "1100000001100", "0000000000000", "0000000000010", "0010010000000", "0100100000001", "1010000000000"], "B": ["0000101000001", "0000000001000", "0000010001000", "0000000000011", "0000100000000", "0000000000010", "0000000000000", "0000000100100", "0000000000000", "0000000000000", "0000001000011", "1010001100000", "0000000000000", "0000000000000", "0001000100000", "0010000001000", "0101100001000"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3bc205a68c5338c8940330405dbf6dbe48fb8953 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"A": ["00011000000001", "10111011110001", "00010101001100", "00000010000011", "11000010000011", "00011100001011", "00111000000100", "00010000111001", "01001011101001", "11110000100001"], "B": ["11100000100001", "11000011000101", "00000011000001", "00001111111011", "00011101000100", "00010101001011", "10011011101000", "10000001011001", "00001001000100", "00100010000011"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c95ef8f7c34ca3d054092dfa808dc4565b10d0b6 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"a": [2, 5, 0, 1, 4, 9, 8, 7, 3, 6], "b": [10, 5, 11, 1, 6, 0, 4, 13, 7, 9, 8, 12, 2, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3bc205a68c5338c8940330405dbf6dbe48fb8953 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"A": ["00011000000001", "10111011110001", "00010101001100", "00000010000011", "11000010000011", "00011100001011", "00111000000100", "00010000111001", "01001011101001", "11110000100001"], "B": ["11100000100001", "11000011000101", "00000011000001", "00001111111011", "00011101000100", "00010101001011", "10011011101000", "10000001011001", "00001001000100", "00100010000011"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s1/environment/Dockerfile b/tasks/construct-rlve-max-achromatic-coloring-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-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-max-achromatic-coloring-l4-s1/environment/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bc7b35122e4d68124e952df265fc9d3eb600dda4 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 7, "edges": [[0, 1], [0, 3], [0, 5], [0, 6], [0, 11], [1, 3], [1, 5], [1, 9], [1, 10], [1, 11], [2, 3], [2, 5], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [3, 4], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [4, 5], [4, 6], [4, 7], [4, 9], [4, 11], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [6, 8], [6, 9], [6, 10], [6, 11], [7, 8], [7, 10], [9, 11], [10, 11]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s1/solution/solve.sh b/tasks/construct-rlve-max-achromatic-coloring-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..643aea9c3a6fefdfd73505a075d19433c4a6d60e --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-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": [0, 1, 0, 2, 0, 2, 3, 4, 1, 4, 5, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s1/tests/check.py b/tasks/construct-rlve-max-achromatic-coloring-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..bb676a518264e5db4fb0964e27ccffccf6980807 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-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("colors"), n, 0, k - 1, "colors") + if len(set(c)) != k: + raise Invalid(f"uses {len(set(c))} colours, need all {k}") + pairs = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pairs.add((min(c[u], c[v]), max(c[u], c[v]))) + if len(pairs) != k * (k - 1) // 2: + raise Invalid("some pair of colours is not joined by an edge") + return None, {} diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s1/tests/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bc7b35122e4d68124e952df265fc9d3eb600dda4 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 7, "edges": [[0, 1], [0, 3], [0, 5], [0, 6], [0, 11], [1, 3], [1, 5], [1, 9], [1, 10], [1, 11], [2, 3], [2, 5], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [3, 4], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [4, 5], [4, 6], [4, 7], [4, 9], [4, 11], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [6, 8], [6, 9], [6, 10], [6, 11], [7, 8], [7, 10], [9, 11], [10, 11]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s1/tests/run.py b/tasks/construct-rlve-max-achromatic-coloring-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-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-max-achromatic-coloring-l4-s1/tests/test.sh b/tasks/construct-rlve-max-achromatic-coloring-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-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-maximum-clique-l1-s6/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l1-s6/environment/instance.json b/tasks/construct-rlve-maximum-clique-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4bbb22ffbbbfed03a19b1d9e55eb4f7ce24c44a3 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "k": 3, "edges": [[0, 2], [1, 2], [1, 5], [1, 6], [1, 7], [2, 4], [2, 5], [3, 5], [3, 7]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l1-s6/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..30182a7169a3903b7777a8e75a1c2666744b02b5 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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' +{"clique": [1, 2, 5]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l1-s6/tests/check.py b/tasks/construct-rlve-maximum-clique-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l1-s6/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l1-s6/tests/instance.json b/tasks/construct-rlve-maximum-clique-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4bbb22ffbbbfed03a19b1d9e55eb4f7ce24c44a3 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "k": 3, "edges": [[0, 2], [1, 2], [1, 5], [1, 6], [1, 7], [2, 4], [2, 5], [3, 5], [3, 7]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l1-s6/tests/run.py b/tasks/construct-rlve-maximum-clique-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l1-s6/tests/test.sh b/tasks/construct-rlve-maximum-clique-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l2-s4/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l2-s4/environment/instance.json b/tasks/construct-rlve-maximum-clique-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..759a7f9e9ea02d761fa6cfdd036aa7768a293a7c --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 6, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 7], [0, 9], [0, 10], [0, 11], [0, 13], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 13], [3, 4], [3, 5], [3, 8], [3, 9], [3, 10], [3, 11], [4, 6], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 13], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 13], [7, 8], [7, 9], [7, 10], [7, 12], [7, 13], [8, 12], [8, 13], [9, 12], [10, 11], [10, 12], [10, 13], [11, 12], [12, 13]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s4/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4e76fdf68dfda6fbeb3aada7f5914bea96e559d9 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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' +{"clique": [0, 1, 3, 4, 10, 11]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l2-s4/tests/check.py b/tasks/construct-rlve-maximum-clique-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s4/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-s4/tests/instance.json b/tasks/construct-rlve-maximum-clique-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..759a7f9e9ea02d761fa6cfdd036aa7768a293a7c --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 6, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 7], [0, 9], [0, 10], [0, 11], [0, 13], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 13], [3, 4], [3, 5], [3, 8], [3, 9], [3, 10], [3, 11], [4, 6], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 13], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 13], [7, 8], [7, 9], [7, 10], [7, 12], [7, 13], [8, 12], [8, 13], [9, 12], [10, 11], [10, 12], [10, 13], [11, 12], [12, 13]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s4/tests/run.py b/tasks/construct-rlve-maximum-clique-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l2-s4/tests/test.sh b/tasks/construct-rlve-maximum-clique-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l6-s2/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l6-s2/environment/instance.json b/tasks/construct-rlve-maximum-clique-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..18b3800c6b7a5c00f7c9ac994dfa2fa99d8d7c30 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 10, "edges": [[0, 1], [0, 4], [0, 5], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 15], [0, 17], [0, 18], [0, 19], [0, 21], [0, 22], [0, 23], [0, 24], [0, 26], [0, 30], [0, 31], [0, 32], [0, 34], [0, 35], [0, 36], [0, 38], [0, 39], [0, 40], [0, 42], [0, 43], [0, 45], [0, 46], [0, 47], [0, 50], [0, 51], [0, 52], [0, 53], [0, 54], [1, 3], [1, 5], [1, 6], [1, 9], [1, 10], [1, 11], [1, 12], [1, 16], [1, 17], [1, 20], [1, 21], [1, 24], [1, 26], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [1, 41], [1, 42], [1, 43], [1, 44], [1, 46], [1, 47], [1, 48], [1, 50], [1, 51], [1, 53], [1, 54], [1, 55], [2, 3], [2, 5], [2, 6], [2, 8], [2, 9], [2, 13], [2, 14], [2, 16], [2, 19], [2, 20], [2, 24], [2, 25], [2, 28], [2, 30], [2, 31], [2, 33], [2, 36], [2, 37], [2, 39], [2, 41], [2, 42], [2, 44], [2, 45], [2, 47], [2, 48], [2, 49], [2, 53], [2, 54], [2, 55], [3, 4], [3, 5], [3, 7], [3, 8], [3, 9], [3, 11], [3, 12], [3, 15], [3, 17], [3, 18], [3, 19], [3, 22], [3, 23], [3, 25], [3, 28], [3, 29], [3, 30], [3, 31], [3, 35], [3, 37], [3, 38], [3, 40], [3, 42], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [4, 5], [4, 6], [4, 7], [4, 9], [4, 12], [4, 13], [4, 14], [4, 17], [4, 21], [4, 22], [4, 26], [4, 29], [4, 31], [4, 35], [4, 38], [4, 39], [4, 40], [4, 42], [4, 43], [4, 44], [4, 49], [4, 50], [4, 51], [4, 52], [4, 54], [5, 7], [5, 10], [5, 11], [5, 12], [5, 14], [5, 16], [5, 17], [5, 18], [5, 19], [5, 23], [5, 24], [5, 26], [5, 27], [5, 28], [5, 31], [5, 32], [5, 34], [5, 37], [5, 39], [5, 40], [5, 42], [5, 44], [5, 45], [5, 46], [5, 47], [5, 52], [5, 53], [5, 55], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 13], [6, 15], [6, 16], [6, 18], [6, 19], [6, 23], [6, 24], [6, 27], [6, 28], [6, 30], [6, 32], [6, 33], [6, 34], [6, 35], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 46], [6, 47], [6, 49], [6, 50], [6, 51], [6, 55], [7, 8], [7, 9], [7, 11], [7, 12], [7, 18], [7, 20], [7, 22], [7, 23], [7, 24], [7, 28], [7, 31], [7, 32], [7, 34], [7, 37], [7, 38], [7, 40], [7, 41], [7, 44], [7, 49], [7, 51], [7, 52], [7, 53], [7, 54], [8, 11], [8, 12], [8, 16], [8, 17], [8, 19], [8, 21], [8, 23], [8, 25], [8, 26], [8, 28], [8, 29], [8, 31], [8, 32], [8, 34], [8, 35], [8, 36], [8, 39], [8, 40], [8, 41], [8, 42], [8, 43], [8, 44], [8, 46], [8, 47], [8, 50], [8, 51], [8, 53], [9, 10], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 21], [9, 25], [9, 27], [9, 28], [9, 30], [9, 31], [9, 32], [9, 35], [9, 36], [9, 37], [9, 41], [9, 44], [9, 45], [9, 48], [9, 49], [9, 50], [9, 52], [10, 11], [10, 13], [10, 15], [10, 16], [10, 17], [10, 19], [10, 20], [10, 21], [10, 23], [10, 25], [10, 26], [10, 27], [10, 29], [10, 30], [10, 31], [10, 34], [10, 36], [10, 37], [10, 38], [10, 39], [10, 41], [10, 44], [10, 45], [10, 46], [10, 47], [10, 48], [10, 50], [10, 51], [10, 52], [10, 53], [10, 54], [10, 55], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 31], [11, 32], [11, 33], [11, 34], [11, 36], [11, 37], [11, 40], [11, 41], [11, 45], [11, 46], [11, 47], [11, 48], [11, 50], [12, 13], [12, 14], [12, 15], [12, 17], [12, 19], [12, 21], [12, 23], [12, 25], [12, 26], [12, 27], [12, 29], [12, 30], [12, 35], [12, 36], [12, 37], [12, 38], [12, 40], [12, 42], [12, 43], [12, 45], [12, 46], [12, 47], [12, 48], [12, 49], [12, 51], [12, 52], [12, 53], [12, 55], [13, 14], [13, 16], [13, 19], [13, 20], [13, 21], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 30], [13, 33], [13, 35], [13, 37], [13, 38], [13, 40], [13, 41], [13, 42], [13, 44], [13, 45], [13, 46], [13, 47], [13, 48], [13, 49], [13, 51], [13, 52], [13, 54], [13, 55], [14, 18], [14, 21], [14, 22], [14, 23], [14, 25], [14, 30], [14, 31], [14, 35], [14, 36], [14, 37], [14, 40], [14, 41], [14, 42], [14, 46], [14, 48], [14, 49], [14, 51], [14, 52], [14, 55], [15, 16], [15, 17], [15, 18], [15, 19], [15, 22], [15, 23], [15, 24], [15, 25], [15, 29], [15, 32], [15, 33], [15, 34], [15, 36], [15, 40], [15, 42], [15, 43], [15, 46], [15, 48], [15, 49], [15, 52], [15, 53], [15, 55], [16, 17], [16, 18], [16, 19], [16, 25], [16, 26], [16, 27], [16, 29], [16, 30], [16, 32], [16, 35], [16, 37], [16, 38], [16, 40], [16, 41], [16, 43], [16, 45], [16, 47], [16, 48], [16, 49], [16, 50], [16, 51], [16, 52], [16, 53], [16, 54], [16, 55], [17, 18], [17, 19], [17, 20], [17, 21], [17, 24], [17, 25], [17, 26], [17, 28], [17, 32], [17, 34], [17, 36], [17, 37], [17, 38], [17, 39], [17, 40], [17, 41], [17, 43], [17, 45], [17, 46], [17, 48], [17, 49], [17, 50], [17, 51], [17, 52], [18, 20], [18, 21], [18, 22], [18, 25], [18, 26], [18, 27], [18, 29], [18, 30], [18, 32], [18, 34], [18, 35], [18, 38], [18, 39], [18, 42], [18, 43], [18, 44], [18, 45], [18, 46], [18, 47], [18, 48], [18, 50], [18, 51], [19, 23], [19, 25], [19, 26], [19, 27], [19, 30], [19, 31], [19, 33], [19, 34], [19, 35], [19, 36], [19, 39], [19, 40], [19, 41], [19, 43], [19, 44], [19, 46], [19, 47], [19, 48], [19, 50], [19, 53], [19, 54], [20, 21], [20, 22], [20, 23], [20, 24], [20, 26], [20, 28], [20, 32], [20, 33], [20, 34], [20, 37], [20, 38], [20, 39], [20, 40], [20, 41], [20, 44], [20, 46], [20, 47], [20, 51], [20, 52], [20, 53], [20, 54], [20, 55], [21, 22], [21, 23], [21, 25], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 34], [21, 36], [21, 38], [21, 39], [21, 40], [21, 41], [21, 42], [21, 43], [21, 45], [21, 47], [21, 49], [21, 50], [21, 51], [21, 53], [21, 54], [21, 55], [22, 26], [22, 27], [22, 28], [22, 29], [22, 31], [22, 32], [22, 33], [22, 35], [22, 36], [22, 37], [22, 38], [22, 41], [22, 45], [22, 47], [22, 48], [22, 50], [22, 51], [22, 52], [22, 53], [22, 54], [22, 55], [23, 24], [23, 25], [23, 27], [23, 31], [23, 33], [23, 34], [23, 35], [23, 38], [23, 39], [23, 40], [23, 41], [23, 43], [23, 44], [23, 47], [23, 48], [23, 49], [23, 50], [23, 51], [23, 52], [24, 25], [24, 29], [24, 31], [24, 32], [24, 33], [24, 35], [24, 37], [24, 38], [24, 39], [24, 40], [24, 41], [24, 42], [24, 43], [24, 45], [24, 46], [24, 48], [24, 49], [24, 53], [24, 54], [25, 28], [25, 30], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [25, 38], [25, 40], [25, 41], [25, 43], [25, 46], [25, 47], [25, 48], [25, 52], [25, 53], [25, 55], [26, 27], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [26, 36], [26, 37], [26, 38], [26, 40], [26, 41], [26, 42], [26, 43], [26, 44], [26, 45], [26, 46], [26, 48], [26, 49], [26, 50], [26, 51], [26, 52], [26, 53], [26, 55], [27, 29], [27, 30], [27, 33], [27, 34], [27, 35], [27, 36], [27, 38], [27, 39], [27, 40], [27, 41], [27, 43], [27, 44], [27, 45], [27, 46], [27, 48], [27, 49], [27, 50], [27, 53], [27, 54], [27, 55], [28, 30], [28, 33], [28, 34], [28, 36], [28, 38], [28, 39], [28, 40], [28, 41], [28, 42], [28, 44], [28, 46], [28, 47], [28, 50], [28, 51], [28, 54], [29, 30], [29, 31], [29, 32], [29, 33], [29, 36], [29, 38], [29, 41], [29, 42], [29, 43], [29, 45], [29, 47], [29, 48], [29, 51], [29, 52], [29, 54], [29, 55], [30, 31], [30, 32], [30, 34], [30, 35], [30, 40], [30, 41], [30, 42], [30, 43], [30, 45], [30, 47], [30, 48], [30, 49], [30, 52], [31, 33], [31, 35], [31, 36], [31, 37], [31, 38], [31, 39], [31, 40], [31, 41], [31, 42], [31, 43], [31, 44], [31, 45], [31, 47], [31, 49], [31, 50], [31, 51], [31, 52], [31, 55], [32, 34], [32, 36], [32, 37], [32, 39], [32, 40], [32, 41], [32, 43], [32, 45], [32, 47], [32, 48], [32, 50], [32, 53], [32, 54], [32, 55], [33, 35], [33, 36], [33, 38], [33, 39], [33, 40], [33, 42], [33, 43], [33, 48], [33, 50], [33, 51], [33, 52], [33, 54], [33, 55], [34, 42], [34, 46], [34, 48], [34, 50], [34, 51], [34, 52], [34, 54], [34, 55], [35, 36], [35, 37], [35, 39], [35, 40], [35, 41], [35, 42], [35, 44], [35, 47], [35, 48], [35, 49], [35, 53], [35, 54], [35, 55], [36, 37], [36, 38], [36, 40], [36, 41], [36, 42], [36, 45], [36, 46], [36, 47], [36, 52], [36, 55], [37, 38], [37, 41], [37, 45], [37, 46], [37, 47], [37, 49], [37, 50], [37, 52], [37, 53], [38, 39], [38, 40], [38, 41], [38, 42], [38, 43], [38, 44], [38, 46], [38, 48], [38, 49], [38, 51], [38, 53], [38, 55], [39, 43], [39, 44], [39, 49], [39, 52], [39, 53], [39, 54], [40, 41], [40, 44], [40, 45], [40, 47], [40, 50], [40, 51], [40, 53], [40, 54], [40, 55], [41, 44], [41, 45], [41, 47], [41, 48], [41, 50], [41, 51], [41, 52], [41, 55], [42, 44], [42, 46], [42, 47], [42, 49], [42, 52], [42, 54], [43, 44], [43, 45], [43, 50], [43, 51], [43, 52], [43, 53], [43, 54], [44, 46], [44, 47], [44, 49], [44, 51], [44, 53], [44, 54], [44, 55], [45, 48], [45, 49], [45, 51], [45, 52], [45, 53], [46, 47], [46, 48], [46, 49], [46, 50], [46, 51], [46, 52], [46, 55], [47, 48], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [47, 54], [48, 49], [48, 51], [48, 53], [48, 55], [49, 50], [49, 52], [49, 53], [49, 55], [50, 52], [50, 53], [50, 54], [50, 55], [51, 53], [51, 55], [52, 54], [53, 54], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s2/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..acd4faf29ba845e7d967c3617e7bb80541080ee5 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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' +{"clique": [1, 10, 16, 26, 29, 38, 41, 48, 51, 55]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l6-s2/tests/check.py b/tasks/construct-rlve-maximum-clique-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s2/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l6-s2/tests/instance.json b/tasks/construct-rlve-maximum-clique-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..18b3800c6b7a5c00f7c9ac994dfa2fa99d8d7c30 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 10, "edges": [[0, 1], [0, 4], [0, 5], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 15], [0, 17], [0, 18], [0, 19], [0, 21], [0, 22], [0, 23], [0, 24], [0, 26], [0, 30], [0, 31], [0, 32], [0, 34], [0, 35], [0, 36], [0, 38], [0, 39], [0, 40], [0, 42], [0, 43], [0, 45], [0, 46], [0, 47], [0, 50], [0, 51], [0, 52], [0, 53], [0, 54], [1, 3], [1, 5], [1, 6], [1, 9], [1, 10], [1, 11], [1, 12], [1, 16], [1, 17], [1, 20], [1, 21], [1, 24], [1, 26], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [1, 41], [1, 42], [1, 43], [1, 44], [1, 46], [1, 47], [1, 48], [1, 50], [1, 51], [1, 53], [1, 54], [1, 55], [2, 3], [2, 5], [2, 6], [2, 8], [2, 9], [2, 13], [2, 14], [2, 16], [2, 19], [2, 20], [2, 24], [2, 25], [2, 28], [2, 30], [2, 31], [2, 33], [2, 36], [2, 37], [2, 39], [2, 41], [2, 42], [2, 44], [2, 45], [2, 47], [2, 48], [2, 49], [2, 53], [2, 54], [2, 55], [3, 4], [3, 5], [3, 7], [3, 8], [3, 9], [3, 11], [3, 12], [3, 15], [3, 17], [3, 18], [3, 19], [3, 22], [3, 23], [3, 25], [3, 28], [3, 29], [3, 30], [3, 31], [3, 35], [3, 37], [3, 38], [3, 40], [3, 42], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [4, 5], [4, 6], [4, 7], [4, 9], [4, 12], [4, 13], [4, 14], [4, 17], [4, 21], [4, 22], [4, 26], [4, 29], [4, 31], [4, 35], [4, 38], [4, 39], [4, 40], [4, 42], [4, 43], [4, 44], [4, 49], [4, 50], [4, 51], [4, 52], [4, 54], [5, 7], [5, 10], [5, 11], [5, 12], [5, 14], [5, 16], [5, 17], [5, 18], [5, 19], [5, 23], [5, 24], [5, 26], [5, 27], [5, 28], [5, 31], [5, 32], [5, 34], [5, 37], [5, 39], [5, 40], [5, 42], [5, 44], [5, 45], [5, 46], [5, 47], [5, 52], [5, 53], [5, 55], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 13], [6, 15], [6, 16], [6, 18], [6, 19], [6, 23], [6, 24], [6, 27], [6, 28], [6, 30], [6, 32], [6, 33], [6, 34], [6, 35], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 46], [6, 47], [6, 49], [6, 50], [6, 51], [6, 55], [7, 8], [7, 9], [7, 11], [7, 12], [7, 18], [7, 20], [7, 22], [7, 23], [7, 24], [7, 28], [7, 31], [7, 32], [7, 34], [7, 37], [7, 38], [7, 40], [7, 41], [7, 44], [7, 49], [7, 51], [7, 52], [7, 53], [7, 54], [8, 11], [8, 12], [8, 16], [8, 17], [8, 19], [8, 21], [8, 23], [8, 25], [8, 26], [8, 28], [8, 29], [8, 31], [8, 32], [8, 34], [8, 35], [8, 36], [8, 39], [8, 40], [8, 41], [8, 42], [8, 43], [8, 44], [8, 46], [8, 47], [8, 50], [8, 51], [8, 53], [9, 10], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 21], [9, 25], [9, 27], [9, 28], [9, 30], [9, 31], [9, 32], [9, 35], [9, 36], [9, 37], [9, 41], [9, 44], [9, 45], [9, 48], [9, 49], [9, 50], [9, 52], [10, 11], [10, 13], [10, 15], [10, 16], [10, 17], [10, 19], [10, 20], [10, 21], [10, 23], [10, 25], [10, 26], [10, 27], [10, 29], [10, 30], [10, 31], [10, 34], [10, 36], [10, 37], [10, 38], [10, 39], [10, 41], [10, 44], [10, 45], [10, 46], [10, 47], [10, 48], [10, 50], [10, 51], [10, 52], [10, 53], [10, 54], [10, 55], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 31], [11, 32], [11, 33], [11, 34], [11, 36], [11, 37], [11, 40], [11, 41], [11, 45], [11, 46], [11, 47], [11, 48], [11, 50], [12, 13], [12, 14], [12, 15], [12, 17], [12, 19], [12, 21], [12, 23], [12, 25], [12, 26], [12, 27], [12, 29], [12, 30], [12, 35], [12, 36], [12, 37], [12, 38], [12, 40], [12, 42], [12, 43], [12, 45], [12, 46], [12, 47], [12, 48], [12, 49], [12, 51], [12, 52], [12, 53], [12, 55], [13, 14], [13, 16], [13, 19], [13, 20], [13, 21], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 30], [13, 33], [13, 35], [13, 37], [13, 38], [13, 40], [13, 41], [13, 42], [13, 44], [13, 45], [13, 46], [13, 47], [13, 48], [13, 49], [13, 51], [13, 52], [13, 54], [13, 55], [14, 18], [14, 21], [14, 22], [14, 23], [14, 25], [14, 30], [14, 31], [14, 35], [14, 36], [14, 37], [14, 40], [14, 41], [14, 42], [14, 46], [14, 48], [14, 49], [14, 51], [14, 52], [14, 55], [15, 16], [15, 17], [15, 18], [15, 19], [15, 22], [15, 23], [15, 24], [15, 25], [15, 29], [15, 32], [15, 33], [15, 34], [15, 36], [15, 40], [15, 42], [15, 43], [15, 46], [15, 48], [15, 49], [15, 52], [15, 53], [15, 55], [16, 17], [16, 18], [16, 19], [16, 25], [16, 26], [16, 27], [16, 29], [16, 30], [16, 32], [16, 35], [16, 37], [16, 38], [16, 40], [16, 41], [16, 43], [16, 45], [16, 47], [16, 48], [16, 49], [16, 50], [16, 51], [16, 52], [16, 53], [16, 54], [16, 55], [17, 18], [17, 19], [17, 20], [17, 21], [17, 24], [17, 25], [17, 26], [17, 28], [17, 32], [17, 34], [17, 36], [17, 37], [17, 38], [17, 39], [17, 40], [17, 41], [17, 43], [17, 45], [17, 46], [17, 48], [17, 49], [17, 50], [17, 51], [17, 52], [18, 20], [18, 21], [18, 22], [18, 25], [18, 26], [18, 27], [18, 29], [18, 30], [18, 32], [18, 34], [18, 35], [18, 38], [18, 39], [18, 42], [18, 43], [18, 44], [18, 45], [18, 46], [18, 47], [18, 48], [18, 50], [18, 51], [19, 23], [19, 25], [19, 26], [19, 27], [19, 30], [19, 31], [19, 33], [19, 34], [19, 35], [19, 36], [19, 39], [19, 40], [19, 41], [19, 43], [19, 44], [19, 46], [19, 47], [19, 48], [19, 50], [19, 53], [19, 54], [20, 21], [20, 22], [20, 23], [20, 24], [20, 26], [20, 28], [20, 32], [20, 33], [20, 34], [20, 37], [20, 38], [20, 39], [20, 40], [20, 41], [20, 44], [20, 46], [20, 47], [20, 51], [20, 52], [20, 53], [20, 54], [20, 55], [21, 22], [21, 23], [21, 25], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 34], [21, 36], [21, 38], [21, 39], [21, 40], [21, 41], [21, 42], [21, 43], [21, 45], [21, 47], [21, 49], [21, 50], [21, 51], [21, 53], [21, 54], [21, 55], [22, 26], [22, 27], [22, 28], [22, 29], [22, 31], [22, 32], [22, 33], [22, 35], [22, 36], [22, 37], [22, 38], [22, 41], [22, 45], [22, 47], [22, 48], [22, 50], [22, 51], [22, 52], [22, 53], [22, 54], [22, 55], [23, 24], [23, 25], [23, 27], [23, 31], [23, 33], [23, 34], [23, 35], [23, 38], [23, 39], [23, 40], [23, 41], [23, 43], [23, 44], [23, 47], [23, 48], [23, 49], [23, 50], [23, 51], [23, 52], [24, 25], [24, 29], [24, 31], [24, 32], [24, 33], [24, 35], [24, 37], [24, 38], [24, 39], [24, 40], [24, 41], [24, 42], [24, 43], [24, 45], [24, 46], [24, 48], [24, 49], [24, 53], [24, 54], [25, 28], [25, 30], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [25, 38], [25, 40], [25, 41], [25, 43], [25, 46], [25, 47], [25, 48], [25, 52], [25, 53], [25, 55], [26, 27], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [26, 36], [26, 37], [26, 38], [26, 40], [26, 41], [26, 42], [26, 43], [26, 44], [26, 45], [26, 46], [26, 48], [26, 49], [26, 50], [26, 51], [26, 52], [26, 53], [26, 55], [27, 29], [27, 30], [27, 33], [27, 34], [27, 35], [27, 36], [27, 38], [27, 39], [27, 40], [27, 41], [27, 43], [27, 44], [27, 45], [27, 46], [27, 48], [27, 49], [27, 50], [27, 53], [27, 54], [27, 55], [28, 30], [28, 33], [28, 34], [28, 36], [28, 38], [28, 39], [28, 40], [28, 41], [28, 42], [28, 44], [28, 46], [28, 47], [28, 50], [28, 51], [28, 54], [29, 30], [29, 31], [29, 32], [29, 33], [29, 36], [29, 38], [29, 41], [29, 42], [29, 43], [29, 45], [29, 47], [29, 48], [29, 51], [29, 52], [29, 54], [29, 55], [30, 31], [30, 32], [30, 34], [30, 35], [30, 40], [30, 41], [30, 42], [30, 43], [30, 45], [30, 47], [30, 48], [30, 49], [30, 52], [31, 33], [31, 35], [31, 36], [31, 37], [31, 38], [31, 39], [31, 40], [31, 41], [31, 42], [31, 43], [31, 44], [31, 45], [31, 47], [31, 49], [31, 50], [31, 51], [31, 52], [31, 55], [32, 34], [32, 36], [32, 37], [32, 39], [32, 40], [32, 41], [32, 43], [32, 45], [32, 47], [32, 48], [32, 50], [32, 53], [32, 54], [32, 55], [33, 35], [33, 36], [33, 38], [33, 39], [33, 40], [33, 42], [33, 43], [33, 48], [33, 50], [33, 51], [33, 52], [33, 54], [33, 55], [34, 42], [34, 46], [34, 48], [34, 50], [34, 51], [34, 52], [34, 54], [34, 55], [35, 36], [35, 37], [35, 39], [35, 40], [35, 41], [35, 42], [35, 44], [35, 47], [35, 48], [35, 49], [35, 53], [35, 54], [35, 55], [36, 37], [36, 38], [36, 40], [36, 41], [36, 42], [36, 45], [36, 46], [36, 47], [36, 52], [36, 55], [37, 38], [37, 41], [37, 45], [37, 46], [37, 47], [37, 49], [37, 50], [37, 52], [37, 53], [38, 39], [38, 40], [38, 41], [38, 42], [38, 43], [38, 44], [38, 46], [38, 48], [38, 49], [38, 51], [38, 53], [38, 55], [39, 43], [39, 44], [39, 49], [39, 52], [39, 53], [39, 54], [40, 41], [40, 44], [40, 45], [40, 47], [40, 50], [40, 51], [40, 53], [40, 54], [40, 55], [41, 44], [41, 45], [41, 47], [41, 48], [41, 50], [41, 51], [41, 52], [41, 55], [42, 44], [42, 46], [42, 47], [42, 49], [42, 52], [42, 54], [43, 44], [43, 45], [43, 50], [43, 51], [43, 52], [43, 53], [43, 54], [44, 46], [44, 47], [44, 49], [44, 51], [44, 53], [44, 54], [44, 55], [45, 48], [45, 49], [45, 51], [45, 52], [45, 53], [46, 47], [46, 48], [46, 49], [46, 50], [46, 51], [46, 52], [46, 55], [47, 48], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [47, 54], [48, 49], [48, 51], [48, 53], [48, 55], [49, 50], [49, 52], [49, 53], [49, 55], [50, 52], [50, 53], [50, 54], [50, 55], [51, 53], [51, 55], [52, 54], [53, 54], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s2/tests/run.py b/tasks/construct-rlve-maximum-clique-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l6-s2/tests/test.sh b/tasks/construct-rlve-maximum-clique-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-rlve-maximum-clique-l6-s5/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l6-s5/environment/instance.json b/tasks/construct-rlve-maximum-clique-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..65594b44f01843ebc4caba8f366fc3625acaca73 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 12, "edges": [[0, 1], [0, 4], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [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, 28], [0, 29], [0, 31], [0, 32], [0, 34], [0, 36], [0, 38], [0, 39], [0, 40], [0, 41], [0, 42], [0, 43], [0, 44], [0, 46], [0, 49], [0, 50], [0, 52], [0, 53], [0, 54], [0, 55], [1, 3], [1, 5], [1, 6], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 16], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 29], [1, 31], [1, 32], [1, 35], [1, 36], [1, 37], [1, 40], [1, 43], [1, 44], [1, 45], [1, 47], [1, 48], [1, 49], [1, 50], [1, 51], [1, 53], [1, 54], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 11], [2, 13], [2, 14], [2, 17], [2, 18], [2, 20], [2, 21], [2, 23], [2, 25], [2, 26], [2, 27], [2, 29], [2, 30], [2, 32], [2, 35], [2, 36], [2, 37], [2, 38], [2, 39], [2, 40], [2, 42], [2, 44], [2, 45], [2, 46], [2, 49], [2, 50], [2, 52], [2, 54], [2, 55], [3, 6], [3, 7], [3, 8], [3, 10], [3, 11], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 23], [3, 24], [3, 25], [3, 26], [3, 28], [3, 29], [3, 30], [3, 33], [3, 36], [3, 37], [3, 38], [3, 39], [3, 43], [3, 44], [3, 45], [3, 47], [3, 48], [3, 49], [3, 52], [3, 54], [3, 55], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 15], [4, 16], [4, 17], [4, 19], [4, 20], [4, 21], [4, 23], [4, 24], [4, 26], [4, 28], [4, 30], [4, 31], [4, 32], [4, 34], [4, 37], [4, 38], [4, 39], [4, 41], [4, 42], [4, 43], [4, 45], [4, 46], [4, 47], [4, 48], [4, 49], [4, 50], [4, 54], [4, 55], [5, 6], [5, 8], [5, 11], [5, 12], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 24], [5, 27], [5, 28], [5, 29], [5, 30], [5, 32], [5, 33], [5, 34], [5, 35], [5, 37], [5, 38], [5, 39], [5, 40], [5, 43], [5, 46], [5, 47], [5, 48], [5, 49], [5, 50], [5, 51], [5, 52], [5, 53], [5, 55], [6, 8], [6, 9], [6, 11], [6, 12], [6, 13], [6, 14], [6, 17], [6, 18], [6, 19], [6, 20], [6, 22], [6, 23], [6, 26], [6, 27], [6, 29], [6, 31], [6, 33], [6, 34], [6, 36], [6, 38], [6, 40], [6, 42], [6, 43], [6, 44], [6, 45], [6, 47], [6, 48], [6, 49], [6, 50], [6, 51], [6, 53], [7, 9], [7, 10], [7, 13], [7, 14], [7, 15], [7, 16], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 32], [7, 33], [7, 34], [7, 35], [7, 36], [7, 38], [7, 39], [7, 40], [7, 43], [7, 47], [7, 48], [7, 49], [7, 50], [7, 51], [7, 52], [7, 53], [7, 54], [7, 55], [8, 9], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 19], [8, 20], [8, 21], [8, 23], [8, 24], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 32], [8, 34], [8, 35], [8, 36], [8, 38], [8, 39], [8, 40], [8, 41], [8, 42], [8, 43], [8, 44], [8, 45], [8, 46], [8, 47], [8, 48], [8, 49], [8, 50], [8, 52], [8, 53], [8, 55], [9, 11], [9, 13], [9, 14], [9, 16], [9, 19], [9, 20], [9, 21], [9, 24], [9, 25], [9, 27], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 35], [9, 37], [9, 39], [9, 40], [9, 41], [9, 42], [9, 43], [9, 44], [9, 45], [9, 46], [9, 49], [9, 50], [9, 52], [9, 55], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 20], [10, 22], [10, 23], [10, 26], [10, 27], [10, 32], [10, 34], [10, 35], [10, 36], [10, 38], [10, 39], [10, 40], [10, 41], [10, 42], [10, 43], [10, 44], [10, 45], [10, 46], [10, 47], [10, 49], [10, 50], [10, 52], [10, 53], [10, 54], [10, 55], [11, 13], [11, 14], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 22], [11, 26], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 35], [11, 36], [11, 39], [11, 40], [11, 41], [11, 42], [11, 43], [11, 45], [11, 46], [11, 48], [11, 49], [11, 51], [11, 52], [11, 53], [11, 55], [12, 13], [12, 15], [12, 17], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 31], [12, 34], [12, 36], [12, 37], [12, 39], [12, 40], [12, 41], [12, 43], [12, 44], [12, 45], [12, 46], [12, 47], [12, 48], [12, 51], [12, 53], [12, 54], [12, 55], [13, 16], [13, 18], [13, 20], [13, 22], [13, 25], [13, 26], [13, 28], [13, 29], [13, 30], [13, 35], [13, 38], [13, 39], [13, 40], [13, 41], [13, 42], [13, 43], [13, 44], [13, 45], [13, 46], [13, 47], [13, 49], [13, 50], [13, 51], [13, 52], [13, 53], [13, 54], [13, 55], [14, 15], [14, 16], [14, 17], [14, 18], [14, 22], [14, 23], [14, 26], [14, 27], [14, 28], [14, 29], [14, 31], [14, 33], [14, 34], [14, 35], [14, 39], [14, 40], [14, 41], [14, 43], [14, 44], [14, 46], [14, 47], [14, 48], [14, 49], [14, 51], [14, 52], [14, 55], [15, 16], [15, 18], [15, 19], [15, 21], [15, 22], [15, 23], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 32], [15, 33], [15, 34], [15, 35], [15, 36], [15, 37], [15, 39], [15, 40], [15, 41], [15, 42], [15, 44], [15, 45], [15, 46], [15, 47], [15, 48], [15, 50], [15, 51], [15, 52], [15, 53], [15, 54], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 27], [16, 28], [16, 29], [16, 31], [16, 32], [16, 35], [16, 36], [16, 37], [16, 38], [16, 39], [16, 40], [16, 41], [16, 43], [16, 44], [16, 45], [16, 48], [16, 49], [16, 50], [16, 51], [16, 52], [16, 53], [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, 34], [17, 35], [17, 36], [17, 37], [17, 40], [17, 42], [17, 45], [17, 46], [17, 48], [17, 50], [17, 51], [17, 52], [17, 54], [17, 55], [18, 21], [18, 22], [18, 25], [18, 26], [18, 27], [18, 28], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [18, 37], [18, 38], [18, 39], [18, 40], [18, 41], [18, 42], [18, 45], [18, 52], [18, 53], [18, 55], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 26], [19, 27], [19, 28], [19, 30], [19, 31], [19, 33], [19, 34], [19, 35], [19, 36], [19, 38], [19, 43], [19, 45], [19, 46], [19, 47], [19, 48], [19, 49], [19, 53], [19, 54], [19, 55], [20, 22], [20, 23], [20, 24], [20, 25], [20, 27], [20, 30], [20, 32], [20, 33], [20, 34], [20, 35], [20, 36], [20, 38], [20, 39], [20, 40], [20, 42], [20, 46], [20, 47], [20, 48], [20, 49], [20, 50], [20, 51], [20, 52], [20, 53], [20, 54], [20, 55], [21, 22], [21, 23], [21, 24], [21, 25], [21, 28], [21, 31], [21, 32], [21, 34], [21, 35], [21, 36], [21, 38], [21, 39], [21, 40], [21, 41], [21, 42], [21, 43], [21, 44], [21, 45], [21, 46], [21, 47], [21, 48], [21, 49], [21, 51], [21, 52], [21, 53], [21, 55], [22, 23], [22, 24], [22, 25], [22, 26], [22, 30], [22, 32], [22, 33], [22, 34], [22, 35], [22, 36], [22, 37], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 45], [22, 46], [22, 47], [22, 48], [22, 49], [22, 51], [22, 52], [22, 53], [22, 54], [22, 55], [23, 24], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 31], [23, 32], [23, 34], [23, 35], [23, 36], [23, 41], [23, 42], [23, 44], [23, 45], [23, 46], [23, 47], [23, 48], [23, 49], [23, 50], [23, 51], [23, 52], [23, 53], [23, 54], [23, 55], [24, 25], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 36], [24, 37], [24, 39], [24, 40], [24, 41], [24, 42], [24, 43], [24, 44], [24, 45], [24, 48], [24, 49], [24, 50], [24, 51], [24, 52], [24, 53], [24, 55], [25, 27], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [25, 36], [25, 37], [25, 38], [25, 40], [25, 41], [25, 42], [25, 43], [25, 44], [25, 46], [25, 47], [25, 48], [25, 49], [25, 51], [25, 53], [25, 54], [25, 55], [26, 28], [26, 29], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [26, 37], [26, 38], [26, 39], [26, 40], [26, 41], [26, 42], [26, 43], [26, 44], [26, 45], [26, 48], [26, 49], [26, 50], [26, 51], [26, 52], [26, 55], [27, 28], [27, 29], [27, 31], [27, 32], [27, 34], [27, 35], [27, 37], [27, 38], [27, 41], [27, 42], [27, 43], [27, 44], [27, 45], [27, 46], [27, 47], [27, 48], [27, 49], [27, 50], [27, 52], [27, 54], [27, 55], [28, 30], [28, 31], [28, 33], [28, 34], [28, 38], [28, 42], [28, 44], [28, 45], [28, 46], [28, 48], [28, 49], [28, 50], [28, 51], [28, 52], [28, 53], [28, 55], [29, 30], [29, 31], [29, 32], [29, 34], [29, 37], [29, 39], [29, 42], [29, 43], [29, 45], [29, 46], [29, 47], [29, 49], [29, 50], [29, 51], [29, 52], [29, 53], [29, 54], [29, 55], [30, 31], [30, 32], [30, 33], [30, 34], [30, 35], [30, 39], [30, 40], [30, 41], [30, 42], [30, 43], [30, 45], [30, 47], [30, 48], [30, 49], [30, 51], [30, 52], [30, 53], [30, 54], [31, 32], [31, 33], [31, 38], [31, 40], [31, 41], [31, 42], [31, 43], [31, 44], [31, 46], [31, 47], [31, 48], [31, 50], [31, 52], [31, 53], [31, 54], [31, 55], [32, 33], [32, 36], [32, 38], [32, 39], [32, 40], [32, 41], [32, 42], [32, 43], [32, 46], [32, 49], [32, 50], [32, 52], [32, 53], [32, 54], [33, 36], [33, 38], [33, 39], [33, 41], [33, 42], [33, 43], [33, 44], [33, 45], [33, 46], [33, 50], [33, 52], [33, 54], [33, 55], [34, 37], [34, 38], [34, 39], [34, 40], [34, 41], [34, 42], [34, 43], [34, 44], [34, 47], [34, 49], [34, 50], [34, 51], [34, 52], [34, 53], [34, 55], [35, 36], [35, 37], [35, 39], [35, 41], [35, 43], [35, 44], [35, 45], [35, 46], [35, 47], [35, 48], [35, 51], [35, 52], [35, 53], [35, 54], [36, 37], [36, 38], [36, 39], [36, 41], [36, 43], [36, 44], [36, 45], [36, 46], [36, 47], [36, 48], [36, 49], [36, 51], [36, 52], [36, 53], [36, 55], [37, 38], [37, 39], [37, 40], [37, 41], [37, 42], [37, 43], [37, 48], [37, 49], [37, 50], [37, 51], [37, 52], [37, 53], [37, 54], [37, 55], [38, 40], [38, 41], [38, 42], [38, 43], [38, 45], [38, 47], [38, 48], [38, 49], [38, 52], [38, 53], [38, 54], [38, 55], [39, 40], [39, 41], [39, 42], [39, 43], [39, 44], [39, 45], [39, 47], [39, 48], [39, 50], [39, 52], [39, 53], [39, 54], [39, 55], [40, 41], [40, 42], [40, 43], [40, 45], [40, 48], [40, 49], [40, 51], [40, 52], [40, 53], [40, 55], [41, 42], [41, 43], [41, 44], [41, 45], [41, 47], [41, 49], [41, 50], [41, 53], [41, 54], [41, 55], [42, 43], [42, 45], [42, 46], [42, 48], [42, 52], [42, 54], [42, 55], [43, 44], [43, 45], [43, 47], [43, 48], [43, 49], [43, 50], [43, 51], [43, 53], [43, 54], [44, 47], [44, 48], [44, 49], [44, 52], [44, 53], [44, 54], [44, 55], [45, 46], [45, 47], [45, 48], [45, 49], [45, 51], [45, 53], [46, 49], [46, 50], [46, 52], [46, 53], [46, 54], [46, 55], [47, 49], [47, 50], [47, 51], [47, 52], [48, 50], [48, 51], [48, 53], [48, 54], [48, 55], [49, 50], [49, 52], [49, 53], [49, 54], [50, 51], [50, 52], [50, 53], [50, 54], [50, 55], [51, 55], [52, 53], [52, 55], [53, 54], [53, 55], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s5/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f6d8776d66c022d04a08a05a936d3c463f9818b --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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' +{"clique": [0, 7, 10, 13, 16, 20, 22, 38, 40, 49, 52, 53]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l6-s5/tests/check.py b/tasks/construct-rlve-maximum-clique-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s5/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l6-s5/tests/instance.json b/tasks/construct-rlve-maximum-clique-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..65594b44f01843ebc4caba8f366fc3625acaca73 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 12, "edges": [[0, 1], [0, 4], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [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, 28], [0, 29], [0, 31], [0, 32], [0, 34], [0, 36], [0, 38], [0, 39], [0, 40], [0, 41], [0, 42], [0, 43], [0, 44], [0, 46], [0, 49], [0, 50], [0, 52], [0, 53], [0, 54], [0, 55], [1, 3], [1, 5], [1, 6], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 16], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 29], [1, 31], [1, 32], [1, 35], [1, 36], [1, 37], [1, 40], [1, 43], [1, 44], [1, 45], [1, 47], [1, 48], [1, 49], [1, 50], [1, 51], [1, 53], [1, 54], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 11], [2, 13], [2, 14], [2, 17], [2, 18], [2, 20], [2, 21], [2, 23], [2, 25], [2, 26], [2, 27], [2, 29], [2, 30], [2, 32], [2, 35], [2, 36], [2, 37], [2, 38], [2, 39], [2, 40], [2, 42], [2, 44], [2, 45], [2, 46], [2, 49], [2, 50], [2, 52], [2, 54], [2, 55], [3, 6], [3, 7], [3, 8], [3, 10], [3, 11], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 23], [3, 24], [3, 25], [3, 26], [3, 28], [3, 29], [3, 30], [3, 33], [3, 36], [3, 37], [3, 38], [3, 39], [3, 43], [3, 44], [3, 45], [3, 47], [3, 48], [3, 49], [3, 52], [3, 54], [3, 55], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 15], [4, 16], [4, 17], [4, 19], [4, 20], [4, 21], [4, 23], [4, 24], [4, 26], [4, 28], [4, 30], [4, 31], [4, 32], [4, 34], [4, 37], [4, 38], [4, 39], [4, 41], [4, 42], [4, 43], [4, 45], [4, 46], [4, 47], [4, 48], [4, 49], [4, 50], [4, 54], [4, 55], [5, 6], [5, 8], [5, 11], [5, 12], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 24], [5, 27], [5, 28], [5, 29], [5, 30], [5, 32], [5, 33], [5, 34], [5, 35], [5, 37], [5, 38], [5, 39], [5, 40], [5, 43], [5, 46], [5, 47], [5, 48], [5, 49], [5, 50], [5, 51], [5, 52], [5, 53], [5, 55], [6, 8], [6, 9], [6, 11], [6, 12], [6, 13], [6, 14], [6, 17], [6, 18], [6, 19], [6, 20], [6, 22], [6, 23], [6, 26], [6, 27], [6, 29], [6, 31], [6, 33], [6, 34], [6, 36], [6, 38], [6, 40], [6, 42], [6, 43], [6, 44], [6, 45], [6, 47], [6, 48], [6, 49], [6, 50], [6, 51], [6, 53], [7, 9], [7, 10], [7, 13], [7, 14], [7, 15], [7, 16], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 32], [7, 33], [7, 34], [7, 35], [7, 36], [7, 38], [7, 39], [7, 40], [7, 43], [7, 47], [7, 48], [7, 49], [7, 50], [7, 51], [7, 52], [7, 53], [7, 54], [7, 55], [8, 9], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 19], [8, 20], [8, 21], [8, 23], [8, 24], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 32], [8, 34], [8, 35], [8, 36], [8, 38], [8, 39], [8, 40], [8, 41], [8, 42], [8, 43], [8, 44], [8, 45], [8, 46], [8, 47], [8, 48], [8, 49], [8, 50], [8, 52], [8, 53], [8, 55], [9, 11], [9, 13], [9, 14], [9, 16], [9, 19], [9, 20], [9, 21], [9, 24], [9, 25], [9, 27], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 35], [9, 37], [9, 39], [9, 40], [9, 41], [9, 42], [9, 43], [9, 44], [9, 45], [9, 46], [9, 49], [9, 50], [9, 52], [9, 55], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 20], [10, 22], [10, 23], [10, 26], [10, 27], [10, 32], [10, 34], [10, 35], [10, 36], [10, 38], [10, 39], [10, 40], [10, 41], [10, 42], [10, 43], [10, 44], [10, 45], [10, 46], [10, 47], [10, 49], [10, 50], [10, 52], [10, 53], [10, 54], [10, 55], [11, 13], [11, 14], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 22], [11, 26], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 35], [11, 36], [11, 39], [11, 40], [11, 41], [11, 42], [11, 43], [11, 45], [11, 46], [11, 48], [11, 49], [11, 51], [11, 52], [11, 53], [11, 55], [12, 13], [12, 15], [12, 17], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 31], [12, 34], [12, 36], [12, 37], [12, 39], [12, 40], [12, 41], [12, 43], [12, 44], [12, 45], [12, 46], [12, 47], [12, 48], [12, 51], [12, 53], [12, 54], [12, 55], [13, 16], [13, 18], [13, 20], [13, 22], [13, 25], [13, 26], [13, 28], [13, 29], [13, 30], [13, 35], [13, 38], [13, 39], [13, 40], [13, 41], [13, 42], [13, 43], [13, 44], [13, 45], [13, 46], [13, 47], [13, 49], [13, 50], [13, 51], [13, 52], [13, 53], [13, 54], [13, 55], [14, 15], [14, 16], [14, 17], [14, 18], [14, 22], [14, 23], [14, 26], [14, 27], [14, 28], [14, 29], [14, 31], [14, 33], [14, 34], [14, 35], [14, 39], [14, 40], [14, 41], [14, 43], [14, 44], [14, 46], [14, 47], [14, 48], [14, 49], [14, 51], [14, 52], [14, 55], [15, 16], [15, 18], [15, 19], [15, 21], [15, 22], [15, 23], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 32], [15, 33], [15, 34], [15, 35], [15, 36], [15, 37], [15, 39], [15, 40], [15, 41], [15, 42], [15, 44], [15, 45], [15, 46], [15, 47], [15, 48], [15, 50], [15, 51], [15, 52], [15, 53], [15, 54], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 27], [16, 28], [16, 29], [16, 31], [16, 32], [16, 35], [16, 36], [16, 37], [16, 38], [16, 39], [16, 40], [16, 41], [16, 43], [16, 44], [16, 45], [16, 48], [16, 49], [16, 50], [16, 51], [16, 52], [16, 53], [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, 34], [17, 35], [17, 36], [17, 37], [17, 40], [17, 42], [17, 45], [17, 46], [17, 48], [17, 50], [17, 51], [17, 52], [17, 54], [17, 55], [18, 21], [18, 22], [18, 25], [18, 26], [18, 27], [18, 28], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [18, 37], [18, 38], [18, 39], [18, 40], [18, 41], [18, 42], [18, 45], [18, 52], [18, 53], [18, 55], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 26], [19, 27], [19, 28], [19, 30], [19, 31], [19, 33], [19, 34], [19, 35], [19, 36], [19, 38], [19, 43], [19, 45], [19, 46], [19, 47], [19, 48], [19, 49], [19, 53], [19, 54], [19, 55], [20, 22], [20, 23], [20, 24], [20, 25], [20, 27], [20, 30], [20, 32], [20, 33], [20, 34], [20, 35], [20, 36], [20, 38], [20, 39], [20, 40], [20, 42], [20, 46], [20, 47], [20, 48], [20, 49], [20, 50], [20, 51], [20, 52], [20, 53], [20, 54], [20, 55], [21, 22], [21, 23], [21, 24], [21, 25], [21, 28], [21, 31], [21, 32], [21, 34], [21, 35], [21, 36], [21, 38], [21, 39], [21, 40], [21, 41], [21, 42], [21, 43], [21, 44], [21, 45], [21, 46], [21, 47], [21, 48], [21, 49], [21, 51], [21, 52], [21, 53], [21, 55], [22, 23], [22, 24], [22, 25], [22, 26], [22, 30], [22, 32], [22, 33], [22, 34], [22, 35], [22, 36], [22, 37], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 45], [22, 46], [22, 47], [22, 48], [22, 49], [22, 51], [22, 52], [22, 53], [22, 54], [22, 55], [23, 24], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 31], [23, 32], [23, 34], [23, 35], [23, 36], [23, 41], [23, 42], [23, 44], [23, 45], [23, 46], [23, 47], [23, 48], [23, 49], [23, 50], [23, 51], [23, 52], [23, 53], [23, 54], [23, 55], [24, 25], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 36], [24, 37], [24, 39], [24, 40], [24, 41], [24, 42], [24, 43], [24, 44], [24, 45], [24, 48], [24, 49], [24, 50], [24, 51], [24, 52], [24, 53], [24, 55], [25, 27], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [25, 36], [25, 37], [25, 38], [25, 40], [25, 41], [25, 42], [25, 43], [25, 44], [25, 46], [25, 47], [25, 48], [25, 49], [25, 51], [25, 53], [25, 54], [25, 55], [26, 28], [26, 29], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [26, 37], [26, 38], [26, 39], [26, 40], [26, 41], [26, 42], [26, 43], [26, 44], [26, 45], [26, 48], [26, 49], [26, 50], [26, 51], [26, 52], [26, 55], [27, 28], [27, 29], [27, 31], [27, 32], [27, 34], [27, 35], [27, 37], [27, 38], [27, 41], [27, 42], [27, 43], [27, 44], [27, 45], [27, 46], [27, 47], [27, 48], [27, 49], [27, 50], [27, 52], [27, 54], [27, 55], [28, 30], [28, 31], [28, 33], [28, 34], [28, 38], [28, 42], [28, 44], [28, 45], [28, 46], [28, 48], [28, 49], [28, 50], [28, 51], [28, 52], [28, 53], [28, 55], [29, 30], [29, 31], [29, 32], [29, 34], [29, 37], [29, 39], [29, 42], [29, 43], [29, 45], [29, 46], [29, 47], [29, 49], [29, 50], [29, 51], [29, 52], [29, 53], [29, 54], [29, 55], [30, 31], [30, 32], [30, 33], [30, 34], [30, 35], [30, 39], [30, 40], [30, 41], [30, 42], [30, 43], [30, 45], [30, 47], [30, 48], [30, 49], [30, 51], [30, 52], [30, 53], [30, 54], [31, 32], [31, 33], [31, 38], [31, 40], [31, 41], [31, 42], [31, 43], [31, 44], [31, 46], [31, 47], [31, 48], [31, 50], [31, 52], [31, 53], [31, 54], [31, 55], [32, 33], [32, 36], [32, 38], [32, 39], [32, 40], [32, 41], [32, 42], [32, 43], [32, 46], [32, 49], [32, 50], [32, 52], [32, 53], [32, 54], [33, 36], [33, 38], [33, 39], [33, 41], [33, 42], [33, 43], [33, 44], [33, 45], [33, 46], [33, 50], [33, 52], [33, 54], [33, 55], [34, 37], [34, 38], [34, 39], [34, 40], [34, 41], [34, 42], [34, 43], [34, 44], [34, 47], [34, 49], [34, 50], [34, 51], [34, 52], [34, 53], [34, 55], [35, 36], [35, 37], [35, 39], [35, 41], [35, 43], [35, 44], [35, 45], [35, 46], [35, 47], [35, 48], [35, 51], [35, 52], [35, 53], [35, 54], [36, 37], [36, 38], [36, 39], [36, 41], [36, 43], [36, 44], [36, 45], [36, 46], [36, 47], [36, 48], [36, 49], [36, 51], [36, 52], [36, 53], [36, 55], [37, 38], [37, 39], [37, 40], [37, 41], [37, 42], [37, 43], [37, 48], [37, 49], [37, 50], [37, 51], [37, 52], [37, 53], [37, 54], [37, 55], [38, 40], [38, 41], [38, 42], [38, 43], [38, 45], [38, 47], [38, 48], [38, 49], [38, 52], [38, 53], [38, 54], [38, 55], [39, 40], [39, 41], [39, 42], [39, 43], [39, 44], [39, 45], [39, 47], [39, 48], [39, 50], [39, 52], [39, 53], [39, 54], [39, 55], [40, 41], [40, 42], [40, 43], [40, 45], [40, 48], [40, 49], [40, 51], [40, 52], [40, 53], [40, 55], [41, 42], [41, 43], [41, 44], [41, 45], [41, 47], [41, 49], [41, 50], [41, 53], [41, 54], [41, 55], [42, 43], [42, 45], [42, 46], [42, 48], [42, 52], [42, 54], [42, 55], [43, 44], [43, 45], [43, 47], [43, 48], [43, 49], [43, 50], [43, 51], [43, 53], [43, 54], [44, 47], [44, 48], [44, 49], [44, 52], [44, 53], [44, 54], [44, 55], [45, 46], [45, 47], [45, 48], [45, 49], [45, 51], [45, 53], [46, 49], [46, 50], [46, 52], [46, 53], [46, 54], [46, 55], [47, 49], [47, 50], [47, 51], [47, 52], [48, 50], [48, 51], [48, 53], [48, 54], [48, 55], [49, 50], [49, 52], [49, 53], [49, 54], [50, 51], [50, 52], [50, 53], [50, 54], [50, 55], [51, 55], [52, 53], [52, 55], [53, 54], [53, 55], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s5/tests/run.py b/tasks/construct-rlve-maximum-clique-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l6-s5/tests/test.sh b/tasks/construct-rlve-maximum-clique-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-min-chromatic-number-l1-s7/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l1-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l1-s7/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bf72afdbd7bb397946605eb0703606de74c68b41 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 2], [0, 5], [2, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s7/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l1-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b70425146a1f57d8f0818aa5b5ca6b7d754cffec --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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' +{"colors": [0, 0, 1, 0, 0, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s7/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l1-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s7/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-l1-s7/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bf72afdbd7bb397946605eb0703606de74c68b41 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 2], [0, 5], [2, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s7/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l1-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l1-s7/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l1-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l5-s8/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l5-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s8/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l5-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..769e6ad01b4572808bda221f32b6ccadf4a3262b --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 24, "k": 5, "edges": [[0, 3], [0, 4], [0, 5], [0, 7], [0, 10], [0, 12], [0, 14], [0, 17], [0, 18], [0, 19], [1, 6], [1, 7], [1, 13], [1, 19], [1, 20], [1, 21], [2, 3], [2, 4], [2, 6], [2, 13], [2, 21], [3, 8], [3, 10], [3, 11], [3, 15], [3, 16], [3, 18], [3, 21], [3, 23], [4, 5], [4, 6], [4, 8], [4, 11], [4, 15], [4, 16], [4, 17], [4, 23], [5, 8], [5, 13], [5, 16], [5, 17], [6, 7], [6, 8], [6, 9], [6, 13], [6, 18], [7, 9], [7, 21], [8, 9], [8, 10], [8, 14], [8, 16], [8, 17], [8, 19], [9, 10], [9, 12], [9, 13], [9, 19], [9, 20], [10, 17], [10, 18], [10, 20], [10, 21], [10, 22], [10, 23], [11, 13], [11, 15], [11, 19], [11, 20], [11, 23], [12, 13], [12, 16], [12, 17], [12, 21], [12, 22], [12, 23], [13, 16], [13, 18], [13, 20], [13, 23], [14, 16], [14, 17], [14, 22], [15, 16], [15, 18], [15, 19], [15, 20], [16, 18], [16, 20], [16, 22], [17, 18], [17, 20], [18, 21], [18, 22], [19, 20], [19, 23]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s8/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l5-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7443a281530a66a5c0b86292d70dac3bee606c96 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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' +{"colors": [0, 0, 0, 1, 1, 2, 2, 1, 0, 3, 2, 0, 2, 1, 1, 2, 3, 3, 4, 1, 4, 3, 0, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s8/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l5-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s8/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-l5-s8/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l5-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..769e6ad01b4572808bda221f32b6ccadf4a3262b --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 24, "k": 5, "edges": [[0, 3], [0, 4], [0, 5], [0, 7], [0, 10], [0, 12], [0, 14], [0, 17], [0, 18], [0, 19], [1, 6], [1, 7], [1, 13], [1, 19], [1, 20], [1, 21], [2, 3], [2, 4], [2, 6], [2, 13], [2, 21], [3, 8], [3, 10], [3, 11], [3, 15], [3, 16], [3, 18], [3, 21], [3, 23], [4, 5], [4, 6], [4, 8], [4, 11], [4, 15], [4, 16], [4, 17], [4, 23], [5, 8], [5, 13], [5, 16], [5, 17], [6, 7], [6, 8], [6, 9], [6, 13], [6, 18], [7, 9], [7, 21], [8, 9], [8, 10], [8, 14], [8, 16], [8, 17], [8, 19], [9, 10], [9, 12], [9, 13], [9, 19], [9, 20], [10, 17], [10, 18], [10, 20], [10, 21], [10, 22], [10, 23], [11, 13], [11, 15], [11, 19], [11, 20], [11, 23], [12, 13], [12, 16], [12, 17], [12, 21], [12, 22], [12, 23], [13, 16], [13, 18], [13, 20], [13, 23], [14, 16], [14, 17], [14, 22], [15, 16], [15, 18], [15, 19], [15, 20], [16, 18], [16, 20], [16, 22], [17, 18], [17, 20], [18, 21], [18, 22], [19, 20], [19, 23]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s8/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l5-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s8/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l5-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s2/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l5-s2/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..06a0b83a005235d6799c6d58c7ba586d8138ffdb --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 9, "edges": [[0, 2], [0, 7], [0, 12], [1, 5], [1, 9], [2, 4], [2, 5], [2, 7], [2, 9], [3, 4], [3, 6], [3, 12], [4, 9], [4, 11], [5, 7], [5, 8], [5, 13], [6, 9], [6, 10], [6, 14], [7, 11], [7, 13], [10, 11], [10, 13], [12, 13], [12, 14]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s2/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8cc51866d6edd51b08597de173a70321860c3229 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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' +{"colors": [0, 0, 1, 2, 3, 2, 4, 5, 6, 7, 6, 8, 8, 7, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s2/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-l2-s8/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l2-s8/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e87bbe26c8b1cbf220f806ad543cfee93016311c --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"A": 814, "B": 904, "C": 1, "D": 201, "target": 180, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s8/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..90262d39356c986766de52bdbe2311d5d6fe20d3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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' +{"X": 900, "Y": 180} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s8/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s8/tests/check.py @@ -0,0 +1,12 @@ +import math + +from run import Invalid, as_int + + +def check(inst, ans): + X = as_int(ans.get("X"), "X", lo=inst["A"], hi=inst["B"]) + Y = as_int(ans.get("Y"), "Y", lo=inst["C"], hi=inst["D"]) + g = math.gcd(X, Y) + if g < inst["target"]: + raise Invalid(f"gcd(X, Y) = {g} < {inst['target']}") + return None, {"gcd": g} diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s8/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e87bbe26c8b1cbf220f806ad543cfee93016311c --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"A": 814, "B": 904, "C": 1, "D": 201, "target": 180, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s8/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l2-s8/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s7/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l6-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s7/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l6-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..77e1b03d61cb0b6f44c30002feb94e287b37361e --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s7/environment/instance.json @@ -0,0 +1 @@ +{"A": 18558601965, "B": 34495217625, "C": 72377195950, "D": 76079473950, "target": 25359824650, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s7/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l6-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..03f73979fd0898d6f47b437c37b624215f8c2dc9 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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": 25359824650, "Y": 76079473950} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s7/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l6-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s7/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-l6-s7/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l6-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..77e1b03d61cb0b6f44c30002feb94e287b37361e --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s7/tests/instance.json @@ -0,0 +1 @@ +{"A": 18558601965, "B": 34495217625, "C": 72377195950, "D": 76079473950, "target": 25359824650, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s7/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l6-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s7/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l6-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-polynomial-global-minimum-l3-s2/environment/Dockerfile b/tasks/construct-rlve-polynomial-global-minimum-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-global-minimum-l3-s2/environment/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7fc5d7eab6b838b5fcd8de6fe8e8666e2f441171 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [4, 16, 32, 40, 32, 12, 2], "fmin": "0.587391075289587500801061587752950893718624289", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s2/solution/solve.sh b/tasks/construct-rlve-polynomial-global-minimum-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..123677bb39b706b9db9f71c614d9247f09c5ebcc --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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' +{"x0": -0.5996387644174705} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s2/tests/check.py b/tasks/construct-rlve-polynomial-global-minimum-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3be068f4391ad0838c29a4f7d521b8072cf39991 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s2/tests/check.py @@ -0,0 +1,19 @@ +from fractions import Fraction + +from run import Invalid, num + + +def check(inst, ans): + x0 = Fraction(num(ans.get("x0"), "x0")) + if abs(x0) > 10 ** 6: + raise Invalid("x0 out of range") + v = Fraction(0) + for a in reversed(inst["coeffs"]): + v = v * x0 + a + fmin = Fraction(inst["fmin"]) + tol = Fraction(1, 10 ** 9) * max(Fraction(1), abs(fmin)) + if v > fmin + tol: + raise Invalid(f"f(x0) = {float(v)} is above the global minimum {float(fmin)}") + if v < fmin - tol: # cannot happen for a correct f_min; guards against a bad instance + raise Invalid("internal: f(x0) below recorded minimum") + return None, {"f_x0": float(v)} diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s2/tests/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7fc5d7eab6b838b5fcd8de6fe8e8666e2f441171 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [4, 16, 32, 40, 32, 12, 2], "fmin": "0.587391075289587500801061587752950893718624289", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s2/tests/run.py b/tasks/construct-rlve-polynomial-global-minimum-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-global-minimum-l3-s2/tests/test.sh b/tasks/construct-rlve-polynomial-global-minimum-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-integer-roots-l4-s7/environment/Dockerfile b/tasks/construct-rlve-polynomial-integer-roots-l4-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s7/environment/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aa4d919168223794f1317e36ac4b2c6e4b037b96 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [-3870720000, -1778688000, 628339200, 272110720, -31070816, -15547528, 364316, 401010, 9711, -4426, -220, 16, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s7/solution/solve.sh b/tasks/construct-rlve-polynomial-integer-roots-l4-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fd3f0491548e0e476464d9d1dd07bab0acde2b36 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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' +{"roots": [-12, -10, -8, -7, -6, -5, -2, 4, 5, 5, 8, 12]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s7/tests/check.py b/tasks/construct-rlve-polynomial-integer-roots-l4-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2d30553cb884c5e03c8afe73ef652efc483ab791 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s7/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + c = inst["coeffs"] # c[i] = coefficient of x^i, monic of degree len(c) - 1 + n = len(c) - 1 + r = int_list(ans.get("roots"), n, name="roots") + bound = 1 + max(abs(v) for v in c) # Cauchy bound on roots + if any(abs(a) > bound for a in r): # any integer root divides the constant term / is bounded by max|c_i| + raise Invalid("root out of range") + prod = [1] + for a in r: # multiply by (x - a) + nxt = [0] * (len(prod) + 1) + for i, v in enumerate(prod): + nxt[i + 1] += v + nxt[i] -= a * v + prod = nxt + if prod != c: + raise Invalid("the product does not expand to P(x)") + return None, {} diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s7/tests/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l4-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aa4d919168223794f1317e36ac4b2c6e4b037b96 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s7/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [-3870720000, -1778688000, 628339200, 272110720, -31070816, -15547528, 364316, 401010, 9711, -4426, -220, 16, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s7/tests/run.py b/tasks/construct-rlve-polynomial-integer-roots-l4-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s7/tests/test.sh b/tasks/construct-rlve-polynomial-integer-roots-l4-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s9/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l3-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s9/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..073cce2383f7156a66222601c6570524c3a93c88 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s9/environment/instance.json @@ -0,0 +1 @@ +{"X": [-1, 0, 6, 5, -5, -6, -4], "Y": [-5, -3, 249195, 83827, 66067, 204255, 16345], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s9/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..deb7d5869d3130688449d2e298321a9cbf63ad72 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coeffs": [-3, 1, -2, -4, -5, 3, 5]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s9/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l3-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s9/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + X, Y = inst["X"], inst["Y"] + c = int_list(ans.get("coeffs"), len(X), name="coeffs") + for x, y in zip(X, Y): + v = 0 + for a in reversed(c): + v = v * x + a + if v != y: + raise Invalid(f"f({x}) = {v}, need {y}") + return None, {} diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s9/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..073cce2383f7156a66222601c6570524c3a93c88 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s9/tests/instance.json @@ -0,0 +1 @@ +{"X": [-1, 0, 6, 5, -5, -6, -4], "Y": [-5, -3, 249195, 83827, 66067, 204255, 16345], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s9/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l3-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s9/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s3/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l2-s3/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9f340fe35159484780d259388f6404faab607315 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 98, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s3/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cffc9aae34a4638161ad69067894db7540b658d1 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [98, 1, 96, 3, 94, 5, 92, 7, 90, 9, 88, 11, 86, 13, 84, 15, 82, 17, 80, 19, 78, 21, 76, 23, 74, 25, 72, 27, 70, 29, 68, 31, 66, 33, 64, 35, 62, 37, 60, 39, 58, 41, 56, 43, 54, 45, 52, 47, 50, 49, 48, 51, 46, 53, 44, 55, 42, 57, 40, 59, 38, 61, 36, 63, 34, 65, 32, 67, 30, 69, 28, 71, 26, 73, 24, 75, 22, 77, 20, 79, 18, 81, 16, 83, 14, 85, 12, 87, 10, 89, 8, 91, 6, 93, 4, 95, 2, 97]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s3/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s3/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s3/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9f340fe35159484780d259388f6404faab607315 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 98, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s3/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l2-s3/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l2-s4/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l2-s4/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3c17ae982c263345dc8e7b00708f486523f95e82 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 42, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s4/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..853f893d46e36ea8d6030facfbcef92dfeb49cc6 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [42, 1, 40, 3, 38, 5, 36, 7, 34, 9, 32, 11, 30, 13, 28, 15, 26, 17, 24, 19, 22, 21, 20, 23, 18, 25, 16, 27, 14, 29, 12, 31, 10, 33, 8, 35, 6, 37, 4, 39, 2, 41]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s4/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s4/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s4/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3c17ae982c263345dc8e7b00708f486523f95e82 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 42, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s4/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l2-s4/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l5-s7/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l5-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-sum-permutation-l5-s7/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ad49d2f10790c03ee40aff0f3ce5fd5b5f4beadf --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 3282, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l5-s7/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..31ef6f3c7e5b597a6c7e49998bdd6d09862261ed --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l5-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [3282, 1, 3280, 3, 3278, 5, 3276, 7, 3274, 9, 3272, 11, 3270, 13, 3268, 15, 3266, 17, 3264, 19, 3262, 21, 3260, 23, 3258, 25, 3256, 27, 3254, 29, 3252, 31, 3250, 33, 3248, 35, 3246, 37, 3244, 39, 3242, 41, 3240, 43, 3238, 45, 3236, 47, 3234, 49, 3232, 51, 3230, 53, 3228, 55, 3226, 57, 3224, 59, 3222, 61, 3220, 63, 3218, 65, 3216, 67, 3214, 69, 3212, 71, 3210, 73, 3208, 75, 3206, 77, 3204, 79, 3202, 81, 3200, 83, 3198, 85, 3196, 87, 3194, 89, 3192, 91, 3190, 93, 3188, 95, 3186, 97, 3184, 99, 3182, 101, 3180, 103, 3178, 105, 3176, 107, 3174, 109, 3172, 111, 3170, 113, 3168, 115, 3166, 117, 3164, 119, 3162, 121, 3160, 123, 3158, 125, 3156, 127, 3154, 129, 3152, 131, 3150, 133, 3148, 135, 3146, 137, 3144, 139, 3142, 141, 3140, 143, 3138, 145, 3136, 147, 3134, 149, 3132, 151, 3130, 153, 3128, 155, 3126, 157, 3124, 159, 3122, 161, 3120, 163, 3118, 165, 3116, 167, 3114, 169, 3112, 171, 3110, 173, 3108, 175, 3106, 177, 3104, 179, 3102, 181, 3100, 183, 3098, 185, 3096, 187, 3094, 189, 3092, 191, 3090, 193, 3088, 195, 3086, 197, 3084, 199, 3082, 201, 3080, 203, 3078, 205, 3076, 207, 3074, 209, 3072, 211, 3070, 213, 3068, 215, 3066, 217, 3064, 219, 3062, 221, 3060, 223, 3058, 225, 3056, 227, 3054, 229, 3052, 231, 3050, 233, 3048, 235, 3046, 237, 3044, 239, 3042, 241, 3040, 243, 3038, 245, 3036, 247, 3034, 249, 3032, 251, 3030, 253, 3028, 255, 3026, 257, 3024, 259, 3022, 261, 3020, 263, 3018, 265, 3016, 267, 3014, 269, 3012, 271, 3010, 273, 3008, 275, 3006, 277, 3004, 279, 3002, 281, 3000, 283, 2998, 285, 2996, 287, 2994, 289, 2992, 291, 2990, 293, 2988, 295, 2986, 297, 2984, 299, 2982, 301, 2980, 303, 2978, 305, 2976, 307, 2974, 309, 2972, 311, 2970, 313, 2968, 315, 2966, 317, 2964, 319, 2962, 321, 2960, 323, 2958, 325, 2956, 327, 2954, 329, 2952, 331, 2950, 333, 2948, 335, 2946, 337, 2944, 339, 2942, 341, 2940, 343, 2938, 345, 2936, 347, 2934, 349, 2932, 351, 2930, 353, 2928, 355, 2926, 357, 2924, 359, 2922, 361, 2920, 363, 2918, 365, 2916, 367, 2914, 369, 2912, 371, 2910, 373, 2908, 375, 2906, 377, 2904, 379, 2902, 381, 2900, 383, 2898, 385, 2896, 387, 2894, 389, 2892, 391, 2890, 393, 2888, 395, 2886, 397, 2884, 399, 2882, 401, 2880, 403, 2878, 405, 2876, 407, 2874, 409, 2872, 411, 2870, 413, 2868, 415, 2866, 417, 2864, 419, 2862, 421, 2860, 423, 2858, 425, 2856, 427, 2854, 429, 2852, 431, 2850, 433, 2848, 435, 2846, 437, 2844, 439, 2842, 441, 2840, 443, 2838, 445, 2836, 447, 2834, 449, 2832, 451, 2830, 453, 2828, 455, 2826, 457, 2824, 459, 2822, 461, 2820, 463, 2818, 465, 2816, 467, 2814, 469, 2812, 471, 2810, 473, 2808, 475, 2806, 477, 2804, 479, 2802, 481, 2800, 483, 2798, 485, 2796, 487, 2794, 489, 2792, 491, 2790, 493, 2788, 495, 2786, 497, 2784, 499, 2782, 501, 2780, 503, 2778, 505, 2776, 507, 2774, 509, 2772, 511, 2770, 513, 2768, 515, 2766, 517, 2764, 519, 2762, 521, 2760, 523, 2758, 525, 2756, 527, 2754, 529, 2752, 531, 2750, 533, 2748, 535, 2746, 537, 2744, 539, 2742, 541, 2740, 543, 2738, 545, 2736, 547, 2734, 549, 2732, 551, 2730, 553, 2728, 555, 2726, 557, 2724, 559, 2722, 561, 2720, 563, 2718, 565, 2716, 567, 2714, 569, 2712, 571, 2710, 573, 2708, 575, 2706, 577, 2704, 579, 2702, 581, 2700, 583, 2698, 585, 2696, 587, 2694, 589, 2692, 591, 2690, 593, 2688, 595, 2686, 597, 2684, 599, 2682, 601, 2680, 603, 2678, 605, 2676, 607, 2674, 609, 2672, 611, 2670, 613, 2668, 615, 2666, 617, 2664, 619, 2662, 621, 2660, 623, 2658, 625, 2656, 627, 2654, 629, 2652, 631, 2650, 633, 2648, 635, 2646, 637, 2644, 639, 2642, 641, 2640, 643, 2638, 645, 2636, 647, 2634, 649, 2632, 651, 2630, 653, 2628, 655, 2626, 657, 2624, 659, 2622, 661, 2620, 663, 2618, 665, 2616, 667, 2614, 669, 2612, 671, 2610, 673, 2608, 675, 2606, 677, 2604, 679, 2602, 681, 2600, 683, 2598, 685, 2596, 687, 2594, 689, 2592, 691, 2590, 693, 2588, 695, 2586, 697, 2584, 699, 2582, 701, 2580, 703, 2578, 705, 2576, 707, 2574, 709, 2572, 711, 2570, 713, 2568, 715, 2566, 717, 2564, 719, 2562, 721, 2560, 723, 2558, 725, 2556, 727, 2554, 729, 2552, 731, 2550, 733, 2548, 735, 2546, 737, 2544, 739, 2542, 741, 2540, 743, 2538, 745, 2536, 747, 2534, 749, 2532, 751, 2530, 753, 2528, 755, 2526, 757, 2524, 759, 2522, 761, 2520, 763, 2518, 765, 2516, 767, 2514, 769, 2512, 771, 2510, 773, 2508, 775, 2506, 777, 2504, 779, 2502, 781, 2500, 783, 2498, 785, 2496, 787, 2494, 789, 2492, 791, 2490, 793, 2488, 795, 2486, 797, 2484, 799, 2482, 801, 2480, 803, 2478, 805, 2476, 807, 2474, 809, 2472, 811, 2470, 813, 2468, 815, 2466, 817, 2464, 819, 2462, 821, 2460, 823, 2458, 825, 2456, 827, 2454, 829, 2452, 831, 2450, 833, 2448, 835, 2446, 837, 2444, 839, 2442, 841, 2440, 843, 2438, 845, 2436, 847, 2434, 849, 2432, 851, 2430, 853, 2428, 855, 2426, 857, 2424, 859, 2422, 861, 2420, 863, 2418, 865, 2416, 867, 2414, 869, 2412, 871, 2410, 873, 2408, 875, 2406, 877, 2404, 879, 2402, 881, 2400, 883, 2398, 885, 2396, 887, 2394, 889, 2392, 891, 2390, 893, 2388, 895, 2386, 897, 2384, 899, 2382, 901, 2380, 903, 2378, 905, 2376, 907, 2374, 909, 2372, 911, 2370, 913, 2368, 915, 2366, 917, 2364, 919, 2362, 921, 2360, 923, 2358, 925, 2356, 927, 2354, 929, 2352, 931, 2350, 933, 2348, 935, 2346, 937, 2344, 939, 2342, 941, 2340, 943, 2338, 945, 2336, 947, 2334, 949, 2332, 951, 2330, 953, 2328, 955, 2326, 957, 2324, 959, 2322, 961, 2320, 963, 2318, 965, 2316, 967, 2314, 969, 2312, 971, 2310, 973, 2308, 975, 2306, 977, 2304, 979, 2302, 981, 2300, 983, 2298, 985, 2296, 987, 2294, 989, 2292, 991, 2290, 993, 2288, 995, 2286, 997, 2284, 999, 2282, 1001, 2280, 1003, 2278, 1005, 2276, 1007, 2274, 1009, 2272, 1011, 2270, 1013, 2268, 1015, 2266, 1017, 2264, 1019, 2262, 1021, 2260, 1023, 2258, 1025, 2256, 1027, 2254, 1029, 2252, 1031, 2250, 1033, 2248, 1035, 2246, 1037, 2244, 1039, 2242, 1041, 2240, 1043, 2238, 1045, 2236, 1047, 2234, 1049, 2232, 1051, 2230, 1053, 2228, 1055, 2226, 1057, 2224, 1059, 2222, 1061, 2220, 1063, 2218, 1065, 2216, 1067, 2214, 1069, 2212, 1071, 2210, 1073, 2208, 1075, 2206, 1077, 2204, 1079, 2202, 1081, 2200, 1083, 2198, 1085, 2196, 1087, 2194, 1089, 2192, 1091, 2190, 1093, 2188, 1095, 2186, 1097, 2184, 1099, 2182, 1101, 2180, 1103, 2178, 1105, 2176, 1107, 2174, 1109, 2172, 1111, 2170, 1113, 2168, 1115, 2166, 1117, 2164, 1119, 2162, 1121, 2160, 1123, 2158, 1125, 2156, 1127, 2154, 1129, 2152, 1131, 2150, 1133, 2148, 1135, 2146, 1137, 2144, 1139, 2142, 1141, 2140, 1143, 2138, 1145, 2136, 1147, 2134, 1149, 2132, 1151, 2130, 1153, 2128, 1155, 2126, 1157, 2124, 1159, 2122, 1161, 2120, 1163, 2118, 1165, 2116, 1167, 2114, 1169, 2112, 1171, 2110, 1173, 2108, 1175, 2106, 1177, 2104, 1179, 2102, 1181, 2100, 1183, 2098, 1185, 2096, 1187, 2094, 1189, 2092, 1191, 2090, 1193, 2088, 1195, 2086, 1197, 2084, 1199, 2082, 1201, 2080, 1203, 2078, 1205, 2076, 1207, 2074, 1209, 2072, 1211, 2070, 1213, 2068, 1215, 2066, 1217, 2064, 1219, 2062, 1221, 2060, 1223, 2058, 1225, 2056, 1227, 2054, 1229, 2052, 1231, 2050, 1233, 2048, 1235, 2046, 1237, 2044, 1239, 2042, 1241, 2040, 1243, 2038, 1245, 2036, 1247, 2034, 1249, 2032, 1251, 2030, 1253, 2028, 1255, 2026, 1257, 2024, 1259, 2022, 1261, 2020, 1263, 2018, 1265, 2016, 1267, 2014, 1269, 2012, 1271, 2010, 1273, 2008, 1275, 2006, 1277, 2004, 1279, 2002, 1281, 2000, 1283, 1998, 1285, 1996, 1287, 1994, 1289, 1992, 1291, 1990, 1293, 1988, 1295, 1986, 1297, 1984, 1299, 1982, 1301, 1980, 1303, 1978, 1305, 1976, 1307, 1974, 1309, 1972, 1311, 1970, 1313, 1968, 1315, 1966, 1317, 1964, 1319, 1962, 1321, 1960, 1323, 1958, 1325, 1956, 1327, 1954, 1329, 1952, 1331, 1950, 1333, 1948, 1335, 1946, 1337, 1944, 1339, 1942, 1341, 1940, 1343, 1938, 1345, 1936, 1347, 1934, 1349, 1932, 1351, 1930, 1353, 1928, 1355, 1926, 1357, 1924, 1359, 1922, 1361, 1920, 1363, 1918, 1365, 1916, 1367, 1914, 1369, 1912, 1371, 1910, 1373, 1908, 1375, 1906, 1377, 1904, 1379, 1902, 1381, 1900, 1383, 1898, 1385, 1896, 1387, 1894, 1389, 1892, 1391, 1890, 1393, 1888, 1395, 1886, 1397, 1884, 1399, 1882, 1401, 1880, 1403, 1878, 1405, 1876, 1407, 1874, 1409, 1872, 1411, 1870, 1413, 1868, 1415, 1866, 1417, 1864, 1419, 1862, 1421, 1860, 1423, 1858, 1425, 1856, 1427, 1854, 1429, 1852, 1431, 1850, 1433, 1848, 1435, 1846, 1437, 1844, 1439, 1842, 1441, 1840, 1443, 1838, 1445, 1836, 1447, 1834, 1449, 1832, 1451, 1830, 1453, 1828, 1455, 1826, 1457, 1824, 1459, 1822, 1461, 1820, 1463, 1818, 1465, 1816, 1467, 1814, 1469, 1812, 1471, 1810, 1473, 1808, 1475, 1806, 1477, 1804, 1479, 1802, 1481, 1800, 1483, 1798, 1485, 1796, 1487, 1794, 1489, 1792, 1491, 1790, 1493, 1788, 1495, 1786, 1497, 1784, 1499, 1782, 1501, 1780, 1503, 1778, 1505, 1776, 1507, 1774, 1509, 1772, 1511, 1770, 1513, 1768, 1515, 1766, 1517, 1764, 1519, 1762, 1521, 1760, 1523, 1758, 1525, 1756, 1527, 1754, 1529, 1752, 1531, 1750, 1533, 1748, 1535, 1746, 1537, 1744, 1539, 1742, 1541, 1740, 1543, 1738, 1545, 1736, 1547, 1734, 1549, 1732, 1551, 1730, 1553, 1728, 1555, 1726, 1557, 1724, 1559, 1722, 1561, 1720, 1563, 1718, 1565, 1716, 1567, 1714, 1569, 1712, 1571, 1710, 1573, 1708, 1575, 1706, 1577, 1704, 1579, 1702, 1581, 1700, 1583, 1698, 1585, 1696, 1587, 1694, 1589, 1692, 1591, 1690, 1593, 1688, 1595, 1686, 1597, 1684, 1599, 1682, 1601, 1680, 1603, 1678, 1605, 1676, 1607, 1674, 1609, 1672, 1611, 1670, 1613, 1668, 1615, 1666, 1617, 1664, 1619, 1662, 1621, 1660, 1623, 1658, 1625, 1656, 1627, 1654, 1629, 1652, 1631, 1650, 1633, 1648, 1635, 1646, 1637, 1644, 1639, 1642, 1641, 1640, 1643, 1638, 1645, 1636, 1647, 1634, 1649, 1632, 1651, 1630, 1653, 1628, 1655, 1626, 1657, 1624, 1659, 1622, 1661, 1620, 1663, 1618, 1665, 1616, 1667, 1614, 1669, 1612, 1671, 1610, 1673, 1608, 1675, 1606, 1677, 1604, 1679, 1602, 1681, 1600, 1683, 1598, 1685, 1596, 1687, 1594, 1689, 1592, 1691, 1590, 1693, 1588, 1695, 1586, 1697, 1584, 1699, 1582, 1701, 1580, 1703, 1578, 1705, 1576, 1707, 1574, 1709, 1572, 1711, 1570, 1713, 1568, 1715, 1566, 1717, 1564, 1719, 1562, 1721, 1560, 1723, 1558, 1725, 1556, 1727, 1554, 1729, 1552, 1731, 1550, 1733, 1548, 1735, 1546, 1737, 1544, 1739, 1542, 1741, 1540, 1743, 1538, 1745, 1536, 1747, 1534, 1749, 1532, 1751, 1530, 1753, 1528, 1755, 1526, 1757, 1524, 1759, 1522, 1761, 1520, 1763, 1518, 1765, 1516, 1767, 1514, 1769, 1512, 1771, 1510, 1773, 1508, 1775, 1506, 1777, 1504, 1779, 1502, 1781, 1500, 1783, 1498, 1785, 1496, 1787, 1494, 1789, 1492, 1791, 1490, 1793, 1488, 1795, 1486, 1797, 1484, 1799, 1482, 1801, 1480, 1803, 1478, 1805, 1476, 1807, 1474, 1809, 1472, 1811, 1470, 1813, 1468, 1815, 1466, 1817, 1464, 1819, 1462, 1821, 1460, 1823, 1458, 1825, 1456, 1827, 1454, 1829, 1452, 1831, 1450, 1833, 1448, 1835, 1446, 1837, 1444, 1839, 1442, 1841, 1440, 1843, 1438, 1845, 1436, 1847, 1434, 1849, 1432, 1851, 1430, 1853, 1428, 1855, 1426, 1857, 1424, 1859, 1422, 1861, 1420, 1863, 1418, 1865, 1416, 1867, 1414, 1869, 1412, 1871, 1410, 1873, 1408, 1875, 1406, 1877, 1404, 1879, 1402, 1881, 1400, 1883, 1398, 1885, 1396, 1887, 1394, 1889, 1392, 1891, 1390, 1893, 1388, 1895, 1386, 1897, 1384, 1899, 1382, 1901, 1380, 1903, 1378, 1905, 1376, 1907, 1374, 1909, 1372, 1911, 1370, 1913, 1368, 1915, 1366, 1917, 1364, 1919, 1362, 1921, 1360, 1923, 1358, 1925, 1356, 1927, 1354, 1929, 1352, 1931, 1350, 1933, 1348, 1935, 1346, 1937, 1344, 1939, 1342, 1941, 1340, 1943, 1338, 1945, 1336, 1947, 1334, 1949, 1332, 1951, 1330, 1953, 1328, 1955, 1326, 1957, 1324, 1959, 1322, 1961, 1320, 1963, 1318, 1965, 1316, 1967, 1314, 1969, 1312, 1971, 1310, 1973, 1308, 1975, 1306, 1977, 1304, 1979, 1302, 1981, 1300, 1983, 1298, 1985, 1296, 1987, 1294, 1989, 1292, 1991, 1290, 1993, 1288, 1995, 1286, 1997, 1284, 1999, 1282, 2001, 1280, 2003, 1278, 2005, 1276, 2007, 1274, 2009, 1272, 2011, 1270, 2013, 1268, 2015, 1266, 2017, 1264, 2019, 1262, 2021, 1260, 2023, 1258, 2025, 1256, 2027, 1254, 2029, 1252, 2031, 1250, 2033, 1248, 2035, 1246, 2037, 1244, 2039, 1242, 2041, 1240, 2043, 1238, 2045, 1236, 2047, 1234, 2049, 1232, 2051, 1230, 2053, 1228, 2055, 1226, 2057, 1224, 2059, 1222, 2061, 1220, 2063, 1218, 2065, 1216, 2067, 1214, 2069, 1212, 2071, 1210, 2073, 1208, 2075, 1206, 2077, 1204, 2079, 1202, 2081, 1200, 2083, 1198, 2085, 1196, 2087, 1194, 2089, 1192, 2091, 1190, 2093, 1188, 2095, 1186, 2097, 1184, 2099, 1182, 2101, 1180, 2103, 1178, 2105, 1176, 2107, 1174, 2109, 1172, 2111, 1170, 2113, 1168, 2115, 1166, 2117, 1164, 2119, 1162, 2121, 1160, 2123, 1158, 2125, 1156, 2127, 1154, 2129, 1152, 2131, 1150, 2133, 1148, 2135, 1146, 2137, 1144, 2139, 1142, 2141, 1140, 2143, 1138, 2145, 1136, 2147, 1134, 2149, 1132, 2151, 1130, 2153, 1128, 2155, 1126, 2157, 1124, 2159, 1122, 2161, 1120, 2163, 1118, 2165, 1116, 2167, 1114, 2169, 1112, 2171, 1110, 2173, 1108, 2175, 1106, 2177, 1104, 2179, 1102, 2181, 1100, 2183, 1098, 2185, 1096, 2187, 1094, 2189, 1092, 2191, 1090, 2193, 1088, 2195, 1086, 2197, 1084, 2199, 1082, 2201, 1080, 2203, 1078, 2205, 1076, 2207, 1074, 2209, 1072, 2211, 1070, 2213, 1068, 2215, 1066, 2217, 1064, 2219, 1062, 2221, 1060, 2223, 1058, 2225, 1056, 2227, 1054, 2229, 1052, 2231, 1050, 2233, 1048, 2235, 1046, 2237, 1044, 2239, 1042, 2241, 1040, 2243, 1038, 2245, 1036, 2247, 1034, 2249, 1032, 2251, 1030, 2253, 1028, 2255, 1026, 2257, 1024, 2259, 1022, 2261, 1020, 2263, 1018, 2265, 1016, 2267, 1014, 2269, 1012, 2271, 1010, 2273, 1008, 2275, 1006, 2277, 1004, 2279, 1002, 2281, 1000, 2283, 998, 2285, 996, 2287, 994, 2289, 992, 2291, 990, 2293, 988, 2295, 986, 2297, 984, 2299, 982, 2301, 980, 2303, 978, 2305, 976, 2307, 974, 2309, 972, 2311, 970, 2313, 968, 2315, 966, 2317, 964, 2319, 962, 2321, 960, 2323, 958, 2325, 956, 2327, 954, 2329, 952, 2331, 950, 2333, 948, 2335, 946, 2337, 944, 2339, 942, 2341, 940, 2343, 938, 2345, 936, 2347, 934, 2349, 932, 2351, 930, 2353, 928, 2355, 926, 2357, 924, 2359, 922, 2361, 920, 2363, 918, 2365, 916, 2367, 914, 2369, 912, 2371, 910, 2373, 908, 2375, 906, 2377, 904, 2379, 902, 2381, 900, 2383, 898, 2385, 896, 2387, 894, 2389, 892, 2391, 890, 2393, 888, 2395, 886, 2397, 884, 2399, 882, 2401, 880, 2403, 878, 2405, 876, 2407, 874, 2409, 872, 2411, 870, 2413, 868, 2415, 866, 2417, 864, 2419, 862, 2421, 860, 2423, 858, 2425, 856, 2427, 854, 2429, 852, 2431, 850, 2433, 848, 2435, 846, 2437, 844, 2439, 842, 2441, 840, 2443, 838, 2445, 836, 2447, 834, 2449, 832, 2451, 830, 2453, 828, 2455, 826, 2457, 824, 2459, 822, 2461, 820, 2463, 818, 2465, 816, 2467, 814, 2469, 812, 2471, 810, 2473, 808, 2475, 806, 2477, 804, 2479, 802, 2481, 800, 2483, 798, 2485, 796, 2487, 794, 2489, 792, 2491, 790, 2493, 788, 2495, 786, 2497, 784, 2499, 782, 2501, 780, 2503, 778, 2505, 776, 2507, 774, 2509, 772, 2511, 770, 2513, 768, 2515, 766, 2517, 764, 2519, 762, 2521, 760, 2523, 758, 2525, 756, 2527, 754, 2529, 752, 2531, 750, 2533, 748, 2535, 746, 2537, 744, 2539, 742, 2541, 740, 2543, 738, 2545, 736, 2547, 734, 2549, 732, 2551, 730, 2553, 728, 2555, 726, 2557, 724, 2559, 722, 2561, 720, 2563, 718, 2565, 716, 2567, 714, 2569, 712, 2571, 710, 2573, 708, 2575, 706, 2577, 704, 2579, 702, 2581, 700, 2583, 698, 2585, 696, 2587, 694, 2589, 692, 2591, 690, 2593, 688, 2595, 686, 2597, 684, 2599, 682, 2601, 680, 2603, 678, 2605, 676, 2607, 674, 2609, 672, 2611, 670, 2613, 668, 2615, 666, 2617, 664, 2619, 662, 2621, 660, 2623, 658, 2625, 656, 2627, 654, 2629, 652, 2631, 650, 2633, 648, 2635, 646, 2637, 644, 2639, 642, 2641, 640, 2643, 638, 2645, 636, 2647, 634, 2649, 632, 2651, 630, 2653, 628, 2655, 626, 2657, 624, 2659, 622, 2661, 620, 2663, 618, 2665, 616, 2667, 614, 2669, 612, 2671, 610, 2673, 608, 2675, 606, 2677, 604, 2679, 602, 2681, 600, 2683, 598, 2685, 596, 2687, 594, 2689, 592, 2691, 590, 2693, 588, 2695, 586, 2697, 584, 2699, 582, 2701, 580, 2703, 578, 2705, 576, 2707, 574, 2709, 572, 2711, 570, 2713, 568, 2715, 566, 2717, 564, 2719, 562, 2721, 560, 2723, 558, 2725, 556, 2727, 554, 2729, 552, 2731, 550, 2733, 548, 2735, 546, 2737, 544, 2739, 542, 2741, 540, 2743, 538, 2745, 536, 2747, 534, 2749, 532, 2751, 530, 2753, 528, 2755, 526, 2757, 524, 2759, 522, 2761, 520, 2763, 518, 2765, 516, 2767, 514, 2769, 512, 2771, 510, 2773, 508, 2775, 506, 2777, 504, 2779, 502, 2781, 500, 2783, 498, 2785, 496, 2787, 494, 2789, 492, 2791, 490, 2793, 488, 2795, 486, 2797, 484, 2799, 482, 2801, 480, 2803, 478, 2805, 476, 2807, 474, 2809, 472, 2811, 470, 2813, 468, 2815, 466, 2817, 464, 2819, 462, 2821, 460, 2823, 458, 2825, 456, 2827, 454, 2829, 452, 2831, 450, 2833, 448, 2835, 446, 2837, 444, 2839, 442, 2841, 440, 2843, 438, 2845, 436, 2847, 434, 2849, 432, 2851, 430, 2853, 428, 2855, 426, 2857, 424, 2859, 422, 2861, 420, 2863, 418, 2865, 416, 2867, 414, 2869, 412, 2871, 410, 2873, 408, 2875, 406, 2877, 404, 2879, 402, 2881, 400, 2883, 398, 2885, 396, 2887, 394, 2889, 392, 2891, 390, 2893, 388, 2895, 386, 2897, 384, 2899, 382, 2901, 380, 2903, 378, 2905, 376, 2907, 374, 2909, 372, 2911, 370, 2913, 368, 2915, 366, 2917, 364, 2919, 362, 2921, 360, 2923, 358, 2925, 356, 2927, 354, 2929, 352, 2931, 350, 2933, 348, 2935, 346, 2937, 344, 2939, 342, 2941, 340, 2943, 338, 2945, 336, 2947, 334, 2949, 332, 2951, 330, 2953, 328, 2955, 326, 2957, 324, 2959, 322, 2961, 320, 2963, 318, 2965, 316, 2967, 314, 2969, 312, 2971, 310, 2973, 308, 2975, 306, 2977, 304, 2979, 302, 2981, 300, 2983, 298, 2985, 296, 2987, 294, 2989, 292, 2991, 290, 2993, 288, 2995, 286, 2997, 284, 2999, 282, 3001, 280, 3003, 278, 3005, 276, 3007, 274, 3009, 272, 3011, 270, 3013, 268, 3015, 266, 3017, 264, 3019, 262, 3021, 260, 3023, 258, 3025, 256, 3027, 254, 3029, 252, 3031, 250, 3033, 248, 3035, 246, 3037, 244, 3039, 242, 3041, 240, 3043, 238, 3045, 236, 3047, 234, 3049, 232, 3051, 230, 3053, 228, 3055, 226, 3057, 224, 3059, 222, 3061, 220, 3063, 218, 3065, 216, 3067, 214, 3069, 212, 3071, 210, 3073, 208, 3075, 206, 3077, 204, 3079, 202, 3081, 200, 3083, 198, 3085, 196, 3087, 194, 3089, 192, 3091, 190, 3093, 188, 3095, 186, 3097, 184, 3099, 182, 3101, 180, 3103, 178, 3105, 176, 3107, 174, 3109, 172, 3111, 170, 3113, 168, 3115, 166, 3117, 164, 3119, 162, 3121, 160, 3123, 158, 3125, 156, 3127, 154, 3129, 152, 3131, 150, 3133, 148, 3135, 146, 3137, 144, 3139, 142, 3141, 140, 3143, 138, 3145, 136, 3147, 134, 3149, 132, 3151, 130, 3153, 128, 3155, 126, 3157, 124, 3159, 122, 3161, 120, 3163, 118, 3165, 116, 3167, 114, 3169, 112, 3171, 110, 3173, 108, 3175, 106, 3177, 104, 3179, 102, 3181, 100, 3183, 98, 3185, 96, 3187, 94, 3189, 92, 3191, 90, 3193, 88, 3195, 86, 3197, 84, 3199, 82, 3201, 80, 3203, 78, 3205, 76, 3207, 74, 3209, 72, 3211, 70, 3213, 68, 3215, 66, 3217, 64, 3219, 62, 3221, 60, 3223, 58, 3225, 56, 3227, 54, 3229, 52, 3231, 50, 3233, 48, 3235, 46, 3237, 44, 3239, 42, 3241, 40, 3243, 38, 3245, 36, 3247, 34, 3249, 32, 3251, 30, 3253, 28, 3255, 26, 3257, 24, 3259, 22, 3261, 20, 3263, 18, 3265, 16, 3267, 14, 3269, 12, 3271, 10, 3273, 8, 3275, 6, 3277, 4, 3279, 2, 3281]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l5-s7/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l5-s7/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l5-s7/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ad49d2f10790c03ee40aff0f3ce5fd5b5f4beadf --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 3282, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l5-s7/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l5-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-sum-permutation-l5-s7/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l5-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s2/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l6-s2/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4a31e29541b92f116d4dc85878e0e38bc96eb83c --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 27942, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s2/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1f1027bc02a03d6fb459d16c834605f55ecc5ebb --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [27942, 1, 27940, 3, 27938, 5, 27936, 7, 27934, 9, 27932, 11, 27930, 13, 27928, 15, 27926, 17, 27924, 19, 27922, 21, 27920, 23, 27918, 25, 27916, 27, 27914, 29, 27912, 31, 27910, 33, 27908, 35, 27906, 37, 27904, 39, 27902, 41, 27900, 43, 27898, 45, 27896, 47, 27894, 49, 27892, 51, 27890, 53, 27888, 55, 27886, 57, 27884, 59, 27882, 61, 27880, 63, 27878, 65, 27876, 67, 27874, 69, 27872, 71, 27870, 73, 27868, 75, 27866, 77, 27864, 79, 27862, 81, 27860, 83, 27858, 85, 27856, 87, 27854, 89, 27852, 91, 27850, 93, 27848, 95, 27846, 97, 27844, 99, 27842, 101, 27840, 103, 27838, 105, 27836, 107, 27834, 109, 27832, 111, 27830, 113, 27828, 115, 27826, 117, 27824, 119, 27822, 121, 27820, 123, 27818, 125, 27816, 127, 27814, 129, 27812, 131, 27810, 133, 27808, 135, 27806, 137, 27804, 139, 27802, 141, 27800, 143, 27798, 145, 27796, 147, 27794, 149, 27792, 151, 27790, 153, 27788, 155, 27786, 157, 27784, 159, 27782, 161, 27780, 163, 27778, 165, 27776, 167, 27774, 169, 27772, 171, 27770, 173, 27768, 175, 27766, 177, 27764, 179, 27762, 181, 27760, 183, 27758, 185, 27756, 187, 27754, 189, 27752, 191, 27750, 193, 27748, 195, 27746, 197, 27744, 199, 27742, 201, 27740, 203, 27738, 205, 27736, 207, 27734, 209, 27732, 211, 27730, 213, 27728, 215, 27726, 217, 27724, 219, 27722, 221, 27720, 223, 27718, 225, 27716, 227, 27714, 229, 27712, 231, 27710, 233, 27708, 235, 27706, 237, 27704, 239, 27702, 241, 27700, 243, 27698, 245, 27696, 247, 27694, 249, 27692, 251, 27690, 253, 27688, 255, 27686, 257, 27684, 259, 27682, 261, 27680, 263, 27678, 265, 27676, 267, 27674, 269, 27672, 271, 27670, 273, 27668, 275, 27666, 277, 27664, 279, 27662, 281, 27660, 283, 27658, 285, 27656, 287, 27654, 289, 27652, 291, 27650, 293, 27648, 295, 27646, 297, 27644, 299, 27642, 301, 27640, 303, 27638, 305, 27636, 307, 27634, 309, 27632, 311, 27630, 313, 27628, 315, 27626, 317, 27624, 319, 27622, 321, 27620, 323, 27618, 325, 27616, 327, 27614, 329, 27612, 331, 27610, 333, 27608, 335, 27606, 337, 27604, 339, 27602, 341, 27600, 343, 27598, 345, 27596, 347, 27594, 349, 27592, 351, 27590, 353, 27588, 355, 27586, 357, 27584, 359, 27582, 361, 27580, 363, 27578, 365, 27576, 367, 27574, 369, 27572, 371, 27570, 373, 27568, 375, 27566, 377, 27564, 379, 27562, 381, 27560, 383, 27558, 385, 27556, 387, 27554, 389, 27552, 391, 27550, 393, 27548, 395, 27546, 397, 27544, 399, 27542, 401, 27540, 403, 27538, 405, 27536, 407, 27534, 409, 27532, 411, 27530, 413, 27528, 415, 27526, 417, 27524, 419, 27522, 421, 27520, 423, 27518, 425, 27516, 427, 27514, 429, 27512, 431, 27510, 433, 27508, 435, 27506, 437, 27504, 439, 27502, 441, 27500, 443, 27498, 445, 27496, 447, 27494, 449, 27492, 451, 27490, 453, 27488, 455, 27486, 457, 27484, 459, 27482, 461, 27480, 463, 27478, 465, 27476, 467, 27474, 469, 27472, 471, 27470, 473, 27468, 475, 27466, 477, 27464, 479, 27462, 481, 27460, 483, 27458, 485, 27456, 487, 27454, 489, 27452, 491, 27450, 493, 27448, 495, 27446, 497, 27444, 499, 27442, 501, 27440, 503, 27438, 505, 27436, 507, 27434, 509, 27432, 511, 27430, 513, 27428, 515, 27426, 517, 27424, 519, 27422, 521, 27420, 523, 27418, 525, 27416, 527, 27414, 529, 27412, 531, 27410, 533, 27408, 535, 27406, 537, 27404, 539, 27402, 541, 27400, 543, 27398, 545, 27396, 547, 27394, 549, 27392, 551, 27390, 553, 27388, 555, 27386, 557, 27384, 559, 27382, 561, 27380, 563, 27378, 565, 27376, 567, 27374, 569, 27372, 571, 27370, 573, 27368, 575, 27366, 577, 27364, 579, 27362, 581, 27360, 583, 27358, 585, 27356, 587, 27354, 589, 27352, 591, 27350, 593, 27348, 595, 27346, 597, 27344, 599, 27342, 601, 27340, 603, 27338, 605, 27336, 607, 27334, 609, 27332, 611, 27330, 613, 27328, 615, 27326, 617, 27324, 619, 27322, 621, 27320, 623, 27318, 625, 27316, 627, 27314, 629, 27312, 631, 27310, 633, 27308, 635, 27306, 637, 27304, 639, 27302, 641, 27300, 643, 27298, 645, 27296, 647, 27294, 649, 27292, 651, 27290, 653, 27288, 655, 27286, 657, 27284, 659, 27282, 661, 27280, 663, 27278, 665, 27276, 667, 27274, 669, 27272, 671, 27270, 673, 27268, 675, 27266, 677, 27264, 679, 27262, 681, 27260, 683, 27258, 685, 27256, 687, 27254, 689, 27252, 691, 27250, 693, 27248, 695, 27246, 697, 27244, 699, 27242, 701, 27240, 703, 27238, 705, 27236, 707, 27234, 709, 27232, 711, 27230, 713, 27228, 715, 27226, 717, 27224, 719, 27222, 721, 27220, 723, 27218, 725, 27216, 727, 27214, 729, 27212, 731, 27210, 733, 27208, 735, 27206, 737, 27204, 739, 27202, 741, 27200, 743, 27198, 745, 27196, 747, 27194, 749, 27192, 751, 27190, 753, 27188, 755, 27186, 757, 27184, 759, 27182, 761, 27180, 763, 27178, 765, 27176, 767, 27174, 769, 27172, 771, 27170, 773, 27168, 775, 27166, 777, 27164, 779, 27162, 781, 27160, 783, 27158, 785, 27156, 787, 27154, 789, 27152, 791, 27150, 793, 27148, 795, 27146, 797, 27144, 799, 27142, 801, 27140, 803, 27138, 805, 27136, 807, 27134, 809, 27132, 811, 27130, 813, 27128, 815, 27126, 817, 27124, 819, 27122, 821, 27120, 823, 27118, 825, 27116, 827, 27114, 829, 27112, 831, 27110, 833, 27108, 835, 27106, 837, 27104, 839, 27102, 841, 27100, 843, 27098, 845, 27096, 847, 27094, 849, 27092, 851, 27090, 853, 27088, 855, 27086, 857, 27084, 859, 27082, 861, 27080, 863, 27078, 865, 27076, 867, 27074, 869, 27072, 871, 27070, 873, 27068, 875, 27066, 877, 27064, 879, 27062, 881, 27060, 883, 27058, 885, 27056, 887, 27054, 889, 27052, 891, 27050, 893, 27048, 895, 27046, 897, 27044, 899, 27042, 901, 27040, 903, 27038, 905, 27036, 907, 27034, 909, 27032, 911, 27030, 913, 27028, 915, 27026, 917, 27024, 919, 27022, 921, 27020, 923, 27018, 925, 27016, 927, 27014, 929, 27012, 931, 27010, 933, 27008, 935, 27006, 937, 27004, 939, 27002, 941, 27000, 943, 26998, 945, 26996, 947, 26994, 949, 26992, 951, 26990, 953, 26988, 955, 26986, 957, 26984, 959, 26982, 961, 26980, 963, 26978, 965, 26976, 967, 26974, 969, 26972, 971, 26970, 973, 26968, 975, 26966, 977, 26964, 979, 26962, 981, 26960, 983, 26958, 985, 26956, 987, 26954, 989, 26952, 991, 26950, 993, 26948, 995, 26946, 997, 26944, 999, 26942, 1001, 26940, 1003, 26938, 1005, 26936, 1007, 26934, 1009, 26932, 1011, 26930, 1013, 26928, 1015, 26926, 1017, 26924, 1019, 26922, 1021, 26920, 1023, 26918, 1025, 26916, 1027, 26914, 1029, 26912, 1031, 26910, 1033, 26908, 1035, 26906, 1037, 26904, 1039, 26902, 1041, 26900, 1043, 26898, 1045, 26896, 1047, 26894, 1049, 26892, 1051, 26890, 1053, 26888, 1055, 26886, 1057, 26884, 1059, 26882, 1061, 26880, 1063, 26878, 1065, 26876, 1067, 26874, 1069, 26872, 1071, 26870, 1073, 26868, 1075, 26866, 1077, 26864, 1079, 26862, 1081, 26860, 1083, 26858, 1085, 26856, 1087, 26854, 1089, 26852, 1091, 26850, 1093, 26848, 1095, 26846, 1097, 26844, 1099, 26842, 1101, 26840, 1103, 26838, 1105, 26836, 1107, 26834, 1109, 26832, 1111, 26830, 1113, 26828, 1115, 26826, 1117, 26824, 1119, 26822, 1121, 26820, 1123, 26818, 1125, 26816, 1127, 26814, 1129, 26812, 1131, 26810, 1133, 26808, 1135, 26806, 1137, 26804, 1139, 26802, 1141, 26800, 1143, 26798, 1145, 26796, 1147, 26794, 1149, 26792, 1151, 26790, 1153, 26788, 1155, 26786, 1157, 26784, 1159, 26782, 1161, 26780, 1163, 26778, 1165, 26776, 1167, 26774, 1169, 26772, 1171, 26770, 1173, 26768, 1175, 26766, 1177, 26764, 1179, 26762, 1181, 26760, 1183, 26758, 1185, 26756, 1187, 26754, 1189, 26752, 1191, 26750, 1193, 26748, 1195, 26746, 1197, 26744, 1199, 26742, 1201, 26740, 1203, 26738, 1205, 26736, 1207, 26734, 1209, 26732, 1211, 26730, 1213, 26728, 1215, 26726, 1217, 26724, 1219, 26722, 1221, 26720, 1223, 26718, 1225, 26716, 1227, 26714, 1229, 26712, 1231, 26710, 1233, 26708, 1235, 26706, 1237, 26704, 1239, 26702, 1241, 26700, 1243, 26698, 1245, 26696, 1247, 26694, 1249, 26692, 1251, 26690, 1253, 26688, 1255, 26686, 1257, 26684, 1259, 26682, 1261, 26680, 1263, 26678, 1265, 26676, 1267, 26674, 1269, 26672, 1271, 26670, 1273, 26668, 1275, 26666, 1277, 26664, 1279, 26662, 1281, 26660, 1283, 26658, 1285, 26656, 1287, 26654, 1289, 26652, 1291, 26650, 1293, 26648, 1295, 26646, 1297, 26644, 1299, 26642, 1301, 26640, 1303, 26638, 1305, 26636, 1307, 26634, 1309, 26632, 1311, 26630, 1313, 26628, 1315, 26626, 1317, 26624, 1319, 26622, 1321, 26620, 1323, 26618, 1325, 26616, 1327, 26614, 1329, 26612, 1331, 26610, 1333, 26608, 1335, 26606, 1337, 26604, 1339, 26602, 1341, 26600, 1343, 26598, 1345, 26596, 1347, 26594, 1349, 26592, 1351, 26590, 1353, 26588, 1355, 26586, 1357, 26584, 1359, 26582, 1361, 26580, 1363, 26578, 1365, 26576, 1367, 26574, 1369, 26572, 1371, 26570, 1373, 26568, 1375, 26566, 1377, 26564, 1379, 26562, 1381, 26560, 1383, 26558, 1385, 26556, 1387, 26554, 1389, 26552, 1391, 26550, 1393, 26548, 1395, 26546, 1397, 26544, 1399, 26542, 1401, 26540, 1403, 26538, 1405, 26536, 1407, 26534, 1409, 26532, 1411, 26530, 1413, 26528, 1415, 26526, 1417, 26524, 1419, 26522, 1421, 26520, 1423, 26518, 1425, 26516, 1427, 26514, 1429, 26512, 1431, 26510, 1433, 26508, 1435, 26506, 1437, 26504, 1439, 26502, 1441, 26500, 1443, 26498, 1445, 26496, 1447, 26494, 1449, 26492, 1451, 26490, 1453, 26488, 1455, 26486, 1457, 26484, 1459, 26482, 1461, 26480, 1463, 26478, 1465, 26476, 1467, 26474, 1469, 26472, 1471, 26470, 1473, 26468, 1475, 26466, 1477, 26464, 1479, 26462, 1481, 26460, 1483, 26458, 1485, 26456, 1487, 26454, 1489, 26452, 1491, 26450, 1493, 26448, 1495, 26446, 1497, 26444, 1499, 26442, 1501, 26440, 1503, 26438, 1505, 26436, 1507, 26434, 1509, 26432, 1511, 26430, 1513, 26428, 1515, 26426, 1517, 26424, 1519, 26422, 1521, 26420, 1523, 26418, 1525, 26416, 1527, 26414, 1529, 26412, 1531, 26410, 1533, 26408, 1535, 26406, 1537, 26404, 1539, 26402, 1541, 26400, 1543, 26398, 1545, 26396, 1547, 26394, 1549, 26392, 1551, 26390, 1553, 26388, 1555, 26386, 1557, 26384, 1559, 26382, 1561, 26380, 1563, 26378, 1565, 26376, 1567, 26374, 1569, 26372, 1571, 26370, 1573, 26368, 1575, 26366, 1577, 26364, 1579, 26362, 1581, 26360, 1583, 26358, 1585, 26356, 1587, 26354, 1589, 26352, 1591, 26350, 1593, 26348, 1595, 26346, 1597, 26344, 1599, 26342, 1601, 26340, 1603, 26338, 1605, 26336, 1607, 26334, 1609, 26332, 1611, 26330, 1613, 26328, 1615, 26326, 1617, 26324, 1619, 26322, 1621, 26320, 1623, 26318, 1625, 26316, 1627, 26314, 1629, 26312, 1631, 26310, 1633, 26308, 1635, 26306, 1637, 26304, 1639, 26302, 1641, 26300, 1643, 26298, 1645, 26296, 1647, 26294, 1649, 26292, 1651, 26290, 1653, 26288, 1655, 26286, 1657, 26284, 1659, 26282, 1661, 26280, 1663, 26278, 1665, 26276, 1667, 26274, 1669, 26272, 1671, 26270, 1673, 26268, 1675, 26266, 1677, 26264, 1679, 26262, 1681, 26260, 1683, 26258, 1685, 26256, 1687, 26254, 1689, 26252, 1691, 26250, 1693, 26248, 1695, 26246, 1697, 26244, 1699, 26242, 1701, 26240, 1703, 26238, 1705, 26236, 1707, 26234, 1709, 26232, 1711, 26230, 1713, 26228, 1715, 26226, 1717, 26224, 1719, 26222, 1721, 26220, 1723, 26218, 1725, 26216, 1727, 26214, 1729, 26212, 1731, 26210, 1733, 26208, 1735, 26206, 1737, 26204, 1739, 26202, 1741, 26200, 1743, 26198, 1745, 26196, 1747, 26194, 1749, 26192, 1751, 26190, 1753, 26188, 1755, 26186, 1757, 26184, 1759, 26182, 1761, 26180, 1763, 26178, 1765, 26176, 1767, 26174, 1769, 26172, 1771, 26170, 1773, 26168, 1775, 26166, 1777, 26164, 1779, 26162, 1781, 26160, 1783, 26158, 1785, 26156, 1787, 26154, 1789, 26152, 1791, 26150, 1793, 26148, 1795, 26146, 1797, 26144, 1799, 26142, 1801, 26140, 1803, 26138, 1805, 26136, 1807, 26134, 1809, 26132, 1811, 26130, 1813, 26128, 1815, 26126, 1817, 26124, 1819, 26122, 1821, 26120, 1823, 26118, 1825, 26116, 1827, 26114, 1829, 26112, 1831, 26110, 1833, 26108, 1835, 26106, 1837, 26104, 1839, 26102, 1841, 26100, 1843, 26098, 1845, 26096, 1847, 26094, 1849, 26092, 1851, 26090, 1853, 26088, 1855, 26086, 1857, 26084, 1859, 26082, 1861, 26080, 1863, 26078, 1865, 26076, 1867, 26074, 1869, 26072, 1871, 26070, 1873, 26068, 1875, 26066, 1877, 26064, 1879, 26062, 1881, 26060, 1883, 26058, 1885, 26056, 1887, 26054, 1889, 26052, 1891, 26050, 1893, 26048, 1895, 26046, 1897, 26044, 1899, 26042, 1901, 26040, 1903, 26038, 1905, 26036, 1907, 26034, 1909, 26032, 1911, 26030, 1913, 26028, 1915, 26026, 1917, 26024, 1919, 26022, 1921, 26020, 1923, 26018, 1925, 26016, 1927, 26014, 1929, 26012, 1931, 26010, 1933, 26008, 1935, 26006, 1937, 26004, 1939, 26002, 1941, 26000, 1943, 25998, 1945, 25996, 1947, 25994, 1949, 25992, 1951, 25990, 1953, 25988, 1955, 25986, 1957, 25984, 1959, 25982, 1961, 25980, 1963, 25978, 1965, 25976, 1967, 25974, 1969, 25972, 1971, 25970, 1973, 25968, 1975, 25966, 1977, 25964, 1979, 25962, 1981, 25960, 1983, 25958, 1985, 25956, 1987, 25954, 1989, 25952, 1991, 25950, 1993, 25948, 1995, 25946, 1997, 25944, 1999, 25942, 2001, 25940, 2003, 25938, 2005, 25936, 2007, 25934, 2009, 25932, 2011, 25930, 2013, 25928, 2015, 25926, 2017, 25924, 2019, 25922, 2021, 25920, 2023, 25918, 2025, 25916, 2027, 25914, 2029, 25912, 2031, 25910, 2033, 25908, 2035, 25906, 2037, 25904, 2039, 25902, 2041, 25900, 2043, 25898, 2045, 25896, 2047, 25894, 2049, 25892, 2051, 25890, 2053, 25888, 2055, 25886, 2057, 25884, 2059, 25882, 2061, 25880, 2063, 25878, 2065, 25876, 2067, 25874, 2069, 25872, 2071, 25870, 2073, 25868, 2075, 25866, 2077, 25864, 2079, 25862, 2081, 25860, 2083, 25858, 2085, 25856, 2087, 25854, 2089, 25852, 2091, 25850, 2093, 25848, 2095, 25846, 2097, 25844, 2099, 25842, 2101, 25840, 2103, 25838, 2105, 25836, 2107, 25834, 2109, 25832, 2111, 25830, 2113, 25828, 2115, 25826, 2117, 25824, 2119, 25822, 2121, 25820, 2123, 25818, 2125, 25816, 2127, 25814, 2129, 25812, 2131, 25810, 2133, 25808, 2135, 25806, 2137, 25804, 2139, 25802, 2141, 25800, 2143, 25798, 2145, 25796, 2147, 25794, 2149, 25792, 2151, 25790, 2153, 25788, 2155, 25786, 2157, 25784, 2159, 25782, 2161, 25780, 2163, 25778, 2165, 25776, 2167, 25774, 2169, 25772, 2171, 25770, 2173, 25768, 2175, 25766, 2177, 25764, 2179, 25762, 2181, 25760, 2183, 25758, 2185, 25756, 2187, 25754, 2189, 25752, 2191, 25750, 2193, 25748, 2195, 25746, 2197, 25744, 2199, 25742, 2201, 25740, 2203, 25738, 2205, 25736, 2207, 25734, 2209, 25732, 2211, 25730, 2213, 25728, 2215, 25726, 2217, 25724, 2219, 25722, 2221, 25720, 2223, 25718, 2225, 25716, 2227, 25714, 2229, 25712, 2231, 25710, 2233, 25708, 2235, 25706, 2237, 25704, 2239, 25702, 2241, 25700, 2243, 25698, 2245, 25696, 2247, 25694, 2249, 25692, 2251, 25690, 2253, 25688, 2255, 25686, 2257, 25684, 2259, 25682, 2261, 25680, 2263, 25678, 2265, 25676, 2267, 25674, 2269, 25672, 2271, 25670, 2273, 25668, 2275, 25666, 2277, 25664, 2279, 25662, 2281, 25660, 2283, 25658, 2285, 25656, 2287, 25654, 2289, 25652, 2291, 25650, 2293, 25648, 2295, 25646, 2297, 25644, 2299, 25642, 2301, 25640, 2303, 25638, 2305, 25636, 2307, 25634, 2309, 25632, 2311, 25630, 2313, 25628, 2315, 25626, 2317, 25624, 2319, 25622, 2321, 25620, 2323, 25618, 2325, 25616, 2327, 25614, 2329, 25612, 2331, 25610, 2333, 25608, 2335, 25606, 2337, 25604, 2339, 25602, 2341, 25600, 2343, 25598, 2345, 25596, 2347, 25594, 2349, 25592, 2351, 25590, 2353, 25588, 2355, 25586, 2357, 25584, 2359, 25582, 2361, 25580, 2363, 25578, 2365, 25576, 2367, 25574, 2369, 25572, 2371, 25570, 2373, 25568, 2375, 25566, 2377, 25564, 2379, 25562, 2381, 25560, 2383, 25558, 2385, 25556, 2387, 25554, 2389, 25552, 2391, 25550, 2393, 25548, 2395, 25546, 2397, 25544, 2399, 25542, 2401, 25540, 2403, 25538, 2405, 25536, 2407, 25534, 2409, 25532, 2411, 25530, 2413, 25528, 2415, 25526, 2417, 25524, 2419, 25522, 2421, 25520, 2423, 25518, 2425, 25516, 2427, 25514, 2429, 25512, 2431, 25510, 2433, 25508, 2435, 25506, 2437, 25504, 2439, 25502, 2441, 25500, 2443, 25498, 2445, 25496, 2447, 25494, 2449, 25492, 2451, 25490, 2453, 25488, 2455, 25486, 2457, 25484, 2459, 25482, 2461, 25480, 2463, 25478, 2465, 25476, 2467, 25474, 2469, 25472, 2471, 25470, 2473, 25468, 2475, 25466, 2477, 25464, 2479, 25462, 2481, 25460, 2483, 25458, 2485, 25456, 2487, 25454, 2489, 25452, 2491, 25450, 2493, 25448, 2495, 25446, 2497, 25444, 2499, 25442, 2501, 25440, 2503, 25438, 2505, 25436, 2507, 25434, 2509, 25432, 2511, 25430, 2513, 25428, 2515, 25426, 2517, 25424, 2519, 25422, 2521, 25420, 2523, 25418, 2525, 25416, 2527, 25414, 2529, 25412, 2531, 25410, 2533, 25408, 2535, 25406, 2537, 25404, 2539, 25402, 2541, 25400, 2543, 25398, 2545, 25396, 2547, 25394, 2549, 25392, 2551, 25390, 2553, 25388, 2555, 25386, 2557, 25384, 2559, 25382, 2561, 25380, 2563, 25378, 2565, 25376, 2567, 25374, 2569, 25372, 2571, 25370, 2573, 25368, 2575, 25366, 2577, 25364, 2579, 25362, 2581, 25360, 2583, 25358, 2585, 25356, 2587, 25354, 2589, 25352, 2591, 25350, 2593, 25348, 2595, 25346, 2597, 25344, 2599, 25342, 2601, 25340, 2603, 25338, 2605, 25336, 2607, 25334, 2609, 25332, 2611, 25330, 2613, 25328, 2615, 25326, 2617, 25324, 2619, 25322, 2621, 25320, 2623, 25318, 2625, 25316, 2627, 25314, 2629, 25312, 2631, 25310, 2633, 25308, 2635, 25306, 2637, 25304, 2639, 25302, 2641, 25300, 2643, 25298, 2645, 25296, 2647, 25294, 2649, 25292, 2651, 25290, 2653, 25288, 2655, 25286, 2657, 25284, 2659, 25282, 2661, 25280, 2663, 25278, 2665, 25276, 2667, 25274, 2669, 25272, 2671, 25270, 2673, 25268, 2675, 25266, 2677, 25264, 2679, 25262, 2681, 25260, 2683, 25258, 2685, 25256, 2687, 25254, 2689, 25252, 2691, 25250, 2693, 25248, 2695, 25246, 2697, 25244, 2699, 25242, 2701, 25240, 2703, 25238, 2705, 25236, 2707, 25234, 2709, 25232, 2711, 25230, 2713, 25228, 2715, 25226, 2717, 25224, 2719, 25222, 2721, 25220, 2723, 25218, 2725, 25216, 2727, 25214, 2729, 25212, 2731, 25210, 2733, 25208, 2735, 25206, 2737, 25204, 2739, 25202, 2741, 25200, 2743, 25198, 2745, 25196, 2747, 25194, 2749, 25192, 2751, 25190, 2753, 25188, 2755, 25186, 2757, 25184, 2759, 25182, 2761, 25180, 2763, 25178, 2765, 25176, 2767, 25174, 2769, 25172, 2771, 25170, 2773, 25168, 2775, 25166, 2777, 25164, 2779, 25162, 2781, 25160, 2783, 25158, 2785, 25156, 2787, 25154, 2789, 25152, 2791, 25150, 2793, 25148, 2795, 25146, 2797, 25144, 2799, 25142, 2801, 25140, 2803, 25138, 2805, 25136, 2807, 25134, 2809, 25132, 2811, 25130, 2813, 25128, 2815, 25126, 2817, 25124, 2819, 25122, 2821, 25120, 2823, 25118, 2825, 25116, 2827, 25114, 2829, 25112, 2831, 25110, 2833, 25108, 2835, 25106, 2837, 25104, 2839, 25102, 2841, 25100, 2843, 25098, 2845, 25096, 2847, 25094, 2849, 25092, 2851, 25090, 2853, 25088, 2855, 25086, 2857, 25084, 2859, 25082, 2861, 25080, 2863, 25078, 2865, 25076, 2867, 25074, 2869, 25072, 2871, 25070, 2873, 25068, 2875, 25066, 2877, 25064, 2879, 25062, 2881, 25060, 2883, 25058, 2885, 25056, 2887, 25054, 2889, 25052, 2891, 25050, 2893, 25048, 2895, 25046, 2897, 25044, 2899, 25042, 2901, 25040, 2903, 25038, 2905, 25036, 2907, 25034, 2909, 25032, 2911, 25030, 2913, 25028, 2915, 25026, 2917, 25024, 2919, 25022, 2921, 25020, 2923, 25018, 2925, 25016, 2927, 25014, 2929, 25012, 2931, 25010, 2933, 25008, 2935, 25006, 2937, 25004, 2939, 25002, 2941, 25000, 2943, 24998, 2945, 24996, 2947, 24994, 2949, 24992, 2951, 24990, 2953, 24988, 2955, 24986, 2957, 24984, 2959, 24982, 2961, 24980, 2963, 24978, 2965, 24976, 2967, 24974, 2969, 24972, 2971, 24970, 2973, 24968, 2975, 24966, 2977, 24964, 2979, 24962, 2981, 24960, 2983, 24958, 2985, 24956, 2987, 24954, 2989, 24952, 2991, 24950, 2993, 24948, 2995, 24946, 2997, 24944, 2999, 24942, 3001, 24940, 3003, 24938, 3005, 24936, 3007, 24934, 3009, 24932, 3011, 24930, 3013, 24928, 3015, 24926, 3017, 24924, 3019, 24922, 3021, 24920, 3023, 24918, 3025, 24916, 3027, 24914, 3029, 24912, 3031, 24910, 3033, 24908, 3035, 24906, 3037, 24904, 3039, 24902, 3041, 24900, 3043, 24898, 3045, 24896, 3047, 24894, 3049, 24892, 3051, 24890, 3053, 24888, 3055, 24886, 3057, 24884, 3059, 24882, 3061, 24880, 3063, 24878, 3065, 24876, 3067, 24874, 3069, 24872, 3071, 24870, 3073, 24868, 3075, 24866, 3077, 24864, 3079, 24862, 3081, 24860, 3083, 24858, 3085, 24856, 3087, 24854, 3089, 24852, 3091, 24850, 3093, 24848, 3095, 24846, 3097, 24844, 3099, 24842, 3101, 24840, 3103, 24838, 3105, 24836, 3107, 24834, 3109, 24832, 3111, 24830, 3113, 24828, 3115, 24826, 3117, 24824, 3119, 24822, 3121, 24820, 3123, 24818, 3125, 24816, 3127, 24814, 3129, 24812, 3131, 24810, 3133, 24808, 3135, 24806, 3137, 24804, 3139, 24802, 3141, 24800, 3143, 24798, 3145, 24796, 3147, 24794, 3149, 24792, 3151, 24790, 3153, 24788, 3155, 24786, 3157, 24784, 3159, 24782, 3161, 24780, 3163, 24778, 3165, 24776, 3167, 24774, 3169, 24772, 3171, 24770, 3173, 24768, 3175, 24766, 3177, 24764, 3179, 24762, 3181, 24760, 3183, 24758, 3185, 24756, 3187, 24754, 3189, 24752, 3191, 24750, 3193, 24748, 3195, 24746, 3197, 24744, 3199, 24742, 3201, 24740, 3203, 24738, 3205, 24736, 3207, 24734, 3209, 24732, 3211, 24730, 3213, 24728, 3215, 24726, 3217, 24724, 3219, 24722, 3221, 24720, 3223, 24718, 3225, 24716, 3227, 24714, 3229, 24712, 3231, 24710, 3233, 24708, 3235, 24706, 3237, 24704, 3239, 24702, 3241, 24700, 3243, 24698, 3245, 24696, 3247, 24694, 3249, 24692, 3251, 24690, 3253, 24688, 3255, 24686, 3257, 24684, 3259, 24682, 3261, 24680, 3263, 24678, 3265, 24676, 3267, 24674, 3269, 24672, 3271, 24670, 3273, 24668, 3275, 24666, 3277, 24664, 3279, 24662, 3281, 24660, 3283, 24658, 3285, 24656, 3287, 24654, 3289, 24652, 3291, 24650, 3293, 24648, 3295, 24646, 3297, 24644, 3299, 24642, 3301, 24640, 3303, 24638, 3305, 24636, 3307, 24634, 3309, 24632, 3311, 24630, 3313, 24628, 3315, 24626, 3317, 24624, 3319, 24622, 3321, 24620, 3323, 24618, 3325, 24616, 3327, 24614, 3329, 24612, 3331, 24610, 3333, 24608, 3335, 24606, 3337, 24604, 3339, 24602, 3341, 24600, 3343, 24598, 3345, 24596, 3347, 24594, 3349, 24592, 3351, 24590, 3353, 24588, 3355, 24586, 3357, 24584, 3359, 24582, 3361, 24580, 3363, 24578, 3365, 24576, 3367, 24574, 3369, 24572, 3371, 24570, 3373, 24568, 3375, 24566, 3377, 24564, 3379, 24562, 3381, 24560, 3383, 24558, 3385, 24556, 3387, 24554, 3389, 24552, 3391, 24550, 3393, 24548, 3395, 24546, 3397, 24544, 3399, 24542, 3401, 24540, 3403, 24538, 3405, 24536, 3407, 24534, 3409, 24532, 3411, 24530, 3413, 24528, 3415, 24526, 3417, 24524, 3419, 24522, 3421, 24520, 3423, 24518, 3425, 24516, 3427, 24514, 3429, 24512, 3431, 24510, 3433, 24508, 3435, 24506, 3437, 24504, 3439, 24502, 3441, 24500, 3443, 24498, 3445, 24496, 3447, 24494, 3449, 24492, 3451, 24490, 3453, 24488, 3455, 24486, 3457, 24484, 3459, 24482, 3461, 24480, 3463, 24478, 3465, 24476, 3467, 24474, 3469, 24472, 3471, 24470, 3473, 24468, 3475, 24466, 3477, 24464, 3479, 24462, 3481, 24460, 3483, 24458, 3485, 24456, 3487, 24454, 3489, 24452, 3491, 24450, 3493, 24448, 3495, 24446, 3497, 24444, 3499, 24442, 3501, 24440, 3503, 24438, 3505, 24436, 3507, 24434, 3509, 24432, 3511, 24430, 3513, 24428, 3515, 24426, 3517, 24424, 3519, 24422, 3521, 24420, 3523, 24418, 3525, 24416, 3527, 24414, 3529, 24412, 3531, 24410, 3533, 24408, 3535, 24406, 3537, 24404, 3539, 24402, 3541, 24400, 3543, 24398, 3545, 24396, 3547, 24394, 3549, 24392, 3551, 24390, 3553, 24388, 3555, 24386, 3557, 24384, 3559, 24382, 3561, 24380, 3563, 24378, 3565, 24376, 3567, 24374, 3569, 24372, 3571, 24370, 3573, 24368, 3575, 24366, 3577, 24364, 3579, 24362, 3581, 24360, 3583, 24358, 3585, 24356, 3587, 24354, 3589, 24352, 3591, 24350, 3593, 24348, 3595, 24346, 3597, 24344, 3599, 24342, 3601, 24340, 3603, 24338, 3605, 24336, 3607, 24334, 3609, 24332, 3611, 24330, 3613, 24328, 3615, 24326, 3617, 24324, 3619, 24322, 3621, 24320, 3623, 24318, 3625, 24316, 3627, 24314, 3629, 24312, 3631, 24310, 3633, 24308, 3635, 24306, 3637, 24304, 3639, 24302, 3641, 24300, 3643, 24298, 3645, 24296, 3647, 24294, 3649, 24292, 3651, 24290, 3653, 24288, 3655, 24286, 3657, 24284, 3659, 24282, 3661, 24280, 3663, 24278, 3665, 24276, 3667, 24274, 3669, 24272, 3671, 24270, 3673, 24268, 3675, 24266, 3677, 24264, 3679, 24262, 3681, 24260, 3683, 24258, 3685, 24256, 3687, 24254, 3689, 24252, 3691, 24250, 3693, 24248, 3695, 24246, 3697, 24244, 3699, 24242, 3701, 24240, 3703, 24238, 3705, 24236, 3707, 24234, 3709, 24232, 3711, 24230, 3713, 24228, 3715, 24226, 3717, 24224, 3719, 24222, 3721, 24220, 3723, 24218, 3725, 24216, 3727, 24214, 3729, 24212, 3731, 24210, 3733, 24208, 3735, 24206, 3737, 24204, 3739, 24202, 3741, 24200, 3743, 24198, 3745, 24196, 3747, 24194, 3749, 24192, 3751, 24190, 3753, 24188, 3755, 24186, 3757, 24184, 3759, 24182, 3761, 24180, 3763, 24178, 3765, 24176, 3767, 24174, 3769, 24172, 3771, 24170, 3773, 24168, 3775, 24166, 3777, 24164, 3779, 24162, 3781, 24160, 3783, 24158, 3785, 24156, 3787, 24154, 3789, 24152, 3791, 24150, 3793, 24148, 3795, 24146, 3797, 24144, 3799, 24142, 3801, 24140, 3803, 24138, 3805, 24136, 3807, 24134, 3809, 24132, 3811, 24130, 3813, 24128, 3815, 24126, 3817, 24124, 3819, 24122, 3821, 24120, 3823, 24118, 3825, 24116, 3827, 24114, 3829, 24112, 3831, 24110, 3833, 24108, 3835, 24106, 3837, 24104, 3839, 24102, 3841, 24100, 3843, 24098, 3845, 24096, 3847, 24094, 3849, 24092, 3851, 24090, 3853, 24088, 3855, 24086, 3857, 24084, 3859, 24082, 3861, 24080, 3863, 24078, 3865, 24076, 3867, 24074, 3869, 24072, 3871, 24070, 3873, 24068, 3875, 24066, 3877, 24064, 3879, 24062, 3881, 24060, 3883, 24058, 3885, 24056, 3887, 24054, 3889, 24052, 3891, 24050, 3893, 24048, 3895, 24046, 3897, 24044, 3899, 24042, 3901, 24040, 3903, 24038, 3905, 24036, 3907, 24034, 3909, 24032, 3911, 24030, 3913, 24028, 3915, 24026, 3917, 24024, 3919, 24022, 3921, 24020, 3923, 24018, 3925, 24016, 3927, 24014, 3929, 24012, 3931, 24010, 3933, 24008, 3935, 24006, 3937, 24004, 3939, 24002, 3941, 24000, 3943, 23998, 3945, 23996, 3947, 23994, 3949, 23992, 3951, 23990, 3953, 23988, 3955, 23986, 3957, 23984, 3959, 23982, 3961, 23980, 3963, 23978, 3965, 23976, 3967, 23974, 3969, 23972, 3971, 23970, 3973, 23968, 3975, 23966, 3977, 23964, 3979, 23962, 3981, 23960, 3983, 23958, 3985, 23956, 3987, 23954, 3989, 23952, 3991, 23950, 3993, 23948, 3995, 23946, 3997, 23944, 3999, 23942, 4001, 23940, 4003, 23938, 4005, 23936, 4007, 23934, 4009, 23932, 4011, 23930, 4013, 23928, 4015, 23926, 4017, 23924, 4019, 23922, 4021, 23920, 4023, 23918, 4025, 23916, 4027, 23914, 4029, 23912, 4031, 23910, 4033, 23908, 4035, 23906, 4037, 23904, 4039, 23902, 4041, 23900, 4043, 23898, 4045, 23896, 4047, 23894, 4049, 23892, 4051, 23890, 4053, 23888, 4055, 23886, 4057, 23884, 4059, 23882, 4061, 23880, 4063, 23878, 4065, 23876, 4067, 23874, 4069, 23872, 4071, 23870, 4073, 23868, 4075, 23866, 4077, 23864, 4079, 23862, 4081, 23860, 4083, 23858, 4085, 23856, 4087, 23854, 4089, 23852, 4091, 23850, 4093, 23848, 4095, 23846, 4097, 23844, 4099, 23842, 4101, 23840, 4103, 23838, 4105, 23836, 4107, 23834, 4109, 23832, 4111, 23830, 4113, 23828, 4115, 23826, 4117, 23824, 4119, 23822, 4121, 23820, 4123, 23818, 4125, 23816, 4127, 23814, 4129, 23812, 4131, 23810, 4133, 23808, 4135, 23806, 4137, 23804, 4139, 23802, 4141, 23800, 4143, 23798, 4145, 23796, 4147, 23794, 4149, 23792, 4151, 23790, 4153, 23788, 4155, 23786, 4157, 23784, 4159, 23782, 4161, 23780, 4163, 23778, 4165, 23776, 4167, 23774, 4169, 23772, 4171, 23770, 4173, 23768, 4175, 23766, 4177, 23764, 4179, 23762, 4181, 23760, 4183, 23758, 4185, 23756, 4187, 23754, 4189, 23752, 4191, 23750, 4193, 23748, 4195, 23746, 4197, 23744, 4199, 23742, 4201, 23740, 4203, 23738, 4205, 23736, 4207, 23734, 4209, 23732, 4211, 23730, 4213, 23728, 4215, 23726, 4217, 23724, 4219, 23722, 4221, 23720, 4223, 23718, 4225, 23716, 4227, 23714, 4229, 23712, 4231, 23710, 4233, 23708, 4235, 23706, 4237, 23704, 4239, 23702, 4241, 23700, 4243, 23698, 4245, 23696, 4247, 23694, 4249, 23692, 4251, 23690, 4253, 23688, 4255, 23686, 4257, 23684, 4259, 23682, 4261, 23680, 4263, 23678, 4265, 23676, 4267, 23674, 4269, 23672, 4271, 23670, 4273, 23668, 4275, 23666, 4277, 23664, 4279, 23662, 4281, 23660, 4283, 23658, 4285, 23656, 4287, 23654, 4289, 23652, 4291, 23650, 4293, 23648, 4295, 23646, 4297, 23644, 4299, 23642, 4301, 23640, 4303, 23638, 4305, 23636, 4307, 23634, 4309, 23632, 4311, 23630, 4313, 23628, 4315, 23626, 4317, 23624, 4319, 23622, 4321, 23620, 4323, 23618, 4325, 23616, 4327, 23614, 4329, 23612, 4331, 23610, 4333, 23608, 4335, 23606, 4337, 23604, 4339, 23602, 4341, 23600, 4343, 23598, 4345, 23596, 4347, 23594, 4349, 23592, 4351, 23590, 4353, 23588, 4355, 23586, 4357, 23584, 4359, 23582, 4361, 23580, 4363, 23578, 4365, 23576, 4367, 23574, 4369, 23572, 4371, 23570, 4373, 23568, 4375, 23566, 4377, 23564, 4379, 23562, 4381, 23560, 4383, 23558, 4385, 23556, 4387, 23554, 4389, 23552, 4391, 23550, 4393, 23548, 4395, 23546, 4397, 23544, 4399, 23542, 4401, 23540, 4403, 23538, 4405, 23536, 4407, 23534, 4409, 23532, 4411, 23530, 4413, 23528, 4415, 23526, 4417, 23524, 4419, 23522, 4421, 23520, 4423, 23518, 4425, 23516, 4427, 23514, 4429, 23512, 4431, 23510, 4433, 23508, 4435, 23506, 4437, 23504, 4439, 23502, 4441, 23500, 4443, 23498, 4445, 23496, 4447, 23494, 4449, 23492, 4451, 23490, 4453, 23488, 4455, 23486, 4457, 23484, 4459, 23482, 4461, 23480, 4463, 23478, 4465, 23476, 4467, 23474, 4469, 23472, 4471, 23470, 4473, 23468, 4475, 23466, 4477, 23464, 4479, 23462, 4481, 23460, 4483, 23458, 4485, 23456, 4487, 23454, 4489, 23452, 4491, 23450, 4493, 23448, 4495, 23446, 4497, 23444, 4499, 23442, 4501, 23440, 4503, 23438, 4505, 23436, 4507, 23434, 4509, 23432, 4511, 23430, 4513, 23428, 4515, 23426, 4517, 23424, 4519, 23422, 4521, 23420, 4523, 23418, 4525, 23416, 4527, 23414, 4529, 23412, 4531, 23410, 4533, 23408, 4535, 23406, 4537, 23404, 4539, 23402, 4541, 23400, 4543, 23398, 4545, 23396, 4547, 23394, 4549, 23392, 4551, 23390, 4553, 23388, 4555, 23386, 4557, 23384, 4559, 23382, 4561, 23380, 4563, 23378, 4565, 23376, 4567, 23374, 4569, 23372, 4571, 23370, 4573, 23368, 4575, 23366, 4577, 23364, 4579, 23362, 4581, 23360, 4583, 23358, 4585, 23356, 4587, 23354, 4589, 23352, 4591, 23350, 4593, 23348, 4595, 23346, 4597, 23344, 4599, 23342, 4601, 23340, 4603, 23338, 4605, 23336, 4607, 23334, 4609, 23332, 4611, 23330, 4613, 23328, 4615, 23326, 4617, 23324, 4619, 23322, 4621, 23320, 4623, 23318, 4625, 23316, 4627, 23314, 4629, 23312, 4631, 23310, 4633, 23308, 4635, 23306, 4637, 23304, 4639, 23302, 4641, 23300, 4643, 23298, 4645, 23296, 4647, 23294, 4649, 23292, 4651, 23290, 4653, 23288, 4655, 23286, 4657, 23284, 4659, 23282, 4661, 23280, 4663, 23278, 4665, 23276, 4667, 23274, 4669, 23272, 4671, 23270, 4673, 23268, 4675, 23266, 4677, 23264, 4679, 23262, 4681, 23260, 4683, 23258, 4685, 23256, 4687, 23254, 4689, 23252, 4691, 23250, 4693, 23248, 4695, 23246, 4697, 23244, 4699, 23242, 4701, 23240, 4703, 23238, 4705, 23236, 4707, 23234, 4709, 23232, 4711, 23230, 4713, 23228, 4715, 23226, 4717, 23224, 4719, 23222, 4721, 23220, 4723, 23218, 4725, 23216, 4727, 23214, 4729, 23212, 4731, 23210, 4733, 23208, 4735, 23206, 4737, 23204, 4739, 23202, 4741, 23200, 4743, 23198, 4745, 23196, 4747, 23194, 4749, 23192, 4751, 23190, 4753, 23188, 4755, 23186, 4757, 23184, 4759, 23182, 4761, 23180, 4763, 23178, 4765, 23176, 4767, 23174, 4769, 23172, 4771, 23170, 4773, 23168, 4775, 23166, 4777, 23164, 4779, 23162, 4781, 23160, 4783, 23158, 4785, 23156, 4787, 23154, 4789, 23152, 4791, 23150, 4793, 23148, 4795, 23146, 4797, 23144, 4799, 23142, 4801, 23140, 4803, 23138, 4805, 23136, 4807, 23134, 4809, 23132, 4811, 23130, 4813, 23128, 4815, 23126, 4817, 23124, 4819, 23122, 4821, 23120, 4823, 23118, 4825, 23116, 4827, 23114, 4829, 23112, 4831, 23110, 4833, 23108, 4835, 23106, 4837, 23104, 4839, 23102, 4841, 23100, 4843, 23098, 4845, 23096, 4847, 23094, 4849, 23092, 4851, 23090, 4853, 23088, 4855, 23086, 4857, 23084, 4859, 23082, 4861, 23080, 4863, 23078, 4865, 23076, 4867, 23074, 4869, 23072, 4871, 23070, 4873, 23068, 4875, 23066, 4877, 23064, 4879, 23062, 4881, 23060, 4883, 23058, 4885, 23056, 4887, 23054, 4889, 23052, 4891, 23050, 4893, 23048, 4895, 23046, 4897, 23044, 4899, 23042, 4901, 23040, 4903, 23038, 4905, 23036, 4907, 23034, 4909, 23032, 4911, 23030, 4913, 23028, 4915, 23026, 4917, 23024, 4919, 23022, 4921, 23020, 4923, 23018, 4925, 23016, 4927, 23014, 4929, 23012, 4931, 23010, 4933, 23008, 4935, 23006, 4937, 23004, 4939, 23002, 4941, 23000, 4943, 22998, 4945, 22996, 4947, 22994, 4949, 22992, 4951, 22990, 4953, 22988, 4955, 22986, 4957, 22984, 4959, 22982, 4961, 22980, 4963, 22978, 4965, 22976, 4967, 22974, 4969, 22972, 4971, 22970, 4973, 22968, 4975, 22966, 4977, 22964, 4979, 22962, 4981, 22960, 4983, 22958, 4985, 22956, 4987, 22954, 4989, 22952, 4991, 22950, 4993, 22948, 4995, 22946, 4997, 22944, 4999, 22942, 5001, 22940, 5003, 22938, 5005, 22936, 5007, 22934, 5009, 22932, 5011, 22930, 5013, 22928, 5015, 22926, 5017, 22924, 5019, 22922, 5021, 22920, 5023, 22918, 5025, 22916, 5027, 22914, 5029, 22912, 5031, 22910, 5033, 22908, 5035, 22906, 5037, 22904, 5039, 22902, 5041, 22900, 5043, 22898, 5045, 22896, 5047, 22894, 5049, 22892, 5051, 22890, 5053, 22888, 5055, 22886, 5057, 22884, 5059, 22882, 5061, 22880, 5063, 22878, 5065, 22876, 5067, 22874, 5069, 22872, 5071, 22870, 5073, 22868, 5075, 22866, 5077, 22864, 5079, 22862, 5081, 22860, 5083, 22858, 5085, 22856, 5087, 22854, 5089, 22852, 5091, 22850, 5093, 22848, 5095, 22846, 5097, 22844, 5099, 22842, 5101, 22840, 5103, 22838, 5105, 22836, 5107, 22834, 5109, 22832, 5111, 22830, 5113, 22828, 5115, 22826, 5117, 22824, 5119, 22822, 5121, 22820, 5123, 22818, 5125, 22816, 5127, 22814, 5129, 22812, 5131, 22810, 5133, 22808, 5135, 22806, 5137, 22804, 5139, 22802, 5141, 22800, 5143, 22798, 5145, 22796, 5147, 22794, 5149, 22792, 5151, 22790, 5153, 22788, 5155, 22786, 5157, 22784, 5159, 22782, 5161, 22780, 5163, 22778, 5165, 22776, 5167, 22774, 5169, 22772, 5171, 22770, 5173, 22768, 5175, 22766, 5177, 22764, 5179, 22762, 5181, 22760, 5183, 22758, 5185, 22756, 5187, 22754, 5189, 22752, 5191, 22750, 5193, 22748, 5195, 22746, 5197, 22744, 5199, 22742, 5201, 22740, 5203, 22738, 5205, 22736, 5207, 22734, 5209, 22732, 5211, 22730, 5213, 22728, 5215, 22726, 5217, 22724, 5219, 22722, 5221, 22720, 5223, 22718, 5225, 22716, 5227, 22714, 5229, 22712, 5231, 22710, 5233, 22708, 5235, 22706, 5237, 22704, 5239, 22702, 5241, 22700, 5243, 22698, 5245, 22696, 5247, 22694, 5249, 22692, 5251, 22690, 5253, 22688, 5255, 22686, 5257, 22684, 5259, 22682, 5261, 22680, 5263, 22678, 5265, 22676, 5267, 22674, 5269, 22672, 5271, 22670, 5273, 22668, 5275, 22666, 5277, 22664, 5279, 22662, 5281, 22660, 5283, 22658, 5285, 22656, 5287, 22654, 5289, 22652, 5291, 22650, 5293, 22648, 5295, 22646, 5297, 22644, 5299, 22642, 5301, 22640, 5303, 22638, 5305, 22636, 5307, 22634, 5309, 22632, 5311, 22630, 5313, 22628, 5315, 22626, 5317, 22624, 5319, 22622, 5321, 22620, 5323, 22618, 5325, 22616, 5327, 22614, 5329, 22612, 5331, 22610, 5333, 22608, 5335, 22606, 5337, 22604, 5339, 22602, 5341, 22600, 5343, 22598, 5345, 22596, 5347, 22594, 5349, 22592, 5351, 22590, 5353, 22588, 5355, 22586, 5357, 22584, 5359, 22582, 5361, 22580, 5363, 22578, 5365, 22576, 5367, 22574, 5369, 22572, 5371, 22570, 5373, 22568, 5375, 22566, 5377, 22564, 5379, 22562, 5381, 22560, 5383, 22558, 5385, 22556, 5387, 22554, 5389, 22552, 5391, 22550, 5393, 22548, 5395, 22546, 5397, 22544, 5399, 22542, 5401, 22540, 5403, 22538, 5405, 22536, 5407, 22534, 5409, 22532, 5411, 22530, 5413, 22528, 5415, 22526, 5417, 22524, 5419, 22522, 5421, 22520, 5423, 22518, 5425, 22516, 5427, 22514, 5429, 22512, 5431, 22510, 5433, 22508, 5435, 22506, 5437, 22504, 5439, 22502, 5441, 22500, 5443, 22498, 5445, 22496, 5447, 22494, 5449, 22492, 5451, 22490, 5453, 22488, 5455, 22486, 5457, 22484, 5459, 22482, 5461, 22480, 5463, 22478, 5465, 22476, 5467, 22474, 5469, 22472, 5471, 22470, 5473, 22468, 5475, 22466, 5477, 22464, 5479, 22462, 5481, 22460, 5483, 22458, 5485, 22456, 5487, 22454, 5489, 22452, 5491, 22450, 5493, 22448, 5495, 22446, 5497, 22444, 5499, 22442, 5501, 22440, 5503, 22438, 5505, 22436, 5507, 22434, 5509, 22432, 5511, 22430, 5513, 22428, 5515, 22426, 5517, 22424, 5519, 22422, 5521, 22420, 5523, 22418, 5525, 22416, 5527, 22414, 5529, 22412, 5531, 22410, 5533, 22408, 5535, 22406, 5537, 22404, 5539, 22402, 5541, 22400, 5543, 22398, 5545, 22396, 5547, 22394, 5549, 22392, 5551, 22390, 5553, 22388, 5555, 22386, 5557, 22384, 5559, 22382, 5561, 22380, 5563, 22378, 5565, 22376, 5567, 22374, 5569, 22372, 5571, 22370, 5573, 22368, 5575, 22366, 5577, 22364, 5579, 22362, 5581, 22360, 5583, 22358, 5585, 22356, 5587, 22354, 5589, 22352, 5591, 22350, 5593, 22348, 5595, 22346, 5597, 22344, 5599, 22342, 5601, 22340, 5603, 22338, 5605, 22336, 5607, 22334, 5609, 22332, 5611, 22330, 5613, 22328, 5615, 22326, 5617, 22324, 5619, 22322, 5621, 22320, 5623, 22318, 5625, 22316, 5627, 22314, 5629, 22312, 5631, 22310, 5633, 22308, 5635, 22306, 5637, 22304, 5639, 22302, 5641, 22300, 5643, 22298, 5645, 22296, 5647, 22294, 5649, 22292, 5651, 22290, 5653, 22288, 5655, 22286, 5657, 22284, 5659, 22282, 5661, 22280, 5663, 22278, 5665, 22276, 5667, 22274, 5669, 22272, 5671, 22270, 5673, 22268, 5675, 22266, 5677, 22264, 5679, 22262, 5681, 22260, 5683, 22258, 5685, 22256, 5687, 22254, 5689, 22252, 5691, 22250, 5693, 22248, 5695, 22246, 5697, 22244, 5699, 22242, 5701, 22240, 5703, 22238, 5705, 22236, 5707, 22234, 5709, 22232, 5711, 22230, 5713, 22228, 5715, 22226, 5717, 22224, 5719, 22222, 5721, 22220, 5723, 22218, 5725, 22216, 5727, 22214, 5729, 22212, 5731, 22210, 5733, 22208, 5735, 22206, 5737, 22204, 5739, 22202, 5741, 22200, 5743, 22198, 5745, 22196, 5747, 22194, 5749, 22192, 5751, 22190, 5753, 22188, 5755, 22186, 5757, 22184, 5759, 22182, 5761, 22180, 5763, 22178, 5765, 22176, 5767, 22174, 5769, 22172, 5771, 22170, 5773, 22168, 5775, 22166, 5777, 22164, 5779, 22162, 5781, 22160, 5783, 22158, 5785, 22156, 5787, 22154, 5789, 22152, 5791, 22150, 5793, 22148, 5795, 22146, 5797, 22144, 5799, 22142, 5801, 22140, 5803, 22138, 5805, 22136, 5807, 22134, 5809, 22132, 5811, 22130, 5813, 22128, 5815, 22126, 5817, 22124, 5819, 22122, 5821, 22120, 5823, 22118, 5825, 22116, 5827, 22114, 5829, 22112, 5831, 22110, 5833, 22108, 5835, 22106, 5837, 22104, 5839, 22102, 5841, 22100, 5843, 22098, 5845, 22096, 5847, 22094, 5849, 22092, 5851, 22090, 5853, 22088, 5855, 22086, 5857, 22084, 5859, 22082, 5861, 22080, 5863, 22078, 5865, 22076, 5867, 22074, 5869, 22072, 5871, 22070, 5873, 22068, 5875, 22066, 5877, 22064, 5879, 22062, 5881, 22060, 5883, 22058, 5885, 22056, 5887, 22054, 5889, 22052, 5891, 22050, 5893, 22048, 5895, 22046, 5897, 22044, 5899, 22042, 5901, 22040, 5903, 22038, 5905, 22036, 5907, 22034, 5909, 22032, 5911, 22030, 5913, 22028, 5915, 22026, 5917, 22024, 5919, 22022, 5921, 22020, 5923, 22018, 5925, 22016, 5927, 22014, 5929, 22012, 5931, 22010, 5933, 22008, 5935, 22006, 5937, 22004, 5939, 22002, 5941, 22000, 5943, 21998, 5945, 21996, 5947, 21994, 5949, 21992, 5951, 21990, 5953, 21988, 5955, 21986, 5957, 21984, 5959, 21982, 5961, 21980, 5963, 21978, 5965, 21976, 5967, 21974, 5969, 21972, 5971, 21970, 5973, 21968, 5975, 21966, 5977, 21964, 5979, 21962, 5981, 21960, 5983, 21958, 5985, 21956, 5987, 21954, 5989, 21952, 5991, 21950, 5993, 21948, 5995, 21946, 5997, 21944, 5999, 21942, 6001, 21940, 6003, 21938, 6005, 21936, 6007, 21934, 6009, 21932, 6011, 21930, 6013, 21928, 6015, 21926, 6017, 21924, 6019, 21922, 6021, 21920, 6023, 21918, 6025, 21916, 6027, 21914, 6029, 21912, 6031, 21910, 6033, 21908, 6035, 21906, 6037, 21904, 6039, 21902, 6041, 21900, 6043, 21898, 6045, 21896, 6047, 21894, 6049, 21892, 6051, 21890, 6053, 21888, 6055, 21886, 6057, 21884, 6059, 21882, 6061, 21880, 6063, 21878, 6065, 21876, 6067, 21874, 6069, 21872, 6071, 21870, 6073, 21868, 6075, 21866, 6077, 21864, 6079, 21862, 6081, 21860, 6083, 21858, 6085, 21856, 6087, 21854, 6089, 21852, 6091, 21850, 6093, 21848, 6095, 21846, 6097, 21844, 6099, 21842, 6101, 21840, 6103, 21838, 6105, 21836, 6107, 21834, 6109, 21832, 6111, 21830, 6113, 21828, 6115, 21826, 6117, 21824, 6119, 21822, 6121, 21820, 6123, 21818, 6125, 21816, 6127, 21814, 6129, 21812, 6131, 21810, 6133, 21808, 6135, 21806, 6137, 21804, 6139, 21802, 6141, 21800, 6143, 21798, 6145, 21796, 6147, 21794, 6149, 21792, 6151, 21790, 6153, 21788, 6155, 21786, 6157, 21784, 6159, 21782, 6161, 21780, 6163, 21778, 6165, 21776, 6167, 21774, 6169, 21772, 6171, 21770, 6173, 21768, 6175, 21766, 6177, 21764, 6179, 21762, 6181, 21760, 6183, 21758, 6185, 21756, 6187, 21754, 6189, 21752, 6191, 21750, 6193, 21748, 6195, 21746, 6197, 21744, 6199, 21742, 6201, 21740, 6203, 21738, 6205, 21736, 6207, 21734, 6209, 21732, 6211, 21730, 6213, 21728, 6215, 21726, 6217, 21724, 6219, 21722, 6221, 21720, 6223, 21718, 6225, 21716, 6227, 21714, 6229, 21712, 6231, 21710, 6233, 21708, 6235, 21706, 6237, 21704, 6239, 21702, 6241, 21700, 6243, 21698, 6245, 21696, 6247, 21694, 6249, 21692, 6251, 21690, 6253, 21688, 6255, 21686, 6257, 21684, 6259, 21682, 6261, 21680, 6263, 21678, 6265, 21676, 6267, 21674, 6269, 21672, 6271, 21670, 6273, 21668, 6275, 21666, 6277, 21664, 6279, 21662, 6281, 21660, 6283, 21658, 6285, 21656, 6287, 21654, 6289, 21652, 6291, 21650, 6293, 21648, 6295, 21646, 6297, 21644, 6299, 21642, 6301, 21640, 6303, 21638, 6305, 21636, 6307, 21634, 6309, 21632, 6311, 21630, 6313, 21628, 6315, 21626, 6317, 21624, 6319, 21622, 6321, 21620, 6323, 21618, 6325, 21616, 6327, 21614, 6329, 21612, 6331, 21610, 6333, 21608, 6335, 21606, 6337, 21604, 6339, 21602, 6341, 21600, 6343, 21598, 6345, 21596, 6347, 21594, 6349, 21592, 6351, 21590, 6353, 21588, 6355, 21586, 6357, 21584, 6359, 21582, 6361, 21580, 6363, 21578, 6365, 21576, 6367, 21574, 6369, 21572, 6371, 21570, 6373, 21568, 6375, 21566, 6377, 21564, 6379, 21562, 6381, 21560, 6383, 21558, 6385, 21556, 6387, 21554, 6389, 21552, 6391, 21550, 6393, 21548, 6395, 21546, 6397, 21544, 6399, 21542, 6401, 21540, 6403, 21538, 6405, 21536, 6407, 21534, 6409, 21532, 6411, 21530, 6413, 21528, 6415, 21526, 6417, 21524, 6419, 21522, 6421, 21520, 6423, 21518, 6425, 21516, 6427, 21514, 6429, 21512, 6431, 21510, 6433, 21508, 6435, 21506, 6437, 21504, 6439, 21502, 6441, 21500, 6443, 21498, 6445, 21496, 6447, 21494, 6449, 21492, 6451, 21490, 6453, 21488, 6455, 21486, 6457, 21484, 6459, 21482, 6461, 21480, 6463, 21478, 6465, 21476, 6467, 21474, 6469, 21472, 6471, 21470, 6473, 21468, 6475, 21466, 6477, 21464, 6479, 21462, 6481, 21460, 6483, 21458, 6485, 21456, 6487, 21454, 6489, 21452, 6491, 21450, 6493, 21448, 6495, 21446, 6497, 21444, 6499, 21442, 6501, 21440, 6503, 21438, 6505, 21436, 6507, 21434, 6509, 21432, 6511, 21430, 6513, 21428, 6515, 21426, 6517, 21424, 6519, 21422, 6521, 21420, 6523, 21418, 6525, 21416, 6527, 21414, 6529, 21412, 6531, 21410, 6533, 21408, 6535, 21406, 6537, 21404, 6539, 21402, 6541, 21400, 6543, 21398, 6545, 21396, 6547, 21394, 6549, 21392, 6551, 21390, 6553, 21388, 6555, 21386, 6557, 21384, 6559, 21382, 6561, 21380, 6563, 21378, 6565, 21376, 6567, 21374, 6569, 21372, 6571, 21370, 6573, 21368, 6575, 21366, 6577, 21364, 6579, 21362, 6581, 21360, 6583, 21358, 6585, 21356, 6587, 21354, 6589, 21352, 6591, 21350, 6593, 21348, 6595, 21346, 6597, 21344, 6599, 21342, 6601, 21340, 6603, 21338, 6605, 21336, 6607, 21334, 6609, 21332, 6611, 21330, 6613, 21328, 6615, 21326, 6617, 21324, 6619, 21322, 6621, 21320, 6623, 21318, 6625, 21316, 6627, 21314, 6629, 21312, 6631, 21310, 6633, 21308, 6635, 21306, 6637, 21304, 6639, 21302, 6641, 21300, 6643, 21298, 6645, 21296, 6647, 21294, 6649, 21292, 6651, 21290, 6653, 21288, 6655, 21286, 6657, 21284, 6659, 21282, 6661, 21280, 6663, 21278, 6665, 21276, 6667, 21274, 6669, 21272, 6671, 21270, 6673, 21268, 6675, 21266, 6677, 21264, 6679, 21262, 6681, 21260, 6683, 21258, 6685, 21256, 6687, 21254, 6689, 21252, 6691, 21250, 6693, 21248, 6695, 21246, 6697, 21244, 6699, 21242, 6701, 21240, 6703, 21238, 6705, 21236, 6707, 21234, 6709, 21232, 6711, 21230, 6713, 21228, 6715, 21226, 6717, 21224, 6719, 21222, 6721, 21220, 6723, 21218, 6725, 21216, 6727, 21214, 6729, 21212, 6731, 21210, 6733, 21208, 6735, 21206, 6737, 21204, 6739, 21202, 6741, 21200, 6743, 21198, 6745, 21196, 6747, 21194, 6749, 21192, 6751, 21190, 6753, 21188, 6755, 21186, 6757, 21184, 6759, 21182, 6761, 21180, 6763, 21178, 6765, 21176, 6767, 21174, 6769, 21172, 6771, 21170, 6773, 21168, 6775, 21166, 6777, 21164, 6779, 21162, 6781, 21160, 6783, 21158, 6785, 21156, 6787, 21154, 6789, 21152, 6791, 21150, 6793, 21148, 6795, 21146, 6797, 21144, 6799, 21142, 6801, 21140, 6803, 21138, 6805, 21136, 6807, 21134, 6809, 21132, 6811, 21130, 6813, 21128, 6815, 21126, 6817, 21124, 6819, 21122, 6821, 21120, 6823, 21118, 6825, 21116, 6827, 21114, 6829, 21112, 6831, 21110, 6833, 21108, 6835, 21106, 6837, 21104, 6839, 21102, 6841, 21100, 6843, 21098, 6845, 21096, 6847, 21094, 6849, 21092, 6851, 21090, 6853, 21088, 6855, 21086, 6857, 21084, 6859, 21082, 6861, 21080, 6863, 21078, 6865, 21076, 6867, 21074, 6869, 21072, 6871, 21070, 6873, 21068, 6875, 21066, 6877, 21064, 6879, 21062, 6881, 21060, 6883, 21058, 6885, 21056, 6887, 21054, 6889, 21052, 6891, 21050, 6893, 21048, 6895, 21046, 6897, 21044, 6899, 21042, 6901, 21040, 6903, 21038, 6905, 21036, 6907, 21034, 6909, 21032, 6911, 21030, 6913, 21028, 6915, 21026, 6917, 21024, 6919, 21022, 6921, 21020, 6923, 21018, 6925, 21016, 6927, 21014, 6929, 21012, 6931, 21010, 6933, 21008, 6935, 21006, 6937, 21004, 6939, 21002, 6941, 21000, 6943, 20998, 6945, 20996, 6947, 20994, 6949, 20992, 6951, 20990, 6953, 20988, 6955, 20986, 6957, 20984, 6959, 20982, 6961, 20980, 6963, 20978, 6965, 20976, 6967, 20974, 6969, 20972, 6971, 20970, 6973, 20968, 6975, 20966, 6977, 20964, 6979, 20962, 6981, 20960, 6983, 20958, 6985, 20956, 6987, 20954, 6989, 20952, 6991, 20950, 6993, 20948, 6995, 20946, 6997, 20944, 6999, 20942, 7001, 20940, 7003, 20938, 7005, 20936, 7007, 20934, 7009, 20932, 7011, 20930, 7013, 20928, 7015, 20926, 7017, 20924, 7019, 20922, 7021, 20920, 7023, 20918, 7025, 20916, 7027, 20914, 7029, 20912, 7031, 20910, 7033, 20908, 7035, 20906, 7037, 20904, 7039, 20902, 7041, 20900, 7043, 20898, 7045, 20896, 7047, 20894, 7049, 20892, 7051, 20890, 7053, 20888, 7055, 20886, 7057, 20884, 7059, 20882, 7061, 20880, 7063, 20878, 7065, 20876, 7067, 20874, 7069, 20872, 7071, 20870, 7073, 20868, 7075, 20866, 7077, 20864, 7079, 20862, 7081, 20860, 7083, 20858, 7085, 20856, 7087, 20854, 7089, 20852, 7091, 20850, 7093, 20848, 7095, 20846, 7097, 20844, 7099, 20842, 7101, 20840, 7103, 20838, 7105, 20836, 7107, 20834, 7109, 20832, 7111, 20830, 7113, 20828, 7115, 20826, 7117, 20824, 7119, 20822, 7121, 20820, 7123, 20818, 7125, 20816, 7127, 20814, 7129, 20812, 7131, 20810, 7133, 20808, 7135, 20806, 7137, 20804, 7139, 20802, 7141, 20800, 7143, 20798, 7145, 20796, 7147, 20794, 7149, 20792, 7151, 20790, 7153, 20788, 7155, 20786, 7157, 20784, 7159, 20782, 7161, 20780, 7163, 20778, 7165, 20776, 7167, 20774, 7169, 20772, 7171, 20770, 7173, 20768, 7175, 20766, 7177, 20764, 7179, 20762, 7181, 20760, 7183, 20758, 7185, 20756, 7187, 20754, 7189, 20752, 7191, 20750, 7193, 20748, 7195, 20746, 7197, 20744, 7199, 20742, 7201, 20740, 7203, 20738, 7205, 20736, 7207, 20734, 7209, 20732, 7211, 20730, 7213, 20728, 7215, 20726, 7217, 20724, 7219, 20722, 7221, 20720, 7223, 20718, 7225, 20716, 7227, 20714, 7229, 20712, 7231, 20710, 7233, 20708, 7235, 20706, 7237, 20704, 7239, 20702, 7241, 20700, 7243, 20698, 7245, 20696, 7247, 20694, 7249, 20692, 7251, 20690, 7253, 20688, 7255, 20686, 7257, 20684, 7259, 20682, 7261, 20680, 7263, 20678, 7265, 20676, 7267, 20674, 7269, 20672, 7271, 20670, 7273, 20668, 7275, 20666, 7277, 20664, 7279, 20662, 7281, 20660, 7283, 20658, 7285, 20656, 7287, 20654, 7289, 20652, 7291, 20650, 7293, 20648, 7295, 20646, 7297, 20644, 7299, 20642, 7301, 20640, 7303, 20638, 7305, 20636, 7307, 20634, 7309, 20632, 7311, 20630, 7313, 20628, 7315, 20626, 7317, 20624, 7319, 20622, 7321, 20620, 7323, 20618, 7325, 20616, 7327, 20614, 7329, 20612, 7331, 20610, 7333, 20608, 7335, 20606, 7337, 20604, 7339, 20602, 7341, 20600, 7343, 20598, 7345, 20596, 7347, 20594, 7349, 20592, 7351, 20590, 7353, 20588, 7355, 20586, 7357, 20584, 7359, 20582, 7361, 20580, 7363, 20578, 7365, 20576, 7367, 20574, 7369, 20572, 7371, 20570, 7373, 20568, 7375, 20566, 7377, 20564, 7379, 20562, 7381, 20560, 7383, 20558, 7385, 20556, 7387, 20554, 7389, 20552, 7391, 20550, 7393, 20548, 7395, 20546, 7397, 20544, 7399, 20542, 7401, 20540, 7403, 20538, 7405, 20536, 7407, 20534, 7409, 20532, 7411, 20530, 7413, 20528, 7415, 20526, 7417, 20524, 7419, 20522, 7421, 20520, 7423, 20518, 7425, 20516, 7427, 20514, 7429, 20512, 7431, 20510, 7433, 20508, 7435, 20506, 7437, 20504, 7439, 20502, 7441, 20500, 7443, 20498, 7445, 20496, 7447, 20494, 7449, 20492, 7451, 20490, 7453, 20488, 7455, 20486, 7457, 20484, 7459, 20482, 7461, 20480, 7463, 20478, 7465, 20476, 7467, 20474, 7469, 20472, 7471, 20470, 7473, 20468, 7475, 20466, 7477, 20464, 7479, 20462, 7481, 20460, 7483, 20458, 7485, 20456, 7487, 20454, 7489, 20452, 7491, 20450, 7493, 20448, 7495, 20446, 7497, 20444, 7499, 20442, 7501, 20440, 7503, 20438, 7505, 20436, 7507, 20434, 7509, 20432, 7511, 20430, 7513, 20428, 7515, 20426, 7517, 20424, 7519, 20422, 7521, 20420, 7523, 20418, 7525, 20416, 7527, 20414, 7529, 20412, 7531, 20410, 7533, 20408, 7535, 20406, 7537, 20404, 7539, 20402, 7541, 20400, 7543, 20398, 7545, 20396, 7547, 20394, 7549, 20392, 7551, 20390, 7553, 20388, 7555, 20386, 7557, 20384, 7559, 20382, 7561, 20380, 7563, 20378, 7565, 20376, 7567, 20374, 7569, 20372, 7571, 20370, 7573, 20368, 7575, 20366, 7577, 20364, 7579, 20362, 7581, 20360, 7583, 20358, 7585, 20356, 7587, 20354, 7589, 20352, 7591, 20350, 7593, 20348, 7595, 20346, 7597, 20344, 7599, 20342, 7601, 20340, 7603, 20338, 7605, 20336, 7607, 20334, 7609, 20332, 7611, 20330, 7613, 20328, 7615, 20326, 7617, 20324, 7619, 20322, 7621, 20320, 7623, 20318, 7625, 20316, 7627, 20314, 7629, 20312, 7631, 20310, 7633, 20308, 7635, 20306, 7637, 20304, 7639, 20302, 7641, 20300, 7643, 20298, 7645, 20296, 7647, 20294, 7649, 20292, 7651, 20290, 7653, 20288, 7655, 20286, 7657, 20284, 7659, 20282, 7661, 20280, 7663, 20278, 7665, 20276, 7667, 20274, 7669, 20272, 7671, 20270, 7673, 20268, 7675, 20266, 7677, 20264, 7679, 20262, 7681, 20260, 7683, 20258, 7685, 20256, 7687, 20254, 7689, 20252, 7691, 20250, 7693, 20248, 7695, 20246, 7697, 20244, 7699, 20242, 7701, 20240, 7703, 20238, 7705, 20236, 7707, 20234, 7709, 20232, 7711, 20230, 7713, 20228, 7715, 20226, 7717, 20224, 7719, 20222, 7721, 20220, 7723, 20218, 7725, 20216, 7727, 20214, 7729, 20212, 7731, 20210, 7733, 20208, 7735, 20206, 7737, 20204, 7739, 20202, 7741, 20200, 7743, 20198, 7745, 20196, 7747, 20194, 7749, 20192, 7751, 20190, 7753, 20188, 7755, 20186, 7757, 20184, 7759, 20182, 7761, 20180, 7763, 20178, 7765, 20176, 7767, 20174, 7769, 20172, 7771, 20170, 7773, 20168, 7775, 20166, 7777, 20164, 7779, 20162, 7781, 20160, 7783, 20158, 7785, 20156, 7787, 20154, 7789, 20152, 7791, 20150, 7793, 20148, 7795, 20146, 7797, 20144, 7799, 20142, 7801, 20140, 7803, 20138, 7805, 20136, 7807, 20134, 7809, 20132, 7811, 20130, 7813, 20128, 7815, 20126, 7817, 20124, 7819, 20122, 7821, 20120, 7823, 20118, 7825, 20116, 7827, 20114, 7829, 20112, 7831, 20110, 7833, 20108, 7835, 20106, 7837, 20104, 7839, 20102, 7841, 20100, 7843, 20098, 7845, 20096, 7847, 20094, 7849, 20092, 7851, 20090, 7853, 20088, 7855, 20086, 7857, 20084, 7859, 20082, 7861, 20080, 7863, 20078, 7865, 20076, 7867, 20074, 7869, 20072, 7871, 20070, 7873, 20068, 7875, 20066, 7877, 20064, 7879, 20062, 7881, 20060, 7883, 20058, 7885, 20056, 7887, 20054, 7889, 20052, 7891, 20050, 7893, 20048, 7895, 20046, 7897, 20044, 7899, 20042, 7901, 20040, 7903, 20038, 7905, 20036, 7907, 20034, 7909, 20032, 7911, 20030, 7913, 20028, 7915, 20026, 7917, 20024, 7919, 20022, 7921, 20020, 7923, 20018, 7925, 20016, 7927, 20014, 7929, 20012, 7931, 20010, 7933, 20008, 7935, 20006, 7937, 20004, 7939, 20002, 7941, 20000, 7943, 19998, 7945, 19996, 7947, 19994, 7949, 19992, 7951, 19990, 7953, 19988, 7955, 19986, 7957, 19984, 7959, 19982, 7961, 19980, 7963, 19978, 7965, 19976, 7967, 19974, 7969, 19972, 7971, 19970, 7973, 19968, 7975, 19966, 7977, 19964, 7979, 19962, 7981, 19960, 7983, 19958, 7985, 19956, 7987, 19954, 7989, 19952, 7991, 19950, 7993, 19948, 7995, 19946, 7997, 19944, 7999, 19942, 8001, 19940, 8003, 19938, 8005, 19936, 8007, 19934, 8009, 19932, 8011, 19930, 8013, 19928, 8015, 19926, 8017, 19924, 8019, 19922, 8021, 19920, 8023, 19918, 8025, 19916, 8027, 19914, 8029, 19912, 8031, 19910, 8033, 19908, 8035, 19906, 8037, 19904, 8039, 19902, 8041, 19900, 8043, 19898, 8045, 19896, 8047, 19894, 8049, 19892, 8051, 19890, 8053, 19888, 8055, 19886, 8057, 19884, 8059, 19882, 8061, 19880, 8063, 19878, 8065, 19876, 8067, 19874, 8069, 19872, 8071, 19870, 8073, 19868, 8075, 19866, 8077, 19864, 8079, 19862, 8081, 19860, 8083, 19858, 8085, 19856, 8087, 19854, 8089, 19852, 8091, 19850, 8093, 19848, 8095, 19846, 8097, 19844, 8099, 19842, 8101, 19840, 8103, 19838, 8105, 19836, 8107, 19834, 8109, 19832, 8111, 19830, 8113, 19828, 8115, 19826, 8117, 19824, 8119, 19822, 8121, 19820, 8123, 19818, 8125, 19816, 8127, 19814, 8129, 19812, 8131, 19810, 8133, 19808, 8135, 19806, 8137, 19804, 8139, 19802, 8141, 19800, 8143, 19798, 8145, 19796, 8147, 19794, 8149, 19792, 8151, 19790, 8153, 19788, 8155, 19786, 8157, 19784, 8159, 19782, 8161, 19780, 8163, 19778, 8165, 19776, 8167, 19774, 8169, 19772, 8171, 19770, 8173, 19768, 8175, 19766, 8177, 19764, 8179, 19762, 8181, 19760, 8183, 19758, 8185, 19756, 8187, 19754, 8189, 19752, 8191, 19750, 8193, 19748, 8195, 19746, 8197, 19744, 8199, 19742, 8201, 19740, 8203, 19738, 8205, 19736, 8207, 19734, 8209, 19732, 8211, 19730, 8213, 19728, 8215, 19726, 8217, 19724, 8219, 19722, 8221, 19720, 8223, 19718, 8225, 19716, 8227, 19714, 8229, 19712, 8231, 19710, 8233, 19708, 8235, 19706, 8237, 19704, 8239, 19702, 8241, 19700, 8243, 19698, 8245, 19696, 8247, 19694, 8249, 19692, 8251, 19690, 8253, 19688, 8255, 19686, 8257, 19684, 8259, 19682, 8261, 19680, 8263, 19678, 8265, 19676, 8267, 19674, 8269, 19672, 8271, 19670, 8273, 19668, 8275, 19666, 8277, 19664, 8279, 19662, 8281, 19660, 8283, 19658, 8285, 19656, 8287, 19654, 8289, 19652, 8291, 19650, 8293, 19648, 8295, 19646, 8297, 19644, 8299, 19642, 8301, 19640, 8303, 19638, 8305, 19636, 8307, 19634, 8309, 19632, 8311, 19630, 8313, 19628, 8315, 19626, 8317, 19624, 8319, 19622, 8321, 19620, 8323, 19618, 8325, 19616, 8327, 19614, 8329, 19612, 8331, 19610, 8333, 19608, 8335, 19606, 8337, 19604, 8339, 19602, 8341, 19600, 8343, 19598, 8345, 19596, 8347, 19594, 8349, 19592, 8351, 19590, 8353, 19588, 8355, 19586, 8357, 19584, 8359, 19582, 8361, 19580, 8363, 19578, 8365, 19576, 8367, 19574, 8369, 19572, 8371, 19570, 8373, 19568, 8375, 19566, 8377, 19564, 8379, 19562, 8381, 19560, 8383, 19558, 8385, 19556, 8387, 19554, 8389, 19552, 8391, 19550, 8393, 19548, 8395, 19546, 8397, 19544, 8399, 19542, 8401, 19540, 8403, 19538, 8405, 19536, 8407, 19534, 8409, 19532, 8411, 19530, 8413, 19528, 8415, 19526, 8417, 19524, 8419, 19522, 8421, 19520, 8423, 19518, 8425, 19516, 8427, 19514, 8429, 19512, 8431, 19510, 8433, 19508, 8435, 19506, 8437, 19504, 8439, 19502, 8441, 19500, 8443, 19498, 8445, 19496, 8447, 19494, 8449, 19492, 8451, 19490, 8453, 19488, 8455, 19486, 8457, 19484, 8459, 19482, 8461, 19480, 8463, 19478, 8465, 19476, 8467, 19474, 8469, 19472, 8471, 19470, 8473, 19468, 8475, 19466, 8477, 19464, 8479, 19462, 8481, 19460, 8483, 19458, 8485, 19456, 8487, 19454, 8489, 19452, 8491, 19450, 8493, 19448, 8495, 19446, 8497, 19444, 8499, 19442, 8501, 19440, 8503, 19438, 8505, 19436, 8507, 19434, 8509, 19432, 8511, 19430, 8513, 19428, 8515, 19426, 8517, 19424, 8519, 19422, 8521, 19420, 8523, 19418, 8525, 19416, 8527, 19414, 8529, 19412, 8531, 19410, 8533, 19408, 8535, 19406, 8537, 19404, 8539, 19402, 8541, 19400, 8543, 19398, 8545, 19396, 8547, 19394, 8549, 19392, 8551, 19390, 8553, 19388, 8555, 19386, 8557, 19384, 8559, 19382, 8561, 19380, 8563, 19378, 8565, 19376, 8567, 19374, 8569, 19372, 8571, 19370, 8573, 19368, 8575, 19366, 8577, 19364, 8579, 19362, 8581, 19360, 8583, 19358, 8585, 19356, 8587, 19354, 8589, 19352, 8591, 19350, 8593, 19348, 8595, 19346, 8597, 19344, 8599, 19342, 8601, 19340, 8603, 19338, 8605, 19336, 8607, 19334, 8609, 19332, 8611, 19330, 8613, 19328, 8615, 19326, 8617, 19324, 8619, 19322, 8621, 19320, 8623, 19318, 8625, 19316, 8627, 19314, 8629, 19312, 8631, 19310, 8633, 19308, 8635, 19306, 8637, 19304, 8639, 19302, 8641, 19300, 8643, 19298, 8645, 19296, 8647, 19294, 8649, 19292, 8651, 19290, 8653, 19288, 8655, 19286, 8657, 19284, 8659, 19282, 8661, 19280, 8663, 19278, 8665, 19276, 8667, 19274, 8669, 19272, 8671, 19270, 8673, 19268, 8675, 19266, 8677, 19264, 8679, 19262, 8681, 19260, 8683, 19258, 8685, 19256, 8687, 19254, 8689, 19252, 8691, 19250, 8693, 19248, 8695, 19246, 8697, 19244, 8699, 19242, 8701, 19240, 8703, 19238, 8705, 19236, 8707, 19234, 8709, 19232, 8711, 19230, 8713, 19228, 8715, 19226, 8717, 19224, 8719, 19222, 8721, 19220, 8723, 19218, 8725, 19216, 8727, 19214, 8729, 19212, 8731, 19210, 8733, 19208, 8735, 19206, 8737, 19204, 8739, 19202, 8741, 19200, 8743, 19198, 8745, 19196, 8747, 19194, 8749, 19192, 8751, 19190, 8753, 19188, 8755, 19186, 8757, 19184, 8759, 19182, 8761, 19180, 8763, 19178, 8765, 19176, 8767, 19174, 8769, 19172, 8771, 19170, 8773, 19168, 8775, 19166, 8777, 19164, 8779, 19162, 8781, 19160, 8783, 19158, 8785, 19156, 8787, 19154, 8789, 19152, 8791, 19150, 8793, 19148, 8795, 19146, 8797, 19144, 8799, 19142, 8801, 19140, 8803, 19138, 8805, 19136, 8807, 19134, 8809, 19132, 8811, 19130, 8813, 19128, 8815, 19126, 8817, 19124, 8819, 19122, 8821, 19120, 8823, 19118, 8825, 19116, 8827, 19114, 8829, 19112, 8831, 19110, 8833, 19108, 8835, 19106, 8837, 19104, 8839, 19102, 8841, 19100, 8843, 19098, 8845, 19096, 8847, 19094, 8849, 19092, 8851, 19090, 8853, 19088, 8855, 19086, 8857, 19084, 8859, 19082, 8861, 19080, 8863, 19078, 8865, 19076, 8867, 19074, 8869, 19072, 8871, 19070, 8873, 19068, 8875, 19066, 8877, 19064, 8879, 19062, 8881, 19060, 8883, 19058, 8885, 19056, 8887, 19054, 8889, 19052, 8891, 19050, 8893, 19048, 8895, 19046, 8897, 19044, 8899, 19042, 8901, 19040, 8903, 19038, 8905, 19036, 8907, 19034, 8909, 19032, 8911, 19030, 8913, 19028, 8915, 19026, 8917, 19024, 8919, 19022, 8921, 19020, 8923, 19018, 8925, 19016, 8927, 19014, 8929, 19012, 8931, 19010, 8933, 19008, 8935, 19006, 8937, 19004, 8939, 19002, 8941, 19000, 8943, 18998, 8945, 18996, 8947, 18994, 8949, 18992, 8951, 18990, 8953, 18988, 8955, 18986, 8957, 18984, 8959, 18982, 8961, 18980, 8963, 18978, 8965, 18976, 8967, 18974, 8969, 18972, 8971, 18970, 8973, 18968, 8975, 18966, 8977, 18964, 8979, 18962, 8981, 18960, 8983, 18958, 8985, 18956, 8987, 18954, 8989, 18952, 8991, 18950, 8993, 18948, 8995, 18946, 8997, 18944, 8999, 18942, 9001, 18940, 9003, 18938, 9005, 18936, 9007, 18934, 9009, 18932, 9011, 18930, 9013, 18928, 9015, 18926, 9017, 18924, 9019, 18922, 9021, 18920, 9023, 18918, 9025, 18916, 9027, 18914, 9029, 18912, 9031, 18910, 9033, 18908, 9035, 18906, 9037, 18904, 9039, 18902, 9041, 18900, 9043, 18898, 9045, 18896, 9047, 18894, 9049, 18892, 9051, 18890, 9053, 18888, 9055, 18886, 9057, 18884, 9059, 18882, 9061, 18880, 9063, 18878, 9065, 18876, 9067, 18874, 9069, 18872, 9071, 18870, 9073, 18868, 9075, 18866, 9077, 18864, 9079, 18862, 9081, 18860, 9083, 18858, 9085, 18856, 9087, 18854, 9089, 18852, 9091, 18850, 9093, 18848, 9095, 18846, 9097, 18844, 9099, 18842, 9101, 18840, 9103, 18838, 9105, 18836, 9107, 18834, 9109, 18832, 9111, 18830, 9113, 18828, 9115, 18826, 9117, 18824, 9119, 18822, 9121, 18820, 9123, 18818, 9125, 18816, 9127, 18814, 9129, 18812, 9131, 18810, 9133, 18808, 9135, 18806, 9137, 18804, 9139, 18802, 9141, 18800, 9143, 18798, 9145, 18796, 9147, 18794, 9149, 18792, 9151, 18790, 9153, 18788, 9155, 18786, 9157, 18784, 9159, 18782, 9161, 18780, 9163, 18778, 9165, 18776, 9167, 18774, 9169, 18772, 9171, 18770, 9173, 18768, 9175, 18766, 9177, 18764, 9179, 18762, 9181, 18760, 9183, 18758, 9185, 18756, 9187, 18754, 9189, 18752, 9191, 18750, 9193, 18748, 9195, 18746, 9197, 18744, 9199, 18742, 9201, 18740, 9203, 18738, 9205, 18736, 9207, 18734, 9209, 18732, 9211, 18730, 9213, 18728, 9215, 18726, 9217, 18724, 9219, 18722, 9221, 18720, 9223, 18718, 9225, 18716, 9227, 18714, 9229, 18712, 9231, 18710, 9233, 18708, 9235, 18706, 9237, 18704, 9239, 18702, 9241, 18700, 9243, 18698, 9245, 18696, 9247, 18694, 9249, 18692, 9251, 18690, 9253, 18688, 9255, 18686, 9257, 18684, 9259, 18682, 9261, 18680, 9263, 18678, 9265, 18676, 9267, 18674, 9269, 18672, 9271, 18670, 9273, 18668, 9275, 18666, 9277, 18664, 9279, 18662, 9281, 18660, 9283, 18658, 9285, 18656, 9287, 18654, 9289, 18652, 9291, 18650, 9293, 18648, 9295, 18646, 9297, 18644, 9299, 18642, 9301, 18640, 9303, 18638, 9305, 18636, 9307, 18634, 9309, 18632, 9311, 18630, 9313, 18628, 9315, 18626, 9317, 18624, 9319, 18622, 9321, 18620, 9323, 18618, 9325, 18616, 9327, 18614, 9329, 18612, 9331, 18610, 9333, 18608, 9335, 18606, 9337, 18604, 9339, 18602, 9341, 18600, 9343, 18598, 9345, 18596, 9347, 18594, 9349, 18592, 9351, 18590, 9353, 18588, 9355, 18586, 9357, 18584, 9359, 18582, 9361, 18580, 9363, 18578, 9365, 18576, 9367, 18574, 9369, 18572, 9371, 18570, 9373, 18568, 9375, 18566, 9377, 18564, 9379, 18562, 9381, 18560, 9383, 18558, 9385, 18556, 9387, 18554, 9389, 18552, 9391, 18550, 9393, 18548, 9395, 18546, 9397, 18544, 9399, 18542, 9401, 18540, 9403, 18538, 9405, 18536, 9407, 18534, 9409, 18532, 9411, 18530, 9413, 18528, 9415, 18526, 9417, 18524, 9419, 18522, 9421, 18520, 9423, 18518, 9425, 18516, 9427, 18514, 9429, 18512, 9431, 18510, 9433, 18508, 9435, 18506, 9437, 18504, 9439, 18502, 9441, 18500, 9443, 18498, 9445, 18496, 9447, 18494, 9449, 18492, 9451, 18490, 9453, 18488, 9455, 18486, 9457, 18484, 9459, 18482, 9461, 18480, 9463, 18478, 9465, 18476, 9467, 18474, 9469, 18472, 9471, 18470, 9473, 18468, 9475, 18466, 9477, 18464, 9479, 18462, 9481, 18460, 9483, 18458, 9485, 18456, 9487, 18454, 9489, 18452, 9491, 18450, 9493, 18448, 9495, 18446, 9497, 18444, 9499, 18442, 9501, 18440, 9503, 18438, 9505, 18436, 9507, 18434, 9509, 18432, 9511, 18430, 9513, 18428, 9515, 18426, 9517, 18424, 9519, 18422, 9521, 18420, 9523, 18418, 9525, 18416, 9527, 18414, 9529, 18412, 9531, 18410, 9533, 18408, 9535, 18406, 9537, 18404, 9539, 18402, 9541, 18400, 9543, 18398, 9545, 18396, 9547, 18394, 9549, 18392, 9551, 18390, 9553, 18388, 9555, 18386, 9557, 18384, 9559, 18382, 9561, 18380, 9563, 18378, 9565, 18376, 9567, 18374, 9569, 18372, 9571, 18370, 9573, 18368, 9575, 18366, 9577, 18364, 9579, 18362, 9581, 18360, 9583, 18358, 9585, 18356, 9587, 18354, 9589, 18352, 9591, 18350, 9593, 18348, 9595, 18346, 9597, 18344, 9599, 18342, 9601, 18340, 9603, 18338, 9605, 18336, 9607, 18334, 9609, 18332, 9611, 18330, 9613, 18328, 9615, 18326, 9617, 18324, 9619, 18322, 9621, 18320, 9623, 18318, 9625, 18316, 9627, 18314, 9629, 18312, 9631, 18310, 9633, 18308, 9635, 18306, 9637, 18304, 9639, 18302, 9641, 18300, 9643, 18298, 9645, 18296, 9647, 18294, 9649, 18292, 9651, 18290, 9653, 18288, 9655, 18286, 9657, 18284, 9659, 18282, 9661, 18280, 9663, 18278, 9665, 18276, 9667, 18274, 9669, 18272, 9671, 18270, 9673, 18268, 9675, 18266, 9677, 18264, 9679, 18262, 9681, 18260, 9683, 18258, 9685, 18256, 9687, 18254, 9689, 18252, 9691, 18250, 9693, 18248, 9695, 18246, 9697, 18244, 9699, 18242, 9701, 18240, 9703, 18238, 9705, 18236, 9707, 18234, 9709, 18232, 9711, 18230, 9713, 18228, 9715, 18226, 9717, 18224, 9719, 18222, 9721, 18220, 9723, 18218, 9725, 18216, 9727, 18214, 9729, 18212, 9731, 18210, 9733, 18208, 9735, 18206, 9737, 18204, 9739, 18202, 9741, 18200, 9743, 18198, 9745, 18196, 9747, 18194, 9749, 18192, 9751, 18190, 9753, 18188, 9755, 18186, 9757, 18184, 9759, 18182, 9761, 18180, 9763, 18178, 9765, 18176, 9767, 18174, 9769, 18172, 9771, 18170, 9773, 18168, 9775, 18166, 9777, 18164, 9779, 18162, 9781, 18160, 9783, 18158, 9785, 18156, 9787, 18154, 9789, 18152, 9791, 18150, 9793, 18148, 9795, 18146, 9797, 18144, 9799, 18142, 9801, 18140, 9803, 18138, 9805, 18136, 9807, 18134, 9809, 18132, 9811, 18130, 9813, 18128, 9815, 18126, 9817, 18124, 9819, 18122, 9821, 18120, 9823, 18118, 9825, 18116, 9827, 18114, 9829, 18112, 9831, 18110, 9833, 18108, 9835, 18106, 9837, 18104, 9839, 18102, 9841, 18100, 9843, 18098, 9845, 18096, 9847, 18094, 9849, 18092, 9851, 18090, 9853, 18088, 9855, 18086, 9857, 18084, 9859, 18082, 9861, 18080, 9863, 18078, 9865, 18076, 9867, 18074, 9869, 18072, 9871, 18070, 9873, 18068, 9875, 18066, 9877, 18064, 9879, 18062, 9881, 18060, 9883, 18058, 9885, 18056, 9887, 18054, 9889, 18052, 9891, 18050, 9893, 18048, 9895, 18046, 9897, 18044, 9899, 18042, 9901, 18040, 9903, 18038, 9905, 18036, 9907, 18034, 9909, 18032, 9911, 18030, 9913, 18028, 9915, 18026, 9917, 18024, 9919, 18022, 9921, 18020, 9923, 18018, 9925, 18016, 9927, 18014, 9929, 18012, 9931, 18010, 9933, 18008, 9935, 18006, 9937, 18004, 9939, 18002, 9941, 18000, 9943, 17998, 9945, 17996, 9947, 17994, 9949, 17992, 9951, 17990, 9953, 17988, 9955, 17986, 9957, 17984, 9959, 17982, 9961, 17980, 9963, 17978, 9965, 17976, 9967, 17974, 9969, 17972, 9971, 17970, 9973, 17968, 9975, 17966, 9977, 17964, 9979, 17962, 9981, 17960, 9983, 17958, 9985, 17956, 9987, 17954, 9989, 17952, 9991, 17950, 9993, 17948, 9995, 17946, 9997, 17944, 9999, 17942, 10001, 17940, 10003, 17938, 10005, 17936, 10007, 17934, 10009, 17932, 10011, 17930, 10013, 17928, 10015, 17926, 10017, 17924, 10019, 17922, 10021, 17920, 10023, 17918, 10025, 17916, 10027, 17914, 10029, 17912, 10031, 17910, 10033, 17908, 10035, 17906, 10037, 17904, 10039, 17902, 10041, 17900, 10043, 17898, 10045, 17896, 10047, 17894, 10049, 17892, 10051, 17890, 10053, 17888, 10055, 17886, 10057, 17884, 10059, 17882, 10061, 17880, 10063, 17878, 10065, 17876, 10067, 17874, 10069, 17872, 10071, 17870, 10073, 17868, 10075, 17866, 10077, 17864, 10079, 17862, 10081, 17860, 10083, 17858, 10085, 17856, 10087, 17854, 10089, 17852, 10091, 17850, 10093, 17848, 10095, 17846, 10097, 17844, 10099, 17842, 10101, 17840, 10103, 17838, 10105, 17836, 10107, 17834, 10109, 17832, 10111, 17830, 10113, 17828, 10115, 17826, 10117, 17824, 10119, 17822, 10121, 17820, 10123, 17818, 10125, 17816, 10127, 17814, 10129, 17812, 10131, 17810, 10133, 17808, 10135, 17806, 10137, 17804, 10139, 17802, 10141, 17800, 10143, 17798, 10145, 17796, 10147, 17794, 10149, 17792, 10151, 17790, 10153, 17788, 10155, 17786, 10157, 17784, 10159, 17782, 10161, 17780, 10163, 17778, 10165, 17776, 10167, 17774, 10169, 17772, 10171, 17770, 10173, 17768, 10175, 17766, 10177, 17764, 10179, 17762, 10181, 17760, 10183, 17758, 10185, 17756, 10187, 17754, 10189, 17752, 10191, 17750, 10193, 17748, 10195, 17746, 10197, 17744, 10199, 17742, 10201, 17740, 10203, 17738, 10205, 17736, 10207, 17734, 10209, 17732, 10211, 17730, 10213, 17728, 10215, 17726, 10217, 17724, 10219, 17722, 10221, 17720, 10223, 17718, 10225, 17716, 10227, 17714, 10229, 17712, 10231, 17710, 10233, 17708, 10235, 17706, 10237, 17704, 10239, 17702, 10241, 17700, 10243, 17698, 10245, 17696, 10247, 17694, 10249, 17692, 10251, 17690, 10253, 17688, 10255, 17686, 10257, 17684, 10259, 17682, 10261, 17680, 10263, 17678, 10265, 17676, 10267, 17674, 10269, 17672, 10271, 17670, 10273, 17668, 10275, 17666, 10277, 17664, 10279, 17662, 10281, 17660, 10283, 17658, 10285, 17656, 10287, 17654, 10289, 17652, 10291, 17650, 10293, 17648, 10295, 17646, 10297, 17644, 10299, 17642, 10301, 17640, 10303, 17638, 10305, 17636, 10307, 17634, 10309, 17632, 10311, 17630, 10313, 17628, 10315, 17626, 10317, 17624, 10319, 17622, 10321, 17620, 10323, 17618, 10325, 17616, 10327, 17614, 10329, 17612, 10331, 17610, 10333, 17608, 10335, 17606, 10337, 17604, 10339, 17602, 10341, 17600, 10343, 17598, 10345, 17596, 10347, 17594, 10349, 17592, 10351, 17590, 10353, 17588, 10355, 17586, 10357, 17584, 10359, 17582, 10361, 17580, 10363, 17578, 10365, 17576, 10367, 17574, 10369, 17572, 10371, 17570, 10373, 17568, 10375, 17566, 10377, 17564, 10379, 17562, 10381, 17560, 10383, 17558, 10385, 17556, 10387, 17554, 10389, 17552, 10391, 17550, 10393, 17548, 10395, 17546, 10397, 17544, 10399, 17542, 10401, 17540, 10403, 17538, 10405, 17536, 10407, 17534, 10409, 17532, 10411, 17530, 10413, 17528, 10415, 17526, 10417, 17524, 10419, 17522, 10421, 17520, 10423, 17518, 10425, 17516, 10427, 17514, 10429, 17512, 10431, 17510, 10433, 17508, 10435, 17506, 10437, 17504, 10439, 17502, 10441, 17500, 10443, 17498, 10445, 17496, 10447, 17494, 10449, 17492, 10451, 17490, 10453, 17488, 10455, 17486, 10457, 17484, 10459, 17482, 10461, 17480, 10463, 17478, 10465, 17476, 10467, 17474, 10469, 17472, 10471, 17470, 10473, 17468, 10475, 17466, 10477, 17464, 10479, 17462, 10481, 17460, 10483, 17458, 10485, 17456, 10487, 17454, 10489, 17452, 10491, 17450, 10493, 17448, 10495, 17446, 10497, 17444, 10499, 17442, 10501, 17440, 10503, 17438, 10505, 17436, 10507, 17434, 10509, 17432, 10511, 17430, 10513, 17428, 10515, 17426, 10517, 17424, 10519, 17422, 10521, 17420, 10523, 17418, 10525, 17416, 10527, 17414, 10529, 17412, 10531, 17410, 10533, 17408, 10535, 17406, 10537, 17404, 10539, 17402, 10541, 17400, 10543, 17398, 10545, 17396, 10547, 17394, 10549, 17392, 10551, 17390, 10553, 17388, 10555, 17386, 10557, 17384, 10559, 17382, 10561, 17380, 10563, 17378, 10565, 17376, 10567, 17374, 10569, 17372, 10571, 17370, 10573, 17368, 10575, 17366, 10577, 17364, 10579, 17362, 10581, 17360, 10583, 17358, 10585, 17356, 10587, 17354, 10589, 17352, 10591, 17350, 10593, 17348, 10595, 17346, 10597, 17344, 10599, 17342, 10601, 17340, 10603, 17338, 10605, 17336, 10607, 17334, 10609, 17332, 10611, 17330, 10613, 17328, 10615, 17326, 10617, 17324, 10619, 17322, 10621, 17320, 10623, 17318, 10625, 17316, 10627, 17314, 10629, 17312, 10631, 17310, 10633, 17308, 10635, 17306, 10637, 17304, 10639, 17302, 10641, 17300, 10643, 17298, 10645, 17296, 10647, 17294, 10649, 17292, 10651, 17290, 10653, 17288, 10655, 17286, 10657, 17284, 10659, 17282, 10661, 17280, 10663, 17278, 10665, 17276, 10667, 17274, 10669, 17272, 10671, 17270, 10673, 17268, 10675, 17266, 10677, 17264, 10679, 17262, 10681, 17260, 10683, 17258, 10685, 17256, 10687, 17254, 10689, 17252, 10691, 17250, 10693, 17248, 10695, 17246, 10697, 17244, 10699, 17242, 10701, 17240, 10703, 17238, 10705, 17236, 10707, 17234, 10709, 17232, 10711, 17230, 10713, 17228, 10715, 17226, 10717, 17224, 10719, 17222, 10721, 17220, 10723, 17218, 10725, 17216, 10727, 17214, 10729, 17212, 10731, 17210, 10733, 17208, 10735, 17206, 10737, 17204, 10739, 17202, 10741, 17200, 10743, 17198, 10745, 17196, 10747, 17194, 10749, 17192, 10751, 17190, 10753, 17188, 10755, 17186, 10757, 17184, 10759, 17182, 10761, 17180, 10763, 17178, 10765, 17176, 10767, 17174, 10769, 17172, 10771, 17170, 10773, 17168, 10775, 17166, 10777, 17164, 10779, 17162, 10781, 17160, 10783, 17158, 10785, 17156, 10787, 17154, 10789, 17152, 10791, 17150, 10793, 17148, 10795, 17146, 10797, 17144, 10799, 17142, 10801, 17140, 10803, 17138, 10805, 17136, 10807, 17134, 10809, 17132, 10811, 17130, 10813, 17128, 10815, 17126, 10817, 17124, 10819, 17122, 10821, 17120, 10823, 17118, 10825, 17116, 10827, 17114, 10829, 17112, 10831, 17110, 10833, 17108, 10835, 17106, 10837, 17104, 10839, 17102, 10841, 17100, 10843, 17098, 10845, 17096, 10847, 17094, 10849, 17092, 10851, 17090, 10853, 17088, 10855, 17086, 10857, 17084, 10859, 17082, 10861, 17080, 10863, 17078, 10865, 17076, 10867, 17074, 10869, 17072, 10871, 17070, 10873, 17068, 10875, 17066, 10877, 17064, 10879, 17062, 10881, 17060, 10883, 17058, 10885, 17056, 10887, 17054, 10889, 17052, 10891, 17050, 10893, 17048, 10895, 17046, 10897, 17044, 10899, 17042, 10901, 17040, 10903, 17038, 10905, 17036, 10907, 17034, 10909, 17032, 10911, 17030, 10913, 17028, 10915, 17026, 10917, 17024, 10919, 17022, 10921, 17020, 10923, 17018, 10925, 17016, 10927, 17014, 10929, 17012, 10931, 17010, 10933, 17008, 10935, 17006, 10937, 17004, 10939, 17002, 10941, 17000, 10943, 16998, 10945, 16996, 10947, 16994, 10949, 16992, 10951, 16990, 10953, 16988, 10955, 16986, 10957, 16984, 10959, 16982, 10961, 16980, 10963, 16978, 10965, 16976, 10967, 16974, 10969, 16972, 10971, 16970, 10973, 16968, 10975, 16966, 10977, 16964, 10979, 16962, 10981, 16960, 10983, 16958, 10985, 16956, 10987, 16954, 10989, 16952, 10991, 16950, 10993, 16948, 10995, 16946, 10997, 16944, 10999, 16942, 11001, 16940, 11003, 16938, 11005, 16936, 11007, 16934, 11009, 16932, 11011, 16930, 11013, 16928, 11015, 16926, 11017, 16924, 11019, 16922, 11021, 16920, 11023, 16918, 11025, 16916, 11027, 16914, 11029, 16912, 11031, 16910, 11033, 16908, 11035, 16906, 11037, 16904, 11039, 16902, 11041, 16900, 11043, 16898, 11045, 16896, 11047, 16894, 11049, 16892, 11051, 16890, 11053, 16888, 11055, 16886, 11057, 16884, 11059, 16882, 11061, 16880, 11063, 16878, 11065, 16876, 11067, 16874, 11069, 16872, 11071, 16870, 11073, 16868, 11075, 16866, 11077, 16864, 11079, 16862, 11081, 16860, 11083, 16858, 11085, 16856, 11087, 16854, 11089, 16852, 11091, 16850, 11093, 16848, 11095, 16846, 11097, 16844, 11099, 16842, 11101, 16840, 11103, 16838, 11105, 16836, 11107, 16834, 11109, 16832, 11111, 16830, 11113, 16828, 11115, 16826, 11117, 16824, 11119, 16822, 11121, 16820, 11123, 16818, 11125, 16816, 11127, 16814, 11129, 16812, 11131, 16810, 11133, 16808, 11135, 16806, 11137, 16804, 11139, 16802, 11141, 16800, 11143, 16798, 11145, 16796, 11147, 16794, 11149, 16792, 11151, 16790, 11153, 16788, 11155, 16786, 11157, 16784, 11159, 16782, 11161, 16780, 11163, 16778, 11165, 16776, 11167, 16774, 11169, 16772, 11171, 16770, 11173, 16768, 11175, 16766, 11177, 16764, 11179, 16762, 11181, 16760, 11183, 16758, 11185, 16756, 11187, 16754, 11189, 16752, 11191, 16750, 11193, 16748, 11195, 16746, 11197, 16744, 11199, 16742, 11201, 16740, 11203, 16738, 11205, 16736, 11207, 16734, 11209, 16732, 11211, 16730, 11213, 16728, 11215, 16726, 11217, 16724, 11219, 16722, 11221, 16720, 11223, 16718, 11225, 16716, 11227, 16714, 11229, 16712, 11231, 16710, 11233, 16708, 11235, 16706, 11237, 16704, 11239, 16702, 11241, 16700, 11243, 16698, 11245, 16696, 11247, 16694, 11249, 16692, 11251, 16690, 11253, 16688, 11255, 16686, 11257, 16684, 11259, 16682, 11261, 16680, 11263, 16678, 11265, 16676, 11267, 16674, 11269, 16672, 11271, 16670, 11273, 16668, 11275, 16666, 11277, 16664, 11279, 16662, 11281, 16660, 11283, 16658, 11285, 16656, 11287, 16654, 11289, 16652, 11291, 16650, 11293, 16648, 11295, 16646, 11297, 16644, 11299, 16642, 11301, 16640, 11303, 16638, 11305, 16636, 11307, 16634, 11309, 16632, 11311, 16630, 11313, 16628, 11315, 16626, 11317, 16624, 11319, 16622, 11321, 16620, 11323, 16618, 11325, 16616, 11327, 16614, 11329, 16612, 11331, 16610, 11333, 16608, 11335, 16606, 11337, 16604, 11339, 16602, 11341, 16600, 11343, 16598, 11345, 16596, 11347, 16594, 11349, 16592, 11351, 16590, 11353, 16588, 11355, 16586, 11357, 16584, 11359, 16582, 11361, 16580, 11363, 16578, 11365, 16576, 11367, 16574, 11369, 16572, 11371, 16570, 11373, 16568, 11375, 16566, 11377, 16564, 11379, 16562, 11381, 16560, 11383, 16558, 11385, 16556, 11387, 16554, 11389, 16552, 11391, 16550, 11393, 16548, 11395, 16546, 11397, 16544, 11399, 16542, 11401, 16540, 11403, 16538, 11405, 16536, 11407, 16534, 11409, 16532, 11411, 16530, 11413, 16528, 11415, 16526, 11417, 16524, 11419, 16522, 11421, 16520, 11423, 16518, 11425, 16516, 11427, 16514, 11429, 16512, 11431, 16510, 11433, 16508, 11435, 16506, 11437, 16504, 11439, 16502, 11441, 16500, 11443, 16498, 11445, 16496, 11447, 16494, 11449, 16492, 11451, 16490, 11453, 16488, 11455, 16486, 11457, 16484, 11459, 16482, 11461, 16480, 11463, 16478, 11465, 16476, 11467, 16474, 11469, 16472, 11471, 16470, 11473, 16468, 11475, 16466, 11477, 16464, 11479, 16462, 11481, 16460, 11483, 16458, 11485, 16456, 11487, 16454, 11489, 16452, 11491, 16450, 11493, 16448, 11495, 16446, 11497, 16444, 11499, 16442, 11501, 16440, 11503, 16438, 11505, 16436, 11507, 16434, 11509, 16432, 11511, 16430, 11513, 16428, 11515, 16426, 11517, 16424, 11519, 16422, 11521, 16420, 11523, 16418, 11525, 16416, 11527, 16414, 11529, 16412, 11531, 16410, 11533, 16408, 11535, 16406, 11537, 16404, 11539, 16402, 11541, 16400, 11543, 16398, 11545, 16396, 11547, 16394, 11549, 16392, 11551, 16390, 11553, 16388, 11555, 16386, 11557, 16384, 11559, 16382, 11561, 16380, 11563, 16378, 11565, 16376, 11567, 16374, 11569, 16372, 11571, 16370, 11573, 16368, 11575, 16366, 11577, 16364, 11579, 16362, 11581, 16360, 11583, 16358, 11585, 16356, 11587, 16354, 11589, 16352, 11591, 16350, 11593, 16348, 11595, 16346, 11597, 16344, 11599, 16342, 11601, 16340, 11603, 16338, 11605, 16336, 11607, 16334, 11609, 16332, 11611, 16330, 11613, 16328, 11615, 16326, 11617, 16324, 11619, 16322, 11621, 16320, 11623, 16318, 11625, 16316, 11627, 16314, 11629, 16312, 11631, 16310, 11633, 16308, 11635, 16306, 11637, 16304, 11639, 16302, 11641, 16300, 11643, 16298, 11645, 16296, 11647, 16294, 11649, 16292, 11651, 16290, 11653, 16288, 11655, 16286, 11657, 16284, 11659, 16282, 11661, 16280, 11663, 16278, 11665, 16276, 11667, 16274, 11669, 16272, 11671, 16270, 11673, 16268, 11675, 16266, 11677, 16264, 11679, 16262, 11681, 16260, 11683, 16258, 11685, 16256, 11687, 16254, 11689, 16252, 11691, 16250, 11693, 16248, 11695, 16246, 11697, 16244, 11699, 16242, 11701, 16240, 11703, 16238, 11705, 16236, 11707, 16234, 11709, 16232, 11711, 16230, 11713, 16228, 11715, 16226, 11717, 16224, 11719, 16222, 11721, 16220, 11723, 16218, 11725, 16216, 11727, 16214, 11729, 16212, 11731, 16210, 11733, 16208, 11735, 16206, 11737, 16204, 11739, 16202, 11741, 16200, 11743, 16198, 11745, 16196, 11747, 16194, 11749, 16192, 11751, 16190, 11753, 16188, 11755, 16186, 11757, 16184, 11759, 16182, 11761, 16180, 11763, 16178, 11765, 16176, 11767, 16174, 11769, 16172, 11771, 16170, 11773, 16168, 11775, 16166, 11777, 16164, 11779, 16162, 11781, 16160, 11783, 16158, 11785, 16156, 11787, 16154, 11789, 16152, 11791, 16150, 11793, 16148, 11795, 16146, 11797, 16144, 11799, 16142, 11801, 16140, 11803, 16138, 11805, 16136, 11807, 16134, 11809, 16132, 11811, 16130, 11813, 16128, 11815, 16126, 11817, 16124, 11819, 16122, 11821, 16120, 11823, 16118, 11825, 16116, 11827, 16114, 11829, 16112, 11831, 16110, 11833, 16108, 11835, 16106, 11837, 16104, 11839, 16102, 11841, 16100, 11843, 16098, 11845, 16096, 11847, 16094, 11849, 16092, 11851, 16090, 11853, 16088, 11855, 16086, 11857, 16084, 11859, 16082, 11861, 16080, 11863, 16078, 11865, 16076, 11867, 16074, 11869, 16072, 11871, 16070, 11873, 16068, 11875, 16066, 11877, 16064, 11879, 16062, 11881, 16060, 11883, 16058, 11885, 16056, 11887, 16054, 11889, 16052, 11891, 16050, 11893, 16048, 11895, 16046, 11897, 16044, 11899, 16042, 11901, 16040, 11903, 16038, 11905, 16036, 11907, 16034, 11909, 16032, 11911, 16030, 11913, 16028, 11915, 16026, 11917, 16024, 11919, 16022, 11921, 16020, 11923, 16018, 11925, 16016, 11927, 16014, 11929, 16012, 11931, 16010, 11933, 16008, 11935, 16006, 11937, 16004, 11939, 16002, 11941, 16000, 11943, 15998, 11945, 15996, 11947, 15994, 11949, 15992, 11951, 15990, 11953, 15988, 11955, 15986, 11957, 15984, 11959, 15982, 11961, 15980, 11963, 15978, 11965, 15976, 11967, 15974, 11969, 15972, 11971, 15970, 11973, 15968, 11975, 15966, 11977, 15964, 11979, 15962, 11981, 15960, 11983, 15958, 11985, 15956, 11987, 15954, 11989, 15952, 11991, 15950, 11993, 15948, 11995, 15946, 11997, 15944, 11999, 15942, 12001, 15940, 12003, 15938, 12005, 15936, 12007, 15934, 12009, 15932, 12011, 15930, 12013, 15928, 12015, 15926, 12017, 15924, 12019, 15922, 12021, 15920, 12023, 15918, 12025, 15916, 12027, 15914, 12029, 15912, 12031, 15910, 12033, 15908, 12035, 15906, 12037, 15904, 12039, 15902, 12041, 15900, 12043, 15898, 12045, 15896, 12047, 15894, 12049, 15892, 12051, 15890, 12053, 15888, 12055, 15886, 12057, 15884, 12059, 15882, 12061, 15880, 12063, 15878, 12065, 15876, 12067, 15874, 12069, 15872, 12071, 15870, 12073, 15868, 12075, 15866, 12077, 15864, 12079, 15862, 12081, 15860, 12083, 15858, 12085, 15856, 12087, 15854, 12089, 15852, 12091, 15850, 12093, 15848, 12095, 15846, 12097, 15844, 12099, 15842, 12101, 15840, 12103, 15838, 12105, 15836, 12107, 15834, 12109, 15832, 12111, 15830, 12113, 15828, 12115, 15826, 12117, 15824, 12119, 15822, 12121, 15820, 12123, 15818, 12125, 15816, 12127, 15814, 12129, 15812, 12131, 15810, 12133, 15808, 12135, 15806, 12137, 15804, 12139, 15802, 12141, 15800, 12143, 15798, 12145, 15796, 12147, 15794, 12149, 15792, 12151, 15790, 12153, 15788, 12155, 15786, 12157, 15784, 12159, 15782, 12161, 15780, 12163, 15778, 12165, 15776, 12167, 15774, 12169, 15772, 12171, 15770, 12173, 15768, 12175, 15766, 12177, 15764, 12179, 15762, 12181, 15760, 12183, 15758, 12185, 15756, 12187, 15754, 12189, 15752, 12191, 15750, 12193, 15748, 12195, 15746, 12197, 15744, 12199, 15742, 12201, 15740, 12203, 15738, 12205, 15736, 12207, 15734, 12209, 15732, 12211, 15730, 12213, 15728, 12215, 15726, 12217, 15724, 12219, 15722, 12221, 15720, 12223, 15718, 12225, 15716, 12227, 15714, 12229, 15712, 12231, 15710, 12233, 15708, 12235, 15706, 12237, 15704, 12239, 15702, 12241, 15700, 12243, 15698, 12245, 15696, 12247, 15694, 12249, 15692, 12251, 15690, 12253, 15688, 12255, 15686, 12257, 15684, 12259, 15682, 12261, 15680, 12263, 15678, 12265, 15676, 12267, 15674, 12269, 15672, 12271, 15670, 12273, 15668, 12275, 15666, 12277, 15664, 12279, 15662, 12281, 15660, 12283, 15658, 12285, 15656, 12287, 15654, 12289, 15652, 12291, 15650, 12293, 15648, 12295, 15646, 12297, 15644, 12299, 15642, 12301, 15640, 12303, 15638, 12305, 15636, 12307, 15634, 12309, 15632, 12311, 15630, 12313, 15628, 12315, 15626, 12317, 15624, 12319, 15622, 12321, 15620, 12323, 15618, 12325, 15616, 12327, 15614, 12329, 15612, 12331, 15610, 12333, 15608, 12335, 15606, 12337, 15604, 12339, 15602, 12341, 15600, 12343, 15598, 12345, 15596, 12347, 15594, 12349, 15592, 12351, 15590, 12353, 15588, 12355, 15586, 12357, 15584, 12359, 15582, 12361, 15580, 12363, 15578, 12365, 15576, 12367, 15574, 12369, 15572, 12371, 15570, 12373, 15568, 12375, 15566, 12377, 15564, 12379, 15562, 12381, 15560, 12383, 15558, 12385, 15556, 12387, 15554, 12389, 15552, 12391, 15550, 12393, 15548, 12395, 15546, 12397, 15544, 12399, 15542, 12401, 15540, 12403, 15538, 12405, 15536, 12407, 15534, 12409, 15532, 12411, 15530, 12413, 15528, 12415, 15526, 12417, 15524, 12419, 15522, 12421, 15520, 12423, 15518, 12425, 15516, 12427, 15514, 12429, 15512, 12431, 15510, 12433, 15508, 12435, 15506, 12437, 15504, 12439, 15502, 12441, 15500, 12443, 15498, 12445, 15496, 12447, 15494, 12449, 15492, 12451, 15490, 12453, 15488, 12455, 15486, 12457, 15484, 12459, 15482, 12461, 15480, 12463, 15478, 12465, 15476, 12467, 15474, 12469, 15472, 12471, 15470, 12473, 15468, 12475, 15466, 12477, 15464, 12479, 15462, 12481, 15460, 12483, 15458, 12485, 15456, 12487, 15454, 12489, 15452, 12491, 15450, 12493, 15448, 12495, 15446, 12497, 15444, 12499, 15442, 12501, 15440, 12503, 15438, 12505, 15436, 12507, 15434, 12509, 15432, 12511, 15430, 12513, 15428, 12515, 15426, 12517, 15424, 12519, 15422, 12521, 15420, 12523, 15418, 12525, 15416, 12527, 15414, 12529, 15412, 12531, 15410, 12533, 15408, 12535, 15406, 12537, 15404, 12539, 15402, 12541, 15400, 12543, 15398, 12545, 15396, 12547, 15394, 12549, 15392, 12551, 15390, 12553, 15388, 12555, 15386, 12557, 15384, 12559, 15382, 12561, 15380, 12563, 15378, 12565, 15376, 12567, 15374, 12569, 15372, 12571, 15370, 12573, 15368, 12575, 15366, 12577, 15364, 12579, 15362, 12581, 15360, 12583, 15358, 12585, 15356, 12587, 15354, 12589, 15352, 12591, 15350, 12593, 15348, 12595, 15346, 12597, 15344, 12599, 15342, 12601, 15340, 12603, 15338, 12605, 15336, 12607, 15334, 12609, 15332, 12611, 15330, 12613, 15328, 12615, 15326, 12617, 15324, 12619, 15322, 12621, 15320, 12623, 15318, 12625, 15316, 12627, 15314, 12629, 15312, 12631, 15310, 12633, 15308, 12635, 15306, 12637, 15304, 12639, 15302, 12641, 15300, 12643, 15298, 12645, 15296, 12647, 15294, 12649, 15292, 12651, 15290, 12653, 15288, 12655, 15286, 12657, 15284, 12659, 15282, 12661, 15280, 12663, 15278, 12665, 15276, 12667, 15274, 12669, 15272, 12671, 15270, 12673, 15268, 12675, 15266, 12677, 15264, 12679, 15262, 12681, 15260, 12683, 15258, 12685, 15256, 12687, 15254, 12689, 15252, 12691, 15250, 12693, 15248, 12695, 15246, 12697, 15244, 12699, 15242, 12701, 15240, 12703, 15238, 12705, 15236, 12707, 15234, 12709, 15232, 12711, 15230, 12713, 15228, 12715, 15226, 12717, 15224, 12719, 15222, 12721, 15220, 12723, 15218, 12725, 15216, 12727, 15214, 12729, 15212, 12731, 15210, 12733, 15208, 12735, 15206, 12737, 15204, 12739, 15202, 12741, 15200, 12743, 15198, 12745, 15196, 12747, 15194, 12749, 15192, 12751, 15190, 12753, 15188, 12755, 15186, 12757, 15184, 12759, 15182, 12761, 15180, 12763, 15178, 12765, 15176, 12767, 15174, 12769, 15172, 12771, 15170, 12773, 15168, 12775, 15166, 12777, 15164, 12779, 15162, 12781, 15160, 12783, 15158, 12785, 15156, 12787, 15154, 12789, 15152, 12791, 15150, 12793, 15148, 12795, 15146, 12797, 15144, 12799, 15142, 12801, 15140, 12803, 15138, 12805, 15136, 12807, 15134, 12809, 15132, 12811, 15130, 12813, 15128, 12815, 15126, 12817, 15124, 12819, 15122, 12821, 15120, 12823, 15118, 12825, 15116, 12827, 15114, 12829, 15112, 12831, 15110, 12833, 15108, 12835, 15106, 12837, 15104, 12839, 15102, 12841, 15100, 12843, 15098, 12845, 15096, 12847, 15094, 12849, 15092, 12851, 15090, 12853, 15088, 12855, 15086, 12857, 15084, 12859, 15082, 12861, 15080, 12863, 15078, 12865, 15076, 12867, 15074, 12869, 15072, 12871, 15070, 12873, 15068, 12875, 15066, 12877, 15064, 12879, 15062, 12881, 15060, 12883, 15058, 12885, 15056, 12887, 15054, 12889, 15052, 12891, 15050, 12893, 15048, 12895, 15046, 12897, 15044, 12899, 15042, 12901, 15040, 12903, 15038, 12905, 15036, 12907, 15034, 12909, 15032, 12911, 15030, 12913, 15028, 12915, 15026, 12917, 15024, 12919, 15022, 12921, 15020, 12923, 15018, 12925, 15016, 12927, 15014, 12929, 15012, 12931, 15010, 12933, 15008, 12935, 15006, 12937, 15004, 12939, 15002, 12941, 15000, 12943, 14998, 12945, 14996, 12947, 14994, 12949, 14992, 12951, 14990, 12953, 14988, 12955, 14986, 12957, 14984, 12959, 14982, 12961, 14980, 12963, 14978, 12965, 14976, 12967, 14974, 12969, 14972, 12971, 14970, 12973, 14968, 12975, 14966, 12977, 14964, 12979, 14962, 12981, 14960, 12983, 14958, 12985, 14956, 12987, 14954, 12989, 14952, 12991, 14950, 12993, 14948, 12995, 14946, 12997, 14944, 12999, 14942, 13001, 14940, 13003, 14938, 13005, 14936, 13007, 14934, 13009, 14932, 13011, 14930, 13013, 14928, 13015, 14926, 13017, 14924, 13019, 14922, 13021, 14920, 13023, 14918, 13025, 14916, 13027, 14914, 13029, 14912, 13031, 14910, 13033, 14908, 13035, 14906, 13037, 14904, 13039, 14902, 13041, 14900, 13043, 14898, 13045, 14896, 13047, 14894, 13049, 14892, 13051, 14890, 13053, 14888, 13055, 14886, 13057, 14884, 13059, 14882, 13061, 14880, 13063, 14878, 13065, 14876, 13067, 14874, 13069, 14872, 13071, 14870, 13073, 14868, 13075, 14866, 13077, 14864, 13079, 14862, 13081, 14860, 13083, 14858, 13085, 14856, 13087, 14854, 13089, 14852, 13091, 14850, 13093, 14848, 13095, 14846, 13097, 14844, 13099, 14842, 13101, 14840, 13103, 14838, 13105, 14836, 13107, 14834, 13109, 14832, 13111, 14830, 13113, 14828, 13115, 14826, 13117, 14824, 13119, 14822, 13121, 14820, 13123, 14818, 13125, 14816, 13127, 14814, 13129, 14812, 13131, 14810, 13133, 14808, 13135, 14806, 13137, 14804, 13139, 14802, 13141, 14800, 13143, 14798, 13145, 14796, 13147, 14794, 13149, 14792, 13151, 14790, 13153, 14788, 13155, 14786, 13157, 14784, 13159, 14782, 13161, 14780, 13163, 14778, 13165, 14776, 13167, 14774, 13169, 14772, 13171, 14770, 13173, 14768, 13175, 14766, 13177, 14764, 13179, 14762, 13181, 14760, 13183, 14758, 13185, 14756, 13187, 14754, 13189, 14752, 13191, 14750, 13193, 14748, 13195, 14746, 13197, 14744, 13199, 14742, 13201, 14740, 13203, 14738, 13205, 14736, 13207, 14734, 13209, 14732, 13211, 14730, 13213, 14728, 13215, 14726, 13217, 14724, 13219, 14722, 13221, 14720, 13223, 14718, 13225, 14716, 13227, 14714, 13229, 14712, 13231, 14710, 13233, 14708, 13235, 14706, 13237, 14704, 13239, 14702, 13241, 14700, 13243, 14698, 13245, 14696, 13247, 14694, 13249, 14692, 13251, 14690, 13253, 14688, 13255, 14686, 13257, 14684, 13259, 14682, 13261, 14680, 13263, 14678, 13265, 14676, 13267, 14674, 13269, 14672, 13271, 14670, 13273, 14668, 13275, 14666, 13277, 14664, 13279, 14662, 13281, 14660, 13283, 14658, 13285, 14656, 13287, 14654, 13289, 14652, 13291, 14650, 13293, 14648, 13295, 14646, 13297, 14644, 13299, 14642, 13301, 14640, 13303, 14638, 13305, 14636, 13307, 14634, 13309, 14632, 13311, 14630, 13313, 14628, 13315, 14626, 13317, 14624, 13319, 14622, 13321, 14620, 13323, 14618, 13325, 14616, 13327, 14614, 13329, 14612, 13331, 14610, 13333, 14608, 13335, 14606, 13337, 14604, 13339, 14602, 13341, 14600, 13343, 14598, 13345, 14596, 13347, 14594, 13349, 14592, 13351, 14590, 13353, 14588, 13355, 14586, 13357, 14584, 13359, 14582, 13361, 14580, 13363, 14578, 13365, 14576, 13367, 14574, 13369, 14572, 13371, 14570, 13373, 14568, 13375, 14566, 13377, 14564, 13379, 14562, 13381, 14560, 13383, 14558, 13385, 14556, 13387, 14554, 13389, 14552, 13391, 14550, 13393, 14548, 13395, 14546, 13397, 14544, 13399, 14542, 13401, 14540, 13403, 14538, 13405, 14536, 13407, 14534, 13409, 14532, 13411, 14530, 13413, 14528, 13415, 14526, 13417, 14524, 13419, 14522, 13421, 14520, 13423, 14518, 13425, 14516, 13427, 14514, 13429, 14512, 13431, 14510, 13433, 14508, 13435, 14506, 13437, 14504, 13439, 14502, 13441, 14500, 13443, 14498, 13445, 14496, 13447, 14494, 13449, 14492, 13451, 14490, 13453, 14488, 13455, 14486, 13457, 14484, 13459, 14482, 13461, 14480, 13463, 14478, 13465, 14476, 13467, 14474, 13469, 14472, 13471, 14470, 13473, 14468, 13475, 14466, 13477, 14464, 13479, 14462, 13481, 14460, 13483, 14458, 13485, 14456, 13487, 14454, 13489, 14452, 13491, 14450, 13493, 14448, 13495, 14446, 13497, 14444, 13499, 14442, 13501, 14440, 13503, 14438, 13505, 14436, 13507, 14434, 13509, 14432, 13511, 14430, 13513, 14428, 13515, 14426, 13517, 14424, 13519, 14422, 13521, 14420, 13523, 14418, 13525, 14416, 13527, 14414, 13529, 14412, 13531, 14410, 13533, 14408, 13535, 14406, 13537, 14404, 13539, 14402, 13541, 14400, 13543, 14398, 13545, 14396, 13547, 14394, 13549, 14392, 13551, 14390, 13553, 14388, 13555, 14386, 13557, 14384, 13559, 14382, 13561, 14380, 13563, 14378, 13565, 14376, 13567, 14374, 13569, 14372, 13571, 14370, 13573, 14368, 13575, 14366, 13577, 14364, 13579, 14362, 13581, 14360, 13583, 14358, 13585, 14356, 13587, 14354, 13589, 14352, 13591, 14350, 13593, 14348, 13595, 14346, 13597, 14344, 13599, 14342, 13601, 14340, 13603, 14338, 13605, 14336, 13607, 14334, 13609, 14332, 13611, 14330, 13613, 14328, 13615, 14326, 13617, 14324, 13619, 14322, 13621, 14320, 13623, 14318, 13625, 14316, 13627, 14314, 13629, 14312, 13631, 14310, 13633, 14308, 13635, 14306, 13637, 14304, 13639, 14302, 13641, 14300, 13643, 14298, 13645, 14296, 13647, 14294, 13649, 14292, 13651, 14290, 13653, 14288, 13655, 14286, 13657, 14284, 13659, 14282, 13661, 14280, 13663, 14278, 13665, 14276, 13667, 14274, 13669, 14272, 13671, 14270, 13673, 14268, 13675, 14266, 13677, 14264, 13679, 14262, 13681, 14260, 13683, 14258, 13685, 14256, 13687, 14254, 13689, 14252, 13691, 14250, 13693, 14248, 13695, 14246, 13697, 14244, 13699, 14242, 13701, 14240, 13703, 14238, 13705, 14236, 13707, 14234, 13709, 14232, 13711, 14230, 13713, 14228, 13715, 14226, 13717, 14224, 13719, 14222, 13721, 14220, 13723, 14218, 13725, 14216, 13727, 14214, 13729, 14212, 13731, 14210, 13733, 14208, 13735, 14206, 13737, 14204, 13739, 14202, 13741, 14200, 13743, 14198, 13745, 14196, 13747, 14194, 13749, 14192, 13751, 14190, 13753, 14188, 13755, 14186, 13757, 14184, 13759, 14182, 13761, 14180, 13763, 14178, 13765, 14176, 13767, 14174, 13769, 14172, 13771, 14170, 13773, 14168, 13775, 14166, 13777, 14164, 13779, 14162, 13781, 14160, 13783, 14158, 13785, 14156, 13787, 14154, 13789, 14152, 13791, 14150, 13793, 14148, 13795, 14146, 13797, 14144, 13799, 14142, 13801, 14140, 13803, 14138, 13805, 14136, 13807, 14134, 13809, 14132, 13811, 14130, 13813, 14128, 13815, 14126, 13817, 14124, 13819, 14122, 13821, 14120, 13823, 14118, 13825, 14116, 13827, 14114, 13829, 14112, 13831, 14110, 13833, 14108, 13835, 14106, 13837, 14104, 13839, 14102, 13841, 14100, 13843, 14098, 13845, 14096, 13847, 14094, 13849, 14092, 13851, 14090, 13853, 14088, 13855, 14086, 13857, 14084, 13859, 14082, 13861, 14080, 13863, 14078, 13865, 14076, 13867, 14074, 13869, 14072, 13871, 14070, 13873, 14068, 13875, 14066, 13877, 14064, 13879, 14062, 13881, 14060, 13883, 14058, 13885, 14056, 13887, 14054, 13889, 14052, 13891, 14050, 13893, 14048, 13895, 14046, 13897, 14044, 13899, 14042, 13901, 14040, 13903, 14038, 13905, 14036, 13907, 14034, 13909, 14032, 13911, 14030, 13913, 14028, 13915, 14026, 13917, 14024, 13919, 14022, 13921, 14020, 13923, 14018, 13925, 14016, 13927, 14014, 13929, 14012, 13931, 14010, 13933, 14008, 13935, 14006, 13937, 14004, 13939, 14002, 13941, 14000, 13943, 13998, 13945, 13996, 13947, 13994, 13949, 13992, 13951, 13990, 13953, 13988, 13955, 13986, 13957, 13984, 13959, 13982, 13961, 13980, 13963, 13978, 13965, 13976, 13967, 13974, 13969, 13972, 13971, 13970, 13973, 13968, 13975, 13966, 13977, 13964, 13979, 13962, 13981, 13960, 13983, 13958, 13985, 13956, 13987, 13954, 13989, 13952, 13991, 13950, 13993, 13948, 13995, 13946, 13997, 13944, 13999, 13942, 14001, 13940, 14003, 13938, 14005, 13936, 14007, 13934, 14009, 13932, 14011, 13930, 14013, 13928, 14015, 13926, 14017, 13924, 14019, 13922, 14021, 13920, 14023, 13918, 14025, 13916, 14027, 13914, 14029, 13912, 14031, 13910, 14033, 13908, 14035, 13906, 14037, 13904, 14039, 13902, 14041, 13900, 14043, 13898, 14045, 13896, 14047, 13894, 14049, 13892, 14051, 13890, 14053, 13888, 14055, 13886, 14057, 13884, 14059, 13882, 14061, 13880, 14063, 13878, 14065, 13876, 14067, 13874, 14069, 13872, 14071, 13870, 14073, 13868, 14075, 13866, 14077, 13864, 14079, 13862, 14081, 13860, 14083, 13858, 14085, 13856, 14087, 13854, 14089, 13852, 14091, 13850, 14093, 13848, 14095, 13846, 14097, 13844, 14099, 13842, 14101, 13840, 14103, 13838, 14105, 13836, 14107, 13834, 14109, 13832, 14111, 13830, 14113, 13828, 14115, 13826, 14117, 13824, 14119, 13822, 14121, 13820, 14123, 13818, 14125, 13816, 14127, 13814, 14129, 13812, 14131, 13810, 14133, 13808, 14135, 13806, 14137, 13804, 14139, 13802, 14141, 13800, 14143, 13798, 14145, 13796, 14147, 13794, 14149, 13792, 14151, 13790, 14153, 13788, 14155, 13786, 14157, 13784, 14159, 13782, 14161, 13780, 14163, 13778, 14165, 13776, 14167, 13774, 14169, 13772, 14171, 13770, 14173, 13768, 14175, 13766, 14177, 13764, 14179, 13762, 14181, 13760, 14183, 13758, 14185, 13756, 14187, 13754, 14189, 13752, 14191, 13750, 14193, 13748, 14195, 13746, 14197, 13744, 14199, 13742, 14201, 13740, 14203, 13738, 14205, 13736, 14207, 13734, 14209, 13732, 14211, 13730, 14213, 13728, 14215, 13726, 14217, 13724, 14219, 13722, 14221, 13720, 14223, 13718, 14225, 13716, 14227, 13714, 14229, 13712, 14231, 13710, 14233, 13708, 14235, 13706, 14237, 13704, 14239, 13702, 14241, 13700, 14243, 13698, 14245, 13696, 14247, 13694, 14249, 13692, 14251, 13690, 14253, 13688, 14255, 13686, 14257, 13684, 14259, 13682, 14261, 13680, 14263, 13678, 14265, 13676, 14267, 13674, 14269, 13672, 14271, 13670, 14273, 13668, 14275, 13666, 14277, 13664, 14279, 13662, 14281, 13660, 14283, 13658, 14285, 13656, 14287, 13654, 14289, 13652, 14291, 13650, 14293, 13648, 14295, 13646, 14297, 13644, 14299, 13642, 14301, 13640, 14303, 13638, 14305, 13636, 14307, 13634, 14309, 13632, 14311, 13630, 14313, 13628, 14315, 13626, 14317, 13624, 14319, 13622, 14321, 13620, 14323, 13618, 14325, 13616, 14327, 13614, 14329, 13612, 14331, 13610, 14333, 13608, 14335, 13606, 14337, 13604, 14339, 13602, 14341, 13600, 14343, 13598, 14345, 13596, 14347, 13594, 14349, 13592, 14351, 13590, 14353, 13588, 14355, 13586, 14357, 13584, 14359, 13582, 14361, 13580, 14363, 13578, 14365, 13576, 14367, 13574, 14369, 13572, 14371, 13570, 14373, 13568, 14375, 13566, 14377, 13564, 14379, 13562, 14381, 13560, 14383, 13558, 14385, 13556, 14387, 13554, 14389, 13552, 14391, 13550, 14393, 13548, 14395, 13546, 14397, 13544, 14399, 13542, 14401, 13540, 14403, 13538, 14405, 13536, 14407, 13534, 14409, 13532, 14411, 13530, 14413, 13528, 14415, 13526, 14417, 13524, 14419, 13522, 14421, 13520, 14423, 13518, 14425, 13516, 14427, 13514, 14429, 13512, 14431, 13510, 14433, 13508, 14435, 13506, 14437, 13504, 14439, 13502, 14441, 13500, 14443, 13498, 14445, 13496, 14447, 13494, 14449, 13492, 14451, 13490, 14453, 13488, 14455, 13486, 14457, 13484, 14459, 13482, 14461, 13480, 14463, 13478, 14465, 13476, 14467, 13474, 14469, 13472, 14471, 13470, 14473, 13468, 14475, 13466, 14477, 13464, 14479, 13462, 14481, 13460, 14483, 13458, 14485, 13456, 14487, 13454, 14489, 13452, 14491, 13450, 14493, 13448, 14495, 13446, 14497, 13444, 14499, 13442, 14501, 13440, 14503, 13438, 14505, 13436, 14507, 13434, 14509, 13432, 14511, 13430, 14513, 13428, 14515, 13426, 14517, 13424, 14519, 13422, 14521, 13420, 14523, 13418, 14525, 13416, 14527, 13414, 14529, 13412, 14531, 13410, 14533, 13408, 14535, 13406, 14537, 13404, 14539, 13402, 14541, 13400, 14543, 13398, 14545, 13396, 14547, 13394, 14549, 13392, 14551, 13390, 14553, 13388, 14555, 13386, 14557, 13384, 14559, 13382, 14561, 13380, 14563, 13378, 14565, 13376, 14567, 13374, 14569, 13372, 14571, 13370, 14573, 13368, 14575, 13366, 14577, 13364, 14579, 13362, 14581, 13360, 14583, 13358, 14585, 13356, 14587, 13354, 14589, 13352, 14591, 13350, 14593, 13348, 14595, 13346, 14597, 13344, 14599, 13342, 14601, 13340, 14603, 13338, 14605, 13336, 14607, 13334, 14609, 13332, 14611, 13330, 14613, 13328, 14615, 13326, 14617, 13324, 14619, 13322, 14621, 13320, 14623, 13318, 14625, 13316, 14627, 13314, 14629, 13312, 14631, 13310, 14633, 13308, 14635, 13306, 14637, 13304, 14639, 13302, 14641, 13300, 14643, 13298, 14645, 13296, 14647, 13294, 14649, 13292, 14651, 13290, 14653, 13288, 14655, 13286, 14657, 13284, 14659, 13282, 14661, 13280, 14663, 13278, 14665, 13276, 14667, 13274, 14669, 13272, 14671, 13270, 14673, 13268, 14675, 13266, 14677, 13264, 14679, 13262, 14681, 13260, 14683, 13258, 14685, 13256, 14687, 13254, 14689, 13252, 14691, 13250, 14693, 13248, 14695, 13246, 14697, 13244, 14699, 13242, 14701, 13240, 14703, 13238, 14705, 13236, 14707, 13234, 14709, 13232, 14711, 13230, 14713, 13228, 14715, 13226, 14717, 13224, 14719, 13222, 14721, 13220, 14723, 13218, 14725, 13216, 14727, 13214, 14729, 13212, 14731, 13210, 14733, 13208, 14735, 13206, 14737, 13204, 14739, 13202, 14741, 13200, 14743, 13198, 14745, 13196, 14747, 13194, 14749, 13192, 14751, 13190, 14753, 13188, 14755, 13186, 14757, 13184, 14759, 13182, 14761, 13180, 14763, 13178, 14765, 13176, 14767, 13174, 14769, 13172, 14771, 13170, 14773, 13168, 14775, 13166, 14777, 13164, 14779, 13162, 14781, 13160, 14783, 13158, 14785, 13156, 14787, 13154, 14789, 13152, 14791, 13150, 14793, 13148, 14795, 13146, 14797, 13144, 14799, 13142, 14801, 13140, 14803, 13138, 14805, 13136, 14807, 13134, 14809, 13132, 14811, 13130, 14813, 13128, 14815, 13126, 14817, 13124, 14819, 13122, 14821, 13120, 14823, 13118, 14825, 13116, 14827, 13114, 14829, 13112, 14831, 13110, 14833, 13108, 14835, 13106, 14837, 13104, 14839, 13102, 14841, 13100, 14843, 13098, 14845, 13096, 14847, 13094, 14849, 13092, 14851, 13090, 14853, 13088, 14855, 13086, 14857, 13084, 14859, 13082, 14861, 13080, 14863, 13078, 14865, 13076, 14867, 13074, 14869, 13072, 14871, 13070, 14873, 13068, 14875, 13066, 14877, 13064, 14879, 13062, 14881, 13060, 14883, 13058, 14885, 13056, 14887, 13054, 14889, 13052, 14891, 13050, 14893, 13048, 14895, 13046, 14897, 13044, 14899, 13042, 14901, 13040, 14903, 13038, 14905, 13036, 14907, 13034, 14909, 13032, 14911, 13030, 14913, 13028, 14915, 13026, 14917, 13024, 14919, 13022, 14921, 13020, 14923, 13018, 14925, 13016, 14927, 13014, 14929, 13012, 14931, 13010, 14933, 13008, 14935, 13006, 14937, 13004, 14939, 13002, 14941, 13000, 14943, 12998, 14945, 12996, 14947, 12994, 14949, 12992, 14951, 12990, 14953, 12988, 14955, 12986, 14957, 12984, 14959, 12982, 14961, 12980, 14963, 12978, 14965, 12976, 14967, 12974, 14969, 12972, 14971, 12970, 14973, 12968, 14975, 12966, 14977, 12964, 14979, 12962, 14981, 12960, 14983, 12958, 14985, 12956, 14987, 12954, 14989, 12952, 14991, 12950, 14993, 12948, 14995, 12946, 14997, 12944, 14999, 12942, 15001, 12940, 15003, 12938, 15005, 12936, 15007, 12934, 15009, 12932, 15011, 12930, 15013, 12928, 15015, 12926, 15017, 12924, 15019, 12922, 15021, 12920, 15023, 12918, 15025, 12916, 15027, 12914, 15029, 12912, 15031, 12910, 15033, 12908, 15035, 12906, 15037, 12904, 15039, 12902, 15041, 12900, 15043, 12898, 15045, 12896, 15047, 12894, 15049, 12892, 15051, 12890, 15053, 12888, 15055, 12886, 15057, 12884, 15059, 12882, 15061, 12880, 15063, 12878, 15065, 12876, 15067, 12874, 15069, 12872, 15071, 12870, 15073, 12868, 15075, 12866, 15077, 12864, 15079, 12862, 15081, 12860, 15083, 12858, 15085, 12856, 15087, 12854, 15089, 12852, 15091, 12850, 15093, 12848, 15095, 12846, 15097, 12844, 15099, 12842, 15101, 12840, 15103, 12838, 15105, 12836, 15107, 12834, 15109, 12832, 15111, 12830, 15113, 12828, 15115, 12826, 15117, 12824, 15119, 12822, 15121, 12820, 15123, 12818, 15125, 12816, 15127, 12814, 15129, 12812, 15131, 12810, 15133, 12808, 15135, 12806, 15137, 12804, 15139, 12802, 15141, 12800, 15143, 12798, 15145, 12796, 15147, 12794, 15149, 12792, 15151, 12790, 15153, 12788, 15155, 12786, 15157, 12784, 15159, 12782, 15161, 12780, 15163, 12778, 15165, 12776, 15167, 12774, 15169, 12772, 15171, 12770, 15173, 12768, 15175, 12766, 15177, 12764, 15179, 12762, 15181, 12760, 15183, 12758, 15185, 12756, 15187, 12754, 15189, 12752, 15191, 12750, 15193, 12748, 15195, 12746, 15197, 12744, 15199, 12742, 15201, 12740, 15203, 12738, 15205, 12736, 15207, 12734, 15209, 12732, 15211, 12730, 15213, 12728, 15215, 12726, 15217, 12724, 15219, 12722, 15221, 12720, 15223, 12718, 15225, 12716, 15227, 12714, 15229, 12712, 15231, 12710, 15233, 12708, 15235, 12706, 15237, 12704, 15239, 12702, 15241, 12700, 15243, 12698, 15245, 12696, 15247, 12694, 15249, 12692, 15251, 12690, 15253, 12688, 15255, 12686, 15257, 12684, 15259, 12682, 15261, 12680, 15263, 12678, 15265, 12676, 15267, 12674, 15269, 12672, 15271, 12670, 15273, 12668, 15275, 12666, 15277, 12664, 15279, 12662, 15281, 12660, 15283, 12658, 15285, 12656, 15287, 12654, 15289, 12652, 15291, 12650, 15293, 12648, 15295, 12646, 15297, 12644, 15299, 12642, 15301, 12640, 15303, 12638, 15305, 12636, 15307, 12634, 15309, 12632, 15311, 12630, 15313, 12628, 15315, 12626, 15317, 12624, 15319, 12622, 15321, 12620, 15323, 12618, 15325, 12616, 15327, 12614, 15329, 12612, 15331, 12610, 15333, 12608, 15335, 12606, 15337, 12604, 15339, 12602, 15341, 12600, 15343, 12598, 15345, 12596, 15347, 12594, 15349, 12592, 15351, 12590, 15353, 12588, 15355, 12586, 15357, 12584, 15359, 12582, 15361, 12580, 15363, 12578, 15365, 12576, 15367, 12574, 15369, 12572, 15371, 12570, 15373, 12568, 15375, 12566, 15377, 12564, 15379, 12562, 15381, 12560, 15383, 12558, 15385, 12556, 15387, 12554, 15389, 12552, 15391, 12550, 15393, 12548, 15395, 12546, 15397, 12544, 15399, 12542, 15401, 12540, 15403, 12538, 15405, 12536, 15407, 12534, 15409, 12532, 15411, 12530, 15413, 12528, 15415, 12526, 15417, 12524, 15419, 12522, 15421, 12520, 15423, 12518, 15425, 12516, 15427, 12514, 15429, 12512, 15431, 12510, 15433, 12508, 15435, 12506, 15437, 12504, 15439, 12502, 15441, 12500, 15443, 12498, 15445, 12496, 15447, 12494, 15449, 12492, 15451, 12490, 15453, 12488, 15455, 12486, 15457, 12484, 15459, 12482, 15461, 12480, 15463, 12478, 15465, 12476, 15467, 12474, 15469, 12472, 15471, 12470, 15473, 12468, 15475, 12466, 15477, 12464, 15479, 12462, 15481, 12460, 15483, 12458, 15485, 12456, 15487, 12454, 15489, 12452, 15491, 12450, 15493, 12448, 15495, 12446, 15497, 12444, 15499, 12442, 15501, 12440, 15503, 12438, 15505, 12436, 15507, 12434, 15509, 12432, 15511, 12430, 15513, 12428, 15515, 12426, 15517, 12424, 15519, 12422, 15521, 12420, 15523, 12418, 15525, 12416, 15527, 12414, 15529, 12412, 15531, 12410, 15533, 12408, 15535, 12406, 15537, 12404, 15539, 12402, 15541, 12400, 15543, 12398, 15545, 12396, 15547, 12394, 15549, 12392, 15551, 12390, 15553, 12388, 15555, 12386, 15557, 12384, 15559, 12382, 15561, 12380, 15563, 12378, 15565, 12376, 15567, 12374, 15569, 12372, 15571, 12370, 15573, 12368, 15575, 12366, 15577, 12364, 15579, 12362, 15581, 12360, 15583, 12358, 15585, 12356, 15587, 12354, 15589, 12352, 15591, 12350, 15593, 12348, 15595, 12346, 15597, 12344, 15599, 12342, 15601, 12340, 15603, 12338, 15605, 12336, 15607, 12334, 15609, 12332, 15611, 12330, 15613, 12328, 15615, 12326, 15617, 12324, 15619, 12322, 15621, 12320, 15623, 12318, 15625, 12316, 15627, 12314, 15629, 12312, 15631, 12310, 15633, 12308, 15635, 12306, 15637, 12304, 15639, 12302, 15641, 12300, 15643, 12298, 15645, 12296, 15647, 12294, 15649, 12292, 15651, 12290, 15653, 12288, 15655, 12286, 15657, 12284, 15659, 12282, 15661, 12280, 15663, 12278, 15665, 12276, 15667, 12274, 15669, 12272, 15671, 12270, 15673, 12268, 15675, 12266, 15677, 12264, 15679, 12262, 15681, 12260, 15683, 12258, 15685, 12256, 15687, 12254, 15689, 12252, 15691, 12250, 15693, 12248, 15695, 12246, 15697, 12244, 15699, 12242, 15701, 12240, 15703, 12238, 15705, 12236, 15707, 12234, 15709, 12232, 15711, 12230, 15713, 12228, 15715, 12226, 15717, 12224, 15719, 12222, 15721, 12220, 15723, 12218, 15725, 12216, 15727, 12214, 15729, 12212, 15731, 12210, 15733, 12208, 15735, 12206, 15737, 12204, 15739, 12202, 15741, 12200, 15743, 12198, 15745, 12196, 15747, 12194, 15749, 12192, 15751, 12190, 15753, 12188, 15755, 12186, 15757, 12184, 15759, 12182, 15761, 12180, 15763, 12178, 15765, 12176, 15767, 12174, 15769, 12172, 15771, 12170, 15773, 12168, 15775, 12166, 15777, 12164, 15779, 12162, 15781, 12160, 15783, 12158, 15785, 12156, 15787, 12154, 15789, 12152, 15791, 12150, 15793, 12148, 15795, 12146, 15797, 12144, 15799, 12142, 15801, 12140, 15803, 12138, 15805, 12136, 15807, 12134, 15809, 12132, 15811, 12130, 15813, 12128, 15815, 12126, 15817, 12124, 15819, 12122, 15821, 12120, 15823, 12118, 15825, 12116, 15827, 12114, 15829, 12112, 15831, 12110, 15833, 12108, 15835, 12106, 15837, 12104, 15839, 12102, 15841, 12100, 15843, 12098, 15845, 12096, 15847, 12094, 15849, 12092, 15851, 12090, 15853, 12088, 15855, 12086, 15857, 12084, 15859, 12082, 15861, 12080, 15863, 12078, 15865, 12076, 15867, 12074, 15869, 12072, 15871, 12070, 15873, 12068, 15875, 12066, 15877, 12064, 15879, 12062, 15881, 12060, 15883, 12058, 15885, 12056, 15887, 12054, 15889, 12052, 15891, 12050, 15893, 12048, 15895, 12046, 15897, 12044, 15899, 12042, 15901, 12040, 15903, 12038, 15905, 12036, 15907, 12034, 15909, 12032, 15911, 12030, 15913, 12028, 15915, 12026, 15917, 12024, 15919, 12022, 15921, 12020, 15923, 12018, 15925, 12016, 15927, 12014, 15929, 12012, 15931, 12010, 15933, 12008, 15935, 12006, 15937, 12004, 15939, 12002, 15941, 12000, 15943, 11998, 15945, 11996, 15947, 11994, 15949, 11992, 15951, 11990, 15953, 11988, 15955, 11986, 15957, 11984, 15959, 11982, 15961, 11980, 15963, 11978, 15965, 11976, 15967, 11974, 15969, 11972, 15971, 11970, 15973, 11968, 15975, 11966, 15977, 11964, 15979, 11962, 15981, 11960, 15983, 11958, 15985, 11956, 15987, 11954, 15989, 11952, 15991, 11950, 15993, 11948, 15995, 11946, 15997, 11944, 15999, 11942, 16001, 11940, 16003, 11938, 16005, 11936, 16007, 11934, 16009, 11932, 16011, 11930, 16013, 11928, 16015, 11926, 16017, 11924, 16019, 11922, 16021, 11920, 16023, 11918, 16025, 11916, 16027, 11914, 16029, 11912, 16031, 11910, 16033, 11908, 16035, 11906, 16037, 11904, 16039, 11902, 16041, 11900, 16043, 11898, 16045, 11896, 16047, 11894, 16049, 11892, 16051, 11890, 16053, 11888, 16055, 11886, 16057, 11884, 16059, 11882, 16061, 11880, 16063, 11878, 16065, 11876, 16067, 11874, 16069, 11872, 16071, 11870, 16073, 11868, 16075, 11866, 16077, 11864, 16079, 11862, 16081, 11860, 16083, 11858, 16085, 11856, 16087, 11854, 16089, 11852, 16091, 11850, 16093, 11848, 16095, 11846, 16097, 11844, 16099, 11842, 16101, 11840, 16103, 11838, 16105, 11836, 16107, 11834, 16109, 11832, 16111, 11830, 16113, 11828, 16115, 11826, 16117, 11824, 16119, 11822, 16121, 11820, 16123, 11818, 16125, 11816, 16127, 11814, 16129, 11812, 16131, 11810, 16133, 11808, 16135, 11806, 16137, 11804, 16139, 11802, 16141, 11800, 16143, 11798, 16145, 11796, 16147, 11794, 16149, 11792, 16151, 11790, 16153, 11788, 16155, 11786, 16157, 11784, 16159, 11782, 16161, 11780, 16163, 11778, 16165, 11776, 16167, 11774, 16169, 11772, 16171, 11770, 16173, 11768, 16175, 11766, 16177, 11764, 16179, 11762, 16181, 11760, 16183, 11758, 16185, 11756, 16187, 11754, 16189, 11752, 16191, 11750, 16193, 11748, 16195, 11746, 16197, 11744, 16199, 11742, 16201, 11740, 16203, 11738, 16205, 11736, 16207, 11734, 16209, 11732, 16211, 11730, 16213, 11728, 16215, 11726, 16217, 11724, 16219, 11722, 16221, 11720, 16223, 11718, 16225, 11716, 16227, 11714, 16229, 11712, 16231, 11710, 16233, 11708, 16235, 11706, 16237, 11704, 16239, 11702, 16241, 11700, 16243, 11698, 16245, 11696, 16247, 11694, 16249, 11692, 16251, 11690, 16253, 11688, 16255, 11686, 16257, 11684, 16259, 11682, 16261, 11680, 16263, 11678, 16265, 11676, 16267, 11674, 16269, 11672, 16271, 11670, 16273, 11668, 16275, 11666, 16277, 11664, 16279, 11662, 16281, 11660, 16283, 11658, 16285, 11656, 16287, 11654, 16289, 11652, 16291, 11650, 16293, 11648, 16295, 11646, 16297, 11644, 16299, 11642, 16301, 11640, 16303, 11638, 16305, 11636, 16307, 11634, 16309, 11632, 16311, 11630, 16313, 11628, 16315, 11626, 16317, 11624, 16319, 11622, 16321, 11620, 16323, 11618, 16325, 11616, 16327, 11614, 16329, 11612, 16331, 11610, 16333, 11608, 16335, 11606, 16337, 11604, 16339, 11602, 16341, 11600, 16343, 11598, 16345, 11596, 16347, 11594, 16349, 11592, 16351, 11590, 16353, 11588, 16355, 11586, 16357, 11584, 16359, 11582, 16361, 11580, 16363, 11578, 16365, 11576, 16367, 11574, 16369, 11572, 16371, 11570, 16373, 11568, 16375, 11566, 16377, 11564, 16379, 11562, 16381, 11560, 16383, 11558, 16385, 11556, 16387, 11554, 16389, 11552, 16391, 11550, 16393, 11548, 16395, 11546, 16397, 11544, 16399, 11542, 16401, 11540, 16403, 11538, 16405, 11536, 16407, 11534, 16409, 11532, 16411, 11530, 16413, 11528, 16415, 11526, 16417, 11524, 16419, 11522, 16421, 11520, 16423, 11518, 16425, 11516, 16427, 11514, 16429, 11512, 16431, 11510, 16433, 11508, 16435, 11506, 16437, 11504, 16439, 11502, 16441, 11500, 16443, 11498, 16445, 11496, 16447, 11494, 16449, 11492, 16451, 11490, 16453, 11488, 16455, 11486, 16457, 11484, 16459, 11482, 16461, 11480, 16463, 11478, 16465, 11476, 16467, 11474, 16469, 11472, 16471, 11470, 16473, 11468, 16475, 11466, 16477, 11464, 16479, 11462, 16481, 11460, 16483, 11458, 16485, 11456, 16487, 11454, 16489, 11452, 16491, 11450, 16493, 11448, 16495, 11446, 16497, 11444, 16499, 11442, 16501, 11440, 16503, 11438, 16505, 11436, 16507, 11434, 16509, 11432, 16511, 11430, 16513, 11428, 16515, 11426, 16517, 11424, 16519, 11422, 16521, 11420, 16523, 11418, 16525, 11416, 16527, 11414, 16529, 11412, 16531, 11410, 16533, 11408, 16535, 11406, 16537, 11404, 16539, 11402, 16541, 11400, 16543, 11398, 16545, 11396, 16547, 11394, 16549, 11392, 16551, 11390, 16553, 11388, 16555, 11386, 16557, 11384, 16559, 11382, 16561, 11380, 16563, 11378, 16565, 11376, 16567, 11374, 16569, 11372, 16571, 11370, 16573, 11368, 16575, 11366, 16577, 11364, 16579, 11362, 16581, 11360, 16583, 11358, 16585, 11356, 16587, 11354, 16589, 11352, 16591, 11350, 16593, 11348, 16595, 11346, 16597, 11344, 16599, 11342, 16601, 11340, 16603, 11338, 16605, 11336, 16607, 11334, 16609, 11332, 16611, 11330, 16613, 11328, 16615, 11326, 16617, 11324, 16619, 11322, 16621, 11320, 16623, 11318, 16625, 11316, 16627, 11314, 16629, 11312, 16631, 11310, 16633, 11308, 16635, 11306, 16637, 11304, 16639, 11302, 16641, 11300, 16643, 11298, 16645, 11296, 16647, 11294, 16649, 11292, 16651, 11290, 16653, 11288, 16655, 11286, 16657, 11284, 16659, 11282, 16661, 11280, 16663, 11278, 16665, 11276, 16667, 11274, 16669, 11272, 16671, 11270, 16673, 11268, 16675, 11266, 16677, 11264, 16679, 11262, 16681, 11260, 16683, 11258, 16685, 11256, 16687, 11254, 16689, 11252, 16691, 11250, 16693, 11248, 16695, 11246, 16697, 11244, 16699, 11242, 16701, 11240, 16703, 11238, 16705, 11236, 16707, 11234, 16709, 11232, 16711, 11230, 16713, 11228, 16715, 11226, 16717, 11224, 16719, 11222, 16721, 11220, 16723, 11218, 16725, 11216, 16727, 11214, 16729, 11212, 16731, 11210, 16733, 11208, 16735, 11206, 16737, 11204, 16739, 11202, 16741, 11200, 16743, 11198, 16745, 11196, 16747, 11194, 16749, 11192, 16751, 11190, 16753, 11188, 16755, 11186, 16757, 11184, 16759, 11182, 16761, 11180, 16763, 11178, 16765, 11176, 16767, 11174, 16769, 11172, 16771, 11170, 16773, 11168, 16775, 11166, 16777, 11164, 16779, 11162, 16781, 11160, 16783, 11158, 16785, 11156, 16787, 11154, 16789, 11152, 16791, 11150, 16793, 11148, 16795, 11146, 16797, 11144, 16799, 11142, 16801, 11140, 16803, 11138, 16805, 11136, 16807, 11134, 16809, 11132, 16811, 11130, 16813, 11128, 16815, 11126, 16817, 11124, 16819, 11122, 16821, 11120, 16823, 11118, 16825, 11116, 16827, 11114, 16829, 11112, 16831, 11110, 16833, 11108, 16835, 11106, 16837, 11104, 16839, 11102, 16841, 11100, 16843, 11098, 16845, 11096, 16847, 11094, 16849, 11092, 16851, 11090, 16853, 11088, 16855, 11086, 16857, 11084, 16859, 11082, 16861, 11080, 16863, 11078, 16865, 11076, 16867, 11074, 16869, 11072, 16871, 11070, 16873, 11068, 16875, 11066, 16877, 11064, 16879, 11062, 16881, 11060, 16883, 11058, 16885, 11056, 16887, 11054, 16889, 11052, 16891, 11050, 16893, 11048, 16895, 11046, 16897, 11044, 16899, 11042, 16901, 11040, 16903, 11038, 16905, 11036, 16907, 11034, 16909, 11032, 16911, 11030, 16913, 11028, 16915, 11026, 16917, 11024, 16919, 11022, 16921, 11020, 16923, 11018, 16925, 11016, 16927, 11014, 16929, 11012, 16931, 11010, 16933, 11008, 16935, 11006, 16937, 11004, 16939, 11002, 16941, 11000, 16943, 10998, 16945, 10996, 16947, 10994, 16949, 10992, 16951, 10990, 16953, 10988, 16955, 10986, 16957, 10984, 16959, 10982, 16961, 10980, 16963, 10978, 16965, 10976, 16967, 10974, 16969, 10972, 16971, 10970, 16973, 10968, 16975, 10966, 16977, 10964, 16979, 10962, 16981, 10960, 16983, 10958, 16985, 10956, 16987, 10954, 16989, 10952, 16991, 10950, 16993, 10948, 16995, 10946, 16997, 10944, 16999, 10942, 17001, 10940, 17003, 10938, 17005, 10936, 17007, 10934, 17009, 10932, 17011, 10930, 17013, 10928, 17015, 10926, 17017, 10924, 17019, 10922, 17021, 10920, 17023, 10918, 17025, 10916, 17027, 10914, 17029, 10912, 17031, 10910, 17033, 10908, 17035, 10906, 17037, 10904, 17039, 10902, 17041, 10900, 17043, 10898, 17045, 10896, 17047, 10894, 17049, 10892, 17051, 10890, 17053, 10888, 17055, 10886, 17057, 10884, 17059, 10882, 17061, 10880, 17063, 10878, 17065, 10876, 17067, 10874, 17069, 10872, 17071, 10870, 17073, 10868, 17075, 10866, 17077, 10864, 17079, 10862, 17081, 10860, 17083, 10858, 17085, 10856, 17087, 10854, 17089, 10852, 17091, 10850, 17093, 10848, 17095, 10846, 17097, 10844, 17099, 10842, 17101, 10840, 17103, 10838, 17105, 10836, 17107, 10834, 17109, 10832, 17111, 10830, 17113, 10828, 17115, 10826, 17117, 10824, 17119, 10822, 17121, 10820, 17123, 10818, 17125, 10816, 17127, 10814, 17129, 10812, 17131, 10810, 17133, 10808, 17135, 10806, 17137, 10804, 17139, 10802, 17141, 10800, 17143, 10798, 17145, 10796, 17147, 10794, 17149, 10792, 17151, 10790, 17153, 10788, 17155, 10786, 17157, 10784, 17159, 10782, 17161, 10780, 17163, 10778, 17165, 10776, 17167, 10774, 17169, 10772, 17171, 10770, 17173, 10768, 17175, 10766, 17177, 10764, 17179, 10762, 17181, 10760, 17183, 10758, 17185, 10756, 17187, 10754, 17189, 10752, 17191, 10750, 17193, 10748, 17195, 10746, 17197, 10744, 17199, 10742, 17201, 10740, 17203, 10738, 17205, 10736, 17207, 10734, 17209, 10732, 17211, 10730, 17213, 10728, 17215, 10726, 17217, 10724, 17219, 10722, 17221, 10720, 17223, 10718, 17225, 10716, 17227, 10714, 17229, 10712, 17231, 10710, 17233, 10708, 17235, 10706, 17237, 10704, 17239, 10702, 17241, 10700, 17243, 10698, 17245, 10696, 17247, 10694, 17249, 10692, 17251, 10690, 17253, 10688, 17255, 10686, 17257, 10684, 17259, 10682, 17261, 10680, 17263, 10678, 17265, 10676, 17267, 10674, 17269, 10672, 17271, 10670, 17273, 10668, 17275, 10666, 17277, 10664, 17279, 10662, 17281, 10660, 17283, 10658, 17285, 10656, 17287, 10654, 17289, 10652, 17291, 10650, 17293, 10648, 17295, 10646, 17297, 10644, 17299, 10642, 17301, 10640, 17303, 10638, 17305, 10636, 17307, 10634, 17309, 10632, 17311, 10630, 17313, 10628, 17315, 10626, 17317, 10624, 17319, 10622, 17321, 10620, 17323, 10618, 17325, 10616, 17327, 10614, 17329, 10612, 17331, 10610, 17333, 10608, 17335, 10606, 17337, 10604, 17339, 10602, 17341, 10600, 17343, 10598, 17345, 10596, 17347, 10594, 17349, 10592, 17351, 10590, 17353, 10588, 17355, 10586, 17357, 10584, 17359, 10582, 17361, 10580, 17363, 10578, 17365, 10576, 17367, 10574, 17369, 10572, 17371, 10570, 17373, 10568, 17375, 10566, 17377, 10564, 17379, 10562, 17381, 10560, 17383, 10558, 17385, 10556, 17387, 10554, 17389, 10552, 17391, 10550, 17393, 10548, 17395, 10546, 17397, 10544, 17399, 10542, 17401, 10540, 17403, 10538, 17405, 10536, 17407, 10534, 17409, 10532, 17411, 10530, 17413, 10528, 17415, 10526, 17417, 10524, 17419, 10522, 17421, 10520, 17423, 10518, 17425, 10516, 17427, 10514, 17429, 10512, 17431, 10510, 17433, 10508, 17435, 10506, 17437, 10504, 17439, 10502, 17441, 10500, 17443, 10498, 17445, 10496, 17447, 10494, 17449, 10492, 17451, 10490, 17453, 10488, 17455, 10486, 17457, 10484, 17459, 10482, 17461, 10480, 17463, 10478, 17465, 10476, 17467, 10474, 17469, 10472, 17471, 10470, 17473, 10468, 17475, 10466, 17477, 10464, 17479, 10462, 17481, 10460, 17483, 10458, 17485, 10456, 17487, 10454, 17489, 10452, 17491, 10450, 17493, 10448, 17495, 10446, 17497, 10444, 17499, 10442, 17501, 10440, 17503, 10438, 17505, 10436, 17507, 10434, 17509, 10432, 17511, 10430, 17513, 10428, 17515, 10426, 17517, 10424, 17519, 10422, 17521, 10420, 17523, 10418, 17525, 10416, 17527, 10414, 17529, 10412, 17531, 10410, 17533, 10408, 17535, 10406, 17537, 10404, 17539, 10402, 17541, 10400, 17543, 10398, 17545, 10396, 17547, 10394, 17549, 10392, 17551, 10390, 17553, 10388, 17555, 10386, 17557, 10384, 17559, 10382, 17561, 10380, 17563, 10378, 17565, 10376, 17567, 10374, 17569, 10372, 17571, 10370, 17573, 10368, 17575, 10366, 17577, 10364, 17579, 10362, 17581, 10360, 17583, 10358, 17585, 10356, 17587, 10354, 17589, 10352, 17591, 10350, 17593, 10348, 17595, 10346, 17597, 10344, 17599, 10342, 17601, 10340, 17603, 10338, 17605, 10336, 17607, 10334, 17609, 10332, 17611, 10330, 17613, 10328, 17615, 10326, 17617, 10324, 17619, 10322, 17621, 10320, 17623, 10318, 17625, 10316, 17627, 10314, 17629, 10312, 17631, 10310, 17633, 10308, 17635, 10306, 17637, 10304, 17639, 10302, 17641, 10300, 17643, 10298, 17645, 10296, 17647, 10294, 17649, 10292, 17651, 10290, 17653, 10288, 17655, 10286, 17657, 10284, 17659, 10282, 17661, 10280, 17663, 10278, 17665, 10276, 17667, 10274, 17669, 10272, 17671, 10270, 17673, 10268, 17675, 10266, 17677, 10264, 17679, 10262, 17681, 10260, 17683, 10258, 17685, 10256, 17687, 10254, 17689, 10252, 17691, 10250, 17693, 10248, 17695, 10246, 17697, 10244, 17699, 10242, 17701, 10240, 17703, 10238, 17705, 10236, 17707, 10234, 17709, 10232, 17711, 10230, 17713, 10228, 17715, 10226, 17717, 10224, 17719, 10222, 17721, 10220, 17723, 10218, 17725, 10216, 17727, 10214, 17729, 10212, 17731, 10210, 17733, 10208, 17735, 10206, 17737, 10204, 17739, 10202, 17741, 10200, 17743, 10198, 17745, 10196, 17747, 10194, 17749, 10192, 17751, 10190, 17753, 10188, 17755, 10186, 17757, 10184, 17759, 10182, 17761, 10180, 17763, 10178, 17765, 10176, 17767, 10174, 17769, 10172, 17771, 10170, 17773, 10168, 17775, 10166, 17777, 10164, 17779, 10162, 17781, 10160, 17783, 10158, 17785, 10156, 17787, 10154, 17789, 10152, 17791, 10150, 17793, 10148, 17795, 10146, 17797, 10144, 17799, 10142, 17801, 10140, 17803, 10138, 17805, 10136, 17807, 10134, 17809, 10132, 17811, 10130, 17813, 10128, 17815, 10126, 17817, 10124, 17819, 10122, 17821, 10120, 17823, 10118, 17825, 10116, 17827, 10114, 17829, 10112, 17831, 10110, 17833, 10108, 17835, 10106, 17837, 10104, 17839, 10102, 17841, 10100, 17843, 10098, 17845, 10096, 17847, 10094, 17849, 10092, 17851, 10090, 17853, 10088, 17855, 10086, 17857, 10084, 17859, 10082, 17861, 10080, 17863, 10078, 17865, 10076, 17867, 10074, 17869, 10072, 17871, 10070, 17873, 10068, 17875, 10066, 17877, 10064, 17879, 10062, 17881, 10060, 17883, 10058, 17885, 10056, 17887, 10054, 17889, 10052, 17891, 10050, 17893, 10048, 17895, 10046, 17897, 10044, 17899, 10042, 17901, 10040, 17903, 10038, 17905, 10036, 17907, 10034, 17909, 10032, 17911, 10030, 17913, 10028, 17915, 10026, 17917, 10024, 17919, 10022, 17921, 10020, 17923, 10018, 17925, 10016, 17927, 10014, 17929, 10012, 17931, 10010, 17933, 10008, 17935, 10006, 17937, 10004, 17939, 10002, 17941, 10000, 17943, 9998, 17945, 9996, 17947, 9994, 17949, 9992, 17951, 9990, 17953, 9988, 17955, 9986, 17957, 9984, 17959, 9982, 17961, 9980, 17963, 9978, 17965, 9976, 17967, 9974, 17969, 9972, 17971, 9970, 17973, 9968, 17975, 9966, 17977, 9964, 17979, 9962, 17981, 9960, 17983, 9958, 17985, 9956, 17987, 9954, 17989, 9952, 17991, 9950, 17993, 9948, 17995, 9946, 17997, 9944, 17999, 9942, 18001, 9940, 18003, 9938, 18005, 9936, 18007, 9934, 18009, 9932, 18011, 9930, 18013, 9928, 18015, 9926, 18017, 9924, 18019, 9922, 18021, 9920, 18023, 9918, 18025, 9916, 18027, 9914, 18029, 9912, 18031, 9910, 18033, 9908, 18035, 9906, 18037, 9904, 18039, 9902, 18041, 9900, 18043, 9898, 18045, 9896, 18047, 9894, 18049, 9892, 18051, 9890, 18053, 9888, 18055, 9886, 18057, 9884, 18059, 9882, 18061, 9880, 18063, 9878, 18065, 9876, 18067, 9874, 18069, 9872, 18071, 9870, 18073, 9868, 18075, 9866, 18077, 9864, 18079, 9862, 18081, 9860, 18083, 9858, 18085, 9856, 18087, 9854, 18089, 9852, 18091, 9850, 18093, 9848, 18095, 9846, 18097, 9844, 18099, 9842, 18101, 9840, 18103, 9838, 18105, 9836, 18107, 9834, 18109, 9832, 18111, 9830, 18113, 9828, 18115, 9826, 18117, 9824, 18119, 9822, 18121, 9820, 18123, 9818, 18125, 9816, 18127, 9814, 18129, 9812, 18131, 9810, 18133, 9808, 18135, 9806, 18137, 9804, 18139, 9802, 18141, 9800, 18143, 9798, 18145, 9796, 18147, 9794, 18149, 9792, 18151, 9790, 18153, 9788, 18155, 9786, 18157, 9784, 18159, 9782, 18161, 9780, 18163, 9778, 18165, 9776, 18167, 9774, 18169, 9772, 18171, 9770, 18173, 9768, 18175, 9766, 18177, 9764, 18179, 9762, 18181, 9760, 18183, 9758, 18185, 9756, 18187, 9754, 18189, 9752, 18191, 9750, 18193, 9748, 18195, 9746, 18197, 9744, 18199, 9742, 18201, 9740, 18203, 9738, 18205, 9736, 18207, 9734, 18209, 9732, 18211, 9730, 18213, 9728, 18215, 9726, 18217, 9724, 18219, 9722, 18221, 9720, 18223, 9718, 18225, 9716, 18227, 9714, 18229, 9712, 18231, 9710, 18233, 9708, 18235, 9706, 18237, 9704, 18239, 9702, 18241, 9700, 18243, 9698, 18245, 9696, 18247, 9694, 18249, 9692, 18251, 9690, 18253, 9688, 18255, 9686, 18257, 9684, 18259, 9682, 18261, 9680, 18263, 9678, 18265, 9676, 18267, 9674, 18269, 9672, 18271, 9670, 18273, 9668, 18275, 9666, 18277, 9664, 18279, 9662, 18281, 9660, 18283, 9658, 18285, 9656, 18287, 9654, 18289, 9652, 18291, 9650, 18293, 9648, 18295, 9646, 18297, 9644, 18299, 9642, 18301, 9640, 18303, 9638, 18305, 9636, 18307, 9634, 18309, 9632, 18311, 9630, 18313, 9628, 18315, 9626, 18317, 9624, 18319, 9622, 18321, 9620, 18323, 9618, 18325, 9616, 18327, 9614, 18329, 9612, 18331, 9610, 18333, 9608, 18335, 9606, 18337, 9604, 18339, 9602, 18341, 9600, 18343, 9598, 18345, 9596, 18347, 9594, 18349, 9592, 18351, 9590, 18353, 9588, 18355, 9586, 18357, 9584, 18359, 9582, 18361, 9580, 18363, 9578, 18365, 9576, 18367, 9574, 18369, 9572, 18371, 9570, 18373, 9568, 18375, 9566, 18377, 9564, 18379, 9562, 18381, 9560, 18383, 9558, 18385, 9556, 18387, 9554, 18389, 9552, 18391, 9550, 18393, 9548, 18395, 9546, 18397, 9544, 18399, 9542, 18401, 9540, 18403, 9538, 18405, 9536, 18407, 9534, 18409, 9532, 18411, 9530, 18413, 9528, 18415, 9526, 18417, 9524, 18419, 9522, 18421, 9520, 18423, 9518, 18425, 9516, 18427, 9514, 18429, 9512, 18431, 9510, 18433, 9508, 18435, 9506, 18437, 9504, 18439, 9502, 18441, 9500, 18443, 9498, 18445, 9496, 18447, 9494, 18449, 9492, 18451, 9490, 18453, 9488, 18455, 9486, 18457, 9484, 18459, 9482, 18461, 9480, 18463, 9478, 18465, 9476, 18467, 9474, 18469, 9472, 18471, 9470, 18473, 9468, 18475, 9466, 18477, 9464, 18479, 9462, 18481, 9460, 18483, 9458, 18485, 9456, 18487, 9454, 18489, 9452, 18491, 9450, 18493, 9448, 18495, 9446, 18497, 9444, 18499, 9442, 18501, 9440, 18503, 9438, 18505, 9436, 18507, 9434, 18509, 9432, 18511, 9430, 18513, 9428, 18515, 9426, 18517, 9424, 18519, 9422, 18521, 9420, 18523, 9418, 18525, 9416, 18527, 9414, 18529, 9412, 18531, 9410, 18533, 9408, 18535, 9406, 18537, 9404, 18539, 9402, 18541, 9400, 18543, 9398, 18545, 9396, 18547, 9394, 18549, 9392, 18551, 9390, 18553, 9388, 18555, 9386, 18557, 9384, 18559, 9382, 18561, 9380, 18563, 9378, 18565, 9376, 18567, 9374, 18569, 9372, 18571, 9370, 18573, 9368, 18575, 9366, 18577, 9364, 18579, 9362, 18581, 9360, 18583, 9358, 18585, 9356, 18587, 9354, 18589, 9352, 18591, 9350, 18593, 9348, 18595, 9346, 18597, 9344, 18599, 9342, 18601, 9340, 18603, 9338, 18605, 9336, 18607, 9334, 18609, 9332, 18611, 9330, 18613, 9328, 18615, 9326, 18617, 9324, 18619, 9322, 18621, 9320, 18623, 9318, 18625, 9316, 18627, 9314, 18629, 9312, 18631, 9310, 18633, 9308, 18635, 9306, 18637, 9304, 18639, 9302, 18641, 9300, 18643, 9298, 18645, 9296, 18647, 9294, 18649, 9292, 18651, 9290, 18653, 9288, 18655, 9286, 18657, 9284, 18659, 9282, 18661, 9280, 18663, 9278, 18665, 9276, 18667, 9274, 18669, 9272, 18671, 9270, 18673, 9268, 18675, 9266, 18677, 9264, 18679, 9262, 18681, 9260, 18683, 9258, 18685, 9256, 18687, 9254, 18689, 9252, 18691, 9250, 18693, 9248, 18695, 9246, 18697, 9244, 18699, 9242, 18701, 9240, 18703, 9238, 18705, 9236, 18707, 9234, 18709, 9232, 18711, 9230, 18713, 9228, 18715, 9226, 18717, 9224, 18719, 9222, 18721, 9220, 18723, 9218, 18725, 9216, 18727, 9214, 18729, 9212, 18731, 9210, 18733, 9208, 18735, 9206, 18737, 9204, 18739, 9202, 18741, 9200, 18743, 9198, 18745, 9196, 18747, 9194, 18749, 9192, 18751, 9190, 18753, 9188, 18755, 9186, 18757, 9184, 18759, 9182, 18761, 9180, 18763, 9178, 18765, 9176, 18767, 9174, 18769, 9172, 18771, 9170, 18773, 9168, 18775, 9166, 18777, 9164, 18779, 9162, 18781, 9160, 18783, 9158, 18785, 9156, 18787, 9154, 18789, 9152, 18791, 9150, 18793, 9148, 18795, 9146, 18797, 9144, 18799, 9142, 18801, 9140, 18803, 9138, 18805, 9136, 18807, 9134, 18809, 9132, 18811, 9130, 18813, 9128, 18815, 9126, 18817, 9124, 18819, 9122, 18821, 9120, 18823, 9118, 18825, 9116, 18827, 9114, 18829, 9112, 18831, 9110, 18833, 9108, 18835, 9106, 18837, 9104, 18839, 9102, 18841, 9100, 18843, 9098, 18845, 9096, 18847, 9094, 18849, 9092, 18851, 9090, 18853, 9088, 18855, 9086, 18857, 9084, 18859, 9082, 18861, 9080, 18863, 9078, 18865, 9076, 18867, 9074, 18869, 9072, 18871, 9070, 18873, 9068, 18875, 9066, 18877, 9064, 18879, 9062, 18881, 9060, 18883, 9058, 18885, 9056, 18887, 9054, 18889, 9052, 18891, 9050, 18893, 9048, 18895, 9046, 18897, 9044, 18899, 9042, 18901, 9040, 18903, 9038, 18905, 9036, 18907, 9034, 18909, 9032, 18911, 9030, 18913, 9028, 18915, 9026, 18917, 9024, 18919, 9022, 18921, 9020, 18923, 9018, 18925, 9016, 18927, 9014, 18929, 9012, 18931, 9010, 18933, 9008, 18935, 9006, 18937, 9004, 18939, 9002, 18941, 9000, 18943, 8998, 18945, 8996, 18947, 8994, 18949, 8992, 18951, 8990, 18953, 8988, 18955, 8986, 18957, 8984, 18959, 8982, 18961, 8980, 18963, 8978, 18965, 8976, 18967, 8974, 18969, 8972, 18971, 8970, 18973, 8968, 18975, 8966, 18977, 8964, 18979, 8962, 18981, 8960, 18983, 8958, 18985, 8956, 18987, 8954, 18989, 8952, 18991, 8950, 18993, 8948, 18995, 8946, 18997, 8944, 18999, 8942, 19001, 8940, 19003, 8938, 19005, 8936, 19007, 8934, 19009, 8932, 19011, 8930, 19013, 8928, 19015, 8926, 19017, 8924, 19019, 8922, 19021, 8920, 19023, 8918, 19025, 8916, 19027, 8914, 19029, 8912, 19031, 8910, 19033, 8908, 19035, 8906, 19037, 8904, 19039, 8902, 19041, 8900, 19043, 8898, 19045, 8896, 19047, 8894, 19049, 8892, 19051, 8890, 19053, 8888, 19055, 8886, 19057, 8884, 19059, 8882, 19061, 8880, 19063, 8878, 19065, 8876, 19067, 8874, 19069, 8872, 19071, 8870, 19073, 8868, 19075, 8866, 19077, 8864, 19079, 8862, 19081, 8860, 19083, 8858, 19085, 8856, 19087, 8854, 19089, 8852, 19091, 8850, 19093, 8848, 19095, 8846, 19097, 8844, 19099, 8842, 19101, 8840, 19103, 8838, 19105, 8836, 19107, 8834, 19109, 8832, 19111, 8830, 19113, 8828, 19115, 8826, 19117, 8824, 19119, 8822, 19121, 8820, 19123, 8818, 19125, 8816, 19127, 8814, 19129, 8812, 19131, 8810, 19133, 8808, 19135, 8806, 19137, 8804, 19139, 8802, 19141, 8800, 19143, 8798, 19145, 8796, 19147, 8794, 19149, 8792, 19151, 8790, 19153, 8788, 19155, 8786, 19157, 8784, 19159, 8782, 19161, 8780, 19163, 8778, 19165, 8776, 19167, 8774, 19169, 8772, 19171, 8770, 19173, 8768, 19175, 8766, 19177, 8764, 19179, 8762, 19181, 8760, 19183, 8758, 19185, 8756, 19187, 8754, 19189, 8752, 19191, 8750, 19193, 8748, 19195, 8746, 19197, 8744, 19199, 8742, 19201, 8740, 19203, 8738, 19205, 8736, 19207, 8734, 19209, 8732, 19211, 8730, 19213, 8728, 19215, 8726, 19217, 8724, 19219, 8722, 19221, 8720, 19223, 8718, 19225, 8716, 19227, 8714, 19229, 8712, 19231, 8710, 19233, 8708, 19235, 8706, 19237, 8704, 19239, 8702, 19241, 8700, 19243, 8698, 19245, 8696, 19247, 8694, 19249, 8692, 19251, 8690, 19253, 8688, 19255, 8686, 19257, 8684, 19259, 8682, 19261, 8680, 19263, 8678, 19265, 8676, 19267, 8674, 19269, 8672, 19271, 8670, 19273, 8668, 19275, 8666, 19277, 8664, 19279, 8662, 19281, 8660, 19283, 8658, 19285, 8656, 19287, 8654, 19289, 8652, 19291, 8650, 19293, 8648, 19295, 8646, 19297, 8644, 19299, 8642, 19301, 8640, 19303, 8638, 19305, 8636, 19307, 8634, 19309, 8632, 19311, 8630, 19313, 8628, 19315, 8626, 19317, 8624, 19319, 8622, 19321, 8620, 19323, 8618, 19325, 8616, 19327, 8614, 19329, 8612, 19331, 8610, 19333, 8608, 19335, 8606, 19337, 8604, 19339, 8602, 19341, 8600, 19343, 8598, 19345, 8596, 19347, 8594, 19349, 8592, 19351, 8590, 19353, 8588, 19355, 8586, 19357, 8584, 19359, 8582, 19361, 8580, 19363, 8578, 19365, 8576, 19367, 8574, 19369, 8572, 19371, 8570, 19373, 8568, 19375, 8566, 19377, 8564, 19379, 8562, 19381, 8560, 19383, 8558, 19385, 8556, 19387, 8554, 19389, 8552, 19391, 8550, 19393, 8548, 19395, 8546, 19397, 8544, 19399, 8542, 19401, 8540, 19403, 8538, 19405, 8536, 19407, 8534, 19409, 8532, 19411, 8530, 19413, 8528, 19415, 8526, 19417, 8524, 19419, 8522, 19421, 8520, 19423, 8518, 19425, 8516, 19427, 8514, 19429, 8512, 19431, 8510, 19433, 8508, 19435, 8506, 19437, 8504, 19439, 8502, 19441, 8500, 19443, 8498, 19445, 8496, 19447, 8494, 19449, 8492, 19451, 8490, 19453, 8488, 19455, 8486, 19457, 8484, 19459, 8482, 19461, 8480, 19463, 8478, 19465, 8476, 19467, 8474, 19469, 8472, 19471, 8470, 19473, 8468, 19475, 8466, 19477, 8464, 19479, 8462, 19481, 8460, 19483, 8458, 19485, 8456, 19487, 8454, 19489, 8452, 19491, 8450, 19493, 8448, 19495, 8446, 19497, 8444, 19499, 8442, 19501, 8440, 19503, 8438, 19505, 8436, 19507, 8434, 19509, 8432, 19511, 8430, 19513, 8428, 19515, 8426, 19517, 8424, 19519, 8422, 19521, 8420, 19523, 8418, 19525, 8416, 19527, 8414, 19529, 8412, 19531, 8410, 19533, 8408, 19535, 8406, 19537, 8404, 19539, 8402, 19541, 8400, 19543, 8398, 19545, 8396, 19547, 8394, 19549, 8392, 19551, 8390, 19553, 8388, 19555, 8386, 19557, 8384, 19559, 8382, 19561, 8380, 19563, 8378, 19565, 8376, 19567, 8374, 19569, 8372, 19571, 8370, 19573, 8368, 19575, 8366, 19577, 8364, 19579, 8362, 19581, 8360, 19583, 8358, 19585, 8356, 19587, 8354, 19589, 8352, 19591, 8350, 19593, 8348, 19595, 8346, 19597, 8344, 19599, 8342, 19601, 8340, 19603, 8338, 19605, 8336, 19607, 8334, 19609, 8332, 19611, 8330, 19613, 8328, 19615, 8326, 19617, 8324, 19619, 8322, 19621, 8320, 19623, 8318, 19625, 8316, 19627, 8314, 19629, 8312, 19631, 8310, 19633, 8308, 19635, 8306, 19637, 8304, 19639, 8302, 19641, 8300, 19643, 8298, 19645, 8296, 19647, 8294, 19649, 8292, 19651, 8290, 19653, 8288, 19655, 8286, 19657, 8284, 19659, 8282, 19661, 8280, 19663, 8278, 19665, 8276, 19667, 8274, 19669, 8272, 19671, 8270, 19673, 8268, 19675, 8266, 19677, 8264, 19679, 8262, 19681, 8260, 19683, 8258, 19685, 8256, 19687, 8254, 19689, 8252, 19691, 8250, 19693, 8248, 19695, 8246, 19697, 8244, 19699, 8242, 19701, 8240, 19703, 8238, 19705, 8236, 19707, 8234, 19709, 8232, 19711, 8230, 19713, 8228, 19715, 8226, 19717, 8224, 19719, 8222, 19721, 8220, 19723, 8218, 19725, 8216, 19727, 8214, 19729, 8212, 19731, 8210, 19733, 8208, 19735, 8206, 19737, 8204, 19739, 8202, 19741, 8200, 19743, 8198, 19745, 8196, 19747, 8194, 19749, 8192, 19751, 8190, 19753, 8188, 19755, 8186, 19757, 8184, 19759, 8182, 19761, 8180, 19763, 8178, 19765, 8176, 19767, 8174, 19769, 8172, 19771, 8170, 19773, 8168, 19775, 8166, 19777, 8164, 19779, 8162, 19781, 8160, 19783, 8158, 19785, 8156, 19787, 8154, 19789, 8152, 19791, 8150, 19793, 8148, 19795, 8146, 19797, 8144, 19799, 8142, 19801, 8140, 19803, 8138, 19805, 8136, 19807, 8134, 19809, 8132, 19811, 8130, 19813, 8128, 19815, 8126, 19817, 8124, 19819, 8122, 19821, 8120, 19823, 8118, 19825, 8116, 19827, 8114, 19829, 8112, 19831, 8110, 19833, 8108, 19835, 8106, 19837, 8104, 19839, 8102, 19841, 8100, 19843, 8098, 19845, 8096, 19847, 8094, 19849, 8092, 19851, 8090, 19853, 8088, 19855, 8086, 19857, 8084, 19859, 8082, 19861, 8080, 19863, 8078, 19865, 8076, 19867, 8074, 19869, 8072, 19871, 8070, 19873, 8068, 19875, 8066, 19877, 8064, 19879, 8062, 19881, 8060, 19883, 8058, 19885, 8056, 19887, 8054, 19889, 8052, 19891, 8050, 19893, 8048, 19895, 8046, 19897, 8044, 19899, 8042, 19901, 8040, 19903, 8038, 19905, 8036, 19907, 8034, 19909, 8032, 19911, 8030, 19913, 8028, 19915, 8026, 19917, 8024, 19919, 8022, 19921, 8020, 19923, 8018, 19925, 8016, 19927, 8014, 19929, 8012, 19931, 8010, 19933, 8008, 19935, 8006, 19937, 8004, 19939, 8002, 19941, 8000, 19943, 7998, 19945, 7996, 19947, 7994, 19949, 7992, 19951, 7990, 19953, 7988, 19955, 7986, 19957, 7984, 19959, 7982, 19961, 7980, 19963, 7978, 19965, 7976, 19967, 7974, 19969, 7972, 19971, 7970, 19973, 7968, 19975, 7966, 19977, 7964, 19979, 7962, 19981, 7960, 19983, 7958, 19985, 7956, 19987, 7954, 19989, 7952, 19991, 7950, 19993, 7948, 19995, 7946, 19997, 7944, 19999, 7942, 20001, 7940, 20003, 7938, 20005, 7936, 20007, 7934, 20009, 7932, 20011, 7930, 20013, 7928, 20015, 7926, 20017, 7924, 20019, 7922, 20021, 7920, 20023, 7918, 20025, 7916, 20027, 7914, 20029, 7912, 20031, 7910, 20033, 7908, 20035, 7906, 20037, 7904, 20039, 7902, 20041, 7900, 20043, 7898, 20045, 7896, 20047, 7894, 20049, 7892, 20051, 7890, 20053, 7888, 20055, 7886, 20057, 7884, 20059, 7882, 20061, 7880, 20063, 7878, 20065, 7876, 20067, 7874, 20069, 7872, 20071, 7870, 20073, 7868, 20075, 7866, 20077, 7864, 20079, 7862, 20081, 7860, 20083, 7858, 20085, 7856, 20087, 7854, 20089, 7852, 20091, 7850, 20093, 7848, 20095, 7846, 20097, 7844, 20099, 7842, 20101, 7840, 20103, 7838, 20105, 7836, 20107, 7834, 20109, 7832, 20111, 7830, 20113, 7828, 20115, 7826, 20117, 7824, 20119, 7822, 20121, 7820, 20123, 7818, 20125, 7816, 20127, 7814, 20129, 7812, 20131, 7810, 20133, 7808, 20135, 7806, 20137, 7804, 20139, 7802, 20141, 7800, 20143, 7798, 20145, 7796, 20147, 7794, 20149, 7792, 20151, 7790, 20153, 7788, 20155, 7786, 20157, 7784, 20159, 7782, 20161, 7780, 20163, 7778, 20165, 7776, 20167, 7774, 20169, 7772, 20171, 7770, 20173, 7768, 20175, 7766, 20177, 7764, 20179, 7762, 20181, 7760, 20183, 7758, 20185, 7756, 20187, 7754, 20189, 7752, 20191, 7750, 20193, 7748, 20195, 7746, 20197, 7744, 20199, 7742, 20201, 7740, 20203, 7738, 20205, 7736, 20207, 7734, 20209, 7732, 20211, 7730, 20213, 7728, 20215, 7726, 20217, 7724, 20219, 7722, 20221, 7720, 20223, 7718, 20225, 7716, 20227, 7714, 20229, 7712, 20231, 7710, 20233, 7708, 20235, 7706, 20237, 7704, 20239, 7702, 20241, 7700, 20243, 7698, 20245, 7696, 20247, 7694, 20249, 7692, 20251, 7690, 20253, 7688, 20255, 7686, 20257, 7684, 20259, 7682, 20261, 7680, 20263, 7678, 20265, 7676, 20267, 7674, 20269, 7672, 20271, 7670, 20273, 7668, 20275, 7666, 20277, 7664, 20279, 7662, 20281, 7660, 20283, 7658, 20285, 7656, 20287, 7654, 20289, 7652, 20291, 7650, 20293, 7648, 20295, 7646, 20297, 7644, 20299, 7642, 20301, 7640, 20303, 7638, 20305, 7636, 20307, 7634, 20309, 7632, 20311, 7630, 20313, 7628, 20315, 7626, 20317, 7624, 20319, 7622, 20321, 7620, 20323, 7618, 20325, 7616, 20327, 7614, 20329, 7612, 20331, 7610, 20333, 7608, 20335, 7606, 20337, 7604, 20339, 7602, 20341, 7600, 20343, 7598, 20345, 7596, 20347, 7594, 20349, 7592, 20351, 7590, 20353, 7588, 20355, 7586, 20357, 7584, 20359, 7582, 20361, 7580, 20363, 7578, 20365, 7576, 20367, 7574, 20369, 7572, 20371, 7570, 20373, 7568, 20375, 7566, 20377, 7564, 20379, 7562, 20381, 7560, 20383, 7558, 20385, 7556, 20387, 7554, 20389, 7552, 20391, 7550, 20393, 7548, 20395, 7546, 20397, 7544, 20399, 7542, 20401, 7540, 20403, 7538, 20405, 7536, 20407, 7534, 20409, 7532, 20411, 7530, 20413, 7528, 20415, 7526, 20417, 7524, 20419, 7522, 20421, 7520, 20423, 7518, 20425, 7516, 20427, 7514, 20429, 7512, 20431, 7510, 20433, 7508, 20435, 7506, 20437, 7504, 20439, 7502, 20441, 7500, 20443, 7498, 20445, 7496, 20447, 7494, 20449, 7492, 20451, 7490, 20453, 7488, 20455, 7486, 20457, 7484, 20459, 7482, 20461, 7480, 20463, 7478, 20465, 7476, 20467, 7474, 20469, 7472, 20471, 7470, 20473, 7468, 20475, 7466, 20477, 7464, 20479, 7462, 20481, 7460, 20483, 7458, 20485, 7456, 20487, 7454, 20489, 7452, 20491, 7450, 20493, 7448, 20495, 7446, 20497, 7444, 20499, 7442, 20501, 7440, 20503, 7438, 20505, 7436, 20507, 7434, 20509, 7432, 20511, 7430, 20513, 7428, 20515, 7426, 20517, 7424, 20519, 7422, 20521, 7420, 20523, 7418, 20525, 7416, 20527, 7414, 20529, 7412, 20531, 7410, 20533, 7408, 20535, 7406, 20537, 7404, 20539, 7402, 20541, 7400, 20543, 7398, 20545, 7396, 20547, 7394, 20549, 7392, 20551, 7390, 20553, 7388, 20555, 7386, 20557, 7384, 20559, 7382, 20561, 7380, 20563, 7378, 20565, 7376, 20567, 7374, 20569, 7372, 20571, 7370, 20573, 7368, 20575, 7366, 20577, 7364, 20579, 7362, 20581, 7360, 20583, 7358, 20585, 7356, 20587, 7354, 20589, 7352, 20591, 7350, 20593, 7348, 20595, 7346, 20597, 7344, 20599, 7342, 20601, 7340, 20603, 7338, 20605, 7336, 20607, 7334, 20609, 7332, 20611, 7330, 20613, 7328, 20615, 7326, 20617, 7324, 20619, 7322, 20621, 7320, 20623, 7318, 20625, 7316, 20627, 7314, 20629, 7312, 20631, 7310, 20633, 7308, 20635, 7306, 20637, 7304, 20639, 7302, 20641, 7300, 20643, 7298, 20645, 7296, 20647, 7294, 20649, 7292, 20651, 7290, 20653, 7288, 20655, 7286, 20657, 7284, 20659, 7282, 20661, 7280, 20663, 7278, 20665, 7276, 20667, 7274, 20669, 7272, 20671, 7270, 20673, 7268, 20675, 7266, 20677, 7264, 20679, 7262, 20681, 7260, 20683, 7258, 20685, 7256, 20687, 7254, 20689, 7252, 20691, 7250, 20693, 7248, 20695, 7246, 20697, 7244, 20699, 7242, 20701, 7240, 20703, 7238, 20705, 7236, 20707, 7234, 20709, 7232, 20711, 7230, 20713, 7228, 20715, 7226, 20717, 7224, 20719, 7222, 20721, 7220, 20723, 7218, 20725, 7216, 20727, 7214, 20729, 7212, 20731, 7210, 20733, 7208, 20735, 7206, 20737, 7204, 20739, 7202, 20741, 7200, 20743, 7198, 20745, 7196, 20747, 7194, 20749, 7192, 20751, 7190, 20753, 7188, 20755, 7186, 20757, 7184, 20759, 7182, 20761, 7180, 20763, 7178, 20765, 7176, 20767, 7174, 20769, 7172, 20771, 7170, 20773, 7168, 20775, 7166, 20777, 7164, 20779, 7162, 20781, 7160, 20783, 7158, 20785, 7156, 20787, 7154, 20789, 7152, 20791, 7150, 20793, 7148, 20795, 7146, 20797, 7144, 20799, 7142, 20801, 7140, 20803, 7138, 20805, 7136, 20807, 7134, 20809, 7132, 20811, 7130, 20813, 7128, 20815, 7126, 20817, 7124, 20819, 7122, 20821, 7120, 20823, 7118, 20825, 7116, 20827, 7114, 20829, 7112, 20831, 7110, 20833, 7108, 20835, 7106, 20837, 7104, 20839, 7102, 20841, 7100, 20843, 7098, 20845, 7096, 20847, 7094, 20849, 7092, 20851, 7090, 20853, 7088, 20855, 7086, 20857, 7084, 20859, 7082, 20861, 7080, 20863, 7078, 20865, 7076, 20867, 7074, 20869, 7072, 20871, 7070, 20873, 7068, 20875, 7066, 20877, 7064, 20879, 7062, 20881, 7060, 20883, 7058, 20885, 7056, 20887, 7054, 20889, 7052, 20891, 7050, 20893, 7048, 20895, 7046, 20897, 7044, 20899, 7042, 20901, 7040, 20903, 7038, 20905, 7036, 20907, 7034, 20909, 7032, 20911, 7030, 20913, 7028, 20915, 7026, 20917, 7024, 20919, 7022, 20921, 7020, 20923, 7018, 20925, 7016, 20927, 7014, 20929, 7012, 20931, 7010, 20933, 7008, 20935, 7006, 20937, 7004, 20939, 7002, 20941, 7000, 20943, 6998, 20945, 6996, 20947, 6994, 20949, 6992, 20951, 6990, 20953, 6988, 20955, 6986, 20957, 6984, 20959, 6982, 20961, 6980, 20963, 6978, 20965, 6976, 20967, 6974, 20969, 6972, 20971, 6970, 20973, 6968, 20975, 6966, 20977, 6964, 20979, 6962, 20981, 6960, 20983, 6958, 20985, 6956, 20987, 6954, 20989, 6952, 20991, 6950, 20993, 6948, 20995, 6946, 20997, 6944, 20999, 6942, 21001, 6940, 21003, 6938, 21005, 6936, 21007, 6934, 21009, 6932, 21011, 6930, 21013, 6928, 21015, 6926, 21017, 6924, 21019, 6922, 21021, 6920, 21023, 6918, 21025, 6916, 21027, 6914, 21029, 6912, 21031, 6910, 21033, 6908, 21035, 6906, 21037, 6904, 21039, 6902, 21041, 6900, 21043, 6898, 21045, 6896, 21047, 6894, 21049, 6892, 21051, 6890, 21053, 6888, 21055, 6886, 21057, 6884, 21059, 6882, 21061, 6880, 21063, 6878, 21065, 6876, 21067, 6874, 21069, 6872, 21071, 6870, 21073, 6868, 21075, 6866, 21077, 6864, 21079, 6862, 21081, 6860, 21083, 6858, 21085, 6856, 21087, 6854, 21089, 6852, 21091, 6850, 21093, 6848, 21095, 6846, 21097, 6844, 21099, 6842, 21101, 6840, 21103, 6838, 21105, 6836, 21107, 6834, 21109, 6832, 21111, 6830, 21113, 6828, 21115, 6826, 21117, 6824, 21119, 6822, 21121, 6820, 21123, 6818, 21125, 6816, 21127, 6814, 21129, 6812, 21131, 6810, 21133, 6808, 21135, 6806, 21137, 6804, 21139, 6802, 21141, 6800, 21143, 6798, 21145, 6796, 21147, 6794, 21149, 6792, 21151, 6790, 21153, 6788, 21155, 6786, 21157, 6784, 21159, 6782, 21161, 6780, 21163, 6778, 21165, 6776, 21167, 6774, 21169, 6772, 21171, 6770, 21173, 6768, 21175, 6766, 21177, 6764, 21179, 6762, 21181, 6760, 21183, 6758, 21185, 6756, 21187, 6754, 21189, 6752, 21191, 6750, 21193, 6748, 21195, 6746, 21197, 6744, 21199, 6742, 21201, 6740, 21203, 6738, 21205, 6736, 21207, 6734, 21209, 6732, 21211, 6730, 21213, 6728, 21215, 6726, 21217, 6724, 21219, 6722, 21221, 6720, 21223, 6718, 21225, 6716, 21227, 6714, 21229, 6712, 21231, 6710, 21233, 6708, 21235, 6706, 21237, 6704, 21239, 6702, 21241, 6700, 21243, 6698, 21245, 6696, 21247, 6694, 21249, 6692, 21251, 6690, 21253, 6688, 21255, 6686, 21257, 6684, 21259, 6682, 21261, 6680, 21263, 6678, 21265, 6676, 21267, 6674, 21269, 6672, 21271, 6670, 21273, 6668, 21275, 6666, 21277, 6664, 21279, 6662, 21281, 6660, 21283, 6658, 21285, 6656, 21287, 6654, 21289, 6652, 21291, 6650, 21293, 6648, 21295, 6646, 21297, 6644, 21299, 6642, 21301, 6640, 21303, 6638, 21305, 6636, 21307, 6634, 21309, 6632, 21311, 6630, 21313, 6628, 21315, 6626, 21317, 6624, 21319, 6622, 21321, 6620, 21323, 6618, 21325, 6616, 21327, 6614, 21329, 6612, 21331, 6610, 21333, 6608, 21335, 6606, 21337, 6604, 21339, 6602, 21341, 6600, 21343, 6598, 21345, 6596, 21347, 6594, 21349, 6592, 21351, 6590, 21353, 6588, 21355, 6586, 21357, 6584, 21359, 6582, 21361, 6580, 21363, 6578, 21365, 6576, 21367, 6574, 21369, 6572, 21371, 6570, 21373, 6568, 21375, 6566, 21377, 6564, 21379, 6562, 21381, 6560, 21383, 6558, 21385, 6556, 21387, 6554, 21389, 6552, 21391, 6550, 21393, 6548, 21395, 6546, 21397, 6544, 21399, 6542, 21401, 6540, 21403, 6538, 21405, 6536, 21407, 6534, 21409, 6532, 21411, 6530, 21413, 6528, 21415, 6526, 21417, 6524, 21419, 6522, 21421, 6520, 21423, 6518, 21425, 6516, 21427, 6514, 21429, 6512, 21431, 6510, 21433, 6508, 21435, 6506, 21437, 6504, 21439, 6502, 21441, 6500, 21443, 6498, 21445, 6496, 21447, 6494, 21449, 6492, 21451, 6490, 21453, 6488, 21455, 6486, 21457, 6484, 21459, 6482, 21461, 6480, 21463, 6478, 21465, 6476, 21467, 6474, 21469, 6472, 21471, 6470, 21473, 6468, 21475, 6466, 21477, 6464, 21479, 6462, 21481, 6460, 21483, 6458, 21485, 6456, 21487, 6454, 21489, 6452, 21491, 6450, 21493, 6448, 21495, 6446, 21497, 6444, 21499, 6442, 21501, 6440, 21503, 6438, 21505, 6436, 21507, 6434, 21509, 6432, 21511, 6430, 21513, 6428, 21515, 6426, 21517, 6424, 21519, 6422, 21521, 6420, 21523, 6418, 21525, 6416, 21527, 6414, 21529, 6412, 21531, 6410, 21533, 6408, 21535, 6406, 21537, 6404, 21539, 6402, 21541, 6400, 21543, 6398, 21545, 6396, 21547, 6394, 21549, 6392, 21551, 6390, 21553, 6388, 21555, 6386, 21557, 6384, 21559, 6382, 21561, 6380, 21563, 6378, 21565, 6376, 21567, 6374, 21569, 6372, 21571, 6370, 21573, 6368, 21575, 6366, 21577, 6364, 21579, 6362, 21581, 6360, 21583, 6358, 21585, 6356, 21587, 6354, 21589, 6352, 21591, 6350, 21593, 6348, 21595, 6346, 21597, 6344, 21599, 6342, 21601, 6340, 21603, 6338, 21605, 6336, 21607, 6334, 21609, 6332, 21611, 6330, 21613, 6328, 21615, 6326, 21617, 6324, 21619, 6322, 21621, 6320, 21623, 6318, 21625, 6316, 21627, 6314, 21629, 6312, 21631, 6310, 21633, 6308, 21635, 6306, 21637, 6304, 21639, 6302, 21641, 6300, 21643, 6298, 21645, 6296, 21647, 6294, 21649, 6292, 21651, 6290, 21653, 6288, 21655, 6286, 21657, 6284, 21659, 6282, 21661, 6280, 21663, 6278, 21665, 6276, 21667, 6274, 21669, 6272, 21671, 6270, 21673, 6268, 21675, 6266, 21677, 6264, 21679, 6262, 21681, 6260, 21683, 6258, 21685, 6256, 21687, 6254, 21689, 6252, 21691, 6250, 21693, 6248, 21695, 6246, 21697, 6244, 21699, 6242, 21701, 6240, 21703, 6238, 21705, 6236, 21707, 6234, 21709, 6232, 21711, 6230, 21713, 6228, 21715, 6226, 21717, 6224, 21719, 6222, 21721, 6220, 21723, 6218, 21725, 6216, 21727, 6214, 21729, 6212, 21731, 6210, 21733, 6208, 21735, 6206, 21737, 6204, 21739, 6202, 21741, 6200, 21743, 6198, 21745, 6196, 21747, 6194, 21749, 6192, 21751, 6190, 21753, 6188, 21755, 6186, 21757, 6184, 21759, 6182, 21761, 6180, 21763, 6178, 21765, 6176, 21767, 6174, 21769, 6172, 21771, 6170, 21773, 6168, 21775, 6166, 21777, 6164, 21779, 6162, 21781, 6160, 21783, 6158, 21785, 6156, 21787, 6154, 21789, 6152, 21791, 6150, 21793, 6148, 21795, 6146, 21797, 6144, 21799, 6142, 21801, 6140, 21803, 6138, 21805, 6136, 21807, 6134, 21809, 6132, 21811, 6130, 21813, 6128, 21815, 6126, 21817, 6124, 21819, 6122, 21821, 6120, 21823, 6118, 21825, 6116, 21827, 6114, 21829, 6112, 21831, 6110, 21833, 6108, 21835, 6106, 21837, 6104, 21839, 6102, 21841, 6100, 21843, 6098, 21845, 6096, 21847, 6094, 21849, 6092, 21851, 6090, 21853, 6088, 21855, 6086, 21857, 6084, 21859, 6082, 21861, 6080, 21863, 6078, 21865, 6076, 21867, 6074, 21869, 6072, 21871, 6070, 21873, 6068, 21875, 6066, 21877, 6064, 21879, 6062, 21881, 6060, 21883, 6058, 21885, 6056, 21887, 6054, 21889, 6052, 21891, 6050, 21893, 6048, 21895, 6046, 21897, 6044, 21899, 6042, 21901, 6040, 21903, 6038, 21905, 6036, 21907, 6034, 21909, 6032, 21911, 6030, 21913, 6028, 21915, 6026, 21917, 6024, 21919, 6022, 21921, 6020, 21923, 6018, 21925, 6016, 21927, 6014, 21929, 6012, 21931, 6010, 21933, 6008, 21935, 6006, 21937, 6004, 21939, 6002, 21941, 6000, 21943, 5998, 21945, 5996, 21947, 5994, 21949, 5992, 21951, 5990, 21953, 5988, 21955, 5986, 21957, 5984, 21959, 5982, 21961, 5980, 21963, 5978, 21965, 5976, 21967, 5974, 21969, 5972, 21971, 5970, 21973, 5968, 21975, 5966, 21977, 5964, 21979, 5962, 21981, 5960, 21983, 5958, 21985, 5956, 21987, 5954, 21989, 5952, 21991, 5950, 21993, 5948, 21995, 5946, 21997, 5944, 21999, 5942, 22001, 5940, 22003, 5938, 22005, 5936, 22007, 5934, 22009, 5932, 22011, 5930, 22013, 5928, 22015, 5926, 22017, 5924, 22019, 5922, 22021, 5920, 22023, 5918, 22025, 5916, 22027, 5914, 22029, 5912, 22031, 5910, 22033, 5908, 22035, 5906, 22037, 5904, 22039, 5902, 22041, 5900, 22043, 5898, 22045, 5896, 22047, 5894, 22049, 5892, 22051, 5890, 22053, 5888, 22055, 5886, 22057, 5884, 22059, 5882, 22061, 5880, 22063, 5878, 22065, 5876, 22067, 5874, 22069, 5872, 22071, 5870, 22073, 5868, 22075, 5866, 22077, 5864, 22079, 5862, 22081, 5860, 22083, 5858, 22085, 5856, 22087, 5854, 22089, 5852, 22091, 5850, 22093, 5848, 22095, 5846, 22097, 5844, 22099, 5842, 22101, 5840, 22103, 5838, 22105, 5836, 22107, 5834, 22109, 5832, 22111, 5830, 22113, 5828, 22115, 5826, 22117, 5824, 22119, 5822, 22121, 5820, 22123, 5818, 22125, 5816, 22127, 5814, 22129, 5812, 22131, 5810, 22133, 5808, 22135, 5806, 22137, 5804, 22139, 5802, 22141, 5800, 22143, 5798, 22145, 5796, 22147, 5794, 22149, 5792, 22151, 5790, 22153, 5788, 22155, 5786, 22157, 5784, 22159, 5782, 22161, 5780, 22163, 5778, 22165, 5776, 22167, 5774, 22169, 5772, 22171, 5770, 22173, 5768, 22175, 5766, 22177, 5764, 22179, 5762, 22181, 5760, 22183, 5758, 22185, 5756, 22187, 5754, 22189, 5752, 22191, 5750, 22193, 5748, 22195, 5746, 22197, 5744, 22199, 5742, 22201, 5740, 22203, 5738, 22205, 5736, 22207, 5734, 22209, 5732, 22211, 5730, 22213, 5728, 22215, 5726, 22217, 5724, 22219, 5722, 22221, 5720, 22223, 5718, 22225, 5716, 22227, 5714, 22229, 5712, 22231, 5710, 22233, 5708, 22235, 5706, 22237, 5704, 22239, 5702, 22241, 5700, 22243, 5698, 22245, 5696, 22247, 5694, 22249, 5692, 22251, 5690, 22253, 5688, 22255, 5686, 22257, 5684, 22259, 5682, 22261, 5680, 22263, 5678, 22265, 5676, 22267, 5674, 22269, 5672, 22271, 5670, 22273, 5668, 22275, 5666, 22277, 5664, 22279, 5662, 22281, 5660, 22283, 5658, 22285, 5656, 22287, 5654, 22289, 5652, 22291, 5650, 22293, 5648, 22295, 5646, 22297, 5644, 22299, 5642, 22301, 5640, 22303, 5638, 22305, 5636, 22307, 5634, 22309, 5632, 22311, 5630, 22313, 5628, 22315, 5626, 22317, 5624, 22319, 5622, 22321, 5620, 22323, 5618, 22325, 5616, 22327, 5614, 22329, 5612, 22331, 5610, 22333, 5608, 22335, 5606, 22337, 5604, 22339, 5602, 22341, 5600, 22343, 5598, 22345, 5596, 22347, 5594, 22349, 5592, 22351, 5590, 22353, 5588, 22355, 5586, 22357, 5584, 22359, 5582, 22361, 5580, 22363, 5578, 22365, 5576, 22367, 5574, 22369, 5572, 22371, 5570, 22373, 5568, 22375, 5566, 22377, 5564, 22379, 5562, 22381, 5560, 22383, 5558, 22385, 5556, 22387, 5554, 22389, 5552, 22391, 5550, 22393, 5548, 22395, 5546, 22397, 5544, 22399, 5542, 22401, 5540, 22403, 5538, 22405, 5536, 22407, 5534, 22409, 5532, 22411, 5530, 22413, 5528, 22415, 5526, 22417, 5524, 22419, 5522, 22421, 5520, 22423, 5518, 22425, 5516, 22427, 5514, 22429, 5512, 22431, 5510, 22433, 5508, 22435, 5506, 22437, 5504, 22439, 5502, 22441, 5500, 22443, 5498, 22445, 5496, 22447, 5494, 22449, 5492, 22451, 5490, 22453, 5488, 22455, 5486, 22457, 5484, 22459, 5482, 22461, 5480, 22463, 5478, 22465, 5476, 22467, 5474, 22469, 5472, 22471, 5470, 22473, 5468, 22475, 5466, 22477, 5464, 22479, 5462, 22481, 5460, 22483, 5458, 22485, 5456, 22487, 5454, 22489, 5452, 22491, 5450, 22493, 5448, 22495, 5446, 22497, 5444, 22499, 5442, 22501, 5440, 22503, 5438, 22505, 5436, 22507, 5434, 22509, 5432, 22511, 5430, 22513, 5428, 22515, 5426, 22517, 5424, 22519, 5422, 22521, 5420, 22523, 5418, 22525, 5416, 22527, 5414, 22529, 5412, 22531, 5410, 22533, 5408, 22535, 5406, 22537, 5404, 22539, 5402, 22541, 5400, 22543, 5398, 22545, 5396, 22547, 5394, 22549, 5392, 22551, 5390, 22553, 5388, 22555, 5386, 22557, 5384, 22559, 5382, 22561, 5380, 22563, 5378, 22565, 5376, 22567, 5374, 22569, 5372, 22571, 5370, 22573, 5368, 22575, 5366, 22577, 5364, 22579, 5362, 22581, 5360, 22583, 5358, 22585, 5356, 22587, 5354, 22589, 5352, 22591, 5350, 22593, 5348, 22595, 5346, 22597, 5344, 22599, 5342, 22601, 5340, 22603, 5338, 22605, 5336, 22607, 5334, 22609, 5332, 22611, 5330, 22613, 5328, 22615, 5326, 22617, 5324, 22619, 5322, 22621, 5320, 22623, 5318, 22625, 5316, 22627, 5314, 22629, 5312, 22631, 5310, 22633, 5308, 22635, 5306, 22637, 5304, 22639, 5302, 22641, 5300, 22643, 5298, 22645, 5296, 22647, 5294, 22649, 5292, 22651, 5290, 22653, 5288, 22655, 5286, 22657, 5284, 22659, 5282, 22661, 5280, 22663, 5278, 22665, 5276, 22667, 5274, 22669, 5272, 22671, 5270, 22673, 5268, 22675, 5266, 22677, 5264, 22679, 5262, 22681, 5260, 22683, 5258, 22685, 5256, 22687, 5254, 22689, 5252, 22691, 5250, 22693, 5248, 22695, 5246, 22697, 5244, 22699, 5242, 22701, 5240, 22703, 5238, 22705, 5236, 22707, 5234, 22709, 5232, 22711, 5230, 22713, 5228, 22715, 5226, 22717, 5224, 22719, 5222, 22721, 5220, 22723, 5218, 22725, 5216, 22727, 5214, 22729, 5212, 22731, 5210, 22733, 5208, 22735, 5206, 22737, 5204, 22739, 5202, 22741, 5200, 22743, 5198, 22745, 5196, 22747, 5194, 22749, 5192, 22751, 5190, 22753, 5188, 22755, 5186, 22757, 5184, 22759, 5182, 22761, 5180, 22763, 5178, 22765, 5176, 22767, 5174, 22769, 5172, 22771, 5170, 22773, 5168, 22775, 5166, 22777, 5164, 22779, 5162, 22781, 5160, 22783, 5158, 22785, 5156, 22787, 5154, 22789, 5152, 22791, 5150, 22793, 5148, 22795, 5146, 22797, 5144, 22799, 5142, 22801, 5140, 22803, 5138, 22805, 5136, 22807, 5134, 22809, 5132, 22811, 5130, 22813, 5128, 22815, 5126, 22817, 5124, 22819, 5122, 22821, 5120, 22823, 5118, 22825, 5116, 22827, 5114, 22829, 5112, 22831, 5110, 22833, 5108, 22835, 5106, 22837, 5104, 22839, 5102, 22841, 5100, 22843, 5098, 22845, 5096, 22847, 5094, 22849, 5092, 22851, 5090, 22853, 5088, 22855, 5086, 22857, 5084, 22859, 5082, 22861, 5080, 22863, 5078, 22865, 5076, 22867, 5074, 22869, 5072, 22871, 5070, 22873, 5068, 22875, 5066, 22877, 5064, 22879, 5062, 22881, 5060, 22883, 5058, 22885, 5056, 22887, 5054, 22889, 5052, 22891, 5050, 22893, 5048, 22895, 5046, 22897, 5044, 22899, 5042, 22901, 5040, 22903, 5038, 22905, 5036, 22907, 5034, 22909, 5032, 22911, 5030, 22913, 5028, 22915, 5026, 22917, 5024, 22919, 5022, 22921, 5020, 22923, 5018, 22925, 5016, 22927, 5014, 22929, 5012, 22931, 5010, 22933, 5008, 22935, 5006, 22937, 5004, 22939, 5002, 22941, 5000, 22943, 4998, 22945, 4996, 22947, 4994, 22949, 4992, 22951, 4990, 22953, 4988, 22955, 4986, 22957, 4984, 22959, 4982, 22961, 4980, 22963, 4978, 22965, 4976, 22967, 4974, 22969, 4972, 22971, 4970, 22973, 4968, 22975, 4966, 22977, 4964, 22979, 4962, 22981, 4960, 22983, 4958, 22985, 4956, 22987, 4954, 22989, 4952, 22991, 4950, 22993, 4948, 22995, 4946, 22997, 4944, 22999, 4942, 23001, 4940, 23003, 4938, 23005, 4936, 23007, 4934, 23009, 4932, 23011, 4930, 23013, 4928, 23015, 4926, 23017, 4924, 23019, 4922, 23021, 4920, 23023, 4918, 23025, 4916, 23027, 4914, 23029, 4912, 23031, 4910, 23033, 4908, 23035, 4906, 23037, 4904, 23039, 4902, 23041, 4900, 23043, 4898, 23045, 4896, 23047, 4894, 23049, 4892, 23051, 4890, 23053, 4888, 23055, 4886, 23057, 4884, 23059, 4882, 23061, 4880, 23063, 4878, 23065, 4876, 23067, 4874, 23069, 4872, 23071, 4870, 23073, 4868, 23075, 4866, 23077, 4864, 23079, 4862, 23081, 4860, 23083, 4858, 23085, 4856, 23087, 4854, 23089, 4852, 23091, 4850, 23093, 4848, 23095, 4846, 23097, 4844, 23099, 4842, 23101, 4840, 23103, 4838, 23105, 4836, 23107, 4834, 23109, 4832, 23111, 4830, 23113, 4828, 23115, 4826, 23117, 4824, 23119, 4822, 23121, 4820, 23123, 4818, 23125, 4816, 23127, 4814, 23129, 4812, 23131, 4810, 23133, 4808, 23135, 4806, 23137, 4804, 23139, 4802, 23141, 4800, 23143, 4798, 23145, 4796, 23147, 4794, 23149, 4792, 23151, 4790, 23153, 4788, 23155, 4786, 23157, 4784, 23159, 4782, 23161, 4780, 23163, 4778, 23165, 4776, 23167, 4774, 23169, 4772, 23171, 4770, 23173, 4768, 23175, 4766, 23177, 4764, 23179, 4762, 23181, 4760, 23183, 4758, 23185, 4756, 23187, 4754, 23189, 4752, 23191, 4750, 23193, 4748, 23195, 4746, 23197, 4744, 23199, 4742, 23201, 4740, 23203, 4738, 23205, 4736, 23207, 4734, 23209, 4732, 23211, 4730, 23213, 4728, 23215, 4726, 23217, 4724, 23219, 4722, 23221, 4720, 23223, 4718, 23225, 4716, 23227, 4714, 23229, 4712, 23231, 4710, 23233, 4708, 23235, 4706, 23237, 4704, 23239, 4702, 23241, 4700, 23243, 4698, 23245, 4696, 23247, 4694, 23249, 4692, 23251, 4690, 23253, 4688, 23255, 4686, 23257, 4684, 23259, 4682, 23261, 4680, 23263, 4678, 23265, 4676, 23267, 4674, 23269, 4672, 23271, 4670, 23273, 4668, 23275, 4666, 23277, 4664, 23279, 4662, 23281, 4660, 23283, 4658, 23285, 4656, 23287, 4654, 23289, 4652, 23291, 4650, 23293, 4648, 23295, 4646, 23297, 4644, 23299, 4642, 23301, 4640, 23303, 4638, 23305, 4636, 23307, 4634, 23309, 4632, 23311, 4630, 23313, 4628, 23315, 4626, 23317, 4624, 23319, 4622, 23321, 4620, 23323, 4618, 23325, 4616, 23327, 4614, 23329, 4612, 23331, 4610, 23333, 4608, 23335, 4606, 23337, 4604, 23339, 4602, 23341, 4600, 23343, 4598, 23345, 4596, 23347, 4594, 23349, 4592, 23351, 4590, 23353, 4588, 23355, 4586, 23357, 4584, 23359, 4582, 23361, 4580, 23363, 4578, 23365, 4576, 23367, 4574, 23369, 4572, 23371, 4570, 23373, 4568, 23375, 4566, 23377, 4564, 23379, 4562, 23381, 4560, 23383, 4558, 23385, 4556, 23387, 4554, 23389, 4552, 23391, 4550, 23393, 4548, 23395, 4546, 23397, 4544, 23399, 4542, 23401, 4540, 23403, 4538, 23405, 4536, 23407, 4534, 23409, 4532, 23411, 4530, 23413, 4528, 23415, 4526, 23417, 4524, 23419, 4522, 23421, 4520, 23423, 4518, 23425, 4516, 23427, 4514, 23429, 4512, 23431, 4510, 23433, 4508, 23435, 4506, 23437, 4504, 23439, 4502, 23441, 4500, 23443, 4498, 23445, 4496, 23447, 4494, 23449, 4492, 23451, 4490, 23453, 4488, 23455, 4486, 23457, 4484, 23459, 4482, 23461, 4480, 23463, 4478, 23465, 4476, 23467, 4474, 23469, 4472, 23471, 4470, 23473, 4468, 23475, 4466, 23477, 4464, 23479, 4462, 23481, 4460, 23483, 4458, 23485, 4456, 23487, 4454, 23489, 4452, 23491, 4450, 23493, 4448, 23495, 4446, 23497, 4444, 23499, 4442, 23501, 4440, 23503, 4438, 23505, 4436, 23507, 4434, 23509, 4432, 23511, 4430, 23513, 4428, 23515, 4426, 23517, 4424, 23519, 4422, 23521, 4420, 23523, 4418, 23525, 4416, 23527, 4414, 23529, 4412, 23531, 4410, 23533, 4408, 23535, 4406, 23537, 4404, 23539, 4402, 23541, 4400, 23543, 4398, 23545, 4396, 23547, 4394, 23549, 4392, 23551, 4390, 23553, 4388, 23555, 4386, 23557, 4384, 23559, 4382, 23561, 4380, 23563, 4378, 23565, 4376, 23567, 4374, 23569, 4372, 23571, 4370, 23573, 4368, 23575, 4366, 23577, 4364, 23579, 4362, 23581, 4360, 23583, 4358, 23585, 4356, 23587, 4354, 23589, 4352, 23591, 4350, 23593, 4348, 23595, 4346, 23597, 4344, 23599, 4342, 23601, 4340, 23603, 4338, 23605, 4336, 23607, 4334, 23609, 4332, 23611, 4330, 23613, 4328, 23615, 4326, 23617, 4324, 23619, 4322, 23621, 4320, 23623, 4318, 23625, 4316, 23627, 4314, 23629, 4312, 23631, 4310, 23633, 4308, 23635, 4306, 23637, 4304, 23639, 4302, 23641, 4300, 23643, 4298, 23645, 4296, 23647, 4294, 23649, 4292, 23651, 4290, 23653, 4288, 23655, 4286, 23657, 4284, 23659, 4282, 23661, 4280, 23663, 4278, 23665, 4276, 23667, 4274, 23669, 4272, 23671, 4270, 23673, 4268, 23675, 4266, 23677, 4264, 23679, 4262, 23681, 4260, 23683, 4258, 23685, 4256, 23687, 4254, 23689, 4252, 23691, 4250, 23693, 4248, 23695, 4246, 23697, 4244, 23699, 4242, 23701, 4240, 23703, 4238, 23705, 4236, 23707, 4234, 23709, 4232, 23711, 4230, 23713, 4228, 23715, 4226, 23717, 4224, 23719, 4222, 23721, 4220, 23723, 4218, 23725, 4216, 23727, 4214, 23729, 4212, 23731, 4210, 23733, 4208, 23735, 4206, 23737, 4204, 23739, 4202, 23741, 4200, 23743, 4198, 23745, 4196, 23747, 4194, 23749, 4192, 23751, 4190, 23753, 4188, 23755, 4186, 23757, 4184, 23759, 4182, 23761, 4180, 23763, 4178, 23765, 4176, 23767, 4174, 23769, 4172, 23771, 4170, 23773, 4168, 23775, 4166, 23777, 4164, 23779, 4162, 23781, 4160, 23783, 4158, 23785, 4156, 23787, 4154, 23789, 4152, 23791, 4150, 23793, 4148, 23795, 4146, 23797, 4144, 23799, 4142, 23801, 4140, 23803, 4138, 23805, 4136, 23807, 4134, 23809, 4132, 23811, 4130, 23813, 4128, 23815, 4126, 23817, 4124, 23819, 4122, 23821, 4120, 23823, 4118, 23825, 4116, 23827, 4114, 23829, 4112, 23831, 4110, 23833, 4108, 23835, 4106, 23837, 4104, 23839, 4102, 23841, 4100, 23843, 4098, 23845, 4096, 23847, 4094, 23849, 4092, 23851, 4090, 23853, 4088, 23855, 4086, 23857, 4084, 23859, 4082, 23861, 4080, 23863, 4078, 23865, 4076, 23867, 4074, 23869, 4072, 23871, 4070, 23873, 4068, 23875, 4066, 23877, 4064, 23879, 4062, 23881, 4060, 23883, 4058, 23885, 4056, 23887, 4054, 23889, 4052, 23891, 4050, 23893, 4048, 23895, 4046, 23897, 4044, 23899, 4042, 23901, 4040, 23903, 4038, 23905, 4036, 23907, 4034, 23909, 4032, 23911, 4030, 23913, 4028, 23915, 4026, 23917, 4024, 23919, 4022, 23921, 4020, 23923, 4018, 23925, 4016, 23927, 4014, 23929, 4012, 23931, 4010, 23933, 4008, 23935, 4006, 23937, 4004, 23939, 4002, 23941, 4000, 23943, 3998, 23945, 3996, 23947, 3994, 23949, 3992, 23951, 3990, 23953, 3988, 23955, 3986, 23957, 3984, 23959, 3982, 23961, 3980, 23963, 3978, 23965, 3976, 23967, 3974, 23969, 3972, 23971, 3970, 23973, 3968, 23975, 3966, 23977, 3964, 23979, 3962, 23981, 3960, 23983, 3958, 23985, 3956, 23987, 3954, 23989, 3952, 23991, 3950, 23993, 3948, 23995, 3946, 23997, 3944, 23999, 3942, 24001, 3940, 24003, 3938, 24005, 3936, 24007, 3934, 24009, 3932, 24011, 3930, 24013, 3928, 24015, 3926, 24017, 3924, 24019, 3922, 24021, 3920, 24023, 3918, 24025, 3916, 24027, 3914, 24029, 3912, 24031, 3910, 24033, 3908, 24035, 3906, 24037, 3904, 24039, 3902, 24041, 3900, 24043, 3898, 24045, 3896, 24047, 3894, 24049, 3892, 24051, 3890, 24053, 3888, 24055, 3886, 24057, 3884, 24059, 3882, 24061, 3880, 24063, 3878, 24065, 3876, 24067, 3874, 24069, 3872, 24071, 3870, 24073, 3868, 24075, 3866, 24077, 3864, 24079, 3862, 24081, 3860, 24083, 3858, 24085, 3856, 24087, 3854, 24089, 3852, 24091, 3850, 24093, 3848, 24095, 3846, 24097, 3844, 24099, 3842, 24101, 3840, 24103, 3838, 24105, 3836, 24107, 3834, 24109, 3832, 24111, 3830, 24113, 3828, 24115, 3826, 24117, 3824, 24119, 3822, 24121, 3820, 24123, 3818, 24125, 3816, 24127, 3814, 24129, 3812, 24131, 3810, 24133, 3808, 24135, 3806, 24137, 3804, 24139, 3802, 24141, 3800, 24143, 3798, 24145, 3796, 24147, 3794, 24149, 3792, 24151, 3790, 24153, 3788, 24155, 3786, 24157, 3784, 24159, 3782, 24161, 3780, 24163, 3778, 24165, 3776, 24167, 3774, 24169, 3772, 24171, 3770, 24173, 3768, 24175, 3766, 24177, 3764, 24179, 3762, 24181, 3760, 24183, 3758, 24185, 3756, 24187, 3754, 24189, 3752, 24191, 3750, 24193, 3748, 24195, 3746, 24197, 3744, 24199, 3742, 24201, 3740, 24203, 3738, 24205, 3736, 24207, 3734, 24209, 3732, 24211, 3730, 24213, 3728, 24215, 3726, 24217, 3724, 24219, 3722, 24221, 3720, 24223, 3718, 24225, 3716, 24227, 3714, 24229, 3712, 24231, 3710, 24233, 3708, 24235, 3706, 24237, 3704, 24239, 3702, 24241, 3700, 24243, 3698, 24245, 3696, 24247, 3694, 24249, 3692, 24251, 3690, 24253, 3688, 24255, 3686, 24257, 3684, 24259, 3682, 24261, 3680, 24263, 3678, 24265, 3676, 24267, 3674, 24269, 3672, 24271, 3670, 24273, 3668, 24275, 3666, 24277, 3664, 24279, 3662, 24281, 3660, 24283, 3658, 24285, 3656, 24287, 3654, 24289, 3652, 24291, 3650, 24293, 3648, 24295, 3646, 24297, 3644, 24299, 3642, 24301, 3640, 24303, 3638, 24305, 3636, 24307, 3634, 24309, 3632, 24311, 3630, 24313, 3628, 24315, 3626, 24317, 3624, 24319, 3622, 24321, 3620, 24323, 3618, 24325, 3616, 24327, 3614, 24329, 3612, 24331, 3610, 24333, 3608, 24335, 3606, 24337, 3604, 24339, 3602, 24341, 3600, 24343, 3598, 24345, 3596, 24347, 3594, 24349, 3592, 24351, 3590, 24353, 3588, 24355, 3586, 24357, 3584, 24359, 3582, 24361, 3580, 24363, 3578, 24365, 3576, 24367, 3574, 24369, 3572, 24371, 3570, 24373, 3568, 24375, 3566, 24377, 3564, 24379, 3562, 24381, 3560, 24383, 3558, 24385, 3556, 24387, 3554, 24389, 3552, 24391, 3550, 24393, 3548, 24395, 3546, 24397, 3544, 24399, 3542, 24401, 3540, 24403, 3538, 24405, 3536, 24407, 3534, 24409, 3532, 24411, 3530, 24413, 3528, 24415, 3526, 24417, 3524, 24419, 3522, 24421, 3520, 24423, 3518, 24425, 3516, 24427, 3514, 24429, 3512, 24431, 3510, 24433, 3508, 24435, 3506, 24437, 3504, 24439, 3502, 24441, 3500, 24443, 3498, 24445, 3496, 24447, 3494, 24449, 3492, 24451, 3490, 24453, 3488, 24455, 3486, 24457, 3484, 24459, 3482, 24461, 3480, 24463, 3478, 24465, 3476, 24467, 3474, 24469, 3472, 24471, 3470, 24473, 3468, 24475, 3466, 24477, 3464, 24479, 3462, 24481, 3460, 24483, 3458, 24485, 3456, 24487, 3454, 24489, 3452, 24491, 3450, 24493, 3448, 24495, 3446, 24497, 3444, 24499, 3442, 24501, 3440, 24503, 3438, 24505, 3436, 24507, 3434, 24509, 3432, 24511, 3430, 24513, 3428, 24515, 3426, 24517, 3424, 24519, 3422, 24521, 3420, 24523, 3418, 24525, 3416, 24527, 3414, 24529, 3412, 24531, 3410, 24533, 3408, 24535, 3406, 24537, 3404, 24539, 3402, 24541, 3400, 24543, 3398, 24545, 3396, 24547, 3394, 24549, 3392, 24551, 3390, 24553, 3388, 24555, 3386, 24557, 3384, 24559, 3382, 24561, 3380, 24563, 3378, 24565, 3376, 24567, 3374, 24569, 3372, 24571, 3370, 24573, 3368, 24575, 3366, 24577, 3364, 24579, 3362, 24581, 3360, 24583, 3358, 24585, 3356, 24587, 3354, 24589, 3352, 24591, 3350, 24593, 3348, 24595, 3346, 24597, 3344, 24599, 3342, 24601, 3340, 24603, 3338, 24605, 3336, 24607, 3334, 24609, 3332, 24611, 3330, 24613, 3328, 24615, 3326, 24617, 3324, 24619, 3322, 24621, 3320, 24623, 3318, 24625, 3316, 24627, 3314, 24629, 3312, 24631, 3310, 24633, 3308, 24635, 3306, 24637, 3304, 24639, 3302, 24641, 3300, 24643, 3298, 24645, 3296, 24647, 3294, 24649, 3292, 24651, 3290, 24653, 3288, 24655, 3286, 24657, 3284, 24659, 3282, 24661, 3280, 24663, 3278, 24665, 3276, 24667, 3274, 24669, 3272, 24671, 3270, 24673, 3268, 24675, 3266, 24677, 3264, 24679, 3262, 24681, 3260, 24683, 3258, 24685, 3256, 24687, 3254, 24689, 3252, 24691, 3250, 24693, 3248, 24695, 3246, 24697, 3244, 24699, 3242, 24701, 3240, 24703, 3238, 24705, 3236, 24707, 3234, 24709, 3232, 24711, 3230, 24713, 3228, 24715, 3226, 24717, 3224, 24719, 3222, 24721, 3220, 24723, 3218, 24725, 3216, 24727, 3214, 24729, 3212, 24731, 3210, 24733, 3208, 24735, 3206, 24737, 3204, 24739, 3202, 24741, 3200, 24743, 3198, 24745, 3196, 24747, 3194, 24749, 3192, 24751, 3190, 24753, 3188, 24755, 3186, 24757, 3184, 24759, 3182, 24761, 3180, 24763, 3178, 24765, 3176, 24767, 3174, 24769, 3172, 24771, 3170, 24773, 3168, 24775, 3166, 24777, 3164, 24779, 3162, 24781, 3160, 24783, 3158, 24785, 3156, 24787, 3154, 24789, 3152, 24791, 3150, 24793, 3148, 24795, 3146, 24797, 3144, 24799, 3142, 24801, 3140, 24803, 3138, 24805, 3136, 24807, 3134, 24809, 3132, 24811, 3130, 24813, 3128, 24815, 3126, 24817, 3124, 24819, 3122, 24821, 3120, 24823, 3118, 24825, 3116, 24827, 3114, 24829, 3112, 24831, 3110, 24833, 3108, 24835, 3106, 24837, 3104, 24839, 3102, 24841, 3100, 24843, 3098, 24845, 3096, 24847, 3094, 24849, 3092, 24851, 3090, 24853, 3088, 24855, 3086, 24857, 3084, 24859, 3082, 24861, 3080, 24863, 3078, 24865, 3076, 24867, 3074, 24869, 3072, 24871, 3070, 24873, 3068, 24875, 3066, 24877, 3064, 24879, 3062, 24881, 3060, 24883, 3058, 24885, 3056, 24887, 3054, 24889, 3052, 24891, 3050, 24893, 3048, 24895, 3046, 24897, 3044, 24899, 3042, 24901, 3040, 24903, 3038, 24905, 3036, 24907, 3034, 24909, 3032, 24911, 3030, 24913, 3028, 24915, 3026, 24917, 3024, 24919, 3022, 24921, 3020, 24923, 3018, 24925, 3016, 24927, 3014, 24929, 3012, 24931, 3010, 24933, 3008, 24935, 3006, 24937, 3004, 24939, 3002, 24941, 3000, 24943, 2998, 24945, 2996, 24947, 2994, 24949, 2992, 24951, 2990, 24953, 2988, 24955, 2986, 24957, 2984, 24959, 2982, 24961, 2980, 24963, 2978, 24965, 2976, 24967, 2974, 24969, 2972, 24971, 2970, 24973, 2968, 24975, 2966, 24977, 2964, 24979, 2962, 24981, 2960, 24983, 2958, 24985, 2956, 24987, 2954, 24989, 2952, 24991, 2950, 24993, 2948, 24995, 2946, 24997, 2944, 24999, 2942, 25001, 2940, 25003, 2938, 25005, 2936, 25007, 2934, 25009, 2932, 25011, 2930, 25013, 2928, 25015, 2926, 25017, 2924, 25019, 2922, 25021, 2920, 25023, 2918, 25025, 2916, 25027, 2914, 25029, 2912, 25031, 2910, 25033, 2908, 25035, 2906, 25037, 2904, 25039, 2902, 25041, 2900, 25043, 2898, 25045, 2896, 25047, 2894, 25049, 2892, 25051, 2890, 25053, 2888, 25055, 2886, 25057, 2884, 25059, 2882, 25061, 2880, 25063, 2878, 25065, 2876, 25067, 2874, 25069, 2872, 25071, 2870, 25073, 2868, 25075, 2866, 25077, 2864, 25079, 2862, 25081, 2860, 25083, 2858, 25085, 2856, 25087, 2854, 25089, 2852, 25091, 2850, 25093, 2848, 25095, 2846, 25097, 2844, 25099, 2842, 25101, 2840, 25103, 2838, 25105, 2836, 25107, 2834, 25109, 2832, 25111, 2830, 25113, 2828, 25115, 2826, 25117, 2824, 25119, 2822, 25121, 2820, 25123, 2818, 25125, 2816, 25127, 2814, 25129, 2812, 25131, 2810, 25133, 2808, 25135, 2806, 25137, 2804, 25139, 2802, 25141, 2800, 25143, 2798, 25145, 2796, 25147, 2794, 25149, 2792, 25151, 2790, 25153, 2788, 25155, 2786, 25157, 2784, 25159, 2782, 25161, 2780, 25163, 2778, 25165, 2776, 25167, 2774, 25169, 2772, 25171, 2770, 25173, 2768, 25175, 2766, 25177, 2764, 25179, 2762, 25181, 2760, 25183, 2758, 25185, 2756, 25187, 2754, 25189, 2752, 25191, 2750, 25193, 2748, 25195, 2746, 25197, 2744, 25199, 2742, 25201, 2740, 25203, 2738, 25205, 2736, 25207, 2734, 25209, 2732, 25211, 2730, 25213, 2728, 25215, 2726, 25217, 2724, 25219, 2722, 25221, 2720, 25223, 2718, 25225, 2716, 25227, 2714, 25229, 2712, 25231, 2710, 25233, 2708, 25235, 2706, 25237, 2704, 25239, 2702, 25241, 2700, 25243, 2698, 25245, 2696, 25247, 2694, 25249, 2692, 25251, 2690, 25253, 2688, 25255, 2686, 25257, 2684, 25259, 2682, 25261, 2680, 25263, 2678, 25265, 2676, 25267, 2674, 25269, 2672, 25271, 2670, 25273, 2668, 25275, 2666, 25277, 2664, 25279, 2662, 25281, 2660, 25283, 2658, 25285, 2656, 25287, 2654, 25289, 2652, 25291, 2650, 25293, 2648, 25295, 2646, 25297, 2644, 25299, 2642, 25301, 2640, 25303, 2638, 25305, 2636, 25307, 2634, 25309, 2632, 25311, 2630, 25313, 2628, 25315, 2626, 25317, 2624, 25319, 2622, 25321, 2620, 25323, 2618, 25325, 2616, 25327, 2614, 25329, 2612, 25331, 2610, 25333, 2608, 25335, 2606, 25337, 2604, 25339, 2602, 25341, 2600, 25343, 2598, 25345, 2596, 25347, 2594, 25349, 2592, 25351, 2590, 25353, 2588, 25355, 2586, 25357, 2584, 25359, 2582, 25361, 2580, 25363, 2578, 25365, 2576, 25367, 2574, 25369, 2572, 25371, 2570, 25373, 2568, 25375, 2566, 25377, 2564, 25379, 2562, 25381, 2560, 25383, 2558, 25385, 2556, 25387, 2554, 25389, 2552, 25391, 2550, 25393, 2548, 25395, 2546, 25397, 2544, 25399, 2542, 25401, 2540, 25403, 2538, 25405, 2536, 25407, 2534, 25409, 2532, 25411, 2530, 25413, 2528, 25415, 2526, 25417, 2524, 25419, 2522, 25421, 2520, 25423, 2518, 25425, 2516, 25427, 2514, 25429, 2512, 25431, 2510, 25433, 2508, 25435, 2506, 25437, 2504, 25439, 2502, 25441, 2500, 25443, 2498, 25445, 2496, 25447, 2494, 25449, 2492, 25451, 2490, 25453, 2488, 25455, 2486, 25457, 2484, 25459, 2482, 25461, 2480, 25463, 2478, 25465, 2476, 25467, 2474, 25469, 2472, 25471, 2470, 25473, 2468, 25475, 2466, 25477, 2464, 25479, 2462, 25481, 2460, 25483, 2458, 25485, 2456, 25487, 2454, 25489, 2452, 25491, 2450, 25493, 2448, 25495, 2446, 25497, 2444, 25499, 2442, 25501, 2440, 25503, 2438, 25505, 2436, 25507, 2434, 25509, 2432, 25511, 2430, 25513, 2428, 25515, 2426, 25517, 2424, 25519, 2422, 25521, 2420, 25523, 2418, 25525, 2416, 25527, 2414, 25529, 2412, 25531, 2410, 25533, 2408, 25535, 2406, 25537, 2404, 25539, 2402, 25541, 2400, 25543, 2398, 25545, 2396, 25547, 2394, 25549, 2392, 25551, 2390, 25553, 2388, 25555, 2386, 25557, 2384, 25559, 2382, 25561, 2380, 25563, 2378, 25565, 2376, 25567, 2374, 25569, 2372, 25571, 2370, 25573, 2368, 25575, 2366, 25577, 2364, 25579, 2362, 25581, 2360, 25583, 2358, 25585, 2356, 25587, 2354, 25589, 2352, 25591, 2350, 25593, 2348, 25595, 2346, 25597, 2344, 25599, 2342, 25601, 2340, 25603, 2338, 25605, 2336, 25607, 2334, 25609, 2332, 25611, 2330, 25613, 2328, 25615, 2326, 25617, 2324, 25619, 2322, 25621, 2320, 25623, 2318, 25625, 2316, 25627, 2314, 25629, 2312, 25631, 2310, 25633, 2308, 25635, 2306, 25637, 2304, 25639, 2302, 25641, 2300, 25643, 2298, 25645, 2296, 25647, 2294, 25649, 2292, 25651, 2290, 25653, 2288, 25655, 2286, 25657, 2284, 25659, 2282, 25661, 2280, 25663, 2278, 25665, 2276, 25667, 2274, 25669, 2272, 25671, 2270, 25673, 2268, 25675, 2266, 25677, 2264, 25679, 2262, 25681, 2260, 25683, 2258, 25685, 2256, 25687, 2254, 25689, 2252, 25691, 2250, 25693, 2248, 25695, 2246, 25697, 2244, 25699, 2242, 25701, 2240, 25703, 2238, 25705, 2236, 25707, 2234, 25709, 2232, 25711, 2230, 25713, 2228, 25715, 2226, 25717, 2224, 25719, 2222, 25721, 2220, 25723, 2218, 25725, 2216, 25727, 2214, 25729, 2212, 25731, 2210, 25733, 2208, 25735, 2206, 25737, 2204, 25739, 2202, 25741, 2200, 25743, 2198, 25745, 2196, 25747, 2194, 25749, 2192, 25751, 2190, 25753, 2188, 25755, 2186, 25757, 2184, 25759, 2182, 25761, 2180, 25763, 2178, 25765, 2176, 25767, 2174, 25769, 2172, 25771, 2170, 25773, 2168, 25775, 2166, 25777, 2164, 25779, 2162, 25781, 2160, 25783, 2158, 25785, 2156, 25787, 2154, 25789, 2152, 25791, 2150, 25793, 2148, 25795, 2146, 25797, 2144, 25799, 2142, 25801, 2140, 25803, 2138, 25805, 2136, 25807, 2134, 25809, 2132, 25811, 2130, 25813, 2128, 25815, 2126, 25817, 2124, 25819, 2122, 25821, 2120, 25823, 2118, 25825, 2116, 25827, 2114, 25829, 2112, 25831, 2110, 25833, 2108, 25835, 2106, 25837, 2104, 25839, 2102, 25841, 2100, 25843, 2098, 25845, 2096, 25847, 2094, 25849, 2092, 25851, 2090, 25853, 2088, 25855, 2086, 25857, 2084, 25859, 2082, 25861, 2080, 25863, 2078, 25865, 2076, 25867, 2074, 25869, 2072, 25871, 2070, 25873, 2068, 25875, 2066, 25877, 2064, 25879, 2062, 25881, 2060, 25883, 2058, 25885, 2056, 25887, 2054, 25889, 2052, 25891, 2050, 25893, 2048, 25895, 2046, 25897, 2044, 25899, 2042, 25901, 2040, 25903, 2038, 25905, 2036, 25907, 2034, 25909, 2032, 25911, 2030, 25913, 2028, 25915, 2026, 25917, 2024, 25919, 2022, 25921, 2020, 25923, 2018, 25925, 2016, 25927, 2014, 25929, 2012, 25931, 2010, 25933, 2008, 25935, 2006, 25937, 2004, 25939, 2002, 25941, 2000, 25943, 1998, 25945, 1996, 25947, 1994, 25949, 1992, 25951, 1990, 25953, 1988, 25955, 1986, 25957, 1984, 25959, 1982, 25961, 1980, 25963, 1978, 25965, 1976, 25967, 1974, 25969, 1972, 25971, 1970, 25973, 1968, 25975, 1966, 25977, 1964, 25979, 1962, 25981, 1960, 25983, 1958, 25985, 1956, 25987, 1954, 25989, 1952, 25991, 1950, 25993, 1948, 25995, 1946, 25997, 1944, 25999, 1942, 26001, 1940, 26003, 1938, 26005, 1936, 26007, 1934, 26009, 1932, 26011, 1930, 26013, 1928, 26015, 1926, 26017, 1924, 26019, 1922, 26021, 1920, 26023, 1918, 26025, 1916, 26027, 1914, 26029, 1912, 26031, 1910, 26033, 1908, 26035, 1906, 26037, 1904, 26039, 1902, 26041, 1900, 26043, 1898, 26045, 1896, 26047, 1894, 26049, 1892, 26051, 1890, 26053, 1888, 26055, 1886, 26057, 1884, 26059, 1882, 26061, 1880, 26063, 1878, 26065, 1876, 26067, 1874, 26069, 1872, 26071, 1870, 26073, 1868, 26075, 1866, 26077, 1864, 26079, 1862, 26081, 1860, 26083, 1858, 26085, 1856, 26087, 1854, 26089, 1852, 26091, 1850, 26093, 1848, 26095, 1846, 26097, 1844, 26099, 1842, 26101, 1840, 26103, 1838, 26105, 1836, 26107, 1834, 26109, 1832, 26111, 1830, 26113, 1828, 26115, 1826, 26117, 1824, 26119, 1822, 26121, 1820, 26123, 1818, 26125, 1816, 26127, 1814, 26129, 1812, 26131, 1810, 26133, 1808, 26135, 1806, 26137, 1804, 26139, 1802, 26141, 1800, 26143, 1798, 26145, 1796, 26147, 1794, 26149, 1792, 26151, 1790, 26153, 1788, 26155, 1786, 26157, 1784, 26159, 1782, 26161, 1780, 26163, 1778, 26165, 1776, 26167, 1774, 26169, 1772, 26171, 1770, 26173, 1768, 26175, 1766, 26177, 1764, 26179, 1762, 26181, 1760, 26183, 1758, 26185, 1756, 26187, 1754, 26189, 1752, 26191, 1750, 26193, 1748, 26195, 1746, 26197, 1744, 26199, 1742, 26201, 1740, 26203, 1738, 26205, 1736, 26207, 1734, 26209, 1732, 26211, 1730, 26213, 1728, 26215, 1726, 26217, 1724, 26219, 1722, 26221, 1720, 26223, 1718, 26225, 1716, 26227, 1714, 26229, 1712, 26231, 1710, 26233, 1708, 26235, 1706, 26237, 1704, 26239, 1702, 26241, 1700, 26243, 1698, 26245, 1696, 26247, 1694, 26249, 1692, 26251, 1690, 26253, 1688, 26255, 1686, 26257, 1684, 26259, 1682, 26261, 1680, 26263, 1678, 26265, 1676, 26267, 1674, 26269, 1672, 26271, 1670, 26273, 1668, 26275, 1666, 26277, 1664, 26279, 1662, 26281, 1660, 26283, 1658, 26285, 1656, 26287, 1654, 26289, 1652, 26291, 1650, 26293, 1648, 26295, 1646, 26297, 1644, 26299, 1642, 26301, 1640, 26303, 1638, 26305, 1636, 26307, 1634, 26309, 1632, 26311, 1630, 26313, 1628, 26315, 1626, 26317, 1624, 26319, 1622, 26321, 1620, 26323, 1618, 26325, 1616, 26327, 1614, 26329, 1612, 26331, 1610, 26333, 1608, 26335, 1606, 26337, 1604, 26339, 1602, 26341, 1600, 26343, 1598, 26345, 1596, 26347, 1594, 26349, 1592, 26351, 1590, 26353, 1588, 26355, 1586, 26357, 1584, 26359, 1582, 26361, 1580, 26363, 1578, 26365, 1576, 26367, 1574, 26369, 1572, 26371, 1570, 26373, 1568, 26375, 1566, 26377, 1564, 26379, 1562, 26381, 1560, 26383, 1558, 26385, 1556, 26387, 1554, 26389, 1552, 26391, 1550, 26393, 1548, 26395, 1546, 26397, 1544, 26399, 1542, 26401, 1540, 26403, 1538, 26405, 1536, 26407, 1534, 26409, 1532, 26411, 1530, 26413, 1528, 26415, 1526, 26417, 1524, 26419, 1522, 26421, 1520, 26423, 1518, 26425, 1516, 26427, 1514, 26429, 1512, 26431, 1510, 26433, 1508, 26435, 1506, 26437, 1504, 26439, 1502, 26441, 1500, 26443, 1498, 26445, 1496, 26447, 1494, 26449, 1492, 26451, 1490, 26453, 1488, 26455, 1486, 26457, 1484, 26459, 1482, 26461, 1480, 26463, 1478, 26465, 1476, 26467, 1474, 26469, 1472, 26471, 1470, 26473, 1468, 26475, 1466, 26477, 1464, 26479, 1462, 26481, 1460, 26483, 1458, 26485, 1456, 26487, 1454, 26489, 1452, 26491, 1450, 26493, 1448, 26495, 1446, 26497, 1444, 26499, 1442, 26501, 1440, 26503, 1438, 26505, 1436, 26507, 1434, 26509, 1432, 26511, 1430, 26513, 1428, 26515, 1426, 26517, 1424, 26519, 1422, 26521, 1420, 26523, 1418, 26525, 1416, 26527, 1414, 26529, 1412, 26531, 1410, 26533, 1408, 26535, 1406, 26537, 1404, 26539, 1402, 26541, 1400, 26543, 1398, 26545, 1396, 26547, 1394, 26549, 1392, 26551, 1390, 26553, 1388, 26555, 1386, 26557, 1384, 26559, 1382, 26561, 1380, 26563, 1378, 26565, 1376, 26567, 1374, 26569, 1372, 26571, 1370, 26573, 1368, 26575, 1366, 26577, 1364, 26579, 1362, 26581, 1360, 26583, 1358, 26585, 1356, 26587, 1354, 26589, 1352, 26591, 1350, 26593, 1348, 26595, 1346, 26597, 1344, 26599, 1342, 26601, 1340, 26603, 1338, 26605, 1336, 26607, 1334, 26609, 1332, 26611, 1330, 26613, 1328, 26615, 1326, 26617, 1324, 26619, 1322, 26621, 1320, 26623, 1318, 26625, 1316, 26627, 1314, 26629, 1312, 26631, 1310, 26633, 1308, 26635, 1306, 26637, 1304, 26639, 1302, 26641, 1300, 26643, 1298, 26645, 1296, 26647, 1294, 26649, 1292, 26651, 1290, 26653, 1288, 26655, 1286, 26657, 1284, 26659, 1282, 26661, 1280, 26663, 1278, 26665, 1276, 26667, 1274, 26669, 1272, 26671, 1270, 26673, 1268, 26675, 1266, 26677, 1264, 26679, 1262, 26681, 1260, 26683, 1258, 26685, 1256, 26687, 1254, 26689, 1252, 26691, 1250, 26693, 1248, 26695, 1246, 26697, 1244, 26699, 1242, 26701, 1240, 26703, 1238, 26705, 1236, 26707, 1234, 26709, 1232, 26711, 1230, 26713, 1228, 26715, 1226, 26717, 1224, 26719, 1222, 26721, 1220, 26723, 1218, 26725, 1216, 26727, 1214, 26729, 1212, 26731, 1210, 26733, 1208, 26735, 1206, 26737, 1204, 26739, 1202, 26741, 1200, 26743, 1198, 26745, 1196, 26747, 1194, 26749, 1192, 26751, 1190, 26753, 1188, 26755, 1186, 26757, 1184, 26759, 1182, 26761, 1180, 26763, 1178, 26765, 1176, 26767, 1174, 26769, 1172, 26771, 1170, 26773, 1168, 26775, 1166, 26777, 1164, 26779, 1162, 26781, 1160, 26783, 1158, 26785, 1156, 26787, 1154, 26789, 1152, 26791, 1150, 26793, 1148, 26795, 1146, 26797, 1144, 26799, 1142, 26801, 1140, 26803, 1138, 26805, 1136, 26807, 1134, 26809, 1132, 26811, 1130, 26813, 1128, 26815, 1126, 26817, 1124, 26819, 1122, 26821, 1120, 26823, 1118, 26825, 1116, 26827, 1114, 26829, 1112, 26831, 1110, 26833, 1108, 26835, 1106, 26837, 1104, 26839, 1102, 26841, 1100, 26843, 1098, 26845, 1096, 26847, 1094, 26849, 1092, 26851, 1090, 26853, 1088, 26855, 1086, 26857, 1084, 26859, 1082, 26861, 1080, 26863, 1078, 26865, 1076, 26867, 1074, 26869, 1072, 26871, 1070, 26873, 1068, 26875, 1066, 26877, 1064, 26879, 1062, 26881, 1060, 26883, 1058, 26885, 1056, 26887, 1054, 26889, 1052, 26891, 1050, 26893, 1048, 26895, 1046, 26897, 1044, 26899, 1042, 26901, 1040, 26903, 1038, 26905, 1036, 26907, 1034, 26909, 1032, 26911, 1030, 26913, 1028, 26915, 1026, 26917, 1024, 26919, 1022, 26921, 1020, 26923, 1018, 26925, 1016, 26927, 1014, 26929, 1012, 26931, 1010, 26933, 1008, 26935, 1006, 26937, 1004, 26939, 1002, 26941, 1000, 26943, 998, 26945, 996, 26947, 994, 26949, 992, 26951, 990, 26953, 988, 26955, 986, 26957, 984, 26959, 982, 26961, 980, 26963, 978, 26965, 976, 26967, 974, 26969, 972, 26971, 970, 26973, 968, 26975, 966, 26977, 964, 26979, 962, 26981, 960, 26983, 958, 26985, 956, 26987, 954, 26989, 952, 26991, 950, 26993, 948, 26995, 946, 26997, 944, 26999, 942, 27001, 940, 27003, 938, 27005, 936, 27007, 934, 27009, 932, 27011, 930, 27013, 928, 27015, 926, 27017, 924, 27019, 922, 27021, 920, 27023, 918, 27025, 916, 27027, 914, 27029, 912, 27031, 910, 27033, 908, 27035, 906, 27037, 904, 27039, 902, 27041, 900, 27043, 898, 27045, 896, 27047, 894, 27049, 892, 27051, 890, 27053, 888, 27055, 886, 27057, 884, 27059, 882, 27061, 880, 27063, 878, 27065, 876, 27067, 874, 27069, 872, 27071, 870, 27073, 868, 27075, 866, 27077, 864, 27079, 862, 27081, 860, 27083, 858, 27085, 856, 27087, 854, 27089, 852, 27091, 850, 27093, 848, 27095, 846, 27097, 844, 27099, 842, 27101, 840, 27103, 838, 27105, 836, 27107, 834, 27109, 832, 27111, 830, 27113, 828, 27115, 826, 27117, 824, 27119, 822, 27121, 820, 27123, 818, 27125, 816, 27127, 814, 27129, 812, 27131, 810, 27133, 808, 27135, 806, 27137, 804, 27139, 802, 27141, 800, 27143, 798, 27145, 796, 27147, 794, 27149, 792, 27151, 790, 27153, 788, 27155, 786, 27157, 784, 27159, 782, 27161, 780, 27163, 778, 27165, 776, 27167, 774, 27169, 772, 27171, 770, 27173, 768, 27175, 766, 27177, 764, 27179, 762, 27181, 760, 27183, 758, 27185, 756, 27187, 754, 27189, 752, 27191, 750, 27193, 748, 27195, 746, 27197, 744, 27199, 742, 27201, 740, 27203, 738, 27205, 736, 27207, 734, 27209, 732, 27211, 730, 27213, 728, 27215, 726, 27217, 724, 27219, 722, 27221, 720, 27223, 718, 27225, 716, 27227, 714, 27229, 712, 27231, 710, 27233, 708, 27235, 706, 27237, 704, 27239, 702, 27241, 700, 27243, 698, 27245, 696, 27247, 694, 27249, 692, 27251, 690, 27253, 688, 27255, 686, 27257, 684, 27259, 682, 27261, 680, 27263, 678, 27265, 676, 27267, 674, 27269, 672, 27271, 670, 27273, 668, 27275, 666, 27277, 664, 27279, 662, 27281, 660, 27283, 658, 27285, 656, 27287, 654, 27289, 652, 27291, 650, 27293, 648, 27295, 646, 27297, 644, 27299, 642, 27301, 640, 27303, 638, 27305, 636, 27307, 634, 27309, 632, 27311, 630, 27313, 628, 27315, 626, 27317, 624, 27319, 622, 27321, 620, 27323, 618, 27325, 616, 27327, 614, 27329, 612, 27331, 610, 27333, 608, 27335, 606, 27337, 604, 27339, 602, 27341, 600, 27343, 598, 27345, 596, 27347, 594, 27349, 592, 27351, 590, 27353, 588, 27355, 586, 27357, 584, 27359, 582, 27361, 580, 27363, 578, 27365, 576, 27367, 574, 27369, 572, 27371, 570, 27373, 568, 27375, 566, 27377, 564, 27379, 562, 27381, 560, 27383, 558, 27385, 556, 27387, 554, 27389, 552, 27391, 550, 27393, 548, 27395, 546, 27397, 544, 27399, 542, 27401, 540, 27403, 538, 27405, 536, 27407, 534, 27409, 532, 27411, 530, 27413, 528, 27415, 526, 27417, 524, 27419, 522, 27421, 520, 27423, 518, 27425, 516, 27427, 514, 27429, 512, 27431, 510, 27433, 508, 27435, 506, 27437, 504, 27439, 502, 27441, 500, 27443, 498, 27445, 496, 27447, 494, 27449, 492, 27451, 490, 27453, 488, 27455, 486, 27457, 484, 27459, 482, 27461, 480, 27463, 478, 27465, 476, 27467, 474, 27469, 472, 27471, 470, 27473, 468, 27475, 466, 27477, 464, 27479, 462, 27481, 460, 27483, 458, 27485, 456, 27487, 454, 27489, 452, 27491, 450, 27493, 448, 27495, 446, 27497, 444, 27499, 442, 27501, 440, 27503, 438, 27505, 436, 27507, 434, 27509, 432, 27511, 430, 27513, 428, 27515, 426, 27517, 424, 27519, 422, 27521, 420, 27523, 418, 27525, 416, 27527, 414, 27529, 412, 27531, 410, 27533, 408, 27535, 406, 27537, 404, 27539, 402, 27541, 400, 27543, 398, 27545, 396, 27547, 394, 27549, 392, 27551, 390, 27553, 388, 27555, 386, 27557, 384, 27559, 382, 27561, 380, 27563, 378, 27565, 376, 27567, 374, 27569, 372, 27571, 370, 27573, 368, 27575, 366, 27577, 364, 27579, 362, 27581, 360, 27583, 358, 27585, 356, 27587, 354, 27589, 352, 27591, 350, 27593, 348, 27595, 346, 27597, 344, 27599, 342, 27601, 340, 27603, 338, 27605, 336, 27607, 334, 27609, 332, 27611, 330, 27613, 328, 27615, 326, 27617, 324, 27619, 322, 27621, 320, 27623, 318, 27625, 316, 27627, 314, 27629, 312, 27631, 310, 27633, 308, 27635, 306, 27637, 304, 27639, 302, 27641, 300, 27643, 298, 27645, 296, 27647, 294, 27649, 292, 27651, 290, 27653, 288, 27655, 286, 27657, 284, 27659, 282, 27661, 280, 27663, 278, 27665, 276, 27667, 274, 27669, 272, 27671, 270, 27673, 268, 27675, 266, 27677, 264, 27679, 262, 27681, 260, 27683, 258, 27685, 256, 27687, 254, 27689, 252, 27691, 250, 27693, 248, 27695, 246, 27697, 244, 27699, 242, 27701, 240, 27703, 238, 27705, 236, 27707, 234, 27709, 232, 27711, 230, 27713, 228, 27715, 226, 27717, 224, 27719, 222, 27721, 220, 27723, 218, 27725, 216, 27727, 214, 27729, 212, 27731, 210, 27733, 208, 27735, 206, 27737, 204, 27739, 202, 27741, 200, 27743, 198, 27745, 196, 27747, 194, 27749, 192, 27751, 190, 27753, 188, 27755, 186, 27757, 184, 27759, 182, 27761, 180, 27763, 178, 27765, 176, 27767, 174, 27769, 172, 27771, 170, 27773, 168, 27775, 166, 27777, 164, 27779, 162, 27781, 160, 27783, 158, 27785, 156, 27787, 154, 27789, 152, 27791, 150, 27793, 148, 27795, 146, 27797, 144, 27799, 142, 27801, 140, 27803, 138, 27805, 136, 27807, 134, 27809, 132, 27811, 130, 27813, 128, 27815, 126, 27817, 124, 27819, 122, 27821, 120, 27823, 118, 27825, 116, 27827, 114, 27829, 112, 27831, 110, 27833, 108, 27835, 106, 27837, 104, 27839, 102, 27841, 100, 27843, 98, 27845, 96, 27847, 94, 27849, 92, 27851, 90, 27853, 88, 27855, 86, 27857, 84, 27859, 82, 27861, 80, 27863, 78, 27865, 76, 27867, 74, 27869, 72, 27871, 70, 27873, 68, 27875, 66, 27877, 64, 27879, 62, 27881, 60, 27883, 58, 27885, 56, 27887, 54, 27889, 52, 27891, 50, 27893, 48, 27895, 46, 27897, 44, 27899, 42, 27901, 40, 27903, 38, 27905, 36, 27907, 34, 27909, 32, 27911, 30, 27913, 28, 27915, 26, 27917, 24, 27919, 22, 27921, 20, 27923, 18, 27925, 16, 27927, 14, 27929, 12, 27931, 10, 27933, 8, 27935, 6, 27937, 4, 27939, 2, 27941]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s2/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s2/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-s2/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4a31e29541b92f116d4dc85878e0e38bc96eb83c --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 27942, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s2/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l6-s2/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-rlve-prime-graph-coloring-l3-s2/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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-prime-graph-coloring-l3-s2/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c8a826dbf179d27708cce8d8ab04bf09340e3a24 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 82, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s2/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0157b32ae81e8eb1cc5b8d9d70a928cad30fa55d --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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' +{"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]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s2/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s2/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + sieve = [True] * (n + 1) + sieve[0] = False + if n >= 1: + sieve[1] = False + for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: + for j in range(i * i, n + 1, i): + sieve[j] = False + for p in range(2, n): + if sieve[p]: + for u in range(n - p): + if c[u] == c[u + p]: + raise Invalid(f"vertices {u + 1} and {u + p + 1} (difference {p}) share a colour") + return None, {} diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s2/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c8a826dbf179d27708cce8d8ab04bf09340e3a24 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 82, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s2/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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-prime-graph-coloring-l3-s2/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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-prime-graph-coloring-l3-s5/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l3-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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-prime-graph-coloring-l3-s5/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7f093a3dd84237cf2f5e064320747248f3f7ad77 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 46, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s5/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ff474dd218e8857a984c0d41dde3dd12f4a24e71 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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' +{"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]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s5/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l3-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s5/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + sieve = [True] * (n + 1) + sieve[0] = False + if n >= 1: + sieve[1] = False + for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: + for j in range(i * i, n + 1, i): + sieve[j] = False + for p in range(2, n): + if sieve[p]: + for u in range(n - p): + if c[u] == c[u + p]: + raise Invalid(f"vertices {u + 1} and {u + p + 1} (difference {p}) share a colour") + return None, {} diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s5/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7f093a3dd84237cf2f5e064320747248f3f7ad77 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 46, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s5/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l3-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s5/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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-recursive-sequence-sum-l1-s6/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l1-s6/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a38f13a03ecffbe9a2117f71505879b5ac12dab9 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"F0": 122, "A": 12, "B": 13480, "S": 30474520, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s6/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d442d77cdb9612131b01acbcbc1413e038c3b798 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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' +{"indices": [1, 2, 3, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s6/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s6/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-l1-s6/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a38f13a03ecffbe9a2117f71505879b5ac12dab9 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"F0": 122, "A": 12, "B": 13480, "S": 30474520, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s6/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l1-s6/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l5-s9/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l5-s9/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9230950985dcd15a82e45cfdb316394a473aa3f2 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"F0": 70, "A": 5, "B": 2648, "S": 681728124730224609373676, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s9/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..32b14fc5f38a7e0bc94f33d8570275ac9a0db9e9 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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' +{"indices": [16, 30]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s9/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s9/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-l5-s9/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9230950985dcd15a82e45cfdb316394a473aa3f2 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"F0": 70, "A": 5, "B": 2648, "S": 681728124730224609373676, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s9/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l5-s9/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-round-robin-scores-l1-s2/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-round-robin-scores-l1-s2/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..788deff7e716f86c05b6cb80aa46eb524b37e8b6 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"W": [3, 5, 2, 3], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s2/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c5693b3bc4df7aad12a6c95756cf1240fb4c4b47 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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' +{"A": ["0111", "1021", "1001", "1110"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l1-s2/tests/check.py b/tasks/construct-rlve-round-robin-scores-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s2/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l1-s2/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..788deff7e716f86c05b6cb80aa46eb524b37e8b6 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"W": [3, 5, 2, 3], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s2/tests/run.py b/tasks/construct-rlve-round-robin-scores-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-round-robin-scores-l1-s2/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-round-robin-scores-l1-s5/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l1-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s5/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..92db1927145d23e72e22d8de8ebbf057c1c21698 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s5/environment/instance.json @@ -0,0 +1 @@ +{"W": [4, 4, 4, 4], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s5/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l1-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8a0ff404629e9b44f0f9f362c3a6e71e286341a5 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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": ["0012", "2001", "1200", "0120"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l1-s5/tests/check.py b/tasks/construct-rlve-round-robin-scores-l1-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s5/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l1-s5/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..92db1927145d23e72e22d8de8ebbf057c1c21698 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s5/tests/instance.json @@ -0,0 +1 @@ +{"W": [4, 4, 4, 4], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s5/tests/run.py b/tasks/construct-rlve-round-robin-scores-l1-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s5/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l1-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l2-s9/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l2-s9/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..302be5a06969bfbbc8ead3b7d091872dcaeee3c1 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"W": [9, 4, 5, 9, 7, 6], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l2-s9/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..16bf5699f3037f6ae240548ad3636992cce985be --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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": ["021211", "002001", "100201", "020022", "122000", "111020"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l2-s9/tests/check.py b/tasks/construct-rlve-round-robin-scores-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l2-s9/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l2-s9/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..302be5a06969bfbbc8ead3b7d091872dcaeee3c1 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"W": [9, 4, 5, 9, 7, 6], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l2-s9/tests/run.py b/tasks/construct-rlve-round-robin-scores-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l2-s9/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l5-s3/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-round-robin-scores-l5-s3/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e9986a81cfe9ccba1120db5b556c4362492949 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"W": [16, 21, 20, 19, 17, 19, 18, 23, 17, 15, 20, 16, 18, 19, 24, 15, 15, 18], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s3/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cfdff4045e0c3ff15107ec3129c4da18d8d5d4a6 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": ["001111111111111111", "201111111111111211", "110011111121111121", "112011111201110111", "111101111101110121", "111110101111120211", "111111011211110111", "111112101112121111", "111111110111111111", "111011011011111111", "110221111101002111", "111111101110111111", "111111111121011110", "111110101121101112", "111222211101110111", "101110111111111011", "110101111111111101", "111111111111201110"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l5-s3/tests/check.py b/tasks/construct-rlve-round-robin-scores-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s3/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l5-s3/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f4e9986a81cfe9ccba1120db5b556c4362492949 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"W": [16, 21, 20, 19, 17, 19, 18, 23, 17, 15, 20, 16, 18, 19, 24, 15, 15, 18], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s3/tests/run.py b/tasks/construct-rlve-round-robin-scores-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-round-robin-scores-l5-s3/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-round-robin-scores-l5-s4/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-round-robin-scores-l5-s4/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9bcba83425fa4252f89b6b7e037f71f3a938d53e --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"W": [28, 18, 17, 30, 20, 20, 19, 21, 24, 24, 21, 20, 22, 24, 22, 14, 33, 16], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s4/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9effb37b7344f3af34f681b30711c0eb3ca08682 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": ["021121121001222201", "000020101211201120", "120111011120001111", "121011111212122202", "001101110201120221", "121110110002120102", "112111001211110002", "021111201112201001", "111122110011122200", "201002012022111102", "210122111000001220", "112010101020102211", "002111101121021211", "022000120122002201", "011022210110100122", "011001220100001002", "201202222201120202", "121010012021110000"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l5-s4/tests/check.py b/tasks/construct-rlve-round-robin-scores-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s4/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l5-s4/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9bcba83425fa4252f89b6b7e037f71f3a938d53e --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"W": [28, 18, 17, 30, 20, 20, 19, 21, 24, 24, 21, 20, 22, 24, 22, 14, 33, 16], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s4/tests/run.py b/tasks/construct-rlve-round-robin-scores-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-round-robin-scores-l5-s4/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-round-robin-scores-l6-s1/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l6-s1/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8e85bdcd9d07b23e7f4b59425bc79abd387ac207 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"W": [14, 41, 29, 33, 44, 36, 32, 38, 41, 45, 44, 27, 41, 33, 30, 24, 36, 28, 44, 36, 36, 35, 40, 29, 37], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l6-s1/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..19b07bd30e0ae301c94895057e8ae7354eed4715 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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": ["0000000002002010022000001", "2010020202102220222220200", "2100200200222201002020000", "2220200110200022020010022", "2200012220020222022002212", "2022100002000022212202120", "2222020000000102021022200", "2001022002222222000002210", "2221022200022002220202010", "0022202020022022220222020", "2100222022022102020220022", "2202022000000200200020002", "0002222000020221222202021", "2002021022100022100220020", "1020002020220001020002212", "2210000000021010020202020", "2022202200200122000200211", "0020010200020200200020222", "0002001222220222220210022", "2022202200020020020020220", "2001220220002022201001220", "2222000000220200222210001", "2022010022222202002002002", "2220102110020010100002202", "1220022222001202100221000"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l6-s1/tests/check.py b/tasks/construct-rlve-round-robin-scores-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l6-s1/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l6-s1/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8e85bdcd9d07b23e7f4b59425bc79abd387ac207 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"W": [14, 41, 29, 33, 44, 36, 32, 38, 41, 45, 44, 27, 41, 33, 30, 24, 36, 28, 44, 36, 36, 35, 40, 29, 37], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l6-s1/tests/run.py b/tasks/construct-rlve-round-robin-scores-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l6-s1/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-shortest-path-count-l1-s3/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l1-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-shortest-path-count-l1-s3/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..47cccfee18ceae9d52ccb0bfbf0d7e62a48d410e --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"K": 35, "n_max": 36, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l1-s3/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4506b75a5107c2964b70a31be2725e2c2ce29413 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 18, "adj": ["NNYYNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNYNNNN", "YNNNYYNNNNNNNYNNNN", "NNYYNNYYNNNNNNNNNN", "NNYYNNYYNNNNNNNNNN", "NNNNYYNNYYNNNNNNNN", "NNNNYYNNYYNNNNNNNN", "NNNNNNYYNNYYNNNNNN", "NNNNNNYYNNYYNNNNNN", "NNNNNNNNYYNNNNNNNY", "NNNNNNNNYYNNNNNNNY", "YNNNNNNNNNNNNYNNNN", "NNYYNNNNNNNNYNYNNN", "NNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNYNY", "NYNNNNNNNNYYNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l1-s3/tests/check.py b/tasks/construct-rlve-shortest-path-count-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l1-s3/tests/check.py @@ -0,0 +1,34 @@ +from run import Invalid, as_int + + +def check(inst, ans): + n = as_int(ans.get("n"), "n", lo=2, hi=inst["n_max"]) + adj = ans.get("adj") + if not isinstance(adj, list) or len(adj) != n: + raise Invalid(f"adj must be a list of {n} strings") + for r in adj: + if not isinstance(r, str) or len(r) != n or set(r) - {"Y", "N"}: + raise Invalid("each row must be a string of length n over {'Y','N'}") + for i in range(n): + if adj[i][i] != "N": + raise Invalid("self-loop") + for j in range(i + 1, n): + if adj[i][j] != adj[j][i]: + raise Invalid("matrix not symmetric") + nb = [[j for j in range(n) if adj[i][j] == "Y"] for i in range(n)] + dist = [-1] * n + cnt = [0] * n + dist[0], cnt[0] = 0, 1 + q = [0] + for u in q: # BFS with exact (Python int) path counts + for v in nb[u]: + if dist[v] < 0: + dist[v] = dist[u] + 1 + q.append(v) + if dist[v] == dist[u] + 1: + cnt[v] += cnt[u] + if dist[1] < 0: + raise Invalid("vertex 2 is unreachable from vertex 1") + if cnt[1] != inst["K"]: + raise Invalid(f"{cnt[1]} shortest paths, need {inst['K']}") + return None, {} diff --git a/tasks/construct-rlve-shortest-path-count-l1-s3/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..47cccfee18ceae9d52ccb0bfbf0d7e62a48d410e --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"K": 35, "n_max": 36, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l1-s3/tests/run.py b/tasks/construct-rlve-shortest-path-count-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l1-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-shortest-path-count-l1-s3/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l1-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-shortest-path-count-l2-s1/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s1/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0ad4f92978c7ac7d75b336d999731dbed7171d20 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"K": 236, "n_max": 51, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s1/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1a43af4c1a245c131f96c7fa0f8d75bad915c95c --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 24, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNYNNNNN", "NNYYNNYYNNNNNNNNNNYNNNNN", "NNNNYYNNYYNNNNNNNNNYNNNN", "NNNNYYNNYYNNNNNNNNNYNNNN", "NNNNNNYYNNYYNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNYNN", "NNNNNNNNYYNNYYNNNNNNNYNN", "NNNNNNNNNNYYNNYYNNNNNNYN", "NNNNNNNNNNYYNNYYNNNNNNYN", "NNNNNNNNNNNNYYNNNNNNNNNY", "NNNNNNNNNNNNYYNNNNNNNNNY", "NNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNYNYNNNNN", "NNNNYYNNNNNNNNNNNYNYNNNN", "NNNNNNYYNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNYYNNNNNNNNYNYN", "NNNNNNNNNNNNYYNNNNNNNYNY", "NYNNNNNNNNNNNNYYNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l2-s1/tests/check.py b/tasks/construct-rlve-shortest-path-count-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s1/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-s1/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0ad4f92978c7ac7d75b336d999731dbed7171d20 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"K": 236, "n_max": 51, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s1/tests/run.py b/tasks/construct-rlve-shortest-path-count-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s1/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s8/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s8/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..786de8d1b21fcd72b061c598cd35cd3d502b0bad --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"K": 240, "n_max": 51, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s8/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..411180b70e699a48bbbf4c67ea1a4952fc4a9012 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 24, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNYNNN", "NNNNNNYYNNYYNNNNNNNNYNNN", "NNNNNNNNYYNNYYNNNNNNNYNN", "NNNNNNNNYYNNYYNNNNNNNYNN", "NNNNNNNNNNYYNNYYNNNNNNYN", "NNNNNNNNNNYYNNYYNNNNNNYN", "NNNNNNNNNNNNYYNNNNNNNNNY", "NNNNNNNNNNNNYYNNNNNNNNNY", "NNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNYYNNNNNNNNNYNYNN", "NNNNNNNNNNYYNNNNNNNNYNYN", "NNNNNNNNNNNNYYNNNNNNNYNY", "NYNNNNNNNNNNNNYYNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l2-s8/tests/check.py b/tasks/construct-rlve-shortest-path-count-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s8/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-s8/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..786de8d1b21fcd72b061c598cd35cd3d502b0bad --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"K": 240, "n_max": 51, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s8/tests/run.py b/tasks/construct-rlve-shortest-path-count-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s8/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l6-s0/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-shortest-path-count-l6-s0/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6f16cb64d47ca78c95a59e33411f90f5d969de91 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"K": 681091269143539577, "n_max": 363, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l6-s0/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..578934fe24f8be6c0501e92dfdf01d99003979c4 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 180, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l6-s0/tests/check.py b/tasks/construct-rlve-shortest-path-count-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s0/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-s0/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6f16cb64d47ca78c95a59e33411f90f5d969de91 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"K": 681091269143539577, "n_max": 363, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l6-s0/tests/run.py b/tasks/construct-rlve-shortest-path-count-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-shortest-path-count-l6-s0/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-shortest-path-count-l6-s7/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l6-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l6-s7/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2f579ee80912ff0df132d6cd26ccf16883287eb2 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s7/environment/instance.json @@ -0,0 +1 @@ +{"K": 304361666097914654, "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-s7/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l6-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8c6f9f04853ef3e2fa4eaf9948e3e7a10831a165 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 177, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l6-s7/tests/check.py b/tasks/construct-rlve-shortest-path-count-l6-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s7/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-s7/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2f579ee80912ff0df132d6cd26ccf16883287eb2 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s7/tests/instance.json @@ -0,0 +1 @@ +{"K": 304361666097914654, "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-s7/tests/run.py b/tasks/construct-rlve-shortest-path-count-l6-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l6-s7/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l6-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-l1-s3/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..babf96795459a0c55e482ae702a10d893bc6b58d --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"points": [[0, 6], [0, 7], [2, 0], [3, 8]], "r_opt": 4.031128874149275, "r2_num": 65, "r2_den": 4, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..72c06b2c01abb1d375ac738d03a30f8cb01d0991 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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' +{"x": 2.5, "y": 4.0, "r": 4.031128875149275} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..babf96795459a0c55e482ae702a10d893bc6b58d --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"points": [[0, 6], [0, 7], [2, 0], [3, 8]], "r_opt": 4.031128874149275, "r2_num": 65, "r2_den": 4, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s4/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l1-s4/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b6cfb82240820edf6625d6671ec3ac874ff7fec0 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"points": [[1, 1], [2, 5], [3, 4], [4, 2]], "r_opt": 2.1368471406442104, "r2_num": 1105, "r2_den": 242, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s4/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a616759c07f499701da0290a98f210af4221e35 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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' +{"x": 2.0454545454545454, "y": 2.8636363636363638, "r": 2.1368471416442105} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s4/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s4/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s4/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b6cfb82240820edf6625d6671ec3ac874ff7fec0 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"points": [[1, 1], [2, 5], [3, 4], [4, 2]], "r_opt": 2.1368471406442104, "r2_num": 1105, "r2_den": 242, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s4/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l1-s4/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l2-s8/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l2-s8/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..20a7536299a41dc261b9785a16218c761de4ecb2 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"points": [[1, 13], [3, 9], [5, 14], [6, 12], [10, 5], [11, 8], [15, 0], [15, 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-s8/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0b3721858c8214fea0b752608af10e71667beceb --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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' +{"x": 8.0, "y": 6.5, "r": 9.5524865882714} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l2-s8/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l2-s8/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l2-s8/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..20a7536299a41dc261b9785a16218c761de4ecb2 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"points": [[1, 13], [3, 9], [5, 14], [6, 12], [10, 5], [11, 8], [15, 0], [15, 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-s8/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l2-s8/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s5/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s5/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0a21ae2d2d834619a031ae2295644f5d2b8c6f16 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"points": [[1, 14], [1, 48], [2, 11], [2, 22], [4, 94], [5, 8], [6, 118], [13, 88], [14, 119], [16, 67], [17, 84], [17, 103], [21, 97], [23, 106], [27, 62], [28, 47], [31, 94], [36, 6], [36, 72], [37, 30], [37, 109], [39, 90], [40, 14], [48, 97], [49, 56], [51, 95], [54, 38], [54, 84], [57, 57], [60, 25], [62, 19], [62, 25], [65, 11], [65, 96], [71, 48], [73, 22], [73, 37], [75, 47], [77, 80], [78, 110], [87, 114], [89, 39], [92, 58], [93, 114], [95, 20], [95, 78], [96, 41], [96, 45], [97, 39], [98, 44], [98, 73], [104, 2], [104, 37], [106, 2], [111, 67], [114, 58], [114, 86], [115, 17], [115, 88], [116, 61]], "r_opt": 76.57675887630658, "r2_num": 5864, "r2_den": 1, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s5/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..77cd9f4c0604f6396fe65c9a9241ab301ea3b83b --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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": 56.0, "y": 60.0, "r": 76.57675887730659} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s5/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s5/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-s5/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0a21ae2d2d834619a031ae2295644f5d2b8c6f16 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"points": [[1, 14], [1, 48], [2, 11], [2, 22], [4, 94], [5, 8], [6, 118], [13, 88], [14, 119], [16, 67], [17, 84], [17, 103], [21, 97], [23, 106], [27, 62], [28, 47], [31, 94], [36, 6], [36, 72], [37, 30], [37, 109], [39, 90], [40, 14], [48, 97], [49, 56], [51, 95], [54, 38], [54, 84], [57, 57], [60, 25], [62, 19], [62, 25], [65, 11], [65, 96], [71, 48], [73, 22], [73, 37], [75, 47], [77, 80], [78, 110], [87, 114], [89, 39], [92, 58], [93, 114], [95, 20], [95, 78], [96, 41], [96, 45], [97, 39], [98, 44], [98, 73], [104, 2], [104, 37], [106, 2], [111, 67], [114, 58], [114, 86], [115, 17], [115, 88], [116, 61]], "r_opt": 76.57675887630658, "r2_num": 5864, "r2_den": 1, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s5/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s5/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l6-s0/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9892643ac2adb79395d7904d7a41a58f97b3c5b6 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"points": [[3, 114], [3, 195], [6, 22], [10, 56], [10, 175], [13, 55], [13, 116], [15, 82], [16, 231], [19, 196], [22, 115], [23, 104], [24, 119], [27, 76], [30, 46], [31, 37], [33, 14], [35, 97], [41, 44], [44, 124], [45, 125], [46, 224], [50, 101], [50, 159], [52, 87], [52, 181], [64, 56], [67, 198], [67, 240], [78, 71], [79, 196], [80, 206], [80, 216], [84, 13], [84, 108], [86, 217], [87, 23], [88, 76], [91, 165], [92, 55], [94, 147], [95, 66], [96, 17], [98, 18], [98, 134], [99, 4], [100, 164], [101, 28], [105, 116], [108, 136], [108, 215], [111, 33], [113, 210], [116, 185], [117, 222], [118, 233], [120, 239], [123, 130], [124, 195], [126, 40], [128, 9], [137, 185], [138, 95], [139, 29], [139, 157], [142, 124], [149, 65], [149, 117], [150, 12], [154, 200], [155, 28], [157, 90], [157, 213], [159, 122], [160, 65], [160, 132], [163, 171], [163, 173], [167, 119], [168, 38], [169, 24], [169, 223], [170, 6], [170, 7], [175, 128], [178, 53], [179, 60], [180, 83], [183, 228], [185, 8], [186, 209], [187, 104], [189, 215], [192, 125], [192, 169], [194, 13], [195, 93], [196, 10], [200, 44], [203, 35], [204, 162], [205, 6], [205, 153], [206, 36], [207, 240], [208, 29], [210, 132], [211, 113], [216, 16], [216, 206], [218, 135], [222, 47], [227, 80], [228, 130], [231, 217], [234, 25], [234, 221], [236, 27], [238, 37], [238, 94]], "r_opt": 151.31506864816868, "r2_num": 91585, "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-s0/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..03a1b4768c6e20bc517da7fbc0f6e4444ffd42b0 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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' +{"x": 120.0, "y": 121.5, "r": 151.31506864916867} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9892643ac2adb79395d7904d7a41a58f97b3c5b6 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"points": [[3, 114], [3, 195], [6, 22], [10, 56], [10, 175], [13, 55], [13, 116], [15, 82], [16, 231], [19, 196], [22, 115], [23, 104], [24, 119], [27, 76], [30, 46], [31, 37], [33, 14], [35, 97], [41, 44], [44, 124], [45, 125], [46, 224], [50, 101], [50, 159], [52, 87], [52, 181], [64, 56], [67, 198], [67, 240], [78, 71], [79, 196], [80, 206], [80, 216], [84, 13], [84, 108], [86, 217], [87, 23], [88, 76], [91, 165], [92, 55], [94, 147], [95, 66], [96, 17], [98, 18], [98, 134], [99, 4], [100, 164], [101, 28], [105, 116], [108, 136], [108, 215], [111, 33], [113, 210], [116, 185], [117, 222], [118, 233], [120, 239], [123, 130], [124, 195], [126, 40], [128, 9], [137, 185], [138, 95], [139, 29], [139, 157], [142, 124], [149, 65], [149, 117], [150, 12], [154, 200], [155, 28], [157, 90], [157, 213], [159, 122], [160, 65], [160, 132], [163, 171], [163, 173], [167, 119], [168, 38], [169, 24], [169, 223], [170, 6], [170, 7], [175, 128], [178, 53], [179, 60], [180, 83], [183, 228], [185, 8], [186, 209], [187, 104], [189, 215], [192, 125], [192, 169], [194, 13], [195, 93], [196, 10], [200, 44], [203, 35], [204, 162], [205, 6], [205, 153], [206, 36], [207, 240], [208, 29], [210, 132], [211, 113], [216, 16], [216, 206], [218, 135], [222, 47], [227, 80], [228, 130], [231, 217], [234, 25], [234, 221], [236, 27], [238, 37], [238, 94]], "r_opt": 151.31506864816868, "r2_num": 91585, "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-s0/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l6-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s0/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l5-s0/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..97cb205ca7c013b013a1626ff1460a1e51507bb3 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"n1": 18, "n2": 26, "edges1": [[7, 15], [0, 6], [8, 9], [8, 15], [15, 17], [3, 7], [8, 13], [3, 16], [3, 11], [1, 13], [3, 15], [11, 13], [8, 10], [0, 4], [1, 3], [3, 14], [15, 16], [12, 15]], "edges2": [[6, 21], [0, 21], [15, 20], [0, 12], [11, 15], [13, 22], [5, 12], [1, 18], [7, 10], [9, 22], [6, 10], [9, 19], [5, 24], [18, 22], [7, 19], [3, 4], [15, 24], [21, 23], [1, 25], [0, 6], [5, 20], [7, 13], [4, 11], [17, 22], [22, 23], [5, 10], [17, 20], [7, 12], [10, 16], [2, 7], [5, 23], [16, 17], [4, 21], [3, 7], [15, 22], [17, 18], [16, 18], [20, 21], [4, 19], [7, 16], [5, 7], [19, 21], [0, 14], [11, 17], [9, 11], [3, 24], [7, 11], [21, 24]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s0/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71b0c9370dbb02909499acb127874623b15158bf --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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' +{"p": [1, 24, 14, 5, 25, 8, 18, 10, 11, 4, 9, 20, 13, 15, 23, 7, 12, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s0/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s0/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-l5-s0/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..97cb205ca7c013b013a1626ff1460a1e51507bb3 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"n1": 18, "n2": 26, "edges1": [[7, 15], [0, 6], [8, 9], [8, 15], [15, 17], [3, 7], [8, 13], [3, 16], [3, 11], [1, 13], [3, 15], [11, 13], [8, 10], [0, 4], [1, 3], [3, 14], [15, 16], [12, 15]], "edges2": [[6, 21], [0, 21], [15, 20], [0, 12], [11, 15], [13, 22], [5, 12], [1, 18], [7, 10], [9, 22], [6, 10], [9, 19], [5, 24], [18, 22], [7, 19], [3, 4], [15, 24], [21, 23], [1, 25], [0, 6], [5, 20], [7, 13], [4, 11], [17, 22], [22, 23], [5, 10], [17, 20], [7, 12], [10, 16], [2, 7], [5, 23], [16, 17], [4, 21], [3, 7], [15, 22], [17, 18], [16, 18], [20, 21], [4, 19], [7, 16], [5, 7], [19, 21], [0, 14], [11, 17], [9, 11], [3, 24], [7, 11], [21, 24]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s0/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l5-s0/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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/optimize-ae-p45-sum-product-fp-n4000037/environment/Dockerfile b/tasks/optimize-ae-p45-sum-product-fp-n4000037/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p45-sum-product-fp-n4000037/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==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-p45-sum-product-fp-n4000037/environment/instance.json b/tasks/optimize-ae-p45-sum-product-fp-n4000037/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..93908e027e19f4e153a37d8b08613da068dbb7ac --- /dev/null +++ b/tasks/optimize-ae-p45-sum-product-fp-n4000037/environment/instance.json @@ -0,0 +1 @@ +{"p": 4000037, "k": 2000, "direction": "minimize", "family": "ae_p45_sum_product_fp", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p45-sum-product-fp-n4000037/solution/solve.sh b/tasks/optimize-ae-p45-sum-product-fp-n4000037/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1757768bc62f28ae8e373f26687fcbb63262a5fa --- /dev/null +++ b/tasks/optimize-ae-p45-sum-product-fp-n4000037/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"X": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 35, 36, 40, 42, 44, 45, 48, 49, 50, 54, 55, 56, 60, 63, 64, 66, 70, 72, 75, 77, 80, 81, 84, 88, 90, 96, 98, 99, 100, 105, 108, 110, 112, 120, 121, 125, 126, 128, 132, 135, 140, 144, 147, 20569, 20591, 20613, 70630, 70657, 70672, 70675, 70684, 70690, 70693, 70702, 70711, 70720, 70729, 70732, 70738, 70747, 70750, 70765, 70792, 95631, 95661, 95711, 95731, 95751, 95756, 95761, 95767, 95771, 95775, 95781, 95786, 95791, 95811, 95831, 95881, 95911, 141314, 141344, 141350, 141368, 141395, 141404, 141422, 141440, 141449, 141476, 141494, 141500, 141530, 166433, 166458, 166461, 166465, 166468, 166473, 166475, 166478, 166481, 166482, 166483, 166486, 166489, 166491, 166496, 166499, 166503, 166506, 166531, 187009, 187073, 187137, 191422, 191462, 191502, 191512, 191522, 191542, 191562, 191572, 191582, 191622, 191662, 212016, 212025, 212052, 212106, 212133, 212160, 212214, 212241, 212250, 237131, 237255, 262227, 262240, 262244, 262253, 262262, 262266, 262279, 282763, 282790, 282808, 282844, 282880, 282898, 282925, 287193, 287233, 287253, 287268, 287283, 287293, 287313, 287333, 287343, 287358, 287373, 287393, 287433, 332866, 332887, 332916, 332922, 332936, 332943, 332946, 332950, 332956, 332957, 332962, 332964, 332966, 332971, 332972, 332978, 332982, 332985, 332992, 333006, 333012, 333041, 333062, 353510, 353555, 353600, 357925, 357958, 357980, 357991, 358013, 358018, 358024, 358030, 358035, 358057, 358068, 358090, 358123, 378527, 378549, 378571, 378599, 378615, 378631, 378659, 378681, 378703, 383004, 383024, 383044, 383084, 383124, 383144, 383164, 403637, 403713, 428693, 428702, 428705, 428713, 428717, 428718, 428723, 428726, 428727, 428729, 428731, 428732, 428733, 428735, 428737, 428738, 428739, 428741, 428743, 428744, 428747, 428752, 428753, 428757, 428765, 428768, 428777, 474262, 474510, 478755, 478780, 478805, 478855, 478905, 478930, 478955, 499374, 499383, 499404, 499418, 499419, 499425, 499432, 499434, 499439, 499443, 499446, 499449, 499453, 499458, 499460, 499467, 499473, 499474, 499488, 499509, 499518, 503915, 524488, 524493, 524506, 524519, 524524, 570061, 570093, 570109, 570121, 570133, 570141, 570143, 570157, 570171, 570173, 570181, 570193, 570205, 570221, 570253, 574566, 574586, 574591, 574626, 574661, 574666, 574686, 595199, 595209, 595210, 595212, 595214, 595215, 595216, 595217, 595218, 595219, 595220, 595222, 595224, 595225, 595235, 640768, 640793, 640843, 640868, 640893, 640943, 640968, 645286, 645388, 665832, 665844, 665872, 665900, 665907, 665912, 665914, 665924, 665928, 665932, 665942, 665944, 665949, 665956, 665984, 666012, 666024, 670377, 670397, 670417, 690966, 690971, 691005, 691010, 715916, 715960, 715982, 716015, 716026, 716036, 716048, 716060, 716070, 716081, 716114, 716136, 716180, 736529, 736584, 736629, 736639, 736649, 736694, 736749, 761643, 761655, 761675, 761683, 761685, 761687, 761691, 761693, 761695, 761698, 761699, 761700, 761703, 761705, 761707, 761711, 761713, 761715, 761723, 761743, 761755, 786732, 786786, 807274, 807426, 832290, 832305, 832340, 832375, 832405, 832410, 832415, 832445, 832480, 832515, 832530, 857386, 857404, 857434, 857446, 857449, 857452, 857454, 857458, 857461, 857462, 857464, 857465, 857466, 857470, 857474, 857475, 857476, 857478, 857479, 857482, 857486, 857488, 857491, 857494, 857506, 857536, 857554, 903087, 903155, 928076, 928136, 928151, 928161, 928166, 928171, 928176, 928178, 928181, 928184, 928186, 928191, 928196, 928201, 928211, 928226, 928286, 953145, 953177, 953209, 953217, 953225, 953237, 953241, 953245, 953257, 953265, 953273, 953305, 953337, 978298, 978304, 998766, 998808, 998836, 998850, 998871, 998878, 998886, 998892, 998898, 998906, 998913, 998934, 998948, 998976, 999018, 1003298, 1003319, 1003343, 1003361, 1003379, 1003403, 1003424, 1023917, 1023927, 1023937, 1023940, 1023942, 1023947, 1023951, 1023952, 1023953, 1023957, 1023962, 1023964, 1023967, 1023977, 1023987, 1048976, 1049048, 1073973, 1074039, 1074054, 1074072, 1074090, 1074105, 1074171, 1094542, 1094597, 1094619, 1094641, 1094644, 1094652, 1094657, 1094659, 1094663, 1094667, 1094669, 1094674, 1094682, 1094685, 1094707, 1094729, 1094784, 1119648, 1119673, 1119698, 1119718, 1119723, 1119728, 1119748, 1119773, 1119798, 1140218, 1140242, 1140266, 1140282, 1140286, 1140314, 1140342, 1140346, 1140362, 1140386, 1140410, 1144679, 1144687, 1144711, 1144729, 1144747, 1144759, 1144762, 1144783, 1144804, 1144807, 1144819, 1144837, 1144855, 1144879, 1144887, 1165276, 1165325, 1165367, 1165374, 1165381, 1165423, 1165472, 1190405, 1190418, 1190420, 1190423, 1190424, 1190428, 1190430, 1190431, 1190432, 1190433, 1190434, 1190435, 1190436, 1190437, 1190438, 1190440, 1190444, 1190445, 1190448, 1190450, 1190463, 1215359, 1215404, 1215429, 1215434, 1215449, 1215479, 1215494, 1215509, 1215539, 1215554, 1215559, 1215584, 1215629, 1236003, 1236167, 1261143, 1261147, 1286079, 1286106, 1286151, 1286169, 1286178, 1286179, 1286181, 1286187, 1286191, 1286193, 1286196, 1286199, 1286204, 1286205, 1286206, 1286211, 1286214, 1286217, 1286219, 1286223, 1286229, 1286231, 1286232, 1286241, 1286259, 1286304, 1286331, 1311220, 1311310, 1331744, 1331800, 1331814, 1331828, 1331848, 1331856, 1331864, 1331884, 1331898, 1331912, 1331968, 1336241, 1336269, 1336309, 1336325, 1336341, 1336381, 1336409, 1356853, 1356883, 1356889, 1356898, 1356903, 1356904, 1356907, 1356909, 1356910, 1356913, 1356916, 1356919, 1356922, 1356923, 1356925, 1356928, 1356929, 1356934, 1356943, 1356979, 1381935, 1382017, 1427519, 1427555, 1427575, 1427579, 1427591, 1427600, 1427609, 1427615, 1427627, 1427639, 1427645, 1427654, 1427663, 1427675, 1427679, 1427699, 1427735, 1432030, 1432052, 1432072, 1432096, 1432120, 1432140, 1432162, 1452610, 1452654, 1452664, 1452665, 1452676, 1452684, 1452685, 1452687, 1452689, 1452690, 1452698, 1452709, 1452710, 1452720, 1452764, 1473223, 1473258, 1473278, 1473298, 1473333, 1498212, 1498247, 1498254, 1498275, 1498317, 1498329, 1498338, 1498347, 1498359, 1498401, 1498422, 1498429, 1498464, 1502772, 1502792, 1502807, 1502822, 1502842, 1523286, 1523310, 1523350, 1523366, 1523370, 1523374, 1523382, 1523386, 1523390, 1523396, 1523398, 1523400, 1523406, 1523410, 1523414, 1523422, 1523426, 1523430, 1523446, 1523486, 1523510, 1548441, 1548475, 1568959, 1569004, 1569019, 1569049, 1569079, 1569094, 1569139, 1573464, 1573572, 1598578, 1619137, 1619141, 1619147, 1619149, 1619157, 1619161, 1619162, 1619163, 1619165, 1619166, 1619167, 1619169, 1619171, 1619172, 1619173, 1619175, 1619176, 1619177, 1619181, 1619189, 1619191, 1619197, 1619201, 1639679, 1639716, 1639804, 1639841, 1644136, 1644322, 1664750, 1664785, 1664810, 1664820, 1664830, 1664855, 1664890, 1669191, 1669240, 1669275, 1669289, 1669303, 1669338, 1669387, 1689869, 1689891, 1710471, 1714808, 1714868, 1714892, 1714908, 1714916, 1714922, 1714924, 1714928, 1714930, 1714932, 1714933, 1714937, 1714940, 1714943, 1714947, 1714948, 1714950, 1714952, 1714956, 1714958, 1714964, 1714972, 1714988, 1715012, 1715072, 1760491, 1760541, 1760566, 1760591, 1760616, 1760641, 1760691, 1785572, 1785627, 1785630, 1785636, 1785640, 1785642, 1785645, 1785647, 1785648, 1785649, 1785650, 1785651, 1785652, 1785653, 1785654, 1785655, 1785657, 1785660, 1785662, 1785666, 1785672, 1785675, 1785730, 1806174, 1806310, 1810579, 1810594, 1810623, 1810667, 1810678, 1810689, 1810703, 1810711, 1810719, 1810733, 1810744, 1810755, 1810799, 1810828, 1810843, 1831225, 1831288, 1831291, 1831302, 1831313, 1831316, 1831379, 1835708, 1835834, 1856272, 1856302, 1856322, 1856332, 1856347, 1856352, 1856356, 1856362, 1856368, 1856372, 1856377, 1856392, 1856402, 1856422, 1856452, 1881391, 1881403, 1881415, 1881416, 1881428, 1881429, 1881441, 1881453, 1901941, 1902085, 1906354, 1906418, 1906434, 1906450, 1906482, 1906514, 1906530, 1906546, 1906610, 1952063, 1952078, 1952103, 1952109, 1952113, 1952118, 1952123, 1952128, 1952131, 1952133, 1952135, 1952138, 1952143, 1952148, 1952153, 1952157, 1952163, 1952188, 1952203, 1997672, 1997700, 1997721, 1997742, 1997756, 1997772, 1997784, 1997796, 1997812, 1997826, 1997847, 1997868, 1997896, 2002141, 2002169, 2002190, 2002211, 2002225, 2002241, 2002253, 2002265, 2002281, 2002295, 2002316, 2002337, 2002365, 2047834, 2047849, 2047874, 2047880, 2047884, 2047889, 2047894, 2047899, 2047902, 2047904, 2047906, 2047909, 2047914, 2047919, 2047924, 2047928, 2047934, 2047959, 2047974, 2093427, 2093491, 2093507, 2093523, 2093555, 2093587, 2093603, 2093619, 2093683, 2097952, 2098096, 2118584, 2118596, 2118608, 2118609, 2118621, 2118622, 2118634, 2118646, 2143585, 2143615, 2143635, 2143645, 2143660, 2143665, 2143669, 2143675, 2143681, 2143685, 2143690, 2143705, 2143715, 2143735, 2143765, 2164203, 2164329, 2168658, 2168721, 2168724, 2168735, 2168746, 2168749, 2168812, 2189194, 2189209, 2189238, 2189282, 2189293, 2189304, 2189318, 2189326, 2189334, 2189348, 2189359, 2189370, 2189414, 2189443, 2189458, 2193727, 2193863, 2214307, 2214362, 2214365, 2214371, 2214375, 2214377, 2214380, 2214382, 2214383, 2214384, 2214385, 2214386, 2214387, 2214388, 2214389, 2214390, 2214392, 2214395, 2214397, 2214401, 2214407, 2214410, 2214465, 2239346, 2239396, 2239421, 2239446, 2239471, 2239496, 2239546, 2284965, 2285025, 2285049, 2285065, 2285073, 2285079, 2285081, 2285085, 2285087, 2285089, 2285090, 2285094, 2285097, 2285100, 2285104, 2285105, 2285107, 2285109, 2285113, 2285115, 2285121, 2285129, 2285145, 2285169, 2285229, 2289566, 2310146, 2310168, 2330650, 2330699, 2330734, 2330748, 2330762, 2330797, 2330846, 2335147, 2335182, 2335207, 2335217, 2335227, 2335252, 2335287, 2355715, 2355901, 2360196, 2360233, 2360321, 2360358, 2380836, 2380840, 2380846, 2380848, 2380856, 2380860, 2380861, 2380862, 2380864, 2380865, 2380866, 2380868, 2380870, 2380871, 2380872, 2380874, 2380875, 2380876, 2380880, 2380888, 2380890, 2380896, 2380900, 2401459, 2426465, 2426573, 2430898, 2430943, 2430958, 2430988, 2431018, 2431033, 2431078, 2451562, 2451596, 2476527, 2476551, 2476591, 2476607, 2476611, 2476615, 2476623, 2476627, 2476631, 2476637, 2476639, 2476641, 2476647, 2476651, 2476655, 2476663, 2476667, 2476671, 2476687, 2476727, 2476751, 2497195, 2497215, 2497230, 2497245, 2497265, 2501573, 2501608, 2501615, 2501636, 2501678, 2501690, 2501699, 2501708, 2501720, 2501762, 2501783, 2501790, 2501825, 2526704, 2526739, 2526759, 2526779, 2526814, 2547273, 2547317, 2547327, 2547328, 2547339, 2547347, 2547348, 2547350, 2547352, 2547353, 2547361, 2547372, 2547373, 2547383, 2547427, 2567875, 2567897, 2567917, 2567941, 2567965, 2567985, 2568007, 2572302, 2572338, 2572358, 2572362, 2572374, 2572383, 2572392, 2572398, 2572410, 2572422, 2572428, 2572437, 2572446, 2572458, 2572462, 2572482, 2572518, 2618020, 2618102, 2643058, 2643088, 2643094, 2643103, 2643108, 2643109, 2643112, 2643114, 2643115, 2643118, 2643121, 2643124, 2643127, 2643128, 2643130, 2643133, 2643134, 2643139, 2643148, 2643184, 2663628, 2663656, 2663696, 2663712, 2663728, 2663768, 2663796, 2668069, 2668125, 2668139, 2668153, 2668173, 2668181, 2668189, 2668209, 2668223, 2668237, 2668293, 2688727, 2688817, 2713706, 2713733, 2713778, 2713796, 2713805, 2713806, 2713808, 2713814, 2713818, 2713820, 2713823, 2713826, 2713831, 2713832, 2713833, 2713838, 2713841, 2713844, 2713846, 2713850, 2713856, 2713858, 2713859, 2713868, 2713886, 2713931, 2713958, 2738890, 2738894, 2763870, 2764034, 2784408, 2784453, 2784478, 2784483, 2784498, 2784528, 2784543, 2784558, 2784588, 2784603, 2784608, 2784633, 2784678, 2809574, 2809587, 2809589, 2809592, 2809593, 2809597, 2809599, 2809600, 2809601, 2809602, 2809603, 2809604, 2809605, 2809606, 2809607, 2809609, 2809613, 2809614, 2809617, 2809619, 2809632, 2834565, 2834614, 2834656, 2834663, 2834670, 2834712, 2834761, 2855150, 2855158, 2855182, 2855200, 2855218, 2855230, 2855233, 2855254, 2855275, 2855278, 2855290, 2855308, 2855326, 2855350, 2855358, 2859627, 2859651, 2859675, 2859691, 2859695, 2859723, 2859751, 2859755, 2859771, 2859795, 2859819, 2880239, 2880264, 2880289, 2880309, 2880314, 2880319, 2880339, 2880364, 2880389, 2905253, 2905308, 2905330, 2905352, 2905355, 2905363, 2905368, 2905370, 2905374, 2905378, 2905380, 2905385, 2905393, 2905396, 2905418, 2905440, 2905495, 2925866, 2925932, 2925947, 2925965, 2925983, 2925998, 2926064, 2950989, 2951061, 2976050, 2976060, 2976070, 2976073, 2976075, 2976080, 2976084, 2976085, 2976086, 2976090, 2976095, 2976097, 2976100, 2976110, 2976120, 2996613, 2996634, 2996658, 2996676, 2996694, 2996718, 2996739, 3001019, 3001061, 3001089, 3001103, 3001124, 3001131, 3001139, 3001145, 3001151, 3001159, 3001166, 3001187, 3001201, 3001229, 3001271, 3021733, 3021739, 3046700, 3046732, 3046764, 3046772, 3046780, 3046792, 3046796, 3046800, 3046812, 3046820, 3046828, 3046860, 3046892, 3071751, 3071811, 3071826, 3071836, 3071841, 3071846, 3071851, 3071853, 3071856, 3071859, 3071861, 3071866, 3071871, 3071876, 3071886, 3071901, 3071961, 3096882, 3096950, 3142483, 3142501, 3142531, 3142543, 3142546, 3142549, 3142551, 3142555, 3142558, 3142559, 3142561, 3142562, 3142563, 3142567, 3142571, 3142572, 3142573, 3142575, 3142576, 3142579, 3142583, 3142585, 3142588, 3142591, 3142603, 3142633, 3142651, 3167507, 3167522, 3167557, 3167592, 3167622, 3167627, 3167632, 3167662, 3167697, 3167732, 3167747, 3192611, 3192763, 3213251, 3213305, 3238282, 3238294, 3238314, 3238322, 3238324, 3238326, 3238330, 3238332, 3238334, 3238337, 3238338, 3238339, 3238342, 3238344, 3238346, 3238350, 3238352, 3238354, 3238362, 3238382, 3238394, 3263288, 3263343, 3263388, 3263398, 3263408, 3263453, 3263508, 3283857, 3283901, 3283923, 3283956, 3283967, 3283977, 3283989, 3284001, 3284011, 3284022, 3284055, 3284077, 3284121, 3309027, 3309032, 3309066, 3309071, 3329620, 3329640, 3329660, 3334013, 3334025, 3334053, 3334081, 3334088, 3334093, 3334095, 3334105, 3334109, 3334113, 3334123, 3334125, 3334130, 3334137, 3334165, 3334193, 3334205, 3354649, 3354751, 3359069, 3359094, 3359144, 3359169, 3359194, 3359244, 3359269, 3404802, 3404812, 3404813, 3404815, 3404817, 3404818, 3404819, 3404820, 3404821, 3404822, 3404823, 3404825, 3404827, 3404828, 3404838, 3425351, 3425371, 3425376, 3425411, 3425446, 3425451, 3425471, 3429784, 3429816, 3429832, 3429844, 3429856, 3429864, 3429866, 3429880, 3429894, 3429896, 3429904, 3429916, 3429928, 3429944, 3429976, 3475513, 3475518, 3475531, 3475544, 3475549, 3496122, 3500519, 3500528, 3500549, 3500563, 3500564, 3500570, 3500577, 3500579, 3500584, 3500588, 3500591, 3500594, 3500598, 3500603, 3500605, 3500612, 3500618, 3500619, 3500633, 3500654, 3500663, 3521082, 3521107, 3521132, 3521182, 3521232, 3521257, 3521282, 3525527, 3525775, 3571260, 3571269, 3571272, 3571280, 3571284, 3571285, 3571290, 3571293, 3571294, 3571296, 3571298, 3571299, 3571300, 3571302, 3571304, 3571305, 3571306, 3571308, 3571310, 3571311, 3571314, 3571319, 3571320, 3571324, 3571332, 3571335, 3571344, 3596324, 3596400, 3616873, 3616893, 3616913, 3616953, 3616993, 3617013, 3617033, 3621334, 3621356, 3621378, 3621406, 3621422, 3621438, 3621466, 3621488, 3621510, 3641914, 3641947, 3641969, 3641980, 3642002, 3642004, 3642007, 3642013, 3642019, 3642024, 3642046, 3642057, 3642079, 3642112, 3646437, 3646482, 3646527, 3666975, 3666996, 3667025, 3667031, 3667045, 3667052, 3667055, 3667059, 3667065, 3667066, 3667071, 3667073, 3667075, 3667080, 3667081, 3667087, 3667091, 3667094, 3667101, 3667115, 3667121, 3667150, 3667171, 3712604, 3712644, 3712664, 3712679, 3712694, 3712704, 3712724, 3712744, 3712754, 3712769, 3712784, 3712804, 3712844, 3717112, 3717139, 3717157, 3717193, 3717229, 3717247, 3717274, 3737758, 3737771, 3737775, 3737784, 3737793, 3737797, 3737810, 3762782, 3762906, 3787787, 3787796, 3787823, 3787877, 3787904, 3787931, 3787985, 3788012, 3788021, 3808375, 3808415, 3808455, 3808465, 3808475, 3808495, 3808515, 3808525, 3808535, 3808575, 3808615, 3812900, 3812964, 3813028, 3833506, 3833531, 3833534, 3833538, 3833541, 3833546, 3833548, 3833551, 3833554, 3833555, 3833556, 3833559, 3833562, 3833564, 3833569, 3833572, 3833576, 3833579, 3833604, 3858507, 3858537, 3858543, 3858561, 3858588, 3858597, 3858615, 3858633, 3858642, 3858669, 3858687, 3858693, 3858723, 3904126, 3904156, 3904206, 3904226, 3904246, 3904251, 3904256, 3904262, 3904266, 3904270, 3904276, 3904281, 3904286, 3904306, 3904326, 3904376, 3904406, 3929245, 3929272, 3929287, 3929290, 3929299, 3929305, 3929308, 3929317, 3929326, 3929335, 3929344, 3929347, 3929353, 3929362, 3929365, 3929380, 3929407, 3979424, 3979446, 3979468, 3999890, 3999893, 3999897, 3999902, 3999905, 3999909, 3999911, 3999912, 3999916, 3999917, 3999925, 3999927, 3999929, 3999932, 3999937, 3999938, 3999939, 3999941, 3999947, 3999949, 3999953, 3999956, 3999957, 3999960, 3999962, 3999965, 3999967, 3999971, 3999973, 3999974, 3999977, 3999981, 3999982, 3999983, 3999987, 3999988, 3999989, 3999992, 3999993, 3999995, 3999997, 4000001, 4000002, 4000004, 4000005, 4000007, 4000009, 4000010, 4000011, 4000012, 4000013, 4000015, 4000016, 4000017, 4000019, 4000021, 4000022, 4000023, 4000024, 4000025, 4000026, 4000027, 4000028, 4000029, 4000030, 4000031, 4000032, 4000033, 4000034, 4000035, 4000036]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p45-sum-product-fp-n4000037/tests/check.py b/tasks/optimize-ae-p45-sum-product-fp-n4000037/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..7184ef5e5926255a1a72ddf7fe632faebdd9012c --- /dev/null +++ b/tasks/optimize-ae-p45-sum-product-fp-n4000037/tests/check.py @@ -0,0 +1,15 @@ +"""Finite-field sum-product problem (AlphaEvolve problem 45): minimize max(|X+X|, |X*X|) in F_p, |X| = floor(sqrt p).""" +import numpy as np + +from run import Invalid, int_list + + +def check(inst, ans): + p, k = inst["p"], inst["k"] + x = int_list(ans.get("X"), k, 0, p - 1, "X") + if len(set(x)) != k: + raise Invalid("X must consist of distinct residues") + a = np.array(sorted(x), dtype=np.int64) + s = int(np.unique(np.add.outer(a, a) % p).size) + q = int(np.unique(np.multiply.outer(a, a) % p).size) # products < p^2 < 2^63 + return float(max(s, q)), {"sumset": s, "productset": q} diff --git a/tasks/optimize-ae-p45-sum-product-fp-n4000037/tests/instance.json b/tasks/optimize-ae-p45-sum-product-fp-n4000037/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d0ca21063ef2d16bbba5984f1a04136ec88a1105 --- /dev/null +++ b/tasks/optimize-ae-p45-sum-product-fp-n4000037/tests/instance.json @@ -0,0 +1 @@ +{"p": 4000037, "k": 2000, "direction": "minimize", "best_known": 149602.0, "baseline": 959284.0, "family": "ae_p45_sum_product_fp", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p45-sum-product-fp-n4000037/tests/run.py b/tasks/optimize-ae-p45-sum-product-fp-n4000037/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p45-sum-product-fp-n4000037/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/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-p45-sum-product-fp-n4000037/tests/test.sh b/tasks/optimize-ae-p45-sum-product-fp-n4000037/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p45-sum-product-fp-n4000037/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/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-n10/environment/Dockerfile b/tasks/optimize-ae-p60-no5-on-sphere-n10/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n10/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==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-n10/environment/instance.json b/tasks/optimize-ae-p60-no5-on-sphere-n10/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f5847c8b550f4cc264b6da453378aa4705d0f354 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n10/environment/instance.json @@ -0,0 +1 @@ +{"n": 10, "max_points": 40, "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-n10/solution/solve.sh b/tasks/optimize-ae-p60-no5-on-sphere-n10/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2906e3d2d9963fa20dbf0ddb42ed7d4bf545657e --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n10/solution/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": [[8, 1, 0], [1, 5, 6], [9, 8, 6], [4, 6, 1], [8, 0, 9], [0, 1, 9], [0, 7, 4], [3, 0, 8], [9, 7, 0], [1, 7, 7], [1, 4, 9], [4, 5, 3], [5, 1, 7], [7, 4, 5], [7, 6, 1], [2, 1, 2], [9, 4, 8], [9, 5, 5], [3, 8, 1], [5, 8, 3], [7, 0, 2], [2, 2, 8], [2, 3, 2], [5, 7, 6], [0, 9, 0], [0, 2, 0], [8, 9, 1], [4, 9, 9]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p60-no5-on-sphere-n10/tests/check.py b/tasks/optimize-ae-p60-no5-on-sphere-n10/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..535715270fb95983b4b3896cda93a8746da1a961 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n10/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-n10/tests/instance.json b/tasks/optimize-ae-p60-no5-on-sphere-n10/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5d44242092c247278d7939350bd3c24808d28228 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n10/tests/instance.json @@ -0,0 +1 @@ +{"n": 10, "max_points": 40, "direction": "maximize", "best_known": 28.0, "baseline": 20.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-n10/tests/run.py b/tasks/optimize-ae-p60-no5-on-sphere-n10/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n10/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/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-n10/tests/test.sh b/tasks/optimize-ae-p60-no5-on-sphere-n10/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n10/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/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-kissing-d11-n605/environment/Dockerfile b/tasks/optimize-ea-kissing-d11-n605/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ea-kissing-d11-n605/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==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-kissing-d11-n605/environment/instance.json b/tasks/optimize-ea-kissing-d11-n605/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3f36cd806be6784bdc7fc7f3b9124c2fcfd1b753 --- /dev/null +++ b/tasks/optimize-ea-kissing-d11-n605/environment/instance.json @@ -0,0 +1 @@ +{"dim": 11, "n": 605, "direction": "minimize", "progress_scale": "log", "log_floor": 0.001, "family": "ea_kissing_number", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ea-kissing-d11-n605/solution/solve.sh b/tasks/optimize-ea-kissing-d11-n605/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e54ee753ce589ea9d7beddc2c233e95350438b31 --- /dev/null +++ b/tasks/optimize-ea-kissing-d11-n605/solution/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": [[-0.9939863759901654, -0.9402300329915074, 1.5797556579109484, 0.7266414004424878, 0.9492533764263298, -0.08269420514470294, -0.53877888746077, 1.174372226101963, -0.14335550574303, -0.5751494887760122, 0.14080863273957772], [0.38775214542252784, 0.6023469389016719, -0.0713299606881812, 0.052040277237129354, 0.7886530122517591, 0.2711420113093591, 0.409803893698545, -1.809753326384127, 1.424599006578943, 0.6650883765574955, 1.014604733107526], [2.6996128898500538, 1.0793908188745975, -0.24891750082199943, -0.02108105638497597, -0.1810643965461852, -0.159110708802073, -1.7989923648227055, 1.1386656304709093, 0.5006560019595302, 1.840717033276779, -1.3665929730212598], [1.0354852755374822, -0.5020206467889974, -0.5199693809820277, -1.2590554606235846, 1.0153604293170544, -0.6290288215539477, 2.5488421255816367, 0.7524371068637923, -0.4417370225611701, 1.0041961027396191, 1.6679734004059161], [-0.658995528300114, 0.8696257582731342, 0.07466678090335396, 2.270887589809408, 0.0241568759090442, -0.7098930609484476, 1.5109334210730676, -0.2821665347545587, -0.7013185961781944, -0.7099027585412793, -1.2970450470911026], [-1.4094432989173038, 0.5466262274346123, 1.219645050025084, 0.18682620728441265, -0.6077970343074001, -0.8302978630369018, -0.41210963830460023, -1.0251166250882504, 0.9321879213717753, 2.063877409774116, -0.6052206364202044], [-0.7494915081481819, 0.1640187752860314, 0.30872822423400065, -0.6163689319394746, -1.7577227458425884, -0.2229983127938007, 1.9445270864526323, -2.2029943458823227, 0.6801316327834493, 0.8644117150609745, 0.23427431145407002], [-0.9006618654373082, 2.4832951761245234, -1.0096151625451883, 0.01528487229822945, 0.24382041014502612, 0.8523627202799006, 0.41440831139478784, -0.3054361504632666, 0.04486828122966318, -1.5448968265156529, 1.5604178781949893], [1.412790419751577, 0.47333754677128986, -1.5306046310161552, -1.8041253731283782, 0.36848525059677967, -0.3279264431931541, -0.08646103958029577, -0.251473313772133, 0.9174063234097438, -0.13967836741845238, 0.5456834216588141], [-1.0167866942608388, 1.085913994740199, -1.7844798910490882, -0.902213842862937, -0.4313594014985412, 0.5358814092202328, -0.8012816121130388, 0.066698097421269, -0.8045237294033939, -0.10596464134909968, 0.6300443410842763], [1.5267518702503602, 0.2915203180974385, 0.5645557194125472, 0.40921889401778644, -0.28406872995664895, -1.2360075590199964, -1.7966483400217916, 2.3290287809171386, 1.2491958953374882, -0.6926046635979433, -1.2572014648583065], [0.03795677026702004, 0.6214473492508052, -2.038660310224602, -0.8205021433842642, 1.0547097854341996, 1.3522287932623267, -0.03853378702610469, -0.16927081975714542, 1.296805903478584, -0.7923712087190342, 0.6072791188827895], [-0.29469679939619975, 1.193522679196271, 0.7495560035181116, 0.06780314305723029, -0.22616752632010467, 0.6095753592627706, 1.400122580505552, -0.11098976007924694, -0.09652958612079166, 0.5453528090528772, 0.09304968450924399], [-0.9725526613945477, 2.588994362335724, 0.9255682329755965, 0.1577227595847925, -0.42157507462205, 0.48344174641890825, 0.008424508927348211, -0.6590797708824588, -0.5590215266080695, -1.5537253880661586, 0.27574791166894036], [0.816024548478278, -0.4042701494687125, 0.5931271371754239, -0.1214977821272483, -0.4346455980555386, 0.583611602528427, 0.6650888898825037, 0.5946048981281342, 0.8764250434836818, -1.4510268257262424, 0.050273502845271274], [-0.7070805794252406, -0.21870763304865284, -0.12327694055185463, -0.8573876209909372, 0.341258875895802, -0.28962066049317287, -0.9042392797152728, -1.4509731604382432, 0.8390964418890355, -1.917603375624587, -0.7245074442775055], [-1.107300638507509, -1.4738184425755343, 0.5331153864942862, -2.60290691162394, 0.7209897762892469, -1.5378915903975157, -0.12691374849413808, 0.3564761504507534, 0.9265959588044044, -1.1677424837043564, -1.8570491738722736], [1.0760769381815989, -0.012916040519985184, -1.0115444297939575, -2.2648553572641967, 0.42488550389304386, 0.12277527119776291, 0.012321495038403988, -1.5401140337312305, 0.5795898728328258, -0.9756294393936304, -0.7017381591856906], [0.7611732892615691, 1.863240868506913, 0.5156137232608284, -0.014458311201095482, 2.1177122361380567, 0.09599207310413005, 1.0857955365177905, -0.2745959778352406, 2.343388295818825, -0.7642057729831457, -0.8153420184530296], [1.8646091735468049, -0.12870698903153385, 0.4162662395777144, -0.3049917905937132, 0.07855767573779121, 0.4035248407917264, -0.5963246836324824, -0.35741915035980804, -1.7613731501539622, 0.33385900923842393, -0.9392968180554857], [-1.0945992102149582, 0.708393246984579, -1.240340459535164, 0.25871922892176713, 0.36024948385215805, -0.09856866424879729, 0.40107242808568805, 1.833593977143142, -0.47705361439054084, -1.7506573211714436, 0.20316349607950362], [0.21006055828751077, 0.9383230068608822, 0.1687478481759274, -0.5477284004930898, 2.757274998555782, -1.4062961707275896, 1.194787865219375, 0.4478670939277439, -0.47565724535097137, -1.4661722513357738, 0.3732516291959073], [0.2220387344274182, 0.5674551090472643, -0.43846260113699886, -0.15072659040848432, -0.522302405489205, 0.042994406810359334, -0.23436414092564747, 0.26185953211681723, -0.5686859298861586, 1.4121744553060578, 0.4481504656650861], [0.6932015714032586, 0.08431437995069845, -2.4421733915522283, 0.6182885178407563, -0.7579677397261475, 1.171233612725234, -2.6225389200312264, 1.2038346915920164, 0.19369287119960876, 1.0135606662046066, -0.09999168277946464], [-1.338557610708442, 0.3695486244602026, 1.003102336596097, 0.0010963248320071735, -0.9223449736639668, -0.6919390617143928, 0.4152747634859201, 0.07254380432146813, -0.9530687203168364, 0.276275096102255, 0.07034163559760354], [0.38821248522739005, 1.0869414050559678, 0.19218652409391843, -0.08153423977820237, 1.630549574626927, -1.4759619964415813, 0.4335675157678365, -0.3166263315451755, -0.38281843411047967, -0.47369734365511396, -0.6727099927663193], [-0.4090383535300877, 1.172325920768566, -0.6572889734413164, -0.18520984038884633, 1.7852897236594265, -0.31278891649844986, 0.3046684298142745, 1.3230301692403255, -0.36055038610880186, 1.2926874790038678, -0.4414796799254158], [0.44942259207880425, 1.1214371304228279, 0.14277434583894083, 0.46260329534833455, -0.4301581775537919, -1.2194350376431693, 0.02144915782577583, -1.3145368459068754, -1.3909902023849994, 0.8382415577665988, -0.435383251187962], [-1.1696184938627971, 0.3207104879036821, -0.08173421388544196, 0.9650561118484863, 1.2316139734347282, -0.5253861952033867, -1.682524683128045, -2.141961424398297, -1.4714153230604743, 1.7967576320773584, -1.1762862996688024], [0.4069377265197215, -0.515051643008915, -1.2593203624386373, 0.459822269837741, -1.006396862449664, 1.2502274289950102, 0.03799135839153012, -0.6633246729463584, -0.039615683624673804, -1.3236850750456424, 0.006982607982885088], [1.0411924392546485, 0.5256819376724975, 0.02153195404930484, -0.30618030796139745, 1.1169332440003885, 0.47213662047347094, -0.8037374083563976, -0.48730640937074304, -0.41765157363499833, -1.5729398559482082, 0.8359578982822141], [0.235051878367084, -1.0005688520877067, -0.9141821162789588, -1.6467662728591062, 0.28823233612663424, -0.11792293562519648, -0.581295590674406, 0.2789023756138623, -0.32715618210828495, -0.9389774516906471, 0.1679644019638099], [-0.1226799005234017, -0.2993736457014252, -1.6875289029984486, -0.256247483243878, -0.4697471320879693, 1.3668385161104797, 2.1545185151470636, -0.6877587610846015, 1.6222524761407593, 0.5964779313513737, 1.7496875659491462], [-1.2796568662918513, 0.1394731084134215, 0.592762172481642, -0.5765716787188334, -0.6101015728968043, -1.5924940749559031, -0.9114491461225652, -0.3893407612050608, -1.4743078675848944, 1.4737407570975294, -0.6758366397095976], [1.041482031674611, 1.250773171368331, -0.16561007051543408, 1.328675598303735, 0.8592496384267845, 0.9536991378774246, 0.8153241010115668, -1.6760926606316948, -1.2396481970497897, 0.35519474017269154, -1.1946309956093608], [-0.7182654433773886, 1.05132747897526, 0.3436489500123604, -0.647697727999297, -0.6553862234099811, -0.9525838279240532, -0.037859022915580055, -1.1350396342365232, -0.3729168512327389, -0.005817422754940633, -1.7840036111993152], [1.0234291364556087, 0.0393377460270373, -1.6764655210473107, 0.32959209525507005, 2.0472511856160485, 1.589134381819155, 0.626086385998275, 1.779788153618257, 1.048776624508783, -0.5963681913534203, 0.36576465088125265], [-2.245372851726508, 1.0365538927553255, -0.27825552423874594, -0.052588179971068724, -0.7458362524514169, -1.3719622332200383, 0.39619463458215126, -1.3790024220050061, -0.9450235868513873, 0.5203554225338721, -0.23504377434207602], [-0.41814250404163333, 1.1350036508933568, -1.0863610200907257, -0.6953755817467457, -0.42568805409119087, 0.37482154737807266, -0.989100733005092, 0.38308575488479746, 0.5436150201714869, -0.24886688452444172, 0.5598473916491284], [0.3648274259760012, -1.2605397724678062, 0.09846406007547527, -0.4835576567727527, 1.046746877050106, -1.9853668980540966, -1.0635483486751036, -0.9381749138492117, 0.6501191820248042, 0.26204166311064164, 0.5885840531498873], [-0.05202816953191403, 0.18596022828178987, 0.7171028104150116, -0.05946129373673437, 0.13566710512929256, 0.7548273733392359, -1.1277204575255584, -1.2008736630024537, -0.7913303194819343, -0.8748915634599985, 0.1796533378252569], [0.9150954331392123, 1.8208527621222803, 0.10300072734011899, -2.03135533144859, -1.2867007813337679, -1.6332527229009448, 1.6768004469979274, -0.853014991868466, -0.2156859398880096, -0.8924845710295141, -0.4570583904014223], [0.35895416727703955, -0.37248365482369616, -2.180446737976995, 0.3561785057405736, -0.7627688186301868, -1.1547821457826608, 0.8180023496347102, 0.3202233779704561, -0.5544766319984027, -0.08943396902300595, 1.9495861762655544], [-0.25515318876850757, 1.215762892213149, 0.6060361009398346, -1.2595711008672439, 0.7159729490413889, -1.6191204231608345, 0.506058416241664, -1.7913360427393898, 1.2046592400818332, -0.20208037117280386, 0.6232243666665048], [-0.2942603057395799, -0.46603656449849906, -1.4266251362793652, 0.4774686862912761, -0.6057600050684757, 0.2635355946477431, 1.8519220305139805, -0.46628509717517613, -0.6032179924318481, 0.1368640049575054, -0.4183549679580006], [0.37491083950311005, 0.15786690371999912, 1.5543672026120365, -0.647561062400716, -1.4499527217823693, -0.1538725234441346, 0.4781379180803594, -0.10141741317352153, -0.8927616820213021, -1.1204775361296904, 0.8219064408418767], [0.30333611587615644, -0.2791769003467225, -0.2350108596167479, 0.17631384488595947, -0.6120967463084301, -0.24389620979424484, 0.4839658560735628, 2.50585254807261, 0.3269714525403178, -0.329640892731759, -0.5034066773694382], [-1.452905300276322, -1.608356471493908, -0.18219642412057702, -0.10681394922545742, 1.9521065627671246, -1.3423208084251361, -0.6601471867300873, -0.5937049583409265, 1.0021706818344482, -1.188530572745136, 2.0237442954262717], [0.5411546461610881, -0.3413221535563296, 2.098066767557307, -0.4598977267064477, 0.09292911648104785, -2.622852551218477, 0.4852170703079986, 0.10217609143237616, -1.0721787663336166, -0.4581086840729606, 0.12269212744882751], [-1.0916929705893839, -0.9142704393284883, -1.6323018765518593, -0.5969523811962016, -1.2407523021749287, 0.09676771407647751, -0.3758724542391508, 1.181597908805889, -0.7217472924664265, -3.4275278410197636, 1.2561582848018344], [0.861883823566763, -0.7647321951237025, -0.9675227845260203, -0.44659785233158883, 0.7505330533855352, 1.0768537121282171, -0.6070451710526802, -0.7618307063926626, 0.4577580869782135, 0.7363354172330023, -0.2601482641900028], [0.7193810744266004, -0.9107281440455601, -1.3114191650528109, 0.7885674077572308, -1.595602759396589, -0.21006702478715558, 1.0602481167343365, 0.547827902591185, -2.2195996946850447, -0.4080944193339973, 0.8071275685061662], [-0.7044940289547545, 0.9860433401784802, 1.1234453719812534, 0.20642909567844295, -0.11492238599122692, -1.1726116786795706, -0.02860456153208979, 0.0012893384271333182, 2.007480863321665, 0.7075110591405315, -0.03460475561700726], [-0.3494137490374101, 0.2864475133630456, 1.0078371022787205, 1.9627671917487055, -1.1730146692345838, 0.724075609806995, -0.3536659320410423, 0.19226584101117666, -0.3635267451441748, -0.15307394311826342, 0.6607896743210266], [-0.033443777481138436, -0.9637894453735562, 0.9528303891406354, 0.5864305184527971, 0.5305473698512472, -0.8305585322643039, 0.7357320153786665, -0.29358157082035025, 0.9818803359176651, 0.34952786087443694, -1.3469177950188869], [1.6288109679940483, 0.0839838380129485, -0.47347717617601676, -1.1528658087432087, 0.25693933841130856, -0.6388178871841661, 0.4183265979071121, -1.3464419249516169, 0.3635161756555392, 1.403514900662874, -0.4135999585991291], [1.575636565969534, -0.8877697627903897, -0.7352261676917476, -0.8278228737983412, -0.928386907665344, 0.781521818941904, 0.15962565366758982, -0.22048197478537643, 0.47653600943683816, 0.031122756219365152, -0.5606161833305282], [0.015696663736852624, 0.5411453358188619, -0.37641948855074264, -2.19448841286217, 0.5023322212454603, -0.2221175806366146, -0.5608019964075572, -0.24551609527150972, 1.5926709782927762, -0.723891632274041, -0.671472319479903], [0.9858799492472253, 0.10171152686214485, 0.3159385216948658, 0.8955756221331683, 0.9387189860468299, 1.6762559072085061, 2.0902330984809057, 0.09759713728414691, -1.443707831115802, -1.4254347160079108, -0.579523280329519], [0.062152189634681686, -0.8588611747202477, -0.8931490928149549, 0.17557300979411516, 0.4611759754426946, 1.0938563053274513, 0.8012270139569745, 0.49802694253370217, 1.0206032189713725, -0.3755258041352424, 0.8183829389944808], [1.1936437793330177, -0.07259323553548946, 0.005740419187321253, -0.39632870573898493, 1.2672770382809515, -0.38509661909548637, -0.49394585302916866, -0.7632487860836393, 1.31072278646141, 0.5810108474350171, 1.4502311121336302], [-0.46265497384613385, 0.5881867901702581, 0.6959334155339735, -0.7148972773769962, -1.1137907241291347, -1.275033255382002, 1.0726351603604312, 0.4733487122531651, 0.33135754758872266, 0.7864846054642719, -0.26224075930468016], [-1.3063336059208221, -1.2528795246985787, 1.518158758738166, -1.8204375521670837, -0.5250555217531676, -2.0297550081041225, 1.2941537967956311, -2.407044865355224, -0.43131535043458447, 0.4256097437177492, -0.1703866779019153], [1.228553230420566, 0.8580802379721828, 0.054816055808101144, 0.030004755089288335, 1.3790871962323024, -0.6976667462153285, -0.028163245954142522, 0.43808250774004504, -0.9111381030762588, 0.5933788533067206, -0.36398415389785616], [-0.7291631110607918, 1.1981559497035257, -0.323073381974792, -0.14495633410125522, 0.0297102502999084, -0.8133477872118215, -0.07445232505551859, 0.6118927581707205, 1.0686288491828742, -0.2975221870891073, 0.1612798773253734], [-0.6794372683147162, 0.45878442314860546, 0.0005436031491962805, -0.29611912822539654, 0.7084349612756634, 0.012116026600762806, -0.7828486484094087, -0.8191500495493396, -0.42500787801251566, -0.28164327243298815, -0.020330956696314146], [-0.6539377043139671, 0.3957604519971728, -0.2404272620837438, 0.14918824919736437, 0.5331320543019885, 0.7847577623192495, -0.2854838594853092, 1.632198521735314, 0.7989392047852767, -1.9284270804979677, 0.8528290380503577], [0.9930754097577748, -0.6819506456119613, 0.685453156372487, 0.17120813487860273, 0.6543752039344735, 0.28543625611965184, 0.5656532292402777, 1.9919800894073323, 2.134065955034646, -1.7816261948972179, 0.172191097682412], [0.3621239213748213, 1.1651764582433897, -0.6604749947315495, 0.010232524974921794, 0.5994342608536812, 0.08717232306347529, -0.3268368465458957, -0.7762473015013338, -0.7694746379529797, 1.3928263648710792, 1.6547136723611562], [0.3662673529164151, -1.7139337685819191, 0.19729320815284196, 0.5666470674309565, 0.382283891825393, -0.11268801907663607, -2.408395434771497, -1.835283872131895, -0.1865690590255575, 0.6708040174856126, -2.3331051340365114], [0.08261473559446388, -0.8152817279996569, 0.7520363483831707, -0.823707414116226, -0.6545431138247496, -0.9024239258733014, 0.19642980808082677, -0.8655718156557669, -0.878273258297885, -0.870923321778611, -0.3419855591165155], [-0.2585102803976317, -0.16905458357543257, -1.8107541282958657, -0.8885900416227377, -0.2733268309688006, -1.408608848537285, -0.37688408278378793, 1.4257377491343763, -0.20415961737922408, 0.1591835018167436, 0.6134165360561693], [-1.4769746722476265, 0.009414935525508232, 0.0673451131381669, 0.974967113807018, -0.08015785248250328, -2.0928524812801217, 0.8854875258171494, 0.6011850133808736, 0.004972464463170941, -1.1497657154442833, 1.545188584861436], [-0.27870841769507976, 1.2333283044248795, -0.16347948667416626, 1.1885918997588059, -0.16883261913650457, -0.14204725933866108, -0.8693704512563477, -1.097523396500727, -1.1334440939234325, 0.440395161570648, 0.007224565119097885], [0.06382379335577751, 0.7320272167288894, 1.5113424518459952, -0.5417840739365339, -0.818674356813564, 0.5701624999895045, 0.9875875168210493, 1.9096495411042698, -0.8741901336045171, -0.006020545525686212, -0.293070639632493], [0.059351118079582925, -0.7005151631723433, 0.05385467140509663, -0.27813125300524866, 0.08516288832666528, -1.3315157032203886, -0.038482026780652566, 0.6124018767017009, 0.3434705886869066, 0.020156849347615597, -0.9368072729691374], [-1.4272746494563555, -1.4782511595373673, 0.4535404852611643, -0.7296548594280895, -0.7257076087855738, 0.5346876500596566, -0.7863399063420549, 0.5509120537749318, -0.4949180837915423, -1.1728000023165117, 0.8424543936880895], [-0.5055277667445112, -0.5632711124381726, -0.3106492881270573, 0.4056619438919009, 0.9254895451692032, 2.081007853962234, 0.7299397227891109, -0.878388215492269, -0.4470524788420023, 0.43603075667154784, -1.9693673542841565], [-1.2208828944217054, -1.3793719145883663, -0.3219355427830522, -1.6686802055717795, -1.5805390577807577, -1.8502607943490168, -0.4051935522879936, 0.9561543112652512, -0.7655273645942118, 2.0671013275828347, 1.5984098914458276], [-0.5020701855647315, 0.3265325289290007, 0.49471054294907635, -1.273046753023157, -1.1339247557001335, -1.464683801805222, -0.16388799079929017, -1.1674764069943715, -0.25561407843523054, 0.4346467411055088, 1.086215252062708], [0.20677258182671665, 0.866421802846534, -2.180529471104563, 0.720344912193855, -1.535543400247331, -0.5785202461425555, -1.5758108063700682, 0.5775991678370119, -0.9350521750648668, 0.05459663041668254, -1.1912565165813203], [0.08857980347056718, 0.3141421122448403, 0.6721248969312558, 0.9300601842826708, 1.5071479418359173, 1.6466571130220362, 1.770483357134033, 0.6924048992395024, -1.0791542295752663, 0.0006236533563167899, 0.5481343378974161], [-1.0306321525410334, -0.34386545852711087, -1.180251687495047, 1.2719134024831318, 0.4053715019444323, -1.0210823960879167, 1.531535466366879, -0.6965643802709998, -0.03991811577076142, -0.40023272246579794, 0.9931299679029355], [-0.18212217093251098, -1.4611053258786348, 0.07472313607518415, -0.3685558446959996, 0.20979101586819698, -1.2109520013657702, 0.7143564529609139, 0.8602963566882669, -1.5229383563687107, 1.9391951488524346, 1.9186384979634674], [-2.5554655057793427, -0.7053955488127527, 0.3899325914801191, 1.221768629748444, 1.1204350469314421, 1.7286037575448523, 0.08548165507346106, -0.513619116187055, 1.5706794660704952, -0.8282020955276242, 3.1949161183101094], [1.80588086199481, 0.5161536193740572, -0.2877641073751109, 0.8282575883763417, -0.05643110494672512, 1.4916879495576532, 0.168063291615398, -1.0578203674289537, -1.5354424142676308, 0.13227829551223566, -1.85584756916217], [-0.8348505904174935, 1.0655590419580963, 0.007398054983615158, 1.2893035094421617, -0.3531307065800515, -0.3786882924353206, -0.1581390348930063, 0.17755437039721, -0.42716258339354196, 1.508937069722211, -1.8449339558519684], [0.17346426931926734, -0.5963951190864, -1.8348628899348507, -0.7717252101817752, 2.055542510705919, 0.9027139537159994, 0.714680043586044, 1.0355453307624811, 1.333501678109937, 0.4290382871405553, 0.24843838949460612], [0.3560057741687154, -1.6052870421199448, 0.8472163920309637, 0.6363277061032756, 0.6921638950445125, 0.9932992415453884, 0.5578354016501719, -0.2589691914150234, -0.8129668962231562, -1.6881268897995594, 0.09137666595789616], [-0.488361529023726, 0.25049374165163957, 0.546645833893806, 0.023161832539284735, 0.9873963488597911, -1.063243298826217, -0.4779299994596224, -1.0303095678927907, -1.7537636872047992, -1.5669464316740647, 0.7891645091509246], [0.2701170423201563, -0.48729172576993124, -0.019823767630328316, -0.89468077465535, -0.20374026483867094, 0.012891265062823948, 1.7756061390984794, 0.37829370001253354, -0.7708987854118998, -1.075507225111361, 0.32443708936368804], [-0.4454751469372457, 0.1275155998222922, -0.3526606244056267, -1.0982417940139249, 0.12849294712338735, 0.22649659017026474, 2.0164984181711536, 0.7327719188962127, -0.8178961905136115, 1.4986923045067497, 0.4127676615486539], [-2.6987232493728457, -0.4440901688253487, -0.38459210666972937, 0.1642989843040832, -0.9109599141888293, 1.0130949821733342, -0.7563610972275994, 0.5933525749221112, 0.12092958376707753, 1.4205058337722736, -1.0919475969291237], [-0.9540839029184944, 1.1980808903967202, 0.03470663913194237, -1.3194877896163368, 0.8659283748370247, -0.3074870568162875, 0.2903158416552902, 0.14864980609561634, 0.26018145276251353, 1.0337194090057544, 2.032041792526179], [-0.0027530711192891937, 0.397369436881779, -1.1233286233974253, -0.5414140055514239, -0.9027134052664093, -0.7394882186100843, 1.0849914630737805, 1.4806977206361722, -0.8221030831493246, -0.29601053629119156, 1.478666098844675], [0.12313434181793532, -0.8988868149879908, 0.028066305881087866, 0.2565010861776268, -0.8038924565317426, -0.13315477371278703, -1.0909861246467, -1.5441205673028893, 0.6778428990458997, -1.7587295961654967, -0.9174549574185824], [-1.6876571884434057, 1.5234281158795016, -0.9209400972705315, 1.5883272929688084, -0.3579545230181904, 1.219929183507807, 0.722686103314672, 0.056941424968972656, -1.701092352329757, 0.6324786705685664, 2.0794099873396665], [1.285466883782608, -0.6725140760968834, -0.2720780968431731, 0.3186513178932878, -0.7357566888081637, 0.9937837327784385, 0.5260308172096553, 0.4583286737735333, -0.6830740792455982, -1.0977415999771873, 0.3292282991060411], [1.0141105833239366, -0.2047939992396227, 0.9647932921534802, -1.5425519414349718, 0.6231257228859145, 0.7357464122357938, -0.47040765123141526, -1.5916552851044943, -1.668561624513854, 0.8885459707847646, -1.3600185534812308], [-1.149682558341734, -0.6746216591501505, 0.1319030862012211, 0.07606205227798267, -1.61190149366168, 0.16795949832522142, 0.468993577426277, 0.4554604956378376, -1.2313992800116034, 0.20593849834261116, 1.1397160494088046], [-0.40070628681644, -0.7445015747970265, 0.16049170527749565, 0.5833882118360877, -1.146497748466616, -1.5535994108151925, -0.9606682048405376, 0.4009476004900974, 0.14533549704379764, -1.685825672040471, -0.628865933310794], [-1.661935802135576, 0.8456373890243216, -0.04503726274607789, -0.9288574509745142, -0.9316290632503423, -0.29452619118237694, 1.8669461314971567, -0.33546156332664206, 0.09922883312840136, 1.354567997419231, 1.1408860204887035], [-0.28076607716070057, -0.6013524000408075, 0.41988074221370475, 0.3016671563319447, -1.4585770471143198, -1.489840101999026, 0.4021099634754497, -0.6450003196948975, 0.5119663569573861, -0.09456211679616956, -0.4497835789352364], [-0.1479758015675427, 1.300988017943945, -1.4572448031440755, 0.35561739976871376, 0.9605683310186969, 1.7630975125576096, -0.9424172610210497, -0.277806423035193, 0.5029504395673234, 1.6340975890925347, -0.3312828460410961], [1.5631962738755003, -0.5677489724990977, -2.1085693758415873, -0.9992101178503874, -1.8496351954033547, 0.2647852876314526, 1.0709433624902012, -0.44876657738352516, 0.3003412052750464, 0.5328469336373282, -0.891507177594206], [0.16884877999401113, 0.0037120145227655704, -0.1984652403273843, 1.0075034617159175, -1.3570302936225314, -0.33281448143733955, 0.559996218915469, 1.3044892464090658, 0.6014292219217662, 1.7207069706349518, -0.05246922472583712], [0.9333068779106252, -1.1973349125682604, 0.5182595908800965, -2.0298515941525697, 1.0612937220364345, -0.5669362321790634, 1.120720494768404, -2.390022805022067, 0.9854810434769302, -1.2601559842043786, 1.2976518412165294], [0.1464569373657464, -0.11118652584547999, -0.061569826067014444, -0.15422315885012516, -0.6632587198223342, -1.5738859711331858, -0.5565319631587995, 0.35751933063433666, 1.3749592089703626, 0.7042422604900204, -1.6720023727184665], [0.18720306352649402, 0.2707828259673176, -1.4049551506499054, 1.6806944865726947, 1.2452835355076552, -0.2006692107333116, -0.9372866935800848, -0.004246624634303593, -0.03186115267183938, 0.2113962009517022, 0.15190951454349902], [1.4612501312253863, 0.281133939918577, -0.024761874881613192, 0.6519411024211275, -0.00012114733455708261, 1.2266297484318243, 1.0985673249786039, 0.5065596749559786, 0.7764872913920868, -0.7287862978313233, -0.9989796395746445], [0.24506249192967822, 0.5939628411009155, -0.71330046666607, -1.334294924220492, -0.7488517804487924, 0.6434834746195838, 1.6136303488203554, 0.20674095003716195, 1.3701601371180405, 0.6198620948178927, 1.8326091907066506], [1.576658425877057, 0.7328640385091824, -0.10385042791620633, -0.7016160724985038, 0.21254553807922294, -0.7359016769404343, -1.25350979790021, 0.4933493909281116, -1.0311993466962341, -0.5777180783197186, 1.019205401782629], [-1.9129054719827425, 0.5426563596416615, 1.1537330374099404, -0.6366141220556781, 0.2508498556636611, 0.5889559676537617, 0.5009983550064321, -0.7619487986305132, 0.3727317811087478, -0.09102210519476028, -1.0822565396780035], [-0.03885859923185032, 0.5068633435905957, 1.1374396652908434, 0.3498853519948762, 0.1557054039256063, -1.018122547533656, 1.1550310425052894, -1.370885173452839, 0.46758752823218275, -0.553658206859269, -0.11085565520842318], [1.8609844575013226, -1.5431137609414343, 1.2828640843166945, 1.2709740819881188, 0.09969598734135698, 1.0500225101909317, -1.7547729373368564, 0.3415256545128105, 0.01623728716912923, -1.1262929910089183, 0.4294321391206534], [2.386765279320377, -0.4211876446707577, -1.6120976491956194, -0.04031401602427242, 1.0331130270698237, -0.30754674595636833, 1.0801305465205135, 2.376137139297063, 0.7473155146157849, -0.9691902858241275, 0.5460679590711476], [1.2305435360833274, 1.7647049376982868, -1.3578131135118814, -0.9889942915183266, 1.3870781689510623, -1.680588964502566, -0.6547866593562551, -1.7836386084285938, 1.3797154125587325, -0.5204412033628033, -1.8072251804978665], [0.8441810481649104, -0.1092721249814738, -0.7233393483030259, 1.0120796189537808, -0.07759582008328507, -1.1346566807715455, -2.14684599632613, 1.1018351015807957, 0.7238234887036133, -0.4446705877289288, 1.8046509458241902], [-0.7982178590681726, 0.5662503233280735, 1.1066770125830547, -0.961546209813095, -0.9985080596483237, -0.48964542556413765, 0.5889353220355547, 0.03068657844004274, -1.7499887538861163, 0.8370316638802805, 0.12760282406890025], [0.2958777334885471, 0.8292812424736412, -0.2514260743275684, 0.986976007659003, -0.6896456740345472, 0.24109130279015575, 1.4347510626726003, -0.06851229882122031, 0.9124658102409956, 0.9496926959327935, 1.2007493126645343], [1.2087303723768308, -0.6702522426804326, 0.5809160576949282, -0.282445914890101, 1.0832688125519314, 2.3661135575089145, 1.158294888432547, 0.6492088463702577, 0.7939372416959231, 1.2168574043863656, 0.6208425139869337], [0.6191883285449843, -0.2793340239517387, -0.4221018424358912, -0.45265027152752363, -0.5014876364321832, 1.6798857569435421, -0.10866835351475274, -0.551482551350575, 0.8018195238532526, 0.434676534990205, 0.9985240644299088], [1.0330478194642816, 0.068581036741734, 0.5700878453624547, -1.0915314439332662, 1.0957699412726352, -0.8382876516300802, 0.45208851278193973, -0.4129129186898014, 0.3688095580511016, -1.4670394729693006, -0.5886731383062851], [0.3815822490387992, -0.6917370427862296, -0.5014335104591724, -1.1722992521850473, -0.6287294151510627, -0.07284756718543978, -1.0583764029957659, -0.8187059819424728, -0.8741662461380026, 2.3235163909944214, 0.5085415219307176], [-0.9219940428513987, 1.0224186873992043, -2.143001295884342, 0.21859027086903834, 0.8334081213961055, 2.1633232097310833, 0.4868208240721606, -1.023988468951888, -0.5520758191442249, 0.3874029375268459, 1.4535011043198947], [-0.4792633045911382, -0.5617337862898202, -1.1386555539589829, -0.3591641468052442, -0.8386291535404083, 0.3325874488051871, -1.3519286094226513, -0.48583338038174195, 0.08805607811460939, -0.3665623704106097, 0.38655726041704347], [-1.5510964021963483, -0.5843570843140796, 0.4530253454412094, 1.1905641022537823, -0.2465817645078051, -1.7553289096542177, 0.6917830772926948, -0.7193859564163947, 0.2088037731241824, -1.696353820991041, -0.4168244166101968], [-0.23970555337251917, -0.598912629818096, -0.2222590993149501, -0.3708273761102486, -1.9317456685762824, 0.26773904471478704, 0.17178156573084144, 0.381440233229747, 0.9353039683234381, 0.5898078953388222, -0.5821582727632574], [0.01173841814111875, 0.28187281341427234, -0.9625892226042254, 1.098240178826275, -0.01819168495250671, -0.1288215502114501, 0.12008651260074833, -0.5794204605041398, 0.2125217004024998, -1.5206761822646837, 0.6958155164824669], [0.5016913268255705, -0.8262586475017328, 1.0974347312019956, -1.6659559899088774, -1.6876948761544306, 0.338066480665337, 0.5946366296199547, -0.2871905293186195, -0.9964135782278482, 1.0430655313304478, 2.0652946725357872], [1.1204875004908292, 0.5058522243704263, -0.0792708166789493, 1.461544811240721, 0.6974151308952593, -1.0853994923778438, 1.1244244044026015, -0.9329481325548966, 1.3812454320525882, 0.595680545518155, 0.5794187276704986], [0.7742038160834267, -0.2052451996087412, 0.040956095243747326, -0.7088079527824652, 0.9664734664669433, 0.10484715504247664, -0.33155836065723215, -0.10188555271504612, 0.34294536480145155, -0.0227144376914806, 0.09061637127033298], [-0.8544783645101773, -1.9372399558263511, 1.9322544673311117, 0.3827291257275181, -0.42661290046515016, 0.15544099937353686, -0.30156408121223616, -1.8967183824412635, 0.4672643922028249, 0.1396090880212846, -1.2011199122156482], [0.22141610159809058, -0.8621874221432221, 0.2646402733823072, 0.8017697465030669, -2.3248582076721966, 1.191757567683503, 0.3494540523194451, 1.0072301264413381, 1.066993243144194, 1.2105992320572694, 0.5171869518122608], [0.5476205951928945, -0.07302294720680316, -0.2376116679547096, 0.2537680233766186, 0.7551319409721412, 0.10124379745915105, 0.9162472001456908, -1.0531942258714582, 1.069622347411057, 1.1368386295011588, -0.15922865248808213], [0.13559983864991595, -1.3062692273811665, 1.4119538725483731, 0.8703910483553003, 0.4335730216011285, 0.3897337943941517, 0.6226995269358178, -0.08972539065274948, -0.24088946662341063, 0.18263245311269943, -1.228659040538516], [0.5903356429672696, -0.8280955665592431, 1.0563962731430723, 2.322022806514436, -1.4011737974759526, -0.21199840410615095, 0.7215699567594572, -0.24755675484285736, -0.014791053478724493, -0.9944112803730998, -0.22804061939727216], [0.34436698313739483, -1.2093714007302783, 1.0995249278769001, 0.20491552719292225, -0.7794099609237412, 0.9644935283492424, -0.9515197435307545, -0.23056252220924287, 1.123147920124362, 1.0690008735542393, -0.26889005695338136], [-0.887840304732052, 0.30573241456121164, -0.9704872769758388, 0.09888595605762612, -1.4734613621969457, -1.2525271090945438, 0.9232615973434926, 0.22479325229658267, -0.42980949374697835, 1.8563250587447038, -0.88351672811037], [0.21240809220956722, 1.0407487979271153, 2.4873985886311543, -1.8932949523985605, -1.5699079498056987, 1.2425576991966287, 1.1946252051234472, -0.057835151291342236, -0.4702301664486281, 1.6755510266385427, 1.2060442573636747], [-0.714391988577001, -0.35645971165226786, -0.6266056186069076, 0.4989429524174727, 1.6194082979078317, -1.2901929943455483, -0.09456362480563475, 1.4566941552202661, -0.765463226987887, -0.43172181329530723, 0.7375415823221172], [0.6295183053723811, 2.1173425093902423, -0.17783705404286868, -1.1409894908914886, -0.7044925382824813, -1.4074981824663704, -7.058841366734552e-05, 0.22209587496704414, 0.19579370562463988, 1.600190823429671, -0.279516356058516], [-0.6561987254548762, -1.8449665078655904, -0.9756928750421633, -0.8074087529223635, 1.31047543079399, 0.05781636383463325, 0.1226887263147367, 0.12268489559165631, 1.5602466126509515, 1.9255257330774174, -1.3919976283037974], [0.3077176050408724, 0.08248617257551513, -1.4622743377045975, -0.004979099835252863, -0.27330925714802756, -0.3452871759986539, 0.0756803631651395, 1.1661035774187927, -0.03403926941672209, -0.5719124651016623, -1.7242799303849827], [1.6215784636264274, 1.80442301040709, -0.47081188263013196, -0.3092307180754546, 0.37905694765335757, 1.3900491218384776, 1.212827488781576, 0.9409334963656049, -1.918334392841491, 1.013457389233102, 0.2918989609235101], [0.26259833099563185, -0.8706179325609283, -0.45906152638568415, -1.353183799495703, -1.2246305260999462, -0.4100906647036789, 0.4569640076597085, 0.26277513522676255, -1.5641450105670427, -0.14634623737697464, 1.4349234595717921], [-1.3203931263730886, -0.4196600843786145, -0.523013137727412, 0.7671753177584872, -0.8515758070642646, 0.1698654959930276, 0.05955568265956829, -0.2835780825156372, -0.3117147769054308, -0.30136048437357515, 0.6683621979719453], [-0.9546933173276377, 0.44750166538900715, -1.6924632655728202, -0.22823822006534022, -1.1000334705556924, 1.0414746597152484, 0.8181880315592277, 0.027218917734647425, 1.142311018589604, 0.4760701717692599, 1.5649854955908895], [-2.1798997730393075, -0.049392250726201334, 0.8825332503275516, 2.146119217876775, 0.48952007415133864, -0.9160371689411757, 0.5210208828126743, 1.1352013905860767, 0.9333455491456011, 0.4617177908657677, 0.18764362964754933], [0.11468162144125953, -0.30849222766376516, -0.3147020833018248, 0.058833966295053886, -0.03736909544998863, -0.6194738127876788, 1.5802931200042827, 0.32145493833761507, 0.8351072404192245, -0.8131119399121337, -1.3915900668017898], [-0.5246136283808158, -0.6739975830113021, 0.6949731665140017, 0.6903269679039576, 0.843065658719915, 2.2127487679831854, 0.41803081452001856, 1.3665105343329875, 0.41521224848866684, -1.2100034430720379, 1.1766126015908873], [-0.09000712937019235, 0.10177951224971413, 0.31152073190050655, 0.05315378654051247, 0.456218831863369, -0.2830554197401604, 0.08444085990671903, -0.10718073217585114, -1.4727272411799663, -0.7059165468085135, 0.3079069353824377], [-0.7978454525654396, -0.028136484080267123, -0.2838800756943059, 1.629712228171199, 0.01596988865836274, 0.08694522483372596, -0.09617906064152401, -1.883100875226894, 1.1218447638668243, -1.03030483691793, -0.28991123441572564], [1.3538575761009657, -0.701800554922522, 1.1546074685722163, 0.43857278891806106, -0.990247860882726, -0.3117922107222804, 0.3018297925153534, 1.103966336158295, 0.9395530073260054, 1.8316661768751445, 0.4845136805838092], [1.1225921657192526, 0.6696135181600833, -0.8513614534454184, 0.2558460208760817, -0.032652906791538094, -0.511084627545978, 0.35791850367112465, 0.9583726711047821, 0.41749937403460896, -0.6455291121359249, -1.5484199294054848], [-0.2663522637317928, -0.3931787282300644, 1.0355200464736045, -0.3938935405757355, -0.05108628600592451, -0.9246546301556914, -1.6283586318337009, 0.7630032268657208, 0.3334083908251451, 0.17735225894719114, -0.3079543184443125], [-1.1437153808111016, -0.29585794499644397, -1.9648345738761293, 0.6644930183355623, -0.6262007250092, -0.8098302173732067, 1.0829175817719288, -0.9624764723435518, -0.04978032621192173, -0.03122954101821003, 0.6556590314996945], [-0.5299341954256239, -0.030249830530957013, -1.5057801130521433, 1.101442880711358, 0.029275284436721765, -1.0674231672848566, 1.1725358511109416, 1.6906271272186022, -1.0523671914595938, -0.6853005421605972, 0.0013929387729967608], [0.7482147763795984, 0.7560540063180896, 0.10010752402751812, 0.5494993697991998, -0.013750692800844615, 0.7029282952820155, 0.8137958311761669, -0.36106630447259686, 1.350542893426083, -1.2432814873031006, 0.41986072556827], [0.48312957113598975, 2.245696190298554, -0.03630982836982949, 1.299537810610525, 0.4934653221297115, -0.3690314226562498, 0.635594100454342, -0.4083324848100047, 0.6415488814598745, -0.5354694839450683, -1.1045203071981242], [-0.7437915180062806, -1.5557913022341978, 0.5174478094208129, 0.8554170196086145, -0.6994026318803614, 1.6915426480166278, -0.09031084907929662, -1.6679204708854407, -0.8952886233006278, 0.3938092765162264, 1.605215256583557], [-1.6603317706144236, -0.4415637753129742, -1.303274050471401, 0.2762541343049454, 0.8341658680359952, -1.7516991625744405, -0.563267839304633, 0.1897702454374694, -2.347885224184757, 2.007390742940897, -0.29555172757783943], [-0.7095981570208083, 1.670804490694278, 0.4706238719749286, 0.1961589478523126, -0.07388485714024412, 0.7617977649100067, 2.2808265922952744, 1.9517066809901746, 0.3646749677094546, -0.5368174945272013, 0.7195198313781479], [-1.2208543040826574, -0.9709250969411192, -1.165441440716368, -0.1519736292995574, -1.02074037468086, -0.2406935060013597, 0.26014653161941875, -0.19436257870891058, 0.4362534334118188, -0.28961681948408224, 1.6482554191466952], [-0.9995130757547664, -1.7841174822153378, 0.7260895753575771, -0.6918599793549514, 0.034573235955449325, -0.4347723433432981, -0.19826618678340835, -0.2877768574829606, -1.1751828391898662, 0.06902646698725354, -0.6724859841916703], [0.5294564594728539, -2.094888265721859, 0.4393181311924345, 0.3399844914698607, 0.504468227686339, 0.47771200042149403, 1.1952222245461837, -0.01063050917604615, -0.5574244206757266, -0.5483090661996735, 0.15143638793302996], [0.9351991617061695, -1.573726735099384, 1.1902769586022077, -2.182432658816341, 0.41785520869977183, 0.18321164014538732, 0.235374733130005, -0.3543354944504777, 0.46117941103754895, -1.5180131656091114, -0.1588412329816447], [-0.6718249367393277, -1.6494269398747958, 1.1413650593055147, -0.4488653192461176, -0.4041635270075468, 0.5172968366508206, 0.7511627175348723, -1.3492458773884595, 0.7933856947510456, -0.429201617884147, 0.5494000367567854], [-0.5531581405167534, 0.02717354424509986, -0.4456286384275973, -0.47653747040534405, -1.3724114351201415, 1.8830113660938663, 1.042608208105355, 0.5327342693992537, -1.3702639656972277, 0.10589353639746814, 2.2597223705008984], [1.1432981479204682, 1.5112449202556695, 1.8063145444185882, 0.694189439743254, -2.0926154869745206, -0.04013591573803938, -0.19410744573941233, 0.7393509652480514, -0.2256506442196573, 0.13799198818865566, 1.4965190785518208], [-0.4500416603849931, 0.27151972981686456, 0.16286194780832505, -0.8780983092666393, 0.4794557635398237, 0.7407563294088132, -1.3544136264093665, 0.2721855078566131, 0.706307539182048, -0.7218972936872431, 0.6440107896146653], [-0.292657092525183, 0.8701730506245156, 0.3377785443647691, 0.9740053925679297, -2.1043153105873365, 1.7095735700290553, 1.625244408538695, -0.014992828121005972, 1.277318008514237, -0.4708476155124177, 2.576199738344596], [0.053817126933711365, -0.025303783724195138, -1.769940730722229, -0.3550183014733334, 2.5847878212010795, -0.592070752832684, -0.604202960700397, -1.0738924766246107, -1.1810031629881308, -0.6325377668320057, -0.6958091838915158], [-0.9636570526091957, -0.0564544032920065, 0.8720948699494641, 0.7777535297189971, 2.2523175621197304, -1.4569599652998086, 0.4811467515596427, -0.016934427556951417, 1.0208738636932424, 0.6963956921138872, 0.8680193945804082], [-0.7930776338982788, -0.4468257756996677, -0.2041687473351932, -0.6242055559630124, 0.3354734670709962, -0.7856478516241527, -0.06429432429299539, -1.6273398677243844, -2.296418573698983, 1.0225916704840836, 0.6311667594820015], [0.4997397882031183, -1.2385513917757969, 0.35974295864713485, 1.1591689180765457, 1.6153779118481424, 0.11564487062410601, 0.3159060455035629, 0.30410983488374865, -0.31690653759631543, 1.4644859677257094, -0.5945674578685763], [0.6323656076227488, -0.6120977219918701, -0.8424434199171045, 0.8032527201112647, -0.8136753446604288, -0.15691463873178083, -1.6898907375280963, -0.1930409151375771, -0.6367342103269031, 0.5100261506110247, -1.59482120276811], [1.9118512273214425, 0.8051209072834705, -1.4204154499672723, 0.292244571558178, -1.3373120429047591, 1.1387439810835935, 0.09483030082795484, 0.12886730464387505, 1.2226558526699678, -1.7373268957348458, 0.7022423634413496], [0.5420372011428856, -0.5284970479846793, 1.4689235772156193, 1.3043275419562257, -1.614158786508962, 0.36190543099072175, 1.5706757847152792, -0.34742906371739773, 1.0562568500521914, 0.06762632623251885, 2.7713628873407123], [-0.6524286378076753, 0.695800269499251, -0.19360110031229286, 0.8637570442688662, -2.0570003521877536, 0.1313200220135549, -1.860582763816658, -1.5688687295708736, 0.06809471797084941, -1.6322093849707133, 0.2784890195022342], [0.6521510996348233, 0.9109043635139585, 0.5641835516071224, -0.6219844051429245, -0.1746615951067455, -1.060991315851283, -0.0574281058595159, 1.4069536665213458, -1.166872188673863, -0.6609810515221172, -0.24492388389215183], [0.22062104315126232, 0.33579096489892324, 0.6066380161897712, 0.2622372556765158, 1.2718078988486365, -0.5389747040390587, -0.29238571484163245, -0.9271046140805677, -1.113622580389371, 0.9454181082600727, -0.2624299387047313], [0.43448711027365855, -0.02337490986760245, 1.3728333161754704, -1.7264164898355414, -1.1897253726913286, 1.5976812339110562, 1.6908825412535484, 0.4814926638908223, 1.5574412691244963, 1.0102817327639713, -1.0905809161258957], [0.6816845514258721, 0.3900794484482312, 1.077542469781757, 1.3220968463999823, 1.4160437423938563, -1.4402185806665682, 0.8013959087714132, -2.2240017571641255, -0.005197144591339686, 2.4632808826605843, 0.4500453530796132], [0.7164342796028708, 0.15386959591334096, -1.0820475627817876, 0.6364574861019793, -0.8913415155917417, 1.1678206454445537, -1.9854015633254087, 0.4961145062094816, -0.5444463546407438, 1.30640426877651, 1.0290775576992353], [1.112735466030313, 0.0253001158464084, -0.3782967597550514, 0.9472726666064728, 0.8423206091443852, 0.3043782314642586, 0.18831780692157624, 1.3768216789206869, -0.7300876381552278, -0.8800083102915212, 0.5333581212998126], [-0.9180515991933969, -0.07885973123643901, 1.6890062341145062, 1.3404579659566624, -0.4355660237138329, -1.2199654199946188, -0.7733974051496788, -0.445416023250492, 1.07299606069262, 1.0979849698920927, 1.4376162953153107], [-0.49818370565343384, -0.46432323298551903, 0.5933841190396433, -1.548190877025903, 0.6048577296521822, 0.8270910524298588, 1.0927145727285579, 0.4362865019331574, -1.2207938773950429, 0.9706962797612445, 0.3508586723405712], [0.7612496609372256, -0.7743393324943036, -0.8997214121505, -1.6755920251551795, -1.5447100222421581, -0.16189918388214913, -0.5146898695923479, -1.234150926022861, 1.2741302845537794, 0.0034524734572451373, -0.6125258840926191], [0.16591462996708756, -1.1655279399163108, -0.6628695117906657, -0.77864376304371, 0.1542667522198705, -0.31464174476735973, -1.2804678180029503, 1.210854435663568, 0.5548182953735284, 2.1786844555673923, -1.9253622793784673], [-1.3086751640145504, -0.826504825667614, -0.6275268263480865, -1.747736788755961, -0.7713526568700633, 1.2079122760582282, -1.980289488043944, 0.6738579961218659, -1.409158995541199, -1.311376864179177, -0.8827512582094397], [-1.0090824606016786, 0.8631594446680921, 0.125464448969519, -0.624803931606116, -0.2852545969608078, 1.01742132301156, 1.6877974090777554, 0.0361335659193229, -0.5117752945263921, 0.6490557266550899, 0.6632545915413097], [-1.8571104606931867, -0.4606390244004049, -0.6315886343194197, -0.2723644345739285, 0.23824504455801512, -0.3182193467551373, -0.33102322146612634, -0.4786757724640096, -0.9309217004794701, -1.3875653521784745, -0.5232982647370958], [0.32350482796411434, 0.1970504392123217, -0.27524358832528767, -0.5527423051825614, -1.5598615637854927, -0.38524381486944576, 0.7324430709693172, 1.8605283490118458, -2.648385560971976, 0.2805061000868833, -0.6493610425922236], [-1.158300936862466, 1.0358940279327473, -0.10879370193038629, 0.7724942015299058, -0.053226313305841585, 0.7851041156638967, -0.25276478302439737, 0.41896786154088184, -0.9528168331358957, -1.3527280912485817, -0.13435480256477467], [-0.751507017295844, 1.9151866667209683, -0.7488092319027543, -0.5028698676770601, -0.13639151894222779, -0.08249679929152583, -1.147124770523818, 0.7880442271421231, 0.16215260914674665, 0.33237316671322426, -0.19640243308393981], [-1.3898042097021075, -0.21943229728940175, 0.7962675035542317, -0.8434617079157986, 0.18878694126966608, 1.728119997074263, 0.5824835657954438, -1.5534291168189172, -1.1705658843098612, -0.7260903655891948, 1.1007673166077387], [-0.1814117522089968, -0.519349752915382, -0.3897216390770072, -0.10710014646127893, 2.0331964111200396, -0.6719195979130698, 0.6471922221875653, 0.22722444156141883, -0.625589870907246, -0.4661351344496344, -0.32057315345941645], [0.30632665432805517, 1.025973283232117, -0.9667982037659715, -0.7696710134908828, -0.12465050662683377, -1.3452113977872635, 0.736217304407215, 1.0984666566112191, 0.6088801949430401, -0.3824234651980754, -0.1694471161561447], [1.391628479341686, 0.2852635535534657, 2.692738863200828, -0.383006424669253, 0.11507916244280043, 1.1992998847671896, 0.680503276160984, 1.0150304701963553, -1.1641910071661072, -1.213724745431129, -0.6601884655965296], [-0.279796317399651, 0.8665768224378676, 0.17983693461271533, -1.0298882381884904, 0.5313370595940201, -0.6465047935704137, 0.4089572575012819, -1.2463974542399503, -0.9033273104314806, -0.682866788523466, -0.7740591285879689], [0.764703845053099, 0.8732847775097984, 0.7404396463241902, -1.7502372816853518, -1.1599421569821087, -1.025917937996349, -0.3243327869528591, -0.7657613299269171, -0.011382132268944443, -1.0549594002281408, 0.8223331435842295], [1.2465679413557211, -0.0325240433561466, -1.1119518118612812, -0.49693456399276187, 1.8127194325267955, 0.4494552327490812, 0.7550224426502502, -1.481762932398467, 0.1620121484427747, 1.517652916686789, 0.21816433104241847], [-0.25084529496048463, 0.12282001507725762, 0.618496242952877, 0.16739394617902936, -0.5261465657338146, -1.1506221959287222, -0.02850077339598674, -1.0469385557284887, -0.8614938183708285, -1.0414507888521882, 0.6658029040533121], [-0.7891950645750105, -1.6016657265213494, 0.12695172328376444, -0.8746145982646328, -0.08430688328052441, 0.27301544154550406, -0.7620116095555737, -1.4463041322871861, -0.20110420173761093, 1.3842802814026491, -1.0553224710076607], [-0.4782904982033712, -0.7859379334853726, -0.4282949161789996, -1.4296523722581955, -0.4577678022234142, -0.6607979559053516, -0.3456784681372773, 0.023446785090185444, 1.0528507424470719, -1.4366418616302463, 0.5472662768039815], [0.5248374199792866, -0.39059280040481303, 0.4190344526193213, -0.008953071449389154, 0.6410326314133816, 1.295365949939548, -0.914268268114089, -0.9595301385693232, 0.18809282952176015, 0.6943063803615468, 1.5739485055878006], [-0.7409095860827821, -0.429732887914844, 1.5537188411587093, 1.450700533611001, 2.160864990482081, 0.4526914890060086, 0.09331958815407808, -0.3382657810060985, -0.303196961428944, 0.9462871183095499, -0.02592379026409957], [0.3437861417131645, -0.7571992133788084, -0.10199345348648453, -0.6147074567432982, -2.003830407612402, -0.6572985330594979, 2.718757327687298, 0.11246761110771109, -0.9755575076890428, -0.01901591235112339, 0.8610258415620536], [-0.14276055316627548, 0.5222770477859432, -1.9495280955689012, -1.3780448361444435, 1.0328539843752824, -0.5667761900700842, -0.5228312289911907, -0.34791750303434327, 1.6786657271322867, -1.5865997801350356, 0.8569062186005447], [0.737253566852749, 0.2320102207269017, 0.6617044911579759, -0.9850852243556534, 1.3479668225366688, 0.5261801700315907, 0.6110929032328641, 1.326989368386169, 0.20263245358334325, 0.116410339016643, 1.6485886683149746], [0.44694169354240315, -0.9956319451630563, 0.7105556027616501, -2.307398903716416, -0.670880618459623, 0.874757661221484, -0.6124958220612052, 0.0686866944370682, -0.47716968051347536, -0.37034230544585045, -0.00564498756231942], [0.2618828564603298, -0.4555750367868328, -1.1370864888199155, 0.07919201642752674, 0.4668161408716367, 1.736573202281578, 1.2298400514602064, -0.5917903496552347, -0.8135697712535251, -1.0013677042812443, 0.27143476266529426], [1.7231470167992426, -0.6834565909780893, 0.2935917212915007, -0.27062538714742085, -0.41109994978730385, -0.3938209864626428, -0.7424768493419832, -0.9810908856848682, -0.8638959007934017, -1.4273800564087566, -2.0958124753360803], [1.7249461329378453, -1.1965559695085317, -0.365738123206901, 1.5730196714720592, -2.1899729158084704, -0.5944898001460965, -0.9410699322033219, -0.6328286041998326, -0.10120258009325411, 0.32448710946552417, 0.0785297173033786], [0.20111857248132592, 0.6165746530639078, 0.8626535673686476, -0.24802426629087684, 0.6199029744388885, 0.3378220283626178, 0.43396772756359403, 0.5574590593466149, 1.7422012213095057, -0.25266077751476246, 1.3060019697094154], [-0.8272423308965906, -0.01446343229941084, 1.3548593618675857, -0.6038006696936904, -0.8474672435458439, 1.0824797226852954, -1.4220129293865689, -0.9812438868746651, -0.9279675264541711, 2.2785718897324005, 0.17030399672974444], [-1.2594212103695774, 0.3369923869623555, 1.57374351285177, -0.32387860863005763, -0.7541916381099247, 0.9433497109515361, 0.6242447596585663, 0.35402835350577855, -0.499525296171179, 1.7474449478912024, 1.7450921893678122], [-1.5028466527804873, -0.3010335973688022, 0.7407403823933287, -0.8924899208117769, 1.4424844917071897, 0.8121222477517538, -0.28876853363620236, 0.445248148949776, 2.7374588859467623, -0.5310057959675761, -1.3009465242680078], [1.1207582294369642, 0.9395892132265927, 1.513730102470935, -1.1185514662385638, -2.148096505105349, 0.6537659523158756, -0.8093279330475388, -0.6875955997301304, 0.9863014633937215, -0.56225469183519, 1.0097627415513644], [0.6480752019176172, -1.6779173843887325, -1.1231522104986653, 1.4221177680408563, -1.0464404081259389, 0.046799038117938445, 0.21952271123446226, 0.4524080616883831, 0.1555565134565735, -0.3096089811109183, 1.4791140609977886], [-0.6841757161186253, 0.9762029685068954, 0.712426057767147, 0.1744932848738121, -0.6946234079984905, 0.4322416295342538, -1.025379367722287, 1.3106839658294835, 0.6829212087640684, 0.49881657315807104, -0.6032412253365911], [0.2688108583918925, -1.6791424926826568, -0.9181218409482805, -1.1566447884498428, -2.304963006335191, -1.1021060127081397, -0.24872406775105682, -0.48618328597231947, 1.7053795229654423, 0.116337907938441, 0.7435704344219437], [0.8425752199750189, 1.3553087882386325, 1.6711203795146086, 1.6875306788510875, 0.2656248693555355, -0.5306146208692375, -2.058142722092073, -1.8979394261483624, 0.16450924345530782, 1.638040935738286, 0.07851212042150058], [1.0855529081288222, -1.8443405339918861, -1.1087792284138487, 0.9018280506761482, 0.5511994045672078, 2.003027023091094, -0.4514857005471588, 1.0607569934140748, 0.30481794389013017, 1.7519226919265345, -0.005496362512040291], [0.6111872668909244, 1.1514607852804442, 1.5110691434623171, -1.3018758725028614, -1.7649906531809827, 0.17656749930200752, 0.15744900197305348, 0.16623016981512223, -0.30630868157964963, -0.5027415229320646, 0.3123840802009667], [1.4455970696125005, 0.2799109712882706, -1.1928536514804515, -0.41641292968563137, -1.7247762174514025, 1.0707067676139221, -0.11486721287568928, 2.0429604548633495, 1.5805093511070336, 0.3093529818253016, -0.4189109633066638], [0.1438579295041271, -0.5077345971957812, 0.135297839656152, -0.8379098791192948, -0.2145734890861586, 0.590917096324666, -1.7453304669608551, 0.7522851981467982, 0.5505568469289901, 0.4648804046258344, 0.5870160927907476], [0.8637347945955868, 0.8917038107182585, -0.115603213103884, 1.634791865568978, 0.4922777484746156, -0.49113833512093713, -1.0512718696120225, 0.8060697789155, -0.3992802076483032, -0.27721835937407535, -0.6367373824729343], [-0.9881947318770483, -0.902676870078077, 0.027438555993640843, -1.8010753804609352, -0.287785289728387, 1.1879725090829254, 0.43421904672144856, 0.710408406078057, -2.3104199404735435, -0.7113282199558851, 1.6149502918988565], [-1.3789163757938387, -0.8432599530936501, 1.1528927471522445, 0.11741687318681122, 2.068387673479908, 0.7724592597033796, 0.8557302002334862, -1.671122112176934, -1.2842568522730768, -2.5739797871433425, -0.5896759693996991], [-2.0546741972560643, 0.5364477148190483, 1.0567918200378053, -0.5987607152686629, 0.7975740061603397, 0.24490825859215362, -0.7794669741264645, 0.5739847677220693, -0.7428703910936014, 1.2011143994544666, 0.7035688282369014], [1.70442085101807, -0.42760201730256664, -2.3612717937730316, 0.7194424634361443, -1.5437546775941549, -0.3603319410164423, 1.5073347131122008, -0.12215687940020503, -0.3382471957952137, 0.3116890478518219, 0.5428229504645513], [-2.3281194747971794, 1.4874104145805422, 1.2291474541178284, 0.3804359652220185, -0.022990770542611498, -0.5457032238514228, 1.0581998408661628, 2.8300666715344533, 0.22323830025655717, -0.8840748330442215, 0.4204564811301606], [-0.4331023146031755, 0.6556152687975336, 0.04066782830124048, -0.5220098782045633, 0.5599923298931251, -0.8303155028431917, 0.8021001622717513, 0.27695056990783884, -1.9298269272433892, 1.5327618974146877, -1.1154156381291143], [-0.251448941207333, 0.5121429422140813, -1.0108034517395394, 1.0154463579908886, 0.584032158031703, 0.13154925774685214, 0.9729179457157882, -0.5254564056184503, 0.4688488062620763, -1.723856346513283, 0.010522386763011425], [-1.0636958747267733, -0.9368327750862879, -0.7150834330144581, -2.060812661736812, -0.9959384305848449, -0.4919248855813461, -0.7916170120572056, 0.7433563401005414, -0.17991195478951294, -0.4073741009047545, -0.7565805414866429], [0.9323584742986483, 0.581078496726515, -1.0502720965906929, 0.06999227407075335, 0.3137792505103459, -0.7332924924082802, -0.05998880859715924, -0.9820103577541188, -1.2070081594062734, -0.6753696350890418, -1.5094840538409573], [0.8062485092233412, 0.8425601289340009, 1.4366986020802122, -0.7378308475121339, 1.0725162659957066, -1.229945911948476, -0.7328801410660826, 0.12578357351136993, 2.4601928041065078, -0.30413629888151167, 0.9560731045399099], [0.09350131430202693, -1.2798688449156537, 0.5824421076717413, -3.577121347308164, 0.29007538328319543, 0.6766573116555806, -0.48300399286169526, -0.3034748526513122, 0.12108101116831252, -0.3679462622139143, -0.22740428004929808], [-2.353679323485168, 0.4708146439437946, 0.0034565985024660553, -1.3515099283699465, 1.7472744796797721, -0.6969159562742834, 1.9754485891948095, -1.535717690742518, -0.14256270910331384, -0.06156983188263562, 0.6616069147057763], [0.8269103051548375, -2.4165594360580775, 1.051392418068761, 0.3363547178001094, 0.28287802857670513, -0.6000119504301891, -0.1267744358106183, -0.0739493422681826, 0.25551325054030755, -0.38554117639727703, 1.6932003462320926], [0.5251291790232825, 0.8830954141045743, 0.836744454764357, -0.13243160390966163, -0.9411847599024994, 0.753926872804747, -0.8085245543436135, 0.15774278212106832, -1.3914659276596817, 0.30034401617044604, 1.5278230642205626], [-1.2098387642831692, -0.7310848795458396, -1.6009548902478818, -0.4107964081009177, 0.3935549184537875, -0.09079191913620137, -0.5196105833663448, -0.05716384353311925, 0.9598322963272592, 1.2754237398106125, 1.2414686746375263], [-1.3766928043276898, -0.47668273146614837, -1.2970235531264156, 0.2891786116458305, 0.11537046868794729, -0.3049504177182845, 0.022332270192037335, -0.7976201730037173, 0.18014511101745534, -1.4953883645778774, 0.7554201077244012], [0.7765251048338789, -0.8611633656754448, 1.1597342655900205, -0.8979964095796578, 0.09909536822945868, -1.2884782539601445, -0.8770763497103692, -2.7817333860991056, 1.408172020641868, 0.12442257376038339, 1.2222501130400967], [0.5491669610986223, 1.996734074455559, -0.4908679670104818, -0.6039880888700884, 1.0957879761256752, 0.3389202140493834, -0.12302599683363531, 0.8811372124954941, 0.9060723857502527, -1.1860256122589299, 0.43615032845796275], [0.5118048089874934, 0.35096746350407065, 0.5414664011970284, -1.4279068771236967, 0.9922373038640636, 0.46431317826812346, -0.1847101062860197, -0.5477631658025822, 0.685108443245414, 0.7269728666869553, -0.818619485801263], [-1.3070869546994484, -0.6598003354761623, -1.0481820604887098, 0.9518200483292887, 0.8526703225939246, 0.9237227862742255, 0.6588444753284779, -0.5598782044126625, -1.25484794136648, -0.5496189659467058, -0.9840593522534807], [-0.045530696819611256, -0.6130635498297171, -2.570613497299164, -0.24307871122581165, 0.7049971787282717, -0.17601298517569947, -0.13745463540176348, -1.8446627233691635, 0.6484683640513768, -1.548359049432422, 0.7963714643488735], [-0.3756579945983891, -0.1272173044735222, -0.4609161045700121, 0.007179376817078023, 0.25795656509697257, -1.6199666385631755, 1.6052475092379748, -1.9351395710011863, -1.4343713905273796, -0.6972080452824706, 1.2181430097892985], [0.031041048832505184, 0.12005656689443098, 1.6385447065464813, -2.2190160098012472, 1.4724253656623993, 0.454747027297528, -0.3053127879351279, 0.23589590429150925, -1.2310320102929495, -1.6928158043661703, 0.3482822267484158], [-0.5095913764392864, -0.11969855731034063, -1.6208726137125293, -1.2219168443044066, -0.019100461013135308, -1.4837475846044295, -0.07391378627699809, 1.082889412363893, -1.5364479515542457, -0.5091392272688371, 1.2249281436247872], [-0.14054311571969438, -0.8366313758183884, 1.231424771754981, 1.2250644949158154, -1.8902599949908372, 0.44550503315780604, 0.6793124741028189, -0.48369413958176205, 1.5877303217805456, 0.13228225416991868, 0.41539983010990017], [-1.321800943249666, -0.04237607969664101, -1.1381490266560945, 0.5992887358260487, -1.5644596624282228, 1.3435424134026113, 1.677104150574959, -0.6217937285487984, -0.0581828586553444, -1.4287100116613078, 0.24769246044790172], [-0.95569866824135, 0.7051116860505448, -0.11742166111180985, 1.0243504370156025, -0.07226189636510019, -0.39281049484660363, 1.1774319698557534, -0.08142569760510562, 0.995222184923403, -0.4465160870188007, -1.9886264132813165], [-0.3483073105050823, 0.3669088427987163, -0.9271753778132755, -0.6680478941212268, 0.18066891116447634, -0.8154297341899207, 1.1743129967523602, 0.6727393337090999, -2.0559915528025536, 0.9911738169515202, 0.6254931778664654], [-0.9860181845891318, 1.7484019809495865, -0.6873812475301095, -0.48233238758020847, -1.9089624726100003, -1.5504566856767827, 0.6706891928328516, -0.16761380062610529, 2.4428092156452204, -0.3197676296380161, 0.42011191975636636], [-0.24536758127768463, -0.34660140635971026, -0.42687989282556543, -0.11294948333627294, -0.3880969914376984, -0.5985428027573191, 0.9662824299757762, 0.30087798438999613, 0.9419271358723474, 1.8618451175849813, 0.8881908180578725], [-0.34360120549078305, 0.3746482803139132, -0.9860440792956889, -0.7304096976980031, -0.8042571950658087, -0.25430505908216094, -0.6768946936558724, 1.1174153436021, -0.1837465204506881, -0.9325975086057638, -0.09791294916022195], [1.6867316177033365, -0.05568820502122922, -1.6221800118653382, 0.7997333506126786, 1.43340319686924, 1.5302515645641896, 0.45811937152083493, 0.9110748007644296, -0.009812869921589673, 0.7465906351262771, 0.007706723830078067], [-0.3727196368546362, 0.912086059649731, 1.3759054282052585, 0.7616951023661527, 0.4082424791408057, 1.4268791034692108, 1.8248115313056243, -1.2464972026024437, -2.0053980591286753, -0.03973295739368917, -1.0011677555811207], [-0.8259538904539676, 0.8960315058146271, -0.1610492225628265, 0.09021322240626235, -0.9736657918214988, 0.9800130851173638, -0.1479954821270568, 0.5173594753846333, 0.8877321654563218, -1.1156647819807424, -0.6481633004167167], [1.210206887516839, -1.582528323506361, -2.594587898829501, 2.0914474517137225, 1.4450011973034842, -0.15809458008184635, -0.030742368446144926, 0.8079742816638809, -0.4628798436638368, -0.2632367730134761, -0.6749301838358488], [1.9751571902979963, 0.4218912125518476, -0.6577502645483948, -0.10277019865507464, 1.3872545849217894, -0.03704132046147911, -0.7356099334895982, 0.6539878103568992, 0.1830349737506544, -1.1080300966963157, 1.159610986983949], [-0.8384198743421546, -0.5393040596144748, 0.587951796946061, -0.8778772393141809, 0.5906175122741271, 0.3896032963092434, -1.5020121126401693, -0.8890202529210375, -2.032130099446071, -0.05863253828435936, 1.3993299684713039], [1.4333784489336556, -0.33903787665847834, -0.49925912745250495, 1.9755319664826487, 0.3941079697907169, 0.1892441614384496, -0.546396971214071, 0.7577822990993229, -0.8167529338300137, 1.3907980809540625, -0.25997650559529445], [1.0130966977963374, -0.26433147444821137, -0.6448626400914611, -1.5223637194647703, 0.5988325790644906, -0.984662050629868, 0.8851566536393751, 0.3272841046600434, 0.2018860855940335, -1.3670911750431596, -1.233519775870274], [-0.16409809271179715, -0.8204481111566977, 0.9351167547083825, 1.5154822267779067, -1.4057898236721298, -0.7096976869527489, -1.750545959762467, 1.008800594673401, 0.4799380967527129, 0.6032168207320919, 0.008369061262813204], [1.6389896962678747, -1.6752207500319718, -0.5449702764108465, 1.3180141997776706, -1.7254914066671032, -1.3566854104793926, -0.7639742938470628, 0.37441812723973505, 0.26182692395870005, 0.5171636481605786, 0.7325952910150229], [0.6218522152647014, -0.6520383366785211, 0.3319814519449966, 1.0489766669371834, 1.2417891609502172, -0.11447062355488687, 0.4576153966190023, 1.2777731630478417, -0.7022695985513261, 1.1935453281256445, 0.20149607511123271], [-0.5643225736523735, -0.9676903554755529, -0.6995631401668573, 2.2861503342336036, 0.3651233717454549, -0.8182676530565726, 0.31753377027790375, 0.24380439226573775, -1.922034143349977, 1.410533712430829, -0.008394863627804084], [0.30444021540122146, 0.9892246080776765, -0.4456319770729856, -0.46985530213586973, 0.1956341116236021, -0.10524129928325163, 0.7556139140791773, -0.2546680011232527, 0.144260205342363, 0.16880119901441396, -0.2209211180996584], [1.1865014955739557, 0.2980770056526932, 0.3946065533821481, -1.9801644879559468, -0.374347574560933, 0.5535121655589343, -0.3164359768073101, -0.3034238777050447, 0.2767326270517101, -0.20030222141528534, -1.9783547117276832], [0.5885458233762594, -1.7539804515747548, 2.5511918435060026, 0.4913227043487062, 1.4488904888578884, -0.22022662361929501, 0.40917538237725076, -0.8510595694170413, 0.25474597463815674, 1.5771852648055429, -0.09941660574677716], [-0.5155615710750461, -0.06037054120286356, 2.1817202467930974, 1.1638439375252292, 0.18773327243059074, 0.09854908635076308, -0.7683318844056658, -0.1440089513514928, -0.6424095924515488, -1.4326236138763315, -0.3253024457623946], [1.2265555312149565, 0.49772300088872035, 0.6694180671149682, 0.7880175945149336, -0.8346204434036743, 1.1644591564267668, -0.30080808078509774, 0.705890157167678, 0.032486459892602335, 1.6076877373023901, 1.3509564559255947], [-1.084575698384655, 0.5356212052224782, 0.9559212204305166, 0.07761801197071268, -0.13640335684850546, -0.904593898853392, 0.47289961160679056, -0.06401202401055744, -0.5720120744658779, -0.2507939387139658, 0.9287088313799404], [0.08390694741930171, -1.5074057425769818, -0.15648539973900186, -0.43268617085576777, -0.058282280116565, -0.0663952542763818, 0.5237141188530752, -3.65266715699831, -2.345018374793956, 0.19966231815484686, -1.6788700121501465], [0.3016202826302554, 0.8914185180725291, -2.907810710277677, -1.0110566976336368, -0.7984541208903656, -0.936639251280206, 1.8913016764468096, -1.646021384338866, -0.4408371590416665, -0.7234563218783953, -2.5776995205983932], [1.736374603758665, -0.7010788810985497, -0.707168598224529, -0.1389972753177263, -0.24929774319153142, -0.7025862092472437, -0.31935798531384024, -1.0483957528457073, -0.5044384261038605, -1.2054088561727392, -0.5338633329194061], [-0.5393634941537424, -0.5400051092531182, -0.13461296961762975, -0.5447855118509558, 0.0924521955258514, -0.6075422751882975, -0.22825681251107705, 0.4357929827237744, -0.12364158006670951, -0.3689999547467432, 0.5113608631706119], [-0.39998743529292446, 1.9205281640713756, -0.6397246105837847, -0.5073770214075256, -0.5583535971134926, 0.6218838033881049, 0.46816931998940503, -1.4596744686383976, 1.329121517470541, -0.21685732121984294, -0.7346132472241003], [1.88671007777717, 1.7044697786846632, -0.22008234985938316, -0.10911834054377448, 1.0504046381533023, -1.6182375952274688, -0.7837467509003399, -1.8163108644267758, -0.075197230833651, -0.8881460389502212, 0.5056775505177155], [0.2629872049334668, 0.5335264831585828, -0.27979343884987745, -1.9071599523837675, -0.04077930385305101, 0.9008861238015701, -0.8731503257046884, -0.5296810614904208, 0.8859822338226777, -0.7915096854943492, 0.39817631526266306], [-1.3854191012562274, -1.4566488995388585, -1.369102608103352, 0.8362238571130487, -0.618863649592366, 0.9502058358137934, -1.6083573900078194, 0.6155090075654904, 0.9544327768020666, -1.1581979977612482, -0.16137895728173327], [1.3771054046517135, -0.570667500292527, 0.48556044688887756, -0.7581843555577381, 0.8287766141248052, 1.4416589125199186, 0.5293872692047379, -0.3330858543464309, -0.9858859671051831, -0.24484551304747496, 0.3400544293709878], [1.7880768249947223, -1.540084498228211, 0.3634592572861091, 2.079669949112667, -2.020793398429145, 0.7947859624493699, 1.0204169802903185, -1.055821200297025, 0.15578402194803143, 1.3264077400552536, 1.904712835135521], [-0.9917679404637649, -0.09425573660151729, -0.05190432192825505, -0.359099258727656, 0.3611774148432071, 0.11945793856528467, 0.6428631507954785, 0.5671541752861642, 0.18812092051871776, 1.1830490698677854, -1.233150794155236], [0.6294176158133101, 0.3735189603855503, -0.2552212140260684, 0.7690723326565683, -0.20287414272934307, -0.34086638239952016, 1.5410182405497757, -0.6890658413405987, -0.5308168072589451, 0.5380755601726691, 1.0546083474799848], [0.16810436038330567, -0.5632647523897101, -1.0105444011120204, 1.315832834855737, -0.7734344780762167, -0.3831691837270603, 1.3470460633387915, -0.45516498890310414, 1.982927309259598, -0.3533595886354783, 0.010718379342823504], [0.2616023595024118, 1.4560084369060384, -0.19170996976409715, 0.846791630644763, -0.5837192256516376, -1.2713125313124525, -0.19482200047337703, -1.4061404938576152, 0.23396088270669427, -1.9504380979052192, 1.5618485512443216], [-0.7584697983953756, 0.7958142144485685, 2.8065538811144277, -0.22516457614487978, 1.4734081802579388, -0.23995660219391607, -0.22091304919112462, -0.35707782289350304, 0.2886164520086455, -0.35857371209500544, 2.0084321322611918], [-0.6853714018246261, -0.2779301823091151, -0.4855732106546542, 0.9060954286228388, 0.4704076859818616, 0.02658516340367882, 0.24874085911361513, -1.2637479820565676, -0.4948673889530311, 1.9154328802197227, 0.26866172379617614], [-0.37579312029369594, -0.3249338795753335, -0.5590764498561188, 0.3680112776217051, -1.517429802902367, -0.9677123995183706, -1.0182056186198727, 0.21810997751648628, 1.3507350834895435, -1.4067783908861058, 0.04526124121025648], [1.7685322384139088, 0.23862597512351563, -2.26914624857756, 0.026365138346288654, 0.20878337610718534, 0.24434723095450203, 1.959669935015717, -0.421383271463757, -0.4612431757357754, 0.8292443352746864, -0.22794041889471994], [-0.7087343231379628, 1.0930737925620948, 1.439366083598611, 0.30121036834707904, 0.20265009284495303, -2.4299877512905903, 1.0217777771336436, 0.20088596977496637, -1.0298553896135465, -1.5727261258899854, 0.6853214528995643], [-0.8236516353750397, -0.17680956320994726, -0.442810940021379, 0.7969775347860554, -1.4695371051790325, -0.29159810093581584, 0.15510237209680125, -0.884766073231885, 0.20276964542783674, 0.6788095007411239, -1.8087993154632698], [-0.7294419031132716, -0.23741755593970904, -0.37614456625506726, 1.0219215151310117, 0.36779877961665797, -0.716524534425413, 0.1745035719150801, -1.1009490483136337, -0.7051748074866135, 0.4975846047423883, -0.5202693921798971], [-0.6268254498749065, -0.13895509813875626, 1.166067892523998, 1.040125115226684, 0.6335473923908809, -1.037764327647097, 0.5876173730379848, -0.6516863002293288, -1.1134038694296176, -0.29305440204407357, -0.39619535025591907], [-0.5423129335551388, 0.019034912420838313, -0.4982374698871774, 0.5093497880594335, -0.09171628140511781, -0.6738644244357156, 1.8082369854169225, -0.5124867847219913, 0.6655284531574398, -0.805014489521752, 0.7703373320043475], [0.1739839067580094, -0.2812912638190167, 0.589713085447564, -1.0034355371386632, -0.4019399421436016, -0.507255329653141, 1.771855147583681, 0.34205186421354766, -1.6855098439620333, -0.2775187068293648, 2.032713724868088], [0.9701713174288855, -1.2477113574353882, -0.9865824074778518, -0.4238986434057129, 0.9093750900062914, -0.19572860812852683, -0.40180096665438975, -0.3100381733088403, -1.6056226384561147, -1.7532376600014734, -0.4879843598199169], [-0.5039248129781687, 0.7904734985920531, -0.6656538363882172, 0.37828242935095646, -1.2641629573532551, 0.9007589632221739, 0.5610897581951957, 0.2141375426001311, -0.6313566397392847, 0.44611060826799637, 1.5324653138790656], [0.7965723423984878, 0.15487883256554938, 0.9833483558950894, -1.3318494374469112, -1.335840395793344, 2.322861053115031, -0.016363458311988124, 2.159587160915955, 0.24088983555301327, -0.9804360157558736, 0.09021938723406436], [-1.5920402013028716, -1.398206984376796, 0.971602344490549, 0.9866459650530794, -0.11466104455016364, 0.2572734347915071, 0.29769420574247785, -0.6525070987784696, -2.194849052652118, -0.05225780153069285, 0.509755492811023], [-0.484610993186136, -0.6323035620164101, 0.07830726778184398, -0.27073056974450743, 1.1761017133044864, -0.7792566111936923, -0.3335527551162745, 1.3075217954722032, 0.7594611563714619, 1.590768422402053, 1.5681839090121308], [-0.20029592731007967, 0.5913960839379244, -1.07418756609567, -0.12103427188890231, 0.594243956379833, 0.8045851514367925, 1.9279867348246014, 0.6053789738928321, -1.8134032707262173, 0.4309238182841661, -1.0177312382975046], [-0.7313399374423654, -1.1062852878418348, -0.5781525329532947, -1.5012147081402885, 0.08142213639319346, 1.3301458971932136, -0.8485887600900062, 0.7054659013842477, -1.4410936709145237, -1.8696785323038008, -0.3582087391733365], [-0.30508255213668994, -1.4787965201422777, -0.3746200798401768, 0.3921019458450947, 0.3515837707750011, 0.20714406404358462, -0.0681711262115481, -0.15992665088566232, -1.899025060536104, -0.6414574437718799, -1.3984803242186457], [-0.5248805798594166, -0.6346453424228116, -0.9381971093178476, 0.03071255006488174, -0.34106820253412473, 0.47730344336547054, 0.6604094554855614, -1.6455656981668692, -1.5803842285072847, 0.4353734014842991, -0.2936493740543735], [0.7307128246668434, -0.522939069265784, -0.8915868415030939, 0.7630344699123213, 1.4109560587351997, 1.244368968415261, 0.9670846039002443, -0.35584568834406266, 0.26188225419084826, 0.1821372753166712, 0.34782131411041417], [-0.31951080756271955, 1.142549719847719, 0.39152966860284166, -0.3212247926227898, -0.8703514855171745, 0.7778271133513438, -0.7209044855072515, -0.7380556039327699, -0.129232838435403, -0.5128888048123041, -1.3841113684663031], [0.8970451200633799, 0.7418349945017577, 0.8835901598676416, 1.3054685562480077, -0.9625424362741737, -0.06631871695368925, 1.0924303660490164, 0.5934562454990897, 1.3355196483195595, -0.33208122462700757, 1.2553351103827597], [1.0080661472523205, 1.0131338307644122, 1.2709305744258126, 0.44957281191993825, 0.889400390418926, 0.38678238383495456, -0.1775013654259425, -1.5623179287622266, -1.7668009908662976, -0.03463968341700843, 2.0198590780486003], [0.5700764778688643, -0.287409014527408, 0.28112506094469286, 0.6611033406053414, -0.7173796125187798, -0.3619147157760482, 0.3523640052242963, -0.8233686983206717, -0.054350841489202294, -0.39778286169098453, -1.4387118324240484], [-0.9399009669126771, 0.7943206372660958, 1.282564580123673, -0.368135786644691, 0.23141381958870913, 1.3322366544926505, 0.5014778118949608, -0.5330026909056215, -0.9880793425418137, -1.0391586388773275, -1.1391362778964418], [0.2280094949030817, -0.8124094738615115, 0.5956343461673256, 1.4970624298727937, -0.32540079326000027, -1.6207054086967716, 2.0362880443268176, 0.26795716662525404, 0.9674404947021473, 1.0888161709346214, -0.5404842801073333], [0.22213843632624977, 1.2891491058645745, 0.226419885720632, -1.134982959299621, -1.2174731622541044, -0.7627440111331968, -0.09742389769236527, -1.0781168859431303, -0.5765577269028929, 0.548268245313498, -0.07257673006678692], [-1.5322996533797268, -2.316280898586373, -1.7139690085953565, 0.17860435743700717, 0.7132251143242816, -0.3354672287573671, 0.7835135551338335, -0.4282425930449532, -0.7637008562037964, 0.22920842137953, -1.3693536347980364], [-0.9883861262690588, 0.1464744656515701, -0.2637737689887922, 0.7990572798005016, -0.5279881105305766, 0.37739945362988175, 1.5532558891559713, 0.01913709733357545, -1.8443291697575193, 0.6841815037646937, 0.8257856084698836], [1.6125573670273592, -0.3360329985652458, 0.017152045966314367, 0.4517031476196441, -0.9242145239063986, -0.6127878894148379, 0.445365441471694, -1.1376749440809084, 1.1803759707747377, -1.871637472556409, -1.1895978898769526], [0.04522923659109031, 0.7839101809171373, -0.2500274763151318, 1.4971929174766478, 0.8855496772511546, -0.23951420192732395, 1.1113322007808117, 1.3154498843931393, 1.042502721454961, 0.6712557120851825, -0.3884225604624051], [-1.3462297009152395, 1.0221492709475657, -1.3316618846535304, -0.48155797382081844, 0.9751433421335629, 0.31841037513782994, -2.921776617337292, 1.0819301393024234, -1.9752546691931474, -1.7600121875426702, -0.7356698298569804], [1.2611180502172261, -0.19624819975479701, 1.8957255501108596, 0.46828739883188225, -0.2070488655876836, 0.8855165038260594, -1.0550956765920259, 1.1943252863311737, -0.356362808583755, -0.5634070595434616, 1.3248492792128703], [-0.2831663692981376, -0.7294744760797183, -0.9912520540301025, 1.0209234334063626, 0.32243627142574227, -1.3330801078963976, 0.4187629038839804, 0.35880153287529826, 0.49570112641895225, -0.29703976935102766, 0.07204019916115714], [-0.23791670547119886, 0.16268846613957041, -0.4742934941419027, 1.2345758715146642, 0.08526668080428572, 0.3182536355452446, -0.17786673210210396, -2.511017627847204, -1.059054840893578, -1.6399347012791985, 1.133563191694198], [-0.8146429164002573, 0.7257234280025039, -0.5061099810730402, 0.4050012393066983, -0.17524741370528077, 0.4531650726030027, 0.6286500186963309, -0.7123096328084554, 0.260910490105094, -0.5859489028463336, 0.9890266517591605], [2.0594612324149546, -0.664438254908288, -0.6237144488821925, -1.489588316690072, -2.855671124464933, 1.557278323931421, 0.14353000933667612, 1.4732515253367713, 0.5176675734570445, -0.08892815861698038, -0.4236986698736674], [1.3858743368905169, 0.798506556873621, -0.7013414860807795, -1.4167579680132953, -0.11698894481035153, -0.49667465407805506, 0.7868539933633732, -0.9080368788589094, 0.41705446230351145, 0.7159007806807914, 1.2427814087117812], [-0.2551074216490089, 0.10951008459668857, -0.39955850966450857, 0.5217134728740256, 1.047466070524243, -0.2490983450045454, -0.5194951112955879, -0.15134736933772094, -0.26950881362166734, -1.3474716447732171, 0.48540867389059905], [1.1075259287467172, 0.8528146211102409, -0.5866215063939867, 0.28073868467126817, 0.45722849838580654, 0.30718728655140815, -0.14723719834221935, -0.6033846228550472, -0.2853440265988104, -0.10532878708392457, 0.24183123965285958], [1.3218214372540837, -1.4567033998521006, 0.48099922928533, -0.45458288040980294, 1.345082515177592, 1.2749434053085398, -0.6627792323826893, -0.4287361960560357, 1.5457824676997682, -0.12611556890324488, -1.1314424770479103], [1.0190160473283818, -0.804256448430151, -1.125515784479288, -0.07615042300190722, 0.3248417557071014, -0.44393838558132154, 1.7926423414955193, 0.9095600095790345, -1.3998468624363456, -1.1666554382904297, -0.8978845967858576], [-2.0204994220891934, -0.7244511214066033, -1.2334327972431252, 1.2087383148648143, 1.354735362218482, -2.197410368574672, 2.366646111575552, 0.2684284221248617, -0.3137447242440358, 0.07180480535759516, 0.9601462165997887], [-0.4128125770880857, 0.48425148172776433, 2.3346618300682964, 0.97358537188509, 0.9681354601771106, 1.4331513673491405, 2.56057835928463, 0.11556992961993583, -0.3389660369653311, 0.7194303790416167, -2.0815915081205283], [-0.8942816303537161, 0.14973409641996688, -0.005742803323276601, -0.5729700982307111, 0.9785565962935956, -0.15258077801196013, -0.019619362948878612, -0.8113928869496575, 2.0071176905169503, 0.6436819963734787, -1.5506216783586149], [0.8337494481970049, -1.4240083471014335, -1.6513827563974854, -0.7592281294126475, 0.08983788460812589, -0.17407556566718632, 0.4127553127951918, 1.495008107209947, -1.9005052092048318, 0.43650522216984455, 1.0335397068909953], [-1.1969837856016208, 1.0561511643285675, 1.0318526848163163, -1.3864530227371035, 0.018624315168374348, 0.7670249375810694, -0.022033306085736372, 0.24637694120068618, 0.5981171611393509, 0.2494409384228598, 0.8840314762777658], [-0.2668089250483745, -0.4081195679870415, -0.19640077246216925, -2.2306660953358044, 0.8219399791368472, 0.9509856796294569, -1.648405717920523, 0.7170378072184068, -0.22016535257734837, 2.821807859905867, 0.5199611445028609], [-1.0149621863293292, -0.6041234549466921, 1.9458528861044584, -0.3142896942477466, -0.9500550597277896, -0.7394680178901204, -0.10508597258766303, -0.2674858325090093, -2.384645820338677, -0.4162270516260552, 0.1399021696767911], [1.1059712226945329, 0.653862346716025, 0.0986243530147372, 0.5181949733651001, 1.0549150006339802, -0.3024406747594829, -0.21200738252758594, -0.4699706013681278, -0.19061098323499398, 0.7160242626589687, 0.13846459763813873], [0.2768351319269501, -0.5250539203420479, 1.1623379953950845, -0.2369366782681125, -0.12393586635727177, -1.8692362915800635, -0.2765830750343247, 0.12252161930981981, -0.6490979691437809, -0.5361392899115743, 0.8854866783786994], [0.6312829916688462, -1.9096686834928405, -0.7302183974095233, 0.2927672693893426, 0.7865838874169481, 2.3171886161456037, 0.9205270907402313, -1.8807001852669245, -0.9964906740669072, 0.16465169063809218, -0.9989542021167095], [-0.022023042987361793, 1.2289715845869122, -1.1116916825944425, -0.8665169166013388, 1.927651986345509, -0.8104241494071239, 0.3883583834783841, 1.681649318573984, 0.6763505756550288, -0.6837438355439851, -0.30717732096918515], [-0.065653360450613, -0.04545910964716823, 0.8899653424233462, 1.3761376874256663, 0.46855478588254684, 0.6802615205393857, 0.1805026054625798, -0.08265679292960385, 0.28901791173575275, -0.7269737305483299, 0.6980584916552327], [-0.003257988970015482, -1.5573275563900613, -0.010603925720998695, -1.4225832720854645, -1.6363636760245495, -0.7016079578515412, 0.09000814853207516, -0.49247465760932135, -0.1668042859862504, -0.9090893290671098, -2.0924739478766368], [-0.13778647871248673, -0.6074293649383451, -1.3983098847249, -1.8440170712035269, 0.41246843640733344, 0.27379545579833753, 0.36855832927659815, 0.231816274954754, 1.2392263762546736, -0.2333072765013915, 0.14967131750960302], [0.5065614320782, 0.07473638568526553, 1.822829002015358, -0.5991701598429157, 1.4734468995894767, 1.9708438212502133, 0.5903183053740938, -0.6330241450119958, 1.4864996648568052, -1.182802729338811, -0.6044138148215514], [1.1999467548065372, 0.23867721325128202, 1.680972255128687, -1.2326428653788288, 0.8065021389171491, 0.14948700635736642, 0.22049709389894778, 0.6835045360517135, 0.7165194074378225, 0.09515881055924809, -2.835784466857325], [1.3814813974572713, 0.09645891439933514, -1.2103537621888532, -0.11630783948738872, 1.109325237008889, 1.1360585333032436, 1.4317242076134247, -1.446075126552792, -0.7254226703692377, 0.8231799244259626, -0.4411951664298943], [0.8355723918288017, -2.1334528628655, 0.7938706347640955, 0.5731450448785846, 0.12246732499078888, 0.3941815325910979, -1.5532591703424818, -0.6365845166438482, -1.626442458287181, -1.2893590004917708, -0.554027903195268], [0.6718836727410163, -0.9451868828186619, 0.43217703986826655, 0.30642347835646105, 0.7102549809568534, 0.44076913832993025, 0.06894485667565858, 1.3471559074192858, 0.7452486336981696, -0.24939701670605532, -0.2439814733615044], [0.13266032807033684, 1.3895828836399222, -0.6921222743971124, 0.5538089139346358, 1.5598746403267068, -0.3858390226919662, 1.3126281339560293, -0.41196052122018895, 0.8122512204189934, 0.9280003703122834, 0.5937647225356539], [-1.7886433675383846, -1.7736963317653864, 1.9082336967715863, -1.0491305767862085, 0.09843814377177383, -0.5305161218831017, -0.3756392206352602, 0.3563911601175512, 0.8721487475384317, -1.4952583400078612, 0.7847146477007904], [-1.1075253080563736, 0.08782973561265459, 0.7774546761047687, -0.6502421663032459, -0.8199817815622371, 0.4521006615687894, 0.60395992624073, -1.5194981243510863, 0.255103523870726, -0.8391689521196354, 0.33780851596351597], [0.7202423036508392, -0.19014566976588607, 0.3078837489662441, 1.6078949469140902, -0.5904556229665736, 0.3856140039584441, 0.7311637883742765, -0.2339585695601299, -0.44953451827589086, -0.6744955306538298, -1.2827157293321965], [1.5814638137889938, 1.2782344303293245, -0.2178714292360786, -0.23773405740682776, -0.6901713132523205, 0.5744522391915968, 0.7059487794217872, -1.14817786194495, -0.0060377124941372266, 1.0935881857752037, 0.7110733128325168], [-1.737552950371197, -0.8689730685885043, -0.7043164738516883, -0.24855228344149477, -0.629304776993729, 0.13977396017448376, 0.5851486407956064, 0.5520521172450302, -2.0379489878713812, -2.323093972477046, -1.197289357491392], [-1.027839911418417, 0.8712807077075025, 0.12229378697732435, 0.42388277902305044, 2.181891361462787, -0.22093532881607789, 0.23825692630302067, 0.5339894949276774, 0.7820496885687033, 0.23644492211137055, 0.7007399746022286], [-0.8145027818924251, 2.479008442513986, -1.5965036108164896, -0.8212668168336026, 0.45559335305171794, 1.1604017878276591, -0.5914343946052351, 0.7899705096396465, 1.0052146528924073, -0.004980641456055286, -1.3097949562830071], [0.11685589263236562, -0.013347618029764313, -0.35820949987304496, 0.02967809468841109, 1.1115954464332596, -1.2239616102500153, -0.03129049155787726, -0.656205978073286, 0.40244829772837165, 0.7736279448275967, 0.5360860722437114], [-0.7929777446827017, 0.15968949177295552, -0.5173998373098135, 1.3313101875720663, -0.490396400506834, -0.8109511818597089, 0.5385315071978979, -0.03614339184964135, 0.7853612165163197, 1.1302442147581817, -1.1877217834202147], [-0.4760182716505211, -1.3476482799756468, -0.3503886686052356, -1.9252973840042025, -0.4632919220236944, -1.3369147729448856, 1.1350550744896222, 0.007960126777259541, -1.3423213863163015, 0.6908589542366779, -1.4732816601794012], [-0.41511548216793914, -0.6263028955259149, -1.2173801983353505, -0.6176565507153065, 0.5423165547915987, 1.8721225106333792, -0.2098364587621888, 0.15167351796316048, -0.6763026028044027, -0.2333359294896367, 1.31638240064387], [0.9927458510522502, -0.4877081316634309, 0.8951507656955565, 0.6902666221794557, 0.6299728038135488, -2.3841361225732456, 0.5643219230490846, 1.503704511169063, -0.3840797838047446, 2.2352369553399507, -0.6271973136479199], [1.6746646819845938, 0.3774126515046879, -1.4640128824116663, -0.10295126914210051, 1.254373225442129, 0.5976091793333952, 0.13409666594026692, 0.3425968439925489, -0.4545332701149898, 0.9560091074883549, -0.04593013304722543], [-2.2908970375823747, 0.6714158969511533, 0.5496786078526181, -1.8657105038975803, 0.7163941820525976, 1.3851433070910515, 0.6531909234070425, 0.2089105311982621, -0.07781036712670503, 0.4557266215817034, 0.5626073465164986], [-2.078053118833261, 1.0533390739940747, -0.9952346754121063, 1.9386456434609745, 0.7528647095088526, -0.49346362438851016, -0.10100984974663725, -2.105478815965402, 1.6945549559291528, 1.6731528690212956, -1.437551073431965], [-0.1571703452641638, -0.20322635189674773, -0.3337072569985699, -0.14887459988593385, 1.4372978083460262, 1.1030122724877116, -1.2353231409698051, 1.122463172552381, 0.3263475510575983, 0.7260993346995583, -0.8672834382570803], [-0.7285479259328297, 0.19540952589571345, -0.22192858129359724, 0.9622619548998373, -1.2385774065757627, 0.11613197390240913, 0.3244026218726634, -1.9939143638194012, 1.799440311133087, 0.3153662347986365, 0.7932084333336527], [1.5718864416628253, 0.5480530424749822, 0.6374992369003785, -1.5020375870372624, -0.6971225034927888, 1.3628687232419785, 0.06869705309146838, -0.48928068518367457, 0.2268348324694318, -0.4305265181047887, -0.22690832277133552], [-0.10690167617300333, 0.24652439486762046, -0.07290726538226838, 0.0031892697910929995, -1.6630151608936476, -0.3737287424161353, -2.0106637257880005, 0.0073595639966997075, 0.16911717144966326, -0.15861079684659057, 1.6814917981467181], [-1.0316885789509733, -0.15330734428231924, 1.2942146501775855, 0.9806682208847722, -1.2573768952542084, 1.68028707430669, 0.6668715651953168, 0.8212641855750312, 0.30124878436530406, -0.6958799961489066, -0.9134642641446047], [0.5865732364792985, -0.29651218447510413, 1.344342308014972, 1.3999606776643265, 0.4155385097180521, -0.5882140898745938, -0.876520628483936, 0.08004560008311425, 0.48670710875776213, -1.8523944753670765, 0.34412120426115395], [0.6635624983070797, 0.08922368443224654, 0.5243336791096347, 0.34716484345099646, 0.6214766385749353, -0.7692737974229741, 0.019057228892492818, 0.5827161463641257, -0.2667869545126045, 0.6293136960368058, -0.6093114372123543], [0.4868168994596433, 1.3320392988779515, 0.12229818408645085, 0.6596460316457534, -1.5680697530942713, 0.3400608500105188, 0.32158250517604403, -0.270602727887315, 0.2298908082079834, 0.8412700303379782, 0.15977646620892313], [-0.3544206920755751, 0.5544126210935927, -3.211588406896152, 0.5307197275747308, 0.003756505782345411, 1.548305060161182, 1.1251689612792792, -0.4702168587288926, -0.03270632396620803, 1.7876222823505954, -0.5281842350731977], [-0.2649652104114589, 0.450728601066805, 0.7325669781588339, -0.18827677560420947, 0.8639904390305527, -0.30453353976396463, 0.5003673905545841, -0.3346718804258595, 0.7993288010901205, 0.5659456164499813, -2.4379108351603995], [-0.13566144429243276, -1.1390710705248979, -0.9870477153728785, 0.05884879592385266, 0.7326543261749028, 0.581609096528967, -1.1040852917936084, 0.6616897073551922, 0.6006945459005245, -2.9832139307128624, -0.0006909219778187587], [-0.016476768026463626, -0.8973869736648683, 1.795713937182654, -0.2166961226844281, 1.2821292043272203, 1.298046275124054, -1.2425538125416793, -0.8923577028041997, -0.36827803842361273, -0.09468067202814426, 0.6254109667982838], [1.377360515625818, 0.4105314598075166, 0.7587449730669461, -0.8263649781454323, 0.6918918331019648, -1.2654067780683687, 0.6167444706388847, 0.45349767375727185, 0.2271810356338948, 1.3081156253116144, -0.26041249661269983], [0.9973147837270413, 1.291477175302939, -0.9240399317528453, -1.5471571670298485, -1.0972383913001607, -1.2231028211032857, -1.3560051630236523, -0.8035304360017254, -0.7494962107168054, -0.11436221641916675, -0.5782754539641572], [-0.841260622003721, 1.2258511475170109, 2.081815641294181, 0.9417011971251236, 1.3299612535538152, -0.5260803657780837, -0.8581980542472964, -2.5341176336181865, 0.2840107968693249, 1.547440614079455, 0.9997879286256021], [0.1800979958900532, -1.1880209188946111, -1.1734465435861021, -0.3521638742653935, -1.1680391864644044, 1.4738284688736503, 0.7320218145474949, 0.09814847612810713, -2.1291446842230903, -0.28197242874630246, -0.6713631093752287], [-1.8441460885564198, 0.7160369748752983, 0.864642903446883, -0.6641932337787495, -1.2707927777445946, -1.5246335475333226, -0.6536788265922407, -0.7827914153797156, 1.3549821012946985, -0.42689513794734174, 1.258082545859437], [-0.5347235906470754, 0.2199231863277593, 0.6157520338976088, 0.5343200270248182, 0.84253000245973, -1.7225896249950845, -0.5182177339953586, 0.8736413677960772, -0.9256744656834578, 0.4430686588948897, -0.24707965328961312], [0.5296560936461937, 0.3986749587436791, -0.4999307549401956, 0.9739745238277947, -1.7469789582841728, 0.3405721000206977, -0.5244872084322056, -1.447727063652445, 0.32808674294217555, 0.8041456391342011, -1.3675669017708103], [-0.4688299062624321, 1.3259455502107276, 0.19811261766237723, 0.0037569357297685966, -0.3948701365168565, -1.0995241959413482, 1.9194556537989633, 0.1633518648033289, -0.7043674636220622, -0.07739371051706202, -0.13902235185344916], [-2.4804427935537277, -2.887803549832535, -0.5208680467991001, 0.04277700012971977, 2.3453009497552455, 0.7453487235256091, 1.4327673223109225, -0.7705171805119364, -0.6703166581271182, 0.1874858614088582, 0.90871399063725], [-0.6623776082095497, -1.7724952153278466, 0.36928380953923684, 0.6307395155247973, -0.3545836401909805, 2.113565792332275, -1.077601509895539, -1.385641416394678, -2.478489595985215, -0.6267446571330243, -0.1947949499973091], [0.6375829683928884, -0.7850426807734485, 1.55489209634631, -1.581737033176664, 0.5607115298917438, 1.4618866498768346, 0.47561991157087075, 1.62755931838193, -0.6388868206410507, 0.1892460127686755, -0.7422043109566703], [1.338382164320517, 0.4716342391282676, 0.6359693620853134, -0.05816112657304581, 0.48243738544589204, 0.6277895213676332, 0.6385283883888608, -0.47074487394823633, 0.9410722548536938, 1.355623207220354, -0.533001775422617], [-1.4286941544148992, -0.7344831109596686, 0.24905006195271648, 0.5381704710882808, 1.1171389770200115, -1.786603904645577, -0.4425048316859611, -0.34849213560965964, 1.174422228104612, -1.002371078237454, -0.1438160873605329], [0.8130265656373619, 0.2627723887203678, 0.9760752552614972, 0.6926187888273762, -1.0839051621555875, -0.26951023980199496, 0.23299587410640835, -0.965561787487185, -1.6009094778533186, 2.6807209359394113, 0.334306527563016], [0.3043094750828891, 0.8051791955581531, 1.2849650335061427, -1.136052988806628, 0.5849416032927948, 1.4193944630210948, -0.0581308655018406, -0.3576446503400636, 0.5338538262387295, 0.45530224776420825, 1.366039041127836], [-0.8165853741046097, -0.46924815984463164, 0.2267586242268497, -0.8803304108551376, 1.023919589435851, 0.048644032026626795, -0.17708926342044723, 0.9006081855174609, 0.2765597869476426, 0.9598699106857601, -0.562633836481949], [0.0976061851986364, -1.6667013669063682, -0.16493977816875016, 1.6586159750516127, 0.1756504879104074, 0.17709110355458102, -0.3239995818161721, 0.11083145334078215, -0.3217495233776784, -0.10150624381747572, 0.8468655725928321], [0.6234962189029286, 0.9127318700043322, 0.46788292600095405, 1.3928892943614517, -0.53730827887942, -0.27844752986864973, 0.5322947139118113, -1.9991047668022348, 0.5350528982238247, 1.1747874189241532, -0.4213546335435797], [-1.9776215895032625, 0.9893068997389427, 0.3887536810835922, 0.17097802511863056, 2.1459029736089215, 2.2622265926571528, -1.2490522525832632, -1.0772842644218332, 1.4504884421677144, 0.30321936928699555, -0.4149653748995341], [-1.7524856808976543, 0.785890550955336, 0.05416587745225734, 0.9375947011786431, -1.3655277784036364, 0.5829800119454488, 0.05066410118119827, 1.3285733639994588, -0.803302396637645, -0.7533156465078796, 0.4224294899173214], [0.6604038054784999, 0.5454503215890697, 0.6033016243404965, 0.14277010128299578, -0.9037940971330902, -0.9094681244442665, 0.018624024426722053, 0.6083549590261326, -0.4300376999129179, 1.8407975983511153, 0.8345127205441496], [1.494134243372044, -0.9973493360960867, -0.02828965540078178, 0.6371779560280513, 0.61681142730843, 2.100834518832486, -0.7772598051699761, -1.695615934396799, -0.14976514526311285, 0.7626400046093929, 0.22765354609838348], [0.16725594561157026, 0.6764117762082775, 0.12510649840946714, -0.41632920020013986, -0.5937102376067693, -1.0494990497165892, 0.8274843954011895, 0.9679807946207969, -1.6211625577065756, 0.08053327675301637, -0.9731941857611651], [-1.869067815453823, 1.2391188421228236, 0.04614644078403939, 0.7358820349619182, 0.2479404179208208, -1.43540637311224, 1.457541475216615, 0.23681547853329085, -0.44588650965116333, 1.881109506637252, 0.28960981597769003], [1.0517619476303186, 1.3248365115570682, 0.9619507181196065, -1.4476408004294028, -0.41481631867822466, -0.7221288214897614, 0.17004965624321908, -1.9678695600583727, 0.967244412004262, 0.5652461998197554, -0.10234218983524672], [0.24900415433104367, -1.8907795866098018, -0.7215357769351587, 0.806126239497046, 0.846177362835014, -0.5658860538372259, -0.14704838966404055, -0.3625534329166943, -0.7137046011138248, -0.2212219401570238, 1.6346392056139363], [-2.2606939425658323, 1.3872062265082297, -1.4620955799905662, -0.03363196884027072, 0.6270363998007689, 0.8400630485627204, -0.5548103387906115, 1.3847653952233014, -1.1416373620340838, -2.224439929854261, -0.9444061251965161], [-0.37592737880100946, 0.5477115828304865, 1.0925806740587585, -1.3189418873955865, 0.4692666839512089, -1.6932924780263579, -1.8432989180392927, -0.737916079074257, 0.3690983530614943, 0.8203371721971073, 0.04292809992580812], [-0.6070541155388166, -0.03680686653931593, 0.24603409439665344, -0.9371829807491933, -0.1502592823037243, -0.26567589204350056, -0.09108499645058965, -1.7187672035932928, -0.19114171196019358, -1.038597088960105, -0.20101472638744203], [1.3408507549321425, 1.0770187356429914, -1.1033179844043186, -2.1646968765189007, -0.23314983819344584, -1.4892137413328288, -0.4695679827481086, -1.8333912418993767, 0.20514535640409248, 0.6683675881383013, -0.20363115673599957], [-0.2049224541270611, 0.36037491380963455, -0.4082350522934302, -2.1394341196319977, -0.1447052925604607, -0.6861843638854359, 0.2747333420958486, -0.8917977480152293, -1.009174794400565, 0.7477414106751296, 0.11066371967905425], [-0.1752871473592955, 0.4663817489075168, -2.108770582618128, -0.15036891970489585, -1.534164554404075, -0.3511433115050874, 1.721311551962885, -0.9107127384503576, 0.3248690644986759, -0.8592224315596685, 0.30159062394051733], [0.7886817095426208, -2.0873748496559235, -0.7572551901085038, 0.7861920770472934, 0.15547244205697655, -0.22582928275461292, -0.35684649430103355, -1.291371219484128, 0.28952314891618686, -0.13351961185810496, 0.6297150952018781], [-0.8884269110808907, 0.5731351184229773, -1.772170011451006, -0.7042551320245726, -0.15326782663147784, -0.08628177806766085, -0.8666664630006774, -0.42852801829403986, 0.6935429274137359, -1.2630102102863288, 0.3436740712846602], [1.1419422601711815, -0.3229737886240039, 0.9634865307147492, -0.45010157179016436, 0.16221761446384855, 2.136646495286036, 0.14530860710968033, 0.9420621346141724, -0.1998959006559053, 0.47509429827449595, -0.3023969181408384], [-2.121167754084503, 0.5052148455790441, -0.0379738167537764, 0.3829268132353993, -0.3363020291963896, 1.817507748063003, -0.29057422681124084, -0.47127248274151845, -1.0312635130965504, 0.6421317015652723, -1.0590950367867815], [1.535871414080884, 1.9050311737473589, -1.4087485963100201, -1.4464387995167542, 0.6331587558552016, -0.5834791534424636, -1.3882563985263363, -0.6977000437903965, -0.8153874579833708, -1.3091686670202662, -1.312246426312788], [1.1171622482567398, -2.9967360965980627, 1.3099022955648973, -0.9666072119174599, -0.1912528979667068, -1.677997912329757, -1.5652910111284617, -0.7269187270831632, 1.6175346260070735, 0.7426926334885635, -2.4244033363806263], [0.939651044090604, 0.12338903082398307, 1.0470864247720364, -0.31946706295276783, -1.1390832676287643, -0.21681777185504267, 0.38662863920202073, 1.2421856732089196, 2.3048781041806032, 0.7875886656751521, -1.5047696979264436], [1.1196922755183327, -0.4470197745133691, -1.5367446119562789, -0.8167356605316687, 0.8764753965707236, 0.49347009765246924, -0.20268210529279135, 1.2481039995131034, 0.7735794320142402, 2.174260384650076, -0.16013331415359142], [-1.8037363709596708, -0.8619700374181248, -1.510658052226165, 0.8357844186597952, 0.8278226099995645, -0.5284533369601937, -0.650720164936163, 0.06262777681362613, 0.35358096683720747, -0.7724616076131035, 0.18923501624451342], [-0.5063381681151871, -0.04935567109624409, -1.0444306207431964, 0.499318821353332, -0.023074534787233075, -0.6249908691825922, 0.04784746356144921, -0.20209762094796338, 0.7757400210265418, 0.7804833367388413, 0.34681714955191256], [-1.7128980179222286, 0.7512331271275285, 0.5345658951272647, -1.102708694558857, 2.076290203664072, -0.3294060262528158, 0.22974149022848936, -0.23950605500513858, 0.5618578614500808, 0.9008797911228582, 1.2164714486825483], [-0.06306805957014276, 0.8631798378549245, 1.7700253801917514, -0.14874839061740677, 0.10691191674696457, -0.14202637704941684, -0.9618939091234847, -0.7035808696476995, -0.9398624108527353, 0.6245966548991904, 2.8182281089065433], [0.8347649650345143, -0.5237148760844199, 1.3830725379774342, -0.01949032735994039, -1.651828723120434, -0.07852357131177069, -0.35230352349844735, -1.812063772016948, 0.5209641028631082, 1.1237362443414114, 0.6062563764283594], [0.413128356494011, 0.46396429083404556, 0.14486774521465498, -1.9217777439455803, -1.6826062113930063, -0.3740455501749429, 0.4823383028894125, -0.6618728114255117, 0.0283741871859572, 1.5195486085488605, 0.424920110019543], [-1.8910719894748216, 0.727045727192111, 0.10802484664964031, -0.36038301095455755, 1.2646293042720664, -0.7174572250467223, -3.0672338698735877, 1.398100709312743, -0.03717246845265747, 0.2122777430534534, -1.0913274644915723], [-0.9880906431458908, -0.7133030016925246, 0.629693827692036, 0.49314084314900825, -1.6711878844139711, -0.593688290198315, -0.8060178069588507, 0.46571503775690154, -0.040567733690107355, 0.03892524802651959, -1.7802908200233338], [1.390346414133906, -1.3308455908010284, -1.0319740717411185, 0.533983404498999, -0.03518122957739236, -1.5947823143740911, -0.7306648396209965, -1.9766714368934686, -0.5280782455767539, -1.157991275477517, -0.6515975934492234], [-0.3173703796096355, 0.9386666139263087, -1.5064933820681758, -1.0889743896560926, 0.019587078660621066, 0.8056964643407311, 0.7526879699929057, -1.398626922196824, 0.3484783709527546, -0.19305694001354085, -0.6560613385298489], [-0.17584952036662715, 0.6106253878283833, 0.7588798983620129, 0.6997023290949419, -2.081693812767458, 0.10897721622208831, 1.1402821975432396, -0.1606101760539216, 1.6954448840061334, 1.081864120446393, 0.1532216378090319], [0.5091459257937929, 1.3787823772583796, -0.43161806513327716, -0.31772567976275634, -2.2438916178829804, 0.3479332706830639, -1.0446392284545372, 0.04613510322391667, 2.287966719136109, -0.342476176084685, 0.7121999523189004], [0.0022861452033935675, -0.1943832729474945, 0.08389081133910867, 0.4896519241996929, 1.5629366023794315, -0.20862043632016355, -0.5908219553035772, 0.3899524159771523, -0.16286094463209924, 0.3782228352353236, 0.325015777783022], [-0.6882868470293916, 1.1066682520036197, -0.24590186127492042, 0.009054275455664023, 0.6519048811253616, 0.5885994580598405, 0.13350318981553683, -0.20295463381324502, -0.3739484092897445, 0.958584334428857, -0.8553107012071324], [-0.5136296324718358, -1.2235077587292693, 0.7564499971089301, 0.7032838554904844, -1.4677543703829783, 2.21781406433458, 0.8946313186946563, 0.36766641678766326, 0.961604186119835, -0.18330483334602818, -0.36941791435050886], [0.42631161726662786, -0.23201811505228934, -0.5896932786795471, 1.340436540004189, 0.17018243603910418, 0.6414936188237843, -0.29293709053180483, 0.5742230850053748, 0.7337016476105731, 1.1554115151631728, 2.907124736780779], [0.8292015567350917, 0.7351744259396543, 1.097726583916708, 0.5973571950592705, -0.18374732248996647, -0.05679416214988086, -1.2386033049093985, -0.6558259294616079, -0.6685711545451372, 0.934082753468766, -0.5578807651976205], [0.442119749860914, -1.0013933207153176, 1.5476385610941263, 1.520129155892154, -0.06771997946482729, 0.7987932715778864, -0.08895128022388114, -0.3460368642895485, 0.7196505487592103, 0.3284918368964987, 0.4101650581988622], [0.42909622463270136, -0.6729102816523244, -0.06012159608831734, -0.2148163634052957, 1.0442556447732303, 1.4628097985360569, 0.07160326201273037, -1.121317144057861, 0.5769778397753071, 1.568179654238582, -0.8643073175271241], [-0.24793095274575222, 0.5575931181778826, 1.6301652632078292, -0.18812541344039652, -1.1126502278639807, -0.16922608990903149, -0.6051045379880771, -0.3226890869497411, 0.00680094292455032, 1.4072893486071754, 0.4736053940104509], [0.979813175895446, -0.20750876632445583, -1.5107907789778703, 0.03903963403758856, -0.9020048492984009, -0.3973563208684317, -0.06171749592941361, 1.669135545212465, -0.401414305217687, -0.28761160074019737, 0.8201077489791871], [-0.8597700372766927, -0.7290739529971503, -0.45894676448207955, 0.20636834253658665, 0.3677932029624441, 2.2464185560501626, -0.15792270646666381, -0.7621643848527071, 0.6135129849162462, -0.24377281506138054, 0.17709480148538462], [0.7519434922040318, -0.42006817928776446, 0.5748968211493658, -0.07030457859538887, -1.3243267174013484, -0.9810494629789791, -0.7910513302393993, -0.7000983940843983, 0.06913384365781974, 0.3456405529613543, -1.017444619317033], [-0.1997022604299631, 1.0168124388547768, 0.4513443829061663, 1.2066414800296512, 0.6036067478092053, 0.9131488331266708, -0.010415633485036171, 0.3196056544436364, -0.3155506039759205, -0.26561321205241956, 0.16194110889718266], [0.8466627323619003, -0.653980306017236, 1.0695534119387509, -0.3851383830525043, 0.9309465639651566, 0.40657887139717797, 1.6587381386526592, -0.6670045994692071, 0.6477040803132958, -0.17794661330418365, 0.6820927964936825], [1.7618752999168992, 0.32663154699538194, -1.3002451523311007, -1.0963049202094963, -0.9624602852590106, 1.7352607894715046, 0.04475408717093161, -0.5591677397416954, 0.5119321378903757, -0.3022990541799661, -1.9046671822586627], [0.9370154197550261, 0.983017495097348, 0.564339515673542, -0.23201004193064872, -0.49726020314886754, 1.2227009759960674, 1.3221550793662327, 0.47269988486502423, 0.20778720879073964, -0.5426763922656561, 0.1052530632730642], [-0.2630648253594096, -0.045729215936524015, 0.49495210894965574, -0.6106143399053422, -0.27120025402046044, -1.0348049889505626, 0.6448493529404006, -0.6395528438050474, -0.28027091751160615, 1.2092851680732382, -1.093746765212723], [-1.7617092482302352, -1.9585181818445558, 0.3024269129287871, -1.0108966440083038, 1.1978040861537127, -0.07563466481843126, 0.28973509802197417, -1.175152805951184, 0.32405423096564995, 0.05009690865817937, -0.11016394252977547], [1.053195011918376, -2.6607403085791845, 0.11532103546752677, -0.15728452392460346, 0.6717029226374144, 0.8554128811517051, -0.5149641398576937, 0.8346460270671431, 1.1896143319609391, -0.04093427492664203, -0.5932455828380889], [0.10733152836423537, 0.9979871470310165, -0.8544619284655632, -0.35431438178971064, 1.3154104613814919, 1.0624624233977469, 1.670124075133344, 0.13733900907065383, -1.1841299332931474, -0.951263734581379, -0.23748240375501697], [-0.4675185480937866, -1.339949807943152, 0.7172460994322076, 0.9689805893343985, 2.2934980686980704, -0.732687766992606, -0.7405946432808048, -0.29327676334640035, -0.5600436906442209, -1.5213253670978832, -0.00118083409496471], [-0.6621151574699363, 0.707212167746986, 0.22704822220994061, 0.48340415122414704, 0.7424898753150557, 0.24804245755451249, -0.9654441215478677, 0.3403221586057554, 1.46915975914413, 0.9583204406295857, 1.3191595482291512], [0.6175089227356403, -0.28178630548185946, -0.32447671899356145, 0.9337179908476122, -0.6415517732922751, 0.22795690149367576, -0.2274833175280987, 0.06613339580840634, -0.22314195208907736, -0.14730342407438715, 0.2757088841010176], [0.34128442287782224, -0.592319148047216, 0.3185005147069283, 1.0158014672486309, 1.0568543259032608, 0.4092650033718213, 0.46361501422685386, 0.34895228344150725, 0.16229414441758286, 0.5729261263718299, 1.2635540139563257], [-0.7905675023856436, 0.8901674648818982, -0.14461467193940047, -0.09558018549676534, -1.4046528762859334, -0.6204067919383819, -2.025430766177341, -0.062124726183805615, -1.2881516488905445, -2.5703788288728204, -0.39995314055853715], [-0.4143588438850485, -0.30748999979562275, -0.9945252739938767, -0.9759163333000558, 0.15088917154566098, -0.09569647822487204, -0.5614533939501056, -0.15616750110172484, -1.3594449593367592, -1.1177577421600702, -1.4996559613796636], [-1.0831643053224758, 0.8953684008837398, 0.5157799478679812, -1.3240799429250127, -0.7557830284660458, 1.0218703477124131, -0.37946373101509395, 0.07407049748541078, 1.2783937439231048, 1.493056585174897, -0.3442575925280037], [-0.6960771556997091, -1.0502386842339726, 0.3896407604972754, -0.25200568987388483, -3.1321924786127906, 0.4048824266119793, 0.36602063307579163, 1.3058163049000122, 0.021934342828620126, -0.08722009731894725, -0.8584852024207306], [0.5360310044068185, -0.8416558417679609, -0.14396118902126473, 1.7508579617920266, 0.188464712472999, -0.22772990522517864, -0.008653359808022539, 0.36138593242271977, -2.149272780529741, 0.5315134949366815, 1.6633434703435934], [-0.6508516964961933, -0.37803558939408044, 0.9853032267866184, -1.6276411859764333, 1.1852778632424388, -0.1950222765253056, 0.4801883434410999, 0.9965158636176225, -0.7695114836707231, 0.1862716131313115, 0.9398643125500102], [0.4471161657712868, 1.442471837567146, -0.756335391547397, -0.6378506817593808, 0.17597719608722642, -0.7344245376895022, -1.0718888998832883, 0.4501622932314547, 0.3990462593492201, -0.3079592467990388, -2.064798821307365], [3.730871913372008, 0.6762459514576701, -0.3705954559793513, -1.4919937737561064, -0.5853074775706727, -0.05021792584555272, 0.04698165562045939, -1.4100525418141676, 0.4190509658305909, -0.2637460552679073, 0.3324342263167248], [0.18564824092664967, 0.30412523511070366, -0.5086253350813033, 0.3072845101405061, -0.6861746871011657, 0.055797008298370546, -1.0961675915613296, -0.5511192223824114, -1.673015880192615, 2.141512453923317, -0.9996207013012439], [-0.41967670459632916, -0.3551548455163018, -0.32178672933231495, 0.23755438922805888, 0.24897933564650418, 0.649410906821232, 2.2771408702086045, -0.9929991799529425, -0.9013759578880168, 0.47570986847181507, 0.38781439700866], [-2.278204373393848, -0.4271799672936321, -0.5426066740617028, -0.051603367143610426, 0.41668114086281627, 0.49341772966807057, -1.2938898876849192, 0.7966075708710151, 0.028853967325862248, -1.0007240386452654, -0.14706368708617895], [-0.35375835160886443, -0.767755822952028, -0.7391205191102727, 1.3697482570778035, -0.6128700062783039, -1.0614490461031119, -0.5782291578503994, 0.0030863073400908135, 1.5623840431126175, -0.5904402430729941, 1.4371245875715635], [-0.5761736146154096, 1.04054821675052, 1.7395878993981064, -0.5619728877585083, 0.03469882706590183, -0.6965982424686027, 0.7885895420285955, -0.44873726285175886, 0.699574202906633, -0.3161317660489144, -0.4228430260731975], [-0.27281407383605294, 0.10219388717189981, -0.7192996783726107, -1.6246039037557363, 1.4251068015302077, 0.638447006177215, 0.7334181165737166, 0.4485379728731886, 0.011119603434673287, -0.8679807516852114, 0.56826988967109], [-1.1946693780889035, -0.2834026442723549, 0.4373237733721992, -1.1699533568060092, 0.008790253892958679, 1.5250031213440198, 0.20669004252181314, -0.5734688024862934, -1.2817459736002672, 1.2303753313817967, -0.06007265265568609], [-1.8170945690940856, -0.3686461058376731, -0.1467710095667356, -0.29840213884981975, 0.6735178358810595, -0.5341756308144673, -1.4560047861364427, 0.08519975525040811, 1.347400650165189, -0.3715846320696046, 0.3205121524140236], [0.3109481488346033, -0.7278023412621507, 0.46688914940812326, 0.14929203204694835, 1.961425991276841, 0.5112809872256068, 0.4304061818160862, -0.2269295705123678, 0.21222555899785145, 0.43696438445439867, -1.2553087156624823], [-0.36433484027627644, -1.4587155036441706, -0.18549004910671088, 2.4013321722223577, 1.0298236604817093, 0.44380650615202316, -0.7874312753669129, -0.11428983248421011, 0.7347040861955138, 0.5410473279444256, -0.9691347457707948], [-1.5033675919394704, 0.19079011529405923, -0.8563241169271811, 0.8385784184174663, 0.8730123915426843, 0.3550028994901229, -0.8536357151579176, 0.2577650665828303, 1.5140087971947844, 0.06971099488078121, -0.3326359922566801], [-0.03832520471080523, -0.9494641870659378, -0.5144973393349592, 2.1309956664394507, -0.3062321594446994, -0.41466716580035595, 0.7514523240627385, -0.2038334281904195, 0.5401291944867844, -1.068947577699283, 1.1805834015473948], [-0.3145497307229629, 0.9538513859848199, -0.6285066034122571, 0.18649279096663687, -1.2205072727870887, -0.48839854707144137, 0.08610490425861679, 0.03672735397597977, -0.2519491885532132, -0.1800704238457483, -0.8372690477696979], [-0.254711762696864, -1.5995112363483017, 1.5833996545482623, -1.4643647594167721, -0.3685628689087543, 0.9856732559136651, 0.2237988290567574, 0.21593149475136902, 0.986936120462939, 0.42939690458939206, -0.6917503668911856], [-1.4100287917398109, -0.2817028398840328, -1.6060644627912395, -0.679931317859667, -0.3515419365830644, -0.12163541317799734, -0.8973154776061261, 0.24583586575780564, -0.331387467406612, -0.21892177427795315, -0.2822711218461355], [-0.43540979765900845, 1.750571340136027, 1.2925420125235365, -0.02030673272110416, -0.5987465140970755, 0.4264467742833614, 0.02382193841727892, 1.027257145574139, -0.8801823741486932, -2.0921508499754635, -1.1103009163292492], [1.7439832203029617, 0.7085246100356681, 1.3034452777802104, 0.8987375788537466, 0.8386207925074878, -0.2983968709265898, -1.145338774630697, -0.42690234905360236, -0.37915253164878243, 0.890420307915275, -2.0346893222485836], [1.310519049728698, -1.4295056540679636, 1.5232195615997295, -0.38101349747330326, -0.960236119876349, 0.6780699616083533, 0.7366069012922922, -0.27930889227136085, 0.49083590282545453, -1.1192673981153007, -0.44649943111799545], [-0.5213773546509203, -2.356385231802835, -0.9568906427580014, -1.7986474989690058, -0.5273812677898444, 1.9568154660733545, -0.03623237583673021, -0.14872326846241007, 0.5710550393693502, -0.9071605051698843, -1.935641445231278], [-2.130793285003285, 0.6074821015930543, 0.34901678969686883, 0.6291680721662698, 0.26901405127965333, 0.24149505293033408, -1.0310924085558135, 0.6624982054626802, -0.7102460196594692, -2.3081927003381058, -1.5167751159047147], [-1.3342037430355782, 0.1587594691287899, 0.8240259270103841, -2.050712774437541, -2.0787405758312905, -0.7646671077952987, 0.2904482165192088, 0.466222441382727, 1.9216323010825276, 0.22517906457736486, 0.6560932172178848], [-1.7801565815879736, -1.2499178801893447, -0.6151789060734948, -0.2437632047976983, -0.3010826692783573, 0.1775789460820891, -2.126911389092406, 0.43794729747887984, 2.166120409158697, 1.8117721055249159, -2.404927096931375], [0.8689304878230129, -1.0782798814089318, -0.9366605021364977, 0.4626242400683209, -0.7494868407467176, -2.118234365915245, -1.4810034041441478, -0.782407385967878, -1.0013741656343387, 0.30550168108268866, 0.2573292898634153], [1.3177300685356053, 1.2934341971955314, -1.7660311530380792, -0.1606694785749699, 1.9903385275396477, -3.6234508467256545, -2.809173414209638, -0.415187095121263, -1.2986065457609681, -0.527209573376068, 0.8958422875179495], [-1.7053708879855618, 0.10470332575883863, 0.12059924917532075, -0.19945111349304565, 0.6147462805326471, -2.4496029731865887, 0.9819244551444862, 1.0812927065623696, 0.06909153969123383, 1.4255049859157884, 0.3253470770267916], [-0.4771415909260097, 0.45904610537453333, 0.8362036538254181, 1.509037071188564, -0.9877125283016555, -0.13101884691094418, -0.11336864585575587, 0.7111218711042109, 0.1696345268609788, -1.0792478814148545, 0.3501227980561797], [1.1116164269722089, -0.8283604568434965, 1.9465279675885794, -2.0112346367214533, -0.24718469956244465, -0.27598478233905677, -0.3436999687297725, -0.4372005946442904, -0.6546833145881356, 0.5162865112954449, -1.3393921418511046], [-1.1937100689547115, -0.44046289752472845, -0.13753108793848964, 0.5027820803655376, 2.2347567685720016, -0.07394621889519057, 1.6748326953736092, -1.2429350135597672, 0.16706154766384854, -1.065082630456589, 0.514826431712451], [-0.5376750317390532, -1.5012126153621683, -0.18429950069147677, 1.3834043395627786, -0.16391053280145026, -1.6807495731609086, 0.8277592879164054, -0.19686181909572703, 0.8450034736606301, 1.1989656376349698, -0.573278508079534], [1.0659718885422842, -0.8096870166179598, 0.10016231769037073, 0.02685454587387504, -0.05221127838338058, -0.5836940555543589, 0.5801001354383601, 0.3693622714788656, -0.906869452263744, -0.19757894812136628, -0.6555656392440118], [-0.9935633374419904, 0.7836883607670999, 0.49070649210792455, 1.5094245800125312, 0.28622236217917996, 0.3677624408831722, -0.4171634069406567, 0.9645187793621405, 0.07221228056932383, -0.14624830211826417, 1.166574333500623], [-0.08455225815334422, -0.7442656065871428, -0.34308798396756707, 0.2642546989795926, 0.9307032888767441, -1.105023574853041, 0.8996854894621683, 0.3501576798280416, -1.3556083836928483, 0.0829776901583478, 0.6049295526006175], [-0.5949693680431318, -1.3329398776935162, 0.20792266755609365, 1.2222533371531037, 0.12358728337983649, -0.19993826606804543, 0.22268739456576425, 0.2811846854213509, 1.219011924688255, 1.5475328709531655, 0.7913292969978318], [0.732169376131779, 0.8711595070551773, -0.18032433529229236, 0.7666738137885802, -0.6724803820630586, -0.4866127085708601, -1.4431739726414727, 0.6825845015929295, 1.2661189100576513, 1.1658594555139346, -0.004769410070144477], [-0.6334989411536484, 0.5141523489069598, -0.9905014271537464, 1.0486480038740373, 0.3212295142822659, -0.3412287689541428, -0.46564861265072716, -0.2308664670516972, 2.255233106064369, 0.48354116416281484, -0.9114393358674115], [0.060771243090845896, -0.6031027558880458, -0.25695661755390087, 0.5388205475784001, 0.6926541178662656, 0.8659080327135561, 0.43133902136617586, 0.6236666792198201, 1.1019181757930843, -0.17940128775725, -1.3800898006250646], [1.1526202288600291, -0.2789186074003112, -0.8586015741165212, -1.779420235652821, 1.4768306173635843, -0.49888506260592586, -0.0534982036237692, -1.6056286718424955, 0.08503653795754589, -0.4774356823562439, -0.2398566326199369], [1.980325907540671, -0.38587898939435106, 1.9652019676673955, 1.3017933874319259, 0.9124389386429499, 1.3040676602666623, 1.5407425376000292, 1.862379544463004, 0.5367717178888428, -1.516367175060917, -1.127912260576104], [0.41975115629909054, -1.6482741489613322, -0.5595412482466898, -0.36438847503909744, -0.5655259621548171, -2.1915545983965545, -0.6412903873540244, -0.7413622827944651, 1.7030838653773608, -0.7646880800655551, -0.9934888494268407], [-0.44807991817027826, -1.0377880576204466, 1.6526423745799776, -0.9480190936512082, -0.6017704312743569, -0.48234265181829233, 0.08749945906476228, -0.3830758356855316, 0.41456399276543177, -0.6781453772263365, 0.9217919081643411], [-0.4986608167007311, -0.09367439990539685, 0.20962213176934902, -0.29751659563568883, 1.0072420067328087, 1.5147101772596643, -1.594974072923655, -1.0507853193732808, -1.1781762176214874, -0.09126340990221816, -0.05736596255282147], [1.501033868694365, -0.08073504625909925, 0.4831360830688514, -0.17321179113327254, 1.2554357533038847, -1.3047122623815104, 0.9419738003055009, 1.062175169977075, -0.5630554503625272, -0.7054416611484806, -1.5980815140437599], [-0.17845131262717043, 0.005984936590076729, -0.09886877237823977, -1.5905398589132462, -0.5866478873877782, -1.0252740903506552, 1.6848739375388004, 0.38201395867838517, -0.6578678146162211, -0.5400111370494174, -1.0190627367451492], [1.2792700983854794, 0.1993115064297366, -0.8830083761053296, -0.23067553378842542, 2.7034116909956603, -1.1509374795738465, 0.0876199938845232, 2.2318526540671733, -1.051071156864888, -1.7812088740564667, 0.701566185376753], [-2.141546529114208, 0.8121641279099758, -0.24752187834585598, 0.03752051413786053, 2.443461696964998, -0.9361000020735954, -0.5942015730252728, -1.5341196193277644, 0.5202288948479145, 0.18636857110535548, -1.1561977281453368], [0.5280654322975897, 0.8792439607740682, 0.9782623576928232, 2.502092317806146, -0.6666403534953919, -0.620087881161499, 0.6125453898961052, -0.13988910907163357, -0.5764945130838844, -0.3071094170940664, 0.6837790094541476], [3.0084833998749065, 0.6087267090632205, -0.9193051658519915, -0.1227452467577157, 0.7046962503328361, 1.47638442312133, 0.5403964496407986, -0.829638698608886, 0.821327289664046, -1.1262772402112466, -0.05548189286328419], [-0.23399248864000144, -0.2078180479054902, -1.125828171195267, -0.06477190437181034, -0.9486396315584201, -0.4782733142747518, -0.5749339590698405, 1.8483738863991839, -0.5139595852414784, -3.062158289839807, -1.0357565118706313], [-0.8433375062338888, -0.10736697070203109, -0.4938504667291283, -0.01398965918314244, 0.6469459509640739, 0.21903318466222071, -0.07357360012862475, 1.1547656115920317, -1.0584258871634034, 0.13502417335813005, 0.737579488056156], [0.0913125722997836, -2.3494673734061706, -0.5554418262879847, 0.281095443611821, -1.1371163519384497, -0.5155639798947825, 1.8851773808522692, 0.5825059388873927, -0.3809835572325082, 0.9456104738416475, -1.5935183292512312], [-1.1711470032452924, 0.5032159810236065, -0.7195794201051156, -1.1881888883355871, -0.1976396610049073, -0.6859111659005773, 0.8089281848729971, -0.4284402205876947, 0.5832661177162461, 0.19243029390590838, 2.1461229266339363], [0.10682187009147597, -1.6390469726844965, -1.8451215781073353, 0.5291203386988026, 0.8060839951063219, -0.12918896863572446, 0.7871711987810714, 1.085800946026427, -0.2993815558355752, -0.09561481927984548, 0.9122920075635892], [-0.5928318347476842, 0.7100273515204747, -1.43461867674884, -0.7808769605141325, 0.11715361123841496, 0.2841698371912079, -0.2825919456278503, 0.9192805355833958, -1.7253565105794042, -1.0171331015614151, -0.13716407175969608], [-1.666958661633892, -0.043585120970618854, 1.2344979914814118, -1.1108342273571576, -0.08940337645843037, -2.082918342749376, -0.46810912326349713, 0.6313399846216138, -0.633821035552394, 0.16523001008296945, -2.895091819046027], [-1.4638981316379809, 0.8000996156769878, 0.2507108185708608, -0.47368647676546577, 0.07051678521448011, -0.6698064352493618, -1.0148408320234916, -0.16909737881757084, 0.2179928035114695, 1.933563850525947, 0.585395379656172], [-1.8248681927402601, -0.582809570947571, 1.4542626342436382, 0.11307293905683576, 0.5863865752960817, 1.6141807049547383, 1.5261411328726004, 1.9784362552278008, 0.28750264458108593, -1.5307819775501634, 0.8431038164843817], [-2.4551456546101975, 0.19027683229175163, -1.2476305756795731, 0.04565926107514738, -0.6698331252444982, -1.0496588993054672, 0.3799552238326978, 1.6112878731697222, -1.8647272341546002, -2.3013797625566355, -0.12388737826262841], [-2.1045533877340166, 1.200080133172796, 0.3528958493052432, -0.9438100560870358, -0.32646765136028927, 1.1227471186784252, 0.4400977162064776, 0.07292753452349879, -0.1495894563821863, -0.14368907151700003, 0.1486256139203504], [0.520604425775426, -0.15432393533322794, 1.0070832295141372, -0.7152707454478522, -1.0323870102585735, 1.2216855132228361, -0.1590783238797994, -1.8205811609345495, 1.3185120696344441, 1.2213388993012257, -0.11902490688539417], [1.1137818003939153, -1.0620187525562834, -0.7646273408332329, 0.6550183359758359, -0.8602662421343735, -0.2966037957682805, 1.091766101956827, -0.2763170649180081, -0.01986503518105014, 0.6713806300462096, -0.9393258254078699], [0.3293584513685017, 0.30557798063435165, 0.14600812170127134, 0.15645675935274456, -2.7341708101902964, 0.2701699652922312, -0.03935889941770951, -1.0938598851028098, -0.6495894081713022, -0.28737692526568615, 1.5611802059900461], [-0.32480779506604973, -0.9610820114706546, 0.6446417979214104, -0.4639196214560042, -0.39533812700266413, 1.5314575814337124, -0.5210623943017658, -0.2144260245171569, 1.5595256002666071, 1.474693257582901, -0.3502946547236465], [2.356315094846684, -0.13539606343726715, 0.09018516779493185, 1.4189886372738054, 0.4204793550067362, -0.2855781568694913, 1.717130881075291, 0.3584133080982111, -1.0044060334076552, 0.3800461298860246, 0.44928069474611326], [-1.9740937127740381, 1.0975948875945751, 1.0833152045887866, 0.38729778288093025, 1.8400426138451917, 0.18768030633620655, -1.050175631938038, 2.9717624321411504, -0.8727155127232076, -0.4936495397180011, -0.9299562765715382], [0.49741041336678654, -2.042650766116634, -1.312818795721266, -2.5709181405040713, 0.5816947957869834, -0.49501888180083053, 0.22392826720075526, 1.0961687238353244, -0.031941871820029076, 0.01900781539526028, -0.20206898741236512], [-0.14678616579217113, -1.0446237978263035, -0.9443120097425309, -0.610801589536586, 2.0178123632420215, 0.4961545383422545, 0.0334001317373336, 0.442839049318006, -0.8968882864768364, 0.028877114741730377, 0.4947233402926585], [-0.18923743162423862, 0.7966141674551795, 0.9303252086381022, 1.5364149117707615, -0.40776635637573533, -1.6326501856280378, 0.04825872198824991, 1.6007539029017996, -1.4939271205020836, -0.026353689676290287, 1.4865842450337727], [0.5979370176894403, -0.2660634314535331, 0.941157512033772, 1.1017079485972068, 0.42223986602338376, -0.486510785937827, 1.24842220291334, 1.5122243687402874, 1.7104920712605158, 0.3160422132599371, 0.33506733844781617], [-0.7104792173810064, 0.09771624505851195, -0.5373080976769632, 0.8349250836730885, -1.3910455814452742, 0.2854631471793461, -2.4694010854080015, -2.5924264710926876, -0.6813949905989111, 1.6755757711036507, 2.889206984537364], [0.24381487086796613, 0.747739018976782, -0.0027576474437982124, 0.9282520170493492, -0.42353442333478486, 1.3711231430427495, -0.7346148196346703, -0.03230351697376002, -0.7153583598189467, -1.859253408476433, 0.8322847752354917], [-0.31028078088093924, -1.8276904778589276, -0.5051651628580367, 1.0385306338731894, 0.4684957076878804, -1.1188028965586139, -1.8869426955513118, -0.3662860772425589, -1.283701211174207, -0.7808420781214023, -0.18037900329368903], [0.1200748147025166, 1.6063692920885206, 0.43375298235447113, -0.3986575934366704, -0.21238918738976695, -1.0245057407916063, 1.206791022048746, -3.7996078499261636, -0.8433859522311923, -1.004023229611754, 0.6109960221990034], [1.6981476673673581, 0.5935209571839849, -1.2795627941845928, 0.3992663824688197, -0.7614772554393012, -0.52205703576718, 1.414018752211526, 0.6629560107833125, -1.464308178160196, 1.0778963900888685, -0.6432003614865572], [1.6569240557794809, -0.15913714779453783, 0.7358197944831255, -1.6149800518651636, 0.5738138605112496, -0.03987456834578642, -0.08570404474074668, 1.5184709103668408, -1.5541565583498425, 2.0908783013952528, -0.021732962890938155], [0.10614830358719325, -1.2948088589009867, 0.3463661080783022, -1.323198825717563, 0.9748539508001922, 1.9288225172450433, -1.0731219292352334, -0.1582611519624197, 0.6852032832822154, -1.5840041583848041, -1.3709073468597432], [-0.27163061978035014, 1.1727738536463417, -0.7514683845535275, 0.16180088108395302, -0.03183265793033796, -1.6315672657239928, -1.391258569751675, 1.2596650970746188, -0.26957350429730287, 0.3878023783585899, -1.1279340264119164], [-0.4953453799979642, -1.4721958481487252, 1.3540941948287024, -2.164987780401942, -1.0433013646338631, -0.21054736108844976, -0.5578623999956518, 0.32564442493528284, 0.10849187410022407, 0.5126774269586692, -0.018783738063583064], [0.09268037218158776, -0.1677935945000333, -2.495650826397103, -0.8367460675891687, -0.48739296147038613, 0.3678532301799499, -2.630540925920715, -0.3964723178693293, -1.2187778545931869, -0.6160010502001362, 0.024056413267608295], [0.43476638063731116, -1.0528925652842434, -0.5429589931832335, -0.3364338991016381, 0.5872107217533838, 0.6422614941932252, -0.2120670810683446, 0.42153390732979934, 0.38395927519590606, 0.07089166595996826, -0.04053179181831338], [1.7722659525983675, 0.9091526400182429, -0.5456914491650456, -2.163285125001521, -1.0055323009739545, 0.13748882603044674, 2.0767028939648955, 2.0539073742155445, 0.4328315343304153, 0.6555779239464697, 0.41742122565303436], [-0.23162650448110933, -0.3034888482336236, 1.088124276407093, -1.7773410512214651, 1.988770233662547, 1.107230849128235, -0.276541342956098, 0.036236468422731385, 0.6309908542068767, 0.27291127709060836, -0.6181615379827593], [1.7971808293595735, -1.2548121090358222, -1.7914209779275756, -0.007972148282413405, 0.019960085170068427, 0.8511102387513892, 0.3759918302559427, -1.1236019794786662, 0.9063612955165333, 0.05082324531137961, -0.4984269821528153], [-0.22627930182000724, 0.08676418572074662, 1.3778053944059716, 0.6750701851373796, 0.2189332966233167, -0.5175323206626281, 2.676361267185328, -0.8050991908742818, -0.8350046897238607, 1.900894923445938, 0.05278350740329077], [0.4597780846652859, -0.8043540365824752, 0.6949749379327906, -0.2569424535220351, -0.20404601381022225, -0.08337653758288797, 0.4874734103577956, 0.681074847854156, -0.3234771177558823, 0.4915167695372311, -0.25699795346517207], [-0.3180912787096088, -1.5220620183100366, -0.6758640915448045, 1.233419776106592, -2.032618455978064, -0.6262583756780928, 0.05173829642191437, -0.3437153374411609, 0.6731977328499263, 1.3589235091968892, -1.9182941041127726], [1.0777672374953902, 0.022002235044201283, -1.6861058928400057, 0.4787428895634379, -0.4509026738419129, -0.0170668112231781, -0.23301082224369457, -1.0546778233250487, 1.2294374002866075, -0.7636387416374769, -0.29916574125368267], [0.003994165114903069, 0.5801196856618879, 2.0030900239102722, 0.7040245742364266, 0.8157827616346539, 0.6668979490831789, 0.34163494263952265, 0.09915384671744333, 1.5906094979498429, -0.5874895789524911, 0.6474979348347664], [-1.299955586830893, -0.15336702915329053, -0.4409484968805548, -0.7208391381111494, -1.6132529548417427, 2.0685472553855915, -0.2715003771766711, 0.358067635593635, -0.47589549075310084, 0.5908257718780269, -0.0997750878008328], [-0.04345723109825957, 1.7888426068691279, 1.3813020617503058, -0.08016905714895652, -0.9840867052338034, 0.40392329564413254, 0.9042202409975981, -0.06706571405559292, -0.17023057768027972, -0.5210439307609109, -0.5624112247271316], [-1.5950604904190142, 0.683571148391573, -0.3979337776078677, 0.7614382082074556, 1.1613547715818817, -0.8495560346382458, 1.9877724918463267, 1.3929967399530774, -0.7417940296132393, 0.12851817716980282, 0.02299205924423133], [-0.006335945704904619, -2.2874316712369684, 0.20548461647657038, -0.3654650814627272, 1.22363429319849, 0.6649856399394621, -0.14424313541518483, 1.891736717047184, 1.1202823823483123, -1.5478359945824636, 0.3978781473522546], [0.8165578608041176, 1.8656701106046578, 1.2178420586937175, 1.3139201488231151, -0.5301774182193751, -0.7526795198068339, -0.14620453115146212, 0.09926872664031114, 0.2523171211447438, 1.3537465816373635, -1.4280498847897338], [1.8310569624532362, 0.4220676678351308, 1.3301599586062636, -0.13769300815366062, 1.4862952844389303, -1.5275717609487374, 0.5131593549118971, 0.3937561447716735, 0.25444660420637344, -1.086967290921476, 2.0109834102415465], [-0.10827389318147905, 1.7320388399318696, 0.6468037857441251, -0.04999916229490562, -0.60783731437936, 1.231846406199384, -1.3707792749449925, -2.987442947034096, 0.0749026907857829, -0.9595030835356055, -0.11090222879538686], [0.2091532403891831, 0.19628564675589621, 0.9804457592978456, 0.046242503393231514, 1.2071432485464635, -0.7127577623411572, -2.1488029797446266, -0.06539123231611325, 0.45059349142050786, -0.9207857615652725, 1.6715660745394851], [1.09088416673843, 0.0716645118115838, -0.4041392137628323, -0.5200646523973028, 0.6419856559365005, -0.027309511238700592, 0.04578164878550872, -0.9056104257731978, 0.83102122091575, 0.6912174887251117, 0.09198094691192829], [-1.9801683049177021, 0.1907991036931276, 0.8381392080757214, 0.42228697990250974, 1.3630284754636013, -0.7028743853270178, 0.38075151923839196, 0.01385024260805444, 0.5037156729337723, 0.7985922002838756, -0.013681627892561292], [-2.0828102106815343, 0.05666678004811456, -0.37262370667899947, 0.11692454365705726, -1.1574077891977117, 0.19718941888762426, -0.5949096421096263, 0.8554983215230566, -0.7481861197473157, -1.3389487438981615, -0.3865128249985956], [-1.1773128734868985, 0.5581394298522931, 0.4750553397101952, -0.6486371649981689, -0.6018423590386839, -0.4019642898141699, -0.8230013008890807, 1.3366333283365341, 0.6068230241961459, 1.3094695760550563, 0.4407722328396241], [-1.2649645757435126, 1.0374778066094041, -1.8498651289515489, -1.461095806302891, 1.2189700431616382, -0.0975650546326203, -0.34511424115047973, 0.10788339124028772, -1.4410538030159137, 2.106588720849723, -0.5041523227219028], [1.3168608536648874, 0.416399403003155, -1.4066225894780433, 1.3345132565552529, -2.1111381944943757, 1.1731787392169162, 1.2057355726868588, -0.26411408302063444, -0.15441192780341356, -0.7224782171846174, 0.44448817221268744], [1.9745269431266608, 0.0916631958249753, -0.5093907887647076, 0.7710989104772937, 0.49250959932541427, 0.14240807165329752, 1.415647421983975, -0.07161952778986055, 0.6403203634179355, 0.22052598577476745, 0.5535803601926126], [0.5619265152531993, -1.2073311160971631, 2.2248651948871876, -0.7712580335164554, 0.4057550624247745, 1.1699405782042211, -0.8214631929110675, 1.297935749432899, 0.07257155790870971, -1.1264095014799507, -0.3713175514336845], [-0.12157624778005387, 1.3547216770640302, -0.14446893976679903, 1.6826017440980456, 1.7633247086866712, 0.7927891243036984, 0.030750690965689283, -1.2429416171882133, 0.3722688023469101, 0.22474874665758224, -1.2383584484657293], [-0.8965636126451711, -0.05208346329684582, -0.7427566181697356, 0.3813066543702677, -0.5700502673203325, 0.23318148119141985, -0.03426139544392662, -0.05101248134850633, -1.5487235497679361, 1.1281215105361522, 0.007006745983049657], [-2.1710265577328762, 0.9369306483689838, 0.5516517526109177, -1.5797664622230758, -0.9808083718801404, -1.1048079033327105, -0.8769771390330326, -0.6948324928496138, -1.295184307861355, -1.2648197942306727, 1.0900290044624634], [1.731692381986656, 0.17471189895489628, -2.2649283367944544, 1.6533019382334349, 0.8445779797069376, 0.641419535246658, -0.08080506122902599, -1.085832682237906, 0.09942308968870157, -2.23408631191513, -0.7693752077058985], [-0.67068307667356, 1.4654862868948186, -0.2050710779730007, -0.6636358011717308, -0.8099887921153597, 0.4973956217055001, 0.22603194566326876, -0.1275920014902166, 0.462389090297731, 0.6802422172640072, 0.021023659676839657], [0.665695178703548, 0.0918352742401322, -0.21498048415642795, 0.8214351696176898, 1.6624893433100312, -0.8536344444148879, -0.4339895273939534, -1.1381521312109213, -1.8205300799846267, 0.09187757006354419, -0.18193330616679532], [0.8086597758622438, -2.011027427644436, 0.24270024505323937, 1.826306347511205, 0.942943482415871, 0.2058990266407265, 0.037663709162842555, -0.8739437355770443, 0.1765436929508069, -0.14623004326881756, 0.7059591754189182], [-0.45403130641321154, 0.45101409566780726, 0.7856106151622755, -0.8040909115889706, 0.29031247682617706, -0.41358822044486243, -0.7496280753427581, 0.7821081812147778, -1.3209841872464858, -1.9720254327604274, -1.0462425192250124], [0.7523964107716239, 1.013576933969708, -0.605142563828707, -0.3076145155236562, -0.5333172232840625, -0.5546661561515303, -0.06582878704131294, 0.31820589068468874, 0.08667200984433888, -0.06309996680520188, -0.35874585554879784], [-0.17524796413832652, 0.9589447549615876, 1.042089305585435, -0.6222371355032079, 0.7779629686582938, 0.1835521373766812, -0.6460010514619728, 1.098131140107744, -0.051136004710442856, 0.6812262869935775, -0.5688993695579525], [1.3590988811809017, 1.3553616526437247, 0.7720626247422054, -0.9388947134632404, -0.4919841208878735, -1.4662713416838609, -1.4969856261200416, 0.928965972930791, 0.029235030276948206, -0.5255443585946206, 2.1078937950488696], [0.017542488735818953, 0.8536876635430849, -0.4530730177578792, 1.093348835427617, 1.195629146615982, 0.7865319770749178, 2.2929032634553637, 0.5765422570534847, -1.0424198194583167, -0.868215645395189, -1.0016734628574873], [1.3564901535244447, -0.18234168182804328, -0.26193360693473994, 0.5051249102024054, 0.7720709880050032, 0.4263630350742511, -0.09473388042998285, -0.40520220674228546, 0.7261437493784757, -0.16494592274852052, 0.9802622164641571], [1.5284096074079248, 0.8312002493578878, -0.31949769377565607, 2.4560024386321233, 0.3850999174997642, 1.421461222449134, -0.2689911243803748, -1.6437967440850787, -0.1572274694733265, -1.2314823826960508, -1.079573757691429], [0.44317122511623225, 0.39427551425454516, 1.1685827476776944, -0.5730189591057856, 1.7519706528905972, -0.7450125213715626, 1.6868849372484036, 0.1760375206877068, -2.368401347770816, 0.03632521679899814, -0.5176239301976983], [0.2088222706050908, 0.5216565617647888, -0.3990506054502906, -2.689894980754565, 1.7614445486320982, -1.2047225459452682, 0.41324564053697554, -0.011464701711769533, 0.13664183304948566, -0.16145066672172126, 0.16428540340549072], [1.2081111206377297, 0.38588835504657437, 1.1038261701022256, -0.5588412578451046, 0.49112764815633125, -0.6834545603717231, 0.5661519047995413, -0.4586151086146864, -0.16863200386868407, 0.6225504902462504, 2.1004811228178557], [0.399657978921721, 0.19740402683463504, 1.028032037643594, 1.0441968949406009, -1.7477076306629082, 0.06815526457095758, -1.8486589212351237, -0.5704501325561356, -1.560962247882318, 1.3217112484625457, -1.1154212636406122], [-0.8319889091227619, -0.37902654532839036, -0.4109815654243271, -1.3472828904448908, 1.1988041205792916, -0.013056230881480111, 2.7668951757826283, -1.4401059980960076, -0.4399797409191198, 0.2673977401840845, 0.6628125107998406], [3.0903488477013927, 0.776215395710208, -0.7670949818302534, 0.6385785455467619, 0.300731597648457, 0.7986980609744123, -0.3027654638894512, -0.63087192125401, 1.8312719195186835, 0.32406141353455004, 0.8155013070704737], [-0.47218410575517733, -2.048390625713205, -2.1663768729848414, -0.9243470263845619, -1.0473703614359686, -0.512694517967413, 0.3150978838481239, 1.3524125929281907, 1.0815283386636456, -1.4359460044242776, -0.29816595476786223], [-0.5884908752087358, -0.28452581466432164, -0.1921203902382197, -1.2220108320167298, 1.307432847036849, -0.25836864636786955, 0.26666462816949754, 0.8775518133328423, -0.6825638702829548, 0.6449494424037212, -0.5294293245763199], [-1.2887305260089732, 1.4459653643021821, -0.8883755957220253, 0.9890876509993697, -2.056476179113744, 0.5589299136465624, -0.28001607460118233, -0.5375057712600104, -0.03865522147596851, -0.7529431024863862, -0.4938013661181758], [-0.20679513759037266, 1.2380220673751858, -0.21444977346732544, -0.08490786927953684, -1.455791381557005, -0.4340997508917987, 0.6328332651432089, -0.6843401935070805, -0.07982767029480936, 0.7201161554456111, -1.8011647231651648], [0.18688229628561454, -0.5398864743323033, -1.0689517283448728, -1.1223072026658294, 0.3269620727778335, 0.5725294535991473, 0.8860881709596654, 0.11525663800113684, -0.1469533243851815, -0.2248768850954705, 0.003948651072938794], [-0.8647724332434287, -0.14890268508101775, -1.0097706187417828, 0.38160541140626764, 0.0719030372842334, -0.38052303726422754, 0.3575855415748168, 0.0773321171562361, -1.6297568714545978, -1.0582078830609825, 1.182757784757653], [-2.3316919340725293, -1.237000389486217, 0.12027354746535897, -0.5562579225981283, 0.16625720908137484, -0.4529539583499886, -1.4851908482454035, 1.625085293720304, 0.20874509849898756, 0.19959575141473054, 1.7626068296146418], [-1.0171703387211941, -2.5681484596863005, -0.7503676681830561, -0.02320090583585319, -0.860231435692342, 0.4498519508201021, 1.612836818322594, -1.0464481956271, -0.0806694145919218, 0.8848509645907013, -0.5306080173561055], [-0.7841588619307361, -0.3579558502167451, -0.061413539022732784, 1.5292486328767636, -0.09337711398777117, -0.0924144159795328, 1.2112393541508695, 0.10070320576548125, 0.47694880517103394, -2.270788303845244, 0.9970785225782405], [-0.7129187585604791, 1.816846952433326, -0.459923355488933, -0.654370091801156, -0.3642300358822143, 2.2705648618127223, 1.099097574024231, -1.3100949648726155, 0.1668682375039234, 0.9926846309981133, 0.2564464904970588], [-0.4278252656098408, 1.5410034224357156, -1.3138412175352892, -0.8363755012414543, -1.0535663936451183, -0.3248325291876498, 0.2038250016745197, -2.0804768970569816, 1.2341749593582723, 0.360258199532362, 0.08918905187267243], [-2.254903898364517, 0.11669838056033811, -1.020133649874593, -1.337720845246626, 0.48686664606868857, -0.947181638249252, 0.20892162960681512, 1.0200728115743756, 0.6038691436505002, 2.6486045441118238, -0.08229739547479774], [-0.2672228111849231, 0.795365297298088, -1.275656682338119, -0.4423095872010733, -0.14533405461190982, -0.26103667621671456, -0.6994243251894973, 0.5238317744228848, -0.06552091905835437, -0.7413163423481609, 1.4540987024540561], [0.01749623474575599, -0.49184637637070244, -0.5454149627884145, -0.2739914233196557, 0.17240780619523144, -1.4485738287412546, 1.3153686949148158, -0.3582911863622961, -0.5582636746479592, -0.5277791587380178, -2.427535131627443], [0.29385690629644506, -0.9267548401711939, 0.6100948341318343, -1.6944578202703782, 0.16225869498158213, 0.8201888336734745, -1.3030253977355524, 0.05294067923791526, 1.4876615424871518, -0.29425882404650366, 0.13692738429466286], [1.1726986597540603, -1.411397180689316, -1.6198694102659605, 0.0478609443797171, 0.6874649916686566, -1.8889315318681266, -0.9384059881900543, 0.31031112821564333, 0.939016390444441, 1.0958463803060072, 0.7497316680673125], [-0.2700506941022207, -0.6051206497166525, -1.698774897821978, 0.7049367074542825, 1.1897078702231418, -0.10506318155923515, 0.4744910067884375, -0.9249698694338534, -0.5027462492179935, 1.0935909907782055, -1.1145614865720805], [-0.39593009171015453, 0.06701060132745637, -0.5575629505332743, -1.3552767474468326, -1.2019727766096846, -0.6237955440097479, 0.5974921828354793, -0.4624919645598005, 1.8361381899879845, -0.16922129943602443, -1.4841630334396765]]} +RLMATH_EOF diff --git a/tasks/optimize-ea-kissing-d11-n605/tests/check.py b/tasks/optimize-ea-kissing-d11-n605/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e67c43884a1e3216148fc027eaa31c36e4ff51a4 --- /dev/null +++ b/tasks/optimize-ea-kissing-d11-n605/tests/check.py @@ -0,0 +1,70 @@ +"""Kissing configurations with an overlap loss (EinsteinArena kissing-number-d11 / -d11-605 / -d12, MIT). + +Sphere centres c_i = 2 v_i / |v_i|; loss = sum_{i= max |v_i|^2 (in 30-80 digit Decimal arithmetic, so huge integer inputs can round) and +otherwise sums float-ish Decimal overlaps. Here every number is read as an exact rational (floats via their +shortest decimal repr), and a pair is overlapping iff > 0 and 4 ^2 > |v_i|^2 |v_j|^2, +decided in exact integer arithmetic (necessary and sufficient). The loss is 0 exactly for valid +configurations, and every overlapping pair contributes a strictly positive amount computed from the exact +excess 4^2 - |v_i|^2|v_j|^2 (so an invalid configuration can never round to 0).""" +import math +import re +from fractions import Fraction + +from run import Invalid + +DEC = re.compile(r"^[+-]?\d{1,40}(\.\d{1,80})?$") + + +def _rat(x): + if isinstance(x, bool): + raise Invalid("coordinates must be numbers") + if isinstance(x, int): + return Fraction(x) + if isinstance(x, float): + if not math.isfinite(x): + raise Invalid("non-finite coordinate") + return Fraction(repr(x)) + if isinstance(x, str) and DEC.fullmatch(x): + return Fraction(x) + raise Invalid("coordinates must be numbers or decimal strings") + + +def check(inst, ans): + n, d = inst["n"], inst["dim"] + vs = ans.get("vectors") + if not isinstance(vs, list) or len(vs) != n: + raise Invalid(f"vectors must be a list of exactly {n} vectors") + rows = [] + for v in vs: + if not isinstance(v, list) or len(v) != d: + raise Invalid(f"each vector must have exactly {d} coordinates") + rows.append([_rat(x) for x in v]) + den = 1 + for r in rows: + for q in r: + den = den * q.denominator // math.gcd(den, q.denominator) + R = [[int(q * den) for q in r] for r in rows] + N = [sum(x * x for x in r) for r in R] + if min(N) == 0: + raise Invalid("all vectors must be non-zero") + loss, bad = 0.0, 0 + for i in range(n): + ri, Ni = R[i], N[i] + for j in range(i + 1, n): + p = sum(a * b for a, b in zip(ri, R[j])) + if p <= 0: + continue + NN = Ni * N[j] + ex = 4 * p * p - NN + if ex <= 0: + continue + bad += 1 + q = float(Fraction(ex, NN)) # 4 cos^2 - 1 > 0 + c = min(1.0, float(Fraction(p * p, NN)) ** 0.5) + ov = 2.0 * (q / (2 * c + 1)) / (1.0 + math.sqrt(max(0.0, 2 - 2 * c))) + loss += max(ov, 1e-300) + return loss, {"overlapping_pairs": bad} diff --git a/tasks/optimize-ea-kissing-d11-n605/tests/instance.json b/tasks/optimize-ea-kissing-d11-n605/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9e1e8798117193a38973c51a3b506f4eb79f7de5 --- /dev/null +++ b/tasks/optimize-ea-kissing-d11-n605/tests/instance.json @@ -0,0 +1 @@ +{"dim": 11, "n": 605, "direction": "minimize", "best_known": 1.7152471173506234, "progress_scale": "log", "log_floor": 0.001, "baseline": 1910.0812438093099, "family": "ea_kissing_number", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ea-kissing-d11-n605/tests/run.py b/tasks/optimize-ea-kissing-d11-n605/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ea-kissing-d11-n605/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/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-kissing-d11-n605/tests/test.sh b/tasks/optimize-ea-kissing-d11-n605/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ea-kissing-d11-n605/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/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-tammes-n50/environment/Dockerfile b/tasks/optimize-ea-tammes-n50/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ea-tammes-n50/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==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-tammes-n50/environment/instance.json b/tasks/optimize-ea-tammes-n50/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0913de2e0262b9e688eaaa9ee2de4283b6baaa2c --- /dev/null +++ b/tasks/optimize-ea-tammes-n50/environment/instance.json @@ -0,0 +1 @@ +{"n": 50, "direction": "maximize", "family": "ea_tammes", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ea-tammes-n50/solution/solve.sh b/tasks/optimize-ea-tammes-n50/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4130b5825099a28ccb698a14c1b343f08d3987b2 --- /dev/null +++ b/tasks/optimize-ea-tammes-n50/solution/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": [[0.7322901985853106, -0.580873433242494, -0.35543933323278176], [0.8668577253808234, 0.29709842023339167, -0.40036260145324254], [0.09188746042046939, 0.8178982615454883, 0.5679781055448748], [0.41753906891157594, 0.7210915371304273, -0.552890695356082], [-0.7479003654736476, 0.6359554715278511, 0.1902779061220013], [0.505801994465565, -0.03341820449736239, 0.862002068444635], [-0.9373130668768048, -0.048481761768592896, -0.3450995993011466], [0.31438814393675263, -0.8388229551939425, 0.44445038507318796], [-0.7527465493975529, -0.5247635341322129, -0.3974869376660664], [0.8097328358764708, -0.5667802456649191, 0.1519634417465671], [-0.35039337926840286, -0.5149747971085981, 0.7823205469037788], [0.7608528722093818, -0.14893360140102668, -0.6316024772152611], [0.7031992081066337, 0.6996024139865048, -0.1267569961085325], [0.16052783862765743, -0.5355084499435196, 0.8291329887687631], [-0.0829631173116482, -0.4823522455455945, -0.8720398112374551], [-0.19797421324956202, -0.872482290982598, 0.44674474010331017], [0.1745502547985098, -0.8642704767830905, -0.4717719274298806], [0.9442997680276304, 0.31119178880473675, 0.1070402666451824], [-0.48438920248932094, -0.027923825885594503, 0.8744068620840476], [-0.6555042626238464, -0.6462434634107526, 0.39074742184797967], [-0.24842750976476122, 0.11160835876493462, -0.9621992239894382], [0.27694916860990354, 0.9608364341162783, -0.00961794577849917], [-0.18716646366976272, 0.3898929511567737, 0.9016386202440627], [0.7473571578426565, 0.3221204451031153, 0.5811159070855981], [0.07581470606828906, 0.49749244658639424, -0.8641489431418999], [-0.5291907885285076, -0.8460019631842343, -0.06509829202827139], [-0.7392775647612096, 0.31816313051783696, 0.5934988665699584], [0.6257898735970058, -0.47103814864058924, 0.6216993619336356], [0.31930600444180995, 0.44433577480136294, 0.8370241303326204], [0.22612525745167922, -0.08431303325833629, -0.970442517805764], [-0.5077589635060772, 0.8333556296598351, -0.21840153271782226], [0.5374730743178054, 0.2839261574194893, -0.7940457364134451], [0.557377500854481, 0.7465391064802271, 0.36333136946445627], [-0.3815346648627622, 0.6327060625971085, -0.6738800619256544], [-0.038369176293852246, 0.9104979022134303, -0.4117297370551152], [0.9157376406447653, -0.12074800444650675, 0.38320293961365326], [-0.32822982500784675, -0.7798822686271368, -0.5329623148556649], [-0.5447609503606935, -0.2721612378041721, -0.7931984415006217], [-0.20273714329317305, 0.9637334138376233, 0.17353834671969107], [-0.8296725523645236, -0.18295159099343192, 0.5274202984394031], [0.41590583225349836, -0.5092324165254462, -0.7534618003967949], [0.9768607557168405, -0.15740225918673897, -0.14480190863118433], [-0.9768864682708631, 0.15719194937515044, 0.1448568920035228], [-0.6788742016826994, 0.21503580197205505, -0.7020608393578954], [0.012084482910697728, -0.0735915541532142, 0.9972152467898271], [-0.8469181007296209, 0.4526330520844084, -0.279021595610958], [-0.04060697495737542, -0.9988523159782288, -0.025399300182086026], [0.4600635849276428, -0.886714806932079, -0.04558891302643101], [-0.4105165258632419, 0.7118757572331307, 0.569832508950596], [-0.9286899228617197, -0.3662744606040965, 0.05812096596127289]]} +RLMATH_EOF diff --git a/tasks/optimize-ea-tammes-n50/tests/check.py b/tasks/optimize-ea-tammes-n50/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..af79b2b1d2f6be5bb2dd07edd8d10ad91ffc3e4b --- /dev/null +++ b/tasks/optimize-ea-tammes-n50/tests/check.py @@ -0,0 +1,16 @@ +"""Tammes problem: n points on S^2, maximize the minimum pairwise distance (EinsteinArena verifier, MIT).""" +import itertools +import math + +from run import Invalid, float_matrix + + +def check(inst, ans): + v = float_matrix(ans.get("vectors"), inst["n"], 3, "vectors") + u = [] + for x in v: + nr = math.sqrt(sum(t * t for t in x)) + if nr < 1e-12: + raise Invalid("zero vector") + u.append([t / nr for t in x]) + return min(math.dist(a, b) for a, b in itertools.combinations(u, 2)), {} diff --git a/tasks/optimize-ea-tammes-n50/tests/instance.json b/tasks/optimize-ea-tammes-n50/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..77d816d74186bc7a08b2d1f2e06dff87a2de249c --- /dev/null +++ b/tasks/optimize-ea-tammes-n50/tests/instance.json @@ -0,0 +1 @@ +{"n": 50, "direction": "maximize", "best_known": 0.5134721, "baseline": 0.12558103905862603, "family": "ea_tammes", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ea-tammes-n50/tests/run.py b/tasks/optimize-ea-tammes-n50/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ea-tammes-n50/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/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-tammes-n50/tests/test.sh b/tasks/optimize-ea-tammes-n50/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ea-tammes-n50/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/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-finch-3ap-diffs-n40/environment/Dockerfile b/tasks/optimize-finch-3ap-diffs-n40/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-finch-3ap-diffs-n40/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==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-finch-3ap-diffs-n40/environment/instance.json b/tasks/optimize-finch-3ap-diffs-n40/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e96633e2427ff37d33dde908c2ccf064a168591d --- /dev/null +++ b/tasks/optimize-finch-3ap-diffs-n40/environment/instance.json @@ -0,0 +1 @@ +{"n": 40, "M": 400, "direction": "maximize", "family": "finch_3ap_diffs_40", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-finch-3ap-diffs-n40/solution/solve.sh b/tasks/optimize-finch-3ap-diffs-n40/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6094210c72313c0f91c70c17ee1caa814ac7bf5a --- /dev/null +++ b/tasks/optimize-finch-3ap-diffs-n40/solution/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, 6, 14, 30, 56, 60, 106, 110, 114, 120, 126, 128, 153, 155, 162, 166, 174, 180, 186, 190, 193, 195, 196, 198, 200, 204, 206, 210, 218, 225, 226, 227, 250, 254, 276, 280, 292, 330, 342, 394]} +RLMATH_EOF diff --git a/tasks/optimize-finch-3ap-diffs-n40/tests/check.py b/tasks/optimize-finch-3ap-diffs-n40/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ac30a01a909fcbd25818ff1325c71ecc5d13f84c --- /dev/null +++ b/tasks/optimize-finch-3ap-diffs-n40/tests/check.py @@ -0,0 +1,14 @@ +"""Erdos #1097: number of distinct common differences of 3-term APs in a 40-element set A of [0, 400) +(Finch/EFT skydiscover erdos_1097_3ap_diffs_n40, Apache-2.0). Exact integer count, as upstream. Change: +entries must be JSON integers (upstream cast with int()).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, M = inst["n"], inst["M"] + A = int_list(ans.get("A"), n, 0, M - 1, "A") + if len(set(A)) != n: + raise Invalid("elements must be distinct") + S, L = set(A), sorted(A) + ds = {L[j] - L[i] for i in range(n) for j in range(i + 1, n) if 2 * L[j] - L[i] in S} + return float(len(ds)), {} diff --git a/tasks/optimize-finch-3ap-diffs-n40/tests/instance.json b/tasks/optimize-finch-3ap-diffs-n40/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2d644da36f35f50b65e067b9d45bab7d994c50de --- /dev/null +++ b/tasks/optimize-finch-3ap-diffs-n40/tests/instance.json @@ -0,0 +1 @@ +{"n": 40, "M": 400, "direction": "maximize", "best_known": 109.0, "baseline": 19.0, "family": "finch_3ap_diffs_40", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-finch-3ap-diffs-n40/tests/run.py b/tasks/optimize-finch-3ap-diffs-n40/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-finch-3ap-diffs-n40/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/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-finch-3ap-diffs-n40/tests/test.sh b/tasks/optimize-finch-3ap-diffs-n40/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-finch-3ap-diffs-n40/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt