diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s6/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s6/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cf04d836d6fb8d76f5d936011aa76491a0a44264 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"N": 120, "t": 35, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s6/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2a8f0e7a40bd84566084d72fba5282f183defd09 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"factors": [245, 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, 36, 36, 36, 36, 37, 37, 37, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 39, 39, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 41, 41, 43, 43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 46, 46, 46, 46, 46, 47, 47, 49, 51, 51, 51, 51, 51, 51, 51, 53, 53, 58, 58, 58, 58, 59, 59, 61, 62, 62, 62, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s6/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s6/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s6/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cf04d836d6fb8d76f5d936011aa76491a0a44264 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"N": 120, "t": 35, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s6/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p38-factorial-factors-l2-s6/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l2-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s8/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s8/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cc4910e584ad80196338b72722ab44b7f0925bbc --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"N": 8823, "t": 2881, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s8/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a96c38bd43b34a25a7da2896556b07c62c16a947 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [69144, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2881, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2882, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2883, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2884, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2886, 2887, 2887, 2887, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2888, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2889, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2890, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2891, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2892, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2893, 2894, 2894, 2894, 2894, 2894, 2894, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2895, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2896, 2897, 2897, 2897, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2898, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2899, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2900, 2901, 2901, 2901, 2901, 2901, 2901, 2901, 2901, 2901, 2902, 2902, 2902, 2902, 2902, 2902, 2903, 2903, 2903, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2904, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2905, 2906, 2906, 2906, 2906, 2906, 2906, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2909, 2909, 2909, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2910, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2911, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2912, 2913, 2913, 2913, 2913, 2913, 2913, 2913, 2913, 2913, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2914, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2915, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2916, 2917, 2917, 2917, 2918, 2918, 2918, 2918, 2918, 2918, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2919, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2920, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2921, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2922, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2923, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2924, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2925, 2926, 2926, 2927, 2927, 2927, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2928, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2929, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2930, 2931, 2931, 2931, 2931, 2931, 2931, 2931, 2931, 2931, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2933, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2934, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2936, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2937, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2938, 2939, 2939, 2939, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2940, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2942, 2942, 2942, 2942, 2942, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2943, 2944, 2944, 2944, 2944, 2944, 2944, 2944, 2944, 2944, 2944, 2944, 2944, 2944, 2944, 2944, 2945, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2946, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2947, 2949, 2949, 2949, 2949, 2949, 2949, 2949, 2949, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2951, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2952, 2953, 2953, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2954, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2955, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2957, 2957, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2959, 2961, 2962, 2962, 2962, 2962, 2962, 2963, 2963, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2966, 2966, 2966, 2966, 2966, 2967, 2969, 2969, 2971, 2971, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2973, 2973, 2973, 2973, 2973, 2973, 2973, 2973, 2974, 2974, 2974, 2974, 2974, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2977, 2978, 2978, 2978, 2978, 2978, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2979, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2981, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2983, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2984, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2985, 2986, 2986, 2986, 2986, 2986, 2989, 2989, 2991, 2991, 2991, 2991, 2991, 2991, 2991, 2991, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2994, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2997, 2997, 2998, 2998, 2998, 2998, 2998, 2999, 2999, 3001, 3001, 3002, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3006, 3011, 3011, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3012, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3014, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3017, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3018, 3019, 3019, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3020, 3022, 3022, 3022, 3022, 3022, 3023, 3023, 3027, 3027, 3027, 3027, 3027, 3027, 3027, 3027, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3029, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3031, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3032, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3033, 3034, 3034, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3035, 3037, 3037, 3039, 3039, 3039, 3039, 3039, 3039, 3039, 3039, 3041, 3041, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3043, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3046, 3046, 3046, 3046, 3046, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3047, 3049, 3049, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3054, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3056, 3057, 3057, 3057, 3057, 3057, 3057, 3057, 3057, 3061, 3061, 3062, 3062, 3062, 3062, 3062, 3063, 3063, 3063, 3063, 3063, 3063, 3063, 3063, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3064, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3065, 3067, 3067, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3070, 3072, 3072, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3073, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3079, 3079, 3083, 3083, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3084, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3085, 3086, 3086, 3086, 3086, 3086, 3089, 3089, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3091, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3093, 3093, 3093, 3093, 3093, 3093, 3093, 3093, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3095, 3098, 3098, 3098, 3098, 3098, 3099, 3099, 3099, 3099, 3099, 3099, 3099, 3099, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3101, 3106, 3106, 3106, 3106, 3106, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3107, 3109, 3109, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3110, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3112, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3113, 3117, 3117, 3117, 3117, 3117, 3117, 3117, 3117, 3118, 3118, 3118, 3118, 3118, 3119, 3119, 3121, 3121, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3134, 3134, 3134, 3134, 3134, 3137, 3137, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3142, 3142, 3142, 3142, 3142, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3147, 3147, 3147, 3147, 3147, 3147, 3147, 3147, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3153, 3153, 3153, 3153, 3153, 3153, 3153, 3153, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3158, 3158, 3158, 3158, 3158, 3163, 3163, 3166, 3166, 3166, 3166, 3166, 3167, 3167, 3169, 3169, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3181, 3181, 3183, 3183, 3183, 3183, 3183, 3183, 3183, 3183, 3187, 3187, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3189, 3189, 3189, 3189, 3189, 3189, 3189, 3189, 3191, 3191, 3194, 3194, 3194, 3194, 3194, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3202, 3202, 3202, 3202, 3202, 3203, 3203, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3207, 3207, 3207, 3207, 3207, 3207, 3207, 3207, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3209, 3209, 3214, 3214, 3214, 3214, 3214, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3217, 3217, 3218, 3218, 3218, 3218, 3218, 3221, 3221, 3226, 3226, 3226, 3226, 3226, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3229, 3229, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3238, 3238, 3238, 3238, 3238, 3239, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3242, 3242, 3242, 3242, 3242, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3247, 3251, 3251, 3253, 3253, 3254, 3254, 3254, 3254, 3254, 3257, 3257, 3259, 3259, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3271, 3271, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3273, 3273, 3273, 3273, 3273, 3273, 3273, 3273, 3274, 3274, 3274, 3274, 3274, 3279, 3279, 3279, 3279, 3279, 3279, 3279, 3279, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3284, 3284, 3284, 3284, 3284, 3284, 3284, 3284, 3284, 3284, 3287, 3291, 3291, 3291, 3291, 3291, 3291, 3291, 3291, 3292, 3292, 3292, 3292, 3292, 3292, 3292, 3292, 3292, 3292, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3299, 3299, 3301, 3301, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3307, 3307, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3309, 3309, 3309, 3309, 3309, 3309, 3309, 3313, 3313, 3314, 3314, 3314, 3314, 3314, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3317, 3319, 3319, 3323, 3323, 3326, 3326, 3326, 3326, 3326, 3327, 3327, 3327, 3327, 3327, 3327, 3327, 3329, 3329, 3331, 3331, 3334, 3334, 3334, 3334, 3334, 3338, 3338, 3338, 3338, 3338, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3343, 3343, 3347, 3347, 3351, 3351, 3351, 3351, 3351, 3351, 3351, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3356, 3356, 3356, 3356, 3356, 3356, 3356, 3356, 3356, 3356, 3359, 3359, 3361, 3361, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3369, 3369, 3369, 3369, 3369, 3369, 3369, 3371, 3371, 3373, 3373, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3386, 3386, 3386, 3386, 3386, 3387, 3387, 3387, 3387, 3387, 3387, 3387, 3389, 3389, 3391, 3391, 3394, 3394, 3394, 3394, 3394, 3398, 3398, 3398, 3398, 3398, 3407, 3407, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3413, 3413, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3418, 3418, 3418, 3418, 3418, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3433, 3433, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3442, 3442, 3442, 3442, 3442, 3446, 3446, 3446, 3446, 3446, 3449, 3449, 3452, 3452, 3452, 3452, 3452, 3452, 3452, 3452, 3452, 3452, 3453, 3453, 3453, 3453, 3453, 3453, 3453, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3457, 3457, 3459, 3459, 3459, 3459, 3459, 3459, 3459, 3461, 3461, 3463, 3463, 3466, 3466, 3466, 3466, 3466, 3467, 3467, 3469, 3469, 3482, 3482, 3482, 3482, 3482, 3489, 3489, 3489, 3489, 3489, 3489, 3489, 3491, 3491, 3494, 3494, 3494, 3494, 3494, 3499, 3499, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3506, 3506, 3506, 3506, 3506, 3508, 3508, 3508, 3508, 3508, 3508, 3508, 3508, 3508, 3508, 3511, 3511, 3513, 3513, 3513, 3513, 3513, 3513, 3513, 3517, 3517, 3518, 3518, 3518, 3518, 3518, 3524, 3524, 3524, 3524, 3524, 3524, 3524, 3524, 3524, 3524, 3527, 3527, 3529, 3529, 3532, 3532, 3532, 3532, 3532, 3532, 3532, 3532, 3532, 3533, 3533, 3539, 3539, 3541, 3541, 3543, 3543, 3543, 3543, 3543, 3543, 3543, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3547, 3547, 3548, 3548, 3548, 3548, 3548, 3548, 3548, 3548, 3548, 3554, 3554, 3554, 3554, 3557, 3557, 3559, 3559, 3561, 3561, 3561, 3561, 3561, 3561, 3561, 3566, 3566, 3566, 3566, 3571, 3571, 3574, 3574, 3574, 3574, 3578, 3578, 3578, 3578, 3579, 3579, 3579, 3579, 3579, 3579, 3579, 3581, 3581, 3583, 3583, 3593, 3593, 3595, 3595, 3595, 3595, 3595, 3595, 3595, 3595, 3595, 3595, 3595, 3595, 3602, 3602, 3602, 3602, 3603, 3603, 3603, 3603, 3603, 3603, 3603, 3607, 3607, 3613, 3613, 3617, 3617, 3622, 3622, 3622, 3622, 3623, 3623, 3628, 3628, 3628, 3628, 3628, 3628, 3628, 3628, 3628, 3631, 3631, 3637, 3637, 3639, 3639, 3639, 3639, 3639, 3639, 3639, 3643, 3643, 3644, 3644, 3644, 3644, 3644, 3644, 3644, 3644, 3644, 3646, 3646, 3646, 3646, 3651, 3651, 3651, 3651, 3651, 3651, 3651, 3659, 3659, 3662, 3662, 3662, 3662, 3669, 3669, 3669, 3669, 3669, 3669, 3669, 3671, 3671, 3673, 3673, 3676, 3676, 3676, 3676, 3676, 3676, 3676, 3676, 3676, 3677, 3677, 3687, 3687, 3687, 3687, 3687, 3687, 3687, 3691, 3691, 3693, 3693, 3693, 3693, 3693, 3693, 3693, 3694, 3694, 3694, 3694, 3697, 3697, 3701, 3701, 3709, 3709, 3711, 3711, 3711, 3711, 3711, 3711, 3711, 3716, 3716, 3716, 3716, 3716, 3716, 3716, 3716, 3716, 3719, 3719, 3722, 3722, 3722, 3722, 3727, 3727, 3733, 3733, 3734, 3734, 3734, 3734, 3739, 3739, 3742, 3742, 3742, 3742, 3746, 3746, 3746, 3746, 3747, 3747, 3747, 3747, 3747, 3747, 3747, 3748, 3748, 3748, 3748, 3748, 3748, 3748, 3748, 3748, 3754, 3754, 3754, 3754, 3758, 3758, 3758, 3758, 3761, 3761, 3764, 3764, 3764, 3764, 3764, 3764, 3764, 3764, 3764, 3767, 3767, 3769, 3769, 3777, 3777, 3777, 3777, 3777, 3777, 3777, 3778, 3778, 3778, 3778, 3779, 3779, 3788, 3788, 3788, 3788, 3788, 3788, 3788, 3788, 3788, 3793, 3793, 3797, 3797, 3802, 3802, 3802, 3802, 3803, 3803, 3812, 3812, 3812, 3812, 3812, 3812, 3812, 3812, 3812, 3814, 3814, 3814, 3814, 3821, 3821, 3823, 3823, 3826, 3826, 3826, 3826, 3831, 3831, 3831, 3831, 3831, 3831, 3833, 3833, 3837, 3837, 3837, 3837, 3837, 3837, 3847, 3847, 3849, 3849, 3849, 3849, 3849, 3849, 3851, 3851, 3853, 3853, 3862, 3862, 3862, 3862, 3863, 3863, 3866, 3866, 3866, 3866, 3867, 3867, 3867, 3867, 3867, 3867, 3873, 3873, 3873, 3873, 3873, 3873, 3877, 3877, 3881, 3881, 3889, 3889, 3891, 3891, 3891, 3891, 3891, 3891, 3898, 3898, 3898, 3898, 3902, 3902, 3902, 3902, 3903, 3903, 3903, 3903, 3903, 3903, 3907, 3907, 3909, 3909, 3909, 3909, 3909, 3909, 3911, 3911, 3917, 3917, 3919, 3919, 3921, 3921, 3921, 3921, 3921, 3921, 3923, 3923, 3929, 3929, 3931, 3931, 3943, 3943, 3946, 3946, 3946, 3946, 3947, 3947, 3957, 3957, 3957, 3957, 3957, 3957, 3958, 3958, 3958, 3958, 3963, 3963, 3963, 3963, 3963, 3963, 3967, 3967, 3974, 3974, 3974, 3974, 3981, 3981, 3981, 3981, 3981, 3981, 3986, 3986, 3986, 3986, 3989, 3989, 3994, 3994, 3994, 3994, 3998, 3998, 3998, 3998, 4001, 4001, 4003, 4003, 4006, 4006, 4006, 4006, 4007, 4007, 4013, 4013, 4019, 4019, 4021, 4021, 4022, 4022, 4022, 4022, 4027, 4027, 4034, 4034, 4034, 4034, 4049, 4049, 4051, 4051, 4054, 4054, 4054, 4054, 4057, 4057, 4058, 4058, 4058, 4058, 4073, 4073, 4078, 4078, 4078, 4078, 4079, 4079, 4083, 4083, 4083, 4083, 4083, 4083, 4091, 4091, 4093, 4093, 4099, 4099, 4101, 4101, 4101, 4101, 4101, 4101, 4106, 4106, 4106, 4106, 4111, 4111, 4119, 4119, 4119, 4119, 4119, 4119, 4126, 4126, 4126, 4126, 4127, 4127, 4129, 4129, 4133, 4133, 4138, 4138, 4138, 4138, 4139, 4139, 4143, 4143, 4143, 4143, 4143, 4143, 4153, 4153, 4157, 4157, 4159, 4159, 4162, 4162, 4162, 4162, 4166, 4166, 4166, 4166, 4174, 4174, 4174, 4174, 4177, 4177, 4178, 4178, 4178, 4178, 4197, 4197, 4197, 4197, 4197, 4197, 4198, 4198, 4198, 4198, 4201, 4201, 4211, 4211, 4217, 4217, 4219, 4219, 4222, 4222, 4222, 4222, 4226, 4226, 4226, 4226, 4227, 4227, 4227, 4227, 4227, 4227, 4229, 4229, 4231, 4231, 4241, 4241, 4243, 4243, 4253, 4253, 4258, 4258, 4258, 4258, 4259, 4259, 4261, 4261, 4262, 4262, 4262, 4262, 4269, 4269, 4269, 4269, 4269, 4269, 4271, 4271, 4273, 4273, 4274, 4274, 4274, 4274, 4281, 4281, 4281, 4281, 4281, 4281, 4282, 4282, 4282, 4282, 4283, 4283, 4286, 4286, 4286, 4286, 4287, 4287, 4287, 4287, 4287, 4287, 4289, 4289, 4297, 4297, 4299, 4299, 4299, 4299, 4299, 4299, 4306, 4306, 4306, 4306, 4317, 4317, 4317, 4317, 4317, 4317, 4322, 4322, 4322, 4322, 4327, 4327, 4337, 4337, 4339, 4339, 4349, 4349, 4357, 4357, 4358, 4358, 4358, 4358, 4363, 4363, 4373, 4373, 4391, 4391, 4397, 4397, 4406, 4406, 4406, 4406, 4409, 4409, 4414, 4414, 4414, 4421, 4423, 4426, 4426, 4426, 4441, 4442, 4442, 4442, 4447, 4451, 4457, 4463, 4474, 4474, 4474, 4478, 4478, 4478, 4481, 4483, 4486, 4486, 4486, 4493, 4502, 4502, 4502, 4507, 4513, 4517, 4519, 4523, 4534, 4534, 4534, 4538, 4538, 4538, 4546, 4546, 4546, 4547, 4549, 4561, 4562, 4562, 4562, 4567, 4574, 4574, 4574, 4583, 4586, 4586, 4586, 4591, 4594, 4594, 4594, 4597, 4603, 4618, 4618, 4618, 4621, 4622, 4622, 4622, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4666, 4666, 4666, 4673, 4678, 4678, 4678, 4679, 4682, 4682, 4682, 4691, 4694, 4694, 4694, 4702, 4702, 4702, 4703, 4714, 4714, 4714, 4721, 4723, 4729, 4733, 4742, 4742, 4742, 4751, 4754, 4754, 4754, 4759, 4762, 4762, 4762, 4766, 4766, 4766, 4778, 4778, 4778, 4783, 4786, 4786, 4786, 4787, 4789, 4793, 4798, 4798, 4798, 4799, 4801, 4813, 4817, 4822, 4822, 4822, 4831, 4834, 4834, 4834, 4846, 4846, 4846, 4861, 4871, 4874, 4874, 4874, 4877, 4882, 4882, 4882, 4889, 4894, 4894, 4894, 4903, 4909, 4918, 4918, 4918, 4919, 4931, 4933, 4934, 4934, 4934, 4937, 4943, 4946, 4946, 4946, 4951, 4954, 4954, 4954, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5006, 5006, 5006, 5009, 5011, 5021, 5023, 5039, 5042, 5042, 5042, 5051, 5059, 5062, 5062, 5062, 5077, 5078, 5078, 5078, 5081, 5086, 5086, 5086, 5087, 5098, 5098, 5098, 5099, 5101, 5102, 5102, 5102, 5107, 5113, 5114, 5114, 5114, 5119, 5147, 5153, 5158, 5158, 5158, 5167, 5171, 5179, 5182, 5182, 5182, 5186, 5186, 5186, 5189, 5197, 5209, 5218, 5218, 5218, 5227, 5231, 5233, 5234, 5234, 5234, 5237, 5242, 5242, 5242, 5261, 5266, 5266, 5266, 5273, 5279, 5281, 5294, 5294, 5294, 5297, 5303, 5309, 5314, 5314, 5314, 5318, 5318, 5318, 5323, 5326, 5326, 5326, 5333, 5342, 5342, 5342, 5347, 5351, 5354, 5354, 5354, 5366, 5366, 5366, 5374, 5374, 5374, 5378, 5378, 5378, 5381, 5386, 5386, 5386, 5387, 5393, 5398, 5398, 5398, 5399, 5407, 5413, 5414, 5414, 5414, 5417, 5419, 5422, 5422, 5422, 5426, 5426, 5426, 5431, 5437, 5438, 5438, 5438, 5441, 5443, 5449, 5458, 5458, 5458, 5462, 5462, 5462, 5471, 5477, 5479, 5482, 5482, 5482, 5483, 5498, 5498, 5498, 5501, 5503, 5506, 5506, 5506, 5507, 5519, 5521, 5527, 5531, 5534, 5534, 5534, 5554, 5554, 5554, 5557, 5563, 5569, 5573, 5578, 5578, 5578, 5581, 5582, 5582, 5582, 5591, 5594, 5594, 5594, 5602, 5602, 5602, 5606, 5606, 5606, 5623, 5638, 5638, 5638, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5666, 5666, 5666, 5669, 5674, 5674, 5674, 5683, 5686, 5686, 5686, 5689, 5693, 5701, 5702, 5702, 5702, 5711, 5714, 5714, 5714, 5717, 5722, 5722, 5722, 5737, 5741, 5743, 5749, 5758, 5758, 5758, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s8/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s8/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s8/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cc4910e584ad80196338b72722ab44b7f0925bbc --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"N": 8823, "t": 2881, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s8/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s8/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s9/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s9/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dfa0a626f771f4ab1622987d8a2f8ddef969997c --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"N": 9545, "t": 3118, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s9/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f93ada1f985f59406e1869b38c1b8be77851975f --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"factors": [18708, 3118, 3118, 3118, 3118, 3118, 3119, 3119, 3119, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3120, 3121, 3121, 3121, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3122, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3123, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3124, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3125, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3126, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3127, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3128, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3129, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3130, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3131, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3132, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3133, 3134, 3134, 3134, 3134, 3134, 3134, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3135, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3136, 3137, 3137, 3137, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3138, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3139, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3140, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3141, 3142, 3142, 3142, 3142, 3142, 3142, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3143, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3144, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3145, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3146, 3147, 3147, 3147, 3147, 3147, 3147, 3147, 3147, 3147, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3149, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3151, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3152, 3153, 3153, 3153, 3153, 3153, 3153, 3153, 3153, 3153, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3154, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3155, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3156, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3157, 3158, 3158, 3158, 3158, 3158, 3158, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3159, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3160, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3161, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3162, 3163, 3163, 3163, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3164, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3165, 3166, 3166, 3166, 3166, 3166, 3166, 3167, 3167, 3167, 3169, 3169, 3169, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3170, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3172, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3173, 3174, 3174, 3174, 3174, 3174, 3174, 3174, 3174, 3174, 3174, 3174, 3174, 3174, 3174, 3174, 3174, 3174, 3174, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3175, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3176, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3177, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3178, 3179, 3179, 3181, 3181, 3181, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3182, 3183, 3183, 3183, 3183, 3183, 3183, 3183, 3183, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3184, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3185, 3187, 3187, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3189, 3189, 3189, 3189, 3189, 3189, 3189, 3189, 3191, 3191, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3193, 3194, 3194, 3194, 3194, 3194, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3197, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3199, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3201, 3202, 3202, 3202, 3202, 3202, 3203, 3203, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3204, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3205, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3206, 3207, 3207, 3207, 3207, 3207, 3207, 3207, 3207, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3208, 3209, 3209, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3210, 3211, 3214, 3214, 3214, 3214, 3214, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3215, 3217, 3217, 3218, 3218, 3218, 3218, 3218, 3221, 3221, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3222, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3223, 3226, 3226, 3226, 3226, 3226, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3227, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3228, 3229, 3229, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3231, 3233, 3233, 3233, 3233, 3233, 3233, 3233, 3233, 3233, 3233, 3233, 3233, 3233, 3233, 3233, 3233, 3233, 3233, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3235, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3236, 3238, 3238, 3238, 3238, 3238, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3241, 3242, 3242, 3242, 3242, 3242, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3243, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3244, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3246, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3247, 3251, 3251, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3252, 3253, 3253, 3254, 3254, 3254, 3254, 3254, 3257, 3257, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3258, 3259, 3259, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3260, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3261, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3262, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3263, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3265, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3269, 3271, 3271, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3272, 3273, 3273, 3273, 3273, 3273, 3273, 3273, 3273, 3274, 3274, 3274, 3274, 3274, 3279, 3279, 3279, 3279, 3279, 3279, 3279, 3279, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3281, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3282, 3284, 3284, 3284, 3284, 3284, 3284, 3284, 3284, 3284, 3284, 3284, 3286, 3286, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3287, 3291, 3291, 3291, 3291, 3291, 3291, 3291, 3291, 3292, 3292, 3292, 3292, 3292, 3292, 3292, 3292, 3292, 3292, 3292, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3295, 3299, 3299, 3301, 3301, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3303, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3305, 3307, 3307, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3308, 3309, 3309, 3309, 3309, 3309, 3309, 3309, 3309, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3310, 3313, 3313, 3314, 3314, 3314, 3314, 3314, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3316, 3319, 3319, 3323, 3323, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3324, 3326, 3326, 3326, 3326, 3326, 3327, 3327, 3327, 3327, 3327, 3327, 3327, 3327, 3329, 3329, 3331, 3331, 3334, 3334, 3334, 3334, 3334, 3338, 3338, 3338, 3338, 3338, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3341, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3342, 3343, 3343, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3346, 3347, 3347, 3351, 3351, 3351, 3351, 3351, 3351, 3351, 3351, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3352, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3353, 3356, 3356, 3356, 3356, 3356, 3356, 3356, 3356, 3356, 3356, 3356, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3357, 3359, 3359, 3361, 3361, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3365, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3368, 3369, 3369, 3369, 3369, 3369, 3369, 3369, 3369, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3370, 3371, 3371, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3372, 3373, 3373, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3377, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3378, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3385, 3386, 3386, 3386, 3386, 3386, 3387, 3387, 3387, 3387, 3387, 3387, 3387, 3387, 3389, 3389, 3391, 3391, 3394, 3394, 3394, 3394, 3394, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3396, 3398, 3398, 3398, 3398, 3398, 3407, 3407, 3409, 3409, 3409, 3409, 3409, 3409, 3409, 3409, 3409, 3409, 3409, 3409, 3409, 3409, 3409, 3409, 3409, 3409, 3409, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3411, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3412, 3413, 3413, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3415, 3418, 3418, 3418, 3418, 3418, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3421, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3426, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3428, 3429, 3433, 3433, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3436, 3437, 3437, 3437, 3437, 3437, 3437, 3437, 3437, 3437, 3437, 3437, 3437, 3437, 3437, 3437, 3437, 3437, 3437, 3437, 3442, 3442, 3442, 3442, 3442, 3446, 3446, 3446, 3446, 3446, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3447, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3448, 3449, 3449, 3452, 3452, 3452, 3452, 3452, 3452, 3452, 3452, 3452, 3452, 3452, 3453, 3453, 3453, 3453, 3453, 3453, 3453, 3453, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3455, 3457, 3457, 3459, 3459, 3459, 3459, 3459, 3459, 3459, 3459, 3461, 3461, 3462, 3462, 3462, 3462, 3462, 3462, 3462, 3462, 3462, 3462, 3462, 3462, 3462, 3462, 3462, 3462, 3463, 3463, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3464, 3466, 3466, 3466, 3466, 3466, 3467, 3467, 3469, 3469, 3482, 3482, 3482, 3482, 3482, 3489, 3489, 3489, 3489, 3489, 3489, 3489, 3489, 3491, 3491, 3493, 3493, 3493, 3493, 3493, 3493, 3493, 3493, 3493, 3493, 3493, 3493, 3493, 3493, 3493, 3493, 3493, 3493, 3493, 3494, 3494, 3494, 3494, 3494, 3499, 3499, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3501, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3505, 3506, 3506, 3506, 3506, 3506, 3508, 3508, 3508, 3508, 3508, 3508, 3508, 3508, 3508, 3508, 3511, 3511, 3512, 3512, 3512, 3512, 3512, 3512, 3512, 3512, 3512, 3512, 3512, 3512, 3512, 3512, 3512, 3512, 3512, 3512, 3512, 3512, 3512, 3513, 3513, 3513, 3513, 3513, 3513, 3513, 3513, 3517, 3517, 3518, 3518, 3518, 3518, 3518, 3521, 3521, 3521, 3521, 3521, 3521, 3521, 3521, 3521, 3521, 3521, 3521, 3521, 3521, 3521, 3521, 3521, 3521, 3522, 3522, 3522, 3522, 3522, 3522, 3522, 3522, 3522, 3522, 3522, 3522, 3522, 3522, 3522, 3522, 3524, 3524, 3524, 3524, 3524, 3524, 3524, 3524, 3524, 3524, 3527, 3527, 3529, 3529, 3532, 3532, 3532, 3532, 3532, 3532, 3532, 3532, 3532, 3532, 3533, 3533, 3539, 3539, 3541, 3541, 3543, 3543, 3543, 3543, 3543, 3543, 3543, 3543, 3544, 3544, 3544, 3544, 3544, 3544, 3544, 3544, 3544, 3544, 3544, 3544, 3544, 3544, 3544, 3544, 3544, 3544, 3544, 3544, 3544, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3545, 3547, 3547, 3548, 3548, 3548, 3548, 3548, 3548, 3548, 3548, 3548, 3548, 3554, 3554, 3554, 3554, 3554, 3557, 3557, 3558, 3558, 3558, 3558, 3558, 3558, 3558, 3558, 3558, 3558, 3558, 3558, 3558, 3558, 3558, 3558, 3559, 3559, 3561, 3561, 3561, 3561, 3561, 3561, 3561, 3561, 3563, 3563, 3563, 3563, 3563, 3563, 3563, 3563, 3563, 3563, 3563, 3563, 3563, 3563, 3563, 3563, 3563, 3563, 3566, 3566, 3566, 3566, 3566, 3571, 3571, 3574, 3574, 3574, 3574, 3574, 3578, 3578, 3578, 3578, 3578, 3579, 3579, 3579, 3579, 3579, 3579, 3579, 3579, 3581, 3581, 3583, 3583, 3593, 3593, 3594, 3594, 3594, 3594, 3594, 3594, 3594, 3594, 3594, 3594, 3594, 3594, 3594, 3594, 3594, 3595, 3595, 3595, 3595, 3595, 3595, 3595, 3595, 3595, 3595, 3595, 3595, 3595, 3602, 3602, 3602, 3602, 3602, 3603, 3603, 3603, 3603, 3603, 3603, 3603, 3606, 3606, 3606, 3606, 3606, 3606, 3606, 3606, 3606, 3606, 3606, 3606, 3606, 3606, 3606, 3607, 3607, 3613, 3613, 3617, 3617, 3622, 3622, 3622, 3622, 3622, 3623, 3623, 3628, 3628, 3628, 3628, 3628, 3628, 3628, 3628, 3628, 3628, 3631, 3631, 3635, 3635, 3635, 3635, 3635, 3635, 3635, 3635, 3635, 3635, 3635, 3635, 3635, 3637, 3637, 3639, 3639, 3639, 3639, 3639, 3639, 3639, 3642, 3642, 3642, 3642, 3642, 3642, 3642, 3642, 3642, 3642, 3642, 3642, 3642, 3642, 3642, 3643, 3643, 3644, 3644, 3644, 3644, 3644, 3644, 3644, 3644, 3644, 3644, 3646, 3646, 3646, 3646, 3646, 3651, 3651, 3651, 3651, 3651, 3651, 3651, 3659, 3659, 3662, 3662, 3662, 3662, 3662, 3665, 3665, 3665, 3665, 3665, 3665, 3665, 3665, 3665, 3665, 3665, 3665, 3665, 3669, 3669, 3669, 3669, 3669, 3669, 3669, 3671, 3671, 3673, 3673, 3676, 3676, 3676, 3676, 3676, 3676, 3676, 3676, 3676, 3676, 3677, 3677, 3678, 3678, 3678, 3678, 3678, 3678, 3678, 3678, 3678, 3678, 3678, 3678, 3678, 3678, 3678, 3687, 3687, 3687, 3687, 3687, 3687, 3687, 3691, 3691, 3693, 3693, 3693, 3693, 3693, 3693, 3693, 3694, 3694, 3694, 3694, 3694, 3695, 3695, 3695, 3695, 3695, 3695, 3695, 3695, 3695, 3695, 3695, 3695, 3697, 3697, 3701, 3701, 3702, 3702, 3702, 3702, 3702, 3702, 3702, 3702, 3702, 3702, 3702, 3702, 3702, 3702, 3702, 3709, 3709, 3711, 3711, 3711, 3711, 3711, 3711, 3711, 3714, 3714, 3714, 3714, 3714, 3714, 3714, 3714, 3714, 3714, 3714, 3714, 3714, 3714, 3714, 3715, 3715, 3715, 3715, 3715, 3715, 3715, 3715, 3715, 3715, 3715, 3715, 3716, 3716, 3716, 3716, 3716, 3716, 3716, 3716, 3716, 3716, 3719, 3719, 3722, 3722, 3722, 3722, 3722, 3727, 3727, 3733, 3733, 3734, 3734, 3734, 3734, 3734, 3739, 3739, 3742, 3742, 3742, 3742, 3742, 3746, 3746, 3746, 3746, 3746, 3747, 3747, 3747, 3747, 3747, 3747, 3747, 3748, 3748, 3748, 3748, 3748, 3748, 3748, 3748, 3748, 3748, 3754, 3754, 3754, 3754, 3754, 3755, 3755, 3755, 3755, 3755, 3755, 3755, 3755, 3755, 3755, 3755, 3755, 3758, 3758, 3758, 3758, 3758, 3761, 3761, 3764, 3764, 3764, 3764, 3764, 3764, 3764, 3764, 3764, 3764, 3767, 3767, 3769, 3769, 3777, 3777, 3777, 3777, 3777, 3777, 3777, 3778, 3778, 3778, 3778, 3778, 3779, 3779, 3785, 3785, 3785, 3785, 3785, 3785, 3785, 3785, 3785, 3785, 3785, 3785, 3788, 3788, 3788, 3788, 3788, 3788, 3788, 3788, 3788, 3788, 3793, 3793, 3797, 3797, 3802, 3802, 3802, 3802, 3802, 3803, 3803, 3805, 3805, 3805, 3805, 3805, 3805, 3805, 3805, 3805, 3805, 3805, 3805, 3812, 3812, 3812, 3812, 3812, 3812, 3812, 3812, 3812, 3812, 3814, 3814, 3814, 3814, 3814, 3821, 3821, 3823, 3823, 3826, 3826, 3826, 3826, 3831, 3831, 3831, 3831, 3831, 3831, 3831, 3833, 3833, 3837, 3837, 3837, 3837, 3837, 3837, 3837, 3845, 3845, 3845, 3845, 3845, 3845, 3845, 3845, 3845, 3845, 3845, 3845, 3847, 3847, 3849, 3849, 3849, 3849, 3849, 3849, 3849, 3851, 3851, 3853, 3853, 3862, 3862, 3862, 3862, 3863, 3863, 3865, 3865, 3865, 3865, 3865, 3865, 3865, 3865, 3865, 3865, 3865, 3865, 3866, 3866, 3866, 3866, 3867, 3867, 3867, 3867, 3867, 3867, 3867, 3868, 3868, 3868, 3868, 3868, 3868, 3868, 3868, 3868, 3873, 3873, 3873, 3873, 3873, 3873, 3873, 3877, 3877, 3881, 3881, 3884, 3884, 3884, 3884, 3884, 3884, 3884, 3884, 3884, 3889, 3889, 3891, 3891, 3891, 3891, 3891, 3891, 3891, 3898, 3898, 3898, 3898, 3902, 3902, 3902, 3902, 3903, 3903, 3903, 3903, 3903, 3903, 3903, 3907, 3907, 3908, 3908, 3908, 3908, 3908, 3908, 3908, 3908, 3908, 3909, 3909, 3909, 3909, 3909, 3909, 3909, 3911, 3911, 3917, 3917, 3919, 3919, 3921, 3921, 3921, 3921, 3921, 3921, 3921, 3923, 3923, 3929, 3929, 3931, 3931, 3932, 3932, 3932, 3932, 3932, 3932, 3932, 3932, 3932, 3943, 3943, 3946, 3946, 3946, 3946, 3947, 3947, 3957, 3957, 3957, 3957, 3957, 3957, 3957, 3958, 3958, 3958, 3958, 3963, 3963, 3963, 3963, 3963, 3963, 3963, 3964, 3964, 3964, 3964, 3964, 3964, 3964, 3964, 3964, 3967, 3967, 3974, 3974, 3974, 3974, 3981, 3981, 3981, 3981, 3981, 3981, 3981, 3986, 3986, 3986, 3986, 3988, 3988, 3988, 3988, 3988, 3988, 3988, 3988, 3988, 3989, 3989, 3994, 3994, 3994, 3994, 3998, 3998, 3998, 3998, 4001, 4001, 4003, 4003, 4006, 4006, 4006, 4006, 4007, 4007, 4013, 4013, 4019, 4019, 4021, 4021, 4022, 4022, 4022, 4022, 4027, 4027, 4034, 4034, 4034, 4034, 4036, 4036, 4036, 4036, 4036, 4036, 4036, 4036, 4036, 4049, 4049, 4051, 4051, 4052, 4052, 4052, 4052, 4052, 4052, 4052, 4052, 4052, 4054, 4054, 4054, 4054, 4057, 4057, 4058, 4058, 4058, 4058, 4073, 4073, 4076, 4076, 4076, 4076, 4076, 4076, 4076, 4076, 4076, 4078, 4078, 4078, 4078, 4079, 4079, 4083, 4083, 4083, 4083, 4083, 4083, 4083, 4084, 4084, 4084, 4084, 4084, 4084, 4084, 4084, 4084, 4091, 4091, 4093, 4093, 4099, 4099, 4101, 4101, 4101, 4101, 4101, 4101, 4106, 4106, 4106, 4106, 4111, 4111, 4119, 4119, 4119, 4119, 4119, 4119, 4124, 4124, 4124, 4124, 4124, 4124, 4124, 4124, 4124, 4126, 4126, 4126, 4126, 4127, 4127, 4129, 4129, 4132, 4132, 4132, 4132, 4132, 4132, 4132, 4132, 4132, 4133, 4133, 4138, 4138, 4138, 4138, 4139, 4139, 4143, 4143, 4143, 4143, 4143, 4143, 4153, 4153, 4156, 4156, 4156, 4156, 4156, 4156, 4156, 4156, 4156, 4157, 4157, 4159, 4159, 4162, 4162, 4162, 4162, 4166, 4166, 4166, 4166, 4174, 4174, 4174, 4174, 4177, 4177, 4178, 4178, 4178, 4178, 4197, 4197, 4197, 4197, 4197, 4197, 4198, 4198, 4198, 4198, 4201, 4201, 4211, 4211, 4217, 4217, 4219, 4219, 4222, 4222, 4222, 4222, 4226, 4226, 4226, 4226, 4227, 4227, 4227, 4227, 4227, 4227, 4229, 4229, 4231, 4231, 4241, 4241, 4243, 4243, 4253, 4253, 4258, 4258, 4258, 4258, 4259, 4259, 4261, 4261, 4262, 4262, 4262, 4262, 4269, 4269, 4269, 4269, 4269, 4269, 4271, 4271, 4273, 4273, 4274, 4274, 4274, 4274, 4281, 4281, 4281, 4281, 4281, 4281, 4282, 4282, 4282, 4282, 4283, 4283, 4286, 4286, 4286, 4286, 4287, 4287, 4287, 4287, 4287, 4287, 4289, 4289, 4297, 4297, 4299, 4299, 4299, 4299, 4299, 4299, 4306, 4306, 4306, 4306, 4317, 4317, 4317, 4317, 4317, 4317, 4322, 4322, 4322, 4322, 4327, 4327, 4337, 4337, 4339, 4339, 4341, 4341, 4341, 4341, 4341, 4341, 4349, 4349, 4353, 4353, 4353, 4353, 4353, 4353, 4357, 4357, 4358, 4358, 4358, 4358, 4359, 4359, 4359, 4359, 4359, 4359, 4363, 4363, 4373, 4373, 4377, 4377, 4377, 4377, 4377, 4377, 4391, 4391, 4397, 4397, 4406, 4406, 4406, 4406, 4409, 4409, 4413, 4413, 4413, 4413, 4413, 4413, 4414, 4414, 4414, 4414, 4421, 4421, 4423, 4423, 4426, 4426, 4426, 4426, 4441, 4441, 4442, 4442, 4442, 4442, 4443, 4443, 4443, 4443, 4443, 4443, 4447, 4447, 4449, 4449, 4449, 4449, 4449, 4449, 4451, 4451, 4457, 4457, 4461, 4461, 4461, 4461, 4461, 4461, 4463, 4463, 4467, 4467, 4467, 4467, 4467, 4467, 4474, 4474, 4474, 4474, 4478, 4478, 4478, 4478, 4479, 4479, 4479, 4479, 4479, 4479, 4481, 4481, 4483, 4483, 4486, 4486, 4486, 4486, 4493, 4493, 4497, 4497, 4497, 4497, 4497, 4497, 4502, 4502, 4502, 4502, 4507, 4507, 4513, 4513, 4517, 4517, 4519, 4519, 4523, 4523, 4533, 4533, 4533, 4533, 4533, 4533, 4534, 4534, 4534, 4534, 4538, 4538, 4538, 4538, 4546, 4546, 4546, 4546, 4547, 4547, 4549, 4549, 4561, 4561, 4562, 4562, 4562, 4562, 4567, 4567, 4569, 4569, 4569, 4569, 4569, 4569, 4574, 4574, 4574, 4574, 4583, 4583, 4586, 4586, 4586, 4586, 4591, 4591, 4593, 4593, 4593, 4593, 4593, 4593, 4594, 4594, 4594, 4594, 4597, 4597, 4603, 4603, 4618, 4618, 4618, 4618, 4621, 4621, 4622, 4622, 4622, 4622, 4629, 4629, 4629, 4629, 4629, 4629, 4637, 4637, 4639, 4639, 4643, 4643, 4647, 4647, 4647, 4647, 4647, 4647, 4649, 4649, 4651, 4651, 4657, 4657, 4659, 4659, 4659, 4659, 4659, 4659, 4663, 4663, 4666, 4666, 4666, 4666, 4673, 4673, 4678, 4678, 4678, 4678, 4679, 4679, 4682, 4682, 4682, 4682, 4691, 4691, 4694, 4694, 4694, 4694, 4702, 4702, 4702, 4702, 4703, 4703, 4714, 4714, 4714, 4714, 4721, 4721, 4723, 4723, 4729, 4729, 4733, 4733, 4742, 4742, 4742, 4742, 4751, 4751, 4754, 4754, 4754, 4754, 4759, 4759, 4762, 4762, 4762, 4762, 4766, 4766, 4766, 4766, 4778, 4778, 4778, 4783, 4786, 4786, 4786, 4787, 4789, 4793, 4798, 4798, 4798, 4799, 4801, 4813, 4817, 4822, 4822, 4822, 4831, 4834, 4834, 4834, 4846, 4846, 4846, 4861, 4871, 4874, 4874, 4874, 4877, 4882, 4882, 4882, 4889, 4894, 4894, 4894, 4903, 4909, 4918, 4918, 4918, 4919, 4931, 4933, 4934, 4934, 4934, 4937, 4943, 4946, 4946, 4946, 4951, 4954, 4954, 4954, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5006, 5006, 5006, 5009, 5011, 5021, 5023, 5039, 5042, 5042, 5042, 5051, 5059, 5062, 5062, 5062, 5077, 5078, 5078, 5078, 5081, 5086, 5086, 5086, 5087, 5098, 5098, 5098, 5099, 5101, 5102, 5102, 5102, 5107, 5113, 5114, 5114, 5114, 5119, 5147, 5153, 5158, 5158, 5158, 5167, 5171, 5179, 5182, 5182, 5182, 5186, 5186, 5186, 5189, 5197, 5209, 5218, 5218, 5218, 5227, 5231, 5233, 5234, 5234, 5234, 5237, 5242, 5242, 5242, 5261, 5266, 5266, 5266, 5273, 5279, 5281, 5294, 5294, 5294, 5297, 5303, 5309, 5314, 5314, 5314, 5318, 5318, 5318, 5323, 5326, 5326, 5326, 5333, 5342, 5342, 5342, 5347, 5351, 5354, 5354, 5354, 5366, 5366, 5366, 5374, 5374, 5374, 5378, 5378, 5378, 5381, 5386, 5386, 5386, 5387, 5393, 5398, 5398, 5398, 5399, 5407, 5413, 5414, 5414, 5414, 5417, 5419, 5422, 5422, 5422, 5426, 5426, 5426, 5431, 5437, 5438, 5438, 5438, 5441, 5443, 5449, 5458, 5458, 5458, 5462, 5462, 5462, 5471, 5477, 5479, 5482, 5482, 5482, 5483, 5498, 5498, 5498, 5501, 5503, 5506, 5506, 5506, 5507, 5519, 5521, 5527, 5531, 5534, 5534, 5534, 5554, 5554, 5554, 5557, 5563, 5569, 5573, 5578, 5578, 5578, 5581, 5582, 5582, 5582, 5591, 5594, 5594, 5594, 5602, 5602, 5602, 5606, 5606, 5606, 5623, 5638, 5638, 5638, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5666, 5666, 5666, 5669, 5674, 5674, 5674, 5683, 5686, 5686, 5686, 5689, 5693, 5701, 5702, 5702, 5702, 5711, 5714, 5714, 5714, 5717, 5722, 5722, 5722, 5737, 5741, 5743, 5749, 5758, 5758, 5758, 5774, 5774, 5774, 5779, 5783, 5791, 5794, 5794, 5794, 5801, 5806, 5806, 5806, 5807, 5813, 5818, 5818, 5818, 5821, 5827, 5834, 5834, 5834, 5839, 5843, 5849, 5851, 5854, 5854, 5854, 5857, 5861, 5867, 5869, 5878, 5878, 5878, 5879, 5881, 5897, 5903, 5906, 5906, 5906, 5914, 5914, 5914, 5923, 5926, 5926, 5926, 5927, 5938, 5938, 5938, 5939, 5942, 5942, 5942, 5953, 5981, 5987, 5998, 5998, 5998, 6002, 6002, 6002, 6007, 6011, 6022, 6022, 6022, 6029, 6037, 6038, 6038, 6038, 6043, 6046, 6046, 6046, 6047, 6053, 6067, 6073, 6074, 6074, 6074, 6079, 6082, 6082, 6082, 6089, 6091, 6098, 6098, 6098, 6101, 6113, 6121, 6122, 6122, 6122, 6131, 6133, 6134, 6134, 6134, 6143, 6151, 6158, 6158, 6158, 6163, 6166, 6166, 6166, 6173, 6178, 6178, 6178, 6197, 6199, 6203, 6211, 6217, 6218, 6218, 6218, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s9/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s9/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s9/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dfa0a626f771f4ab1622987d8a2f8ddef969997c --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"N": 9545, "t": 3118, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s9/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s9/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p58-happy-ending-l1-s0/environment/Dockerfile b/tasks/construct-ae-p58-happy-ending-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-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-p58-happy-ending-l1-s0/environment/instance.json b/tasks/construct-ae-p58-happy-ending-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..441e1e37e4213f67c45ccf9b3a9a60401bba84a6 --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "k": 5, "max_abs": 1000000000000000000, "family": "ae_p58_happy_ending", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p58-happy-ending-l1-s0/solution/solve.sh b/tasks/construct-ae-p58-happy-ending-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..03b207ac090f5d54ef16fb74ca9457e449b79b82 --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l1-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"points": [[0, 0], [15000, -15000000], [15001, -14999998], [15002, -14999990], [30000, -60000000], [30001, -59999990], [30002, -59999988], [45000, -135000000]]} +RLMATH_EOF diff --git a/tasks/construct-ae-p58-happy-ending-l1-s0/tests/check.py b/tasks/construct-ae-p58-happy-ending-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..47e4606e109bc165111a8138a5a2f60870d563c8 --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l1-s0/tests/check.py @@ -0,0 +1,69 @@ +"""Erdos-Szekeres happy ending (AlphaEvolve problem 58): n = 2^(k-2) integer points in general position with no +k points in convex position. Exact integer orientation tests; the largest convex-position subset is computed by +the O(n^4) bottom-vertex / angular-order dynamic programme. + +Upstream bug: the notebook's verifier uses float orientations with a 1e-9 threshold (and numba fastmath); its +33- and 65-point sets (claimed to have "0 convex k-gons") contain a convex 7-gon / 8-gon under exact arithmetic.""" +import functools + +import numpy as np + +from run import Invalid, int_list + + +def orient_table(p): + n = len(p) + o = np.zeros((n, n, n), dtype=np.int8) + for i in range(n): + xi, yi = p[i] + for j in range(i + 1, n): + dx, dy = p[j][0] - xi, p[j][1] - yi + for k in range(j + 1, n): + c = dx * (p[k][1] - yi) - dy * (p[k][0] - xi) + if c == 0: + raise Invalid(f"points {p[i]}, {p[j]}, {p[k]} are collinear") + s = 1 if c > 0 else -1 + o[i, j, k] = o[j, k, i] = o[k, i, j] = s + o[i, k, j] = o[k, j, i] = o[j, i, k] = -s + return o + + +def max_convex(p, o): + n = len(p) + best = min(n, 3) + order = sorted(range(n), key=lambda i: (p[i][1], p[i][0])) + for bi, b in enumerate(order): + rest = order[bi + 1:] + m = len(rest) + if m < 2: + continue + rest = sorted(rest, key=functools.cmp_to_key(lambda u, v: -int(o[b, u, v]))) + r = np.array(rest) + chain = np.zeros((m, m), dtype=np.int32) # chain[i, j]: longest convex chain b .. r_i -> r_j + for j in range(1, m): + for i in range(j): + v = 3 + if i > 0: + ok = (chain[:i, i] > 0) & (o[r[:i], r[i], r[j]] > 0) + if ok.any(): + v = max(v, int(chain[:i, i][ok].max()) + 1) + chain[i, j] = v + close = o[r[:j], r[j], b] > 0 + if close.any(): + best = max(best, int(chain[:j, j][close].max())) + return best + + +def check(inst, ans): + n, k, lim = inst["n"], inst["k"], inst["max_abs"] + pts = ans.get("points") + if not isinstance(pts, list) or len(pts) != n: + raise Invalid(f"points must be a list of {n} [x, y] pairs") + p = [tuple(int_list(q, 2, -lim, lim, "point")) for q in pts] + if len(set(p)) != n: + raise Invalid("points must be distinct") + o = orient_table(p) + mc = max_convex(p, o) + if mc >= k: + raise Invalid(f"the set contains {mc} points in convex position (>= {k})") + return None, {"max_convex_subset": mc} diff --git a/tasks/construct-ae-p58-happy-ending-l1-s0/tests/instance.json b/tasks/construct-ae-p58-happy-ending-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..441e1e37e4213f67c45ccf9b3a9a60401bba84a6 --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "k": 5, "max_abs": 1000000000000000000, "family": "ae_p58_happy_ending", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p58-happy-ending-l1-s0/tests/run.py b/tasks/construct-ae-p58-happy-ending-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-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-p58-happy-ending-l1-s0/tests/test.sh b/tasks/construct-ae-p58-happy-ending-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p58-happy-ending-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-l6-s0/environment/Dockerfile b/tasks/construct-mc-all-interval-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-all-interval-l6-s0/environment/instance.json b/tasks/construct-mc-all-interval-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a3b9a7ddd9aac9fec27db1f35e34af7d47d3d536 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 72, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s0/solution/solve.sh b/tasks/construct-mc-all-interval-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1017432de26ee70c89d2cf4b967f574093bca8b5 --- /dev/null +++ b/tasks/construct-mc-all-interval-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": [0, 71, 1, 70, 2, 69, 3, 68, 4, 67, 5, 66, 6, 65, 7, 64, 8, 63, 9, 62, 10, 61, 11, 60, 12, 59, 13, 58, 14, 57, 15, 56, 16, 55, 17, 54, 18, 53, 19, 52, 20, 51, 21, 50, 22, 49, 23, 48, 24, 47, 25, 46, 26, 45, 27, 44, 28, 43, 29, 42, 30, 41, 31, 40, 32, 39, 33, 38, 34, 37, 35, 36]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l6-s0/tests/check.py b/tasks/construct-mc-all-interval-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s0/tests/check.py @@ -0,0 +1,17 @@ +"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + d = [abs(x[i + 1] - x[i]) for i in range(n - 1)] + if sorted(d) != list(range(1, n)): + raise Invalid("consecutive differences are not a permutation of 1..n-1") + seqs = {"x": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-all-interval-l6-s0/tests/instance.json b/tasks/construct-mc-all-interval-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a3b9a7ddd9aac9fec27db1f35e34af7d47d3d536 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 72, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s0/tests/test.sh b/tasks/construct-mc-all-interval-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-all-interval-l6-s7/environment/Dockerfile b/tasks/construct-mc-all-interval-l6-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-mc-all-interval-l6-s7/environment/instance.json b/tasks/construct-mc-all-interval-l6-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8122102536afa159ddb701212c7eddb68800e431 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 120, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s7/solution/solve.sh b/tasks/construct-mc-all-interval-l6-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bea5adf3ed7b683e5853a362c546103cb6535aab --- /dev/null +++ b/tasks/construct-mc-all-interval-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": [0, 119, 1, 118, 2, 117, 3, 116, 4, 115, 5, 114, 6, 113, 7, 112, 8, 111, 9, 110, 10, 109, 11, 108, 12, 107, 13, 106, 14, 105, 15, 104, 16, 103, 17, 102, 18, 101, 19, 100, 20, 99, 21, 98, 22, 97, 23, 96, 24, 95, 25, 94, 26, 93, 27, 92, 28, 91, 29, 90, 30, 89, 31, 88, 32, 87, 33, 86, 34, 85, 35, 84, 36, 83, 37, 82, 38, 81, 39, 80, 40, 79, 41, 78, 42, 77, 43, 76, 44, 75, 45, 74, 46, 73, 47, 72, 48, 71, 49, 70, 50, 69, 51, 68, 52, 67, 53, 66, 54, 65, 55, 64, 56, 63, 57, 62, 58, 61, 59, 60]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l6-s7/tests/check.py b/tasks/construct-mc-all-interval-l6-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s7/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-s7/tests/instance.json b/tasks/construct-mc-all-interval-l6-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8122102536afa159ddb701212c7eddb68800e431 --- /dev/null +++ b/tasks/construct-mc-all-interval-l6-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 120, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l6-s7/tests/run.py b/tasks/construct-mc-all-interval-l6-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-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-mc-all-interval-l6-s7/tests/test.sh b/tasks/construct-mc-all-interval-l6-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-mc-bibd-l5-s3/environment/Dockerfile b/tasks/construct-mc-bibd-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-bibd-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-bibd-l5-s3/environment/instance.json b/tasks/construct-mc-bibd-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b84a5d4159c814b7f1e347d36311d4b126693591 --- /dev/null +++ b/tasks/construct-mc-bibd-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"v": 18, "k": 3, "lambda": 2, "b": 102, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l5-s3/solution/solve.sh b/tasks/construct-mc-bibd-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1568da9d9b1de2941a6ccf1fc13315259b56623a --- /dev/null +++ b/tasks/construct-mc-bibd-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' +{"blocks": [[4, 15, 16], [3, 13, 14], [0, 3, 7], [4, 5, 13], [5, 10, 17], [4, 7, 10], [6, 16, 17], [3, 4, 17], [0, 4, 10], [1, 10, 16], [1, 13, 17], [2, 7, 10], [10, 12, 16], [11, 13, 15], [8, 13, 17], [1, 4, 9], [0, 4, 16], [6, 7, 11], [4, 8, 12], [5, 11, 16], [4, 8, 15], [1, 2, 11], [2, 4, 13], [2, 6, 17], [1, 2, 16], [11, 14, 17], [4, 6, 11], [1, 3, 4], [3, 6, 13], [1, 14, 15], [1, 3, 12], [1, 12, 13], [0, 12, 17], [0, 3, 17], [1, 5, 7], [1, 5, 6], [5, 12, 13], [7, 13, 15], [1, 6, 8], [7, 8, 11], [1, 7, 8], [8, 9, 12], [1, 9, 17], [0, 1, 14], [6, 9, 15], [3, 6, 7], [3, 10, 15], [3, 5, 9], [3, 9, 11], [9, 12, 15], [9, 13, 16], [0, 13, 16], [0, 10, 14], [2, 7, 12], [6, 10, 13], [10, 11, 12], [8, 10, 15], [6, 12, 15], [1, 10, 11], [6, 8, 14], [3, 8, 16], [11, 12, 16], [11, 15, 17], [2, 6, 16], [2, 3, 8], [3, 15, 16], [8, 14, 16], [7, 13, 14], [0, 11, 13], [0, 6, 12], [8, 9, 11], [0, 5, 11], [6, 10, 14], [0, 1, 15], [7, 15, 17], [7, 12, 14], [5, 14, 15], [3, 5, 10], [3, 12, 14], [5, 7, 16], [4, 7, 9], [5, 9, 14], [4, 5, 6], [9, 14, 16], [0, 7, 9], [0, 2, 15], [0, 2, 8], [2, 14, 17], [5, 8, 17], [7, 16, 17], [4, 11, 14], [0, 6, 9], [2, 4, 14], [2, 5, 12], [8, 10, 13], [2, 9, 13], [9, 10, 17], [0, 5, 8], [4, 12, 17], [2, 9, 10], [2, 5, 15], [2, 3, 11]]} +RLMATH_EOF diff --git a/tasks/construct-mc-bibd-l5-s3/tests/check.py b/tasks/construct-mc-bibd-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c4b5da62477026f27ff9869fe33602fcc41e2ea9 --- /dev/null +++ b/tasks/construct-mc-bibd-l5-s3/tests/check.py @@ -0,0 +1,25 @@ +"""Balanced incomplete block design BIBD(v, k, lambda) (MathConstraint bibd, CC-BY-4.0). +Answer = list of b blocks; every block is a k-subset of {0..v-1}, every pair of points lies in exactly +lambda blocks (which forces every point to lie in r blocks). Repeated blocks are allowed, as upstream +(its 0/1 incidence-matrix model does not forbid equal columns).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + v, k, lam, b = inst["v"], inst["k"], inst["lambda"], inst["b"] + blocks = ans.get("blocks") + if not isinstance(blocks, list) or len(blocks) != b: + raise Invalid(f"blocks must be a list of exactly {b} blocks") + pair = {} + for B in blocks: + B = int_list(B, k, 0, v - 1, "block") + if len(set(B)) != k: + raise Invalid("a block contains a repeated point") + for p in itertools.combinations(sorted(B), 2): + pair[p] = pair.get(p, 0) + 1 + for p in itertools.combinations(range(v), 2): + if pair.get(p, 0) != lam: + raise Invalid(f"points {p} lie together in {pair.get(p, 0)} blocks, need {lam}") + return None, {} diff --git a/tasks/construct-mc-bibd-l5-s3/tests/instance.json b/tasks/construct-mc-bibd-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b84a5d4159c814b7f1e347d36311d4b126693591 --- /dev/null +++ b/tasks/construct-mc-bibd-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"v": 18, "k": 3, "lambda": 2, "b": 102, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l5-s3/tests/run.py b/tasks/construct-mc-bibd-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-bibd-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-bibd-l5-s3/tests/test.sh b/tasks/construct-mc-bibd-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-bibd-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-bibd-l5-s4/environment/Dockerfile b/tasks/construct-mc-bibd-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-bibd-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-bibd-l5-s4/environment/instance.json b/tasks/construct-mc-bibd-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c054da1cb0164f024c5808cb0797b6440ee4323a --- /dev/null +++ b/tasks/construct-mc-bibd-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"v": 23, "k": 11, "lambda": 5, "b": 23, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l5-s4/solution/solve.sh b/tasks/construct-mc-bibd-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bf6d9f86950dc3d10a7cf30553f27768578ec541 --- /dev/null +++ b/tasks/construct-mc-bibd-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' +{"blocks": [[1, 2, 3, 4, 6, 8, 9, 12, 13, 16, 18], [2, 3, 4, 5, 7, 9, 10, 13, 14, 17, 19], [3, 4, 5, 6, 8, 10, 11, 14, 15, 18, 20], [4, 5, 6, 7, 9, 11, 12, 15, 16, 19, 21], [5, 6, 7, 8, 10, 12, 13, 16, 17, 20, 22], [0, 6, 7, 8, 9, 11, 13, 14, 17, 18, 21], [1, 7, 8, 9, 10, 12, 14, 15, 18, 19, 22], [0, 2, 8, 9, 10, 11, 13, 15, 16, 19, 20], [1, 3, 9, 10, 11, 12, 14, 16, 17, 20, 21], [2, 4, 10, 11, 12, 13, 15, 17, 18, 21, 22], [0, 3, 5, 11, 12, 13, 14, 16, 18, 19, 22], [0, 1, 4, 6, 12, 13, 14, 15, 17, 19, 20], [1, 2, 5, 7, 13, 14, 15, 16, 18, 20, 21], [2, 3, 6, 8, 14, 15, 16, 17, 19, 21, 22], [0, 3, 4, 7, 9, 15, 16, 17, 18, 20, 22], [0, 1, 4, 5, 8, 10, 16, 17, 18, 19, 21], [1, 2, 5, 6, 9, 11, 17, 18, 19, 20, 22], [0, 2, 3, 6, 7, 10, 12, 18, 19, 20, 21], [1, 3, 4, 7, 8, 11, 13, 19, 20, 21, 22], [0, 2, 4, 5, 8, 9, 12, 14, 20, 21, 22], [0, 1, 3, 5, 6, 9, 10, 13, 15, 21, 22], [0, 1, 2, 4, 6, 7, 10, 11, 14, 16, 22], [0, 1, 2, 3, 5, 7, 8, 11, 12, 15, 17]]} +RLMATH_EOF diff --git a/tasks/construct-mc-bibd-l5-s4/tests/check.py b/tasks/construct-mc-bibd-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c4b5da62477026f27ff9869fe33602fcc41e2ea9 --- /dev/null +++ b/tasks/construct-mc-bibd-l5-s4/tests/check.py @@ -0,0 +1,25 @@ +"""Balanced incomplete block design BIBD(v, k, lambda) (MathConstraint bibd, CC-BY-4.0). +Answer = list of b blocks; every block is a k-subset of {0..v-1}, every pair of points lies in exactly +lambda blocks (which forces every point to lie in r blocks). Repeated blocks are allowed, as upstream +(its 0/1 incidence-matrix model does not forbid equal columns).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + v, k, lam, b = inst["v"], inst["k"], inst["lambda"], inst["b"] + blocks = ans.get("blocks") + if not isinstance(blocks, list) or len(blocks) != b: + raise Invalid(f"blocks must be a list of exactly {b} blocks") + pair = {} + for B in blocks: + B = int_list(B, k, 0, v - 1, "block") + if len(set(B)) != k: + raise Invalid("a block contains a repeated point") + for p in itertools.combinations(sorted(B), 2): + pair[p] = pair.get(p, 0) + 1 + for p in itertools.combinations(range(v), 2): + if pair.get(p, 0) != lam: + raise Invalid(f"points {p} lie together in {pair.get(p, 0)} blocks, need {lam}") + return None, {} diff --git a/tasks/construct-mc-bibd-l5-s4/tests/instance.json b/tasks/construct-mc-bibd-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c054da1cb0164f024c5808cb0797b6440ee4323a --- /dev/null +++ b/tasks/construct-mc-bibd-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"v": 23, "k": 11, "lambda": 5, "b": 23, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l5-s4/tests/run.py b/tasks/construct-mc-bibd-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-bibd-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-bibd-l5-s4/tests/test.sh b/tasks/construct-mc-bibd-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-bibd-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-graceful-graph-l5-s1/environment/Dockerfile b/tasks/construct-mc-graceful-graph-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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-graceful-graph-l5-s1/environment/instance.json b/tasks/construct-mc-graceful-graph-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..96a594eca3a3488a5c7cd66192f61a832d85597e --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"k": 4, "p": 5, "num_vertices": 20, "edges": [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15], [16, 17], [16, 18], [16, 19], [17, 18], [17, 19], [18, 19], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19]], "fixed": [], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l5-s1/solution/solve.sh b/tasks/construct-mc-graceful-graph-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2f0a975a227978fe405fa2d1e2b8d7db10b93994 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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' +{"labels": [8, 1, 26, 45, 40, 6, 2, 0, 4, 3, 31, 46, 27, 44, 5, 13, 39, 9, 18, 29]} +RLMATH_EOF diff --git a/tasks/construct-mc-graceful-graph-l5-s1/tests/check.py b/tasks/construct-mc-graceful-graph-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f4d33af1d63c0495c3b32d34db6ae10f0fb45923 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s1/tests/check.py @@ -0,0 +1,19 @@ +"""Graceful labelling of K_k x P_p (MathConstraint graceful_graph, CC-BY-4.0): distinct vertex labels in +0..m (m = number of edges) whose edge differences |l(u) - l(v)| are all distinct.""" +from run import Invalid, int_list + + +def check(inst, ans): + nv, edges = inst["num_vertices"], inst["edges"] + m = len(edges) + x = int_list(ans.get("labels"), nv, 0, m, "labels") + if len(set(x)) != nv: + raise Invalid("vertex labels must be distinct") + d = [abs(x[u] - x[v]) for u, v in edges] + if len(set(d)) != m: + raise Invalid("edge labels are not distinct") + seqs = {"labels": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-graceful-graph-l5-s1/tests/instance.json b/tasks/construct-mc-graceful-graph-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..96a594eca3a3488a5c7cd66192f61a832d85597e --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"k": 4, "p": 5, "num_vertices": 20, "edges": [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15], [16, 17], [16, 18], [16, 19], [17, 18], [17, 19], [18, 19], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19]], "fixed": [], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l5-s1/tests/run.py b/tasks/construct-mc-graceful-graph-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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-graceful-graph-l5-s1/tests/test.sh b/tasks/construct-mc-graceful-graph-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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-graph-k-coloring-l1-s1/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-graph-k-coloring-l1-s1/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..978e9d809e4524893bce20c656e9b9c49414ad1d --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 3, "edges": [[0, 9], [1, 10], [1, 11], [1, 19], [2, 3], [2, 6], [3, 4], [3, 9], [3, 19], [4, 10], [4, 12], [4, 13], [4, 14], [4, 15], [5, 10], [5, 13], [6, 8], [7, 8], [8, 12], [8, 19], [9, 11], [10, 13], [10, 14], [10, 19], [11, 14], [12, 13], [12, 18], [12, 19], [13, 18], [15, 17]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l1-s1/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fee6516f6cf7a2f1f66f734018843be68adf07e5 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [2, 1, 0, 2, 1, 1, 2, 0, 1, 0, 2, 2, 2, 0, 0, 0, 1, 1, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l1-s1/tests/check.py b/tasks/construct-mc-graph-k-coloring-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s1/tests/check.py @@ -0,0 +1,11 @@ +"""Proper k-colouring of a given graph (MathConstraint graph_k_coloring, CC-BY-4.0). Any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-mc-graph-k-coloring-l1-s1/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..978e9d809e4524893bce20c656e9b9c49414ad1d --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 3, "edges": [[0, 9], [1, 10], [1, 11], [1, 19], [2, 3], [2, 6], [3, 4], [3, 9], [3, 19], [4, 10], [4, 12], [4, 13], [4, 14], [4, 15], [5, 10], [5, 13], [6, 8], [7, 8], [8, 12], [8, 19], [9, 11], [10, 13], [10, 14], [10, 19], [11, 14], [12, 13], [12, 18], [12, 19], [13, 18], [15, 17]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l1-s1/tests/run.py b/tasks/construct-mc-graph-k-coloring-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-graph-k-coloring-l1-s1/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-graph-k-coloring-l1-s6/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-graph-k-coloring-l1-s6/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..83cd83ffce53baf06160377ff9b4f96c8a3dd8f0 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 3, "edges": [[0, 2], [0, 4], [0, 9], [0, 15], [0, 19], [1, 17], [1, 19], [2, 16], [3, 9], [3, 11], [3, 19], [4, 8], [4, 14], [4, 17], [5, 7], [5, 15], [6, 11], [6, 16], [7, 10], [7, 12], [7, 15], [7, 16], [7, 19], [10, 14], [10, 16], [10, 18], [11, 19], [12, 16], [13, 14], [15, 18]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l1-s6/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fbd14998271dd5ba1726ab200f11e2e7e3c6b9c8 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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' +{"coloring": [1, 0, 2, 1, 0, 0, 2, 1, 1, 0, 2, 0, 2, 0, 1, 2, 0, 1, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l1-s6/tests/check.py b/tasks/construct-mc-graph-k-coloring-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s6/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-s6/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..83cd83ffce53baf06160377ff9b4f96c8a3dd8f0 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 3, "edges": [[0, 2], [0, 4], [0, 9], [0, 15], [0, 19], [1, 17], [1, 19], [2, 16], [3, 9], [3, 11], [3, 19], [4, 8], [4, 14], [4, 17], [5, 7], [5, 15], [6, 11], [6, 16], [7, 10], [7, 12], [7, 15], [7, 16], [7, 19], [10, 14], [10, 16], [10, 18], [11, 19], [12, 16], [13, 14], [15, 18]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l1-s6/tests/run.py b/tasks/construct-mc-graph-k-coloring-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-graph-k-coloring-l1-s6/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-graph-k-coloring-l5-s0/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-graph-k-coloring-l5-s0/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c8613a9fcf3ef27219325b59a4dcc69fa52ec85c --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 100, "k": 4, "edges": [[0, 5], [0, 11], [0, 16], [0, 35], [0, 45], [0, 64], [0, 89], [0, 90], [0, 91], [1, 30], [1, 38], [1, 40], [1, 44], [1, 93], [2, 7], [2, 9], [2, 10], [2, 12], [2, 26], [2, 37], [2, 42], [2, 83], [3, 24], [3, 30], [3, 47], [3, 55], [3, 58], [3, 78], [3, 87], [4, 16], [4, 20], [4, 36], [4, 51], [4, 52], [4, 64], [4, 75], [4, 80], [4, 93], [4, 94], [5, 8], [5, 47], [5, 52], [5, 58], [5, 84], [5, 92], [5, 99], [6, 11], [6, 16], [6, 22], [6, 28], [6, 37], [6, 70], [6, 82], [6, 83], [6, 88], [6, 97], [7, 8], [7, 12], [7, 15], [7, 23], [7, 86], [7, 87], [7, 95], [8, 12], [8, 14], [8, 31], [8, 32], [8, 71], [8, 89], [8, 93], [9, 12], [9, 15], [9, 18], [9, 39], [9, 42], [9, 55], [9, 57], [9, 69], [9, 96], [10, 23], [10, 49], [10, 57], [11, 20], [11, 22], [11, 26], [11, 32], [11, 43], [11, 46], [11, 55], [11, 66], [11, 79], [11, 84], [12, 16], [12, 22], [12, 30], [12, 44], [12, 58], [12, 73], [12, 90], [12, 98], [13, 40], [13, 53], [13, 63], [13, 69], [13, 77], [14, 24], [14, 48], [14, 54], [14, 57], [14, 71], [14, 75], [14, 83], [15, 87], [16, 26], [16, 33], [16, 41], [16, 56], [16, 58], [16, 61], [16, 91], [16, 92], [17, 45], [17, 69], [18, 23], [18, 26], [18, 27], [18, 33], [18, 36], [18, 40], [18, 64], [18, 66], [18, 67], [18, 73], [18, 75], [18, 82], [18, 94], [19, 22], [19, 38], [19, 48], [19, 58], [19, 71], [19, 73], [19, 87], [20, 35], [20, 48], [20, 60], [20, 66], [20, 76], [21, 24], [21, 34], [21, 39], [21, 63], [22, 35], [22, 36], [22, 38], [22, 56], [22, 59], [22, 61], [22, 62], [22, 63], [22, 71], [22, 72], [22, 81], [23, 26], [23, 65], [23, 71], [23, 74], [23, 76], [23, 78], [23, 87], [24, 32], [24, 38], [24, 52], [25, 37], [25, 45], [25, 46], [25, 53], [25, 60], [25, 82], [26, 44], [26, 51], [26, 53], [26, 64], [26, 80], [26, 86], [26, 95], [27, 43], [27, 59], [27, 76], [28, 47], [28, 51], [28, 76], [28, 85], [28, 90], [28, 93], [29, 42], [29, 47], [29, 55], [29, 57], [29, 77], [29, 88], [29, 89], [29, 99], [30, 36], [30, 59], [30, 60], [30, 61], [30, 66], [30, 67], [30, 86], [30, 87], [30, 89], [30, 90], [30, 93], [30, 97], [30, 99], [31, 33], [31, 42], [31, 58], [31, 59], [31, 62], [31, 89], [31, 90], [32, 40], [32, 89], [32, 90], [33, 37], [33, 79], [34, 48], [34, 91], [35, 52], [35, 58], [35, 66], [35, 73], [35, 78], [36, 44], [36, 45], [36, 70], [36, 81], [36, 96], [36, 98], [37, 38], [37, 57], [37, 59], [37, 68], [37, 83], [37, 94], [37, 99], [38, 62], [38, 68], [38, 78], [38, 79], [39, 45], [39, 50], [39, 55], [39, 72], [39, 77], [41, 49], [41, 55], [41, 60], [41, 71], [41, 96], [42, 53], [42, 57], [42, 59], [42, 75], [42, 77], [43, 57], [43, 60], [43, 62], [43, 66], [43, 72], [43, 77], [43, 89], [43, 94], [43, 99], [44, 45], [44, 46], [44, 65], [44, 78], [44, 93], [44, 94], [45, 52], [45, 60], [45, 74], [45, 79], [45, 86], [45, 92], [45, 95], [45, 96], [46, 56], [47, 66], [47, 72], [47, 73], [47, 77], [47, 82], [48, 58], [48, 62], [48, 78], [48, 85], [48, 99], [49, 56], [49, 69], [49, 81], [49, 89], [50, 57], [50, 60], [50, 63], [50, 65], [50, 66], [50, 96], [50, 98], [51, 53], [51, 89], [51, 96], [52, 54], [52, 80], [53, 67], [53, 96], [53, 97], [54, 88], [54, 96], [55, 91], [55, 96], [55, 97], [56, 57], [56, 71], [56, 77], [57, 74], [57, 78], [57, 87], [58, 67], [58, 88], [58, 96], [58, 99], [59, 86], [59, 99], [60, 67], [60, 68], [60, 72], [60, 91], [60, 92], [61, 67], [62, 63], [62, 68], [62, 78], [62, 95], [63, 79], [63, 90], [63, 92], [64, 79], [65, 80], [65, 81], [65, 86], [65, 88], [65, 99], [66, 80], [67, 72], [67, 83], [67, 94], [67, 96], [68, 71], [68, 75], [68, 80], [68, 98], [69, 72], [70, 85], [70, 93], [70, 96], [71, 86], [72, 86], [72, 87], [72, 90], [73, 82], [73, 93], [73, 95], [73, 96], [73, 99], [74, 77], [75, 83], [76, 78], [78, 80], [78, 81], [78, 96], [79, 81], [80, 86], [82, 86], [84, 86], [85, 93], [86, 89], [86, 96], [86, 99], [87, 89], [88, 96], [90, 98], [92, 97], [93, 98], [94, 95], [95, 98], [97, 99]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l5-s0/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1772ee6196e20ca7d0822de9e805e56d72bedaef --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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": [3, 2, 2, 3, 0, 2, 0, 0, 1, 1, 0, 1, 3, 0, 2, 3, 2, 2, 0, 0, 2, 3, 2, 1, 1, 0, 3, 1, 1, 1, 1, 2, 2, 3, 1, 0, 3, 1, 3, 0, 3, 1, 0, 2, 0, 1, 2, 0, 3, 2, 2, 2, 3, 1, 1, 2, 1, 3, 1, 3, 3, 0, 0, 1, 1, 3, 3, 2, 2, 3, 2, 3, 1, 1, 0, 1, 0, 3, 2, 2, 1, 1, 3, 3, 0, 0, 2, 2, 2, 0, 0, 0, 0, 3, 3, 2, 0, 3, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l5-s0/tests/check.py b/tasks/construct-mc-graph-k-coloring-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s0/tests/check.py @@ -0,0 +1,11 @@ +"""Proper k-colouring of a given graph (MathConstraint graph_k_coloring, CC-BY-4.0). Any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-mc-graph-k-coloring-l5-s0/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c8613a9fcf3ef27219325b59a4dcc69fa52ec85c --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 100, "k": 4, "edges": [[0, 5], [0, 11], [0, 16], [0, 35], [0, 45], [0, 64], [0, 89], [0, 90], [0, 91], [1, 30], [1, 38], [1, 40], [1, 44], [1, 93], [2, 7], [2, 9], [2, 10], [2, 12], [2, 26], [2, 37], [2, 42], [2, 83], [3, 24], [3, 30], [3, 47], [3, 55], [3, 58], [3, 78], [3, 87], [4, 16], [4, 20], [4, 36], [4, 51], [4, 52], [4, 64], [4, 75], [4, 80], [4, 93], [4, 94], [5, 8], [5, 47], [5, 52], [5, 58], [5, 84], [5, 92], [5, 99], [6, 11], [6, 16], [6, 22], [6, 28], [6, 37], [6, 70], [6, 82], [6, 83], [6, 88], [6, 97], [7, 8], [7, 12], [7, 15], [7, 23], [7, 86], [7, 87], [7, 95], [8, 12], [8, 14], [8, 31], [8, 32], [8, 71], [8, 89], [8, 93], [9, 12], [9, 15], [9, 18], [9, 39], [9, 42], [9, 55], [9, 57], [9, 69], [9, 96], [10, 23], [10, 49], [10, 57], [11, 20], [11, 22], [11, 26], [11, 32], [11, 43], [11, 46], [11, 55], [11, 66], [11, 79], [11, 84], [12, 16], [12, 22], [12, 30], [12, 44], [12, 58], [12, 73], [12, 90], [12, 98], [13, 40], [13, 53], [13, 63], [13, 69], [13, 77], [14, 24], [14, 48], [14, 54], [14, 57], [14, 71], [14, 75], [14, 83], [15, 87], [16, 26], [16, 33], [16, 41], [16, 56], [16, 58], [16, 61], [16, 91], [16, 92], [17, 45], [17, 69], [18, 23], [18, 26], [18, 27], [18, 33], [18, 36], [18, 40], [18, 64], [18, 66], [18, 67], [18, 73], [18, 75], [18, 82], [18, 94], [19, 22], [19, 38], [19, 48], [19, 58], [19, 71], [19, 73], [19, 87], [20, 35], [20, 48], [20, 60], [20, 66], [20, 76], [21, 24], [21, 34], [21, 39], [21, 63], [22, 35], [22, 36], [22, 38], [22, 56], [22, 59], [22, 61], [22, 62], [22, 63], [22, 71], [22, 72], [22, 81], [23, 26], [23, 65], [23, 71], [23, 74], [23, 76], [23, 78], [23, 87], [24, 32], [24, 38], [24, 52], [25, 37], [25, 45], [25, 46], [25, 53], [25, 60], [25, 82], [26, 44], [26, 51], [26, 53], [26, 64], [26, 80], [26, 86], [26, 95], [27, 43], [27, 59], [27, 76], [28, 47], [28, 51], [28, 76], [28, 85], [28, 90], [28, 93], [29, 42], [29, 47], [29, 55], [29, 57], [29, 77], [29, 88], [29, 89], [29, 99], [30, 36], [30, 59], [30, 60], [30, 61], [30, 66], [30, 67], [30, 86], [30, 87], [30, 89], [30, 90], [30, 93], [30, 97], [30, 99], [31, 33], [31, 42], [31, 58], [31, 59], [31, 62], [31, 89], [31, 90], [32, 40], [32, 89], [32, 90], [33, 37], [33, 79], [34, 48], [34, 91], [35, 52], [35, 58], [35, 66], [35, 73], [35, 78], [36, 44], [36, 45], [36, 70], [36, 81], [36, 96], [36, 98], [37, 38], [37, 57], [37, 59], [37, 68], [37, 83], [37, 94], [37, 99], [38, 62], [38, 68], [38, 78], [38, 79], [39, 45], [39, 50], [39, 55], [39, 72], [39, 77], [41, 49], [41, 55], [41, 60], [41, 71], [41, 96], [42, 53], [42, 57], [42, 59], [42, 75], [42, 77], [43, 57], [43, 60], [43, 62], [43, 66], [43, 72], [43, 77], [43, 89], [43, 94], [43, 99], [44, 45], [44, 46], [44, 65], [44, 78], [44, 93], [44, 94], [45, 52], [45, 60], [45, 74], [45, 79], [45, 86], [45, 92], [45, 95], [45, 96], [46, 56], [47, 66], [47, 72], [47, 73], [47, 77], [47, 82], [48, 58], [48, 62], [48, 78], [48, 85], [48, 99], [49, 56], [49, 69], [49, 81], [49, 89], [50, 57], [50, 60], [50, 63], [50, 65], [50, 66], [50, 96], [50, 98], [51, 53], [51, 89], [51, 96], [52, 54], [52, 80], [53, 67], [53, 96], [53, 97], [54, 88], [54, 96], [55, 91], [55, 96], [55, 97], [56, 57], [56, 71], [56, 77], [57, 74], [57, 78], [57, 87], [58, 67], [58, 88], [58, 96], [58, 99], [59, 86], [59, 99], [60, 67], [60, 68], [60, 72], [60, 91], [60, 92], [61, 67], [62, 63], [62, 68], [62, 78], [62, 95], [63, 79], [63, 90], [63, 92], [64, 79], [65, 80], [65, 81], [65, 86], [65, 88], [65, 99], [66, 80], [67, 72], [67, 83], [67, 94], [67, 96], [68, 71], [68, 75], [68, 80], [68, 98], [69, 72], [70, 85], [70, 93], [70, 96], [71, 86], [72, 86], [72, 87], [72, 90], [73, 82], [73, 93], [73, 95], [73, 96], [73, 99], [74, 77], [75, 83], [76, 78], [78, 80], [78, 81], [78, 96], [79, 81], [80, 86], [82, 86], [84, 86], [85, 93], [86, 89], [86, 96], [86, 99], [87, 89], [88, 96], [90, 98], [92, 97], [93, 98], [94, 95], [95, 98], [97, 99]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l5-s0/tests/run.py b/tasks/construct-mc-graph-k-coloring-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-graph-k-coloring-l5-s0/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-graph-k-coloring-l5-s9/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-graph-k-coloring-l5-s9/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9a87a27f08e8090645a07921f7595b90e87353e8 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 100, "k": 4, "edges": [[0, 11], [0, 24], [0, 42], [0, 53], [0, 59], [0, 71], [0, 76], [0, 84], [0, 85], [0, 96], [1, 2], [1, 18], [1, 24], [1, 39], [1, 42], [1, 53], [1, 58], [1, 71], [1, 90], [1, 94], [2, 5], [2, 32], [2, 38], [2, 41], [2, 73], [2, 96], [3, 8], [3, 9], [3, 12], [3, 26], [3, 31], [3, 50], [3, 61], [3, 63], [3, 64], [3, 69], [4, 6], [4, 29], [4, 49], [4, 64], [4, 80], [5, 18], [5, 19], [5, 41], [5, 67], [5, 74], [5, 93], [5, 94], [6, 16], [6, 18], [6, 34], [6, 41], [6, 68], [6, 83], [6, 87], [7, 34], [7, 43], [7, 45], [7, 50], [7, 54], [7, 56], [7, 58], [7, 69], [7, 84], [7, 90], [8, 21], [8, 25], [8, 30], [8, 41], [8, 42], [8, 65], [8, 69], [8, 75], [8, 97], [8, 98], [9, 20], [9, 33], [9, 77], [9, 80], [10, 22], [10, 54], [10, 56], [10, 66], [10, 81], [10, 86], [10, 96], [11, 15], [11, 25], [11, 33], [11, 37], [11, 39], [11, 68], [11, 84], [12, 25], [12, 30], [12, 65], [12, 67], [12, 77], [12, 93], [13, 16], [13, 20], [13, 21], [13, 23], [13, 72], [13, 76], [13, 83], [14, 22], [14, 44], [14, 89], [14, 91], [15, 21], [15, 24], [15, 28], [15, 32], [15, 59], [15, 63], [15, 64], [15, 85], [15, 86], [15, 97], [16, 29], [16, 59], [16, 67], [16, 76], [16, 90], [16, 91], [16, 92], [17, 22], [17, 37], [17, 40], [17, 57], [17, 73], [17, 77], [18, 48], [18, 58], [18, 79], [18, 99], [19, 22], [19, 35], [19, 47], [19, 55], [19, 57], [19, 67], [19, 88], [20, 30], [20, 33], [20, 37], [20, 62], [20, 83], [21, 22], [21, 42], [21, 56], [21, 61], [21, 62], [21, 84], [21, 87], [22, 27], [22, 33], [22, 44], [22, 56], [22, 66], [22, 76], [22, 82], [22, 88], [22, 89], [22, 95], [23, 30], [23, 32], [23, 40], [23, 47], [23, 84], [23, 91], [23, 94], [24, 37], [24, 57], [24, 64], [24, 88], [25, 29], [25, 54], [25, 59], [25, 70], [25, 94], [26, 32], [26, 36], [26, 74], [26, 90], [26, 92], [27, 45], [27, 58], [28, 30], [28, 34], [28, 35], [28, 42], [28, 51], [28, 74], [28, 96], [29, 37], [29, 46], [29, 51], [29, 55], [29, 68], [29, 74], [29, 86], [29, 88], [30, 37], [30, 69], [30, 95], [31, 38], [31, 40], [31, 53], [31, 56], [31, 78], [31, 82], [31, 85], [32, 36], [32, 47], [32, 51], [32, 53], [32, 59], [32, 66], [32, 71], [32, 84], [32, 85], [33, 58], [33, 75], [33, 77], [33, 78], [33, 97], [34, 37], [34, 50], [34, 61], [35, 41], [35, 43], [35, 47], [35, 77], [35, 86], [35, 93], [36, 52], [36, 65], [36, 66], [36, 95], [36, 98], [37, 41], [37, 46], [37, 50], [37, 58], [37, 68], [37, 71], [37, 89], [38, 80], [39, 51], [39, 66], [40, 45], [40, 90], [40, 95], [40, 98], [41, 46], [41, 48], [41, 50], [41, 56], [41, 61], [41, 63], [41, 68], [41, 69], [41, 72], [41, 78], [41, 98], [42, 44], [42, 45], [42, 58], [42, 59], [42, 62], [43, 76], [43, 92], [43, 93], [43, 99], [44, 68], [44, 83], [45, 47], [45, 70], [45, 73], [45, 98], [45, 99], [46, 55], [46, 57], [46, 65], [46, 77], [47, 59], [47, 62], [48, 50], [48, 59], [48, 95], [49, 53], [49, 67], [49, 90], [49, 92], [50, 68], [50, 74], [50, 94], [51, 74], [51, 81], [51, 89], [52, 54], [52, 73], [52, 85], [52, 96], [52, 97], [53, 97], [54, 55], [54, 77], [54, 94], [55, 58], [55, 65], [55, 72], [55, 83], [55, 94], [55, 97], [56, 57], [56, 78], [56, 87], [57, 68], [57, 90], [58, 62], [58, 73], [58, 96], [59, 75], [59, 87], [60, 68], [60, 73], [60, 78], [60, 82], [60, 89], [60, 96], [61, 64], [61, 68], [61, 72], [61, 87], [62, 63], [62, 79], [63, 68], [63, 70], [63, 76], [63, 80], [63, 87], [64, 68], [64, 83], [64, 91], [64, 96], [65, 67], [65, 88], [66, 73], [66, 74], [66, 77], [66, 79], [67, 69], [67, 73], [67, 80], [67, 87], [68, 93], [68, 94], [68, 98], [69, 77], [69, 94], [70, 71], [70, 83], [70, 90], [71, 86], [72, 78], [72, 86], [73, 86], [74, 94], [75, 88], [75, 94], [76, 83], [77, 87], [77, 89], [77, 92], [78, 80], [78, 88], [79, 82], [79, 91], [80, 89], [80, 91], [80, 98], [82, 86], [83, 99], [84, 93], [84, 94], [85, 99], [87, 88], [87, 95], [87, 98], [87, 99], [88, 89], [88, 92], [88, 97], [89, 98], [90, 97], [93, 96], [94, 98]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l5-s9/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a73079e0df503adf5e484f15ff96eb93aeace0b4 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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' +{"coloring": [0, 0, 3, 1, 2, 0, 3, 1, 3, 2, 1, 3, 0, 0, 1, 0, 2, 3, 2, 1, 1, 1, 2, 3, 1, 2, 0, 0, 1, 1, 2, 0, 1, 0, 2, 3, 2, 0, 2, 2, 1, 1, 2, 0, 3, 3, 3, 2, 0, 1, 3, 0, 0, 2, 3, 0, 3, 0, 3, 3, 0, 0, 0, 3, 3, 1, 0, 3, 2, 0, 1, 3, 3, 1, 2, 2, 1, 1, 2, 1, 1, 2, 3, 2, 2, 2, 2, 2, 0, 3, 3, 0, 3, 1, 1, 3, 2, 1, 0, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l5-s9/tests/check.py b/tasks/construct-mc-graph-k-coloring-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s9/tests/check.py @@ -0,0 +1,11 @@ +"""Proper k-colouring of a given graph (MathConstraint graph_k_coloring, CC-BY-4.0). Any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-mc-graph-k-coloring-l5-s9/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9a87a27f08e8090645a07921f7595b90e87353e8 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 100, "k": 4, "edges": [[0, 11], [0, 24], [0, 42], [0, 53], [0, 59], [0, 71], [0, 76], [0, 84], [0, 85], [0, 96], [1, 2], [1, 18], [1, 24], [1, 39], [1, 42], [1, 53], [1, 58], [1, 71], [1, 90], [1, 94], [2, 5], [2, 32], [2, 38], [2, 41], [2, 73], [2, 96], [3, 8], [3, 9], [3, 12], [3, 26], [3, 31], [3, 50], [3, 61], [3, 63], [3, 64], [3, 69], [4, 6], [4, 29], [4, 49], [4, 64], [4, 80], [5, 18], [5, 19], [5, 41], [5, 67], [5, 74], [5, 93], [5, 94], [6, 16], [6, 18], [6, 34], [6, 41], [6, 68], [6, 83], [6, 87], [7, 34], [7, 43], [7, 45], [7, 50], [7, 54], [7, 56], [7, 58], [7, 69], [7, 84], [7, 90], [8, 21], [8, 25], [8, 30], [8, 41], [8, 42], [8, 65], [8, 69], [8, 75], [8, 97], [8, 98], [9, 20], [9, 33], [9, 77], [9, 80], [10, 22], [10, 54], [10, 56], [10, 66], [10, 81], [10, 86], [10, 96], [11, 15], [11, 25], [11, 33], [11, 37], [11, 39], [11, 68], [11, 84], [12, 25], [12, 30], [12, 65], [12, 67], [12, 77], [12, 93], [13, 16], [13, 20], [13, 21], [13, 23], [13, 72], [13, 76], [13, 83], [14, 22], [14, 44], [14, 89], [14, 91], [15, 21], [15, 24], [15, 28], [15, 32], [15, 59], [15, 63], [15, 64], [15, 85], [15, 86], [15, 97], [16, 29], [16, 59], [16, 67], [16, 76], [16, 90], [16, 91], [16, 92], [17, 22], [17, 37], [17, 40], [17, 57], [17, 73], [17, 77], [18, 48], [18, 58], [18, 79], [18, 99], [19, 22], [19, 35], [19, 47], [19, 55], [19, 57], [19, 67], [19, 88], [20, 30], [20, 33], [20, 37], [20, 62], [20, 83], [21, 22], [21, 42], [21, 56], [21, 61], [21, 62], [21, 84], [21, 87], [22, 27], [22, 33], [22, 44], [22, 56], [22, 66], [22, 76], [22, 82], [22, 88], [22, 89], [22, 95], [23, 30], [23, 32], [23, 40], [23, 47], [23, 84], [23, 91], [23, 94], [24, 37], [24, 57], [24, 64], [24, 88], [25, 29], [25, 54], [25, 59], [25, 70], [25, 94], [26, 32], [26, 36], [26, 74], [26, 90], [26, 92], [27, 45], [27, 58], [28, 30], [28, 34], [28, 35], [28, 42], [28, 51], [28, 74], [28, 96], [29, 37], [29, 46], [29, 51], [29, 55], [29, 68], [29, 74], [29, 86], [29, 88], [30, 37], [30, 69], [30, 95], [31, 38], [31, 40], [31, 53], [31, 56], [31, 78], [31, 82], [31, 85], [32, 36], [32, 47], [32, 51], [32, 53], [32, 59], [32, 66], [32, 71], [32, 84], [32, 85], [33, 58], [33, 75], [33, 77], [33, 78], [33, 97], [34, 37], [34, 50], [34, 61], [35, 41], [35, 43], [35, 47], [35, 77], [35, 86], [35, 93], [36, 52], [36, 65], [36, 66], [36, 95], [36, 98], [37, 41], [37, 46], [37, 50], [37, 58], [37, 68], [37, 71], [37, 89], [38, 80], [39, 51], [39, 66], [40, 45], [40, 90], [40, 95], [40, 98], [41, 46], [41, 48], [41, 50], [41, 56], [41, 61], [41, 63], [41, 68], [41, 69], [41, 72], [41, 78], [41, 98], [42, 44], [42, 45], [42, 58], [42, 59], [42, 62], [43, 76], [43, 92], [43, 93], [43, 99], [44, 68], [44, 83], [45, 47], [45, 70], [45, 73], [45, 98], [45, 99], [46, 55], [46, 57], [46, 65], [46, 77], [47, 59], [47, 62], [48, 50], [48, 59], [48, 95], [49, 53], [49, 67], [49, 90], [49, 92], [50, 68], [50, 74], [50, 94], [51, 74], [51, 81], [51, 89], [52, 54], [52, 73], [52, 85], [52, 96], [52, 97], [53, 97], [54, 55], [54, 77], [54, 94], [55, 58], [55, 65], [55, 72], [55, 83], [55, 94], [55, 97], [56, 57], [56, 78], [56, 87], [57, 68], [57, 90], [58, 62], [58, 73], [58, 96], [59, 75], [59, 87], [60, 68], [60, 73], [60, 78], [60, 82], [60, 89], [60, 96], [61, 64], [61, 68], [61, 72], [61, 87], [62, 63], [62, 79], [63, 68], [63, 70], [63, 76], [63, 80], [63, 87], [64, 68], [64, 83], [64, 91], [64, 96], [65, 67], [65, 88], [66, 73], [66, 74], [66, 77], [66, 79], [67, 69], [67, 73], [67, 80], [67, 87], [68, 93], [68, 94], [68, 98], [69, 77], [69, 94], [70, 71], [70, 83], [70, 90], [71, 86], [72, 78], [72, 86], [73, 86], [74, 94], [75, 88], [75, 94], [76, 83], [77, 87], [77, 89], [77, 92], [78, 80], [78, 88], [79, 82], [79, 91], [80, 89], [80, 91], [80, 98], [82, 86], [83, 99], [84, 93], [84, 94], [85, 99], [87, 88], [87, 95], [87, 98], [87, 99], [88, 89], [88, 92], [88, 97], [89, 98], [90, 97], [93, 96], [94, 98]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l5-s9/tests/run.py b/tasks/construct-mc-graph-k-coloring-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-graph-k-coloring-l5-s9/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-hadamard-l5-s1/environment/Dockerfile b/tasks/construct-mc-hadamard-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-hadamard-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-hadamard-l5-s1/environment/instance.json b/tasks/construct-mc-hadamard-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b3bcdacf87e49731f33d502108ea56a6a05abdb2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 53, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l5-s1/solution/solve.sh b/tasks/construct-mc-hadamard-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4d20139aaf6bb5d8997b043c499471b47414e31d --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 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]} +RLMATH_EOF diff --git a/tasks/construct-mc-hadamard-l5-s1/tests/check.py b/tasks/construct-mc-hadamard-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..fc4b93160fd7473dd14935db9d712e52abdd00c2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s1/tests/check.py @@ -0,0 +1,18 @@ +"""Legendre pair of odd length n (MathConstraint hadamard, CC-BY-4.0): x, y in {-1,+1}^n with +sum(x) = sum(y) = 1 and PAF_x(k) + PAF_y(k) = -2 for k = 1..(n-1)/2 (periodic autocorrelation).""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, -1, 1, "x") + y = int_list(ans.get("y"), n, -1, 1, "y") + if 0 in x or 0 in y: + raise Invalid("entries must be -1 or +1") + if sum(x) != 1 or sum(y) != 1: + raise Invalid("sum(x) and sum(y) must both equal 1") + for k in range(1, (n - 1) // 2 + 1): + p = sum(x[i] * x[(i + k) % n] for i in range(n)) + sum(y[i] * y[(i + k) % n] for i in range(n)) + if p != -2: + raise Invalid(f"PAF_x({k}) + PAF_y({k}) = {p}, need -2") + return None, {} diff --git a/tasks/construct-mc-hadamard-l5-s1/tests/instance.json b/tasks/construct-mc-hadamard-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b3bcdacf87e49731f33d502108ea56a6a05abdb2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 53, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l5-s1/tests/run.py b/tasks/construct-mc-hadamard-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-hadamard-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-hadamard-l5-s1/tests/test.sh b/tasks/construct-mc-hadamard-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-hadamard-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-low-autocorrelation-l3-s3/environment/Dockerfile b/tasks/construct-mc-low-autocorrelation-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-low-autocorrelation-l3-s3/environment/instance.json b/tasks/construct-mc-low-autocorrelation-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..00228985f8dbbece2b12a66a0844017459eff8fe --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 21, "bound": 52, "fixed": [["seq", 5, -1], ["seq", 12, -1], ["seq", 17, 1], ["seq", 20, 1], ["c", 0, 2], ["c", 1, -1], ["c", 8, 2], ["c", 19, -1]], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l3-s3/solution/solve.sh b/tasks/construct-mc-low-autocorrelation-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..86b8a40ede7e1971728cebdc536634f6aa4889f5 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"seq": [-1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-low-autocorrelation-l3-s3/tests/check.py b/tasks/construct-mc-low-autocorrelation-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8456f7b1c0ff0c9fb4bc9ae5a49074c8afa7d1aa --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s3/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-s3/tests/instance.json b/tasks/construct-mc-low-autocorrelation-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..00228985f8dbbece2b12a66a0844017459eff8fe --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 21, "bound": 52, "fixed": [["seq", 5, -1], ["seq", 12, -1], ["seq", 17, 1], ["seq", 20, 1], ["c", 0, 2], ["c", 1, -1], ["c", 8, 2], ["c", 19, -1]], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l3-s3/tests/run.py b/tasks/construct-mc-low-autocorrelation-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-low-autocorrelation-l3-s3/tests/test.sh b/tasks/construct-mc-low-autocorrelation-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-low-autocorrelation-l3-s4/environment/Dockerfile b/tasks/construct-mc-low-autocorrelation-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-low-autocorrelation-l3-s4/environment/instance.json b/tasks/construct-mc-low-autocorrelation-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1060df4925dcc01dd59001d1a733d674d1cb0e38 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 22, "bound": 56, "fixed": [], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l3-s4/solution/solve.sh b/tasks/construct-mc-low-autocorrelation-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b636d86174f7f16caff73e8b43c6d55d9db2b133 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"seq": [1, -1, 1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, -1]} +RLMATH_EOF diff --git a/tasks/construct-mc-low-autocorrelation-l3-s4/tests/check.py b/tasks/construct-mc-low-autocorrelation-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8456f7b1c0ff0c9fb4bc9ae5a49074c8afa7d1aa --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s4/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-s4/tests/instance.json b/tasks/construct-mc-low-autocorrelation-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1060df4925dcc01dd59001d1a733d674d1cb0e38 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 22, "bound": 56, "fixed": [], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l3-s4/tests/run.py b/tasks/construct-mc-low-autocorrelation-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-low-autocorrelation-l3-s4/tests/test.sh b/tasks/construct-mc-low-autocorrelation-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-magic-sequence-l4-s2/environment/Dockerfile b/tasks/construct-mc-magic-sequence-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-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-magic-sequence-l4-s2/environment/instance.json b/tasks/construct-mc-magic-sequence-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..66ea05d9fc3a624caea719c60c8c179f1697f793 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 28, "fixed": [], "family": "mc_magic_sequence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-magic-sequence-l4-s2/solution/solve.sh b/tasks/construct-mc-magic-sequence-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..858624f34f0251e71566a274dac717eae5122cda --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [24, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-magic-sequence-l4-s2/tests/check.py b/tasks/construct-mc-magic-sequence-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..27f636ddd6cfe523924ae01c6b9f37ee392f0332 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-s2/tests/check.py @@ -0,0 +1,18 @@ +"""Magic sequence of length n: x[i] = number of occurrences of i in x (MathConstraint magic_sequence, +CC-BY-4.0). The property itself is checked (no stored answer).""" +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n, "x") + cnt = Counter(x) + for i in range(n): + if x[i] != cnt.get(i, 0): + raise Invalid(f"x[{i}] = {x[i]} but {i} occurs {cnt.get(i, 0)} times") + for name, i, v in inst.get("fixed", []): + if x[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-magic-sequence-l4-s2/tests/instance.json b/tasks/construct-mc-magic-sequence-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..66ea05d9fc3a624caea719c60c8c179f1697f793 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 28, "fixed": [], "family": "mc_magic_sequence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-magic-sequence-l4-s2/tests/run.py b/tasks/construct-mc-magic-sequence-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-magic-sequence-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-magic-sequence-l4-s2/tests/test.sh b/tasks/construct-mc-magic-sequence-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-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-magic-sequence-l4-s5/environment/Dockerfile b/tasks/construct-mc-magic-sequence-l4-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-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-magic-sequence-l4-s5/environment/instance.json b/tasks/construct-mc-magic-sequence-l4-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4289e70f60916781f6c4797c0e64214019067860 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 32, "fixed": [], "family": "mc_magic_sequence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-magic-sequence-l4-s5/solution/solve.sh b/tasks/construct-mc-magic-sequence-l4-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fe970c54d32b5d6758d42decf7c466a90686d6a5 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-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": [28, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-magic-sequence-l4-s5/tests/check.py b/tasks/construct-mc-magic-sequence-l4-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..27f636ddd6cfe523924ae01c6b9f37ee392f0332 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-s5/tests/check.py @@ -0,0 +1,18 @@ +"""Magic sequence of length n: x[i] = number of occurrences of i in x (MathConstraint magic_sequence, +CC-BY-4.0). The property itself is checked (no stored answer).""" +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n, "x") + cnt = Counter(x) + for i in range(n): + if x[i] != cnt.get(i, 0): + raise Invalid(f"x[{i}] = {x[i]} but {i} occurs {cnt.get(i, 0)} times") + for name, i, v in inst.get("fixed", []): + if x[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-magic-sequence-l4-s5/tests/instance.json b/tasks/construct-mc-magic-sequence-l4-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4289e70f60916781f6c4797c0e64214019067860 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 32, "fixed": [], "family": "mc_magic_sequence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-magic-sequence-l4-s5/tests/run.py b/tasks/construct-mc-magic-sequence-l4-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-magic-sequence-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-magic-sequence-l4-s5/tests/test.sh b/tasks/construct-mc-magic-sequence-l4-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-max-clique-l3-s3/environment/Dockerfile b/tasks/construct-mc-max-clique-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-max-clique-l3-s3/environment/instance.json b/tasks/construct-mc-max-clique-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..649d89184b4fed9c92964e08f7a75a63c813aa8c --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 50, "k": 5, "edges": [[0, 2], [0, 4], [0, 5], [0, 7], [0, 8], [0, 9], [0, 10], [0, 12], [0, 13], [0, 14], [0, 21], [0, 22], [0, 23], [0, 24], [0, 27], [0, 30], [0, 33], [0, 35], [0, 36], [0, 40], [0, 41], [0, 42], [0, 43], [0, 45], [0, 46], [0, 47], [1, 2], [1, 3], [1, 4], [1, 5], [1, 7], [1, 9], [1, 10], [1, 12], [1, 15], [1, 16], [1, 19], [1, 20], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 28], [1, 29], [1, 30], [1, 31], [1, 33], [1, 34], [1, 35], [1, 38], [1, 39], [1, 40], [1, 45], [1, 46], [1, 48], [1, 49], [2, 5], [2, 6], [2, 7], [2, 9], [2, 11], [2, 12], [2, 15], [2, 17], [2, 19], [2, 20], [2, 21], [2, 22], [2, 24], [2, 27], [2, 30], [2, 32], [2, 33], [2, 35], [2, 39], [2, 40], [2, 42], [2, 43], [2, 47], [2, 48], [3, 4], [3, 5], [3, 8], [3, 9], [3, 12], [3, 13], [3, 16], [3, 17], [3, 18], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 29], [3, 30], [3, 34], [3, 37], [3, 42], [3, 43], [3, 45], [3, 49], [4, 6], [4, 7], [4, 9], [4, 10], [4, 11], [4, 12], [4, 14], [4, 17], [4, 18], [4, 19], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 32], [4, 35], [4, 36], [4, 38], [4, 41], [4, 42], [4, 43], [4, 46], [4, 49], [5, 7], [5, 9], [5, 10], [5, 11], [5, 12], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 26], [5, 27], [5, 28], [5, 29], [5, 31], [5, 32], [5, 33], [5, 34], [5, 38], [5, 41], [5, 42], [5, 43], [5, 44], [5, 45], [5, 49], [6, 8], [6, 9], [6, 10], [6, 11], [6, 13], [6, 15], [6, 16], [6, 17], [6, 20], [6, 21], [6, 22], [6, 24], [6, 26], [6, 28], [6, 29], [6, 31], [6, 34], [6, 35], [6, 36], [6, 38], [6, 41], [6, 43], [6, 44], [6, 47], [6, 48], [7, 11], [7, 12], [7, 14], [7, 16], [7, 17], [7, 21], [7, 27], [7, 31], [7, 34], [7, 35], [7, 36], [7, 37], [7, 38], [7, 41], [7, 43], [7, 44], [7, 45], [7, 46], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 17], [8, 18], [8, 20], [8, 22], [8, 23], [8, 24], [8, 25], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 35], [8, 36], [8, 38], [8, 39], [8, 41], [8, 43], [8, 46], [8, 47], [8, 49], [9, 10], [9, 11], [9, 12], [9, 13], [9, 15], [9, 17], [9, 18], [9, 19], [9, 23], [9, 26], [9, 27], [9, 28], [9, 29], [9, 30], [9, 32], [9, 34], [9, 36], [9, 39], [9, 40], [9, 43], [9, 45], [9, 48], [9, 49], [10, 12], [10, 14], [10, 16], [10, 17], [10, 18], [10, 23], [10, 25], [10, 27], [10, 28], [10, 32], [10, 33], [10, 35], [10, 37], [10, 39], [10, 41], [10, 43], [10, 45], [10, 47], [10, 48], [10, 49], [11, 12], [11, 14], [11, 16], [11, 17], [11, 19], [11, 21], [11, 22], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 30], [11, 32], [11, 33], [11, 34], [11, 37], [11, 38], [11, 42], [11, 43], [11, 44], [11, 45], [11, 46], [11, 49], [12, 14], [12, 15], [12, 17], [12, 19], [12, 22], [12, 23], [12, 24], [12, 25], [12, 30], [12, 31], [12, 32], [12, 33], [12, 34], [12, 37], [12, 38], [12, 40], [12, 41], [12, 42], [12, 43], [12, 45], [12, 46], [12, 47], [12, 48], [13, 17], [13, 18], [13, 19], [13, 20], [13, 22], [13, 25], [13, 26], [13, 29], [13, 34], [13, 35], [13, 36], [13, 37], [13, 38], [13, 40], [13, 43], [13, 44], [13, 45], [13, 46], [14, 18], [14, 19], [14, 20], [14, 24], [14, 26], [14, 28], [14, 30], [14, 31], [14, 33], [14, 34], [14, 35], [14, 36], [14, 38], [14, 43], [14, 45], [14, 46], [14, 47], [14, 48], [14, 49], [15, 17], [15, 18], [15, 19], [15, 20], [15, 22], [15, 25], [15, 28], [15, 29], [15, 31], [15, 32], [15, 33], [15, 35], [15, 37], [15, 38], [15, 39], [15, 40], [15, 41], [15, 45], [15, 49], [16, 20], [16, 21], [16, 23], [16, 24], [16, 26], [16, 27], [16, 29], [16, 32], [16, 33], [16, 36], [16, 37], [16, 38], [16, 40], [16, 45], [16, 48], [16, 49], [17, 20], [17, 21], [17, 22], [17, 24], [17, 27], [17, 29], [17, 31], [17, 32], [17, 34], [17, 35], [17, 36], [17, 39], [17, 40], [17, 43], [17, 45], [17, 46], [17, 47], [17, 48], [17, 49], [18, 20], [18, 21], [18, 23], [18, 28], [18, 29], [18, 31], [18, 33], [18, 34], [18, 36], [18, 37], [18, 38], [18, 40], [18, 42], [18, 43], [18, 45], [18, 46], [18, 47], [18, 48], [19, 23], [19, 25], [19, 26], [19, 27], [19, 28], [19, 30], [19, 31], [19, 33], [19, 34], [19, 36], [19, 37], [19, 38], [19, 39], [19, 41], [19, 42], [19, 43], [19, 44], [19, 45], [19, 46], [19, 47], [19, 48], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 28], [20, 29], [20, 30], [20, 33], [20, 35], [20, 36], [20, 37], [20, 38], [20, 39], [20, 40], [20, 41], [20, 43], [20, 45], [20, 47], [20, 48], [20, 49], [21, 22], [21, 26], [21, 29], [21, 32], [21, 33], [21, 34], [21, 36], [21, 37], [21, 38], [21, 40], [21, 41], [21, 42], [21, 43], [21, 44], [21, 45], [21, 49], [22, 25], [22, 26], [22, 28], [22, 30], [22, 31], [22, 32], [22, 34], [22, 37], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 43], [22, 45], [22, 47], [22, 48], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 34], [23, 37], [23, 39], [23, 40], [23, 42], [23, 43], [23, 45], [23, 47], [23, 48], [23, 49], [24, 26], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 36], [24, 37], [24, 38], [24, 39], [24, 40], [24, 43], [24, 45], [24, 46], [24, 48], [24, 49], [25, 26], [25, 27], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [25, 36], [25, 37], [25, 39], [25, 40], [25, 41], [25, 45], [25, 46], [25, 47], [25, 48], [25, 49], [26, 30], [26, 31], [26, 32], [26, 33], [26, 35], [26, 38], [26, 39], [26, 40], [26, 44], [26, 46], [26, 48], [26, 49], [27, 29], [27, 30], [27, 33], [27, 38], [27, 39], [27, 42], [27, 45], [27, 46], [27, 47], [27, 48], [27, 49], [28, 32], [28, 33], [28, 34], [28, 35], [28, 36], [28, 39], [28, 40], [28, 41], [28, 42], [28, 44], [28, 47], [28, 49], [29, 33], [29, 34], [29, 35], [29, 36], [29, 38], [29, 39], [29, 40], [29, 42], [29, 43], [29, 45], [29, 46], [29, 47], [30, 31], [30, 32], [30, 33], [30, 34], [30, 35], [30, 36], [30, 38], [30, 39], [30, 40], [30, 42], [30, 44], [30, 45], [30, 46], [30, 49], [31, 32], [31, 34], [31, 35], [31, 37], [31, 38], [31, 39], [31, 41], [31, 42], [31, 43], [31, 44], [31, 48], [31, 49], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 42], [32, 45], [32, 46], [32, 48], [33, 36], [33, 37], [33, 39], [33, 40], [33, 41], [33, 43], [33, 44], [33, 45], [33, 49], [34, 35], [34, 36], [34, 41], [34, 44], [34, 47], [34, 48], [34, 49], [35, 39], [35, 40], [35, 42], [35, 43], [35, 46], [35, 47], [35, 48], [36, 37], [36, 38], [36, 39], [36, 40], [36, 41], [36, 43], [36, 44], [36, 45], [36, 48], [37, 39], [37, 40], [37, 41], [37, 43], [37, 44], [37, 45], [37, 48], [38, 41], [38, 42], [38, 43], [38, 44], [38, 45], [38, 48], [39, 40], [39, 41], [39, 42], [39, 45], [39, 47], [39, 48], [40, 41], [40, 43], [40, 45], [40, 46], [40, 47], [40, 49], [41, 42], [41, 45], [41, 46], [41, 47], [41, 49], [42, 44], [42, 45], [42, 47], [42, 48], [42, 49], [43, 44], [43, 47], [43, 48], [43, 49], [44, 45], [44, 47], [44, 48], [44, 49], [45, 47], [45, 48], [46, 47], [46, 48], [47, 48]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l3-s3/solution/solve.sh b/tasks/construct-mc-max-clique-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a77a2b2ff0430db6ab59602b6f27272c964f9470 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [42, 44, 45, 47, 48]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-clique-l3-s3/tests/check.py b/tasks/construct-mc-max-clique-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3f70dbd5b155a3514c2102aa4ad460201495210 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s3/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-s3/tests/instance.json b/tasks/construct-mc-max-clique-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..649d89184b4fed9c92964e08f7a75a63c813aa8c --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 50, "k": 5, "edges": [[0, 2], [0, 4], [0, 5], [0, 7], [0, 8], [0, 9], [0, 10], [0, 12], [0, 13], [0, 14], [0, 21], [0, 22], [0, 23], [0, 24], [0, 27], [0, 30], [0, 33], [0, 35], [0, 36], [0, 40], [0, 41], [0, 42], [0, 43], [0, 45], [0, 46], [0, 47], [1, 2], [1, 3], [1, 4], [1, 5], [1, 7], [1, 9], [1, 10], [1, 12], [1, 15], [1, 16], [1, 19], [1, 20], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 28], [1, 29], [1, 30], [1, 31], [1, 33], [1, 34], [1, 35], [1, 38], [1, 39], [1, 40], [1, 45], [1, 46], [1, 48], [1, 49], [2, 5], [2, 6], [2, 7], [2, 9], [2, 11], [2, 12], [2, 15], [2, 17], [2, 19], [2, 20], [2, 21], [2, 22], [2, 24], [2, 27], [2, 30], [2, 32], [2, 33], [2, 35], [2, 39], [2, 40], [2, 42], [2, 43], [2, 47], [2, 48], [3, 4], [3, 5], [3, 8], [3, 9], [3, 12], [3, 13], [3, 16], [3, 17], [3, 18], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 29], [3, 30], [3, 34], [3, 37], [3, 42], [3, 43], [3, 45], [3, 49], [4, 6], [4, 7], [4, 9], [4, 10], [4, 11], [4, 12], [4, 14], [4, 17], [4, 18], [4, 19], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 32], [4, 35], [4, 36], [4, 38], [4, 41], [4, 42], [4, 43], [4, 46], [4, 49], [5, 7], [5, 9], [5, 10], [5, 11], [5, 12], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 26], [5, 27], [5, 28], [5, 29], [5, 31], [5, 32], [5, 33], [5, 34], [5, 38], [5, 41], [5, 42], [5, 43], [5, 44], [5, 45], [5, 49], [6, 8], [6, 9], [6, 10], [6, 11], [6, 13], [6, 15], [6, 16], [6, 17], [6, 20], [6, 21], [6, 22], [6, 24], [6, 26], [6, 28], [6, 29], [6, 31], [6, 34], [6, 35], [6, 36], [6, 38], [6, 41], [6, 43], [6, 44], [6, 47], [6, 48], [7, 11], [7, 12], [7, 14], [7, 16], [7, 17], [7, 21], [7, 27], [7, 31], [7, 34], [7, 35], [7, 36], [7, 37], [7, 38], [7, 41], [7, 43], [7, 44], [7, 45], [7, 46], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 17], [8, 18], [8, 20], [8, 22], [8, 23], [8, 24], [8, 25], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 35], [8, 36], [8, 38], [8, 39], [8, 41], [8, 43], [8, 46], [8, 47], [8, 49], [9, 10], [9, 11], [9, 12], [9, 13], [9, 15], [9, 17], [9, 18], [9, 19], [9, 23], [9, 26], [9, 27], [9, 28], [9, 29], [9, 30], [9, 32], [9, 34], [9, 36], [9, 39], [9, 40], [9, 43], [9, 45], [9, 48], [9, 49], [10, 12], [10, 14], [10, 16], [10, 17], [10, 18], [10, 23], [10, 25], [10, 27], [10, 28], [10, 32], [10, 33], [10, 35], [10, 37], [10, 39], [10, 41], [10, 43], [10, 45], [10, 47], [10, 48], [10, 49], [11, 12], [11, 14], [11, 16], [11, 17], [11, 19], [11, 21], [11, 22], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 30], [11, 32], [11, 33], [11, 34], [11, 37], [11, 38], [11, 42], [11, 43], [11, 44], [11, 45], [11, 46], [11, 49], [12, 14], [12, 15], [12, 17], [12, 19], [12, 22], [12, 23], [12, 24], [12, 25], [12, 30], [12, 31], [12, 32], [12, 33], [12, 34], [12, 37], [12, 38], [12, 40], [12, 41], [12, 42], [12, 43], [12, 45], [12, 46], [12, 47], [12, 48], [13, 17], [13, 18], [13, 19], [13, 20], [13, 22], [13, 25], [13, 26], [13, 29], [13, 34], [13, 35], [13, 36], [13, 37], [13, 38], [13, 40], [13, 43], [13, 44], [13, 45], [13, 46], [14, 18], [14, 19], [14, 20], [14, 24], [14, 26], [14, 28], [14, 30], [14, 31], [14, 33], [14, 34], [14, 35], [14, 36], [14, 38], [14, 43], [14, 45], [14, 46], [14, 47], [14, 48], [14, 49], [15, 17], [15, 18], [15, 19], [15, 20], [15, 22], [15, 25], [15, 28], [15, 29], [15, 31], [15, 32], [15, 33], [15, 35], [15, 37], [15, 38], [15, 39], [15, 40], [15, 41], [15, 45], [15, 49], [16, 20], [16, 21], [16, 23], [16, 24], [16, 26], [16, 27], [16, 29], [16, 32], [16, 33], [16, 36], [16, 37], [16, 38], [16, 40], [16, 45], [16, 48], [16, 49], [17, 20], [17, 21], [17, 22], [17, 24], [17, 27], [17, 29], [17, 31], [17, 32], [17, 34], [17, 35], [17, 36], [17, 39], [17, 40], [17, 43], [17, 45], [17, 46], [17, 47], [17, 48], [17, 49], [18, 20], [18, 21], [18, 23], [18, 28], [18, 29], [18, 31], [18, 33], [18, 34], [18, 36], [18, 37], [18, 38], [18, 40], [18, 42], [18, 43], [18, 45], [18, 46], [18, 47], [18, 48], [19, 23], [19, 25], [19, 26], [19, 27], [19, 28], [19, 30], [19, 31], [19, 33], [19, 34], [19, 36], [19, 37], [19, 38], [19, 39], [19, 41], [19, 42], [19, 43], [19, 44], [19, 45], [19, 46], [19, 47], [19, 48], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 28], [20, 29], [20, 30], [20, 33], [20, 35], [20, 36], [20, 37], [20, 38], [20, 39], [20, 40], [20, 41], [20, 43], [20, 45], [20, 47], [20, 48], [20, 49], [21, 22], [21, 26], [21, 29], [21, 32], [21, 33], [21, 34], [21, 36], [21, 37], [21, 38], [21, 40], [21, 41], [21, 42], [21, 43], [21, 44], [21, 45], [21, 49], [22, 25], [22, 26], [22, 28], [22, 30], [22, 31], [22, 32], [22, 34], [22, 37], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 43], [22, 45], [22, 47], [22, 48], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 34], [23, 37], [23, 39], [23, 40], [23, 42], [23, 43], [23, 45], [23, 47], [23, 48], [23, 49], [24, 26], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 36], [24, 37], [24, 38], [24, 39], [24, 40], [24, 43], [24, 45], [24, 46], [24, 48], [24, 49], [25, 26], [25, 27], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [25, 36], [25, 37], [25, 39], [25, 40], [25, 41], [25, 45], [25, 46], [25, 47], [25, 48], [25, 49], [26, 30], [26, 31], [26, 32], [26, 33], [26, 35], [26, 38], [26, 39], [26, 40], [26, 44], [26, 46], [26, 48], [26, 49], [27, 29], [27, 30], [27, 33], [27, 38], [27, 39], [27, 42], [27, 45], [27, 46], [27, 47], [27, 48], [27, 49], [28, 32], [28, 33], [28, 34], [28, 35], [28, 36], [28, 39], [28, 40], [28, 41], [28, 42], [28, 44], [28, 47], [28, 49], [29, 33], [29, 34], [29, 35], [29, 36], [29, 38], [29, 39], [29, 40], [29, 42], [29, 43], [29, 45], [29, 46], [29, 47], [30, 31], [30, 32], [30, 33], [30, 34], [30, 35], [30, 36], [30, 38], [30, 39], [30, 40], [30, 42], [30, 44], [30, 45], [30, 46], [30, 49], [31, 32], [31, 34], [31, 35], [31, 37], [31, 38], [31, 39], [31, 41], [31, 42], [31, 43], [31, 44], [31, 48], [31, 49], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 42], [32, 45], [32, 46], [32, 48], [33, 36], [33, 37], [33, 39], [33, 40], [33, 41], [33, 43], [33, 44], [33, 45], [33, 49], [34, 35], [34, 36], [34, 41], [34, 44], [34, 47], [34, 48], [34, 49], [35, 39], [35, 40], [35, 42], [35, 43], [35, 46], [35, 47], [35, 48], [36, 37], [36, 38], [36, 39], [36, 40], [36, 41], [36, 43], [36, 44], [36, 45], [36, 48], [37, 39], [37, 40], [37, 41], [37, 43], [37, 44], [37, 45], [37, 48], [38, 41], [38, 42], [38, 43], [38, 44], [38, 45], [38, 48], [39, 40], [39, 41], [39, 42], [39, 45], [39, 47], [39, 48], [40, 41], [40, 43], [40, 45], [40, 46], [40, 47], [40, 49], [41, 42], [41, 45], [41, 46], [41, 47], [41, 49], [42, 44], [42, 45], [42, 47], [42, 48], [42, 49], [43, 44], [43, 47], [43, 48], [43, 49], [44, 45], [44, 47], [44, 48], [44, 49], [45, 47], [45, 48], [46, 47], [46, 48], [47, 48]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l3-s3/tests/run.py b/tasks/construct-mc-max-clique-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-max-clique-l3-s3/tests/test.sh b/tasks/construct-mc-max-clique-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-max-clique-l3-s4/environment/Dockerfile b/tasks/construct-mc-max-clique-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-max-clique-l3-s4/environment/instance.json b/tasks/construct-mc-max-clique-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..144d0be5c3966670f2c406a1e581328342e44c65 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 5, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 8], [0, 11], [0, 12], [0, 15], [0, 17], [0, 18], [0, 19], [0, 20], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 30], [0, 32], [0, 34], [0, 36], [0, 38], [0, 39], [0, 40], [0, 41], [0, 43], [0, 44], [0, 45], [0, 46], [0, 47], [0, 49], [0, 52], [0, 54], [0, 55], [1, 2], [1, 7], [1, 8], [1, 9], [1, 10], [1, 12], [1, 13], [1, 14], [1, 15], [1, 17], [1, 20], [1, 22], [1, 23], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 33], [1, 36], [1, 37], [1, 38], [1, 39], [1, 41], [1, 44], [1, 46], [1, 47], [1, 48], [1, 49], [1, 51], [1, 52], [1, 53], [1, 54], [2, 5], [2, 7], [2, 11], [2, 13], [2, 14], [2, 16], [2, 19], [2, 21], [2, 23], [2, 25], [2, 26], [2, 28], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 36], [2, 40], [2, 42], [2, 43], [2, 44], [2, 45], [2, 46], [2, 48], [2, 49], [2, 50], [2, 53], [2, 54], [2, 55], [3, 4], [3, 5], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 14], [3, 15], [3, 20], [3, 21], [3, 22], [3, 24], [3, 26], [3, 27], [3, 31], [3, 32], [3, 34], [3, 35], [3, 38], [3, 39], [3, 41], [3, 45], [3, 46], [3, 49], [3, 50], [3, 51], [3, 54], [4, 5], [4, 6], [4, 7], [4, 10], [4, 11], [4, 13], [4, 14], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 24], [4, 25], [4, 29], [4, 30], [4, 31], [4, 35], [4, 36], [4, 37], [4, 40], [4, 42], [4, 43], [4, 44], [4, 46], [4, 47], [4, 48], [4, 49], [4, 50], [4, 52], [4, 53], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 18], [5, 19], [5, 20], [5, 21], [5, 23], [5, 26], [5, 27], [5, 28], [5, 29], [5, 30], [5, 33], [5, 35], [5, 41], [5, 42], [5, 45], [5, 47], [5, 49], [5, 50], [5, 51], [5, 52], [5, 54], [5, 55], [6, 10], [6, 11], [6, 12], [6, 14], [6, 15], [6, 17], [6, 19], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [6, 27], [6, 28], [6, 30], [6, 32], [6, 33], [6, 34], [6, 35], [6, 36], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 45], [6, 47], [6, 49], [6, 50], [6, 51], [6, 52], [6, 53], [6, 54], [6, 55], [7, 8], [7, 9], [7, 10], [7, 12], [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, 30], [7, 31], [7, 33], [7, 35], [7, 36], [7, 37], [7, 38], [7, 39], [7, 40], [7, 42], [7, 43], [7, 44], [7, 45], [7, 47], [7, 49], [7, 50], [7, 52], [7, 53], [8, 9], [8, 10], [8, 11], [8, 15], [8, 17], [8, 18], [8, 19], [8, 21], [8, 22], [8, 23], [8, 25], [8, 27], [8, 28], [8, 29], [8, 30], [8, 34], [8, 36], [8, 37], [8, 38], [8, 39], [8, 40], [8, 41], [8, 42], [8, 43], [8, 44], [8, 45], [8, 47], [8, 48], [8, 50], [8, 55], [9, 10], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 19], [9, 21], [9, 25], [9, 26], [9, 27], [9, 30], [9, 31], [9, 32], [9, 35], [9, 36], [9, 37], [9, 38], [9, 40], [9, 41], [9, 43], [9, 44], [9, 46], [9, 47], [9, 48], [9, 49], [9, 50], [9, 51], [9, 53], [9, 54], [9, 55], [10, 13], [10, 14], [10, 15], [10, 18], [10, 19], [10, 21], [10, 23], [10, 24], [10, 25], [10, 27], [10, 28], [10, 29], [10, 32], [10, 34], [10, 36], [10, 37], [10, 42], [10, 43], [10, 44], [10, 47], [10, 52], [10, 53], [11, 12], [11, 13], [11, 16], [11, 17], [11, 18], [11, 24], [11, 25], [11, 27], [11, 34], [11, 36], [11, 38], [11, 40], [11, 41], [11, 42], [11, 43], [11, 44], [11, 46], [11, 48], [11, 49], [11, 50], [11, 52], [11, 53], [11, 55], [12, 14], [12, 16], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 26], [12, 27], [12, 28], [12, 30], [12, 33], [12, 36], [12, 38], [12, 39], [12, 41], [12, 42], [12, 43], [12, 44], [12, 45], [12, 46], [12, 47], [12, 48], [12, 49], [12, 50], [12, 51], [12, 53], [12, 54], [12, 55], [13, 14], [13, 15], [13, 17], [13, 20], [13, 21], [13, 25], [13, 26], [13, 27], [13, 28], [13, 29], [13, 30], [13, 33], [13, 34], [13, 35], [13, 38], [13, 39], [13, 41], [13, 42], [13, 44], [13, 45], [13, 46], [13, 47], [13, 48], [13, 50], [13, 51], [13, 53], [13, 54], [14, 15], [14, 16], [14, 17], [14, 18], [14, 21], [14, 23], [14, 25], [14, 26], [14, 28], [14, 30], [14, 31], [14, 32], [14, 34], [14, 37], [14, 39], [14, 40], [14, 44], [14, 48], [14, 49], [14, 50], [14, 53], [14, 54], [14, 55], [15, 17], [15, 19], [15, 20], [15, 22], [15, 23], [15, 26], [15, 28], [15, 29], [15, 31], [15, 33], [15, 34], [15, 35], [15, 40], [15, 42], [15, 46], [15, 47], [15, 49], [15, 51], [15, 52], [15, 54], [15, 55], [16, 17], [16, 18], [16, 19], [16, 22], [16, 23], [16, 27], [16, 28], [16, 32], [16, 33], [16, 34], [16, 35], [16, 38], [16, 39], [16, 45], [16, 46], [16, 47], [16, 49], [16, 52], [16, 53], [16, 54], [16, 55], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 25], [17, 26], [17, 27], [17, 30], [17, 31], [17, 32], [17, 33], [17, 35], [17, 36], [17, 37], [17, 39], [17, 40], [17, 42], [17, 45], [17, 46], [17, 47], [17, 48], [17, 49], [17, 50], [17, 51], [17, 52], [17, 53], [17, 55], [18, 19], [18, 20], [18, 21], [18, 22], [18, 24], [18, 25], [18, 27], [18, 30], [18, 31], [18, 32], [18, 35], [18, 36], [18, 37], [18, 38], [18, 39], [18, 40], [18, 41], [18, 45], [18, 46], [18, 47], [18, 48], [18, 50], [18, 51], [18, 54], [18, 55], [19, 21], [19, 22], [19, 23], [19, 24], [19, 30], [19, 32], [19, 33], [19, 34], [19, 36], [19, 37], [19, 38], [19, 39], [19, 40], [19, 41], [19, 43], [19, 45], [19, 46], [19, 50], [19, 51], [19, 52], [19, 54], [20, 21], [20, 23], [20, 24], [20, 25], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 34], [20, 35], [20, 39], [20, 43], [20, 44], [20, 45], [20, 46], [20, 48], [20, 49], [20, 51], [20, 52], [20, 53], [20, 54], [20, 55], [21, 22], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 34], [21, 35], [21, 36], [21, 38], [21, 40], [21, 42], [21, 43], [21, 44], [21, 46], [21, 49], [21, 50], [21, 51], [21, 53], [21, 54], [22, 26], [22, 27], [22, 31], [22, 32], [22, 33], [22, 34], [22, 36], [22, 37], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 44], [22, 46], [22, 48], [22, 49], [22, 50], [22, 52], [22, 53], [23, 24], [23, 26], [23, 27], [23, 28], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [23, 37], [23, 38], [23, 41], [23, 42], [23, 43], [23, 46], [23, 47], [23, 48], [23, 49], [23, 50], [23, 51], [23, 52], [24, 26], [24, 27], [24, 29], [24, 33], [24, 36], [24, 37], [24, 38], [24, 39], [24, 40], [24, 44], [24, 46], [24, 47], [24, 48], [24, 49], [24, 50], [24, 51], [24, 52], [24, 55], [25, 26], [25, 27], [25, 28], [25, 31], [25, 34], [25, 35], [25, 37], [25, 38], [25, 39], [25, 41], [25, 43], [25, 45], [25, 46], [25, 47], [25, 49], [25, 51], [25, 52], [25, 54], [25, 55], [26, 28], [26, 30], [26, 36], [26, 38], [26, 39], [26, 43], [26, 45], [26, 47], [26, 51], [26, 52], [26, 53], [26, 54], [27, 29], [27, 31], [27, 34], [27, 35], [27, 36], [27, 38], [27, 39], [27, 40], [27, 41], [27, 42], [27, 44], [27, 47], [27, 50], [27, 53], [27, 55], [28, 29], [28, 32], [28, 34], [28, 35], [28, 36], [28, 38], [28, 39], [28, 40], [28, 41], [28, 44], [28, 45], [28, 47], [28, 50], [28, 53], [28, 54], [28, 55], [29, 30], [29, 31], [29, 35], [29, 36], [29, 37], [29, 39], [29, 41], [29, 42], [29, 49], [29, 51], [29, 53], [30, 31], [30, 32], [30, 33], [30, 34], [30, 36], [30, 37], [30, 38], [30, 39], [30, 42], [30, 45], [30, 46], [30, 49], [30, 50], [30, 53], [31, 33], [31, 34], [31, 35], [31, 37], [31, 40], [31, 41], [31, 43], [31, 44], [31, 48], [31, 50], [31, 51], [31, 52], [31, 53], [31, 54], [31, 55], [32, 37], [32, 38], [32, 40], [32, 41], [32, 44], [32, 47], [32, 49], [32, 50], [32, 51], [32, 52], [32, 53], [32, 55], [33, 34], [33, 35], [33, 36], [33, 37], [33, 41], [33, 42], [33, 43], [33, 44], [33, 46], [33, 48], [33, 50], [33, 51], [33, 52], [33, 53], [34, 35], [34, 36], [34, 37], [34, 38], [34, 40], [34, 42], [34, 44], [34, 45], [34, 48], [34, 49], [34, 50], [34, 53], [34, 54], [35, 36], [35, 37], [35, 38], [35, 39], [35, 41], [35, 42], [35, 46], [35, 47], [35, 49], [35, 52], [35, 54], [35, 55], [36, 37], [36, 42], [36, 43], [36, 46], [36, 48], [36, 49], [36, 50], [36, 51], [36, 52], [36, 53], [36, 54], [36, 55], [37, 41], [37, 42], [37, 43], [37, 44], [37, 45], [37, 46], [37, 47], [37, 49], [37, 50], [37, 51], [37, 52], [37, 55], [38, 40], [38, 42], [38, 43], [38, 44], [38, 45], [38, 46], [38, 48], [38, 49], [38, 50], [38, 54], [39, 40], [39, 41], [39, 43], [39, 46], [39, 47], [39, 48], [39, 49], [39, 50], [39, 52], [39, 54], [39, 55], [40, 42], [40, 43], [40, 44], [40, 45], [40, 47], [40, 48], [40, 50], [40, 52], [40, 54], [41, 44], [41, 45], [41, 49], [41, 50], [41, 52], [41, 53], [41, 54], [42, 44], [42, 45], [42, 47], [42, 49], [42, 55], [43, 44], [43, 45], [43, 46], [43, 48], [43, 49], [43, 50], [43, 51], [43, 53], [43, 54], [43, 55], [44, 46], [44, 47], [44, 48], [44, 50], [44, 51], [44, 54], [45, 46], [45, 47], [45, 48], [45, 50], [45, 53], [45, 54], [46, 47], [46, 48], [46, 49], [46, 51], [46, 53], [46, 54], [47, 48], [47, 49], [47, 50], [47, 52], [48, 50], [48, 51], [48, 52], [49, 50], [49, 53], [49, 54], [49, 55], [50, 51], [50, 52], [50, 53], [50, 55], [51, 52], [51, 53], [51, 54], [51, 55], [52, 53], [53, 54]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l3-s4/solution/solve.sh b/tasks/construct-mc-max-clique-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ecff296790066e735a17c20fa68616ac2ee86f46 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [43, 44, 46, 48, 51]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-clique-l3-s4/tests/check.py b/tasks/construct-mc-max-clique-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3f70dbd5b155a3514c2102aa4ad460201495210 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s4/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-s4/tests/instance.json b/tasks/construct-mc-max-clique-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..144d0be5c3966670f2c406a1e581328342e44c65 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 5, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 8], [0, 11], [0, 12], [0, 15], [0, 17], [0, 18], [0, 19], [0, 20], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 30], [0, 32], [0, 34], [0, 36], [0, 38], [0, 39], [0, 40], [0, 41], [0, 43], [0, 44], [0, 45], [0, 46], [0, 47], [0, 49], [0, 52], [0, 54], [0, 55], [1, 2], [1, 7], [1, 8], [1, 9], [1, 10], [1, 12], [1, 13], [1, 14], [1, 15], [1, 17], [1, 20], [1, 22], [1, 23], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 33], [1, 36], [1, 37], [1, 38], [1, 39], [1, 41], [1, 44], [1, 46], [1, 47], [1, 48], [1, 49], [1, 51], [1, 52], [1, 53], [1, 54], [2, 5], [2, 7], [2, 11], [2, 13], [2, 14], [2, 16], [2, 19], [2, 21], [2, 23], [2, 25], [2, 26], [2, 28], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 36], [2, 40], [2, 42], [2, 43], [2, 44], [2, 45], [2, 46], [2, 48], [2, 49], [2, 50], [2, 53], [2, 54], [2, 55], [3, 4], [3, 5], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 14], [3, 15], [3, 20], [3, 21], [3, 22], [3, 24], [3, 26], [3, 27], [3, 31], [3, 32], [3, 34], [3, 35], [3, 38], [3, 39], [3, 41], [3, 45], [3, 46], [3, 49], [3, 50], [3, 51], [3, 54], [4, 5], [4, 6], [4, 7], [4, 10], [4, 11], [4, 13], [4, 14], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 24], [4, 25], [4, 29], [4, 30], [4, 31], [4, 35], [4, 36], [4, 37], [4, 40], [4, 42], [4, 43], [4, 44], [4, 46], [4, 47], [4, 48], [4, 49], [4, 50], [4, 52], [4, 53], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 18], [5, 19], [5, 20], [5, 21], [5, 23], [5, 26], [5, 27], [5, 28], [5, 29], [5, 30], [5, 33], [5, 35], [5, 41], [5, 42], [5, 45], [5, 47], [5, 49], [5, 50], [5, 51], [5, 52], [5, 54], [5, 55], [6, 10], [6, 11], [6, 12], [6, 14], [6, 15], [6, 17], [6, 19], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [6, 27], [6, 28], [6, 30], [6, 32], [6, 33], [6, 34], [6, 35], [6, 36], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 45], [6, 47], [6, 49], [6, 50], [6, 51], [6, 52], [6, 53], [6, 54], [6, 55], [7, 8], [7, 9], [7, 10], [7, 12], [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, 30], [7, 31], [7, 33], [7, 35], [7, 36], [7, 37], [7, 38], [7, 39], [7, 40], [7, 42], [7, 43], [7, 44], [7, 45], [7, 47], [7, 49], [7, 50], [7, 52], [7, 53], [8, 9], [8, 10], [8, 11], [8, 15], [8, 17], [8, 18], [8, 19], [8, 21], [8, 22], [8, 23], [8, 25], [8, 27], [8, 28], [8, 29], [8, 30], [8, 34], [8, 36], [8, 37], [8, 38], [8, 39], [8, 40], [8, 41], [8, 42], [8, 43], [8, 44], [8, 45], [8, 47], [8, 48], [8, 50], [8, 55], [9, 10], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 19], [9, 21], [9, 25], [9, 26], [9, 27], [9, 30], [9, 31], [9, 32], [9, 35], [9, 36], [9, 37], [9, 38], [9, 40], [9, 41], [9, 43], [9, 44], [9, 46], [9, 47], [9, 48], [9, 49], [9, 50], [9, 51], [9, 53], [9, 54], [9, 55], [10, 13], [10, 14], [10, 15], [10, 18], [10, 19], [10, 21], [10, 23], [10, 24], [10, 25], [10, 27], [10, 28], [10, 29], [10, 32], [10, 34], [10, 36], [10, 37], [10, 42], [10, 43], [10, 44], [10, 47], [10, 52], [10, 53], [11, 12], [11, 13], [11, 16], [11, 17], [11, 18], [11, 24], [11, 25], [11, 27], [11, 34], [11, 36], [11, 38], [11, 40], [11, 41], [11, 42], [11, 43], [11, 44], [11, 46], [11, 48], [11, 49], [11, 50], [11, 52], [11, 53], [11, 55], [12, 14], [12, 16], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [12, 24], [12, 26], [12, 27], [12, 28], [12, 30], [12, 33], [12, 36], [12, 38], [12, 39], [12, 41], [12, 42], [12, 43], [12, 44], [12, 45], [12, 46], [12, 47], [12, 48], [12, 49], [12, 50], [12, 51], [12, 53], [12, 54], [12, 55], [13, 14], [13, 15], [13, 17], [13, 20], [13, 21], [13, 25], [13, 26], [13, 27], [13, 28], [13, 29], [13, 30], [13, 33], [13, 34], [13, 35], [13, 38], [13, 39], [13, 41], [13, 42], [13, 44], [13, 45], [13, 46], [13, 47], [13, 48], [13, 50], [13, 51], [13, 53], [13, 54], [14, 15], [14, 16], [14, 17], [14, 18], [14, 21], [14, 23], [14, 25], [14, 26], [14, 28], [14, 30], [14, 31], [14, 32], [14, 34], [14, 37], [14, 39], [14, 40], [14, 44], [14, 48], [14, 49], [14, 50], [14, 53], [14, 54], [14, 55], [15, 17], [15, 19], [15, 20], [15, 22], [15, 23], [15, 26], [15, 28], [15, 29], [15, 31], [15, 33], [15, 34], [15, 35], [15, 40], [15, 42], [15, 46], [15, 47], [15, 49], [15, 51], [15, 52], [15, 54], [15, 55], [16, 17], [16, 18], [16, 19], [16, 22], [16, 23], [16, 27], [16, 28], [16, 32], [16, 33], [16, 34], [16, 35], [16, 38], [16, 39], [16, 45], [16, 46], [16, 47], [16, 49], [16, 52], [16, 53], [16, 54], [16, 55], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 25], [17, 26], [17, 27], [17, 30], [17, 31], [17, 32], [17, 33], [17, 35], [17, 36], [17, 37], [17, 39], [17, 40], [17, 42], [17, 45], [17, 46], [17, 47], [17, 48], [17, 49], [17, 50], [17, 51], [17, 52], [17, 53], [17, 55], [18, 19], [18, 20], [18, 21], [18, 22], [18, 24], [18, 25], [18, 27], [18, 30], [18, 31], [18, 32], [18, 35], [18, 36], [18, 37], [18, 38], [18, 39], [18, 40], [18, 41], [18, 45], [18, 46], [18, 47], [18, 48], [18, 50], [18, 51], [18, 54], [18, 55], [19, 21], [19, 22], [19, 23], [19, 24], [19, 30], [19, 32], [19, 33], [19, 34], [19, 36], [19, 37], [19, 38], [19, 39], [19, 40], [19, 41], [19, 43], [19, 45], [19, 46], [19, 50], [19, 51], [19, 52], [19, 54], [20, 21], [20, 23], [20, 24], [20, 25], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 34], [20, 35], [20, 39], [20, 43], [20, 44], [20, 45], [20, 46], [20, 48], [20, 49], [20, 51], [20, 52], [20, 53], [20, 54], [20, 55], [21, 22], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 34], [21, 35], [21, 36], [21, 38], [21, 40], [21, 42], [21, 43], [21, 44], [21, 46], [21, 49], [21, 50], [21, 51], [21, 53], [21, 54], [22, 26], [22, 27], [22, 31], [22, 32], [22, 33], [22, 34], [22, 36], [22, 37], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 44], [22, 46], [22, 48], [22, 49], [22, 50], [22, 52], [22, 53], [23, 24], [23, 26], [23, 27], [23, 28], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [23, 37], [23, 38], [23, 41], [23, 42], [23, 43], [23, 46], [23, 47], [23, 48], [23, 49], [23, 50], [23, 51], [23, 52], [24, 26], [24, 27], [24, 29], [24, 33], [24, 36], [24, 37], [24, 38], [24, 39], [24, 40], [24, 44], [24, 46], [24, 47], [24, 48], [24, 49], [24, 50], [24, 51], [24, 52], [24, 55], [25, 26], [25, 27], [25, 28], [25, 31], [25, 34], [25, 35], [25, 37], [25, 38], [25, 39], [25, 41], [25, 43], [25, 45], [25, 46], [25, 47], [25, 49], [25, 51], [25, 52], [25, 54], [25, 55], [26, 28], [26, 30], [26, 36], [26, 38], [26, 39], [26, 43], [26, 45], [26, 47], [26, 51], [26, 52], [26, 53], [26, 54], [27, 29], [27, 31], [27, 34], [27, 35], [27, 36], [27, 38], [27, 39], [27, 40], [27, 41], [27, 42], [27, 44], [27, 47], [27, 50], [27, 53], [27, 55], [28, 29], [28, 32], [28, 34], [28, 35], [28, 36], [28, 38], [28, 39], [28, 40], [28, 41], [28, 44], [28, 45], [28, 47], [28, 50], [28, 53], [28, 54], [28, 55], [29, 30], [29, 31], [29, 35], [29, 36], [29, 37], [29, 39], [29, 41], [29, 42], [29, 49], [29, 51], [29, 53], [30, 31], [30, 32], [30, 33], [30, 34], [30, 36], [30, 37], [30, 38], [30, 39], [30, 42], [30, 45], [30, 46], [30, 49], [30, 50], [30, 53], [31, 33], [31, 34], [31, 35], [31, 37], [31, 40], [31, 41], [31, 43], [31, 44], [31, 48], [31, 50], [31, 51], [31, 52], [31, 53], [31, 54], [31, 55], [32, 37], [32, 38], [32, 40], [32, 41], [32, 44], [32, 47], [32, 49], [32, 50], [32, 51], [32, 52], [32, 53], [32, 55], [33, 34], [33, 35], [33, 36], [33, 37], [33, 41], [33, 42], [33, 43], [33, 44], [33, 46], [33, 48], [33, 50], [33, 51], [33, 52], [33, 53], [34, 35], [34, 36], [34, 37], [34, 38], [34, 40], [34, 42], [34, 44], [34, 45], [34, 48], [34, 49], [34, 50], [34, 53], [34, 54], [35, 36], [35, 37], [35, 38], [35, 39], [35, 41], [35, 42], [35, 46], [35, 47], [35, 49], [35, 52], [35, 54], [35, 55], [36, 37], [36, 42], [36, 43], [36, 46], [36, 48], [36, 49], [36, 50], [36, 51], [36, 52], [36, 53], [36, 54], [36, 55], [37, 41], [37, 42], [37, 43], [37, 44], [37, 45], [37, 46], [37, 47], [37, 49], [37, 50], [37, 51], [37, 52], [37, 55], [38, 40], [38, 42], [38, 43], [38, 44], [38, 45], [38, 46], [38, 48], [38, 49], [38, 50], [38, 54], [39, 40], [39, 41], [39, 43], [39, 46], [39, 47], [39, 48], [39, 49], [39, 50], [39, 52], [39, 54], [39, 55], [40, 42], [40, 43], [40, 44], [40, 45], [40, 47], [40, 48], [40, 50], [40, 52], [40, 54], [41, 44], [41, 45], [41, 49], [41, 50], [41, 52], [41, 53], [41, 54], [42, 44], [42, 45], [42, 47], [42, 49], [42, 55], [43, 44], [43, 45], [43, 46], [43, 48], [43, 49], [43, 50], [43, 51], [43, 53], [43, 54], [43, 55], [44, 46], [44, 47], [44, 48], [44, 50], [44, 51], [44, 54], [45, 46], [45, 47], [45, 48], [45, 50], [45, 53], [45, 54], [46, 47], [46, 48], [46, 49], [46, 51], [46, 53], [46, 54], [47, 48], [47, 49], [47, 50], [47, 52], [48, 50], [48, 51], [48, 52], [49, 50], [49, 53], [49, 54], [49, 55], [50, 51], [50, 52], [50, 53], [50, 55], [51, 52], [51, 53], [51, 54], [51, 55], [52, 53], [53, 54]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l3-s4/tests/run.py b/tasks/construct-mc-max-clique-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-max-clique-l3-s4/tests/test.sh b/tasks/construct-mc-max-clique-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-clique-l3-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-max-independent-set-l4-s0/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-max-independent-set-l4-s0/environment/instance.json b/tasks/construct-mc-max-independent-set-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..33433c0aa56e9e07e42d2bef1dbed5bd79ce54fc --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 3], [0, 4], [0, 6], [0, 8], [0, 10], [0, 18], [0, 19], [0, 20], [0, 21], [0, 26], [0, 29], [0, 34], [0, 36], [0, 41], [0, 45], [0, 49], [0, 53], [0, 56], [0, 57], [0, 58], [0, 59], [1, 2], [1, 5], [1, 7], [1, 9], [1, 15], [1, 16], [1, 17], [1, 21], [1, 28], [1, 31], [1, 35], [1, 39], [1, 48], [1, 51], [1, 59], [2, 6], [2, 8], [2, 9], [2, 10], [2, 13], [2, 19], [2, 24], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 36], [2, 41], [2, 43], [2, 46], [2, 48], [2, 59], [3, 6], [3, 9], [3, 10], [3, 20], [3, 27], [3, 31], [3, 34], [3, 40], [3, 42], [3, 45], [3, 46], [3, 47], [3, 50], [3, 53], [4, 8], [4, 10], [4, 13], [4, 16], [4, 26], [4, 31], [4, 32], [4, 35], [4, 40], [4, 41], [4, 42], [4, 45], [4, 48], [4, 51], [4, 54], [4, 57], [4, 59], [5, 7], [5, 9], [5, 10], [5, 13], [5, 14], [5, 22], [5, 23], [5, 33], [5, 34], [5, 40], [5, 41], [5, 43], [5, 47], [5, 48], [5, 52], [6, 11], [6, 15], [6, 16], [6, 24], [6, 32], [6, 37], [6, 41], [6, 42], [6, 43], [6, 46], [6, 48], [6, 52], [6, 53], [6, 59], [7, 8], [7, 9], [7, 17], [7, 19], [7, 20], [7, 23], [7, 26], [7, 29], [7, 30], [7, 37], [7, 43], [7, 47], [7, 50], [7, 53], [7, 55], [7, 56], [7, 58], [8, 17], [8, 24], [8, 27], [8, 28], [8, 31], [8, 35], [8, 39], [8, 49], [8, 52], [8, 53], [9, 10], [9, 11], [9, 21], [9, 24], [9, 25], [9, 28], [9, 30], [9, 31], [9, 32], [9, 37], [9, 38], [9, 42], [9, 43], [9, 44], [9, 46], [9, 47], [9, 50], [9, 52], [9, 56], [10, 15], [10, 19], [10, 29], [10, 31], [10, 32], [10, 34], [10, 42], [10, 44], [10, 47], [10, 55], [10, 56], [11, 12], [11, 18], [11, 22], [11, 24], [11, 31], [11, 32], [11, 37], [11, 38], [11, 39], [11, 42], [11, 47], [11, 53], [11, 54], [12, 13], [12, 15], [12, 17], [12, 20], [12, 22], [12, 23], [12, 25], [12, 30], [12, 33], [12, 35], [12, 36], [12, 45], [12, 47], [12, 48], [12, 50], [12, 52], [12, 56], [12, 57], [12, 59], [13, 17], [13, 18], [13, 20], [13, 40], [13, 41], [13, 48], [14, 22], [14, 23], [14, 25], [14, 40], [14, 41], [14, 44], [14, 46], [14, 48], [14, 49], [14, 53], [14, 54], [14, 55], [14, 57], [15, 18], [15, 21], [15, 22], [15, 27], [15, 30], [15, 34], [15, 38], [15, 44], [15, 45], [15, 48], [15, 54], [15, 55], [15, 57], [15, 59], [16, 17], [16, 19], [16, 25], [16, 26], [16, 27], [16, 29], [16, 31], [16, 34], [16, 39], [16, 43], [16, 48], [16, 50], [16, 51], [16, 52], [16, 59], [17, 19], [17, 24], [17, 31], [17, 37], [17, 43], [17, 45], [17, 47], [17, 55], [17, 56], [17, 59], [18, 23], [18, 26], [18, 29], [18, 30], [18, 35], [18, 43], [18, 44], [18, 48], [18, 58], [19, 21], [19, 31], [19, 34], [19, 35], [19, 36], [19, 40], [19, 43], [19, 46], [19, 47], [19, 51], [19, 53], [19, 55], [19, 58], [20, 22], [20, 23], [20, 26], [20, 27], [20, 29], [20, 31], [20, 32], [20, 33], [20, 35], [20, 37], [20, 40], [20, 41], [20, 44], [20, 46], [20, 51], [20, 53], [20, 54], [20, 57], [21, 23], [21, 24], [21, 30], [21, 32], [21, 34], [21, 35], [21, 41], [21, 45], [21, 47], [21, 48], [21, 52], [21, 59], [22, 31], [22, 41], [23, 29], [23, 30], [23, 31], [23, 39], [23, 43], [23, 47], [23, 48], [23, 49], [23, 51], [23, 58], [24, 27], [24, 29], [24, 31], [24, 34], [24, 35], [24, 36], [24, 44], [24, 49], [25, 30], [25, 35], [25, 36], [25, 39], [25, 45], [25, 56], [25, 59], [26, 27], [26, 31], [26, 32], [26, 34], [26, 35], [26, 36], [26, 39], [26, 45], [26, 49], [26, 50], [26, 51], [26, 52], [26, 59], [27, 29], [27, 31], [27, 35], [27, 37], [27, 49], [27, 51], [27, 57], [28, 33], [28, 52], [28, 53], [29, 32], [29, 38], [29, 39], [29, 44], [29, 46], [29, 51], [29, 52], [29, 53], [29, 56], [29, 59], [30, 32], [30, 35], [30, 37], [30, 42], [30, 48], [30, 49], [30, 51], [30, 57], [31, 34], [31, 35], [31, 40], [31, 47], [31, 51], [31, 52], [31, 53], [31, 56], [31, 59], [32, 36], [32, 40], [32, 46], [32, 56], [32, 58], [33, 35], [33, 39], [33, 46], [33, 48], [33, 50], [33, 53], [33, 59], [34, 38], [34, 45], [34, 49], [34, 52], [34, 53], [34, 56], [34, 57], [34, 58], [34, 59], [35, 38], [35, 41], [35, 43], [35, 46], [35, 53], [35, 55], [35, 56], [36, 37], [36, 38], [36, 40], [36, 46], [36, 49], [36, 53], [36, 58], [37, 48], [37, 51], [37, 53], [38, 40], [38, 43], [38, 49], [38, 52], [38, 56], [38, 58], [39, 40], [39, 44], [39, 47], [39, 49], [39, 50], [39, 51], [39, 52], [39, 59], [40, 43], [40, 45], [40, 47], [40, 48], [40, 49], [40, 54], [41, 45], [41, 49], [41, 50], [41, 53], [41, 56], [41, 57], [41, 58], [42, 44], [42, 51], [42, 54], [42, 56], [42, 57], [42, 58], [42, 59], [43, 50], [43, 54], [43, 55], [43, 57], [44, 49], [44, 52], [44, 53], [44, 55], [45, 48], [45, 52], [45, 53], [45, 55], [45, 59], [46, 47], [46, 54], [46, 58], [47, 53], [47, 59], [48, 51], [48, 54], [48, 59], [49, 52], [49, 57], [50, 51], [50, 52], [50, 57], [50, 58], [51, 57], [52, 53], [52, 54], [52, 59], [53, 54], [54, 56], [55, 56], [55, 57], [56, 58], [56, 59]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s0/solution/solve.sh b/tasks/construct-mc-max-independent-set-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b07ccae79bc75d7055a3906bda9ecd5378b495ed --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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' +{"independent_set": [1, 3, 8, 13, 19, 22, 23, 25, 33, 37, 38, 44, 54, 57]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l4-s0/tests/check.py b/tasks/construct-mc-max-independent-set-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s0/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-s0/tests/instance.json b/tasks/construct-mc-max-independent-set-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..33433c0aa56e9e07e42d2bef1dbed5bd79ce54fc --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 3], [0, 4], [0, 6], [0, 8], [0, 10], [0, 18], [0, 19], [0, 20], [0, 21], [0, 26], [0, 29], [0, 34], [0, 36], [0, 41], [0, 45], [0, 49], [0, 53], [0, 56], [0, 57], [0, 58], [0, 59], [1, 2], [1, 5], [1, 7], [1, 9], [1, 15], [1, 16], [1, 17], [1, 21], [1, 28], [1, 31], [1, 35], [1, 39], [1, 48], [1, 51], [1, 59], [2, 6], [2, 8], [2, 9], [2, 10], [2, 13], [2, 19], [2, 24], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 36], [2, 41], [2, 43], [2, 46], [2, 48], [2, 59], [3, 6], [3, 9], [3, 10], [3, 20], [3, 27], [3, 31], [3, 34], [3, 40], [3, 42], [3, 45], [3, 46], [3, 47], [3, 50], [3, 53], [4, 8], [4, 10], [4, 13], [4, 16], [4, 26], [4, 31], [4, 32], [4, 35], [4, 40], [4, 41], [4, 42], [4, 45], [4, 48], [4, 51], [4, 54], [4, 57], [4, 59], [5, 7], [5, 9], [5, 10], [5, 13], [5, 14], [5, 22], [5, 23], [5, 33], [5, 34], [5, 40], [5, 41], [5, 43], [5, 47], [5, 48], [5, 52], [6, 11], [6, 15], [6, 16], [6, 24], [6, 32], [6, 37], [6, 41], [6, 42], [6, 43], [6, 46], [6, 48], [6, 52], [6, 53], [6, 59], [7, 8], [7, 9], [7, 17], [7, 19], [7, 20], [7, 23], [7, 26], [7, 29], [7, 30], [7, 37], [7, 43], [7, 47], [7, 50], [7, 53], [7, 55], [7, 56], [7, 58], [8, 17], [8, 24], [8, 27], [8, 28], [8, 31], [8, 35], [8, 39], [8, 49], [8, 52], [8, 53], [9, 10], [9, 11], [9, 21], [9, 24], [9, 25], [9, 28], [9, 30], [9, 31], [9, 32], [9, 37], [9, 38], [9, 42], [9, 43], [9, 44], [9, 46], [9, 47], [9, 50], [9, 52], [9, 56], [10, 15], [10, 19], [10, 29], [10, 31], [10, 32], [10, 34], [10, 42], [10, 44], [10, 47], [10, 55], [10, 56], [11, 12], [11, 18], [11, 22], [11, 24], [11, 31], [11, 32], [11, 37], [11, 38], [11, 39], [11, 42], [11, 47], [11, 53], [11, 54], [12, 13], [12, 15], [12, 17], [12, 20], [12, 22], [12, 23], [12, 25], [12, 30], [12, 33], [12, 35], [12, 36], [12, 45], [12, 47], [12, 48], [12, 50], [12, 52], [12, 56], [12, 57], [12, 59], [13, 17], [13, 18], [13, 20], [13, 40], [13, 41], [13, 48], [14, 22], [14, 23], [14, 25], [14, 40], [14, 41], [14, 44], [14, 46], [14, 48], [14, 49], [14, 53], [14, 54], [14, 55], [14, 57], [15, 18], [15, 21], [15, 22], [15, 27], [15, 30], [15, 34], [15, 38], [15, 44], [15, 45], [15, 48], [15, 54], [15, 55], [15, 57], [15, 59], [16, 17], [16, 19], [16, 25], [16, 26], [16, 27], [16, 29], [16, 31], [16, 34], [16, 39], [16, 43], [16, 48], [16, 50], [16, 51], [16, 52], [16, 59], [17, 19], [17, 24], [17, 31], [17, 37], [17, 43], [17, 45], [17, 47], [17, 55], [17, 56], [17, 59], [18, 23], [18, 26], [18, 29], [18, 30], [18, 35], [18, 43], [18, 44], [18, 48], [18, 58], [19, 21], [19, 31], [19, 34], [19, 35], [19, 36], [19, 40], [19, 43], [19, 46], [19, 47], [19, 51], [19, 53], [19, 55], [19, 58], [20, 22], [20, 23], [20, 26], [20, 27], [20, 29], [20, 31], [20, 32], [20, 33], [20, 35], [20, 37], [20, 40], [20, 41], [20, 44], [20, 46], [20, 51], [20, 53], [20, 54], [20, 57], [21, 23], [21, 24], [21, 30], [21, 32], [21, 34], [21, 35], [21, 41], [21, 45], [21, 47], [21, 48], [21, 52], [21, 59], [22, 31], [22, 41], [23, 29], [23, 30], [23, 31], [23, 39], [23, 43], [23, 47], [23, 48], [23, 49], [23, 51], [23, 58], [24, 27], [24, 29], [24, 31], [24, 34], [24, 35], [24, 36], [24, 44], [24, 49], [25, 30], [25, 35], [25, 36], [25, 39], [25, 45], [25, 56], [25, 59], [26, 27], [26, 31], [26, 32], [26, 34], [26, 35], [26, 36], [26, 39], [26, 45], [26, 49], [26, 50], [26, 51], [26, 52], [26, 59], [27, 29], [27, 31], [27, 35], [27, 37], [27, 49], [27, 51], [27, 57], [28, 33], [28, 52], [28, 53], [29, 32], [29, 38], [29, 39], [29, 44], [29, 46], [29, 51], [29, 52], [29, 53], [29, 56], [29, 59], [30, 32], [30, 35], [30, 37], [30, 42], [30, 48], [30, 49], [30, 51], [30, 57], [31, 34], [31, 35], [31, 40], [31, 47], [31, 51], [31, 52], [31, 53], [31, 56], [31, 59], [32, 36], [32, 40], [32, 46], [32, 56], [32, 58], [33, 35], [33, 39], [33, 46], [33, 48], [33, 50], [33, 53], [33, 59], [34, 38], [34, 45], [34, 49], [34, 52], [34, 53], [34, 56], [34, 57], [34, 58], [34, 59], [35, 38], [35, 41], [35, 43], [35, 46], [35, 53], [35, 55], [35, 56], [36, 37], [36, 38], [36, 40], [36, 46], [36, 49], [36, 53], [36, 58], [37, 48], [37, 51], [37, 53], [38, 40], [38, 43], [38, 49], [38, 52], [38, 56], [38, 58], [39, 40], [39, 44], [39, 47], [39, 49], [39, 50], [39, 51], [39, 52], [39, 59], [40, 43], [40, 45], [40, 47], [40, 48], [40, 49], [40, 54], [41, 45], [41, 49], [41, 50], [41, 53], [41, 56], [41, 57], [41, 58], [42, 44], [42, 51], [42, 54], [42, 56], [42, 57], [42, 58], [42, 59], [43, 50], [43, 54], [43, 55], [43, 57], [44, 49], [44, 52], [44, 53], [44, 55], [45, 48], [45, 52], [45, 53], [45, 55], [45, 59], [46, 47], [46, 54], [46, 58], [47, 53], [47, 59], [48, 51], [48, 54], [48, 59], [49, 52], [49, 57], [50, 51], [50, 52], [50, 57], [50, 58], [51, 57], [52, 53], [52, 54], [52, 59], [53, 54], [54, 56], [55, 56], [55, 57], [56, 58], [56, 59]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s0/tests/run.py b/tasks/construct-mc-max-independent-set-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-max-independent-set-l4-s0/tests/test.sh b/tasks/construct-mc-max-independent-set-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-max-independent-set-l4-s7/tests/check.py b/tasks/construct-mc-max-independent-set-l4-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s7/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-s7/tests/instance.json b/tasks/construct-mc-max-independent-set-l4-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..114404eb4999b21ea80d0010efc4b152027897fd --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l4-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 60, "k": 14, "edges": [[0, 1], [0, 4], [0, 6], [0, 8], [0, 17], [0, 20], [0, 27], [0, 35], [0, 40], [0, 43], [0, 45], [0, 46], [0, 47], [0, 48], [0, 50], [0, 52], [0, 57], [1, 3], [1, 4], [1, 10], [1, 11], [1, 13], [1, 14], [1, 15], [1, 16], [1, 21], [1, 23], [1, 27], [1, 28], [1, 29], [1, 38], [1, 47], [1, 48], [1, 53], [1, 54], [1, 55], [1, 56], [1, 59], [2, 4], [2, 6], [2, 7], [2, 9], [2, 13], [2, 16], [2, 25], [2, 29], [2, 31], [2, 32], [2, 33], [2, 37], [2, 44], [2, 46], [2, 48], [2, 49], [3, 6], [3, 10], [3, 11], [3, 12], [3, 17], [3, 18], [3, 19], [3, 20], [3, 26], [3, 27], [3, 34], [3, 36], [3, 41], [3, 51], [3, 53], [4, 8], [4, 11], [4, 13], [4, 14], [4, 16], [4, 21], [4, 22], [4, 23], [4, 30], [4, 35], [4, 37], [4, 42], [4, 45], [4, 47], [4, 48], [5, 7], [5, 9], [5, 15], [5, 23], [5, 31], [5, 35], [5, 39], [5, 40], [5, 45], [5, 49], [5, 50], [5, 52], [5, 53], [5, 55], [5, 56], [5, 57], [6, 7], [6, 12], [6, 14], [6, 23], [6, 24], [6, 25], [6, 29], [6, 43], [6, 45], [6, 46], [6, 49], [6, 52], [6, 54], [7, 8], [7, 9], [7, 10], [7, 13], [7, 18], [7, 21], [7, 24], [7, 25], [7, 26], [7, 32], [7, 34], [7, 35], [7, 41], [7, 45], [7, 47], [8, 11], [8, 12], [8, 13], [8, 14], [8, 20], [8, 26], [8, 28], [8, 34], [8, 37], [8, 39], [8, 40], [8, 50], [8, 51], [8, 56], [9, 11], [9, 15], [9, 17], [9, 21], [9, 22], [9, 24], [9, 31], [9, 33], [9, 35], [9, 38], [9, 40], [9, 44], [9, 47], [9, 52], [9, 56], [9, 57], [10, 11], [10, 15], [10, 24], [10, 25], [10, 27], [10, 28], [10, 37], [10, 42], [10, 51], [10, 54], [10, 56], [11, 12], [11, 13], [11, 14], [11, 15], [11, 21], [11, 28], [11, 29], [11, 36], [11, 39], [11, 44], [11, 49], [11, 50], [11, 55], [12, 14], [12, 17], [12, 19], [12, 22], [12, 26], [12, 27], [12, 33], [12, 34], [12, 35], [12, 40], [12, 42], [12, 43], [12, 46], [12, 49], [13, 14], [13, 16], [13, 17], [13, 20], [13, 23], [13, 27], [13, 29], [13, 30], [13, 33], [13, 41], [13, 43], [13, 44], [13, 45], [13, 51], [13, 53], [13, 55], [13, 56], [13, 57], [13, 58], [14, 15], [14, 16], [14, 17], [14, 25], [14, 26], [14, 27], [14, 31], [14, 32], [14, 33], [14, 36], [14, 42], [14, 46], [14, 52], [14, 53], [14, 55], [14, 56], [14, 57], [14, 58], [14, 59], [15, 16], [15, 20], [15, 25], [15, 26], [15, 27], [15, 30], [15, 35], [15, 38], [15, 39], [15, 44], [15, 47], [15, 51], [15, 52], [15, 59], [16, 18], [16, 20], [16, 34], [16, 36], [16, 42], [16, 43], [16, 54], [16, 56], [17, 20], [17, 23], [17, 28], [17, 32], [17, 38], [17, 46], [17, 48], [17, 50], [17, 51], [17, 52], [17, 55], [18, 19], [18, 23], [18, 24], [18, 25], [18, 31], [18, 32], [18, 33], [18, 34], [18, 36], [18, 37], [18, 43], [18, 53], [19, 21], [19, 23], [19, 24], [19, 25], [19, 28], [19, 30], [19, 36], [19, 40], [19, 43], [19, 45], [19, 46], [19, 53], [19, 57], [20, 22], [20, 25], [20, 29], [20, 31], [20, 32], [20, 44], [20, 45], [20, 49], [20, 57], [20, 59], [21, 22], [21, 26], [21, 30], [21, 32], [21, 33], [21, 34], [21, 37], [21, 42], [21, 43], [21, 51], [21, 53], [21, 57], [21, 58], [21, 59], [22, 25], [22, 30], [22, 32], [22, 35], [22, 42], [23, 26], [23, 28], [23, 30], [23, 31], [23, 37], [23, 43], [23, 45], [23, 46], [23, 48], [23, 54], [23, 55], [23, 56], [23, 57], [23, 59], [24, 26], [24, 27], [24, 28], [24, 30], [24, 31], [24, 40], [24, 54], [24, 57], [24, 58], [25, 26], [25, 27], [25, 28], [25, 31], [25, 33], [25, 34], [25, 39], [25, 40], [25, 50], [25, 53], [26, 27], [26, 29], [26, 30], [26, 32], [26, 34], [26, 37], [26, 38], [26, 42], [26, 43], [26, 48], [26, 53], [26, 55], [27, 34], [27, 36], [27, 39], [27, 47], [27, 48], [27, 52], [27, 55], [27, 57], [27, 59], [28, 31], [28, 33], [28, 35], [28, 37], [28, 39], [28, 51], [28, 57], [29, 31], [29, 33], [29, 34], [29, 42], [29, 52], [30, 33], [30, 39], [30, 44], [30, 54], [31, 43], [32, 34], [32, 39], [32, 42], [32, 46], [32, 53], [32, 55], [32, 58], [33, 35], [33, 45], [33, 49], [33, 50], [33, 56], [33, 59], [34, 48], [34, 50], [34, 54], [34, 55], [34, 59], [35, 37], [35, 38], [35, 42], [35, 43], [35, 44], [35, 46], [35, 49], [35, 52], [35, 54], [35, 56], [35, 59], [36, 46], [36, 49], [36, 51], [36, 52], [36, 56], [36, 57], [37, 39], [37, 40], [37, 44], [37, 53], [37, 58], [37, 59], [38, 40], [38, 41], [38, 49], [38, 52], [39, 42], [39, 44], [39, 45], [39, 46], [39, 47], [39, 49], [39, 50], [39, 57], [39, 59], [40, 45], [40, 46], [40, 48], [40, 49], [40, 54], [40, 55], [40, 59], [41, 42], [41, 48], [41, 49], [41, 57], [42, 43], [42, 44], [42, 45], [42, 47], [42, 48], [42, 52], [43, 54], [43, 55], [43, 57], [44, 45], [44, 46], [44, 51], [44, 52], [44, 56], [44, 59], [45, 47], [45, 49], [46, 47], [46, 52], [46, 59], [47, 54], [47, 58], [48, 49], [48, 52], [48, 56], [49, 53], [49, 54], [49, 57], [50, 51], [50, 54], [50, 58], [50, 59], [51, 53], [51, 54], [51, 56], [51, 59], [52, 54], [52, 57], [53, 54], [53, 59], [54, 56], [54, 57], [55, 56], [56, 59], [58, 59]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l4-s7/tests/run.py b/tasks/construct-mc-max-independent-set-l4-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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-max-independent-set-l4-s7/tests/test.sh b/tasks/construct-mc-max-independent-set-l4-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-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-non-transitive-dice-l4-s0/environment/Dockerfile b/tasks/construct-mc-non-transitive-dice-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-non-transitive-dice-l4-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-non-transitive-dice-l4-s0/environment/instance.json b/tasks/construct-mc-non-transitive-dice-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ff8e0054afb6d69b52aced3e93bcba00cf843be --- /dev/null +++ b/tasks/construct-mc-non-transitive-dice-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "m": 6, "family": "mc_non_transitive_dice", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-non-transitive-dice-l4-s0/solution/solve.sh b/tasks/construct-mc-non-transitive-dice-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2593e796ec360991150099f11b7674a417e4655c --- /dev/null +++ b/tasks/construct-mc-non-transitive-dice-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' +{"dice": [[2, 5, 5, 5, 5, 11], [0, 0, 4, 9, 10, 11], [0, 4, 6, 8, 8, 8], [3, 3, 3, 6, 6, 11], [1, 1, 2, 10, 10, 11], [0, 6, 8, 8, 9, 9]]} +RLMATH_EOF diff --git a/tasks/construct-mc-non-transitive-dice-l4-s0/tests/check.py b/tasks/construct-mc-non-transitive-dice-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3d5c04fa6e2819bf32f34fafe13a383437dc62a --- /dev/null +++ b/tasks/construct-mc-non-transitive-dice-l4-s0/tests/check.py @@ -0,0 +1,18 @@ +"""Cyclically intransitive dice (MathConstraint non_transitive_dice, CC-BY-4.0): n dice with m faces in +0..2m-1; die i beats die (i+1) mod n, i.e. #{(a, b): face_i(a) > face_{i+1}(b)} > floor(m^2 / 2). +Face order is irrelevant (upstream additionally demanded sorted faces as a symmetry break; not required).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, m = inst["n"], inst["m"] + D = ans.get("dice") + if not isinstance(D, list) or len(D) != n: + raise Invalid(f"dice must be a list of {n} dice") + D = [int_list(d, m, 0, 2 * m - 1, "die") for d in D] + for i in range(n): + A, B = D[i], D[(i + 1) % n] + w = sum(1 for a in A for b in B if a > b) + if w <= m * m // 2: + raise Invalid(f"die {i} wins only {w} of {m * m} face pairs against die {(i + 1) % n}") + return None, {} diff --git a/tasks/construct-mc-non-transitive-dice-l4-s0/tests/instance.json b/tasks/construct-mc-non-transitive-dice-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ff8e0054afb6d69b52aced3e93bcba00cf843be --- /dev/null +++ b/tasks/construct-mc-non-transitive-dice-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "m": 6, "family": "mc_non_transitive_dice", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-non-transitive-dice-l4-s0/tests/run.py b/tasks/construct-mc-non-transitive-dice-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-non-transitive-dice-l4-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-non-transitive-dice-l4-s0/tests/test.sh b/tasks/construct-mc-non-transitive-dice-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-non-transitive-dice-l4-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-number-partitioning-l4-s3/environment/Dockerfile b/tasks/construct-mc-number-partitioning-l4-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-number-partitioning-l4-s3/environment/instance.json b/tasks/construct-mc-number-partitioning-l4-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0e143455222d9472645ed07bbfd7a2baf493bf55 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 39, "k": 5, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l4-s3/solution/solve.sh b/tasks/construct-mc-number-partitioning-l4-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bb10d0bbdbfcf9dfb35d87b16227b882f1e5e7d5 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [1, 2, 3, 4, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 4, 3, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-number-partitioning-l4-s3/tests/check.py b/tasks/construct-mc-number-partitioning-l4-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..67793721db8ba7d3c3979ea0e1e07091491ffa7e --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s3/tests/check.py @@ -0,0 +1,14 @@ +"""Partition {1..n} into k subsets of equal sum (MathConstraint number_partitioning, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + x = int_list(ans.get("x"), n, 0, k - 1, "x") + target = n * (n + 1) // 2 // k + sums = [0] * k + for i, s in enumerate(x): + sums[s] += i + 1 + if any(t != target for t in sums): + raise Invalid(f"subset sums {sums} are not all {target}") + return None, {} diff --git a/tasks/construct-mc-number-partitioning-l4-s3/tests/instance.json b/tasks/construct-mc-number-partitioning-l4-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0e143455222d9472645ed07bbfd7a2baf493bf55 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 39, "k": 5, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l4-s3/tests/run.py b/tasks/construct-mc-number-partitioning-l4-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-number-partitioning-l4-s3/tests/test.sh b/tasks/construct-mc-number-partitioning-l4-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-number-partitioning-l4-s4/environment/Dockerfile b/tasks/construct-mc-number-partitioning-l4-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-number-partitioning-l4-s4/environment/instance.json b/tasks/construct-mc-number-partitioning-l4-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..18142b9a2dcd5019ee4a72119cd8f924f4583638 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 35, "k": 5, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l4-s4/solution/solve.sh b/tasks/construct-mc-number-partitioning-l4-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..53fbc5a1ebb046229acf970a4e4cf27fb0c8921f --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [0, 2, 4, 1, 3, 1, 3, 0, 2, 4, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 4, 3, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-number-partitioning-l4-s4/tests/check.py b/tasks/construct-mc-number-partitioning-l4-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..67793721db8ba7d3c3979ea0e1e07091491ffa7e --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s4/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-s4/tests/instance.json b/tasks/construct-mc-number-partitioning-l4-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..18142b9a2dcd5019ee4a72119cd8f924f4583638 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 35, "k": 5, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l4-s4/tests/run.py b/tasks/construct-mc-number-partitioning-l4-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-number-partitioning-l4-s4/tests/test.sh b/tasks/construct-mc-number-partitioning-l4-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-ortholatin-l6-s3/environment/Dockerfile b/tasks/construct-mc-ortholatin-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l6-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-ortholatin-l6-s3/environment/instance.json b/tasks/construct-mc-ortholatin-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0096ed58887ceac78440170b4f235db544d42b0e --- /dev/null +++ b/tasks/construct-mc-ortholatin-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 27, "family": "mc_ortholatin", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ortholatin-l6-s3/solution/solve.sh b/tasks/construct-mc-ortholatin-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ff8a6717452e108750f215b5db67b7f947d7374f --- /dev/null +++ b/tasks/construct-mc-ortholatin-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' +{"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, 24, 25, 26], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [18, 19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [19, 20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [20, 21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [21, 22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [22, 23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21], [23, 24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22], [24, 25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23], [25, 26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [26, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]], "Y": [[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0], [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1], [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2], [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3], [6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4], [7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5], [8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6], [9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7], [10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8], [11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9], [12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10], [13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11], [14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12], [15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13], [16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14], [17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15], [18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16], [19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17], [20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18], [21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], [24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22], [25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23], [26, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]]} +RLMATH_EOF diff --git a/tasks/construct-mc-ortholatin-l6-s3/tests/check.py b/tasks/construct-mc-ortholatin-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a5418a59fae1c86318eee903e90d75b36d8a3306 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l6-s3/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-s3/tests/instance.json b/tasks/construct-mc-ortholatin-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0096ed58887ceac78440170b4f235db544d42b0e --- /dev/null +++ b/tasks/construct-mc-ortholatin-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 27, "family": "mc_ortholatin", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ortholatin-l6-s3/tests/run.py b/tasks/construct-mc-ortholatin-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ortholatin-l6-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-ortholatin-l6-s3/tests/test.sh b/tasks/construct-mc-ortholatin-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l6-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-chromatic-girth-l2-s2/environment/Dockerfile b/tasks/construct-mc-pysms-chromatic-girth-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-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-pysms-chromatic-girth-l2-s2/environment/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8d5a5630a359f6162a29cb3a1f5c65f1031c46b3 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 15, "required_edges": [], "max_chromatic_number": 2, "min_edges": 16, "min_girth": 6, "family": "mc_pysms_chromatic_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-chromatic-girth-l2-s2/solution/solve.sh b/tasks/construct-mc-pysms-chromatic-girth-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..29b31295aabc76eea29190ef259ee5c499d715a7 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-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' +{"edges": [[0, 13], [0, 14], [1, 11], [1, 12], [2, 10], [2, 12], [2, 14], [3, 9], [3, 12], [3, 13], [4, 9], [4, 10], [4, 11], [5, 8], [5, 11], [5, 14], [6, 8], [6, 10], [6, 13], [7, 8], [7, 9]], "coloring": [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-chromatic-girth-l2-s2/tests/check.py b/tasks/construct-mc-pysms-chromatic-girth-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l2-s2/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-chromatic-girth-l2-s2/tests/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8d5a5630a359f6162a29cb3a1f5c65f1031c46b3 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 15, "required_edges": [], "max_chromatic_number": 2, "min_edges": 16, "min_girth": 6, "family": "mc_pysms_chromatic_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-chromatic-girth-l2-s2/tests/run.py b/tasks/construct-mc-pysms-chromatic-girth-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-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-pysms-chromatic-girth-l2-s2/tests/test.sh b/tasks/construct-mc-pysms-chromatic-girth-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l2-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-clique-coloring-l1-s0/environment/Dockerfile b/tasks/construct-mc-pysms-clique-coloring-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l1-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-clique-coloring-l1-s0/environment/instance.json b/tasks/construct-mc-pysms-clique-coloring-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8298a412db9ad82d0ec7809a81043c431331b4d4 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 8, "required_edges": [[2, 7], [0, 5]], "max_chromatic_number": 2, "max_clique": 4, "min_degree": 1, "family": "mc_pysms_clique_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-clique-coloring-l1-s0/solution/solve.sh b/tasks/construct-mc-pysms-clique-coloring-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..08bf1a50f3f92d78f6044651a9d06e35672a9282 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l1-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 5], [0, 6], [0, 7], [1, 4], [1, 6], [1, 7], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7]], "coloring": [0, 0, 0, 0, 1, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-clique-coloring-l1-s0/tests/check.py b/tasks/construct-mc-pysms-clique-coloring-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l1-s0/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-clique-coloring-l1-s0/tests/instance.json b/tasks/construct-mc-pysms-clique-coloring-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8298a412db9ad82d0ec7809a81043c431331b4d4 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 8, "required_edges": [[2, 7], [0, 5]], "max_chromatic_number": 2, "max_clique": 4, "min_degree": 1, "family": "mc_pysms_clique_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-clique-coloring-l1-s0/tests/run.py b/tasks/construct-mc-pysms-clique-coloring-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l1-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-clique-coloring-l1-s0/tests/test.sh b/tasks/construct-mc-pysms-clique-coloring-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l1-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s1/environment/Dockerfile b/tasks/construct-mc-pysms-clique-coloring-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s1/environment/instance.json b/tasks/construct-mc-pysms-clique-coloring-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d993d87c0ef1beccc527208fa76ae696e7add9a7 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 19, "required_edges": [], "max_chromatic_number": 5, "max_clique": 5, "min_degree": 5, "family": "mc_pysms_clique_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s1/solution/solve.sh b/tasks/construct-mc-pysms-clique-coloring-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8f7408debf29c73eac398520cf97c5d3e2978829 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [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], [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], [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], [3, 18], [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]], "coloring": [3, 3, 0, 1, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s1/tests/check.py b/tasks/construct-mc-pysms-clique-coloring-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s1/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s1/tests/instance.json b/tasks/construct-mc-pysms-clique-coloring-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d993d87c0ef1beccc527208fa76ae696e7add9a7 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 19, "required_edges": [], "max_chromatic_number": 5, "max_clique": 5, "min_degree": 5, "family": "mc_pysms_clique_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s1/tests/run.py b/tasks/construct-mc-pysms-clique-coloring-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s1/tests/test.sh b/tasks/construct-mc-pysms-clique-coloring-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-girth-degree-l1-s0/environment/Dockerfile b/tasks/construct-mc-pysms-girth-degree-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l1-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-girth-degree-l1-s0/environment/instance.json b/tasks/construct-mc-pysms-girth-degree-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9ea9f7bd58978c6bed7d38a1fd2a8f4dd21b6519 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 11, "required_edges": [], "max_degree": 5, "min_degree": 2, "min_girth": 6, "family": "mc_pysms_girth_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-girth-degree-l1-s0/solution/solve.sh b/tasks/construct-mc-pysms-girth-degree-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4874c4e575317420207cb776e6b4d6e3e99d0ff7 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l1-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 9], [0, 10], [1, 8], [1, 10], [2, 7], [2, 10], [3, 6], [3, 10], [4, 5], [4, 8], [4, 9], [5, 6], [5, 7]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-girth-degree-l1-s0/tests/check.py b/tasks/construct-mc-pysms-girth-degree-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l1-s0/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-girth-degree-l1-s0/tests/instance.json b/tasks/construct-mc-pysms-girth-degree-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9ea9f7bd58978c6bed7d38a1fd2a8f4dd21b6519 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 11, "required_edges": [], "max_degree": 5, "min_degree": 2, "min_girth": 6, "family": "mc_pysms_girth_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-girth-degree-l1-s0/tests/run.py b/tasks/construct-mc-pysms-girth-degree-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l1-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-girth-degree-l1-s0/tests/test.sh b/tasks/construct-mc-pysms-girth-degree-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l1-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-graph-builder-l1-s1/environment/Dockerfile b/tasks/construct-mc-pysms-graph-builder-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-graph-builder-l1-s1/environment/instance.json b/tasks/construct-mc-pysms-graph-builder-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0c0747827e8194e82494ab02e351b15fa8d725aa --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 12, "required_edges": [[5, 7], [4, 6]], "max_degree": 2, "min_degree": 1, "max_chromatic_number": 2, "min_chromatic_number": 2, "min_edges": 9, "max_edges": 11, "family": "mc_pysms_graph_builder", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-graph-builder-l1-s1/solution/solve.sh b/tasks/construct-mc-pysms-graph-builder-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5b359ec7e229559b24e008584ecd5d29bed5b443 --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l1-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 11], [1, 9], [1, 10], [2, 8], [2, 10], [3, 7], [3, 9], [4, 6], [4, 8], [5, 6], [5, 7]], "coloring": [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-graph-builder-l1-s1/tests/check.py b/tasks/construct-mc-pysms-graph-builder-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l1-s1/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-graph-builder-l1-s1/tests/instance.json b/tasks/construct-mc-pysms-graph-builder-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0c0747827e8194e82494ab02e351b15fa8d725aa --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 12, "required_edges": [[5, 7], [4, 6]], "max_degree": 2, "min_degree": 1, "max_chromatic_number": 2, "min_chromatic_number": 2, "min_edges": 9, "max_edges": 11, "family": "mc_pysms_graph_builder", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-graph-builder-l1-s1/tests/run.py b/tasks/construct-mc-pysms-graph-builder-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-graph-builder-l1-s1/tests/test.sh b/tasks/construct-mc-pysms-graph-builder-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-min-connectivity-l2-s1/environment/Dockerfile b/tasks/construct-mc-pysms-min-connectivity-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-l2-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-min-connectivity-l2-s1/environment/instance.json b/tasks/construct-mc-pysms-min-connectivity-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e516c318c3a3ef90ff0924978dcb7d74a3e28336 --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 15, "required_edges": [], "min_connectivity": 1, "family": "mc_pysms_min_connectivity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-connectivity-l2-s1/solution/solve.sh b/tasks/construct-mc-pysms-min-connectivity-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..202381af71f4ba7b8da0d1a923832175f9607239 --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-l2-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 14]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-min-connectivity-l2-s1/tests/check.py b/tasks/construct-mc-pysms-min-connectivity-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-l2-s1/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-min-connectivity-l2-s1/tests/instance.json b/tasks/construct-mc-pysms-min-connectivity-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e516c318c3a3ef90ff0924978dcb7d74a3e28336 --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 15, "required_edges": [], "min_connectivity": 1, "family": "mc_pysms_min_connectivity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-connectivity-l2-s1/tests/run.py b/tasks/construct-mc-pysms-min-connectivity-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-l2-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-min-connectivity-l2-s1/tests/test.sh b/tasks/construct-mc-pysms-min-connectivity-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-l2-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-min-degree-l5-s2/environment/Dockerfile b/tasks/construct-mc-pysms-min-degree-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l5-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-min-degree-l5-s2/environment/instance.json b/tasks/construct-mc-pysms-min-degree-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7bf0156776325e8d8a69758e2dd3700b1281e3bb --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 16, "required_edges": [], "min_degree": 1, "family": "mc_pysms_min_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-degree-l5-s2/solution/solve.sh b/tasks/construct-mc-pysms-min-degree-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4b8141dfb1b77c83fdaab714902ed360207c54d0 --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l5-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [11, 12], [11, 13], [11, 14], [11, 15], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-min-degree-l5-s2/tests/check.py b/tasks/construct-mc-pysms-min-degree-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l5-s2/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-min-degree-l5-s2/tests/instance.json b/tasks/construct-mc-pysms-min-degree-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7bf0156776325e8d8a69758e2dd3700b1281e3bb --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 16, "required_edges": [], "min_degree": 1, "family": "mc_pysms_min_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-degree-l5-s2/tests/run.py b/tasks/construct-mc-pysms-min-degree-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l5-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-min-degree-l5-s2/tests/test.sh b/tasks/construct-mc-pysms-min-degree-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-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-social-golfers-l5-s3/environment/Dockerfile b/tasks/construct-mc-social-golfers-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-social-golfers-l5-s3/environment/instance.json b/tasks/construct-mc-social-golfers-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..61ed08fe2e6c8237c4fae68198e0465b94bf1082 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"n_groups": 7, "group_size": 5, "n_weeks": 5, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l5-s3/solution/solve.sh b/tasks/construct-mc-social-golfers-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fe5a74c86f2410b9e56a6322639d08463ee4b2d9 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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' +{"schedule": [[0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6], [5, 6, 4, 0, 1, 0, 6, 5, 4, 1, 2, 5, 6, 4, 3, 1, 2, 0, 6, 3, 3, 0, 5, 2, 1, 3, 6, 2, 5, 4, 4, 1, 0, 2, 3], [4, 0, 3, 1, 2, 2, 1, 3, 4, 0, 1, 6, 2, 5, 0, 3, 2, 0, 6, 5, 1, 4, 2, 6, 5, 6, 3, 4, 5, 0, 6, 1, 3, 5, 4], [0, 1, 2, 3, 4, 0, 2, 1, 3, 5, 0, 2, 3, 1, 6, 6, 1, 4, 5, 0, 5, 2, 6, 4, 3, 3, 4, 6, 5, 0, 6, 1, 5, 2, 4], [0, 1, 2, 3, 4, 2, 0, 6, 1, 3, 4, 5, 6, 0, 2, 0, 5, 6, 2, 1, 6, 4, 3, 1, 5, 0, 3, 6, 4, 5, 4, 2, 1, 3, 5]]} +RLMATH_EOF diff --git a/tasks/construct-mc-social-golfers-l5-s3/tests/check.py b/tasks/construct-mc-social-golfers-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..73977815b7b6094a8491075b6dc2ae1293e44930 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s3/tests/check.py @@ -0,0 +1,25 @@ +"""Social golfer problem (MathConstraint social_golfers, CSPLib prob010, CC-BY-4.0): each week partition +the g*s players into g groups of size s; no two players share a group in more than one week.""" +from run import Invalid, int_list + + +def check(inst, ans): + g, s, w = inst["n_groups"], inst["group_size"], inst["n_weeks"] + P = g * s + sched = ans.get("schedule") + if not isinstance(sched, list) or len(sched) != w: + raise Invalid(f"schedule must be a list of {w} weeks") + met = set() + for wk, row in enumerate(sched): + row = int_list(row, P, 0, g - 1, f"week {wk}") + groups = [[p for p in range(P) if row[p] == grp] for grp in range(g)] + for grp, mem in enumerate(groups): + if len(mem) != s: + raise Invalid(f"week {wk}: group {grp} has {len(mem)} players, need {s}") + for i in range(s): + for j in range(i + 1, s): + pr = (mem[i], mem[j]) + if pr in met: + raise Invalid(f"players {pr} play together in more than one week") + met.add(pr) + return None, {} diff --git a/tasks/construct-mc-social-golfers-l5-s3/tests/instance.json b/tasks/construct-mc-social-golfers-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..61ed08fe2e6c8237c4fae68198e0465b94bf1082 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"n_groups": 7, "group_size": 5, "n_weeks": 5, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l5-s3/tests/run.py b/tasks/construct-mc-social-golfers-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-social-golfers-l5-s3/tests/test.sh b/tasks/construct-mc-social-golfers-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-van-der-waerden-l4-s2/environment/Dockerfile b/tasks/construct-mc-van-der-waerden-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-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-van-der-waerden-l4-s2/environment/instance.json b/tasks/construct-mc-van-der-waerden-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0ed04a3ce06fc8d1a05503e91a9a765ce0b12e33 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"k": 2, "L": 5, "n": 100, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l4-s2/solution/solve.sh b/tasks/construct-mc-van-der-waerden-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9aaa0ca50246d1fcf3903b109b910ab484ccbb4c --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-van-der-waerden-l4-s2/tests/check.py b/tasks/construct-mc-van-der-waerden-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9853b089b6ac1773d80eac8e9e02ceb4019ad41f --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s2/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-s2/tests/instance.json b/tasks/construct-mc-van-der-waerden-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0ed04a3ce06fc8d1a05503e91a9a765ce0b12e33 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"k": 2, "L": 5, "n": 100, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l4-s2/tests/run.py b/tasks/construct-mc-van-der-waerden-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-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-van-der-waerden-l4-s2/tests/test.sh b/tasks/construct-mc-van-der-waerden-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-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-van-der-waerden-l4-s5/environment/Dockerfile b/tasks/construct-mc-van-der-waerden-l4-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-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-van-der-waerden-l4-s5/environment/instance.json b/tasks/construct-mc-van-der-waerden-l4-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1acf1b43c03ee834627136d92195585fb8b47918 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s5/environment/instance.json @@ -0,0 +1 @@ +{"k": 4, "L": 3, "n": 40, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l4-s5/solution/solve.sh b/tasks/construct-mc-van-der-waerden-l4-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..517488452660147dc84726cfa9ecb3fa98aa93f2 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-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": [0, 2, 0, 2, 1, 1, 0, 2, 0, 3, 3, 0, 3, 3, 1, 2, 1, 2, 3, 3, 2, 3, 3, 0, 0, 1, 1, 0, 2, 0, 1, 1, 0, 0, 2, 2, 3, 3, 2, 3]} +RLMATH_EOF diff --git a/tasks/construct-mc-van-der-waerden-l4-s5/tests/check.py b/tasks/construct-mc-van-der-waerden-l4-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9853b089b6ac1773d80eac8e9e02ceb4019ad41f --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s5/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-s5/tests/instance.json b/tasks/construct-mc-van-der-waerden-l4-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1acf1b43c03ee834627136d92195585fb8b47918 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s5/tests/instance.json @@ -0,0 +1 @@ +{"k": 4, "L": 3, "n": 40, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l4-s5/tests/run.py b/tasks/construct-mc-van-der-waerden-l4-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-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-van-der-waerden-l4-s5/tests/test.sh b/tasks/construct-mc-van-der-waerden-l4-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-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-vertex-cover-l1-s3/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l1-s3/environment/instance.json b/tasks/construct-mc-vertex-cover-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d57195868cfb7346d544a3ec1a869fc8d3088d46 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 8], [0, 19], [1, 6], [1, 9], [1, 17], [1, 18], [2, 3], [3, 7], [3, 13], [3, 18], [5, 12], [5, 14], [5, 17], [6, 11], [6, 14], [8, 10], [8, 12], [8, 15], [9, 15], [9, 18], [12, 18], [12, 19], [13, 15], [14, 15], [15, 16], [15, 17], [15, 19], [16, 18], [17, 18]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s3/solution/solve.sh b/tasks/construct-mc-vertex-cover-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0db8e5b7171528ceedca84cef2d46eef700dac8 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [1, 3, 5, 6, 8, 10, 11, 15, 17, 18, 19]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l1-s3/tests/check.py b/tasks/construct-mc-vertex-cover-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s3/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l1-s3/tests/instance.json b/tasks/construct-mc-vertex-cover-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d57195868cfb7346d544a3ec1a869fc8d3088d46 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 8], [0, 19], [1, 6], [1, 9], [1, 17], [1, 18], [2, 3], [3, 7], [3, 13], [3, 18], [5, 12], [5, 14], [5, 17], [6, 11], [6, 14], [8, 10], [8, 12], [8, 15], [9, 15], [9, 18], [12, 18], [12, 19], [13, 15], [14, 15], [15, 16], [15, 17], [15, 19], [16, 18], [17, 18]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s3/tests/run.py b/tasks/construct-mc-vertex-cover-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l1-s3/tests/test.sh b/tasks/construct-mc-vertex-cover-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-mc-vertex-cover-l1-s4/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-vertex-cover-l1-s4/environment/instance.json b/tasks/construct-mc-vertex-cover-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d112d154f31d15a5d8090b334f50908fcad6de42 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 10], [0, 17], [0, 18], [1, 8], [1, 19], [2, 9], [2, 16], [3, 10], [3, 14], [3, 16], [3, 17], [4, 9], [4, 14], [4, 17], [5, 18], [6, 9], [7, 18], [8, 9], [8, 12], [8, 14], [10, 12], [10, 14], [10, 18], [12, 14]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s4/solution/solve.sh b/tasks/construct-mc-vertex-cover-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a4021e847990ac56a2fe0e2531361f039703eb9d --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [0, 5, 8, 9, 10, 11, 14, 16, 17, 18, 19]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l1-s4/tests/check.py b/tasks/construct-mc-vertex-cover-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s4/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l1-s4/tests/instance.json b/tasks/construct-mc-vertex-cover-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d112d154f31d15a5d8090b334f50908fcad6de42 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 10], [0, 17], [0, 18], [1, 8], [1, 19], [2, 9], [2, 16], [3, 10], [3, 14], [3, 16], [3, 17], [4, 9], [4, 14], [4, 17], [5, 18], [6, 9], [7, 18], [8, 9], [8, 12], [8, 14], [10, 12], [10, 14], [10, 18], [12, 14]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s4/tests/run.py b/tasks/construct-mc-vertex-cover-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-vertex-cover-l1-s4/tests/test.sh b/tasks/construct-mc-vertex-cover-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-3col-l1-s4/tests/run.py b/tasks/construct-nppc-3col-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l5-s2/environment/Dockerfile b/tasks/construct-nppc-3col-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l5-s2/environment/instance.json b/tasks/construct-nppc-3col-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fdea6a40aedf9d8a92b2477feac4d1c2bcc93803 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 60, "edges": [[0, 4], [0, 44], [0, 58], [1, 3], [1, 6], [1, 9], [1, 26], [1, 55], [2, 11], [2, 29], [2, 37], [2, 47], [2, 50], [2, 55], [3, 28], [3, 41], [3, 42], [3, 47], [3, 50], [3, 53], [4, 7], [4, 19], [4, 20], [4, 25], [4, 26], [4, 31], [4, 56], [5, 9], [5, 13], [5, 26], [5, 34], [5, 37], [5, 57], [5, 59], [6, 16], [6, 28], [6, 31], [6, 48], [6, 51], [7, 8], [7, 24], [7, 29], [7, 32], [7, 35], [7, 50], [8, 40], [8, 47], [8, 56], [9, 19], [9, 31], [9, 36], [9, 43], [9, 44], [9, 46], [9, 59], [10, 11], [10, 18], [10, 27], [10, 31], [10, 34], [10, 39], [10, 41], [10, 44], [10, 54], [11, 24], [11, 32], [11, 46], [11, 47], [11, 54], [12, 13], [12, 23], [12, 30], [12, 43], [12, 44], [12, 48], [13, 22], [13, 26], [13, 30], [13, 31], [13, 34], [14, 19], [14, 29], [14, 39], [14, 43], [14, 44], [14, 54], [14, 57], [15, 35], [15, 48], [15, 49], [15, 52], [15, 57], [16, 22], [16, 27], [16, 28], [16, 42], [16, 59], [17, 33], [17, 41], [17, 52], [18, 28], [18, 34], [18, 37], [18, 45], [18, 47], [19, 22], [19, 24], [20, 42], [20, 48], [20, 50], [21, 26], [21, 47], [21, 50], [22, 31], [22, 52], [22, 59], [23, 32], [23, 51], [24, 31], [24, 37], [24, 41], [25, 28], [25, 39], [25, 47], [25, 48], [26, 28], [26, 42], [26, 53], [26, 54], [26, 58], [27, 28], [27, 30], [27, 39], [27, 41], [27, 48], [27, 54], [28, 36], [28, 41], [28, 52], [28, 55], [28, 57], [29, 39], [29, 46], [29, 58], [30, 35], [30, 38], [30, 50], [30, 59], [31, 34], [31, 35], [31, 37], [31, 49], [31, 53], [31, 59], [32, 37], [33, 36], [33, 43], [33, 54], [34, 38], [34, 39], [34, 46], [34, 48], [34, 50], [35, 38], [35, 39], [35, 44], [35, 53], [36, 47], [37, 44], [37, 45], [37, 51], [38, 49], [39, 40], [39, 53], [40, 44], [40, 56], [41, 45], [41, 50], [41, 55], [42, 49], [42, 54], [43, 47], [43, 49], [43, 51], [43, 53], [43, 59], [44, 45], [44, 51], [44, 53], [44, 55], [44, 57], [45, 48], [45, 49], [47, 48], [47, 52], [47, 54], [49, 58], [53, 57], [54, 57], [57, 59]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l5-s2/solution/solve.sh b/tasks/construct-nppc-3col-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..730360e64d3dc04e373e1866609e7d25838afa40 --- /dev/null +++ b/tasks/construct-nppc-3col-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' +{"coloring": [1, 2, 2, 1, 0, 2, 1, 2, 1, 1, 0, 1, 1, 0, 0, 0, 2, 0, 2, 2, 1, 2, 1, 2, 0, 1, 1, 1, 0, 1, 2, 2, 0, 1, 1, 1, 2, 1, 0, 2, 0, 2, 0, 2, 2, 0, 0, 0, 2, 1, 0, 0, 2, 0, 2, 1, 2, 1, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l5-s2/tests/check.py b/tasks/construct-nppc-3col-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s2/tests/check.py @@ -0,0 +1,12 @@ +"""Proper 3-colouring of a given graph. Accepts any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["num_nodes"] + # upstream NPPC verifier skips the range/length check, so an all-distinct colouring passed it + c = int_list(ans.get("coloring"), n, 0, 2, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-nppc-3col-l5-s2/tests/instance.json b/tasks/construct-nppc-3col-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fdea6a40aedf9d8a92b2477feac4d1c2bcc93803 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 60, "edges": [[0, 4], [0, 44], [0, 58], [1, 3], [1, 6], [1, 9], [1, 26], [1, 55], [2, 11], [2, 29], [2, 37], [2, 47], [2, 50], [2, 55], [3, 28], [3, 41], [3, 42], [3, 47], [3, 50], [3, 53], [4, 7], [4, 19], [4, 20], [4, 25], [4, 26], [4, 31], [4, 56], [5, 9], [5, 13], [5, 26], [5, 34], [5, 37], [5, 57], [5, 59], [6, 16], [6, 28], [6, 31], [6, 48], [6, 51], [7, 8], [7, 24], [7, 29], [7, 32], [7, 35], [7, 50], [8, 40], [8, 47], [8, 56], [9, 19], [9, 31], [9, 36], [9, 43], [9, 44], [9, 46], [9, 59], [10, 11], [10, 18], [10, 27], [10, 31], [10, 34], [10, 39], [10, 41], [10, 44], [10, 54], [11, 24], [11, 32], [11, 46], [11, 47], [11, 54], [12, 13], [12, 23], [12, 30], [12, 43], [12, 44], [12, 48], [13, 22], [13, 26], [13, 30], [13, 31], [13, 34], [14, 19], [14, 29], [14, 39], [14, 43], [14, 44], [14, 54], [14, 57], [15, 35], [15, 48], [15, 49], [15, 52], [15, 57], [16, 22], [16, 27], [16, 28], [16, 42], [16, 59], [17, 33], [17, 41], [17, 52], [18, 28], [18, 34], [18, 37], [18, 45], [18, 47], [19, 22], [19, 24], [20, 42], [20, 48], [20, 50], [21, 26], [21, 47], [21, 50], [22, 31], [22, 52], [22, 59], [23, 32], [23, 51], [24, 31], [24, 37], [24, 41], [25, 28], [25, 39], [25, 47], [25, 48], [26, 28], [26, 42], [26, 53], [26, 54], [26, 58], [27, 28], [27, 30], [27, 39], [27, 41], [27, 48], [27, 54], [28, 36], [28, 41], [28, 52], [28, 55], [28, 57], [29, 39], [29, 46], [29, 58], [30, 35], [30, 38], [30, 50], [30, 59], [31, 34], [31, 35], [31, 37], [31, 49], [31, 53], [31, 59], [32, 37], [33, 36], [33, 43], [33, 54], [34, 38], [34, 39], [34, 46], [34, 48], [34, 50], [35, 38], [35, 39], [35, 44], [35, 53], [36, 47], [37, 44], [37, 45], [37, 51], [38, 49], [39, 40], [39, 53], [40, 44], [40, 56], [41, 45], [41, 50], [41, 55], [42, 49], [42, 54], [43, 47], [43, 49], [43, 51], [43, 53], [43, 59], [44, 45], [44, 51], [44, 53], [44, 55], [44, 57], [45, 48], [45, 49], [47, 48], [47, 52], [47, 54], [49, 58], [53, 57], [54, 57], [57, 59]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l5-s2/tests/run.py b/tasks/construct-nppc-3col-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l5-s2/tests/test.sh b/tasks/construct-nppc-3col-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l5-s5/environment/Dockerfile b/tasks/construct-nppc-3col-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l5-s5/environment/instance.json b/tasks/construct-nppc-3col-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aa7c97207f8648ad94eac4275bdf3a9d88c6bfa9 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 60, "edges": [[0, 2], [0, 34], [0, 39], [0, 45], [1, 13], [1, 32], [2, 3], [2, 13], [2, 15], [2, 24], [2, 41], [3, 10], [3, 18], [3, 37], [3, 42], [3, 44], [3, 47], [3, 53], [4, 8], [4, 17], [4, 22], [4, 23], [4, 31], [4, 35], [4, 42], [4, 48], [4, 53], [5, 27], [5, 32], [5, 37], [5, 56], [6, 28], [6, 42], [6, 45], [6, 47], [6, 48], [6, 57], [7, 8], [7, 51], [7, 53], [7, 59], [8, 22], [8, 27], [8, 35], [8, 39], [8, 49], [8, 58], [9, 31], [9, 44], [9, 47], [9, 51], [9, 54], [10, 22], [10, 27], [10, 34], [10, 38], [10, 39], [10, 47], [10, 50], [10, 55], [11, 14], [11, 16], [11, 20], [11, 23], [11, 29], [11, 49], [11, 58], [12, 26], [12, 41], [12, 43], [12, 46], [12, 47], [12, 52], [13, 18], [13, 20], [13, 32], [13, 37], [13, 44], [13, 48], [13, 55], [14, 16], [14, 28], [14, 33], [14, 42], [15, 28], [15, 43], [15, 48], [15, 49], [15, 52], [15, 55], [16, 21], [16, 25], [16, 35], [16, 43], [16, 46], [16, 47], [16, 54], [16, 55], [17, 20], [17, 22], [17, 39], [17, 42], [17, 47], [18, 26], [18, 27], [18, 35], [18, 52], [18, 53], [18, 55], [19, 34], [20, 22], [20, 34], [20, 35], [20, 41], [20, 47], [20, 53], [20, 57], [21, 24], [21, 30], [21, 58], [22, 31], [22, 36], [22, 43], [22, 45], [22, 59], [23, 35], [23, 40], [23, 42], [23, 49], [24, 32], [24, 34], [24, 45], [24, 56], [25, 29], [25, 33], [25, 39], [25, 42], [25, 46], [26, 30], [26, 43], [26, 48], [26, 50], [26, 55], [27, 31], [27, 32], [27, 43], [27, 45], [27, 55], [27, 59], [28, 39], [28, 43], [29, 38], [29, 53], [29, 55], [30, 32], [30, 36], [30, 38], [30, 44], [30, 46], [30, 54], [31, 34], [31, 39], [31, 55], [32, 58], [33, 50], [34, 37], [34, 43], [35, 36], [35, 37], [35, 40], [35, 49], [35, 58], [36, 49], [36, 54], [37, 50], [37, 55], [37, 58], [38, 48], [38, 50], [39, 43], [39, 44], [40, 41], [42, 44], [42, 59], [43, 54], [45, 49], [45, 50], [45, 54], [45, 58], [46, 49], [46, 50], [46, 52], [47, 55], [47, 59], [48, 52], [48, 53], [49, 51], [51, 59], [55, 57], [57, 58]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l5-s5/solution/solve.sh b/tasks/construct-nppc-3col-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7386ad054c6f2d62bdb42f1aca4bf0950c2238e7 --- /dev/null +++ b/tasks/construct-nppc-3col-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' +{"coloring": [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 2, 1, 2, 0, 2, 1, 1, 1, 1, 0, 2, 2, 1, 0, 0, 2, 2, 1, 1, 0, 1, 1, 1, 2, 2, 1, 1, 2, 2, 0, 2, 2, 0, 1, 1, 2, 2, 1, 0, 0, 2, 0, 2, 2, 0, 2, 2, 0, 1]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l5-s5/tests/check.py b/tasks/construct-nppc-3col-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s5/tests/check.py @@ -0,0 +1,12 @@ +"""Proper 3-colouring of a given graph. Accepts any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["num_nodes"] + # upstream NPPC verifier skips the range/length check, so an all-distinct colouring passed it + c = int_list(ans.get("coloring"), n, 0, 2, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-nppc-3col-l5-s5/tests/instance.json b/tasks/construct-nppc-3col-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aa7c97207f8648ad94eac4275bdf3a9d88c6bfa9 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 60, "edges": [[0, 2], [0, 34], [0, 39], [0, 45], [1, 13], [1, 32], [2, 3], [2, 13], [2, 15], [2, 24], [2, 41], [3, 10], [3, 18], [3, 37], [3, 42], [3, 44], [3, 47], [3, 53], [4, 8], [4, 17], [4, 22], [4, 23], [4, 31], [4, 35], [4, 42], [4, 48], [4, 53], [5, 27], [5, 32], [5, 37], [5, 56], [6, 28], [6, 42], [6, 45], [6, 47], [6, 48], [6, 57], [7, 8], [7, 51], [7, 53], [7, 59], [8, 22], [8, 27], [8, 35], [8, 39], [8, 49], [8, 58], [9, 31], [9, 44], [9, 47], [9, 51], [9, 54], [10, 22], [10, 27], [10, 34], [10, 38], [10, 39], [10, 47], [10, 50], [10, 55], [11, 14], [11, 16], [11, 20], [11, 23], [11, 29], [11, 49], [11, 58], [12, 26], [12, 41], [12, 43], [12, 46], [12, 47], [12, 52], [13, 18], [13, 20], [13, 32], [13, 37], [13, 44], [13, 48], [13, 55], [14, 16], [14, 28], [14, 33], [14, 42], [15, 28], [15, 43], [15, 48], [15, 49], [15, 52], [15, 55], [16, 21], [16, 25], [16, 35], [16, 43], [16, 46], [16, 47], [16, 54], [16, 55], [17, 20], [17, 22], [17, 39], [17, 42], [17, 47], [18, 26], [18, 27], [18, 35], [18, 52], [18, 53], [18, 55], [19, 34], [20, 22], [20, 34], [20, 35], [20, 41], [20, 47], [20, 53], [20, 57], [21, 24], [21, 30], [21, 58], [22, 31], [22, 36], [22, 43], [22, 45], [22, 59], [23, 35], [23, 40], [23, 42], [23, 49], [24, 32], [24, 34], [24, 45], [24, 56], [25, 29], [25, 33], [25, 39], [25, 42], [25, 46], [26, 30], [26, 43], [26, 48], [26, 50], [26, 55], [27, 31], [27, 32], [27, 43], [27, 45], [27, 55], [27, 59], [28, 39], [28, 43], [29, 38], [29, 53], [29, 55], [30, 32], [30, 36], [30, 38], [30, 44], [30, 46], [30, 54], [31, 34], [31, 39], [31, 55], [32, 58], [33, 50], [34, 37], [34, 43], [35, 36], [35, 37], [35, 40], [35, 49], [35, 58], [36, 49], [36, 54], [37, 50], [37, 55], [37, 58], [38, 48], [38, 50], [39, 43], [39, 44], [40, 41], [42, 44], [42, 59], [43, 54], [45, 49], [45, 50], [45, 54], [45, 58], [46, 49], [46, 50], [46, 52], [47, 55], [47, 59], [48, 52], [48, 53], [49, 51], [51, 59], [55, 57], [57, 58]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l5-s5/tests/run.py b/tasks/construct-nppc-3col-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-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-nppc-3col-l5-s5/tests/test.sh b/tasks/construct-nppc-3col-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-bandwidth-l3-s0/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-bandwidth-l3-s0/environment/instance.json b/tasks/construct-nppc-bandwidth-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..df3ef7cdf16774fd2adc3b000e1c7b0789c484fe --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 2], [1, 3], [2, 4], [2, 5], [3, 6], [4, 5], [5, 6], [6, 7]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s0/solution/solve.sh b/tasks/construct-nppc-bandwidth-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a5a6c04d171cfd1a76d8b2affd256cc26d9bf893 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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' +{"layout": [0, 4, 1, 6, 2, 3, 5, 7]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l3-s0/tests/check.py b/tasks/construct-nppc-bandwidth-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s0/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-s0/tests/instance.json b/tasks/construct-nppc-bandwidth-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..df3ef7cdf16774fd2adc3b000e1c7b0789c484fe --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 2], [1, 3], [2, 4], [2, 5], [3, 6], [4, 5], [5, 6], [6, 7]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s0/tests/run.py b/tasks/construct-nppc-bandwidth-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-bandwidth-l3-s0/tests/test.sh b/tasks/construct-nppc-bandwidth-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-bandwidth-l3-s6/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-bandwidth-l3-s6/environment/instance.json b/tasks/construct-nppc-bandwidth-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f7b94dc0852dd337811ea4ba9a65fd7afac94789 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 3], [1, 2], [1, 5], [1, 6], [2, 5], [3, 4], [4, 6], [5, 7]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s6/solution/solve.sh b/tasks/construct-nppc-bandwidth-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71f604e40892239947b14b989914a57710fd6342 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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' +{"layout": [6, 3, 2, 7, 5, 1, 4, 0]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l3-s6/tests/check.py b/tasks/construct-nppc-bandwidth-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s6/tests/check.py @@ -0,0 +1,14 @@ +"""Bandwidth <= b: layout must be a permutation of 0..n-1 with |p[u]-p[v]| <= b on every edge.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, b = inst["num_nodes"], inst["bandwidth"] + # upstream NPPC verifier compares sorted(layout) to range(n), which also accepts floats/bools + p = int_list(ans.get("layout"), n, 0, n - 1, "layout") + if len(set(p)) != n: + raise Invalid("layout is not a permutation of 0..n-1") + for u, v in inst["edges"]: + if abs(p[u] - p[v]) > b: + raise Invalid(f"edge ({u},{v}) has stretch {abs(p[u] - p[v])} > {b}") + return None, {} diff --git a/tasks/construct-nppc-bandwidth-l3-s6/tests/instance.json b/tasks/construct-nppc-bandwidth-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f7b94dc0852dd337811ea4ba9a65fd7afac94789 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "bandwidth": 2, "edges": [[0, 3], [1, 2], [1, 5], [1, 6], [2, 5], [3, 4], [4, 6], [5, 7]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l3-s6/tests/run.py b/tasks/construct-nppc-bandwidth-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-bandwidth-l3-s6/tests/test.sh b/tasks/construct-nppc-bandwidth-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l3-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-clique-l2-s9/environment/Dockerfile b/tasks/construct-nppc-clique-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-clique-l2-s9/environment/instance.json b/tasks/construct-nppc-clique-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0c1fa7e741036060bb2742a69d4a34974bcf0dba --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 3], [0, 5], [0, 9], [1, 2], [1, 6], [1, 10], [1, 11], [1, 13], [2, 3], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [3, 8], [3, 9], [3, 12], [3, 13], [4, 6], [4, 8], [4, 9], [4, 10], [4, 13], [5, 9], [5, 11], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [7, 8], [7, 10], [7, 11], [7, 13], [9, 10], [9, 11], [9, 12], [9, 13], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s9/solution/solve.sh b/tasks/construct-nppc-clique-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0e7fa13e9bc351ac49a0488619b76fd5be414ebb --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [2, 6, 9, 10, 11, 12, 13]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l2-s9/tests/check.py b/tasks/construct-nppc-clique-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s9/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l2-s9/tests/instance.json b/tasks/construct-nppc-clique-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0c1fa7e741036060bb2742a69d4a34974bcf0dba --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 3], [0, 5], [0, 9], [1, 2], [1, 6], [1, 10], [1, 11], [1, 13], [2, 3], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [3, 8], [3, 9], [3, 12], [3, 13], [4, 6], [4, 8], [4, 9], [4, 10], [4, 13], [5, 9], [5, 11], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [7, 8], [7, 10], [7, 11], [7, 13], [9, 10], [9, 11], [9, 12], [9, 13], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s9/tests/run.py b/tasks/construct-nppc-clique-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-clique-l2-s9/tests/test.sh b/tasks/construct-nppc-clique-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-clique-l6-s0/environment/Dockerfile b/tasks/construct-nppc-clique-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l6-s0/environment/instance.json b/tasks/construct-nppc-clique-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..899f8cfef93e0611a290224571984d582bd758af --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 1], [0, 3], [0, 5], [0, 6], [0, 7], [0, 10], [0, 12], [0, 14], [0, 18], [0, 20], [0, 21], [0, 23], [0, 26], [0, 28], [0, 30], [0, 31], [0, 39], [0, 40], [0, 43], [0, 44], [0, 48], [0, 49], [0, 50], [0, 52], [0, 53], [0, 56], [0, 58], [0, 62], [0, 63], [0, 66], [0, 68], [0, 69], [0, 71], [0, 72], [0, 75], [0, 79], [0, 80], [0, 81], [0, 85], [0, 87], [0, 94], [0, 95], [0, 98], [0, 99], [1, 4], [1, 5], [1, 6], [1, 10], [1, 13], [1, 17], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 34], [1, 41], [1, 42], [1, 46], [1, 47], [1, 48], [1, 49], [1, 51], [1, 53], [1, 56], [1, 57], [1, 59], [1, 60], [1, 64], [1, 65], [1, 66], [1, 67], [1, 69], [1, 70], [1, 73], [1, 76], [1, 78], [1, 79], [1, 84], [1, 85], [1, 86], [1, 90], [1, 91], [1, 92], [1, 94], [1, 97], [1, 99], [2, 3], [2, 4], [2, 7], [2, 11], [2, 14], [2, 15], [2, 17], [2, 21], [2, 22], [2, 23], [2, 26], [2, 29], [2, 31], [2, 34], [2, 35], [2, 36], [2, 38], [2, 40], [2, 42], [2, 43], [2, 45], [2, 46], [2, 47], [2, 49], [2, 50], [2, 51], [2, 52], [2, 55], [2, 59], [2, 61], [2, 65], [2, 66], [2, 67], [2, 68], [2, 69], [2, 76], [2, 81], [2, 82], [2, 83], [2, 84], [2, 85], [2, 87], [2, 89], [2, 90], [2, 91], [2, 92], [2, 93], [2, 94], [2, 97], [2, 99], [3, 4], [3, 5], [3, 10], [3, 13], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 22], [3, 23], [3, 26], [3, 27], [3, 32], [3, 35], [3, 36], [3, 37], [3, 42], [3, 44], [3, 46], [3, 47], [3, 52], [3, 53], [3, 54], [3, 55], [3, 56], [3, 57], [3, 58], [3, 59], [3, 60], [3, 62], [3, 63], [3, 64], [3, 72], [3, 75], [3, 79], [3, 80], [3, 81], [3, 82], [3, 83], [3, 86], [3, 89], [3, 91], [3, 92], [3, 95], [3, 96], [3, 99], [4, 6], [4, 7], [4, 8], [4, 10], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 20], [4, 22], [4, 24], [4, 28], [4, 29], [4, 30], [4, 31], [4, 33], [4, 36], [4, 38], [4, 39], [4, 41], [4, 42], [4, 45], [4, 46], [4, 47], [4, 48], [4, 50], [4, 53], [4, 55], [4, 59], [4, 64], [4, 65], [4, 69], [4, 72], [4, 74], [4, 77], [4, 80], [4, 82], [4, 83], [4, 84], [4, 85], [4, 86], [4, 94], [4, 97], [5, 8], [5, 9], [5, 10], [5, 12], [5, 14], [5, 16], [5, 17], [5, 19], [5, 21], [5, 23], [5, 25], [5, 27], [5, 28], [5, 29], [5, 30], [5, 32], [5, 33], [5, 34], [5, 35], [5, 36], [5, 37], [5, 40], [5, 41], [5, 42], [5, 43], [5, 44], [5, 46], [5, 47], [5, 48], [5, 50], [5, 51], [5, 52], [5, 53], [5, 55], [5, 56], [5, 59], [5, 61], [5, 63], [5, 64], [5, 65], [5, 66], [5, 69], [5, 70], [5, 71], [5, 72], [5, 73], [5, 74], [5, 75], [5, 76], [5, 77], [5, 78], [5, 79], [5, 80], [5, 81], [5, 84], [5, 86], [5, 87], [5, 90], [5, 91], [5, 95], [5, 99], [6, 9], [6, 11], [6, 12], [6, 13], [6, 15], [6, 17], [6, 18], [6, 20], [6, 24], [6, 30], [6, 32], [6, 33], [6, 35], [6, 38], [6, 40], [6, 42], [6, 43], [6, 44], [6, 46], [6, 48], [6, 50], [6, 51], [6, 53], [6, 56], [6, 58], [6, 60], [6, 61], [6, 64], [6, 69], [6, 72], [6, 73], [6, 76], [6, 78], [6, 80], [6, 81], [6, 82], [6, 83], [6, 87], [6, 91], [6, 94], [6, 95], [6, 97], [7, 9], [7, 11], [7, 12], [7, 14], [7, 16], [7, 17], [7, 26], [7, 29], [7, 30], [7, 31], [7, 32], [7, 35], [7, 36], [7, 37], [7, 38], [7, 39], [7, 40], [7, 43], [7, 45], [7, 47], [7, 53], [7, 54], [7, 60], [7, 65], [7, 66], [7, 67], [7, 68], [7, 69], [7, 70], [7, 71], [7, 74], [7, 75], [7, 77], [7, 78], [7, 79], [7, 83], [7, 84], [7, 87], [7, 89], [7, 92], [7, 96], [7, 98], [8, 9], [8, 10], [8, 12], [8, 18], [8, 19], [8, 21], [8, 25], [8, 27], [8, 29], [8, 36], [8, 37], [8, 39], [8, 40], [8, 42], [8, 43], [8, 46], [8, 47], [8, 49], [8, 51], [8, 52], [8, 53], [8, 57], [8, 59], [8, 62], [8, 63], [8, 64], [8, 65], [8, 68], [8, 72], [8, 73], [8, 74], [8, 77], [8, 78], [8, 79], [8, 83], [8, 85], [8, 87], [8, 90], [8, 91], [8, 92], [8, 96], [8, 97], [8, 98], [9, 11], [9, 13], [9, 14], [9, 15], [9, 18], [9, 24], [9, 25], [9, 26], [9, 28], [9, 29], [9, 30], [9, 32], [9, 33], [9, 35], [9, 38], [9, 40], [9, 41], [9, 42], [9, 43], [9, 44], [9, 51], [9, 54], [9, 55], [9, 56], [9, 57], [9, 58], [9, 60], [9, 61], [9, 63], [9, 66], [9, 68], [9, 70], [9, 73], [9, 76], [9, 77], [9, 79], [9, 82], [9, 84], [9, 85], [9, 87], [9, 89], [9, 91], [9, 93], [9, 95], [10, 11], [10, 12], [10, 17], [10, 20], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 31], [10, 32], [10, 33], [10, 38], [10, 39], [10, 40], [10, 41], [10, 42], [10, 44], [10, 45], [10, 47], [10, 49], [10, 51], [10, 53], [10, 60], [10, 61], [10, 62], [10, 64], [10, 66], [10, 67], [10, 68], [10, 69], [10, 70], [10, 75], [10, 77], [10, 78], [10, 79], [10, 80], [10, 82], [10, 83], [10, 85], [10, 86], [10, 87], [10, 90], [10, 91], [10, 93], [10, 95], [10, 96], [10, 98], [10, 99], [11, 13], [11, 15], [11, 16], [11, 18], [11, 24], [11, 26], [11, 27], [11, 28], [11, 30], [11, 32], [11, 33], [11, 36], [11, 38], [11, 43], [11, 45], [11, 47], [11, 48], [11, 51], [11, 53], [11, 54], [11, 55], [11, 56], [11, 57], [11, 61], [11, 63], [11, 64], [11, 65], [11, 68], [11, 69], [11, 72], [11, 73], [11, 74], [11, 78], [11, 81], [11, 82], [11, 83], [11, 89], [11, 91], [11, 94], [11, 95], [11, 96], [11, 99], [12, 14], [12, 16], [12, 17], [12, 20], [12, 23], [12, 24], [12, 25], [12, 26], [12, 30], [12, 31], [12, 32], [12, 34], [12, 35], [12, 37], [12, 39], [12, 43], [12, 45], [12, 48], [12, 49], [12, 51], [12, 52], [12, 54], [12, 55], [12, 58], [12, 60], [12, 65], [12, 66], [12, 69], [12, 70], [12, 72], [12, 75], [12, 76], [12, 79], [12, 82], [12, 87], [12, 89], [12, 94], [12, 95], [12, 99], [13, 16], [13, 17], [13, 18], [13, 21], [13, 23], [13, 24], [13, 29], [13, 30], [13, 31], [13, 35], [13, 41], [13, 42], [13, 43], [13, 45], [13, 47], [13, 48], [13, 49], [13, 53], [13, 54], [13, 56], [13, 57], [13, 58], [13, 61], [13, 71], [13, 72], [13, 73], [13, 74], [13, 75], [13, 76], [13, 78], [13, 79], [13, 81], [13, 83], [13, 85], [13, 91], [13, 92], [13, 95], [13, 96], [13, 97], [14, 15], [14, 17], [14, 23], [14, 28], [14, 31], [14, 33], [14, 35], [14, 38], [14, 39], [14, 41], [14, 42], [14, 47], [14, 49], [14, 51], [14, 54], [14, 55], [14, 57], [14, 59], [14, 61], [14, 65], [14, 68], [14, 71], [14, 72], [14, 76], [14, 77], [14, 78], [14, 79], [14, 81], [14, 83], [14, 84], [14, 85], [14, 87], [14, 88], [14, 90], [14, 92], [14, 93], [14, 96], [14, 97], [14, 98], [15, 19], [15, 21], [15, 22], [15, 24], [15, 26], [15, 30], [15, 32], [15, 35], [15, 36], [15, 37], [15, 38], [15, 39], [15, 43], [15, 44], [15, 46], [15, 47], [15, 52], [15, 53], [15, 57], [15, 58], [15, 60], [15, 61], [15, 62], [15, 63], [15, 67], [15, 69], [15, 72], [15, 73], [15, 74], [15, 75], [15, 77], [15, 78], [15, 79], [15, 80], [15, 81], [15, 83], [15, 84], [15, 85], [15, 87], [15, 88], [15, 90], [15, 92], [15, 93], [15, 94], [15, 95], [15, 99], [16, 17], [16, 18], [16, 21], [16, 27], [16, 30], [16, 31], [16, 32], [16, 34], [16, 37], [16, 39], [16, 41], [16, 42], [16, 47], [16, 48], [16, 49], [16, 50], [16, 51], [16, 52], [16, 53], [16, 57], [16, 58], [16, 59], [16, 64], [16, 65], [16, 67], [16, 68], [16, 71], [16, 72], [16, 75], [16, 76], [16, 77], [16, 78], [16, 79], [16, 83], [16, 84], [16, 85], [16, 90], [16, 91], [16, 92], [16, 98], [17, 18], [17, 20], [17, 21], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [17, 36], [17, 37], [17, 38], [17, 40], [17, 42], [17, 43], [17, 45], [17, 46], [17, 47], [17, 48], [17, 50], [17, 51], [17, 52], [17, 54], [17, 55], [17, 56], [17, 57], [17, 61], [17, 63], [17, 64], [17, 66], [17, 68], [17, 69], [17, 70], [17, 71], [17, 72], [17, 74], [17, 75], [17, 76], [17, 79], [17, 81], [17, 82], [17, 86], [17, 87], [17, 90], [17, 91], [17, 93], [17, 95], [17, 98], [17, 99], [18, 19], [18, 24], [18, 26], [18, 27], [18, 32], [18, 33], [18, 35], [18, 36], [18, 38], [18, 41], [18, 42], [18, 43], [18, 46], [18, 47], [18, 52], [18, 53], [18, 55], [18, 56], [18, 57], [18, 59], [18, 60], [18, 62], [18, 64], [18, 66], [18, 67], [18, 69], [18, 74], [18, 77], [18, 79], [18, 82], [18, 83], [18, 84], [18, 85], [18, 86], [18, 87], [18, 90], [18, 91], [18, 93], [18, 94], [18, 97], [18, 98], [18, 99], [19, 20], [19, 21], [19, 22], [19, 23], [19, 26], [19, 27], [19, 30], [19, 31], [19, 33], [19, 34], [19, 35], [19, 36], [19, 39], [19, 41], [19, 42], [19, 43], [19, 46], [19, 49], [19, 51], [19, 52], [19, 53], [19, 54], [19, 55], [19, 56], [19, 59], [19, 62], [19, 66], [19, 68], [19, 70], [19, 71], [19, 73], [19, 75], [19, 79], [19, 80], [19, 81], [19, 84], [19, 86], [19, 90], [19, 91], [19, 92], [19, 93], [19, 97], [19, 98], [20, 22], [20, 25], [20, 26], [20, 27], [20, 29], [20, 30], [20, 31], [20, 33], [20, 36], [20, 37], [20, 40], [20, 44], [20, 47], [20, 49], [20, 53], [20, 55], [20, 58], [20, 61], [20, 62], [20, 63], [20, 67], [20, 68], [20, 69], [20, 70], [20, 72], [20, 74], [20, 76], [20, 77], [20, 80], [20, 81], [20, 82], [20, 83], [20, 86], [20, 87], [20, 88], [20, 91], [20, 92], [20, 95], [20, 96], [20, 97], [20, 98], [21, 23], [21, 26], [21, 28], [21, 29], [21, 30], [21, 31], [21, 35], [21, 36], [21, 38], [21, 39], [21, 41], [21, 42], [21, 44], [21, 45], [21, 47], [21, 50], [21, 52], [21, 56], [21, 57], [21, 59], [21, 60], [21, 61], [21, 62], [21, 65], [21, 68], [21, 73], [21, 74], [21, 77], [21, 79], [21, 80], [21, 81], [21, 83], [21, 85], [21, 88], [21, 91], [21, 94], [21, 95], [21, 96], [21, 97], [22, 23], [22, 25], [22, 27], [22, 28], [22, 30], [22, 32], [22, 33], [22, 34], [22, 35], [22, 36], [22, 38], [22, 39], [22, 41], [22, 43], [22, 47], [22, 51], [22, 52], [22, 53], [22, 55], [22, 58], [22, 59], [22, 60], [22, 62], [22, 64], [22, 65], [22, 67], [22, 70], [22, 71], [22, 72], [22, 73], [22, 75], [22, 76], [22, 78], [22, 80], [22, 83], [22, 84], [22, 85], [22, 87], [22, 88], [22, 90], [22, 94], [22, 95], [22, 96], [22, 97], [22, 98], [23, 24], [23, 25], [23, 26], [23, 28], [23, 29], [23, 33], [23, 34], [23, 35], [23, 39], [23, 40], [23, 43], [23, 44], [23, 46], [23, 47], [23, 49], [23, 50], [23, 54], [23, 55], [23, 57], [23, 58], [23, 59], [23, 60], [23, 61], [23, 63], [23, 71], [23, 73], [23, 74], [23, 76], [23, 77], [23, 79], [23, 80], [23, 81], [23, 82], [23, 84], [23, 85], [23, 89], [23, 90], [23, 91], [23, 92], [23, 95], [23, 96], [23, 99], [24, 26], [24, 30], [24, 31], [24, 34], [24, 36], [24, 37], [24, 41], [24, 42], [24, 43], [24, 45], [24, 46], [24, 48], [24, 49], [24, 51], [24, 53], [24, 54], [24, 56], [24, 57], [24, 58], [24, 59], [24, 60], [24, 61], [24, 62], [24, 63], [24, 69], [24, 71], [24, 76], [24, 78], [24, 84], [24, 85], [24, 88], [24, 90], [24, 94], [24, 95], [24, 96], [24, 99], [25, 27], [25, 29], [25, 30], [25, 31], [25, 35], [25, 38], [25, 42], [25, 43], [25, 44], [25, 47], [25, 48], [25, 49], [25, 52], [25, 57], [25, 60], [25, 61], [25, 62], [25, 64], [25, 65], [25, 69], [25, 71], [25, 72], [25, 74], [25, 75], [25, 77], [25, 78], [25, 82], [25, 86], [25, 87], [25, 90], [25, 91], [25, 95], [25, 96], [25, 97], [25, 99], [26, 27], [26, 28], [26, 29], [26, 32], [26, 34], [26, 36], [26, 37], [26, 38], [26, 39], [26, 40], [26, 41], [26, 43], [26, 44], [26, 45], [26, 46], [26, 47], [26, 51], [26, 52], [26, 56], [26, 57], [26, 59], [26, 60], [26, 61], [26, 64], [26, 66], [26, 67], [26, 68], [26, 73], [26, 75], [26, 77], [26, 78], [26, 79], [26, 82], [26, 85], [26, 86], [26, 87], [26, 88], [26, 89], [26, 90], [26, 95], [26, 99], [27, 30], [27, 32], [27, 34], [27, 35], [27, 37], [27, 40], [27, 41], [27, 43], [27, 45], [27, 46], [27, 47], [27, 48], [27, 49], [27, 50], [27, 51], [27, 52], [27, 54], [27, 55], [27, 56], [27, 57], [27, 58], [27, 60], [27, 67], [27, 69], [27, 70], [27, 71], [27, 72], [27, 73], [27, 74], [27, 76], [27, 78], [27, 79], [27, 83], [27, 84], [27, 85], [27, 86], [27, 87], [27, 88], [27, 89], [27, 91], [27, 92], [27, 95], [27, 99], [28, 30], [28, 31], [28, 36], [28, 37], [28, 38], [28, 39], [28, 41], [28, 42], [28, 43], [28, 44], [28, 46], [28, 47], [28, 49], [28, 50], [28, 51], [28, 53], [28, 56], [28, 57], [28, 59], [28, 60], [28, 61], [28, 63], [28, 69], [28, 70], [28, 71], [28, 72], [28, 75], [28, 77], [28, 79], [28, 80], [28, 81], [28, 82], [28, 83], [28, 85], [28, 86], [28, 88], [28, 89], [28, 91], [28, 93], [28, 96], [28, 97], [28, 99], [29, 30], [29, 34], [29, 36], [29, 38], [29, 46], [29, 50], [29, 51], [29, 52], [29, 53], [29, 55], [29, 56], [29, 57], [29, 59], [29, 62], [29, 65], [29, 66], [29, 67], [29, 70], [29, 71], [29, 73], [29, 74], [29, 76], [29, 79], [29, 81], [29, 84], [29, 87], [29, 88], [29, 89], [29, 98], [29, 99], [30, 33], [30, 35], [30, 37], [30, 38], [30, 39], [30, 40], [30, 42], [30, 43], [30, 44], [30, 45], [30, 46], [30, 48], [30, 49], [30, 50], [30, 51], [30, 53], [30, 55], [30, 60], [30, 62], [30, 63], [30, 64], [30, 65], [30, 68], [30, 69], [30, 73], [30, 75], [30, 77], [30, 78], [30, 82], [30, 83], [30, 86], [30, 87], [30, 88], [30, 89], [30, 90], [30, 91], [30, 92], [30, 94], [30, 95], [30, 97], [30, 98], [30, 99], [31, 32], [31, 34], [31, 35], [31, 37], [31, 38], [31, 39], [31, 40], [31, 41], [31, 42], [31, 43], [31, 45], [31, 46], [31, 52], [31, 55], [31, 61], [31, 62], [31, 63], [31, 65], [31, 67], [31, 71], [31, 76], [31, 77], [31, 78], [31, 82], [31, 89], [31, 90], [31, 91], [31, 93], [31, 96], [32, 33], [32, 35], [32, 36], [32, 40], [32, 42], [32, 45], [32, 47], [32, 50], [32, 51], [32, 53], [32, 54], [32, 58], [32, 59], [32, 60], [32, 61], [32, 63], [32, 66], [32, 68], [32, 72], [32, 81], [32, 82], [32, 83], [32, 84], [32, 85], [32, 88], [32, 89], [32, 90], [32, 91], [32, 92], [32, 96], [33, 35], [33, 36], [33, 37], [33, 38], [33, 39], [33, 41], [33, 46], [33, 48], [33, 50], [33, 52], [33, 53], [33, 56], [33, 57], [33, 58], [33, 59], [33, 61], [33, 63], [33, 67], [33, 76], [33, 77], [33, 78], [33, 84], [33, 85], [33, 89], [33, 90], [33, 91], [33, 92], [33, 94], [33, 95], [33, 97], [33, 98], [34, 35], [34, 36], [34, 38], [34, 39], [34, 40], [34, 43], [34, 44], [34, 45], [34, 46], [34, 47], [34, 48], [34, 52], [34, 53], [34, 55], [34, 56], [34, 58], [34, 59], [34, 60], [34, 62], [34, 69], [34, 71], [34, 72], [34, 74], [34, 76], [34, 77], [34, 79], [34, 80], [34, 85], [34, 88], [34, 92], [34, 93], [34, 95], [34, 97], [34, 99], [35, 36], [35, 38], [35, 39], [35, 40], [35, 43], [35, 45], [35, 46], [35, 47], [35, 48], [35, 49], [35, 50], [35, 51], [35, 52], [35, 54], [35, 55], [35, 56], [35, 57], [35, 58], [35, 65], [35, 66], [35, 67], [35, 68], [35, 69], [35, 70], [35, 71], [35, 74], [35, 75], [35, 78], [35, 79], [35, 81], [35, 82], [35, 83], [35, 84], [35, 85], [35, 86], [35, 87], [35, 89], [35, 90], [35, 91], [35, 92], [35, 93], [35, 98], [36, 38], [36, 39], [36, 41], [36, 44], [36, 46], [36, 47], [36, 50], [36, 52], [36, 56], [36, 59], [36, 60], [36, 62], [36, 64], [36, 66], [36, 67], [36, 68], [36, 71], [36, 72], [36, 78], [36, 79], [36, 82], [36, 83], [36, 85], [36, 86], [36, 87], [36, 88], [36, 89], [36, 92], [36, 93], [36, 94], [36, 96], [36, 99], [37, 38], [37, 39], [37, 40], [37, 44], [37, 45], [37, 46], [37, 47], [37, 48], [37, 52], [37, 56], [37, 59], [37, 66], [37, 67], [37, 72], [37, 73], [37, 76], [37, 77], [37, 78], [37, 79], [37, 81], [37, 82], [37, 85], [37, 86], [37, 89], [37, 90], [37, 97], [37, 99], [38, 39], [38, 40], [38, 41], [38, 45], [38, 46], [38, 47], [38, 48], [38, 50], [38, 51], [38, 55], [38, 57], [38, 58], [38, 59], [38, 61], [38, 62], [38, 63], [38, 64], [38, 67], [38, 69], [38, 70], [38, 71], [38, 75], [38, 76], [38, 78], [38, 83], [38, 84], [38, 87], [38, 88], [38, 89], [38, 93], [38, 96], [38, 97], [38, 98], [38, 99], [39, 43], [39, 45], [39, 48], [39, 49], [39, 50], [39, 53], [39, 54], [39, 55], [39, 58], [39, 59], [39, 60], [39, 63], [39, 65], [39, 67], [39, 68], [39, 69], [39, 72], [39, 76], [39, 77], [39, 80], [39, 83], [39, 86], [39, 88], [39, 89], [39, 92], [39, 93], [39, 99], [40, 41], [40, 42], [40, 43], [40, 44], [40, 45], [40, 46], [40, 47], [40, 48], [40, 50], [40, 51], [40, 52], [40, 53], [40, 54], [40, 55], [40, 56], [40, 57], [40, 58], [40, 60], [40, 62], [40, 63], [40, 66], [40, 67], [40, 69], [40, 70], [40, 71], [40, 73], [40, 74], [40, 75], [40, 76], [40, 77], [40, 78], [40, 79], [40, 80], [40, 83], [40, 84], [40, 86], [40, 87], [40, 89], [40, 91], [40, 93], [40, 98], [40, 99], [41, 42], [41, 44], [41, 45], [41, 46], [41, 50], [41, 55], [41, 58], [41, 61], [41, 62], [41, 64], [41, 66], [41, 67], [41, 69], [41, 71], [41, 74], [41, 75], [41, 83], [41, 84], [41, 85], [41, 86], [41, 90], [41, 92], [41, 93], [41, 94], [41, 97], [41, 98], [42, 43], [42, 45], [42, 47], [42, 48], [42, 49], [42, 50], [42, 52], [42, 59], [42, 65], [42, 66], [42, 67], [42, 71], [42, 73], [42, 75], [42, 77], [42, 79], [42, 81], [42, 86], [42, 87], [42, 90], [42, 92], [42, 96], [42, 97], [43, 44], [43, 46], [43, 47], [43, 48], [43, 50], [43, 51], [43, 52], [43, 53], [43, 54], [43, 55], [43, 56], [43, 57], [43, 58], [43, 61], [43, 62], [43, 63], [43, 65], [43, 67], [43, 69], [43, 70], [43, 71], [43, 74], [43, 75], [43, 76], [43, 79], [43, 81], [43, 85], [43, 86], [43, 87], [43, 88], [43, 91], [43, 92], [43, 93], [43, 95], [44, 46], [44, 48], [44, 51], [44, 52], [44, 53], [44, 55], [44, 56], [44, 60], [44, 63], [44, 66], [44, 68], [44, 69], [44, 73], [44, 74], [44, 79], [44, 80], [44, 81], [44, 85], [44, 88], [44, 91], [44, 92], [44, 93], [44, 94], [44, 97], [44, 99], [45, 49], [45, 51], [45, 52], [45, 53], [45, 55], [45, 56], [45, 58], [45, 59], [45, 60], [45, 62], [45, 68], [45, 69], [45, 70], [45, 71], [45, 80], [45, 81], [45, 82], [45, 88], [45, 90], [45, 91], [45, 96], [45, 97], [45, 98], [46, 47], [46, 48], [46, 49], [46, 50], [46, 51], [46, 52], [46, 54], [46, 55], [46, 56], [46, 57], [46, 58], [46, 61], [46, 66], [46, 67], [46, 69], [46, 70], [46, 71], [46, 72], [46, 74], [46, 75], [46, 76], [46, 77], [46, 78], [46, 79], [46, 81], [46, 82], [46, 83], [46, 84], [46, 85], [46, 86], [46, 87], [46, 88], [46, 91], [46, 92], [46, 94], [46, 95], [46, 96], [46, 99], [47, 48], [47, 50], [47, 51], [47, 52], [47, 54], [47, 55], [47, 56], [47, 57], [47, 59], [47, 60], [47, 61], [47, 62], [47, 63], [47, 65], [47, 68], [47, 69], [47, 70], [47, 71], [47, 72], [47, 73], [47, 74], [47, 77], [47, 79], [47, 83], [47, 86], [47, 87], [47, 89], [47, 91], [47, 92], [47, 95], [47, 97], [47, 99], [48, 50], [48, 51], [48, 52], [48, 54], [48, 55], [48, 56], [48, 57], [48, 59], [48, 62], [48, 63], [48, 64], [48, 67], [48, 69], [48, 70], [48, 72], [48, 73], [48, 74], [48, 75], [48, 76], [48, 78], [48, 79], [48, 80], [48, 83], [48, 85], [48, 87], [48, 90], [48, 91], [48, 92], [48, 93], [48, 94], [48, 96], [48, 99], [49, 50], [49, 52], [49, 55], [49, 57], [49, 58], [49, 59], [49, 60], [49, 61], [49, 63], [49, 68], [49, 69], [49, 73], [49, 75], [49, 80], [49, 81], [49, 82], [49, 83], [49, 87], [49, 88], [49, 90], [49, 91], [49, 95], [49, 97], [49, 99], [50, 51], [50, 52], [50, 54], [50, 55], [50, 56], [50, 57], [50, 60], [50, 61], [50, 63], [50, 67], [50, 68], [50, 69], [50, 70], [50, 72], [50, 74], [50, 76], [50, 77], [50, 78], [50, 79], [50, 80], [50, 81], [50, 87], [50, 89], [50, 91], [50, 93], [50, 94], [50, 98], [51, 52], [51, 53], [51, 54], [51, 55], [51, 56], [51, 58], [51, 60], [51, 64], [51, 67], [51, 68], [51, 69], [51, 70], [51, 72], [51, 73], [51, 74], [51, 76], [51, 77], [51, 79], [51, 80], [51, 84], [51, 85], [51, 87], [51, 88], [51, 91], [51, 93], [51, 96], [51, 97], [51, 98], [52, 53], [52, 54], [52, 55], [52, 56], [52, 58], [52, 59], [52, 60], [52, 61], [52, 62], [52, 64], [52, 66], [52, 69], [52, 70], [52, 72], [52, 73], [52, 74], [52, 78], [52, 79], [52, 82], [52, 83], [52, 84], [52, 86], [52, 87], [52, 89], [52, 90], [52, 91], [52, 93], [52, 94], [52, 96], [52, 99], [53, 54], [53, 55], [53, 56], [53, 59], [53, 60], [53, 63], [53, 64], [53, 65], [53, 66], [53, 70], [53, 71], [53, 75], [53, 77], [53, 78], [53, 81], [53, 83], [53, 86], [53, 88], [53, 89], [53, 91], [53, 93], [53, 95], [53, 96], [53, 98], [53, 99], [54, 57], [54, 58], [54, 61], [54, 67], [54, 70], [54, 71], [54, 72], [54, 76], [54, 81], [54, 83], [54, 85], [54, 86], [54, 87], [54, 90], [54, 94], [54, 95], [55, 56], [55, 58], [55, 59], [55, 61], [55, 62], [55, 63], [55, 65], [55, 67], [55, 68], [55, 69], [55, 70], [55, 71], [55, 72], [55, 73], [55, 74], [55, 78], [55, 79], [55, 82], [55, 83], [55, 84], [55, 85], [55, 87], [55, 89], [55, 90], [55, 91], [55, 92], [55, 93], [55, 95], [55, 96], [55, 99], [56, 58], [56, 60], [56, 61], [56, 62], [56, 63], [56, 64], [56, 65], [56, 69], [56, 70], [56, 72], [56, 73], [56, 74], [56, 75], [56, 76], [56, 77], [56, 78], [56, 79], [56, 80], [56, 81], [56, 83], [56, 84], [56, 85], [56, 86], [56, 87], [56, 88], [56, 89], [56, 90], [56, 91], [56, 92], [56, 94], [56, 95], [56, 96], [57, 60], [57, 61], [57, 65], [57, 66], [57, 68], [57, 69], [57, 71], [57, 74], [57, 75], [57, 78], [57, 79], [57, 80], [57, 81], [57, 82], [57, 85], [57, 86], [57, 89], [57, 90], [57, 95], [57, 98], [57, 99], [58, 62], [58, 63], [58, 67], [58, 69], [58, 70], [58, 73], [58, 74], [58, 80], [58, 83], [58, 84], [58, 85], [58, 88], [58, 89], [58, 90], [58, 91], [58, 92], [58, 93], [58, 95], [59, 60], [59, 61], [59, 62], [59, 63], [59, 65], [59, 66], [59, 68], [59, 69], [59, 72], [59, 74], [59, 75], [59, 77], [59, 78], [59, 79], [59, 81], [59, 82], [59, 84], [59, 85], [59, 88], [59, 89], [59, 90], [59, 92], [59, 96], [59, 97], [59, 98], [59, 99], [60, 61], [60, 64], [60, 66], [60, 71], [60, 73], [60, 74], [60, 78], [60, 79], [60, 80], [60, 81], [60, 83], [60, 84], [60, 85], [60, 86], [60, 88], [60, 89], [60, 90], [60, 91], [60, 92], [60, 94], [60, 95], [60, 99], [61, 62], [61, 63], [61, 67], [61, 68], [61, 70], [61, 73], [61, 74], [61, 75], [61, 79], [61, 80], [61, 82], [61, 83], [61, 84], [61, 85], [61, 88], [61, 89], [61, 90], [61, 92], [61, 94], [61, 98], [61, 99], [62, 65], [62, 68], [62, 69], [62, 70], [62, 71], [62, 72], [62, 74], [62, 75], [62, 78], [62, 79], [62, 81], [62, 83], [62, 84], [62, 86], [62, 87], [62, 89], [62, 90], [62, 97], [62, 98], [62, 99], [63, 64], [63, 66], [63, 67], [63, 68], [63, 69], [63, 70], [63, 71], [63, 72], [63, 76], [63, 78], [63, 79], [63, 81], [63, 88], [63, 89], [63, 90], [63, 92], [63, 93], [63, 95], [63, 96], [63, 97], [63, 98], [63, 99], [64, 65], [64, 66], [64, 71], [64, 74], [64, 75], [64, 77], [64, 78], [64, 79], [64, 83], [64, 85], [64, 86], [64, 87], [64, 92], [64, 93], [64, 94], [64, 96], [64, 98], [65, 68], [65, 69], [65, 71], [65, 72], [65, 74], [65, 83], [65, 84], [65, 85], [65, 88], [65, 90], [65, 92], [65, 93], [65, 94], [65, 95], [65, 99], [66, 67], [66, 68], [66, 71], [66, 74], [66, 76], [66, 78], [66, 79], [66, 80], [66, 82], [66, 83], [66, 84], [66, 87], [66, 90], [66, 91], [66, 94], [66, 96], [66, 98], [66, 99], [67, 71], [67, 72], [67, 73], [67, 81], [67, 82], [67, 83], [67, 85], [67, 86], [67, 88], [67, 90], [67, 91], [67, 92], [67, 94], [67, 96], [67, 98], [68, 69], [68, 70], [68, 71], [68, 72], [68, 74], [68, 76], [68, 77], [68, 79], [68, 81], [68, 82], [68, 83], [68, 86], [68, 87], [68, 88], [68, 89], [68, 90], [68, 96], [68, 97], [68, 98], [69, 70], [69, 73], [69, 74], [69, 75], [69, 76], [69, 78], [69, 79], [69, 80], [69, 81], [69, 83], [69, 84], [69, 85], [69, 87], [69, 90], [69, 91], [69, 92], [69, 94], [69, 95], [69, 96], [69, 97], [69, 99], [70, 72], [70, 74], [70, 75], [70, 78], [70, 79], [70, 80], [70, 81], [70, 83], [70, 84], [70, 86], [70, 87], [70, 88], [70, 91], [70, 97], [70, 98], [71, 74], [71, 75], [71, 76], [71, 79], [71, 83], [71, 85], [71, 87], [71, 88], [71, 89], [71, 91], [71, 95], [71, 96], [71, 99], [72, 73], [72, 74], [72, 76], [72, 79], [72, 80], [72, 81], [72, 83], [72, 84], [72, 85], [72, 88], [72, 91], [72, 98], [73, 74], [73, 78], [73, 79], [73, 80], [73, 87], [73, 90], [73, 91], [73, 93], [73, 96], [73, 98], [74, 76], [74, 79], [74, 81], [74, 83], [74, 84], [74, 86], [74, 87], [74, 91], [74, 95], [74, 96], [75, 76], [75, 78], [75, 79], [75, 80], [75, 81], [75, 82], [75, 83], [75, 90], [75, 91], [75, 92], [75, 94], [75, 95], [75, 97], [75, 99], [76, 79], [76, 80], [76, 84], [76, 85], [76, 87], [76, 88], [76, 89], [76, 94], [76, 95], [76, 96], [76, 97], [76, 98], [76, 99], [77, 78], [77, 81], [77, 82], [77, 83], [77, 84], [77, 85], [77, 86], [77, 88], [77, 90], [77, 91], [77, 92], [77, 95], [78, 80], [78, 81], [78, 82], [78, 83], [78, 84], [78, 86], [78, 87], [78, 89], [78, 90], [78, 92], [78, 96], [78, 97], [78, 99], [79, 80], [79, 81], [79, 82], [79, 84], [79, 85], [79, 87], [79, 90], [79, 91], [79, 93], [79, 94], [79, 96], [79, 98], [79, 99], [80, 81], [80, 82], [80, 84], [80, 85], [80, 86], [80, 88], [80, 91], [80, 93], [80, 95], [80, 97], [80, 99], [81, 84], [81, 87], [81, 91], [81, 94], [81, 95], [82, 83], [82, 86], [82, 89], [82, 91], [82, 93], [82, 95], [82, 97], [83, 90], [83, 92], [83, 94], [83, 97], [83, 99], [84, 85], [84, 87], [84, 89], [84, 92], [84, 95], [84, 96], [85, 86], [85, 92], [85, 94], [85, 97], [85, 98], [85, 99], [86, 87], [86, 92], [86, 94], [86, 95], [87, 88], [87, 90], [87, 91], [87, 93], [87, 94], [87, 95], [87, 96], [88, 89], [88, 91], [88, 95], [88, 96], [88, 99], [89, 90], [89, 93], [89, 97], [89, 99], [90, 91], [90, 93], [90, 94], [90, 95], [90, 98], [91, 94], [91, 97], [91, 98], [92, 93], [92, 94], [92, 96], [92, 97], [92, 99], [93, 94], [94, 96], [95, 96], [95, 97], [95, 99], [96, 97]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s0/solution/solve.sh b/tasks/construct-nppc-clique-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e918533f95dc86727c516dec9ec07e47b524cbab --- /dev/null +++ b/tasks/construct-nppc-clique-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' +{"clique": [5, 17, 27, 35, 40, 43, 46, 47, 48, 50, 51, 52, 55, 56, 69, 70, 74, 79, 87, 91]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l6-s0/tests/check.py b/tasks/construct-nppc-clique-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s0/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l6-s0/tests/instance.json b/tasks/construct-nppc-clique-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..899f8cfef93e0611a290224571984d582bd758af --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 1], [0, 3], [0, 5], [0, 6], [0, 7], [0, 10], [0, 12], [0, 14], [0, 18], [0, 20], [0, 21], [0, 23], [0, 26], [0, 28], [0, 30], [0, 31], [0, 39], [0, 40], [0, 43], [0, 44], [0, 48], [0, 49], [0, 50], [0, 52], [0, 53], [0, 56], [0, 58], [0, 62], [0, 63], [0, 66], [0, 68], [0, 69], [0, 71], [0, 72], [0, 75], [0, 79], [0, 80], [0, 81], [0, 85], [0, 87], [0, 94], [0, 95], [0, 98], [0, 99], [1, 4], [1, 5], [1, 6], [1, 10], [1, 13], [1, 17], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 34], [1, 41], [1, 42], [1, 46], [1, 47], [1, 48], [1, 49], [1, 51], [1, 53], [1, 56], [1, 57], [1, 59], [1, 60], [1, 64], [1, 65], [1, 66], [1, 67], [1, 69], [1, 70], [1, 73], [1, 76], [1, 78], [1, 79], [1, 84], [1, 85], [1, 86], [1, 90], [1, 91], [1, 92], [1, 94], [1, 97], [1, 99], [2, 3], [2, 4], [2, 7], [2, 11], [2, 14], [2, 15], [2, 17], [2, 21], [2, 22], [2, 23], [2, 26], [2, 29], [2, 31], [2, 34], [2, 35], [2, 36], [2, 38], [2, 40], [2, 42], [2, 43], [2, 45], [2, 46], [2, 47], [2, 49], [2, 50], [2, 51], [2, 52], [2, 55], [2, 59], [2, 61], [2, 65], [2, 66], [2, 67], [2, 68], [2, 69], [2, 76], [2, 81], [2, 82], [2, 83], [2, 84], [2, 85], [2, 87], [2, 89], [2, 90], [2, 91], [2, 92], [2, 93], [2, 94], [2, 97], [2, 99], [3, 4], [3, 5], [3, 10], [3, 13], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 22], [3, 23], [3, 26], [3, 27], [3, 32], [3, 35], [3, 36], [3, 37], [3, 42], [3, 44], [3, 46], [3, 47], [3, 52], [3, 53], [3, 54], [3, 55], [3, 56], [3, 57], [3, 58], [3, 59], [3, 60], [3, 62], [3, 63], [3, 64], [3, 72], [3, 75], [3, 79], [3, 80], [3, 81], [3, 82], [3, 83], [3, 86], [3, 89], [3, 91], [3, 92], [3, 95], [3, 96], [3, 99], [4, 6], [4, 7], [4, 8], [4, 10], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 20], [4, 22], [4, 24], [4, 28], [4, 29], [4, 30], [4, 31], [4, 33], [4, 36], [4, 38], [4, 39], [4, 41], [4, 42], [4, 45], [4, 46], [4, 47], [4, 48], [4, 50], [4, 53], [4, 55], [4, 59], [4, 64], [4, 65], [4, 69], [4, 72], [4, 74], [4, 77], [4, 80], [4, 82], [4, 83], [4, 84], [4, 85], [4, 86], [4, 94], [4, 97], [5, 8], [5, 9], [5, 10], [5, 12], [5, 14], [5, 16], [5, 17], [5, 19], [5, 21], [5, 23], [5, 25], [5, 27], [5, 28], [5, 29], [5, 30], [5, 32], [5, 33], [5, 34], [5, 35], [5, 36], [5, 37], [5, 40], [5, 41], [5, 42], [5, 43], [5, 44], [5, 46], [5, 47], [5, 48], [5, 50], [5, 51], [5, 52], [5, 53], [5, 55], [5, 56], [5, 59], [5, 61], [5, 63], [5, 64], [5, 65], [5, 66], [5, 69], [5, 70], [5, 71], [5, 72], [5, 73], [5, 74], [5, 75], [5, 76], [5, 77], [5, 78], [5, 79], [5, 80], [5, 81], [5, 84], [5, 86], [5, 87], [5, 90], [5, 91], [5, 95], [5, 99], [6, 9], [6, 11], [6, 12], [6, 13], [6, 15], [6, 17], [6, 18], [6, 20], [6, 24], [6, 30], [6, 32], [6, 33], [6, 35], [6, 38], [6, 40], [6, 42], [6, 43], [6, 44], [6, 46], [6, 48], [6, 50], [6, 51], [6, 53], [6, 56], [6, 58], [6, 60], [6, 61], [6, 64], [6, 69], [6, 72], [6, 73], [6, 76], [6, 78], [6, 80], [6, 81], [6, 82], [6, 83], [6, 87], [6, 91], [6, 94], [6, 95], [6, 97], [7, 9], [7, 11], [7, 12], [7, 14], [7, 16], [7, 17], [7, 26], [7, 29], [7, 30], [7, 31], [7, 32], [7, 35], [7, 36], [7, 37], [7, 38], [7, 39], [7, 40], [7, 43], [7, 45], [7, 47], [7, 53], [7, 54], [7, 60], [7, 65], [7, 66], [7, 67], [7, 68], [7, 69], [7, 70], [7, 71], [7, 74], [7, 75], [7, 77], [7, 78], [7, 79], [7, 83], [7, 84], [7, 87], [7, 89], [7, 92], [7, 96], [7, 98], [8, 9], [8, 10], [8, 12], [8, 18], [8, 19], [8, 21], [8, 25], [8, 27], [8, 29], [8, 36], [8, 37], [8, 39], [8, 40], [8, 42], [8, 43], [8, 46], [8, 47], [8, 49], [8, 51], [8, 52], [8, 53], [8, 57], [8, 59], [8, 62], [8, 63], [8, 64], [8, 65], [8, 68], [8, 72], [8, 73], [8, 74], [8, 77], [8, 78], [8, 79], [8, 83], [8, 85], [8, 87], [8, 90], [8, 91], [8, 92], [8, 96], [8, 97], [8, 98], [9, 11], [9, 13], [9, 14], [9, 15], [9, 18], [9, 24], [9, 25], [9, 26], [9, 28], [9, 29], [9, 30], [9, 32], [9, 33], [9, 35], [9, 38], [9, 40], [9, 41], [9, 42], [9, 43], [9, 44], [9, 51], [9, 54], [9, 55], [9, 56], [9, 57], [9, 58], [9, 60], [9, 61], [9, 63], [9, 66], [9, 68], [9, 70], [9, 73], [9, 76], [9, 77], [9, 79], [9, 82], [9, 84], [9, 85], [9, 87], [9, 89], [9, 91], [9, 93], [9, 95], [10, 11], [10, 12], [10, 17], [10, 20], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 31], [10, 32], [10, 33], [10, 38], [10, 39], [10, 40], [10, 41], [10, 42], [10, 44], [10, 45], [10, 47], [10, 49], [10, 51], [10, 53], [10, 60], [10, 61], [10, 62], [10, 64], [10, 66], [10, 67], [10, 68], [10, 69], [10, 70], [10, 75], [10, 77], [10, 78], [10, 79], [10, 80], [10, 82], [10, 83], [10, 85], [10, 86], [10, 87], [10, 90], [10, 91], [10, 93], [10, 95], [10, 96], [10, 98], [10, 99], [11, 13], [11, 15], [11, 16], [11, 18], [11, 24], [11, 26], [11, 27], [11, 28], [11, 30], [11, 32], [11, 33], [11, 36], [11, 38], [11, 43], [11, 45], [11, 47], [11, 48], [11, 51], [11, 53], [11, 54], [11, 55], [11, 56], [11, 57], [11, 61], [11, 63], [11, 64], [11, 65], [11, 68], [11, 69], [11, 72], [11, 73], [11, 74], [11, 78], [11, 81], [11, 82], [11, 83], [11, 89], [11, 91], [11, 94], [11, 95], [11, 96], [11, 99], [12, 14], [12, 16], [12, 17], [12, 20], [12, 23], [12, 24], [12, 25], [12, 26], [12, 30], [12, 31], [12, 32], [12, 34], [12, 35], [12, 37], [12, 39], [12, 43], [12, 45], [12, 48], [12, 49], [12, 51], [12, 52], [12, 54], [12, 55], [12, 58], [12, 60], [12, 65], [12, 66], [12, 69], [12, 70], [12, 72], [12, 75], [12, 76], [12, 79], [12, 82], [12, 87], [12, 89], [12, 94], [12, 95], [12, 99], [13, 16], [13, 17], [13, 18], [13, 21], [13, 23], [13, 24], [13, 29], [13, 30], [13, 31], [13, 35], [13, 41], [13, 42], [13, 43], [13, 45], [13, 47], [13, 48], [13, 49], [13, 53], [13, 54], [13, 56], [13, 57], [13, 58], [13, 61], [13, 71], [13, 72], [13, 73], [13, 74], [13, 75], [13, 76], [13, 78], [13, 79], [13, 81], [13, 83], [13, 85], [13, 91], [13, 92], [13, 95], [13, 96], [13, 97], [14, 15], [14, 17], [14, 23], [14, 28], [14, 31], [14, 33], [14, 35], [14, 38], [14, 39], [14, 41], [14, 42], [14, 47], [14, 49], [14, 51], [14, 54], [14, 55], [14, 57], [14, 59], [14, 61], [14, 65], [14, 68], [14, 71], [14, 72], [14, 76], [14, 77], [14, 78], [14, 79], [14, 81], [14, 83], [14, 84], [14, 85], [14, 87], [14, 88], [14, 90], [14, 92], [14, 93], [14, 96], [14, 97], [14, 98], [15, 19], [15, 21], [15, 22], [15, 24], [15, 26], [15, 30], [15, 32], [15, 35], [15, 36], [15, 37], [15, 38], [15, 39], [15, 43], [15, 44], [15, 46], [15, 47], [15, 52], [15, 53], [15, 57], [15, 58], [15, 60], [15, 61], [15, 62], [15, 63], [15, 67], [15, 69], [15, 72], [15, 73], [15, 74], [15, 75], [15, 77], [15, 78], [15, 79], [15, 80], [15, 81], [15, 83], [15, 84], [15, 85], [15, 87], [15, 88], [15, 90], [15, 92], [15, 93], [15, 94], [15, 95], [15, 99], [16, 17], [16, 18], [16, 21], [16, 27], [16, 30], [16, 31], [16, 32], [16, 34], [16, 37], [16, 39], [16, 41], [16, 42], [16, 47], [16, 48], [16, 49], [16, 50], [16, 51], [16, 52], [16, 53], [16, 57], [16, 58], [16, 59], [16, 64], [16, 65], [16, 67], [16, 68], [16, 71], [16, 72], [16, 75], [16, 76], [16, 77], [16, 78], [16, 79], [16, 83], [16, 84], [16, 85], [16, 90], [16, 91], [16, 92], [16, 98], [17, 18], [17, 20], [17, 21], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 33], [17, 34], [17, 35], [17, 36], [17, 37], [17, 38], [17, 40], [17, 42], [17, 43], [17, 45], [17, 46], [17, 47], [17, 48], [17, 50], [17, 51], [17, 52], [17, 54], [17, 55], [17, 56], [17, 57], [17, 61], [17, 63], [17, 64], [17, 66], [17, 68], [17, 69], [17, 70], [17, 71], [17, 72], [17, 74], [17, 75], [17, 76], [17, 79], [17, 81], [17, 82], [17, 86], [17, 87], [17, 90], [17, 91], [17, 93], [17, 95], [17, 98], [17, 99], [18, 19], [18, 24], [18, 26], [18, 27], [18, 32], [18, 33], [18, 35], [18, 36], [18, 38], [18, 41], [18, 42], [18, 43], [18, 46], [18, 47], [18, 52], [18, 53], [18, 55], [18, 56], [18, 57], [18, 59], [18, 60], [18, 62], [18, 64], [18, 66], [18, 67], [18, 69], [18, 74], [18, 77], [18, 79], [18, 82], [18, 83], [18, 84], [18, 85], [18, 86], [18, 87], [18, 90], [18, 91], [18, 93], [18, 94], [18, 97], [18, 98], [18, 99], [19, 20], [19, 21], [19, 22], [19, 23], [19, 26], [19, 27], [19, 30], [19, 31], [19, 33], [19, 34], [19, 35], [19, 36], [19, 39], [19, 41], [19, 42], [19, 43], [19, 46], [19, 49], [19, 51], [19, 52], [19, 53], [19, 54], [19, 55], [19, 56], [19, 59], [19, 62], [19, 66], [19, 68], [19, 70], [19, 71], [19, 73], [19, 75], [19, 79], [19, 80], [19, 81], [19, 84], [19, 86], [19, 90], [19, 91], [19, 92], [19, 93], [19, 97], [19, 98], [20, 22], [20, 25], [20, 26], [20, 27], [20, 29], [20, 30], [20, 31], [20, 33], [20, 36], [20, 37], [20, 40], [20, 44], [20, 47], [20, 49], [20, 53], [20, 55], [20, 58], [20, 61], [20, 62], [20, 63], [20, 67], [20, 68], [20, 69], [20, 70], [20, 72], [20, 74], [20, 76], [20, 77], [20, 80], [20, 81], [20, 82], [20, 83], [20, 86], [20, 87], [20, 88], [20, 91], [20, 92], [20, 95], [20, 96], [20, 97], [20, 98], [21, 23], [21, 26], [21, 28], [21, 29], [21, 30], [21, 31], [21, 35], [21, 36], [21, 38], [21, 39], [21, 41], [21, 42], [21, 44], [21, 45], [21, 47], [21, 50], [21, 52], [21, 56], [21, 57], [21, 59], [21, 60], [21, 61], [21, 62], [21, 65], [21, 68], [21, 73], [21, 74], [21, 77], [21, 79], [21, 80], [21, 81], [21, 83], [21, 85], [21, 88], [21, 91], [21, 94], [21, 95], [21, 96], [21, 97], [22, 23], [22, 25], [22, 27], [22, 28], [22, 30], [22, 32], [22, 33], [22, 34], [22, 35], [22, 36], [22, 38], [22, 39], [22, 41], [22, 43], [22, 47], [22, 51], [22, 52], [22, 53], [22, 55], [22, 58], [22, 59], [22, 60], [22, 62], [22, 64], [22, 65], [22, 67], [22, 70], [22, 71], [22, 72], [22, 73], [22, 75], [22, 76], [22, 78], [22, 80], [22, 83], [22, 84], [22, 85], [22, 87], [22, 88], [22, 90], [22, 94], [22, 95], [22, 96], [22, 97], [22, 98], [23, 24], [23, 25], [23, 26], [23, 28], [23, 29], [23, 33], [23, 34], [23, 35], [23, 39], [23, 40], [23, 43], [23, 44], [23, 46], [23, 47], [23, 49], [23, 50], [23, 54], [23, 55], [23, 57], [23, 58], [23, 59], [23, 60], [23, 61], [23, 63], [23, 71], [23, 73], [23, 74], [23, 76], [23, 77], [23, 79], [23, 80], [23, 81], [23, 82], [23, 84], [23, 85], [23, 89], [23, 90], [23, 91], [23, 92], [23, 95], [23, 96], [23, 99], [24, 26], [24, 30], [24, 31], [24, 34], [24, 36], [24, 37], [24, 41], [24, 42], [24, 43], [24, 45], [24, 46], [24, 48], [24, 49], [24, 51], [24, 53], [24, 54], [24, 56], [24, 57], [24, 58], [24, 59], [24, 60], [24, 61], [24, 62], [24, 63], [24, 69], [24, 71], [24, 76], [24, 78], [24, 84], [24, 85], [24, 88], [24, 90], [24, 94], [24, 95], [24, 96], [24, 99], [25, 27], [25, 29], [25, 30], [25, 31], [25, 35], [25, 38], [25, 42], [25, 43], [25, 44], [25, 47], [25, 48], [25, 49], [25, 52], [25, 57], [25, 60], [25, 61], [25, 62], [25, 64], [25, 65], [25, 69], [25, 71], [25, 72], [25, 74], [25, 75], [25, 77], [25, 78], [25, 82], [25, 86], [25, 87], [25, 90], [25, 91], [25, 95], [25, 96], [25, 97], [25, 99], [26, 27], [26, 28], [26, 29], [26, 32], [26, 34], [26, 36], [26, 37], [26, 38], [26, 39], [26, 40], [26, 41], [26, 43], [26, 44], [26, 45], [26, 46], [26, 47], [26, 51], [26, 52], [26, 56], [26, 57], [26, 59], [26, 60], [26, 61], [26, 64], [26, 66], [26, 67], [26, 68], [26, 73], [26, 75], [26, 77], [26, 78], [26, 79], [26, 82], [26, 85], [26, 86], [26, 87], [26, 88], [26, 89], [26, 90], [26, 95], [26, 99], [27, 30], [27, 32], [27, 34], [27, 35], [27, 37], [27, 40], [27, 41], [27, 43], [27, 45], [27, 46], [27, 47], [27, 48], [27, 49], [27, 50], [27, 51], [27, 52], [27, 54], [27, 55], [27, 56], [27, 57], [27, 58], [27, 60], [27, 67], [27, 69], [27, 70], [27, 71], [27, 72], [27, 73], [27, 74], [27, 76], [27, 78], [27, 79], [27, 83], [27, 84], [27, 85], [27, 86], [27, 87], [27, 88], [27, 89], [27, 91], [27, 92], [27, 95], [27, 99], [28, 30], [28, 31], [28, 36], [28, 37], [28, 38], [28, 39], [28, 41], [28, 42], [28, 43], [28, 44], [28, 46], [28, 47], [28, 49], [28, 50], [28, 51], [28, 53], [28, 56], [28, 57], [28, 59], [28, 60], [28, 61], [28, 63], [28, 69], [28, 70], [28, 71], [28, 72], [28, 75], [28, 77], [28, 79], [28, 80], [28, 81], [28, 82], [28, 83], [28, 85], [28, 86], [28, 88], [28, 89], [28, 91], [28, 93], [28, 96], [28, 97], [28, 99], [29, 30], [29, 34], [29, 36], [29, 38], [29, 46], [29, 50], [29, 51], [29, 52], [29, 53], [29, 55], [29, 56], [29, 57], [29, 59], [29, 62], [29, 65], [29, 66], [29, 67], [29, 70], [29, 71], [29, 73], [29, 74], [29, 76], [29, 79], [29, 81], [29, 84], [29, 87], [29, 88], [29, 89], [29, 98], [29, 99], [30, 33], [30, 35], [30, 37], [30, 38], [30, 39], [30, 40], [30, 42], [30, 43], [30, 44], [30, 45], [30, 46], [30, 48], [30, 49], [30, 50], [30, 51], [30, 53], [30, 55], [30, 60], [30, 62], [30, 63], [30, 64], [30, 65], [30, 68], [30, 69], [30, 73], [30, 75], [30, 77], [30, 78], [30, 82], [30, 83], [30, 86], [30, 87], [30, 88], [30, 89], [30, 90], [30, 91], [30, 92], [30, 94], [30, 95], [30, 97], [30, 98], [30, 99], [31, 32], [31, 34], [31, 35], [31, 37], [31, 38], [31, 39], [31, 40], [31, 41], [31, 42], [31, 43], [31, 45], [31, 46], [31, 52], [31, 55], [31, 61], [31, 62], [31, 63], [31, 65], [31, 67], [31, 71], [31, 76], [31, 77], [31, 78], [31, 82], [31, 89], [31, 90], [31, 91], [31, 93], [31, 96], [32, 33], [32, 35], [32, 36], [32, 40], [32, 42], [32, 45], [32, 47], [32, 50], [32, 51], [32, 53], [32, 54], [32, 58], [32, 59], [32, 60], [32, 61], [32, 63], [32, 66], [32, 68], [32, 72], [32, 81], [32, 82], [32, 83], [32, 84], [32, 85], [32, 88], [32, 89], [32, 90], [32, 91], [32, 92], [32, 96], [33, 35], [33, 36], [33, 37], [33, 38], [33, 39], [33, 41], [33, 46], [33, 48], [33, 50], [33, 52], [33, 53], [33, 56], [33, 57], [33, 58], [33, 59], [33, 61], [33, 63], [33, 67], [33, 76], [33, 77], [33, 78], [33, 84], [33, 85], [33, 89], [33, 90], [33, 91], [33, 92], [33, 94], [33, 95], [33, 97], [33, 98], [34, 35], [34, 36], [34, 38], [34, 39], [34, 40], [34, 43], [34, 44], [34, 45], [34, 46], [34, 47], [34, 48], [34, 52], [34, 53], [34, 55], [34, 56], [34, 58], [34, 59], [34, 60], [34, 62], [34, 69], [34, 71], [34, 72], [34, 74], [34, 76], [34, 77], [34, 79], [34, 80], [34, 85], [34, 88], [34, 92], [34, 93], [34, 95], [34, 97], [34, 99], [35, 36], [35, 38], [35, 39], [35, 40], [35, 43], [35, 45], [35, 46], [35, 47], [35, 48], [35, 49], [35, 50], [35, 51], [35, 52], [35, 54], [35, 55], [35, 56], [35, 57], [35, 58], [35, 65], [35, 66], [35, 67], [35, 68], [35, 69], [35, 70], [35, 71], [35, 74], [35, 75], [35, 78], [35, 79], [35, 81], [35, 82], [35, 83], [35, 84], [35, 85], [35, 86], [35, 87], [35, 89], [35, 90], [35, 91], [35, 92], [35, 93], [35, 98], [36, 38], [36, 39], [36, 41], [36, 44], [36, 46], [36, 47], [36, 50], [36, 52], [36, 56], [36, 59], [36, 60], [36, 62], [36, 64], [36, 66], [36, 67], [36, 68], [36, 71], [36, 72], [36, 78], [36, 79], [36, 82], [36, 83], [36, 85], [36, 86], [36, 87], [36, 88], [36, 89], [36, 92], [36, 93], [36, 94], [36, 96], [36, 99], [37, 38], [37, 39], [37, 40], [37, 44], [37, 45], [37, 46], [37, 47], [37, 48], [37, 52], [37, 56], [37, 59], [37, 66], [37, 67], [37, 72], [37, 73], [37, 76], [37, 77], [37, 78], [37, 79], [37, 81], [37, 82], [37, 85], [37, 86], [37, 89], [37, 90], [37, 97], [37, 99], [38, 39], [38, 40], [38, 41], [38, 45], [38, 46], [38, 47], [38, 48], [38, 50], [38, 51], [38, 55], [38, 57], [38, 58], [38, 59], [38, 61], [38, 62], [38, 63], [38, 64], [38, 67], [38, 69], [38, 70], [38, 71], [38, 75], [38, 76], [38, 78], [38, 83], [38, 84], [38, 87], [38, 88], [38, 89], [38, 93], [38, 96], [38, 97], [38, 98], [38, 99], [39, 43], [39, 45], [39, 48], [39, 49], [39, 50], [39, 53], [39, 54], [39, 55], [39, 58], [39, 59], [39, 60], [39, 63], [39, 65], [39, 67], [39, 68], [39, 69], [39, 72], [39, 76], [39, 77], [39, 80], [39, 83], [39, 86], [39, 88], [39, 89], [39, 92], [39, 93], [39, 99], [40, 41], [40, 42], [40, 43], [40, 44], [40, 45], [40, 46], [40, 47], [40, 48], [40, 50], [40, 51], [40, 52], [40, 53], [40, 54], [40, 55], [40, 56], [40, 57], [40, 58], [40, 60], [40, 62], [40, 63], [40, 66], [40, 67], [40, 69], [40, 70], [40, 71], [40, 73], [40, 74], [40, 75], [40, 76], [40, 77], [40, 78], [40, 79], [40, 80], [40, 83], [40, 84], [40, 86], [40, 87], [40, 89], [40, 91], [40, 93], [40, 98], [40, 99], [41, 42], [41, 44], [41, 45], [41, 46], [41, 50], [41, 55], [41, 58], [41, 61], [41, 62], [41, 64], [41, 66], [41, 67], [41, 69], [41, 71], [41, 74], [41, 75], [41, 83], [41, 84], [41, 85], [41, 86], [41, 90], [41, 92], [41, 93], [41, 94], [41, 97], [41, 98], [42, 43], [42, 45], [42, 47], [42, 48], [42, 49], [42, 50], [42, 52], [42, 59], [42, 65], [42, 66], [42, 67], [42, 71], [42, 73], [42, 75], [42, 77], [42, 79], [42, 81], [42, 86], [42, 87], [42, 90], [42, 92], [42, 96], [42, 97], [43, 44], [43, 46], [43, 47], [43, 48], [43, 50], [43, 51], [43, 52], [43, 53], [43, 54], [43, 55], [43, 56], [43, 57], [43, 58], [43, 61], [43, 62], [43, 63], [43, 65], [43, 67], [43, 69], [43, 70], [43, 71], [43, 74], [43, 75], [43, 76], [43, 79], [43, 81], [43, 85], [43, 86], [43, 87], [43, 88], [43, 91], [43, 92], [43, 93], [43, 95], [44, 46], [44, 48], [44, 51], [44, 52], [44, 53], [44, 55], [44, 56], [44, 60], [44, 63], [44, 66], [44, 68], [44, 69], [44, 73], [44, 74], [44, 79], [44, 80], [44, 81], [44, 85], [44, 88], [44, 91], [44, 92], [44, 93], [44, 94], [44, 97], [44, 99], [45, 49], [45, 51], [45, 52], [45, 53], [45, 55], [45, 56], [45, 58], [45, 59], [45, 60], [45, 62], [45, 68], [45, 69], [45, 70], [45, 71], [45, 80], [45, 81], [45, 82], [45, 88], [45, 90], [45, 91], [45, 96], [45, 97], [45, 98], [46, 47], [46, 48], [46, 49], [46, 50], [46, 51], [46, 52], [46, 54], [46, 55], [46, 56], [46, 57], [46, 58], [46, 61], [46, 66], [46, 67], [46, 69], [46, 70], [46, 71], [46, 72], [46, 74], [46, 75], [46, 76], [46, 77], [46, 78], [46, 79], [46, 81], [46, 82], [46, 83], [46, 84], [46, 85], [46, 86], [46, 87], [46, 88], [46, 91], [46, 92], [46, 94], [46, 95], [46, 96], [46, 99], [47, 48], [47, 50], [47, 51], [47, 52], [47, 54], [47, 55], [47, 56], [47, 57], [47, 59], [47, 60], [47, 61], [47, 62], [47, 63], [47, 65], [47, 68], [47, 69], [47, 70], [47, 71], [47, 72], [47, 73], [47, 74], [47, 77], [47, 79], [47, 83], [47, 86], [47, 87], [47, 89], [47, 91], [47, 92], [47, 95], [47, 97], [47, 99], [48, 50], [48, 51], [48, 52], [48, 54], [48, 55], [48, 56], [48, 57], [48, 59], [48, 62], [48, 63], [48, 64], [48, 67], [48, 69], [48, 70], [48, 72], [48, 73], [48, 74], [48, 75], [48, 76], [48, 78], [48, 79], [48, 80], [48, 83], [48, 85], [48, 87], [48, 90], [48, 91], [48, 92], [48, 93], [48, 94], [48, 96], [48, 99], [49, 50], [49, 52], [49, 55], [49, 57], [49, 58], [49, 59], [49, 60], [49, 61], [49, 63], [49, 68], [49, 69], [49, 73], [49, 75], [49, 80], [49, 81], [49, 82], [49, 83], [49, 87], [49, 88], [49, 90], [49, 91], [49, 95], [49, 97], [49, 99], [50, 51], [50, 52], [50, 54], [50, 55], [50, 56], [50, 57], [50, 60], [50, 61], [50, 63], [50, 67], [50, 68], [50, 69], [50, 70], [50, 72], [50, 74], [50, 76], [50, 77], [50, 78], [50, 79], [50, 80], [50, 81], [50, 87], [50, 89], [50, 91], [50, 93], [50, 94], [50, 98], [51, 52], [51, 53], [51, 54], [51, 55], [51, 56], [51, 58], [51, 60], [51, 64], [51, 67], [51, 68], [51, 69], [51, 70], [51, 72], [51, 73], [51, 74], [51, 76], [51, 77], [51, 79], [51, 80], [51, 84], [51, 85], [51, 87], [51, 88], [51, 91], [51, 93], [51, 96], [51, 97], [51, 98], [52, 53], [52, 54], [52, 55], [52, 56], [52, 58], [52, 59], [52, 60], [52, 61], [52, 62], [52, 64], [52, 66], [52, 69], [52, 70], [52, 72], [52, 73], [52, 74], [52, 78], [52, 79], [52, 82], [52, 83], [52, 84], [52, 86], [52, 87], [52, 89], [52, 90], [52, 91], [52, 93], [52, 94], [52, 96], [52, 99], [53, 54], [53, 55], [53, 56], [53, 59], [53, 60], [53, 63], [53, 64], [53, 65], [53, 66], [53, 70], [53, 71], [53, 75], [53, 77], [53, 78], [53, 81], [53, 83], [53, 86], [53, 88], [53, 89], [53, 91], [53, 93], [53, 95], [53, 96], [53, 98], [53, 99], [54, 57], [54, 58], [54, 61], [54, 67], [54, 70], [54, 71], [54, 72], [54, 76], [54, 81], [54, 83], [54, 85], [54, 86], [54, 87], [54, 90], [54, 94], [54, 95], [55, 56], [55, 58], [55, 59], [55, 61], [55, 62], [55, 63], [55, 65], [55, 67], [55, 68], [55, 69], [55, 70], [55, 71], [55, 72], [55, 73], [55, 74], [55, 78], [55, 79], [55, 82], [55, 83], [55, 84], [55, 85], [55, 87], [55, 89], [55, 90], [55, 91], [55, 92], [55, 93], [55, 95], [55, 96], [55, 99], [56, 58], [56, 60], [56, 61], [56, 62], [56, 63], [56, 64], [56, 65], [56, 69], [56, 70], [56, 72], [56, 73], [56, 74], [56, 75], [56, 76], [56, 77], [56, 78], [56, 79], [56, 80], [56, 81], [56, 83], [56, 84], [56, 85], [56, 86], [56, 87], [56, 88], [56, 89], [56, 90], [56, 91], [56, 92], [56, 94], [56, 95], [56, 96], [57, 60], [57, 61], [57, 65], [57, 66], [57, 68], [57, 69], [57, 71], [57, 74], [57, 75], [57, 78], [57, 79], [57, 80], [57, 81], [57, 82], [57, 85], [57, 86], [57, 89], [57, 90], [57, 95], [57, 98], [57, 99], [58, 62], [58, 63], [58, 67], [58, 69], [58, 70], [58, 73], [58, 74], [58, 80], [58, 83], [58, 84], [58, 85], [58, 88], [58, 89], [58, 90], [58, 91], [58, 92], [58, 93], [58, 95], [59, 60], [59, 61], [59, 62], [59, 63], [59, 65], [59, 66], [59, 68], [59, 69], [59, 72], [59, 74], [59, 75], [59, 77], [59, 78], [59, 79], [59, 81], [59, 82], [59, 84], [59, 85], [59, 88], [59, 89], [59, 90], [59, 92], [59, 96], [59, 97], [59, 98], [59, 99], [60, 61], [60, 64], [60, 66], [60, 71], [60, 73], [60, 74], [60, 78], [60, 79], [60, 80], [60, 81], [60, 83], [60, 84], [60, 85], [60, 86], [60, 88], [60, 89], [60, 90], [60, 91], [60, 92], [60, 94], [60, 95], [60, 99], [61, 62], [61, 63], [61, 67], [61, 68], [61, 70], [61, 73], [61, 74], [61, 75], [61, 79], [61, 80], [61, 82], [61, 83], [61, 84], [61, 85], [61, 88], [61, 89], [61, 90], [61, 92], [61, 94], [61, 98], [61, 99], [62, 65], [62, 68], [62, 69], [62, 70], [62, 71], [62, 72], [62, 74], [62, 75], [62, 78], [62, 79], [62, 81], [62, 83], [62, 84], [62, 86], [62, 87], [62, 89], [62, 90], [62, 97], [62, 98], [62, 99], [63, 64], [63, 66], [63, 67], [63, 68], [63, 69], [63, 70], [63, 71], [63, 72], [63, 76], [63, 78], [63, 79], [63, 81], [63, 88], [63, 89], [63, 90], [63, 92], [63, 93], [63, 95], [63, 96], [63, 97], [63, 98], [63, 99], [64, 65], [64, 66], [64, 71], [64, 74], [64, 75], [64, 77], [64, 78], [64, 79], [64, 83], [64, 85], [64, 86], [64, 87], [64, 92], [64, 93], [64, 94], [64, 96], [64, 98], [65, 68], [65, 69], [65, 71], [65, 72], [65, 74], [65, 83], [65, 84], [65, 85], [65, 88], [65, 90], [65, 92], [65, 93], [65, 94], [65, 95], [65, 99], [66, 67], [66, 68], [66, 71], [66, 74], [66, 76], [66, 78], [66, 79], [66, 80], [66, 82], [66, 83], [66, 84], [66, 87], [66, 90], [66, 91], [66, 94], [66, 96], [66, 98], [66, 99], [67, 71], [67, 72], [67, 73], [67, 81], [67, 82], [67, 83], [67, 85], [67, 86], [67, 88], [67, 90], [67, 91], [67, 92], [67, 94], [67, 96], [67, 98], [68, 69], [68, 70], [68, 71], [68, 72], [68, 74], [68, 76], [68, 77], [68, 79], [68, 81], [68, 82], [68, 83], [68, 86], [68, 87], [68, 88], [68, 89], [68, 90], [68, 96], [68, 97], [68, 98], [69, 70], [69, 73], [69, 74], [69, 75], [69, 76], [69, 78], [69, 79], [69, 80], [69, 81], [69, 83], [69, 84], [69, 85], [69, 87], [69, 90], [69, 91], [69, 92], [69, 94], [69, 95], [69, 96], [69, 97], [69, 99], [70, 72], [70, 74], [70, 75], [70, 78], [70, 79], [70, 80], [70, 81], [70, 83], [70, 84], [70, 86], [70, 87], [70, 88], [70, 91], [70, 97], [70, 98], [71, 74], [71, 75], [71, 76], [71, 79], [71, 83], [71, 85], [71, 87], [71, 88], [71, 89], [71, 91], [71, 95], [71, 96], [71, 99], [72, 73], [72, 74], [72, 76], [72, 79], [72, 80], [72, 81], [72, 83], [72, 84], [72, 85], [72, 88], [72, 91], [72, 98], [73, 74], [73, 78], [73, 79], [73, 80], [73, 87], [73, 90], [73, 91], [73, 93], [73, 96], [73, 98], [74, 76], [74, 79], [74, 81], [74, 83], [74, 84], [74, 86], [74, 87], [74, 91], [74, 95], [74, 96], [75, 76], [75, 78], [75, 79], [75, 80], [75, 81], [75, 82], [75, 83], [75, 90], [75, 91], [75, 92], [75, 94], [75, 95], [75, 97], [75, 99], [76, 79], [76, 80], [76, 84], [76, 85], [76, 87], [76, 88], [76, 89], [76, 94], [76, 95], [76, 96], [76, 97], [76, 98], [76, 99], [77, 78], [77, 81], [77, 82], [77, 83], [77, 84], [77, 85], [77, 86], [77, 88], [77, 90], [77, 91], [77, 92], [77, 95], [78, 80], [78, 81], [78, 82], [78, 83], [78, 84], [78, 86], [78, 87], [78, 89], [78, 90], [78, 92], [78, 96], [78, 97], [78, 99], [79, 80], [79, 81], [79, 82], [79, 84], [79, 85], [79, 87], [79, 90], [79, 91], [79, 93], [79, 94], [79, 96], [79, 98], [79, 99], [80, 81], [80, 82], [80, 84], [80, 85], [80, 86], [80, 88], [80, 91], [80, 93], [80, 95], [80, 97], [80, 99], [81, 84], [81, 87], [81, 91], [81, 94], [81, 95], [82, 83], [82, 86], [82, 89], [82, 91], [82, 93], [82, 95], [82, 97], [83, 90], [83, 92], [83, 94], [83, 97], [83, 99], [84, 85], [84, 87], [84, 89], [84, 92], [84, 95], [84, 96], [85, 86], [85, 92], [85, 94], [85, 97], [85, 98], [85, 99], [86, 87], [86, 92], [86, 94], [86, 95], [87, 88], [87, 90], [87, 91], [87, 93], [87, 94], [87, 95], [87, 96], [88, 89], [88, 91], [88, 95], [88, 96], [88, 99], [89, 90], [89, 93], [89, 97], [89, 99], [90, 91], [90, 93], [90, 94], [90, 95], [90, 98], [91, 94], [91, 97], [91, 98], [92, 93], [92, 94], [92, 96], [92, 97], [92, 99], [93, 94], [94, 96], [95, 96], [95, 97], [95, 99], [96, 97]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s0/tests/run.py b/tasks/construct-nppc-clique-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l6-s0/tests/test.sh b/tasks/construct-nppc-clique-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-clique-l6-s1/environment/instance.json b/tasks/construct-nppc-clique-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b5f4f0de4b57cc9bca00330661bf2cbae5d63981 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 1], [0, 2], [0, 6], [0, 17], [0, 18], [0, 20], [0, 24], [0, 25], [0, 27], [0, 29], [0, 30], [0, 32], [0, 35], [0, 37], [0, 41], [0, 42], [0, 43], [0, 44], [0, 46], [0, 48], [0, 49], [0, 53], [0, 54], [0, 55], [0, 56], [0, 57], [0, 59], [0, 61], [0, 65], [0, 68], [0, 70], [0, 71], [0, 75], [0, 76], [0, 80], [0, 81], [0, 83], [0, 84], [0, 86], [0, 87], [0, 88], [0, 90], [0, 91], [0, 92], [0, 93], [0, 94], [0, 95], [0, 97], [0, 99], [1, 2], [1, 7], [1, 8], [1, 9], [1, 11], [1, 19], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 30], [1, 31], [1, 33], [1, 35], [1, 36], [1, 38], [1, 39], [1, 40], [1, 41], [1, 42], [1, 44], [1, 45], [1, 46], [1, 48], [1, 49], [1, 51], [1, 52], [1, 56], [1, 58], [1, 59], [1, 61], [1, 62], [1, 63], [1, 66], [1, 68], [1, 69], [1, 70], [1, 72], [1, 73], [1, 78], [1, 79], [1, 80], [1, 82], [1, 84], [1, 88], [1, 89], [1, 91], [1, 94], [1, 95], [1, 96], [1, 97], [1, 98], [2, 5], [2, 7], [2, 8], [2, 10], [2, 11], [2, 13], [2, 16], [2, 20], [2, 22], [2, 23], [2, 24], [2, 26], [2, 27], [2, 29], [2, 32], [2, 36], [2, 37], [2, 38], [2, 39], [2, 40], [2, 42], [2, 43], [2, 44], [2, 46], [2, 47], [2, 48], [2, 49], [2, 50], [2, 51], [2, 53], [2, 54], [2, 56], [2, 58], [2, 59], [2, 62], [2, 63], [2, 65], [2, 66], [2, 68], [2, 69], [2, 75], [2, 78], [2, 79], [2, 80], [2, 83], [2, 84], [2, 87], [2, 88], [2, 89], [2, 91], [2, 92], [2, 94], [2, 96], [2, 97], [2, 98], [3, 4], [3, 5], [3, 7], [3, 10], [3, 13], [3, 15], [3, 16], [3, 20], [3, 21], [3, 22], [3, 23], [3, 26], [3, 31], [3, 32], [3, 33], [3, 37], [3, 42], [3, 43], [3, 48], [3, 49], [3, 51], [3, 53], [3, 54], [3, 63], [3, 69], [3, 70], [3, 73], [3, 75], [3, 76], [3, 80], [3, 82], [3, 83], [3, 84], [3, 85], [3, 86], [3, 88], [3, 89], [3, 90], [3, 91], [3, 93], [3, 95], [3, 96], [4, 7], [4, 9], [4, 12], [4, 13], [4, 14], [4, 16], [4, 17], [4, 20], [4, 27], [4, 28], [4, 29], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 40], [4, 42], [4, 43], [4, 45], [4, 50], [4, 52], [4, 53], [4, 55], [4, 59], [4, 60], [4, 61], [4, 63], [4, 64], [4, 65], [4, 66], [4, 67], [4, 68], [4, 70], [4, 71], [4, 72], [4, 74], [4, 76], [4, 77], [4, 78], [4, 79], [4, 80], [4, 84], [4, 85], [4, 86], [4, 88], [4, 91], [4, 92], [4, 93], [4, 94], [4, 95], [4, 96], [4, 97], [4, 99], [5, 6], [5, 7], [5, 8], [5, 10], [5, 11], [5, 12], [5, 16], [5, 17], [5, 18], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 27], [5, 28], [5, 29], [5, 31], [5, 32], [5, 33], [5, 37], [5, 40], [5, 43], [5, 46], [5, 49], [5, 53], [5, 55], [5, 56], [5, 59], [5, 60], [5, 61], [5, 62], [5, 66], [5, 67], [5, 69], [5, 70], [5, 71], [5, 74], [5, 75], [5, 76], [5, 78], [5, 81], [5, 85], [5, 86], [5, 87], [5, 89], [5, 92], [5, 95], [5, 96], [5, 97], [5, 99], [6, 7], [6, 9], [6, 12], [6, 14], [6, 17], [6, 19], [6, 20], [6, 22], [6, 23], [6, 27], [6, 30], [6, 33], [6, 37], [6, 38], [6, 40], [6, 41], [6, 42], [6, 44], [6, 46], [6, 48], [6, 49], [6, 54], [6, 55], [6, 56], [6, 58], [6, 59], [6, 60], [6, 61], [6, 62], [6, 63], [6, 65], [6, 66], [6, 68], [6, 69], [6, 70], [6, 71], [6, 74], [6, 75], [6, 76], [6, 83], [6, 98], [7, 9], [7, 10], [7, 12], [7, 15], [7, 17], [7, 18], [7, 20], [7, 21], [7, 22], [7, 24], [7, 25], [7, 26], [7, 29], [7, 31], [7, 40], [7, 42], [7, 44], [7, 45], [7, 46], [7, 48], [7, 52], [7, 53], [7, 56], [7, 59], [7, 60], [7, 64], [7, 65], [7, 67], [7, 68], [7, 72], [7, 73], [7, 74], [7, 75], [7, 77], [7, 78], [7, 83], [7, 86], [7, 87], [7, 88], [7, 92], [7, 93], [7, 94], [7, 95], [7, 96], [7, 97], [7, 99], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 18], [8, 19], [8, 21], [8, 23], [8, 25], [8, 32], [8, 33], [8, 35], [8, 36], [8, 37], [8, 38], [8, 41], [8, 43], [8, 45], [8, 47], [8, 49], [8, 51], [8, 52], [8, 54], [8, 55], [8, 56], [8, 57], [8, 58], [8, 61], [8, 63], [8, 64], [8, 73], [8, 74], [8, 79], [8, 81], [8, 83], [8, 84], [8, 85], [8, 86], [8, 87], [8, 88], [8, 89], [8, 90], [8, 94], [8, 95], [8, 96], [8, 99], [9, 12], [9, 13], [9, 16], [9, 19], [9, 21], [9, 22], [9, 24], [9, 25], [9, 27], [9, 29], [9, 30], [9, 32], [9, 33], [9, 34], [9, 35], [9, 36], [9, 40], [9, 41], [9, 43], [9, 47], [9, 48], [9, 49], [9, 51], [9, 54], [9, 55], [9, 56], [9, 57], [9, 59], [9, 62], [9, 64], [9, 65], [9, 67], [9, 69], [9, 72], [9, 73], [9, 75], [9, 78], [9, 79], [9, 81], [9, 82], [9, 86], [9, 88], [9, 89], [9, 92], [9, 93], [9, 94], [9, 95], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 20], [10, 24], [10, 26], [10, 27], [10, 28], [10, 29], [10, 32], [10, 33], [10, 37], [10, 38], [10, 39], [10, 42], [10, 43], [10, 44], [10, 46], [10, 47], [10, 48], [10, 50], [10, 51], [10, 54], [10, 55], [10, 56], [10, 57], [10, 59], [10, 60], [10, 61], [10, 63], [10, 65], [10, 68], [10, 71], [10, 76], [10, 77], [10, 79], [10, 80], [10, 81], [10, 84], [10, 88], [10, 91], [10, 92], [10, 93], [10, 95], [10, 98], [11, 13], [11, 18], [11, 21], [11, 22], [11, 24], [11, 25], [11, 32], [11, 34], [11, 37], [11, 39], [11, 40], [11, 41], [11, 45], [11, 46], [11, 47], [11, 49], [11, 52], [11, 53], [11, 54], [11, 55], [11, 56], [11, 57], [11, 58], [11, 59], [11, 60], [11, 63], [11, 65], [11, 66], [11, 67], [11, 68], [11, 69], [11, 70], [11, 73], [11, 75], [11, 77], [11, 79], [11, 80], [11, 81], [11, 84], [11, 86], [11, 87], [11, 91], [11, 92], [11, 93], [11, 95], [11, 97], [11, 99], [12, 13], [12, 16], [12, 19], [12, 21], [12, 25], [12, 26], [12, 28], [12, 31], [12, 32], [12, 37], [12, 38], [12, 40], [12, 41], [12, 42], [12, 43], [12, 45], [12, 46], [12, 47], [12, 49], [12, 50], [12, 55], [12, 56], [12, 57], [12, 60], [12, 62], [12, 63], [12, 68], [12, 69], [12, 72], [12, 77], [12, 78], [12, 79], [12, 80], [12, 83], [12, 84], [12, 85], [12, 88], [12, 90], [12, 94], [12, 95], [12, 96], [12, 97], [12, 99], [13, 15], [13, 17], [13, 18], [13, 20], [13, 21], [13, 23], [13, 26], [13, 27], [13, 28], [13, 29], [13, 32], [13, 35], [13, 39], [13, 40], [13, 43], [13, 45], [13, 46], [13, 48], [13, 50], [13, 51], [13, 54], [13, 55], [13, 56], [13, 58], [13, 59], [13, 60], [13, 63], [13, 64], [13, 65], [13, 66], [13, 67], [13, 68], [13, 69], [13, 70], [13, 71], [13, 72], [13, 75], [13, 76], [13, 79], [13, 80], [13, 81], [13, 83], [13, 84], [13, 86], [13, 87], [13, 89], [13, 90], [13, 91], [13, 93], [13, 94], [13, 95], [13, 96], [13, 97], [13, 98], [13, 99], [14, 16], [14, 17], [14, 18], [14, 21], [14, 23], [14, 25], [14, 31], [14, 33], [14, 34], [14, 37], [14, 40], [14, 42], [14, 44], [14, 47], [14, 49], [14, 50], [14, 52], [14, 54], [14, 55], [14, 56], [14, 57], [14, 62], [14, 67], [14, 69], [14, 71], [14, 73], [14, 74], [14, 75], [14, 76], [14, 77], [14, 78], [14, 82], [14, 85], [14, 86], [14, 87], [14, 89], [14, 97], [14, 98], [15, 16], [15, 17], [15, 18], [15, 21], [15, 23], [15, 24], [15, 25], [15, 26], [15, 27], [15, 31], [15, 33], [15, 37], [15, 39], [15, 40], [15, 41], [15, 44], [15, 46], [15, 47], [15, 54], [15, 58], [15, 62], [15, 63], [15, 66], [15, 68], [15, 71], [15, 73], [15, 74], [15, 75], [15, 76], [15, 77], [15, 78], [15, 79], [15, 80], [15, 82], [15, 86], [15, 87], [15, 89], [15, 92], [15, 93], [15, 98], [15, 99], [16, 17], [16, 18], [16, 19], [16, 24], [16, 26], [16, 27], [16, 28], [16, 29], [16, 33], [16, 37], [16, 42], [16, 43], [16, 45], [16, 47], [16, 50], [16, 52], [16, 53], [16, 58], [16, 59], [16, 61], [16, 63], [16, 66], [16, 74], [16, 75], [16, 77], [16, 79], [16, 81], [16, 85], [16, 86], [16, 87], [16, 88], [16, 90], [16, 92], [16, 93], [16, 94], [16, 98], [16, 99], [17, 23], [17, 25], [17, 27], [17, 29], [17, 31], [17, 33], [17, 35], [17, 36], [17, 38], [17, 42], [17, 44], [17, 46], [17, 47], [17, 49], [17, 52], [17, 55], [17, 57], [17, 58], [17, 61], [17, 62], [17, 63], [17, 64], [17, 69], [17, 70], [17, 72], [17, 77], [17, 78], [17, 80], [17, 82], [17, 83], [17, 86], [17, 87], [17, 88], [17, 89], [17, 91], [17, 92], [17, 93], [17, 96], [17, 98], [18, 19], [18, 20], [18, 22], [18, 24], [18, 27], [18, 28], [18, 30], [18, 31], [18, 33], [18, 35], [18, 36], [18, 37], [18, 38], [18, 39], [18, 40], [18, 42], [18, 43], [18, 47], [18, 49], [18, 51], [18, 52], [18, 53], [18, 60], [18, 62], [18, 66], [18, 67], [18, 69], [18, 71], [18, 72], [18, 73], [18, 75], [18, 76], [18, 77], [18, 78], [18, 80], [18, 83], [18, 85], [18, 86], [18, 88], [18, 89], [18, 91], [18, 92], [18, 93], [18, 94], [18, 95], [18, 96], [18, 97], [19, 20], [19, 22], [19, 23], [19, 27], [19, 31], [19, 34], [19, 35], [19, 36], [19, 37], [19, 38], [19, 39], [19, 41], [19, 44], [19, 48], [19, 50], [19, 52], [19, 53], [19, 57], [19, 59], [19, 63], [19, 65], [19, 66], [19, 67], [19, 68], [19, 70], [19, 71], [19, 72], [19, 73], [19, 75], [19, 77], [19, 78], [19, 79], [19, 82], [19, 83], [19, 84], [19, 85], [19, 86], [19, 88], [19, 89], [19, 92], [19, 93], [19, 96], [19, 98], [19, 99], [20, 21], [20, 23], [20, 24], [20, 26], [20, 27], [20, 29], [20, 31], [20, 33], [20, 35], [20, 39], [20, 43], [20, 44], [20, 46], [20, 48], [20, 49], [20, 50], [20, 51], [20, 54], [20, 55], [20, 56], [20, 57], [20, 58], [20, 59], [20, 60], [20, 63], [20, 66], [20, 67], [20, 68], [20, 69], [20, 71], [20, 72], [20, 74], [20, 77], [20, 78], [20, 79], [20, 80], [20, 81], [20, 84], [20, 89], [20, 90], [20, 91], [20, 93], [20, 94], [20, 95], [20, 96], [20, 97], [20, 98], [21, 23], [21, 27], [21, 28], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [21, 40], [21, 42], [21, 43], [21, 44], [21, 46], [21, 50], [21, 51], [21, 53], [21, 55], [21, 56], [21, 57], [21, 60], [21, 64], [21, 66], [21, 67], [21, 68], [21, 70], [21, 71], [21, 72], [21, 73], [21, 76], [21, 77], [21, 78], [21, 79], [21, 80], [21, 82], [21, 84], [21, 90], [21, 91], [21, 92], [21, 93], [21, 95], [21, 96], [21, 99], [22, 25], [22, 26], [22, 27], [22, 28], [22, 31], [22, 32], [22, 33], [22, 34], [22, 42], [22, 44], [22, 47], [22, 52], [22, 53], [22, 54], [22, 56], [22, 59], [22, 62], [22, 63], [22, 67], [22, 69], [22, 72], [22, 73], [22, 76], [22, 77], [22, 78], [22, 79], [22, 80], [22, 81], [22, 82], [22, 83], [22, 90], [22, 91], [22, 92], [22, 95], [22, 97], [22, 98], [22, 99], [23, 24], [23, 26], [23, 28], [23, 29], [23, 30], [23, 31], [23, 35], [23, 36], [23, 37], [23, 38], [23, 39], [23, 40], [23, 41], [23, 43], [23, 44], [23, 47], [23, 48], [23, 52], [23, 55], [23, 56], [23, 58], [23, 61], [23, 62], [23, 66], [23, 67], [23, 68], [23, 69], [23, 71], [23, 73], [23, 78], [23, 80], [23, 89], [23, 90], [23, 94], [23, 95], [23, 96], [23, 97], [23, 99], [24, 26], [24, 28], [24, 29], [24, 30], [24, 33], [24, 34], [24, 35], [24, 39], [24, 41], [24, 42], [24, 44], [24, 45], [24, 47], [24, 48], [24, 49], [24, 50], [24, 53], [24, 54], [24, 56], [24, 60], [24, 64], [24, 66], [24, 67], [24, 71], [24, 72], [24, 74], [24, 75], [24, 76], [24, 78], [24, 79], [24, 80], [24, 81], [24, 82], [24, 86], [24, 87], [24, 90], [24, 91], [24, 93], [24, 98], [25, 28], [25, 29], [25, 30], [25, 32], [25, 33], [25, 34], [25, 39], [25, 40], [25, 41], [25, 42], [25, 43], [25, 46], [25, 49], [25, 51], [25, 52], [25, 55], [25, 56], [25, 60], [25, 62], [25, 64], [25, 68], [25, 72], [25, 74], [25, 75], [25, 77], [25, 78], [25, 82], [25, 83], [25, 84], [25, 85], [25, 88], [25, 90], [25, 97], [26, 27], [26, 29], [26, 30], [26, 34], [26, 35], [26, 37], [26, 39], [26, 41], [26, 42], [26, 43], [26, 44], [26, 46], [26, 47], [26, 48], [26, 50], [26, 51], [26, 55], [26, 56], [26, 57], [26, 58], [26, 59], [26, 60], [26, 64], [26, 65], [26, 67], [26, 70], [26, 73], [26, 74], [26, 75], [26, 77], [26, 78], [26, 79], [26, 80], [26, 82], [26, 84], [26, 86], [26, 91], [26, 92], [26, 96], [26, 98], [27, 28], [27, 29], [27, 32], [27, 33], [27, 35], [27, 39], [27, 40], [27, 42], [27, 43], [27, 44], [27, 46], [27, 48], [27, 49], [27, 50], [27, 51], [27, 53], [27, 54], [27, 56], [27, 58], [27, 59], [27, 60], [27, 64], [27, 65], [27, 66], [27, 68], [27, 69], [27, 70], [27, 71], [27, 74], [27, 79], [27, 80], [27, 81], [27, 82], [27, 84], [27, 87], [27, 89], [27, 91], [27, 96], [27, 98], [27, 99], [28, 29], [28, 30], [28, 31], [28, 35], [28, 36], [28, 40], [28, 41], [28, 44], [28, 46], [28, 54], [28, 56], [28, 57], [28, 60], [28, 62], [28, 64], [28, 66], [28, 68], [28, 69], [28, 70], [28, 72], [28, 73], [28, 74], [28, 76], [28, 78], [28, 79], [28, 82], [28, 83], [28, 84], [28, 87], [28, 91], [28, 93], [28, 95], [28, 99], [29, 30], [29, 31], [29, 33], [29, 37], [29, 38], [29, 39], [29, 40], [29, 41], [29, 43], [29, 46], [29, 48], [29, 49], [29, 50], [29, 51], [29, 53], [29, 56], [29, 58], [29, 59], [29, 60], [29, 61], [29, 66], [29, 67], [29, 70], [29, 71], [29, 72], [29, 73], [29, 75], [29, 79], [29, 80], [29, 81], [29, 82], [29, 84], [29, 85], [29, 87], [29, 88], [29, 90], [29, 91], [29, 92], [29, 93], [29, 94], [29, 97], [29, 98], [30, 31], [30, 33], [30, 34], [30, 36], [30, 37], [30, 39], [30, 40], [30, 41], [30, 43], [30, 46], [30, 53], [30, 54], [30, 56], [30, 57], [30, 60], [30, 62], [30, 63], [30, 66], [30, 68], [30, 70], [30, 71], [30, 72], [30, 74], [30, 75], [30, 81], [30, 82], [30, 85], [30, 88], [30, 92], [30, 93], [30, 94], [30, 98], [30, 99], [31, 32], [31, 35], [31, 36], [31, 37], [31, 39], [31, 40], [31, 41], [31, 42], [31, 45], [31, 47], [31, 49], [31, 50], [31, 52], [31, 53], [31, 54], [31, 56], [31, 57], [31, 62], [31, 64], [31, 65], [31, 66], [31, 68], [31, 69], [31, 72], [31, 73], [31, 75], [31, 76], [31, 77], [31, 81], [31, 82], [31, 85], [31, 87], [31, 94], [31, 96], [31, 98], [32, 33], [32, 35], [32, 37], [32, 38], [32, 41], [32, 42], [32, 43], [32, 44], [32, 47], [32, 55], [32, 56], [32, 58], [32, 66], [32, 71], [32, 72], [32, 73], [32, 77], [32, 79], [32, 81], [32, 82], [32, 83], [32, 88], [32, 90], [32, 91], [32, 92], [32, 96], [32, 98], [33, 34], [33, 35], [33, 36], [33, 40], [33, 42], [33, 45], [33, 46], [33, 49], [33, 51], [33, 52], [33, 53], [33, 54], [33, 55], [33, 56], [33, 58], [33, 59], [33, 60], [33, 61], [33, 65], [33, 66], [33, 70], [33, 72], [33, 73], [33, 75], [33, 81], [33, 82], [33, 85], [33, 86], [33, 88], [33, 89], [33, 92], [33, 93], [33, 95], [33, 96], [33, 99], [34, 35], [34, 41], [34, 42], [34, 45], [34, 48], [34, 49], [34, 50], [34, 53], [34, 54], [34, 56], [34, 64], [34, 65], [34, 66], [34, 68], [34, 69], [34, 71], [34, 72], [34, 74], [34, 75], [34, 77], [34, 84], [34, 92], [34, 93], [34, 96], [34, 98], [35, 38], [35, 40], [35, 41], [35, 45], [35, 46], [35, 47], [35, 48], [35, 49], [35, 51], [35, 53], [35, 54], [35, 58], [35, 59], [35, 60], [35, 63], [35, 64], [35, 67], [35, 68], [35, 69], [35, 71], [35, 72], [35, 74], [35, 75], [35, 80], [35, 83], [35, 85], [35, 88], [35, 89], [35, 91], [35, 92], [35, 93], [35, 95], [35, 97], [35, 99], [36, 37], [36, 38], [36, 40], [36, 41], [36, 48], [36, 52], [36, 54], [36, 55], [36, 57], [36, 58], [36, 59], [36, 60], [36, 61], [36, 62], [36, 64], [36, 65], [36, 70], [36, 72], [36, 75], [36, 76], [36, 77], [36, 78], [36, 79], [36, 83], [36, 84], [36, 85], [36, 86], [36, 87], [36, 88], [36, 91], [36, 93], [36, 96], [37, 39], [37, 40], [37, 43], [37, 44], [37, 45], [37, 49], [37, 51], [37, 52], [37, 54], [37, 56], [37, 57], [37, 58], [37, 59], [37, 64], [37, 65], [37, 66], [37, 68], [37, 71], [37, 76], [37, 78], [37, 79], [37, 82], [37, 83], [37, 84], [37, 86], [37, 94], [37, 95], [37, 97], [37, 98], [38, 39], [38, 40], [38, 42], [38, 43], [38, 44], [38, 45], [38, 47], [38, 53], [38, 57], [38, 62], [38, 64], [38, 65], [38, 67], [38, 68], [38, 69], [38, 70], [38, 71], [38, 72], [38, 73], [38, 74], [38, 76], [38, 78], [38, 79], [38, 81], [38, 82], [38, 83], [38, 85], [38, 86], [38, 89], [38, 90], [38, 91], [38, 92], [38, 93], [38, 98], [39, 43], [39, 45], [39, 46], [39, 48], [39, 49], [39, 50], [39, 51], [39, 52], [39, 54], [39, 55], [39, 56], [39, 58], [39, 59], [39, 60], [39, 61], [39, 64], [39, 65], [39, 66], [39, 67], [39, 71], [39, 73], [39, 75], [39, 76], [39, 79], [39, 80], [39, 84], [39, 85], [39, 86], [39, 90], [39, 91], [39, 92], [39, 93], [39, 94], [39, 95], [39, 96], [39, 97], [39, 98], [39, 99], [40, 41], [40, 42], [40, 43], [40, 44], [40, 45], [40, 48], [40, 51], [40, 53], [40, 54], [40, 55], [40, 56], [40, 57], [40, 58], [40, 59], [40, 60], [40, 61], [40, 62], [40, 64], [40, 65], [40, 67], [40, 69], [40, 70], [40, 71], [40, 74], [40, 75], [40, 77], [40, 78], [40, 79], [40, 81], [40, 82], [40, 84], [40, 85], [40, 87], [40, 90], [40, 92], [40, 97], [40, 98], [40, 99], [41, 42], [41, 43], [41, 44], [41, 50], [41, 54], [41, 60], [41, 62], [41, 65], [41, 68], [41, 69], [41, 71], [41, 78], [41, 79], [41, 83], [41, 84], [41, 85], [41, 87], [41, 91], [41, 93], [41, 94], [41, 95], [41, 96], [41, 98], [41, 99], [42, 46], [42, 47], [42, 48], [42, 49], [42, 55], [42, 57], [42, 58], [42, 61], [42, 64], [42, 66], [42, 67], [42, 68], [42, 71], [42, 72], [42, 73], [42, 77], [42, 78], [42, 80], [42, 82], [42, 86], [42, 87], [42, 88], [42, 90], [42, 93], [42, 94], [42, 95], [42, 97], [42, 99], [43, 44], [43, 45], [43, 46], [43, 48], [43, 49], [43, 50], [43, 51], [43, 54], [43, 55], [43, 56], [43, 58], [43, 59], [43, 62], [43, 63], [43, 65], [43, 66], [43, 67], [43, 69], [43, 71], [43, 72], [43, 76], [43, 78], [43, 79], [43, 80], [43, 81], [43, 83], [43, 84], [43, 86], [43, 88], [43, 90], [43, 91], [43, 92], [43, 95], [43, 96], [43, 97], [43, 98], [44, 46], [44, 47], [44, 49], [44, 50], [44, 51], [44, 53], [44, 55], [44, 56], [44, 57], [44, 58], [44, 60], [44, 62], [44, 67], [44, 68], [44, 70], [44, 71], [44, 76], [44, 80], [44, 82], [44, 83], [44, 84], [44, 86], [44, 87], [44, 90], [44, 92], [44, 96], [45, 46], [45, 47], [45, 49], [45, 50], [45, 54], [45, 57], [45, 60], [45, 61], [45, 62], [45, 65], [45, 66], [45, 67], [45, 68], [45, 72], [45, 74], [45, 78], [45, 79], [45, 80], [45, 82], [45, 84], [45, 85], [45, 87], [45, 88], [45, 89], [45, 90], [45, 91], [45, 92], [45, 96], [45, 97], [45, 99], [46, 48], [46, 50], [46, 51], [46, 56], [46, 59], [46, 62], [46, 64], [46, 65], [46, 66], [46, 67], [46, 70], [46, 71], [46, 72], [46, 73], [46, 74], [46, 76], [46, 77], [46, 79], [46, 80], [46, 81], [46, 82], [46, 83], [46, 84], [46, 86], [46, 89], [46, 90], [46, 91], [46, 92], [46, 93], [46, 94], [46, 95], [46, 96], [46, 97], [46, 98], [46, 99], [47, 51], [47, 52], [47, 57], [47, 58], [47, 61], [47, 64], [47, 66], [47, 67], [47, 70], [47, 71], [47, 73], [47, 78], [47, 79], [47, 80], [47, 83], [47, 84], [47, 85], [47, 89], [47, 90], [47, 93], [47, 95], [47, 96], [47, 97], [47, 98], [48, 50], [48, 51], [48, 52], [48, 53], [48, 55], [48, 56], [48, 58], [48, 59], [48, 61], [48, 63], [48, 67], [48, 68], [48, 70], [48, 71], [48, 73], [48, 75], [48, 79], [48, 80], [48, 81], [48, 84], [48, 85], [48, 87], [48, 88], [48, 89], [48, 91], [48, 94], [48, 97], [48, 98], [48, 99], [49, 50], [49, 53], [49, 54], [49, 57], [49, 58], [49, 60], [49, 63], [49, 64], [49, 65], [49, 67], [49, 72], [49, 75], [49, 78], [49, 79], [49, 82], [49, 83], [49, 84], [49, 85], [49, 88], [49, 90], [49, 91], [49, 93], [49, 94], [49, 97], [49, 98], [50, 51], [50, 53], [50, 54], [50, 55], [50, 56], [50, 57], [50, 58], [50, 59], [50, 63], [50, 64], [50, 65], [50, 66], [50, 68], [50, 69], [50, 73], [50, 76], [50, 77], [50, 78], [50, 79], [50, 80], [50, 81], [50, 82], [50, 84], [50, 86], [50, 87], [50, 88], [50, 89], [50, 91], [50, 93], [50, 94], [50, 97], [50, 98], [51, 52], [51, 56], [51, 57], [51, 59], [51, 60], [51, 61], [51, 62], [51, 68], [51, 69], [51, 71], [51, 73], [51, 74], [51, 75], [51, 76], [51, 77], [51, 79], [51, 80], [51, 84], [51, 89], [51, 90], [51, 91], [51, 92], [51, 94], [51, 95], [51, 97], [51, 98], [51, 99], [52, 53], [52, 58], [52, 59], [52, 62], [52, 63], [52, 68], [52, 74], [52, 75], [52, 77], [52, 78], [52, 82], [52, 87], [52, 90], [52, 92], [52, 95], [52, 96], [52, 97], [52, 98], [53, 56], [53, 58], [53, 60], [53, 62], [53, 65], [53, 67], [53, 68], [53, 69], [53, 70], [53, 71], [53, 72], [53, 73], [53, 77], [53, 79], [53, 81], [53, 82], [53, 83], [53, 84], [53, 85], [53, 86], [53, 87], [53, 88], [53, 89], [53, 91], [53, 95], [53, 98], [53, 99], [54, 55], [54, 56], [54, 58], [54, 60], [54, 62], [54, 63], [54, 64], [54, 66], [54, 67], [54, 69], [54, 72], [54, 73], [54, 74], [54, 77], [54, 78], [54, 82], [54, 83], [54, 85], [54, 87], [54, 91], [54, 92], [54, 97], [54, 98], [54, 99], [55, 56], [55, 58], [55, 59], [55, 63], [55, 68], [55, 69], [55, 70], [55, 71], [55, 72], [55, 73], [55, 74], [55, 75], [55, 79], [55, 80], [55, 81], [55, 83], [55, 84], [55, 85], [55, 87], [55, 93], [55, 94], [55, 98], [55, 99], [56, 59], [56, 60], [56, 61], [56, 62], [56, 63], [56, 67], [56, 70], [56, 71], [56, 72], [56, 75], [56, 76], [56, 77], [56, 79], [56, 80], [56, 82], [56, 84], [56, 85], [56, 86], [56, 87], [56, 88], [56, 89], [56, 91], [56, 94], [56, 97], [56, 98], [56, 99], [57, 58], [57, 59], [57, 63], [57, 64], [57, 65], [57, 68], [57, 71], [57, 72], [57, 73], [57, 74], [57, 75], [57, 79], [57, 81], [57, 82], [57, 83], [57, 84], [57, 85], [57, 86], [57, 89], [57, 91], [57, 92], [58, 60], [58, 61], [58, 62], [58, 66], [58, 67], [58, 68], [58, 69], [58, 70], [58, 71], [58, 72], [58, 74], [58, 76], [58, 77], [58, 80], [58, 84], [58, 86], [58, 87], [58, 90], [58, 91], [58, 92], [58, 93], [58, 97], [59, 63], [59, 66], [59, 67], [59, 70], [59, 72], [59, 74], [59, 75], [59, 77], [59, 78], [59, 79], [59, 80], [59, 81], [59, 82], [59, 83], [59, 84], [59, 89], [59, 90], [59, 91], [59, 93], [59, 94], [59, 95], [59, 98], [59, 99], [60, 62], [60, 63], [60, 66], [60, 67], [60, 69], [60, 70], [60, 73], [60, 74], [60, 76], [60, 78], [60, 80], [60, 81], [60, 91], [60, 92], [60, 95], [60, 96], [60, 98], [61, 62], [61, 64], [61, 65], [61, 67], [61, 69], [61, 70], [61, 74], [61, 76], [61, 79], [61, 80], [61, 82], [61, 83], [61, 86], [61, 87], [61, 90], [61, 91], [61, 94], [61, 96], [61, 97], [62, 63], [62, 65], [62, 67], [62, 71], [62, 72], [62, 74], [62, 77], [62, 81], [62, 83], [62, 90], [62, 93], [62, 96], [62, 97], [62, 98], [62, 99], [63, 64], [63, 66], [63, 68], [63, 70], [63, 73], [63, 76], [63, 79], [63, 80], [63, 81], [63, 82], [63, 88], [63, 89], [63, 90], [63, 91], [63, 92], [63, 93], [63, 96], [63, 98], [63, 99], [64, 67], [64, 69], [64, 70], [64, 71], [64, 73], [64, 76], [64, 84], [64, 86], [64, 88], [64, 89], [64, 91], [64, 92], [64, 93], [64, 94], [64, 96], [64, 98], [65, 66], [65, 67], [65, 69], [65, 70], [65, 73], [65, 76], [65, 77], [65, 79], [65, 82], [65, 84], [65, 85], [65, 86], [65, 88], [65, 91], [65, 92], [65, 93], [65, 94], [65, 96], [65, 98], [66, 67], [66, 68], [66, 70], [66, 71], [66, 75], [66, 77], [66, 80], [66, 85], [66, 87], [66, 88], [66, 90], [66, 91], [66, 96], [66, 97], [66, 98], [66, 99], [67, 68], [67, 72], [67, 78], [67, 81], [67, 82], [67, 84], [67, 86], [67, 87], [67, 88], [67, 90], [67, 91], [67, 94], [67, 97], [67, 98], [67, 99], [68, 71], [68, 73], [68, 76], [68, 79], [68, 80], [68, 82], [68, 87], [68, 92], [68, 94], [68, 95], [68, 96], [68, 98], [68, 99], [69, 72], [69, 74], [69, 75], [69, 76], [69, 77], [69, 78], [69, 79], [69, 80], [69, 83], [69, 86], [69, 87], [69, 89], [69, 91], [69, 92], [69, 93], [69, 94], [69, 95], [69, 96], [69, 99], [70, 71], [70, 73], [70, 75], [70, 76], [70, 77], [70, 78], [70, 82], [70, 86], [70, 88], [70, 90], [70, 94], [70, 95], [70, 96], [70, 97], [71, 72], [71, 73], [71, 75], [71, 76], [71, 77], [71, 78], [71, 79], [71, 84], [71, 85], [71, 87], [71, 88], [71, 89], [71, 91], [71, 92], [71, 97], [72, 73], [72, 74], [72, 75], [72, 76], [72, 80], [72, 81], [72, 84], [72, 85], [72, 87], [72, 89], [72, 92], [72, 95], [72, 96], [72, 99], [73, 76], [73, 77], [73, 79], [73, 86], [73, 88], [73, 91], [73, 95], [73, 96], [73, 97], [73, 99], [74, 75], [74, 78], [74, 79], [74, 81], [74, 88], [74, 89], [74, 93], [74, 94], [74, 95], [74, 96], [74, 97], [74, 99], [75, 77], [75, 79], [75, 81], [75, 82], [75, 83], [75, 86], [75, 88], [75, 89], [75, 90], [75, 91], [75, 92], [75, 93], [75, 94], [75, 95], [75, 96], [75, 97], [75, 98], [75, 99], [76, 78], [76, 84], [76, 85], [76, 87], [76, 89], [76, 90], [76, 92], [76, 97], [76, 98], [76, 99], [77, 79], [77, 84], [77, 85], [77, 87], [77, 88], [77, 91], [77, 92], [77, 93], [77, 94], [77, 96], [77, 98], [78, 80], [78, 83], [78, 84], [78, 85], [78, 86], [78, 88], [78, 91], [78, 96], [78, 97], [78, 98], [78, 99], [79, 80], [79, 81], [79, 83], [79, 84], [79, 85], [79, 86], [79, 87], [79, 89], [79, 91], [79, 92], [79, 94], [79, 95], [79, 96], [79, 98], [79, 99], [80, 81], [80, 82], [80, 84], [80, 85], [80, 86], [80, 88], [80, 89], [80, 91], [80, 92], [80, 93], [80, 97], [80, 98], [81, 82], [81, 85], [81, 86], [81, 89], [81, 90], [81, 92], [81, 94], [81, 95], [81, 98], [82, 86], [82, 87], [82, 88], [82, 89], [82, 91], [82, 92], [82, 96], [82, 99], [83, 86], [83, 87], [83, 92], [83, 94], [83, 95], [83, 98], [84, 89], [84, 91], [84, 93], [84, 94], [84, 96], [84, 97], [84, 98], [85, 89], [85, 90], [85, 92], [85, 93], [85, 94], [85, 97], [86, 87], [86, 90], [86, 91], [86, 93], [86, 94], [86, 95], [86, 96], [86, 98], [86, 99], [87, 90], [87, 93], [87, 94], [87, 96], [88, 93], [88, 97], [89, 90], [89, 92], [89, 93], [89, 95], [89, 97], [89, 99], [90, 94], [90, 96], [91, 94], [91, 95], [91, 98], [92, 93], [92, 95], [92, 96], [92, 97], [92, 98], [93, 95], [93, 96], [94, 95], [94, 96], [94, 97], [94, 99], [95, 97], [95, 98], [95, 99], [96, 99], [97, 98], [97, 99]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l6-s6/environment/Dockerfile b/tasks/construct-nppc-clique-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-clique-l6-s6/environment/instance.json b/tasks/construct-nppc-clique-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9239898365a0ad82199ddf02d2a023017ccf5caf --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 12], [0, 13], [0, 14], [0, 16], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 25], [0, 26], [0, 28], [0, 31], [0, 34], [0, 36], [0, 37], [0, 39], [0, 42], [0, 44], [0, 46], [0, 49], [0, 50], [0, 51], [0, 52], [0, 53], [0, 57], [0, 65], [0, 66], [0, 70], [0, 71], [0, 72], [0, 73], [0, 74], [0, 75], [0, 76], [0, 77], [0, 78], [0, 79], [0, 81], [0, 83], [0, 84], [0, 86], [0, 87], [0, 89], [0, 92], [0, 94], [0, 97], [1, 3], [1, 4], [1, 6], [1, 7], [1, 8], [1, 9], [1, 11], [1, 12], [1, 13], [1, 14], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 24], [1, 25], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 36], [1, 37], [1, 38], [1, 40], [1, 42], [1, 43], [1, 46], [1, 49], [1, 50], [1, 52], [1, 58], [1, 59], [1, 60], [1, 61], [1, 63], [1, 65], [1, 66], [1, 67], [1, 69], [1, 70], [1, 71], [1, 72], [1, 74], [1, 81], [1, 82], [1, 83], [1, 84], [1, 85], [1, 86], [1, 87], [1, 89], [1, 90], [1, 92], [1, 93], [1, 96], [1, 97], [1, 99], [2, 3], [2, 6], [2, 8], [2, 10], [2, 14], [2, 16], [2, 17], [2, 21], [2, 22], [2, 24], [2, 28], [2, 31], [2, 32], [2, 37], [2, 38], [2, 40], [2, 41], [2, 42], [2, 44], [2, 45], [2, 47], [2, 48], [2, 49], [2, 51], [2, 52], [2, 57], [2, 63], [2, 64], [2, 66], [2, 67], [2, 68], [2, 69], [2, 74], [2, 75], [2, 78], [2, 80], [2, 81], [2, 82], [2, 84], [2, 86], [2, 87], [2, 89], [2, 90], [2, 92], [2, 93], [2, 96], [2, 98], [3, 4], [3, 5], [3, 6], [3, 7], [3, 9], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 18], [3, 19], [3, 21], [3, 22], [3, 23], [3, 25], [3, 28], [3, 29], [3, 30], [3, 32], [3, 34], [3, 36], [3, 37], [3, 38], [3, 39], [3, 42], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 51], [3, 53], [3, 54], [3, 55], [3, 61], [3, 62], [3, 63], [3, 65], [3, 66], [3, 71], [3, 72], [3, 73], [3, 77], [3, 79], [3, 83], [3, 84], [3, 85], [3, 86], [3, 87], [3, 88], [3, 89], [3, 90], [3, 91], [3, 92], [3, 93], [3, 99], [4, 6], [4, 7], [4, 10], [4, 15], [4, 18], [4, 19], [4, 21], [4, 23], [4, 24], [4, 29], [4, 30], [4, 31], [4, 33], [4, 37], [4, 39], [4, 41], [4, 42], [4, 43], [4, 44], [4, 47], [4, 51], [4, 53], [4, 57], [4, 58], [4, 60], [4, 62], [4, 63], [4, 66], [4, 72], [4, 74], [4, 76], [4, 78], [4, 81], [4, 83], [4, 85], [4, 87], [4, 88], [4, 89], [4, 90], [4, 92], [4, 93], [4, 96], [4, 99], [5, 8], [5, 9], [5, 10], [5, 12], [5, 14], [5, 21], [5, 22], [5, 23], [5, 24], [5, 26], [5, 30], [5, 31], [5, 34], [5, 36], [5, 40], [5, 43], [5, 46], [5, 55], [5, 56], [5, 57], [5, 59], [5, 60], [5, 62], [5, 65], [5, 66], [5, 69], [5, 70], [5, 71], [5, 73], [5, 74], [5, 75], [5, 78], [5, 81], [5, 82], [5, 83], [5, 84], [5, 86], [5, 89], [5, 91], [5, 96], [5, 97], [6, 7], [6, 8], [6, 9], [6, 10], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 19], [6, 20], [6, 21], [6, 22], [6, 25], [6, 26], [6, 28], [6, 29], [6, 32], [6, 36], [6, 37], [6, 38], [6, 39], [6, 40], [6, 41], [6, 45], [6, 47], [6, 49], [6, 50], [6, 52], [6, 53], [6, 56], [6, 57], [6, 58], [6, 62], [6, 63], [6, 66], [6, 68], [6, 70], [6, 71], [6, 74], [6, 76], [6, 77], [6, 81], [6, 83], [6, 84], [6, 86], [6, 87], [6, 88], [6, 91], [6, 92], [6, 93], [6, 94], [6, 95], [6, 99], [7, 8], [7, 9], [7, 10], [7, 14], [7, 15], [7, 16], [7, 17], [7, 22], [7, 23], [7, 24], [7, 25], [7, 29], [7, 31], [7, 33], [7, 34], [7, 36], [7, 38], [7, 42], [7, 45], [7, 46], [7, 49], [7, 51], [7, 53], [7, 57], [7, 58], [7, 60], [7, 61], [7, 62], [7, 68], [7, 69], [7, 71], [7, 72], [7, 73], [7, 74], [7, 75], [7, 76], [7, 78], [7, 82], [7, 83], [7, 86], [7, 87], [7, 91], [7, 92], [7, 93], [7, 94], [7, 97], [7, 98], [7, 99], [8, 10], [8, 12], [8, 16], [8, 20], [8, 21], [8, 22], [8, 24], [8, 27], [8, 29], [8, 33], [8, 34], [8, 35], [8, 38], [8, 40], [8, 41], [8, 46], [8, 47], [8, 49], [8, 50], [8, 51], [8, 53], [8, 54], [8, 62], [8, 64], [8, 65], [8, 66], [8, 67], [8, 72], [8, 73], [8, 75], [8, 78], [8, 79], [8, 80], [8, 81], [8, 86], [8, 87], [8, 89], [8, 97], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 18], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 27], [9, 30], [9, 32], [9, 33], [9, 35], [9, 36], [9, 37], [9, 38], [9, 41], [9, 45], [9, 46], [9, 47], [9, 50], [9, 52], [9, 54], [9, 55], [9, 58], [9, 59], [9, 60], [9, 61], [9, 62], [9, 63], [9, 65], [9, 67], [9, 68], [9, 70], [9, 72], [9, 73], [9, 74], [9, 78], [9, 79], [9, 81], [9, 83], [9, 97], [10, 12], [10, 14], [10, 21], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 30], [10, 33], [10, 34], [10, 36], [10, 37], [10, 38], [10, 39], [10, 42], [10, 43], [10, 44], [10, 45], [10, 49], [10, 51], [10, 52], [10, 53], [10, 56], [10, 58], [10, 59], [10, 63], [10, 69], [10, 70], [10, 72], [10, 73], [10, 75], [10, 76], [10, 77], [10, 80], [10, 81], [10, 83], [10, 87], [10, 88], [10, 89], [10, 93], [10, 94], [10, 95], [10, 97], [10, 99], [11, 14], [11, 18], [11, 20], [11, 21], [11, 22], [11, 25], [11, 26], [11, 27], [11, 30], [11, 34], [11, 35], [11, 36], [11, 37], [11, 39], [11, 42], [11, 47], [11, 50], [11, 53], [11, 54], [11, 55], [11, 56], [11, 57], [11, 60], [11, 61], [11, 62], [11, 64], [11, 66], [11, 69], [11, 75], [11, 76], [11, 77], [11, 78], [11, 79], [11, 82], [11, 86], [11, 87], [11, 88], [11, 92], [11, 93], [11, 95], [11, 96], [11, 97], [11, 98], [12, 13], [12, 14], [12, 16], [12, 17], [12, 19], [12, 21], [12, 22], [12, 25], [12, 26], [12, 27], [12, 28], [12, 33], [12, 34], [12, 36], [12, 37], [12, 38], [12, 41], [12, 42], [12, 43], [12, 45], [12, 46], [12, 48], [12, 49], [12, 50], [12, 51], [12, 57], [12, 59], [12, 66], [12, 69], [12, 70], [12, 71], [12, 72], [12, 74], [12, 77], [12, 78], [12, 79], [12, 80], [12, 81], [12, 84], [12, 86], [12, 88], [12, 89], [12, 92], [12, 93], [12, 95], [12, 98], [12, 99], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 21], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 28], [13, 29], [13, 30], [13, 31], [13, 36], [13, 37], [13, 38], [13, 41], [13, 43], [13, 46], [13, 47], [13, 49], [13, 50], [13, 53], [13, 56], [13, 57], [13, 58], [13, 61], [13, 63], [13, 64], [13, 66], [13, 67], [13, 69], [13, 71], [13, 72], [13, 73], [13, 74], [13, 76], [13, 77], [13, 78], [13, 79], [13, 80], [13, 86], [13, 87], [13, 88], [13, 89], [13, 91], [13, 92], [13, 93], [13, 94], [13, 96], [13, 97], [14, 15], [14, 16], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [14, 36], [14, 37], [14, 39], [14, 40], [14, 42], [14, 43], [14, 45], [14, 47], [14, 49], [14, 50], [14, 51], [14, 52], [14, 55], [14, 58], [14, 59], [14, 61], [14, 63], [14, 64], [14, 65], [14, 66], [14, 67], [14, 68], [14, 69], [14, 71], [14, 72], [14, 77], [14, 79], [14, 81], [14, 83], [14, 86], [14, 87], [14, 88], [14, 90], [14, 91], [14, 92], [14, 93], [14, 95], [14, 96], [14, 98], [15, 17], [15, 18], [15, 19], [15, 22], [15, 23], [15, 24], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 32], [15, 34], [15, 36], [15, 37], [15, 38], [15, 39], [15, 40], [15, 43], [15, 50], [15, 52], [15, 55], [15, 58], [15, 62], [15, 63], [15, 64], [15, 68], [15, 70], [15, 71], [15, 72], [15, 74], [15, 75], [15, 76], [15, 78], [15, 79], [15, 81], [15, 82], [15, 83], [15, 84], [15, 87], [15, 92], [15, 94], [15, 95], [15, 97], [15, 98], [15, 99], [16, 19], [16, 21], [16, 23], [16, 24], [16, 25], [16, 27], [16, 28], [16, 29], [16, 31], [16, 35], [16, 36], [16, 37], [16, 38], [16, 39], [16, 41], [16, 42], [16, 45], [16, 46], [16, 47], [16, 49], [16, 50], [16, 54], [16, 58], [16, 60], [16, 61], [16, 62], [16, 64], [16, 66], [16, 71], [16, 72], [16, 73], [16, 79], [16, 80], [16, 83], [16, 86], [16, 87], [16, 89], [16, 90], [16, 92], [16, 93], [16, 94], [16, 95], [16, 97], [16, 98], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 26], [17, 27], [17, 29], [17, 30], [17, 34], [17, 35], [17, 36], [17, 44], [17, 47], [17, 48], [17, 50], [17, 51], [17, 52], [17, 54], [17, 55], [17, 56], [17, 58], [17, 60], [17, 61], [17, 63], [17, 65], [17, 69], [17, 75], [17, 76], [17, 78], [17, 79], [17, 81], [17, 82], [17, 83], [17, 84], [17, 85], [17, 89], [17, 92], [17, 95], [17, 96], [17, 98], [17, 99], [18, 19], [18, 21], [18, 23], [18, 24], [18, 25], [18, 27], [18, 29], [18, 30], [18, 31], [18, 35], [18, 36], [18, 37], [18, 38], [18, 39], [18, 40], [18, 41], [18, 42], [18, 44], [18, 45], [18, 46], [18, 49], [18, 51], [18, 53], [18, 54], [18, 55], [18, 57], [18, 61], [18, 63], [18, 64], [18, 65], [18, 66], [18, 70], [18, 73], [18, 75], [18, 81], [18, 88], [18, 89], [18, 90], [18, 91], [18, 92], [18, 95], [18, 96], [18, 97], [18, 98], [18, 99], [19, 21], [19, 25], [19, 26], [19, 28], [19, 30], [19, 31], [19, 32], [19, 36], [19, 37], [19, 38], [19, 39], [19, 40], [19, 42], [19, 44], [19, 47], [19, 49], [19, 50], [19, 56], [19, 57], [19, 58], [19, 59], [19, 63], [19, 64], [19, 66], [19, 67], [19, 69], [19, 70], [19, 71], [19, 78], [19, 82], [19, 85], [19, 86], [19, 87], [19, 88], [19, 90], [19, 91], [19, 92], [19, 93], [19, 96], [19, 97], [19, 98], [19, 99], [20, 21], [20, 22], [20, 24], [20, 26], [20, 27], [20, 28], [20, 31], [20, 32], [20, 33], [20, 34], [20, 36], [20, 37], [20, 38], [20, 42], [20, 46], [20, 48], [20, 49], [20, 50], [20, 51], [20, 53], [20, 56], [20, 58], [20, 63], [20, 66], [20, 70], [20, 72], [20, 74], [20, 75], [20, 76], [20, 78], [20, 79], [20, 82], [20, 83], [20, 84], [20, 85], [20, 86], [20, 87], [20, 88], [20, 90], [20, 91], [20, 95], [20, 96], [20, 97], [20, 99], [21, 24], [21, 25], [21, 27], [21, 28], [21, 30], [21, 32], [21, 33], [21, 34], [21, 35], [21, 36], [21, 37], [21, 38], [21, 39], [21, 43], [21, 46], [21, 49], [21, 50], [21, 51], [21, 59], [21, 61], [21, 62], [21, 65], [21, 66], [21, 69], [21, 70], [21, 71], [21, 73], [21, 74], [21, 78], [21, 80], [21, 81], [21, 82], [21, 84], [21, 85], [21, 86], [21, 90], [21, 92], [21, 93], [21, 94], [21, 97], [22, 23], [22, 24], [22, 28], [22, 30], [22, 31], [22, 33], [22, 37], [22, 38], [22, 40], [22, 42], [22, 47], [22, 49], [22, 51], [22, 52], [22, 54], [22, 55], [22, 60], [22, 62], [22, 63], [22, 64], [22, 65], [22, 66], [22, 68], [22, 69], [22, 71], [22, 72], [22, 73], [22, 74], [22, 76], [22, 79], [22, 82], [22, 84], [22, 88], [22, 89], [22, 91], [23, 25], [23, 26], [23, 28], [23, 29], [23, 31], [23, 32], [23, 33], [23, 34], [23, 36], [23, 37], [23, 38], [23, 40], [23, 41], [23, 42], [23, 44], [23, 46], [23, 49], [23, 51], [23, 52], [23, 54], [23, 56], [23, 57], [23, 58], [23, 59], [23, 61], [23, 64], [23, 67], [23, 68], [23, 69], [23, 71], [23, 72], [23, 73], [23, 75], [23, 78], [23, 81], [23, 82], [23, 84], [23, 87], [23, 88], [23, 89], [23, 90], [23, 92], [23, 93], [23, 96], [24, 26], [24, 27], [24, 28], [24, 34], [24, 35], [24, 37], [24, 38], [24, 40], [24, 41], [24, 45], [24, 46], [24, 47], [24, 49], [24, 51], [24, 53], [24, 54], [24, 56], [24, 61], [24, 62], [24, 63], [24, 66], [24, 68], [24, 69], [24, 70], [24, 72], [24, 76], [24, 77], [24, 81], [24, 82], [24, 84], [24, 87], [24, 90], [24, 95], [24, 96], [24, 98], [25, 28], [25, 29], [25, 30], [25, 33], [25, 34], [25, 36], [25, 37], [25, 40], [25, 42], [25, 44], [25, 48], [25, 49], [25, 50], [25, 52], [25, 55], [25, 57], [25, 60], [25, 61], [25, 62], [25, 65], [25, 66], [25, 68], [25, 69], [25, 71], [25, 72], [25, 73], [25, 74], [25, 76], [25, 77], [25, 79], [25, 81], [25, 82], [25, 86], [25, 87], [25, 92], [25, 94], [25, 98], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 37], [26, 39], [26, 40], [26, 41], [26, 44], [26, 45], [26, 46], [26, 48], [26, 49], [26, 52], [26, 53], [26, 57], [26, 58], [26, 59], [26, 60], [26, 61], [26, 63], [26, 66], [26, 67], [26, 68], [26, 70], [26, 71], [26, 72], [26, 73], [26, 74], [26, 76], [26, 77], [26, 78], [26, 80], [26, 82], [26, 83], [26, 84], [26, 85], [26, 86], [26, 87], [26, 92], [26, 94], [27, 31], [27, 32], [27, 36], [27, 37], [27, 38], [27, 41], [27, 43], [27, 46], [27, 51], [27, 54], [27, 55], [27, 58], [27, 63], [27, 64], [27, 67], [27, 68], [27, 69], [27, 72], [27, 79], [27, 80], [27, 82], [27, 83], [27, 86], [27, 88], [27, 89], [27, 91], [27, 95], [27, 97], [27, 99], [28, 29], [28, 30], [28, 31], [28, 35], [28, 36], [28, 37], [28, 39], [28, 40], [28, 42], [28, 43], [28, 45], [28, 47], [28, 48], [28, 49], [28, 50], [28, 51], [28, 52], [28, 54], [28, 55], [28, 56], [28, 57], [28, 60], [28, 63], [28, 64], [28, 65], [28, 66], [28, 67], [28, 69], [28, 71], [28, 72], [28, 74], [28, 75], [28, 76], [28, 78], [28, 82], [28, 84], [28, 86], [28, 89], [28, 91], [28, 92], [28, 93], [28, 97], [28, 98], [29, 30], [29, 31], [29, 33], [29, 34], [29, 39], [29, 40], [29, 41], [29, 43], [29, 45], [29, 48], [29, 49], [29, 50], [29, 52], [29, 53], [29, 56], [29, 59], [29, 62], [29, 63], [29, 66], [29, 72], [29, 76], [29, 77], [29, 82], [29, 83], [29, 84], [29, 85], [29, 86], [29, 87], [29, 88], [29, 89], [29, 92], [29, 93], [29, 94], [29, 97], [29, 99], [30, 32], [30, 36], [30, 38], [30, 39], [30, 42], [30, 44], [30, 45], [30, 49], [30, 51], [30, 53], [30, 54], [30, 56], [30, 59], [30, 60], [30, 62], [30, 64], [30, 65], [30, 67], [30, 68], [30, 72], [30, 73], [30, 74], [30, 76], [30, 77], [30, 79], [30, 80], [30, 81], [30, 82], [30, 83], [30, 84], [30, 85], [30, 86], [30, 88], [30, 93], [30, 96], [30, 98], [31, 34], [31, 36], [31, 38], [31, 39], [31, 45], [31, 46], [31, 48], [31, 49], [31, 50], [31, 51], [31, 52], [31, 57], [31, 66], [31, 69], [31, 70], [31, 74], [31, 79], [31, 84], [31, 86], [31, 87], [31, 95], [31, 99], [32, 33], [32, 35], [32, 36], [32, 38], [32, 40], [32, 41], [32, 42], [32, 43], [32, 45], [32, 46], [32, 47], [32, 48], [32, 50], [32, 51], [32, 52], [32, 57], [32, 60], [32, 61], [32, 64], [32, 65], [32, 67], [32, 70], [32, 71], [32, 73], [32, 75], [32, 79], [32, 80], [32, 82], [32, 83], [32, 84], [32, 89], [32, 91], [32, 92], [32, 93], [32, 94], [32, 95], [32, 96], [32, 98], [33, 39], [33, 41], [33, 43], [33, 44], [33, 45], [33, 47], [33, 48], [33, 49], [33, 51], [33, 54], [33, 56], [33, 58], [33, 59], [33, 60], [33, 64], [33, 65], [33, 68], [33, 76], [33, 77], [33, 78], [33, 79], [33, 82], [33, 83], [33, 85], [33, 88], [33, 91], [33, 94], [33, 95], [33, 96], [33, 99], [34, 36], [34, 37], [34, 39], [34, 40], [34, 42], [34, 43], [34, 44], [34, 45], [34, 46], [34, 48], [34, 49], [34, 53], [34, 55], [34, 56], [34, 57], [34, 58], [34, 59], [34, 61], [34, 62], [34, 63], [34, 69], [34, 72], [34, 74], [34, 75], [34, 77], [34, 78], [34, 80], [34, 81], [34, 83], [34, 85], [34, 86], [34, 87], [34, 91], [34, 92], [34, 93], [34, 95], [35, 37], [35, 38], [35, 39], [35, 40], [35, 45], [35, 46], [35, 47], [35, 51], [35, 53], [35, 54], [35, 55], [35, 58], [35, 60], [35, 61], [35, 67], [35, 68], [35, 69], [35, 71], [35, 72], [35, 73], [35, 75], [35, 77], [35, 79], [35, 80], [35, 81], [35, 82], [35, 86], [35, 89], [35, 92], [35, 93], [35, 94], [35, 95], [35, 96], [35, 97], [36, 37], [36, 43], [36, 44], [36, 46], [36, 49], [36, 50], [36, 51], [36, 53], [36, 54], [36, 55], [36, 57], [36, 58], [36, 59], [36, 63], [36, 65], [36, 66], [36, 68], [36, 71], [36, 72], [36, 76], [36, 77], [36, 79], [36, 80], [36, 81], [36, 82], [36, 85], [36, 86], [36, 87], [36, 89], [36, 91], [36, 92], [36, 93], [36, 95], [36, 96], [36, 97], [36, 98], [37, 41], [37, 44], [37, 48], [37, 49], [37, 50], [37, 54], [37, 56], [37, 57], [37, 59], [37, 61], [37, 63], [37, 65], [37, 66], [37, 67], [37, 68], [37, 70], [37, 71], [37, 72], [37, 73], [37, 74], [37, 75], [37, 78], [37, 79], [37, 80], [37, 83], [37, 84], [37, 85], [37, 86], [37, 92], [37, 93], [37, 94], [37, 97], [38, 39], [38, 40], [38, 41], [38, 42], [38, 43], [38, 44], [38, 45], [38, 46], [38, 49], [38, 50], [38, 51], [38, 52], [38, 53], [38, 55], [38, 56], [38, 57], [38, 60], [38, 63], [38, 66], [38, 67], [38, 76], [38, 78], [38, 79], [38, 81], [38, 82], [38, 86], [38, 88], [38, 93], [38, 96], [38, 98], [38, 99], [39, 43], [39, 49], [39, 56], [39, 61], [39, 63], [39, 64], [39, 65], [39, 66], [39, 67], [39, 69], [39, 70], [39, 72], [39, 73], [39, 76], [39, 78], [39, 79], [39, 86], [39, 89], [39, 90], [39, 93], [39, 94], [39, 96], [39, 98], [40, 41], [40, 42], [40, 43], [40, 44], [40, 45], [40, 46], [40, 47], [40, 49], [40, 50], [40, 51], [40, 52], [40, 53], [40, 54], [40, 55], [40, 57], [40, 59], [40, 61], [40, 65], [40, 66], [40, 69], [40, 70], [40, 74], [40, 75], [40, 79], [40, 80], [40, 81], [40, 83], [40, 86], [40, 87], [40, 88], [40, 90], [40, 92], [40, 93], [40, 96], [40, 97], [40, 98], [41, 42], [41, 43], [41, 44], [41, 45], [41, 46], [41, 47], [41, 49], [41, 52], [41, 54], [41, 58], [41, 60], [41, 61], [41, 63], [41, 64], [41, 72], [41, 73], [41, 74], [41, 75], [41, 76], [41, 77], [41, 79], [41, 80], [41, 82], [41, 84], [41, 87], [41, 90], [41, 91], [41, 94], [42, 43], [42, 48], [42, 49], [42, 50], [42, 54], [42, 55], [42, 56], [42, 57], [42, 59], [42, 62], [42, 63], [42, 65], [42, 68], [42, 70], [42, 72], [42, 73], [42, 74], [42, 75], [42, 76], [42, 79], [42, 86], [42, 92], [42, 93], [42, 96], [42, 99], [43, 44], [43, 45], [43, 47], [43, 48], [43, 49], [43, 53], [43, 58], [43, 59], [43, 60], [43, 63], [43, 64], [43, 65], [43, 67], [43, 69], [43, 70], [43, 72], [43, 73], [43, 74], [43, 75], [43, 76], [43, 77], [43, 82], [43, 86], [43, 87], [43, 88], [43, 89], [43, 90], [43, 91], [43, 95], [43, 96], [43, 99], [44, 45], [44, 46], [44, 48], [44, 49], [44, 50], [44, 51], [44, 54], [44, 55], [44, 56], [44, 58], [44, 59], [44, 60], [44, 61], [44, 62], [44, 64], [44, 65], [44, 68], [44, 70], [44, 73], [44, 74], [44, 75], [44, 76], [44, 77], [44, 79], [44, 82], [44, 84], [44, 88], [44, 90], [44, 91], [44, 92], [44, 93], [44, 94], [44, 96], [44, 97], [45, 47], [45, 49], [45, 50], [45, 53], [45, 54], [45, 57], [45, 58], [45, 60], [45, 61], [45, 62], [45, 63], [45, 67], [45, 68], [45, 69], [45, 70], [45, 76], [45, 77], [45, 78], [45, 80], [45, 85], [45, 86], [45, 87], [45, 88], [45, 89], [45, 90], [45, 92], [45, 95], [45, 97], [45, 99], [46, 47], [46, 48], [46, 50], [46, 54], [46, 56], [46, 57], [46, 59], [46, 60], [46, 62], [46, 63], [46, 64], [46, 65], [46, 66], [46, 67], [46, 68], [46, 76], [46, 77], [46, 78], [46, 79], [46, 80], [46, 81], [46, 82], [46, 84], [46, 85], [46, 86], [46, 87], [46, 88], [46, 89], [46, 90], [46, 92], [46, 94], [46, 96], [46, 98], [46, 99], [47, 48], [47, 49], [47, 51], [47, 53], [47, 55], [47, 59], [47, 60], [47, 62], [47, 63], [47, 64], [47, 71], [47, 76], [47, 77], [47, 78], [47, 81], [47, 83], [47, 84], [47, 85], [47, 86], [47, 87], [47, 90], [47, 91], [47, 93], [47, 94], [47, 96], [47, 97], [48, 49], [48, 50], [48, 51], [48, 53], [48, 57], [48, 58], [48, 59], [48, 61], [48, 62], [48, 64], [48, 65], [48, 68], [48, 69], [48, 72], [48, 73], [48, 75], [48, 81], [48, 82], [48, 84], [48, 86], [48, 88], [48, 91], [48, 93], [48, 96], [48, 98], [49, 50], [49, 53], [49, 54], [49, 56], [49, 60], [49, 63], [49, 66], [49, 68], [49, 69], [49, 71], [49, 73], [49, 74], [49, 75], [49, 76], [49, 78], [49, 79], [49, 85], [49, 86], [49, 87], [49, 88], [49, 91], [49, 92], [49, 95], [49, 96], [49, 97], [50, 52], [50, 57], [50, 60], [50, 61], [50, 63], [50, 64], [50, 66], [50, 68], [50, 71], [50, 73], [50, 74], [50, 77], [50, 78], [50, 79], [50, 81], [50, 82], [50, 83], [50, 85], [50, 86], [50, 87], [50, 88], [50, 90], [50, 91], [50, 92], [50, 94], [50, 95], [50, 96], [50, 98], [51, 53], [51, 54], [51, 55], [51, 58], [51, 59], [51, 60], [51, 61], [51, 64], [51, 66], [51, 71], [51, 72], [51, 73], [51, 76], [51, 79], [51, 80], [51, 81], [51, 82], [51, 83], [51, 85], [51, 86], [51, 87], [51, 88], [51, 92], [52, 53], [52, 56], [52, 58], [52, 59], [52, 60], [52, 61], [52, 62], [52, 65], [52, 68], [52, 71], [52, 72], [52, 73], [52, 74], [52, 75], [52, 76], [52, 78], [52, 79], [52, 82], [52, 84], [52, 85], [52, 86], [52, 87], [52, 88], [52, 91], [52, 93], [52, 94], [52, 97], [52, 99], [53, 54], [53, 58], [53, 59], [53, 60], [53, 61], [53, 62], [53, 64], [53, 65], [53, 66], [53, 67], [53, 68], [53, 73], [53, 78], [53, 80], [53, 81], [53, 84], [53, 87], [53, 88], [53, 91], [53, 92], [53, 95], [53, 98], [53, 99], [54, 55], [54, 59], [54, 60], [54, 61], [54, 62], [54, 63], [54, 64], [54, 65], [54, 69], [54, 71], [54, 72], [54, 73], [54, 76], [54, 77], [54, 78], [54, 83], [54, 87], [54, 88], [54, 95], [54, 96], [54, 98], [55, 56], [55, 58], [55, 59], [55, 60], [55, 62], [55, 63], [55, 64], [55, 70], [55, 82], [55, 83], [55, 87], [55, 89], [55, 92], [55, 93], [55, 94], [55, 95], [55, 98], [55, 99], [56, 60], [56, 62], [56, 64], [56, 67], [56, 72], [56, 73], [56, 74], [56, 75], [56, 77], [56, 79], [56, 81], [56, 82], [56, 84], [56, 86], [56, 89], [56, 94], [56, 97], [56, 99], [57, 59], [57, 60], [57, 61], [57, 62], [57, 64], [57, 65], [57, 66], [57, 68], [57, 69], [57, 74], [57, 75], [57, 80], [57, 81], [57, 83], [57, 84], [57, 91], [57, 92], [57, 93], [57, 95], [57, 97], [57, 99], [58, 59], [58, 60], [58, 61], [58, 63], [58, 66], [58, 68], [58, 70], [58, 71], [58, 72], [58, 74], [58, 75], [58, 79], [58, 81], [58, 82], [58, 83], [58, 84], [58, 86], [58, 88], [58, 90], [58, 92], [58, 93], [58, 94], [58, 95], [58, 96], [58, 97], [59, 60], [59, 62], [59, 63], [59, 64], [59, 66], [59, 68], [59, 71], [59, 72], [59, 73], [59, 74], [59, 78], [59, 79], [59, 81], [59, 82], [59, 84], [59, 89], [59, 90], [59, 91], [59, 93], [59, 95], [59, 96], [59, 99], [60, 61], [60, 62], [60, 63], [60, 64], [60, 65], [60, 66], [60, 68], [60, 71], [60, 72], [60, 74], [60, 76], [60, 80], [60, 81], [60, 83], [60, 84], [60, 85], [60, 90], [60, 91], [60, 92], [60, 94], [60, 96], [60, 98], [61, 62], [61, 63], [61, 64], [61, 65], [61, 66], [61, 69], [61, 70], [61, 73], [61, 74], [61, 78], [61, 79], [61, 80], [61, 83], [61, 85], [61, 87], [61, 88], [61, 90], [61, 93], [61, 94], [61, 96], [62, 63], [62, 64], [62, 67], [62, 68], [62, 69], [62, 72], [62, 73], [62, 75], [62, 76], [62, 78], [62, 79], [62, 80], [62, 81], [62, 82], [62, 83], [62, 86], [62, 87], [62, 88], [62, 89], [62, 90], [62, 91], [62, 94], [62, 95], [62, 96], [62, 98], [62, 99], [63, 64], [63, 65], [63, 69], [63, 71], [63, 72], [63, 74], [63, 77], [63, 78], [63, 79], [63, 80], [63, 81], [63, 84], [63, 89], [63, 90], [63, 91], [63, 93], [63, 98], [64, 67], [64, 68], [64, 71], [64, 72], [64, 73], [64, 75], [64, 79], [64, 81], [64, 82], [64, 83], [64, 92], [64, 95], [64, 96], [64, 98], [64, 99], [65, 66], [65, 68], [65, 71], [65, 72], [65, 73], [65, 76], [65, 77], [65, 81], [65, 87], [65, 88], [65, 90], [65, 97], [65, 98], [66, 70], [66, 71], [66, 72], [66, 73], [66, 76], [66, 77], [66, 78], [66, 85], [66, 86], [66, 87], [66, 89], [66, 92], [66, 93], [66, 95], [66, 96], [66, 97], [67, 70], [67, 71], [67, 72], [67, 73], [67, 75], [67, 76], [67, 77], [67, 79], [67, 82], [67, 84], [67, 85], [67, 89], [67, 90], [67, 91], [67, 93], [67, 94], [67, 96], [67, 97], [67, 98], [68, 70], [68, 71], [68, 72], [68, 76], [68, 78], [68, 79], [68, 80], [68, 81], [68, 82], [68, 83], [68, 85], [68, 86], [68, 87], [68, 90], [68, 91], [68, 92], [68, 94], [68, 95], [68, 96], [68, 97], [69, 70], [69, 71], [69, 74], [69, 75], [69, 79], [69, 80], [69, 81], [69, 84], [69, 87], [69, 88], [69, 89], [69, 91], [69, 93], [69, 94], [69, 97], [69, 99], [70, 71], [70, 74], [70, 76], [70, 77], [70, 78], [70, 80], [70, 82], [70, 83], [70, 84], [70, 85], [70, 87], [70, 90], [70, 93], [70, 94], [70, 96], [70, 97], [71, 72], [71, 73], [71, 74], [71, 75], [71, 76], [71, 77], [71, 78], [71, 79], [71, 82], [71, 83], [71, 84], [71, 86], [71, 87], [71, 88], [71, 89], [71, 90], [71, 91], [71, 92], [71, 93], [71, 95], [71, 99], [72, 73], [72, 74], [72, 75], [72, 76], [72, 77], [72, 80], [72, 81], [72, 82], [72, 83], [72, 84], [72, 86], [72, 88], [72, 89], [72, 94], [72, 96], [72, 98], [72, 99], [73, 74], [73, 76], [73, 79], [73, 80], [73, 81], [73, 82], [73, 84], [73, 86], [73, 92], [73, 94], [73, 96], [74, 75], [74, 76], [74, 78], [74, 79], [74, 80], [74, 81], [74, 82], [74, 83], [74, 85], [74, 86], [74, 88], [74, 89], [74, 90], [74, 92], [74, 93], [74, 95], [74, 99], [75, 78], [75, 79], [75, 83], [75, 84], [75, 85], [75, 87], [75, 88], [75, 92], [75, 93], [75, 94], [75, 98], [76, 77], [76, 78], [76, 79], [76, 80], [76, 83], [76, 85], [76, 87], [76, 88], [76, 93], [76, 97], [76, 98], [77, 78], [77, 79], [77, 82], [77, 85], [77, 88], [77, 90], [77, 94], [77, 95], [77, 96], [77, 97], [77, 99], [78, 79], [78, 80], [78, 81], [78, 90], [78, 92], [78, 93], [78, 95], [78, 96], [78, 97], [79, 80], [79, 81], [79, 82], [79, 84], [79, 85], [79, 88], [79, 93], [79, 97], [79, 98], [80, 82], [80, 83], [80, 86], [80, 88], [80, 90], [80, 91], [80, 93], [80, 97], [80, 99], [81, 82], [81, 83], [81, 84], [81, 85], [81, 86], [81, 89], [81, 93], [81, 94], [81, 95], [81, 97], [81, 99], [82, 83], [82, 84], [82, 85], [82, 88], [82, 89], [82, 90], [82, 93], [82, 94], [82, 95], [82, 96], [82, 97], [82, 98], [82, 99], [83, 85], [83, 86], [83, 87], [83, 88], [83, 90], [83, 91], [83, 92], [83, 93], [83, 95], [83, 98], [83, 99], [84, 85], [84, 86], [84, 87], [84, 88], [84, 95], [84, 97], [85, 86], [85, 87], [85, 90], [85, 91], [85, 93], [85, 94], [85, 95], [85, 96], [85, 97], [86, 88], [86, 89], [86, 90], [86, 92], [86, 93], [86, 94], [86, 97], [86, 99], [87, 88], [87, 91], [87, 92], [87, 93], [87, 95], [87, 98], [87, 99], [88, 89], [88, 90], [88, 91], [88, 94], [88, 97], [88, 98], [88, 99], [89, 92], [89, 94], [89, 95], [89, 97], [89, 98], [90, 91], [90, 93], [90, 95], [90, 96], [90, 98], [90, 99], [91, 92], [91, 93], [91, 94], [91, 95], [91, 96], [91, 97], [91, 98], [92, 93], [92, 97], [92, 98], [93, 97], [93, 99], [94, 95], [94, 96], [94, 97], [94, 98], [94, 99], [95, 96], [95, 97], [95, 98], [96, 97], [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-s6/solution/solve.sh b/tasks/construct-nppc-clique-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e03256b08bd0a8bac2b9c28f3f85b0241eb1f4c2 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [0, 1, 3, 6, 12, 13, 14, 16, 19, 21, 25, 28, 36, 37, 49, 50, 66, 71, 86, 92]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l6-s6/tests/check.py b/tasks/construct-nppc-clique-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s6/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l6-s6/tests/instance.json b/tasks/construct-nppc-clique-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9239898365a0ad82199ddf02d2a023017ccf5caf --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 100, "k": 20, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 12], [0, 13], [0, 14], [0, 16], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 25], [0, 26], [0, 28], [0, 31], [0, 34], [0, 36], [0, 37], [0, 39], [0, 42], [0, 44], [0, 46], [0, 49], [0, 50], [0, 51], [0, 52], [0, 53], [0, 57], [0, 65], [0, 66], [0, 70], [0, 71], [0, 72], [0, 73], [0, 74], [0, 75], [0, 76], [0, 77], [0, 78], [0, 79], [0, 81], [0, 83], [0, 84], [0, 86], [0, 87], [0, 89], [0, 92], [0, 94], [0, 97], [1, 3], [1, 4], [1, 6], [1, 7], [1, 8], [1, 9], [1, 11], [1, 12], [1, 13], [1, 14], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 24], [1, 25], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 36], [1, 37], [1, 38], [1, 40], [1, 42], [1, 43], [1, 46], [1, 49], [1, 50], [1, 52], [1, 58], [1, 59], [1, 60], [1, 61], [1, 63], [1, 65], [1, 66], [1, 67], [1, 69], [1, 70], [1, 71], [1, 72], [1, 74], [1, 81], [1, 82], [1, 83], [1, 84], [1, 85], [1, 86], [1, 87], [1, 89], [1, 90], [1, 92], [1, 93], [1, 96], [1, 97], [1, 99], [2, 3], [2, 6], [2, 8], [2, 10], [2, 14], [2, 16], [2, 17], [2, 21], [2, 22], [2, 24], [2, 28], [2, 31], [2, 32], [2, 37], [2, 38], [2, 40], [2, 41], [2, 42], [2, 44], [2, 45], [2, 47], [2, 48], [2, 49], [2, 51], [2, 52], [2, 57], [2, 63], [2, 64], [2, 66], [2, 67], [2, 68], [2, 69], [2, 74], [2, 75], [2, 78], [2, 80], [2, 81], [2, 82], [2, 84], [2, 86], [2, 87], [2, 89], [2, 90], [2, 92], [2, 93], [2, 96], [2, 98], [3, 4], [3, 5], [3, 6], [3, 7], [3, 9], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 18], [3, 19], [3, 21], [3, 22], [3, 23], [3, 25], [3, 28], [3, 29], [3, 30], [3, 32], [3, 34], [3, 36], [3, 37], [3, 38], [3, 39], [3, 42], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 51], [3, 53], [3, 54], [3, 55], [3, 61], [3, 62], [3, 63], [3, 65], [3, 66], [3, 71], [3, 72], [3, 73], [3, 77], [3, 79], [3, 83], [3, 84], [3, 85], [3, 86], [3, 87], [3, 88], [3, 89], [3, 90], [3, 91], [3, 92], [3, 93], [3, 99], [4, 6], [4, 7], [4, 10], [4, 15], [4, 18], [4, 19], [4, 21], [4, 23], [4, 24], [4, 29], [4, 30], [4, 31], [4, 33], [4, 37], [4, 39], [4, 41], [4, 42], [4, 43], [4, 44], [4, 47], [4, 51], [4, 53], [4, 57], [4, 58], [4, 60], [4, 62], [4, 63], [4, 66], [4, 72], [4, 74], [4, 76], [4, 78], [4, 81], [4, 83], [4, 85], [4, 87], [4, 88], [4, 89], [4, 90], [4, 92], [4, 93], [4, 96], [4, 99], [5, 8], [5, 9], [5, 10], [5, 12], [5, 14], [5, 21], [5, 22], [5, 23], [5, 24], [5, 26], [5, 30], [5, 31], [5, 34], [5, 36], [5, 40], [5, 43], [5, 46], [5, 55], [5, 56], [5, 57], [5, 59], [5, 60], [5, 62], [5, 65], [5, 66], [5, 69], [5, 70], [5, 71], [5, 73], [5, 74], [5, 75], [5, 78], [5, 81], [5, 82], [5, 83], [5, 84], [5, 86], [5, 89], [5, 91], [5, 96], [5, 97], [6, 7], [6, 8], [6, 9], [6, 10], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 19], [6, 20], [6, 21], [6, 22], [6, 25], [6, 26], [6, 28], [6, 29], [6, 32], [6, 36], [6, 37], [6, 38], [6, 39], [6, 40], [6, 41], [6, 45], [6, 47], [6, 49], [6, 50], [6, 52], [6, 53], [6, 56], [6, 57], [6, 58], [6, 62], [6, 63], [6, 66], [6, 68], [6, 70], [6, 71], [6, 74], [6, 76], [6, 77], [6, 81], [6, 83], [6, 84], [6, 86], [6, 87], [6, 88], [6, 91], [6, 92], [6, 93], [6, 94], [6, 95], [6, 99], [7, 8], [7, 9], [7, 10], [7, 14], [7, 15], [7, 16], [7, 17], [7, 22], [7, 23], [7, 24], [7, 25], [7, 29], [7, 31], [7, 33], [7, 34], [7, 36], [7, 38], [7, 42], [7, 45], [7, 46], [7, 49], [7, 51], [7, 53], [7, 57], [7, 58], [7, 60], [7, 61], [7, 62], [7, 68], [7, 69], [7, 71], [7, 72], [7, 73], [7, 74], [7, 75], [7, 76], [7, 78], [7, 82], [7, 83], [7, 86], [7, 87], [7, 91], [7, 92], [7, 93], [7, 94], [7, 97], [7, 98], [7, 99], [8, 10], [8, 12], [8, 16], [8, 20], [8, 21], [8, 22], [8, 24], [8, 27], [8, 29], [8, 33], [8, 34], [8, 35], [8, 38], [8, 40], [8, 41], [8, 46], [8, 47], [8, 49], [8, 50], [8, 51], [8, 53], [8, 54], [8, 62], [8, 64], [8, 65], [8, 66], [8, 67], [8, 72], [8, 73], [8, 75], [8, 78], [8, 79], [8, 80], [8, 81], [8, 86], [8, 87], [8, 89], [8, 97], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 18], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 27], [9, 30], [9, 32], [9, 33], [9, 35], [9, 36], [9, 37], [9, 38], [9, 41], [9, 45], [9, 46], [9, 47], [9, 50], [9, 52], [9, 54], [9, 55], [9, 58], [9, 59], [9, 60], [9, 61], [9, 62], [9, 63], [9, 65], [9, 67], [9, 68], [9, 70], [9, 72], [9, 73], [9, 74], [9, 78], [9, 79], [9, 81], [9, 83], [9, 97], [10, 12], [10, 14], [10, 21], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 30], [10, 33], [10, 34], [10, 36], [10, 37], [10, 38], [10, 39], [10, 42], [10, 43], [10, 44], [10, 45], [10, 49], [10, 51], [10, 52], [10, 53], [10, 56], [10, 58], [10, 59], [10, 63], [10, 69], [10, 70], [10, 72], [10, 73], [10, 75], [10, 76], [10, 77], [10, 80], [10, 81], [10, 83], [10, 87], [10, 88], [10, 89], [10, 93], [10, 94], [10, 95], [10, 97], [10, 99], [11, 14], [11, 18], [11, 20], [11, 21], [11, 22], [11, 25], [11, 26], [11, 27], [11, 30], [11, 34], [11, 35], [11, 36], [11, 37], [11, 39], [11, 42], [11, 47], [11, 50], [11, 53], [11, 54], [11, 55], [11, 56], [11, 57], [11, 60], [11, 61], [11, 62], [11, 64], [11, 66], [11, 69], [11, 75], [11, 76], [11, 77], [11, 78], [11, 79], [11, 82], [11, 86], [11, 87], [11, 88], [11, 92], [11, 93], [11, 95], [11, 96], [11, 97], [11, 98], [12, 13], [12, 14], [12, 16], [12, 17], [12, 19], [12, 21], [12, 22], [12, 25], [12, 26], [12, 27], [12, 28], [12, 33], [12, 34], [12, 36], [12, 37], [12, 38], [12, 41], [12, 42], [12, 43], [12, 45], [12, 46], [12, 48], [12, 49], [12, 50], [12, 51], [12, 57], [12, 59], [12, 66], [12, 69], [12, 70], [12, 71], [12, 72], [12, 74], [12, 77], [12, 78], [12, 79], [12, 80], [12, 81], [12, 84], [12, 86], [12, 88], [12, 89], [12, 92], [12, 93], [12, 95], [12, 98], [12, 99], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [13, 19], [13, 21], [13, 23], [13, 24], [13, 25], [13, 26], [13, 27], [13, 28], [13, 29], [13, 30], [13, 31], [13, 36], [13, 37], [13, 38], [13, 41], [13, 43], [13, 46], [13, 47], [13, 49], [13, 50], [13, 53], [13, 56], [13, 57], [13, 58], [13, 61], [13, 63], [13, 64], [13, 66], [13, 67], [13, 69], [13, 71], [13, 72], [13, 73], [13, 74], [13, 76], [13, 77], [13, 78], [13, 79], [13, 80], [13, 86], [13, 87], [13, 88], [13, 89], [13, 91], [13, 92], [13, 93], [13, 94], [13, 96], [13, 97], [14, 15], [14, 16], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [14, 36], [14, 37], [14, 39], [14, 40], [14, 42], [14, 43], [14, 45], [14, 47], [14, 49], [14, 50], [14, 51], [14, 52], [14, 55], [14, 58], [14, 59], [14, 61], [14, 63], [14, 64], [14, 65], [14, 66], [14, 67], [14, 68], [14, 69], [14, 71], [14, 72], [14, 77], [14, 79], [14, 81], [14, 83], [14, 86], [14, 87], [14, 88], [14, 90], [14, 91], [14, 92], [14, 93], [14, 95], [14, 96], [14, 98], [15, 17], [15, 18], [15, 19], [15, 22], [15, 23], [15, 24], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 32], [15, 34], [15, 36], [15, 37], [15, 38], [15, 39], [15, 40], [15, 43], [15, 50], [15, 52], [15, 55], [15, 58], [15, 62], [15, 63], [15, 64], [15, 68], [15, 70], [15, 71], [15, 72], [15, 74], [15, 75], [15, 76], [15, 78], [15, 79], [15, 81], [15, 82], [15, 83], [15, 84], [15, 87], [15, 92], [15, 94], [15, 95], [15, 97], [15, 98], [15, 99], [16, 19], [16, 21], [16, 23], [16, 24], [16, 25], [16, 27], [16, 28], [16, 29], [16, 31], [16, 35], [16, 36], [16, 37], [16, 38], [16, 39], [16, 41], [16, 42], [16, 45], [16, 46], [16, 47], [16, 49], [16, 50], [16, 54], [16, 58], [16, 60], [16, 61], [16, 62], [16, 64], [16, 66], [16, 71], [16, 72], [16, 73], [16, 79], [16, 80], [16, 83], [16, 86], [16, 87], [16, 89], [16, 90], [16, 92], [16, 93], [16, 94], [16, 95], [16, 97], [16, 98], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 26], [17, 27], [17, 29], [17, 30], [17, 34], [17, 35], [17, 36], [17, 44], [17, 47], [17, 48], [17, 50], [17, 51], [17, 52], [17, 54], [17, 55], [17, 56], [17, 58], [17, 60], [17, 61], [17, 63], [17, 65], [17, 69], [17, 75], [17, 76], [17, 78], [17, 79], [17, 81], [17, 82], [17, 83], [17, 84], [17, 85], [17, 89], [17, 92], [17, 95], [17, 96], [17, 98], [17, 99], [18, 19], [18, 21], [18, 23], [18, 24], [18, 25], [18, 27], [18, 29], [18, 30], [18, 31], [18, 35], [18, 36], [18, 37], [18, 38], [18, 39], [18, 40], [18, 41], [18, 42], [18, 44], [18, 45], [18, 46], [18, 49], [18, 51], [18, 53], [18, 54], [18, 55], [18, 57], [18, 61], [18, 63], [18, 64], [18, 65], [18, 66], [18, 70], [18, 73], [18, 75], [18, 81], [18, 88], [18, 89], [18, 90], [18, 91], [18, 92], [18, 95], [18, 96], [18, 97], [18, 98], [18, 99], [19, 21], [19, 25], [19, 26], [19, 28], [19, 30], [19, 31], [19, 32], [19, 36], [19, 37], [19, 38], [19, 39], [19, 40], [19, 42], [19, 44], [19, 47], [19, 49], [19, 50], [19, 56], [19, 57], [19, 58], [19, 59], [19, 63], [19, 64], [19, 66], [19, 67], [19, 69], [19, 70], [19, 71], [19, 78], [19, 82], [19, 85], [19, 86], [19, 87], [19, 88], [19, 90], [19, 91], [19, 92], [19, 93], [19, 96], [19, 97], [19, 98], [19, 99], [20, 21], [20, 22], [20, 24], [20, 26], [20, 27], [20, 28], [20, 31], [20, 32], [20, 33], [20, 34], [20, 36], [20, 37], [20, 38], [20, 42], [20, 46], [20, 48], [20, 49], [20, 50], [20, 51], [20, 53], [20, 56], [20, 58], [20, 63], [20, 66], [20, 70], [20, 72], [20, 74], [20, 75], [20, 76], [20, 78], [20, 79], [20, 82], [20, 83], [20, 84], [20, 85], [20, 86], [20, 87], [20, 88], [20, 90], [20, 91], [20, 95], [20, 96], [20, 97], [20, 99], [21, 24], [21, 25], [21, 27], [21, 28], [21, 30], [21, 32], [21, 33], [21, 34], [21, 35], [21, 36], [21, 37], [21, 38], [21, 39], [21, 43], [21, 46], [21, 49], [21, 50], [21, 51], [21, 59], [21, 61], [21, 62], [21, 65], [21, 66], [21, 69], [21, 70], [21, 71], [21, 73], [21, 74], [21, 78], [21, 80], [21, 81], [21, 82], [21, 84], [21, 85], [21, 86], [21, 90], [21, 92], [21, 93], [21, 94], [21, 97], [22, 23], [22, 24], [22, 28], [22, 30], [22, 31], [22, 33], [22, 37], [22, 38], [22, 40], [22, 42], [22, 47], [22, 49], [22, 51], [22, 52], [22, 54], [22, 55], [22, 60], [22, 62], [22, 63], [22, 64], [22, 65], [22, 66], [22, 68], [22, 69], [22, 71], [22, 72], [22, 73], [22, 74], [22, 76], [22, 79], [22, 82], [22, 84], [22, 88], [22, 89], [22, 91], [23, 25], [23, 26], [23, 28], [23, 29], [23, 31], [23, 32], [23, 33], [23, 34], [23, 36], [23, 37], [23, 38], [23, 40], [23, 41], [23, 42], [23, 44], [23, 46], [23, 49], [23, 51], [23, 52], [23, 54], [23, 56], [23, 57], [23, 58], [23, 59], [23, 61], [23, 64], [23, 67], [23, 68], [23, 69], [23, 71], [23, 72], [23, 73], [23, 75], [23, 78], [23, 81], [23, 82], [23, 84], [23, 87], [23, 88], [23, 89], [23, 90], [23, 92], [23, 93], [23, 96], [24, 26], [24, 27], [24, 28], [24, 34], [24, 35], [24, 37], [24, 38], [24, 40], [24, 41], [24, 45], [24, 46], [24, 47], [24, 49], [24, 51], [24, 53], [24, 54], [24, 56], [24, 61], [24, 62], [24, 63], [24, 66], [24, 68], [24, 69], [24, 70], [24, 72], [24, 76], [24, 77], [24, 81], [24, 82], [24, 84], [24, 87], [24, 90], [24, 95], [24, 96], [24, 98], [25, 28], [25, 29], [25, 30], [25, 33], [25, 34], [25, 36], [25, 37], [25, 40], [25, 42], [25, 44], [25, 48], [25, 49], [25, 50], [25, 52], [25, 55], [25, 57], [25, 60], [25, 61], [25, 62], [25, 65], [25, 66], [25, 68], [25, 69], [25, 71], [25, 72], [25, 73], [25, 74], [25, 76], [25, 77], [25, 79], [25, 81], [25, 82], [25, 86], [25, 87], [25, 92], [25, 94], [25, 98], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 37], [26, 39], [26, 40], [26, 41], [26, 44], [26, 45], [26, 46], [26, 48], [26, 49], [26, 52], [26, 53], [26, 57], [26, 58], [26, 59], [26, 60], [26, 61], [26, 63], [26, 66], [26, 67], [26, 68], [26, 70], [26, 71], [26, 72], [26, 73], [26, 74], [26, 76], [26, 77], [26, 78], [26, 80], [26, 82], [26, 83], [26, 84], [26, 85], [26, 86], [26, 87], [26, 92], [26, 94], [27, 31], [27, 32], [27, 36], [27, 37], [27, 38], [27, 41], [27, 43], [27, 46], [27, 51], [27, 54], [27, 55], [27, 58], [27, 63], [27, 64], [27, 67], [27, 68], [27, 69], [27, 72], [27, 79], [27, 80], [27, 82], [27, 83], [27, 86], [27, 88], [27, 89], [27, 91], [27, 95], [27, 97], [27, 99], [28, 29], [28, 30], [28, 31], [28, 35], [28, 36], [28, 37], [28, 39], [28, 40], [28, 42], [28, 43], [28, 45], [28, 47], [28, 48], [28, 49], [28, 50], [28, 51], [28, 52], [28, 54], [28, 55], [28, 56], [28, 57], [28, 60], [28, 63], [28, 64], [28, 65], [28, 66], [28, 67], [28, 69], [28, 71], [28, 72], [28, 74], [28, 75], [28, 76], [28, 78], [28, 82], [28, 84], [28, 86], [28, 89], [28, 91], [28, 92], [28, 93], [28, 97], [28, 98], [29, 30], [29, 31], [29, 33], [29, 34], [29, 39], [29, 40], [29, 41], [29, 43], [29, 45], [29, 48], [29, 49], [29, 50], [29, 52], [29, 53], [29, 56], [29, 59], [29, 62], [29, 63], [29, 66], [29, 72], [29, 76], [29, 77], [29, 82], [29, 83], [29, 84], [29, 85], [29, 86], [29, 87], [29, 88], [29, 89], [29, 92], [29, 93], [29, 94], [29, 97], [29, 99], [30, 32], [30, 36], [30, 38], [30, 39], [30, 42], [30, 44], [30, 45], [30, 49], [30, 51], [30, 53], [30, 54], [30, 56], [30, 59], [30, 60], [30, 62], [30, 64], [30, 65], [30, 67], [30, 68], [30, 72], [30, 73], [30, 74], [30, 76], [30, 77], [30, 79], [30, 80], [30, 81], [30, 82], [30, 83], [30, 84], [30, 85], [30, 86], [30, 88], [30, 93], [30, 96], [30, 98], [31, 34], [31, 36], [31, 38], [31, 39], [31, 45], [31, 46], [31, 48], [31, 49], [31, 50], [31, 51], [31, 52], [31, 57], [31, 66], [31, 69], [31, 70], [31, 74], [31, 79], [31, 84], [31, 86], [31, 87], [31, 95], [31, 99], [32, 33], [32, 35], [32, 36], [32, 38], [32, 40], [32, 41], [32, 42], [32, 43], [32, 45], [32, 46], [32, 47], [32, 48], [32, 50], [32, 51], [32, 52], [32, 57], [32, 60], [32, 61], [32, 64], [32, 65], [32, 67], [32, 70], [32, 71], [32, 73], [32, 75], [32, 79], [32, 80], [32, 82], [32, 83], [32, 84], [32, 89], [32, 91], [32, 92], [32, 93], [32, 94], [32, 95], [32, 96], [32, 98], [33, 39], [33, 41], [33, 43], [33, 44], [33, 45], [33, 47], [33, 48], [33, 49], [33, 51], [33, 54], [33, 56], [33, 58], [33, 59], [33, 60], [33, 64], [33, 65], [33, 68], [33, 76], [33, 77], [33, 78], [33, 79], [33, 82], [33, 83], [33, 85], [33, 88], [33, 91], [33, 94], [33, 95], [33, 96], [33, 99], [34, 36], [34, 37], [34, 39], [34, 40], [34, 42], [34, 43], [34, 44], [34, 45], [34, 46], [34, 48], [34, 49], [34, 53], [34, 55], [34, 56], [34, 57], [34, 58], [34, 59], [34, 61], [34, 62], [34, 63], [34, 69], [34, 72], [34, 74], [34, 75], [34, 77], [34, 78], [34, 80], [34, 81], [34, 83], [34, 85], [34, 86], [34, 87], [34, 91], [34, 92], [34, 93], [34, 95], [35, 37], [35, 38], [35, 39], [35, 40], [35, 45], [35, 46], [35, 47], [35, 51], [35, 53], [35, 54], [35, 55], [35, 58], [35, 60], [35, 61], [35, 67], [35, 68], [35, 69], [35, 71], [35, 72], [35, 73], [35, 75], [35, 77], [35, 79], [35, 80], [35, 81], [35, 82], [35, 86], [35, 89], [35, 92], [35, 93], [35, 94], [35, 95], [35, 96], [35, 97], [36, 37], [36, 43], [36, 44], [36, 46], [36, 49], [36, 50], [36, 51], [36, 53], [36, 54], [36, 55], [36, 57], [36, 58], [36, 59], [36, 63], [36, 65], [36, 66], [36, 68], [36, 71], [36, 72], [36, 76], [36, 77], [36, 79], [36, 80], [36, 81], [36, 82], [36, 85], [36, 86], [36, 87], [36, 89], [36, 91], [36, 92], [36, 93], [36, 95], [36, 96], [36, 97], [36, 98], [37, 41], [37, 44], [37, 48], [37, 49], [37, 50], [37, 54], [37, 56], [37, 57], [37, 59], [37, 61], [37, 63], [37, 65], [37, 66], [37, 67], [37, 68], [37, 70], [37, 71], [37, 72], [37, 73], [37, 74], [37, 75], [37, 78], [37, 79], [37, 80], [37, 83], [37, 84], [37, 85], [37, 86], [37, 92], [37, 93], [37, 94], [37, 97], [38, 39], [38, 40], [38, 41], [38, 42], [38, 43], [38, 44], [38, 45], [38, 46], [38, 49], [38, 50], [38, 51], [38, 52], [38, 53], [38, 55], [38, 56], [38, 57], [38, 60], [38, 63], [38, 66], [38, 67], [38, 76], [38, 78], [38, 79], [38, 81], [38, 82], [38, 86], [38, 88], [38, 93], [38, 96], [38, 98], [38, 99], [39, 43], [39, 49], [39, 56], [39, 61], [39, 63], [39, 64], [39, 65], [39, 66], [39, 67], [39, 69], [39, 70], [39, 72], [39, 73], [39, 76], [39, 78], [39, 79], [39, 86], [39, 89], [39, 90], [39, 93], [39, 94], [39, 96], [39, 98], [40, 41], [40, 42], [40, 43], [40, 44], [40, 45], [40, 46], [40, 47], [40, 49], [40, 50], [40, 51], [40, 52], [40, 53], [40, 54], [40, 55], [40, 57], [40, 59], [40, 61], [40, 65], [40, 66], [40, 69], [40, 70], [40, 74], [40, 75], [40, 79], [40, 80], [40, 81], [40, 83], [40, 86], [40, 87], [40, 88], [40, 90], [40, 92], [40, 93], [40, 96], [40, 97], [40, 98], [41, 42], [41, 43], [41, 44], [41, 45], [41, 46], [41, 47], [41, 49], [41, 52], [41, 54], [41, 58], [41, 60], [41, 61], [41, 63], [41, 64], [41, 72], [41, 73], [41, 74], [41, 75], [41, 76], [41, 77], [41, 79], [41, 80], [41, 82], [41, 84], [41, 87], [41, 90], [41, 91], [41, 94], [42, 43], [42, 48], [42, 49], [42, 50], [42, 54], [42, 55], [42, 56], [42, 57], [42, 59], [42, 62], [42, 63], [42, 65], [42, 68], [42, 70], [42, 72], [42, 73], [42, 74], [42, 75], [42, 76], [42, 79], [42, 86], [42, 92], [42, 93], [42, 96], [42, 99], [43, 44], [43, 45], [43, 47], [43, 48], [43, 49], [43, 53], [43, 58], [43, 59], [43, 60], [43, 63], [43, 64], [43, 65], [43, 67], [43, 69], [43, 70], [43, 72], [43, 73], [43, 74], [43, 75], [43, 76], [43, 77], [43, 82], [43, 86], [43, 87], [43, 88], [43, 89], [43, 90], [43, 91], [43, 95], [43, 96], [43, 99], [44, 45], [44, 46], [44, 48], [44, 49], [44, 50], [44, 51], [44, 54], [44, 55], [44, 56], [44, 58], [44, 59], [44, 60], [44, 61], [44, 62], [44, 64], [44, 65], [44, 68], [44, 70], [44, 73], [44, 74], [44, 75], [44, 76], [44, 77], [44, 79], [44, 82], [44, 84], [44, 88], [44, 90], [44, 91], [44, 92], [44, 93], [44, 94], [44, 96], [44, 97], [45, 47], [45, 49], [45, 50], [45, 53], [45, 54], [45, 57], [45, 58], [45, 60], [45, 61], [45, 62], [45, 63], [45, 67], [45, 68], [45, 69], [45, 70], [45, 76], [45, 77], [45, 78], [45, 80], [45, 85], [45, 86], [45, 87], [45, 88], [45, 89], [45, 90], [45, 92], [45, 95], [45, 97], [45, 99], [46, 47], [46, 48], [46, 50], [46, 54], [46, 56], [46, 57], [46, 59], [46, 60], [46, 62], [46, 63], [46, 64], [46, 65], [46, 66], [46, 67], [46, 68], [46, 76], [46, 77], [46, 78], [46, 79], [46, 80], [46, 81], [46, 82], [46, 84], [46, 85], [46, 86], [46, 87], [46, 88], [46, 89], [46, 90], [46, 92], [46, 94], [46, 96], [46, 98], [46, 99], [47, 48], [47, 49], [47, 51], [47, 53], [47, 55], [47, 59], [47, 60], [47, 62], [47, 63], [47, 64], [47, 71], [47, 76], [47, 77], [47, 78], [47, 81], [47, 83], [47, 84], [47, 85], [47, 86], [47, 87], [47, 90], [47, 91], [47, 93], [47, 94], [47, 96], [47, 97], [48, 49], [48, 50], [48, 51], [48, 53], [48, 57], [48, 58], [48, 59], [48, 61], [48, 62], [48, 64], [48, 65], [48, 68], [48, 69], [48, 72], [48, 73], [48, 75], [48, 81], [48, 82], [48, 84], [48, 86], [48, 88], [48, 91], [48, 93], [48, 96], [48, 98], [49, 50], [49, 53], [49, 54], [49, 56], [49, 60], [49, 63], [49, 66], [49, 68], [49, 69], [49, 71], [49, 73], [49, 74], [49, 75], [49, 76], [49, 78], [49, 79], [49, 85], [49, 86], [49, 87], [49, 88], [49, 91], [49, 92], [49, 95], [49, 96], [49, 97], [50, 52], [50, 57], [50, 60], [50, 61], [50, 63], [50, 64], [50, 66], [50, 68], [50, 71], [50, 73], [50, 74], [50, 77], [50, 78], [50, 79], [50, 81], [50, 82], [50, 83], [50, 85], [50, 86], [50, 87], [50, 88], [50, 90], [50, 91], [50, 92], [50, 94], [50, 95], [50, 96], [50, 98], [51, 53], [51, 54], [51, 55], [51, 58], [51, 59], [51, 60], [51, 61], [51, 64], [51, 66], [51, 71], [51, 72], [51, 73], [51, 76], [51, 79], [51, 80], [51, 81], [51, 82], [51, 83], [51, 85], [51, 86], [51, 87], [51, 88], [51, 92], [52, 53], [52, 56], [52, 58], [52, 59], [52, 60], [52, 61], [52, 62], [52, 65], [52, 68], [52, 71], [52, 72], [52, 73], [52, 74], [52, 75], [52, 76], [52, 78], [52, 79], [52, 82], [52, 84], [52, 85], [52, 86], [52, 87], [52, 88], [52, 91], [52, 93], [52, 94], [52, 97], [52, 99], [53, 54], [53, 58], [53, 59], [53, 60], [53, 61], [53, 62], [53, 64], [53, 65], [53, 66], [53, 67], [53, 68], [53, 73], [53, 78], [53, 80], [53, 81], [53, 84], [53, 87], [53, 88], [53, 91], [53, 92], [53, 95], [53, 98], [53, 99], [54, 55], [54, 59], [54, 60], [54, 61], [54, 62], [54, 63], [54, 64], [54, 65], [54, 69], [54, 71], [54, 72], [54, 73], [54, 76], [54, 77], [54, 78], [54, 83], [54, 87], [54, 88], [54, 95], [54, 96], [54, 98], [55, 56], [55, 58], [55, 59], [55, 60], [55, 62], [55, 63], [55, 64], [55, 70], [55, 82], [55, 83], [55, 87], [55, 89], [55, 92], [55, 93], [55, 94], [55, 95], [55, 98], [55, 99], [56, 60], [56, 62], [56, 64], [56, 67], [56, 72], [56, 73], [56, 74], [56, 75], [56, 77], [56, 79], [56, 81], [56, 82], [56, 84], [56, 86], [56, 89], [56, 94], [56, 97], [56, 99], [57, 59], [57, 60], [57, 61], [57, 62], [57, 64], [57, 65], [57, 66], [57, 68], [57, 69], [57, 74], [57, 75], [57, 80], [57, 81], [57, 83], [57, 84], [57, 91], [57, 92], [57, 93], [57, 95], [57, 97], [57, 99], [58, 59], [58, 60], [58, 61], [58, 63], [58, 66], [58, 68], [58, 70], [58, 71], [58, 72], [58, 74], [58, 75], [58, 79], [58, 81], [58, 82], [58, 83], [58, 84], [58, 86], [58, 88], [58, 90], [58, 92], [58, 93], [58, 94], [58, 95], [58, 96], [58, 97], [59, 60], [59, 62], [59, 63], [59, 64], [59, 66], [59, 68], [59, 71], [59, 72], [59, 73], [59, 74], [59, 78], [59, 79], [59, 81], [59, 82], [59, 84], [59, 89], [59, 90], [59, 91], [59, 93], [59, 95], [59, 96], [59, 99], [60, 61], [60, 62], [60, 63], [60, 64], [60, 65], [60, 66], [60, 68], [60, 71], [60, 72], [60, 74], [60, 76], [60, 80], [60, 81], [60, 83], [60, 84], [60, 85], [60, 90], [60, 91], [60, 92], [60, 94], [60, 96], [60, 98], [61, 62], [61, 63], [61, 64], [61, 65], [61, 66], [61, 69], [61, 70], [61, 73], [61, 74], [61, 78], [61, 79], [61, 80], [61, 83], [61, 85], [61, 87], [61, 88], [61, 90], [61, 93], [61, 94], [61, 96], [62, 63], [62, 64], [62, 67], [62, 68], [62, 69], [62, 72], [62, 73], [62, 75], [62, 76], [62, 78], [62, 79], [62, 80], [62, 81], [62, 82], [62, 83], [62, 86], [62, 87], [62, 88], [62, 89], [62, 90], [62, 91], [62, 94], [62, 95], [62, 96], [62, 98], [62, 99], [63, 64], [63, 65], [63, 69], [63, 71], [63, 72], [63, 74], [63, 77], [63, 78], [63, 79], [63, 80], [63, 81], [63, 84], [63, 89], [63, 90], [63, 91], [63, 93], [63, 98], [64, 67], [64, 68], [64, 71], [64, 72], [64, 73], [64, 75], [64, 79], [64, 81], [64, 82], [64, 83], [64, 92], [64, 95], [64, 96], [64, 98], [64, 99], [65, 66], [65, 68], [65, 71], [65, 72], [65, 73], [65, 76], [65, 77], [65, 81], [65, 87], [65, 88], [65, 90], [65, 97], [65, 98], [66, 70], [66, 71], [66, 72], [66, 73], [66, 76], [66, 77], [66, 78], [66, 85], [66, 86], [66, 87], [66, 89], [66, 92], [66, 93], [66, 95], [66, 96], [66, 97], [67, 70], [67, 71], [67, 72], [67, 73], [67, 75], [67, 76], [67, 77], [67, 79], [67, 82], [67, 84], [67, 85], [67, 89], [67, 90], [67, 91], [67, 93], [67, 94], [67, 96], [67, 97], [67, 98], [68, 70], [68, 71], [68, 72], [68, 76], [68, 78], [68, 79], [68, 80], [68, 81], [68, 82], [68, 83], [68, 85], [68, 86], [68, 87], [68, 90], [68, 91], [68, 92], [68, 94], [68, 95], [68, 96], [68, 97], [69, 70], [69, 71], [69, 74], [69, 75], [69, 79], [69, 80], [69, 81], [69, 84], [69, 87], [69, 88], [69, 89], [69, 91], [69, 93], [69, 94], [69, 97], [69, 99], [70, 71], [70, 74], [70, 76], [70, 77], [70, 78], [70, 80], [70, 82], [70, 83], [70, 84], [70, 85], [70, 87], [70, 90], [70, 93], [70, 94], [70, 96], [70, 97], [71, 72], [71, 73], [71, 74], [71, 75], [71, 76], [71, 77], [71, 78], [71, 79], [71, 82], [71, 83], [71, 84], [71, 86], [71, 87], [71, 88], [71, 89], [71, 90], [71, 91], [71, 92], [71, 93], [71, 95], [71, 99], [72, 73], [72, 74], [72, 75], [72, 76], [72, 77], [72, 80], [72, 81], [72, 82], [72, 83], [72, 84], [72, 86], [72, 88], [72, 89], [72, 94], [72, 96], [72, 98], [72, 99], [73, 74], [73, 76], [73, 79], [73, 80], [73, 81], [73, 82], [73, 84], [73, 86], [73, 92], [73, 94], [73, 96], [74, 75], [74, 76], [74, 78], [74, 79], [74, 80], [74, 81], [74, 82], [74, 83], [74, 85], [74, 86], [74, 88], [74, 89], [74, 90], [74, 92], [74, 93], [74, 95], [74, 99], [75, 78], [75, 79], [75, 83], [75, 84], [75, 85], [75, 87], [75, 88], [75, 92], [75, 93], [75, 94], [75, 98], [76, 77], [76, 78], [76, 79], [76, 80], [76, 83], [76, 85], [76, 87], [76, 88], [76, 93], [76, 97], [76, 98], [77, 78], [77, 79], [77, 82], [77, 85], [77, 88], [77, 90], [77, 94], [77, 95], [77, 96], [77, 97], [77, 99], [78, 79], [78, 80], [78, 81], [78, 90], [78, 92], [78, 93], [78, 95], [78, 96], [78, 97], [79, 80], [79, 81], [79, 82], [79, 84], [79, 85], [79, 88], [79, 93], [79, 97], [79, 98], [80, 82], [80, 83], [80, 86], [80, 88], [80, 90], [80, 91], [80, 93], [80, 97], [80, 99], [81, 82], [81, 83], [81, 84], [81, 85], [81, 86], [81, 89], [81, 93], [81, 94], [81, 95], [81, 97], [81, 99], [82, 83], [82, 84], [82, 85], [82, 88], [82, 89], [82, 90], [82, 93], [82, 94], [82, 95], [82, 96], [82, 97], [82, 98], [82, 99], [83, 85], [83, 86], [83, 87], [83, 88], [83, 90], [83, 91], [83, 92], [83, 93], [83, 95], [83, 98], [83, 99], [84, 85], [84, 86], [84, 87], [84, 88], [84, 95], [84, 97], [85, 86], [85, 87], [85, 90], [85, 91], [85, 93], [85, 94], [85, 95], [85, 96], [85, 97], [86, 88], [86, 89], [86, 90], [86, 92], [86, 93], [86, 94], [86, 97], [86, 99], [87, 88], [87, 91], [87, 92], [87, 93], [87, 95], [87, 98], [87, 99], [88, 89], [88, 90], [88, 91], [88, 94], [88, 97], [88, 98], [88, 99], [89, 92], [89, 94], [89, 95], [89, 97], [89, 98], [90, 91], [90, 93], [90, 95], [90, 96], [90, 98], [90, 99], [91, 92], [91, 93], [91, 94], [91, 95], [91, 96], [91, 97], [91, 98], [92, 93], [92, 97], [92, 98], [93, 97], [93, 99], [94, 95], [94, 96], [94, 97], [94, 98], [94, 99], [95, 96], [95, 97], [95, 98], [96, 97], [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-s6/tests/run.py b/tasks/construct-nppc-clique-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-clique-l6-s6/tests/test.sh b/tasks/construct-nppc-clique-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-l6-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-dominating-set-l2-s0/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-dominating-set-l2-s0/environment/instance.json b/tasks/construct-nppc-dominating-set-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5dd3b7c38c6591040c8bfc63beb7a73ba95b43b0 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 3], [0, 5], [0, 6], [0, 11], [0, 15], [0, 17], [0, 19], [0, 21], [0, 23], [0, 26], [1, 12], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 22], [1, 23], [2, 3], [2, 6], [2, 7], [2, 9], [2, 15], [2, 16], [2, 25], [2, 26], [2, 28], [2, 29], [3, 7], [3, 12], [3, 17], [3, 20], [3, 22], [3, 23], [3, 29], [4, 5], [4, 6], [4, 8], [4, 9], [4, 10], [4, 11], [4, 16], [4, 18], [4, 20], [4, 22], [4, 23], [4, 24], [4, 25], [5, 20], [5, 25], [5, 26], [5, 28], [5, 29], [6, 9], [6, 11], [6, 13], [6, 14], [6, 16], [6, 20], [6, 21], [6, 24], [7, 8], [7, 13], [7, 17], [7, 18], [7, 21], [7, 24], [7, 28], [8, 11], [8, 13], [8, 14], [8, 18], [8, 20], [8, 21], [8, 22], [8, 23], [8, 25], [8, 28], [9, 11], [9, 12], [9, 13], [9, 16], [9, 22], [9, 23], [9, 24], [9, 25], [10, 13], [10, 15], [10, 17], [10, 26], [10, 29], [11, 12], [11, 14], [11, 21], [11, 23], [11, 28], [12, 13], [12, 14], [12, 15], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 26], [12, 28], [13, 22], [13, 24], [13, 27], [14, 15], [14, 18], [14, 24], [14, 26], [15, 16], [15, 19], [15, 22], [15, 23], [15, 27], [15, 29], [16, 19], [16, 27], [17, 21], [17, 23], [17, 28], [18, 19], [18, 21], [18, 22], [18, 24], [18, 25], [19, 23], [19, 24], [19, 26], [19, 29], [20, 23], [20, 27], [21, 24], [21, 26], [21, 29], [22, 23], [22, 28], [22, 29], [23, 24], [24, 27], [24, 28], [25, 27], [25, 28], [25, 29], [26, 28], [27, 28], [27, 29]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l2-s0/solution/solve.sh b/tasks/construct-nppc-dominating-set-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..05e58ed94ee93a28f8c35a6b91a5acef5f28b0fb --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [6, 7, 9, 11, 12, 13, 15, 16, 19, 20, 21, 23, 24, 25, 28]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l2-s0/tests/check.py b/tasks/construct-nppc-dominating-set-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s0/tests/check.py @@ -0,0 +1,23 @@ +"""Dominating set of size <= k. Accepts any valid dominating set.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier has no type/range checks (out-of-range labels and floats are silently used) + d = int_list(ans.get("dominating_set"), None, 0, n - 1, "dominating_set") + if len(set(d)) != len(d): + raise Invalid("dominating_set contains duplicates") + if not d or len(d) > k: + raise Invalid(f"dominating_set must have 1..{k} vertices, got {len(d)}") + dom = set(d) + s = set(d) + for u, v in inst["edges"]: + if u in s: + dom.add(v) + if v in s: + dom.add(u) + if len(dom) != n: + miss = min(set(range(n)) - dom) + raise Invalid(f"vertex {miss} is not dominated") + return None, {"size": len(d)} diff --git a/tasks/construct-nppc-dominating-set-l2-s0/tests/instance.json b/tasks/construct-nppc-dominating-set-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5dd3b7c38c6591040c8bfc63beb7a73ba95b43b0 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 3], [0, 5], [0, 6], [0, 11], [0, 15], [0, 17], [0, 19], [0, 21], [0, 23], [0, 26], [1, 12], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 22], [1, 23], [2, 3], [2, 6], [2, 7], [2, 9], [2, 15], [2, 16], [2, 25], [2, 26], [2, 28], [2, 29], [3, 7], [3, 12], [3, 17], [3, 20], [3, 22], [3, 23], [3, 29], [4, 5], [4, 6], [4, 8], [4, 9], [4, 10], [4, 11], [4, 16], [4, 18], [4, 20], [4, 22], [4, 23], [4, 24], [4, 25], [5, 20], [5, 25], [5, 26], [5, 28], [5, 29], [6, 9], [6, 11], [6, 13], [6, 14], [6, 16], [6, 20], [6, 21], [6, 24], [7, 8], [7, 13], [7, 17], [7, 18], [7, 21], [7, 24], [7, 28], [8, 11], [8, 13], [8, 14], [8, 18], [8, 20], [8, 21], [8, 22], [8, 23], [8, 25], [8, 28], [9, 11], [9, 12], [9, 13], [9, 16], [9, 22], [9, 23], [9, 24], [9, 25], [10, 13], [10, 15], [10, 17], [10, 26], [10, 29], [11, 12], [11, 14], [11, 21], [11, 23], [11, 28], [12, 13], [12, 14], [12, 15], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 26], [12, 28], [13, 22], [13, 24], [13, 27], [14, 15], [14, 18], [14, 24], [14, 26], [15, 16], [15, 19], [15, 22], [15, 23], [15, 27], [15, 29], [16, 19], [16, 27], [17, 21], [17, 23], [17, 28], [18, 19], [18, 21], [18, 22], [18, 24], [18, 25], [19, 23], [19, 24], [19, 26], [19, 29], [20, 23], [20, 27], [21, 24], [21, 26], [21, 29], [22, 23], [22, 28], [22, 29], [23, 24], [24, 27], [24, 28], [25, 27], [25, 28], [25, 29], [26, 28], [27, 28], [27, 29]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l2-s0/tests/run.py b/tasks/construct-nppc-dominating-set-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-dominating-set-l2-s0/tests/test.sh b/tasks/construct-nppc-dominating-set-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-dominating-set-l2-s7/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-dominating-set-l2-s7/environment/instance.json b/tasks/construct-nppc-dominating-set-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1032527a02f28dbd0d5f7e1e5302d7de5946cf8e --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 4], [0, 11], [0, 16], [0, 20], [0, 28], [1, 2], [1, 3], [1, 8], [1, 9], [1, 10], [1, 16], [1, 21], [1, 22], [2, 7], [2, 12], [2, 15], [2, 27], [3, 4], [3, 6], [3, 10], [3, 15], [3, 17], [3, 19], [3, 22], [4, 6], [4, 10], [4, 19], [4, 20], [4, 23], [4, 25], [4, 27], [4, 28], [4, 29], [5, 6], [5, 7], [5, 11], [5, 12], [5, 17], [5, 19], [5, 21], [5, 22], [5, 23], [5, 25], [5, 28], [6, 10], [6, 11], [6, 19], [6, 21], [6, 25], [6, 27], [6, 28], [7, 17], [7, 18], [7, 20], [7, 22], [7, 27], [7, 28], [7, 29], [8, 11], [8, 21], [8, 22], [8, 25], [8, 26], [8, 27], [8, 29], [9, 10], [9, 12], [9, 15], [9, 17], [9, 18], [9, 24], [9, 27], [9, 28], [10, 15], [11, 17], [11, 18], [11, 25], [11, 26], [11, 28], [12, 14], [12, 15], [12, 19], [12, 20], [12, 22], [12, 24], [12, 25], [12, 27], [12, 28], [13, 14], [13, 16], [13, 17], [13, 18], [13, 21], [13, 22], [13, 23], [13, 27], [13, 28], [14, 16], [14, 19], [14, 21], [14, 22], [14, 23], [14, 24], [15, 16], [15, 19], [15, 22], [15, 25], [15, 29], [16, 17], [16, 18], [16, 19], [16, 22], [16, 26], [17, 22], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [18, 21], [18, 25], [18, 29], [19, 21], [19, 28], [20, 21], [20, 25], [20, 29], [21, 23], [21, 24], [21, 26], [21, 29], [22, 23], [22, 24], [22, 25], [22, 26], [23, 24], [24, 25], [24, 29], [25, 27], [25, 29], [27, 28], [27, 29]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l2-s9/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-dominating-set-l2-s9/environment/instance.json b/tasks/construct-nppc-dominating-set-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..395e611647365b77cb457d2575480796961735da --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 2], [0, 10], [0, 16], [0, 21], [0, 22], [0, 23], [0, 28], [1, 2], [1, 3], [1, 4], [1, 5], [1, 7], [1, 10], [1, 11], [1, 12], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 26], [1, 27], [2, 4], [2, 7], [2, 10], [2, 11], [2, 17], [2, 18], [2, 24], [2, 25], [2, 29], [3, 5], [3, 7], [3, 9], [3, 10], [3, 11], [3, 12], [3, 14], [3, 15], [3, 16], [3, 25], [3, 28], [4, 7], [4, 10], [4, 12], [4, 15], [4, 22], [4, 25], [5, 6], [5, 9], [5, 13], [5, 17], [5, 18], [5, 23], [5, 24], [5, 26], [5, 29], [6, 12], [6, 13], [6, 15], [6, 16], [6, 20], [6, 21], [7, 8], [7, 9], [7, 10], [7, 11], [7, 17], [7, 19], [7, 21], [7, 22], [8, 11], [8, 18], [8, 20], [8, 21], [8, 22], [8, 25], [8, 27], [9, 16], [9, 17], [9, 29], [10, 11], [10, 17], [10, 18], [10, 24], [10, 26], [10, 27], [10, 29], [11, 12], [11, 14], [11, 18], [11, 19], [11, 23], [11, 25], [11, 26], [12, 22], [12, 23], [13, 28], [14, 15], [14, 19], [14, 21], [14, 26], [14, 29], [15, 16], [15, 17], [15, 18], [15, 21], [16, 20], [17, 23], [17, 24], [17, 26], [18, 19], [18, 20], [18, 22], [18, 23], [18, 27], [19, 20], [19, 21], [19, 26], [20, 21], [20, 28], [21, 24], [21, 26], [21, 27], [21, 28], [22, 24], [22, 26], [22, 27], [23, 28], [24, 27], [24, 28], [26, 27], [26, 28]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l2-s9/solution/solve.sh b/tasks/construct-nppc-dominating-set-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5224db672c573b935173325b418b768ae2e6c613 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [0, 1, 5, 7, 8, 10, 11, 15, 19, 20, 21, 22, 23, 24, 25]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l2-s9/tests/check.py b/tasks/construct-nppc-dominating-set-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s9/tests/check.py @@ -0,0 +1,23 @@ +"""Dominating set of size <= k. Accepts any valid dominating set.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier has no type/range checks (out-of-range labels and floats are silently used) + d = int_list(ans.get("dominating_set"), None, 0, n - 1, "dominating_set") + if len(set(d)) != len(d): + raise Invalid("dominating_set contains duplicates") + if not d or len(d) > k: + raise Invalid(f"dominating_set must have 1..{k} vertices, got {len(d)}") + dom = set(d) + s = set(d) + for u, v in inst["edges"]: + if u in s: + dom.add(v) + if v in s: + dom.add(u) + if len(dom) != n: + miss = min(set(range(n)) - dom) + raise Invalid(f"vertex {miss} is not dominated") + return None, {"size": len(d)} diff --git a/tasks/construct-nppc-dominating-set-l2-s9/tests/instance.json b/tasks/construct-nppc-dominating-set-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..395e611647365b77cb457d2575480796961735da --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 2], [0, 10], [0, 16], [0, 21], [0, 22], [0, 23], [0, 28], [1, 2], [1, 3], [1, 4], [1, 5], [1, 7], [1, 10], [1, 11], [1, 12], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 26], [1, 27], [2, 4], [2, 7], [2, 10], [2, 11], [2, 17], [2, 18], [2, 24], [2, 25], [2, 29], [3, 5], [3, 7], [3, 9], [3, 10], [3, 11], [3, 12], [3, 14], [3, 15], [3, 16], [3, 25], [3, 28], [4, 7], [4, 10], [4, 12], [4, 15], [4, 22], [4, 25], [5, 6], [5, 9], [5, 13], [5, 17], [5, 18], [5, 23], [5, 24], [5, 26], [5, 29], [6, 12], [6, 13], [6, 15], [6, 16], [6, 20], [6, 21], [7, 8], [7, 9], [7, 10], [7, 11], [7, 17], [7, 19], [7, 21], [7, 22], [8, 11], [8, 18], [8, 20], [8, 21], [8, 22], [8, 25], [8, 27], [9, 16], [9, 17], [9, 29], [10, 11], [10, 17], [10, 18], [10, 24], [10, 26], [10, 27], [10, 29], [11, 12], [11, 14], [11, 18], [11, 19], [11, 23], [11, 25], [11, 26], [12, 22], [12, 23], [13, 28], [14, 15], [14, 19], [14, 21], [14, 26], [14, 29], [15, 16], [15, 17], [15, 18], [15, 21], [16, 20], [17, 23], [17, 24], [17, 26], [18, 19], [18, 20], [18, 22], [18, 23], [18, 27], [19, 20], [19, 21], [19, 26], [20, 21], [20, 28], [21, 24], [21, 26], [21, 27], [21, 28], [22, 24], [22, 26], [22, 27], [23, 28], [24, 27], [24, 28], [26, 27], [26, 28]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l2-s9/tests/run.py b/tasks/construct-nppc-dominating-set-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-dominating-set-l2-s9/tests/test.sh b/tasks/construct-nppc-dominating-set-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-dominating-set-l6-s1/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-dominating-set-l6-s1/environment/instance.json b/tasks/construct-nppc-dominating-set-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..838b0cb40ae67a0058094f355409752995d80d5a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 300, "k": 20, "edges": [[0, 12], [0, 29], [0, 36], [0, 41], [0, 52], [0, 93], [0, 111], [0, 149], [0, 153], [0, 158], [0, 195], [0, 266], [0, 277], [0, 281], [1, 7], [1, 19], [1, 30], [1, 56], [1, 60], [1, 69], [1, 97], [1, 148], [1, 153], [1, 172], [1, 181], [1, 231], [1, 240], [1, 259], [1, 269], [1, 271], [1, 275], [1, 278], [2, 17], [2, 31], [2, 33], [2, 76], [2, 83], [2, 90], [2, 110], [2, 132], [2, 135], [2, 138], [2, 159], [2, 160], [2, 177], [2, 189], [2, 199], [2, 210], [2, 212], [2, 225], [2, 226], [2, 230], [2, 231], [2, 244], [2, 272], [2, 294], [3, 11], [3, 112], [3, 124], [3, 130], [3, 144], [3, 148], [3, 149], [3, 156], [3, 160], [3, 170], [3, 191], [3, 220], [3, 222], [3, 226], [3, 259], [3, 286], [3, 291], [3, 293], [4, 9], [4, 14], [4, 56], [4, 76], [4, 81], [4, 102], [4, 109], [4, 110], [4, 199], [4, 289], [4, 294], [5, 9], [5, 14], [5, 22], [5, 32], [5, 36], [5, 77], [5, 84], [5, 106], [5, 135], [5, 175], [5, 186], [5, 190], [5, 199], [5, 236], [5, 246], [5, 273], [5, 296], [5, 299], [6, 9], [6, 26], [6, 41], [6, 47], [6, 66], [6, 68], [6, 90], [6, 100], [6, 126], [6, 146], [6, 169], [6, 182], [6, 185], [6, 189], [6, 210], [6, 214], [6, 216], [6, 224], [6, 232], [6, 235], [6, 248], [6, 251], [6, 266], [6, 284], [7, 8], [7, 35], [7, 39], [7, 61], [7, 65], [7, 73], [7, 123], [7, 137], [7, 220], [7, 228], [7, 229], [7, 231], [7, 267], [7, 292], [8, 13], [8, 15], [8, 38], [8, 47], [8, 48], [8, 56], [8, 68], [8, 79], [8, 106], [8, 140], [8, 171], [8, 183], [8, 220], [8, 223], [8, 249], [8, 251], [8, 255], [8, 282], [8, 299], [9, 16], [9, 31], [9, 40], [9, 72], [9, 73], [9, 81], [9, 97], [9, 106], [9, 113], [9, 141], [9, 147], [9, 163], [9, 164], [9, 167], [9, 183], [9, 184], [9, 212], [9, 220], [9, 239], [9, 244], [9, 251], [9, 252], [9, 265], [9, 273], [10, 38], [10, 58], [10, 74], [10, 93], [10, 96], [10, 101], [10, 104], [10, 109], [10, 132], [10, 133], [10, 136], [10, 176], [10, 177], [10, 181], [10, 182], [10, 185], [10, 196], [10, 200], [10, 212], [10, 214], [10, 219], [10, 235], [10, 240], [10, 264], [10, 276], [11, 63], [11, 72], [11, 80], [11, 121], [11, 141], [11, 157], [11, 166], [11, 167], [11, 192], [11, 206], [11, 230], [11, 255], [11, 256], [11, 263], [11, 276], [11, 293], [12, 18], [12, 26], [12, 48], [12, 65], [12, 84], [12, 125], [12, 141], [12, 144], [12, 170], [12, 177], [12, 186], [12, 193], [12, 195], [12, 206], [12, 210], [12, 211], [12, 259], [12, 270], [12, 280], [12, 287], [12, 299], [13, 35], [13, 38], [13, 39], [13, 65], [13, 68], [13, 78], [13, 115], [13, 132], [13, 151], [13, 171], [13, 187], [13, 204], [13, 239], [13, 246], [13, 268], [14, 45], [14, 48], [14, 67], [14, 78], [14, 84], [14, 111], [14, 114], [14, 122], [14, 153], [14, 193], [14, 236], [14, 258], [14, 261], [14, 272], [14, 287], [15, 16], [15, 25], [15, 28], [15, 33], [15, 40], [15, 56], [15, 98], [15, 112], [15, 123], [15, 128], [15, 141], [15, 160], [15, 163], [15, 204], [15, 226], [15, 229], [15, 252], [15, 257], [15, 266], [15, 268], [15, 270], [15, 290], [16, 50], [16, 51], [16, 57], [16, 64], [16, 68], [16, 70], [16, 72], [16, 92], [16, 108], [16, 111], [16, 112], [16, 128], [16, 133], [16, 136], [16, 140], [16, 149], [16, 169], [16, 184], [16, 203], [16, 234], [16, 241], [16, 246], [16, 252], [16, 256], [16, 260], [16, 268], [16, 270], [16, 273], [16, 287], [16, 290], [17, 58], [17, 71], [17, 72], [17, 93], [17, 100], [17, 126], [17, 149], [17, 153], [17, 193], [17, 228], [17, 253], [17, 274], [17, 296], [18, 29], [18, 31], [18, 42], [18, 43], [18, 68], [18, 85], [18, 104], [18, 107], [18, 111], [18, 127], [18, 130], [18, 132], [18, 139], [18, 181], [18, 202], [18, 206], [18, 207], [18, 221], [18, 226], [18, 234], [18, 251], [19, 22], [19, 37], [19, 54], [19, 55], [19, 88], [19, 102], [19, 144], [19, 173], [19, 183], [19, 246], [19, 254], [19, 276], [20, 21], [20, 37], [20, 38], [20, 66], [20, 70], [20, 80], [20, 94], [20, 114], [20, 135], [20, 146], [20, 156], [20, 169], [20, 185], [20, 198], [20, 233], [20, 239], [20, 244], [20, 265], [20, 285], [21, 45], [21, 68], [21, 120], [21, 128], [21, 129], [21, 132], [21, 134], [21, 164], [21, 175], [21, 178], [21, 183], [21, 188], [21, 196], [21, 197], [21, 209], [21, 211], [21, 238], [21, 249], [21, 267], [21, 276], [21, 284], [21, 286], [22, 33], [22, 67], [22, 89], [22, 132], [22, 134], [22, 135], [22, 137], [22, 150], [22, 169], [22, 178], [22, 196], [22, 200], [22, 218], [22, 232], [22, 234], [22, 256], [22, 261], [22, 269], [22, 275], [23, 83], [23, 134], [23, 141], [23, 146], [23, 149], [23, 159], [23, 167], [23, 184], [23, 209], [23, 216], [23, 228], [23, 237], [23, 241], [23, 242], [23, 270], [23, 278], [23, 294], [24, 26], [24, 51], [24, 52], [24, 53], [24, 101], [24, 118], [24, 149], [24, 150], [24, 156], [24, 177], [24, 179], [24, 188], [24, 193], [24, 210], [24, 214], [24, 228], [24, 239], [24, 247], [24, 259], [24, 262], [24, 295], [25, 27], [25, 42], [25, 61], [25, 65], [25, 70], [25, 75], [25, 89], [25, 97], [25, 111], [25, 119], [25, 124], [25, 151], [25, 153], [25, 165], [25, 166], [25, 171], [25, 181], [25, 188], [25, 201], [25, 204], [25, 207], [25, 210], [25, 213], [25, 236], [25, 245], [25, 246], [25, 267], [25, 281], [25, 282], [25, 292], [25, 296], [26, 31], [26, 38], [26, 48], [26, 52], [26, 53], [26, 67], [26, 86], [26, 88], [26, 90], [26, 131], [26, 138], [26, 157], [26, 191], [26, 192], [26, 203], [26, 204], [26, 208], [26, 217], [26, 228], [26, 258], [26, 271], [26, 290], [27, 34], [27, 35], [27, 60], [27, 61], [27, 65], [27, 70], [27, 71], [27, 92], [27, 98], [27, 105], [27, 107], [27, 108], [27, 110], [27, 125], [27, 147], [27, 148], [27, 173], [27, 186], [27, 215], [27, 228], [27, 234], [27, 236], [27, 261], [28, 35], [28, 54], [28, 59], [28, 79], [28, 109], [28, 121], [28, 158], [28, 166], [28, 174], [28, 175], [28, 190], [28, 212], [28, 234], [29, 37], [29, 50], [29, 88], [29, 89], [29, 91], [29, 102], [29, 105], [29, 112], [29, 119], [29, 121], [29, 151], [29, 191], [29, 194], [29, 226], [29, 228], [29, 243], [29, 244], [29, 249], [29, 258], [29, 276], [30, 32], [30, 35], [30, 36], [30, 37], [30, 41], [30, 60], [30, 69], [30, 81], [30, 84], [30, 121], [30, 141], [30, 152], [30, 153], [30, 165], [30, 190], [30, 194], [30, 202], [30, 203], [30, 215], [30, 222], [30, 223], [30, 224], [30, 237], [30, 239], [30, 248], [30, 254], [30, 259], [30, 266], [30, 268], [30, 278], [31, 39], [31, 57], [31, 77], [31, 81], [31, 108], [31, 119], [31, 136], [31, 152], [31, 168], [31, 179], [31, 200], [31, 217], [31, 243], [31, 262], [31, 280], [32, 37], [32, 60], [32, 95], [32, 97], [32, 116], [32, 120], [32, 133], [32, 138], [32, 139], [32, 149], [32, 156], [32, 169], [32, 176], [32, 191], [32, 194], [32, 195], [32, 213], [33, 40], [33, 68], [33, 77], [33, 78], [33, 81], [33, 142], [33, 148], [33, 154], [33, 159], [33, 162], [33, 169], [33, 170], [33, 192], [33, 194], [33, 203], [33, 219], [33, 224], [33, 242], [33, 251], [33, 256], [33, 293], [33, 295], [34, 54], [34, 68], [34, 115], [34, 126], [34, 162], [34, 180], [34, 189], [34, 191], [34, 210], [34, 228], [34, 235], [34, 241], [34, 248], [34, 272], [34, 277], [34, 283], [35, 44], [35, 64], [35, 72], [35, 85], [35, 96], [35, 131], [35, 161], [35, 166], [35, 171], [35, 175], [35, 197], [35, 200], [35, 210], [35, 259], [35, 269], [35, 270], [35, 283], [35, 286], [36, 40], [36, 41], [36, 45], [36, 53], [36, 85], [36, 86], [36, 88], [36, 108], [36, 109], [36, 116], [36, 125], [36, 135], [36, 166], [36, 167], [36, 172], [36, 174], [36, 180], [36, 187], [36, 211], [36, 232], [36, 249], [36, 253], [36, 256], [36, 258], [36, 260], [36, 261], [36, 267], [36, 275], [36, 285], [37, 52], [37, 55], [37, 58], [37, 61], [37, 71], [37, 73], [37, 76], [37, 89], [37, 90], [37, 98], [37, 102], [37, 103], [37, 108], [37, 112], [37, 165], [37, 188], [37, 197], [37, 225], [37, 289], [38, 59], [38, 73], [38, 81], [38, 85], [38, 89], [38, 94], [38, 100], [38, 127], [38, 169], [38, 188], [38, 253], [38, 256], [38, 264], [38, 293], [39, 40], [39, 56], [39, 66], [39, 76], [39, 99], [39, 112], [39, 125], [39, 128], [39, 143], [39, 156], [39, 170], [39, 224], [39, 249], [39, 292], [40, 41], [40, 70], [40, 112], [40, 118], [40, 141], [40, 147], [40, 155], [40, 171], [40, 188], [40, 198], [40, 206], [40, 231], [40, 267], [40, 298], [41, 55], [41, 64], [41, 68], [41, 87], [41, 103], [41, 120], [41, 146], [41, 149], [41, 211], [41, 230], [41, 257], [41, 277], [41, 287], [42, 63], [42, 94], [42, 97], [42, 100], [42, 109], [42, 115], [42, 128], [42, 183], [42, 196], [42, 207], [42, 219], [42, 239], [42, 252], [42, 254], [42, 258], [42, 275], [42, 277], [43, 59], [43, 77], [43, 81], [43, 116], [43, 117], [43, 118], [43, 137], [43, 188], [43, 203], [43, 233], [43, 248], [43, 253], [43, 275], [43, 278], [43, 294], [44, 45], [44, 51], [44, 67], [44, 74], [44, 102], [44, 108], [44, 116], [44, 132], [44, 169], [44, 174], [44, 175], [44, 182], [44, 190], [44, 207], [44, 212], [44, 233], [44, 248], [44, 249], [44, 274], [44, 285], [45, 59], [45, 61], [45, 98], [45, 99], [45, 156], [45, 159], [45, 171], [45, 182], [45, 184], [45, 199], [45, 211], [45, 215], [45, 223], [45, 225], [45, 228], [45, 257], [45, 263], [45, 264], [45, 292], [45, 293], [46, 50], [46, 51], [46, 64], [46, 67], [46, 68], [46, 73], [46, 75], [46, 79], [46, 132], [46, 134], [46, 144], [46, 183], [46, 185], [46, 223], [46, 280], [46, 289], [46, 292], [46, 296], [47, 90], [47, 94], [47, 109], [47, 141], [47, 151], [47, 172], [47, 193], [47, 199], [47, 200], [47, 216], [47, 294], [48, 87], [48, 98], [48, 99], [48, 111], [48, 123], [48, 145], [48, 175], [48, 193], [48, 224], [48, 268], [48, 278], [49, 52], [49, 95], [49, 127], [49, 185], [49, 190], [49, 193], [49, 202], [49, 203], [49, 223], [49, 271], [49, 276], [49, 278], [49, 290], [49, 292], [50, 55], [50, 59], [50, 69], [50, 72], [50, 82], [50, 84], [50, 92], [50, 95], [50, 108], [50, 117], [50, 124], [50, 140], [50, 155], [50, 175], [50, 201], [50, 263], [50, 267], [51, 68], [51, 77], [51, 78], [51, 99], [51, 102], [51, 107], [51, 132], [51, 149], [51, 160], [51, 172], [51, 182], [51, 217], [51, 224], [51, 229], [51, 247], [51, 250], [51, 255], [51, 295], [52, 66], [52, 74], [52, 97], [52, 104], [52, 136], [52, 156], [52, 175], [52, 183], [52, 192], [52, 193], [52, 214], [52, 223], [52, 237], [52, 263], [52, 269], [52, 272], [52, 273], [52, 276], [52, 293], [53, 62], [53, 87], [53, 108], [53, 118], [53, 120], [53, 173], [53, 175], [53, 189], [53, 231], [53, 273], [54, 70], [54, 73], [54, 74], [54, 134], [54, 135], [54, 147], [54, 148], [54, 156], [54, 158], [54, 167], [54, 168], [54, 171], [54, 181], [54, 192], [54, 199], [54, 208], [54, 229], [54, 235], [54, 248], [54, 250], [54, 253], [54, 257], [55, 108], [55, 110], [55, 141], [55, 244], [55, 270], [55, 280], [56, 63], [56, 66], [56, 78], [56, 93], [56, 100], [56, 111], [56, 112], [56, 120], [56, 168], [56, 173], [56, 178], [56, 187], [56, 191], [56, 213], [56, 231], [56, 236], [56, 251], [56, 252], [56, 255], [56, 256], [56, 258], [56, 262], [56, 268], [56, 269], [56, 279], [56, 281], [56, 290], [56, 296], [57, 73], [57, 100], [57, 105], [57, 114], [57, 158], [57, 169], [57, 171], [57, 212], [57, 232], [57, 244], [57, 246], [57, 249], [57, 251], [57, 256], [58, 62], [58, 66], [58, 76], [58, 84], [58, 93], [58, 141], [58, 145], [58, 150], [58, 189], [58, 192], [58, 196], [58, 213], [58, 241], [58, 244], [58, 284], [58, 293], [58, 294], [58, 295], [59, 77], [59, 81], [59, 98], [59, 107], [59, 155], [59, 163], [59, 177], [59, 179], [59, 189], [59, 212], [59, 224], [59, 238], [59, 239], [59, 251], [59, 270], [59, 291], [60, 64], [60, 92], [60, 116], [60, 135], [60, 176], [60, 196], [60, 202], [60, 203], [60, 214], [60, 216], [60, 231], [60, 278], [61, 64], [61, 89], [61, 97], [61, 104], [61, 109], [61, 116], [61, 134], [61, 143], [61, 147], [61, 153], [61, 172], [61, 195], [61, 200], [61, 227], [61, 249], [61, 252], [61, 258], [61, 294], [62, 76], [62, 87], [62, 92], [62, 96], [62, 103], [62, 128], [62, 137], [62, 158], [62, 190], [62, 198], [62, 199], [62, 205], [62, 213], [62, 221], [62, 237], [62, 246], [62, 252], [63, 66], [63, 67], [63, 122], [63, 134], [63, 150], [63, 178], [63, 233], [63, 278], [63, 281], [63, 282], [63, 285], [64, 84], [64, 96], [64, 102], [64, 107], [64, 121], [64, 147], [64, 149], [64, 151], [64, 164], [64, 192], [64, 199], [64, 240], [64, 255], [64, 286], [64, 289], [64, 291], [64, 295], [65, 67], [65, 164], [65, 168], [65, 175], [65, 197], [65, 204], [65, 261], [66, 68], [66, 71], [66, 134], [66, 140], [66, 174], [66, 185], [66, 214], [66, 232], [66, 261], [66, 262], [66, 280], [67, 69], [67, 98], [67, 103], [67, 131], [67, 150], [67, 172], [67, 175], [67, 194], [67, 210], [67, 254], [67, 290], [67, 299], [68, 69], [68, 72], [68, 73], [68, 79], [68, 83], [68, 86], [68, 113], [68, 130], [68, 142], [68, 143], [68, 154], [68, 164], [68, 166], [68, 172], [68, 173], [68, 197], [68, 222], [68, 223], [68, 225], [68, 247], [68, 252], [68, 273], [68, 276], [68, 279], [68, 283], [68, 297], [68, 299], [69, 79], [69, 85], [69, 92], [69, 93], [69, 94], [69, 106], [69, 113], [69, 121], [69, 179], [69, 189], [69, 212], [69, 220], [69, 240], [69, 259], [69, 297], [70, 77], [70, 84], [70, 93], [70, 95], [70, 111], [70, 125], [70, 146], [70, 220], [70, 221], [70, 246], [70, 254], [70, 262], [70, 274], [71, 101], [71, 111], [71, 130], [71, 141], [71, 183], [71, 192], [71, 205], [71, 217], [71, 234], [71, 240], [71, 248], [71, 252], [71, 266], [72, 90], [72, 92], [72, 94], [72, 124], [72, 129], [72, 161], [72, 199], [72, 200], [72, 213], [72, 271], [72, 279], [72, 288], [73, 83], [73, 95], [73, 102], [73, 113], [73, 120], [73, 134], [73, 162], [73, 166], [73, 193], [73, 199], [73, 222], [73, 240], [74, 90], [74, 134], [74, 153], [74, 174], [74, 191], [74, 223], [74, 258], [74, 282], [74, 287], [75, 131], [75, 140], [75, 155], [75, 168], [75, 170], [75, 174], [75, 190], [75, 195], [75, 214], [75, 216], [75, 279], [76, 87], [76, 104], [76, 123], [76, 141], [76, 157], [76, 188], [76, 193], [76, 203], [76, 207], [76, 223], [76, 247], [76, 250], [76, 258], [77, 100], [77, 102], [77, 104], [77, 106], [77, 146], [77, 148], [77, 149], [77, 164], [77, 171], [77, 173], [77, 176], [77, 178], [77, 184], [77, 191], [77, 206], [77, 264], [77, 273], [77, 279], [78, 92], [78, 106], [78, 119], [78, 159], [78, 168], [78, 187], [78, 190], [78, 192], [78, 199], [78, 228], [78, 259], [78, 289], [78, 297], [79, 98], [79, 167], [79, 194], [79, 207], [79, 224], [79, 225], [79, 234], [79, 258], [79, 277], [79, 279], [80, 88], [80, 98], [80, 127], [80, 135], [80, 168], [80, 203], [80, 207], [80, 226], [80, 269], [81, 87], [81, 111], [81, 114], [81, 117], [81, 127], [81, 144], [81, 168], [81, 183], [81, 190], [81, 193], [81, 209], [81, 222], [81, 230], [81, 237], [81, 238], [81, 239], [81, 248], [81, 249], [81, 251], [81, 272], [81, 280], [81, 286], [82, 88], [82, 91], [82, 103], [82, 106], [82, 125], [82, 127], [82, 132], [82, 141], [82, 143], [82, 177], [82, 221], [82, 234], [82, 285], [83, 85], [83, 89], [83, 102], [83, 150], [83, 167], [83, 175], [83, 179], [83, 195], [83, 223], [83, 225], [83, 244], [83, 250], [83, 264], [83, 275], [84, 88], [84, 102], [84, 108], [84, 131], [84, 165], [84, 216], [84, 224], [84, 252], [85, 143], [85, 183], [85, 191], [85, 202], [85, 215], [85, 229], [85, 260], [85, 265], [85, 286], [85, 293], [86, 103], [86, 150], [86, 179], [86, 195], [86, 196], [86, 221], [86, 248], [86, 260], [86, 261], [86, 262], [86, 264], [86, 293], [86, 294], [87, 92], [87, 108], [87, 128], [87, 174], [87, 188], [87, 215], [87, 221], [87, 223], [87, 248], [87, 258], [87, 269], [87, 275], [87, 278], [87, 288], [88, 92], [88, 93], [88, 96], [88, 109], [88, 151], [88, 175], [88, 227], [88, 250], [88, 299], [89, 108], [89, 132], [89, 154], [89, 155], [89, 166], [89, 183], [89, 189], [89, 195], [89, 204], [89, 205], [89, 206], [89, 226], [89, 254], [89, 260], [89, 273], [90, 143], [90, 154], [90, 155], [90, 159], [90, 181], [90, 193], [90, 198], [90, 207], [90, 215], [90, 233], [90, 243], [90, 253], [91, 102], [91, 135], [91, 139], [91, 142], [91, 157], [91, 177], [91, 194], [91, 197], [91, 214], [91, 225], [91, 247], [91, 260], [91, 284], [91, 289], [91, 299], [92, 142], [92, 146], [92, 149], [92, 151], [92, 179], [92, 189], [92, 213], [92, 242], [92, 269], [92, 273], [92, 281], [93, 121], [93, 154], [93, 170], [93, 178], [93, 219], [93, 228], [93, 234], [93, 265], [94, 99], [94, 103], [94, 133], [94, 144], [94, 150], [94, 155], [94, 178], [94, 213], [94, 220], [94, 221], [94, 242], [94, 246], [94, 269], [94, 274], [94, 282], [94, 299], [95, 101], [95, 117], [95, 119], [95, 120], [95, 138], [95, 144], [95, 146], [95, 152], [95, 157], [95, 176], [95, 204], [95, 206], [95, 208], [95, 231], [95, 249], [95, 251], [95, 269], [95, 286], [95, 298], [96, 120], [96, 124], [96, 135], [96, 146], [96, 172], [96, 174], [96, 180], [96, 181], [96, 189], [96, 201], [96, 209], [96, 221], [96, 278], [96, 285], [96, 292], [97, 138], [97, 153], [97, 166], [97, 191], [97, 237], [97, 241], [97, 244], [97, 249], [97, 258], [97, 264], [98, 109], [98, 114], [98, 115], [98, 130], [98, 136], [98, 138], [98, 147], [98, 167], [98, 170], [98, 179], [98, 198], [98, 204], [98, 216], [98, 229], [98, 235], [98, 237], [98, 250], [98, 261], [98, 266], [98, 274], [98, 282], [98, 295], [99, 112], [99, 119], [99, 127], [99, 132], [99, 139], [99, 169], [99, 170], [99, 194], [99, 235], [99, 269], [99, 278], [99, 280], [100, 102], [100, 109], [100, 129], [100, 130], [100, 155], [100, 200], [100, 218], [100, 220], [100, 238], [100, 256], [100, 290], [101, 102], [101, 108], [101, 123], [101, 130], [101, 132], [101, 138], [101, 158], [101, 162], [101, 190], [101, 216], [101, 222], [101, 256], [101, 298], [102, 129], [102, 148], [102, 163], [102, 172], [102, 180], [102, 184], [102, 194], [102, 218], [102, 229], [102, 230], [102, 238], [102, 270], [102, 280], [102, 286], [102, 290], [103, 114], [103, 118], [103, 120], [103, 139], [103, 149], [103, 156], [103, 162], [103, 201], [103, 241], [103, 266], [103, 271], [104, 115], [104, 116], [104, 137], [104, 158], [104, 171], [104, 186], [104, 199], [104, 211], [104, 228], [104, 245], [104, 266], [104, 270], [105, 124], [105, 138], [105, 158], [105, 159], [105, 204], [105, 213], [105, 267], [105, 268], [105, 269], [105, 277], [106, 122], [106, 133], [106, 163], [106, 168], [106, 173], [106, 176], [106, 178], [106, 182], [106, 201], [106, 212], [106, 217], [106, 220], [106, 221], [106, 230], [106, 233], [106, 247], [106, 257], [106, 271], [106, 279], [106, 293], [106, 298], [107, 114], [107, 116], [107, 130], [107, 139], [107, 155], [107, 189], [107, 191], [107, 206], [107, 228], [107, 248], [107, 272], [107, 273], [107, 278], [108, 122], [108, 134], [108, 136], [108, 137], [108, 155], [108, 170], [108, 190], [108, 201], [108, 207], [108, 227], [108, 243], [108, 247], [108, 284], [108, 287], [108, 294], [108, 295], [109, 172], [109, 202], [109, 207], [109, 213], [109, 241], [109, 258], [109, 277], [110, 114], [110, 125], [110, 150], [110, 165], [110, 171], [110, 174], [110, 179], [110, 187], [110, 195], [110, 205], [110, 207], [110, 220], [110, 249], [110, 272], [110, 273], [110, 275], [110, 293], [111, 119], [111, 161], [111, 172], [111, 183], [111, 186], [111, 187], [111, 206], [111, 209], [111, 210], [111, 236], [111, 262], [111, 268], [111, 276], [111, 277], [111, 294], [111, 297], [112, 135], [112, 136], [112, 152], [112, 165], [112, 195], [112, 196], [112, 204], [112, 205], [112, 223], [112, 245], [112, 258], [112, 272], [112, 293], [113, 166], [113, 198], [113, 214], [113, 219], [113, 232], [113, 262], [113, 276], [114, 149], [114, 173], [114, 190], [114, 220], [114, 227], [114, 251], [114, 263], [114, 282], [114, 287], [114, 294], [114, 298], [115, 121], [115, 128], [115, 151], [115, 164], [115, 172], [115, 188], [115, 209], [115, 242], [115, 253], [115, 266], [115, 291], [115, 293], [116, 120], [116, 124], [116, 129], [116, 131], [116, 132], [116, 185], [116, 190], [116, 196], [116, 224], [116, 228], [116, 236], [116, 238], [116, 240], [116, 241], [116, 264], [116, 266], [116, 271], [116, 275], [116, 297], [117, 136], [117, 147], [117, 154], [117, 223], [117, 251], [117, 293], [118, 127], [118, 139], [118, 143], [118, 159], [118, 172], [118, 178], [118, 187], [118, 193], [118, 231], [118, 248], [118, 255], [118, 270], [118, 292], [119, 122], [119, 125], [119, 134], [119, 145], [119, 167], [119, 177], [119, 283], [119, 297], [119, 299], [120, 139], [120, 176], [120, 186], [120, 207], [120, 210], [120, 211], [120, 212], [120, 216], [120, 229], [120, 235], [120, 249], [120, 281], [121, 146], [121, 152], [121, 164], [121, 168], [121, 171], [121, 174], [121, 199], [121, 205], [121, 247], [121, 257], [121, 276], [121, 281], [121, 286], [121, 293], [121, 294], [122, 149], [122, 156], [122, 209], [122, 217], [122, 226], [122, 255], [122, 261], [123, 126], [123, 128], [123, 156], [123, 163], [123, 166], [123, 183], [123, 192], [123, 195], [123, 215], [123, 223], [123, 238], [123, 248], [123, 249], [123, 263], [123, 269], [123, 272], [124, 179], [124, 199], [124, 201], [124, 209], [124, 214], [124, 216], [124, 225], [124, 229], [124, 236], [124, 276], [124, 284], [125, 129], [125, 148], [125, 153], [125, 173], [125, 187], [125, 191], [125, 193], [125, 199], [125, 214], [125, 238], [125, 288], [126, 139], [126, 141], [126, 154], [126, 156], [126, 173], [126, 175], [126, 187], [126, 201], [126, 213], [126, 223], [126, 231], [126, 253], [126, 261], [126, 265], [126, 291], [126, 296], [127, 128], [127, 131], [127, 163], [127, 169], [127, 175], [127, 182], [127, 186], [127, 198], [127, 228], [127, 245], [127, 252], [127, 280], [128, 158], [128, 160], [128, 173], [128, 181], [128, 187], [128, 236], [128, 237], [128, 260], [128, 263], [128, 268], [129, 131], [129, 135], [129, 157], [129, 166], [129, 167], [129, 177], [129, 221], [129, 235], [129, 245], [129, 250], [129, 255], [129, 292], [130, 163], [130, 199], [130, 215], [130, 229], [130, 248], [130, 251], [130, 273], [131, 132], [131, 160], [131, 167], [131, 183], [131, 186], [131, 207], [131, 214], [131, 223], [131, 226], [131, 228], [131, 229], [131, 230], [131, 247], [131, 272], [131, 274], [131, 287], [131, 289], [132, 138], [132, 158], [132, 168], [132, 180], [132, 184], [132, 188], [132, 196], [132, 209], [132, 216], [132, 227], [132, 243], [132, 281], [132, 291], [133, 161], [133, 178], [133, 200], [133, 215], [133, 226], [133, 230], [133, 246], [133, 248], [133, 261], [133, 295], [133, 296], [134, 159], [134, 165], [134, 166], [134, 180], [134, 185], [134, 189], [134, 201], [134, 202], [134, 220], [134, 252], [134, 267], [134, 289], [134, 296], [135, 137], [135, 147], [135, 211], [135, 212], [135, 251], [135, 263], [135, 283], [135, 292], [135, 294], [136, 141], [136, 165], [136, 174], [136, 197], [136, 218], [136, 238], [136, 244], [136, 257], [136, 263], [136, 296], [137, 147], [137, 149], [137, 156], [137, 157], [137, 169], [137, 175], [137, 177], [137, 181], [137, 188], [137, 200], [137, 205], [137, 213], [137, 217], [137, 248], [137, 255], [137, 267], [137, 268], [137, 274], [137, 275], [138, 154], [138, 178], [138, 197], [138, 217], [138, 226], [138, 252], [138, 287], [138, 292], [139, 141], [139, 142], [139, 147], [139, 175], [139, 193], [139, 210], [139, 215], [139, 221], [139, 255], [139, 260], [139, 275], [139, 294], [139, 296], [140, 151], [140, 206], [140, 251], [140, 255], [140, 260], [140, 265], [140, 266], [140, 282], [141, 148], [141, 162], [141, 163], [141, 180], [141, 189], [141, 190], [141, 204], [141, 208], [141, 221], [141, 248], [141, 254], [141, 266], [141, 270], [141, 271], [141, 274], [141, 284], [141, 288], [142, 228], [142, 244], [142, 255], [142, 256], [142, 259], [142, 274], [142, 286], [142, 292], [142, 295], [143, 149], [143, 179], [143, 209], [143, 243], [143, 247], [143, 258], [143, 269], [143, 273], [143, 278], [143, 283], [144, 145], [144, 152], [144, 168], [144, 173], [144, 177], [144, 181], [144, 209], [144, 245], [144, 256], [144, 257], [144, 259], [144, 269], [144, 276], [145, 188], [145, 200], [145, 220], [145, 227], [145, 248], [145, 283], [145, 291], [145, 299], [146, 163], [146, 189], [146, 195], [146, 212], [146, 235], [146, 251], [146, 252], [146, 272], [146, 275], [146, 276], [146, 298], [147, 183], [147, 195], [147, 204], [147, 209], [147, 213], [147, 221], [147, 234], [147, 241], [147, 246], [147, 253], [147, 258], [147, 260], [147, 267], [147, 271], [147, 278], [147, 283], [148, 168], [148, 177], [148, 179], [148, 186], [148, 192], [148, 215], [148, 235], [148, 243], [148, 286], [148, 296], [149, 155], [149, 177], [149, 196], [149, 214], [149, 228], [149, 231], [149, 249], [149, 252], [149, 285], [150, 172], [150, 177], [150, 210], [150, 229], [150, 258], [150, 269], [150, 287], [151, 165], [151, 213], [151, 220], [151, 243], [151, 255], [151, 277], [152, 169], [152, 175], [152, 177], [152, 182], [152, 185], [152, 202], [152, 227], [152, 259], [152, 267], [152, 282], [152, 287], [153, 176], [153, 193], [153, 227], [153, 246], [153, 251], [153, 269], [154, 161], [154, 209], [154, 223], [154, 228], [154, 255], [154, 283], [155, 186], [155, 194], [155, 197], [155, 199], [155, 205], [155, 221], [155, 226], [155, 238], [155, 241], [155, 258], [155, 262], [155, 266], [155, 283], [155, 284], [156, 157], [156, 160], [156, 163], [156, 170], [156, 192], [156, 214], [156, 215], [156, 218], [156, 233], [156, 244], [156, 245], [156, 249], [156, 255], [156, 257], [156, 263], [156, 264], [156, 270], [157, 168], [157, 234], [157, 264], [157, 274], [157, 291], [157, 299], [158, 162], [158, 217], [158, 220], [158, 229], [158, 231], [158, 246], [158, 256], [159, 173], [159, 182], [159, 195], [159, 224], [159, 228], [159, 229], [159, 247], [159, 274], [159, 290], [160, 213], [160, 231], [160, 237], [160, 239], [160, 240], [160, 254], [160, 273], [160, 294], [161, 163], [161, 181], [161, 193], [161, 194], [161, 229], [161, 232], [161, 250], [161, 252], [161, 253], [162, 217], [162, 228], [162, 278], [162, 284], [162, 288], [162, 291], [162, 295], [163, 189], [163, 219], [163, 220], [163, 264], [163, 277], [163, 291], [164, 179], [164, 208], [164, 212], [164, 253], [164, 261], [164, 263], [164, 267], [164, 275], [164, 289], [164, 298], [165, 169], [165, 176], [165, 183], [165, 187], [165, 197], [165, 201], [165, 203], [165, 217], [165, 234], [165, 271], [165, 282], [165, 288], [165, 290], [166, 179], [166, 187], [166, 189], [166, 193], [166, 204], [166, 206], [166, 227], [166, 229], [166, 239], [166, 244], [166, 295], [167, 179], [167, 184], [167, 204], [167, 206], [167, 207], [167, 260], [168, 176], [168, 193], [168, 200], [168, 211], [168, 249], [168, 268], [168, 299], [169, 177], [169, 188], [169, 196], [169, 216], [169, 251], [169, 269], [170, 204], [170, 218], [170, 248], [170, 259], [170, 272], [170, 294], [171, 183], [171, 190], [171, 199], [171, 217], [171, 228], [171, 247], [171, 252], [171, 292], [172, 199], [172, 214], [172, 218], [172, 231], [172, 241], [172, 243], [172, 267], [172, 272], [173, 174], [173, 182], [173, 193], [173, 217], [173, 219], [173, 262], [173, 263], [173, 264], [173, 274], [173, 281], [173, 295], [173, 299], [174, 204], [174, 215], [174, 266], [174, 289], [174, 296], [175, 183], [175, 191], [175, 209], [175, 212], [175, 226], [175, 227], [175, 231], [175, 232], [175, 236], [175, 249], [175, 254], [175, 255], [175, 256], [175, 261], [175, 265], [175, 268], [175, 277], [175, 278], [175, 283], [175, 285], [175, 290], [175, 294], [175, 298], [176, 181], [176, 193], [176, 208], [176, 210], [176, 212], [176, 242], [176, 256], [176, 288], [176, 292], [177, 239], [177, 262], [177, 282], [178, 184], [178, 205], [178, 254], [178, 256], [178, 291], [178, 298], [179, 202], [179, 218], [179, 224], [179, 274], [179, 284], [179, 290], [180, 183], [180, 203], [180, 215], [180, 227], [180, 230], [180, 233], [180, 250], [180, 255], [180, 266], [180, 287], [181, 189], [181, 194], [181, 217], [181, 230], [181, 263], [181, 282], [181, 298], [182, 183], [182, 206], [182, 226], [182, 245], [182, 267], [182, 280], [182, 286], [183, 187], [183, 198], [183, 207], [183, 259], [183, 278], [184, 193], [184, 220], [184, 241], [184, 275], [184, 282], [185, 199], [185, 205], [185, 237], [185, 246], [185, 259], [185, 278], [185, 288], [186, 187], [186, 199], [186, 214], [186, 217], [186, 231], [186, 248], [186, 261], [186, 295], [186, 296], [187, 198], [187, 203], [187, 216], [187, 218], [187, 224], [187, 243], [187, 278], [188, 249], [188, 295], [189, 192], [189, 199], [189, 200], [189, 203], [189, 213], [189, 217], [189, 232], [189, 251], [189, 254], [189, 264], [189, 270], [189, 288], [190, 210], [190, 215], [190, 220], [190, 244], [190, 248], [190, 261], [190, 265], [190, 270], [191, 204], [191, 221], [191, 238], [191, 261], [192, 205], [192, 215], [192, 224], [192, 288], [193, 204], [193, 226], [193, 238], [193, 246], [193, 260], [193, 262], [193, 265], [193, 268], [193, 284], [193, 288], [194, 220], [194, 223], [194, 236], [194, 240], [194, 245], [194, 265], [194, 275], [194, 297], [195, 220], [195, 246], [195, 275], [195, 298], [196, 199], [196, 201], [196, 203], [196, 213], [196, 214], [196, 230], [196, 241], [196, 262], [196, 294], [196, 298], [197, 202], [197, 228], [197, 238], [197, 249], [197, 251], [197, 266], [197, 269], [197, 280], [198, 247], [198, 269], [198, 287], [198, 292], [199, 207], [199, 226], [199, 237], [199, 240], [199, 242], [199, 257], [199, 264], [199, 289], [199, 293], [200, 237], [200, 253], [200, 278], [201, 204], [201, 233], [201, 248], [201, 272], [201, 283], [201, 287], [202, 206], [202, 217], [202, 226], [202, 227], [202, 231], [202, 253], [202, 254], [202, 263], [202, 269], [202, 290], [202, 295], [203, 208], [203, 233], [203, 238], [203, 275], [204, 244], [204, 268], [204, 294], [205, 211], [205, 231], [205, 254], [205, 266], [205, 274], [205, 281], [206, 269], [206, 271], [207, 213], [207, 221], [207, 227], [207, 230], [207, 251], [207, 267], [207, 268], [207, 273], [208, 231], [208, 244], [208, 279], [208, 292], [209, 227], [209, 253], [209, 266], [209, 271], [209, 277], [210, 232], [210, 273], [211, 234], [211, 235], [211, 245], [211, 259], [211, 269], [211, 281], [211, 299], [212, 216], [212, 240], [212, 250], [212, 256], [212, 273], [213, 223], [213, 237], [213, 266], [213, 275], [214, 289], [214, 297], [215, 224], [215, 225], [215, 229], [215, 246], [215, 248], [215, 261], [215, 262], [215, 267], [215, 287], [216, 220], [216, 235], [216, 260], [216, 282], [216, 293], [217, 219], [217, 228], [217, 293], [218, 249], [218, 250], [218, 272], [219, 230], [219, 236], [219, 244], [219, 269], [219, 270], [220, 229], [220, 256], [220, 270], [220, 281], [220, 292], [221, 244], [221, 246], [221, 249], [221, 272], [221, 284], [222, 232], [222, 243], [222, 245], [222, 261], [222, 269], [222, 290], [222, 292], [222, 299], [223, 230], [223, 249], [223, 296], [224, 240], [224, 243], [224, 262], [224, 269], [224, 271], [225, 239], [225, 247], [225, 251], [225, 266], [225, 285], [225, 286], [225, 296], [226, 231], [226, 243], [226, 254], [226, 256], [226, 268], [226, 284], [227, 231], [227, 235], [228, 235], [228, 250], [228, 253], [228, 263], [228, 267], [228, 276], [228, 287], [228, 296], [229, 243], [229, 287], [230, 234], [230, 244], [230, 253], [230, 295], [231, 248], [231, 253], [231, 281], [231, 286], [231, 288], [232, 260], [232, 261], [232, 272], [233, 279], [233, 286], [234, 243], [234, 249], [234, 268], [234, 278], [234, 295], [235, 237], [235, 238], [235, 269], [235, 287], [236, 256], [236, 266], [236, 277], [236, 279], [236, 288], [237, 257], [237, 271], [237, 272], [238, 271], [238, 273], [239, 243], [239, 256], [239, 261], [239, 275], [239, 278], [239, 282], [239, 285], [240, 251], [240, 267], [240, 293], [241, 263], [241, 268], [241, 275], [241, 276], [241, 277], [241, 289], [242, 279], [242, 281], [243, 269], [244, 268], [244, 279], [244, 281], [244, 287], [245, 274], [245, 277], [245, 288], [245, 298], [246, 266], [246, 270], [246, 290], [247, 253], [247, 277], [247, 283], [247, 285], [248, 271], [248, 293], [249, 264], [249, 288], [250, 254], [250, 256], [250, 263], [250, 281], [250, 288], [250, 291], [251, 262], [251, 267], [251, 268], [251, 276], [252, 271], [252, 272], [252, 291], [253, 272], [253, 278], [254, 259], [254, 274], [254, 279], [254, 290], [255, 266], [256, 258], [256, 278], [256, 299], [257, 265], [257, 274], [257, 278], [257, 279], [258, 264], [258, 271], [258, 294], [259, 283], [260, 279], [260, 297], [262, 267], [262, 274], [262, 294], [263, 271], [264, 273], [264, 285], [266, 267], [266, 298], [267, 296], [268, 294], [269, 294], [270, 279], [271, 276], [271, 277], [271, 298], [272, 277], [272, 284], [273, 283], [273, 287], [273, 288], [273, 295], [274, 279], [274, 281], [274, 282], [275, 283], [275, 290], [275, 293], [275, 294], [276, 291], [277, 283], [278, 292], [280, 283], [282, 285], [284, 297], [284, 298], [285, 286], [285, 289], [286, 291], [288, 295], [294, 298], [294, 299]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l6-s1/solution/solve.sh b/tasks/construct-nppc-dominating-set-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f46547847a0d579130a3cdb70cc4739dd7f54d7a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [10, 16, 25, 30, 36, 56, 68, 81, 98, 102, 121, 132, 141, 156, 175, 193, 199, 220, 228, 269]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l6-s1/tests/check.py b/tasks/construct-nppc-dominating-set-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s1/tests/check.py @@ -0,0 +1,23 @@ +"""Dominating set of size <= k. Accepts any valid dominating set.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier has no type/range checks (out-of-range labels and floats are silently used) + d = int_list(ans.get("dominating_set"), None, 0, n - 1, "dominating_set") + if len(set(d)) != len(d): + raise Invalid("dominating_set contains duplicates") + if not d or len(d) > k: + raise Invalid(f"dominating_set must have 1..{k} vertices, got {len(d)}") + dom = set(d) + s = set(d) + for u, v in inst["edges"]: + if u in s: + dom.add(v) + if v in s: + dom.add(u) + if len(dom) != n: + miss = min(set(range(n)) - dom) + raise Invalid(f"vertex {miss} is not dominated") + return None, {"size": len(d)} diff --git a/tasks/construct-nppc-dominating-set-l6-s1/tests/instance.json b/tasks/construct-nppc-dominating-set-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..838b0cb40ae67a0058094f355409752995d80d5a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 300, "k": 20, "edges": [[0, 12], [0, 29], [0, 36], [0, 41], [0, 52], [0, 93], [0, 111], [0, 149], [0, 153], [0, 158], [0, 195], [0, 266], [0, 277], [0, 281], [1, 7], [1, 19], [1, 30], [1, 56], [1, 60], [1, 69], [1, 97], [1, 148], [1, 153], [1, 172], [1, 181], [1, 231], [1, 240], [1, 259], [1, 269], [1, 271], [1, 275], [1, 278], [2, 17], [2, 31], [2, 33], [2, 76], [2, 83], [2, 90], [2, 110], [2, 132], [2, 135], [2, 138], [2, 159], [2, 160], [2, 177], [2, 189], [2, 199], [2, 210], [2, 212], [2, 225], [2, 226], [2, 230], [2, 231], [2, 244], [2, 272], [2, 294], [3, 11], [3, 112], [3, 124], [3, 130], [3, 144], [3, 148], [3, 149], [3, 156], [3, 160], [3, 170], [3, 191], [3, 220], [3, 222], [3, 226], [3, 259], [3, 286], [3, 291], [3, 293], [4, 9], [4, 14], [4, 56], [4, 76], [4, 81], [4, 102], [4, 109], [4, 110], [4, 199], [4, 289], [4, 294], [5, 9], [5, 14], [5, 22], [5, 32], [5, 36], [5, 77], [5, 84], [5, 106], [5, 135], [5, 175], [5, 186], [5, 190], [5, 199], [5, 236], [5, 246], [5, 273], [5, 296], [5, 299], [6, 9], [6, 26], [6, 41], [6, 47], [6, 66], [6, 68], [6, 90], [6, 100], [6, 126], [6, 146], [6, 169], [6, 182], [6, 185], [6, 189], [6, 210], [6, 214], [6, 216], [6, 224], [6, 232], [6, 235], [6, 248], [6, 251], [6, 266], [6, 284], [7, 8], [7, 35], [7, 39], [7, 61], [7, 65], [7, 73], [7, 123], [7, 137], [7, 220], [7, 228], [7, 229], [7, 231], [7, 267], [7, 292], [8, 13], [8, 15], [8, 38], [8, 47], [8, 48], [8, 56], [8, 68], [8, 79], [8, 106], [8, 140], [8, 171], [8, 183], [8, 220], [8, 223], [8, 249], [8, 251], [8, 255], [8, 282], [8, 299], [9, 16], [9, 31], [9, 40], [9, 72], [9, 73], [9, 81], [9, 97], [9, 106], [9, 113], [9, 141], [9, 147], [9, 163], [9, 164], [9, 167], [9, 183], [9, 184], [9, 212], [9, 220], [9, 239], [9, 244], [9, 251], [9, 252], [9, 265], [9, 273], [10, 38], [10, 58], [10, 74], [10, 93], [10, 96], [10, 101], [10, 104], [10, 109], [10, 132], [10, 133], [10, 136], [10, 176], [10, 177], [10, 181], [10, 182], [10, 185], [10, 196], [10, 200], [10, 212], [10, 214], [10, 219], [10, 235], [10, 240], [10, 264], [10, 276], [11, 63], [11, 72], [11, 80], [11, 121], [11, 141], [11, 157], [11, 166], [11, 167], [11, 192], [11, 206], [11, 230], [11, 255], [11, 256], [11, 263], [11, 276], [11, 293], [12, 18], [12, 26], [12, 48], [12, 65], [12, 84], [12, 125], [12, 141], [12, 144], [12, 170], [12, 177], [12, 186], [12, 193], [12, 195], [12, 206], [12, 210], [12, 211], [12, 259], [12, 270], [12, 280], [12, 287], [12, 299], [13, 35], [13, 38], [13, 39], [13, 65], [13, 68], [13, 78], [13, 115], [13, 132], [13, 151], [13, 171], [13, 187], [13, 204], [13, 239], [13, 246], [13, 268], [14, 45], [14, 48], [14, 67], [14, 78], [14, 84], [14, 111], [14, 114], [14, 122], [14, 153], [14, 193], [14, 236], [14, 258], [14, 261], [14, 272], [14, 287], [15, 16], [15, 25], [15, 28], [15, 33], [15, 40], [15, 56], [15, 98], [15, 112], [15, 123], [15, 128], [15, 141], [15, 160], [15, 163], [15, 204], [15, 226], [15, 229], [15, 252], [15, 257], [15, 266], [15, 268], [15, 270], [15, 290], [16, 50], [16, 51], [16, 57], [16, 64], [16, 68], [16, 70], [16, 72], [16, 92], [16, 108], [16, 111], [16, 112], [16, 128], [16, 133], [16, 136], [16, 140], [16, 149], [16, 169], [16, 184], [16, 203], [16, 234], [16, 241], [16, 246], [16, 252], [16, 256], [16, 260], [16, 268], [16, 270], [16, 273], [16, 287], [16, 290], [17, 58], [17, 71], [17, 72], [17, 93], [17, 100], [17, 126], [17, 149], [17, 153], [17, 193], [17, 228], [17, 253], [17, 274], [17, 296], [18, 29], [18, 31], [18, 42], [18, 43], [18, 68], [18, 85], [18, 104], [18, 107], [18, 111], [18, 127], [18, 130], [18, 132], [18, 139], [18, 181], [18, 202], [18, 206], [18, 207], [18, 221], [18, 226], [18, 234], [18, 251], [19, 22], [19, 37], [19, 54], [19, 55], [19, 88], [19, 102], [19, 144], [19, 173], [19, 183], [19, 246], [19, 254], [19, 276], [20, 21], [20, 37], [20, 38], [20, 66], [20, 70], [20, 80], [20, 94], [20, 114], [20, 135], [20, 146], [20, 156], [20, 169], [20, 185], [20, 198], [20, 233], [20, 239], [20, 244], [20, 265], [20, 285], [21, 45], [21, 68], [21, 120], [21, 128], [21, 129], [21, 132], [21, 134], [21, 164], [21, 175], [21, 178], [21, 183], [21, 188], [21, 196], [21, 197], [21, 209], [21, 211], [21, 238], [21, 249], [21, 267], [21, 276], [21, 284], [21, 286], [22, 33], [22, 67], [22, 89], [22, 132], [22, 134], [22, 135], [22, 137], [22, 150], [22, 169], [22, 178], [22, 196], [22, 200], [22, 218], [22, 232], [22, 234], [22, 256], [22, 261], [22, 269], [22, 275], [23, 83], [23, 134], [23, 141], [23, 146], [23, 149], [23, 159], [23, 167], [23, 184], [23, 209], [23, 216], [23, 228], [23, 237], [23, 241], [23, 242], [23, 270], [23, 278], [23, 294], [24, 26], [24, 51], [24, 52], [24, 53], [24, 101], [24, 118], [24, 149], [24, 150], [24, 156], [24, 177], [24, 179], [24, 188], [24, 193], [24, 210], [24, 214], [24, 228], [24, 239], [24, 247], [24, 259], [24, 262], [24, 295], [25, 27], [25, 42], [25, 61], [25, 65], [25, 70], [25, 75], [25, 89], [25, 97], [25, 111], [25, 119], [25, 124], [25, 151], [25, 153], [25, 165], [25, 166], [25, 171], [25, 181], [25, 188], [25, 201], [25, 204], [25, 207], [25, 210], [25, 213], [25, 236], [25, 245], [25, 246], [25, 267], [25, 281], [25, 282], [25, 292], [25, 296], [26, 31], [26, 38], [26, 48], [26, 52], [26, 53], [26, 67], [26, 86], [26, 88], [26, 90], [26, 131], [26, 138], [26, 157], [26, 191], [26, 192], [26, 203], [26, 204], [26, 208], [26, 217], [26, 228], [26, 258], [26, 271], [26, 290], [27, 34], [27, 35], [27, 60], [27, 61], [27, 65], [27, 70], [27, 71], [27, 92], [27, 98], [27, 105], [27, 107], [27, 108], [27, 110], [27, 125], [27, 147], [27, 148], [27, 173], [27, 186], [27, 215], [27, 228], [27, 234], [27, 236], [27, 261], [28, 35], [28, 54], [28, 59], [28, 79], [28, 109], [28, 121], [28, 158], [28, 166], [28, 174], [28, 175], [28, 190], [28, 212], [28, 234], [29, 37], [29, 50], [29, 88], [29, 89], [29, 91], [29, 102], [29, 105], [29, 112], [29, 119], [29, 121], [29, 151], [29, 191], [29, 194], [29, 226], [29, 228], [29, 243], [29, 244], [29, 249], [29, 258], [29, 276], [30, 32], [30, 35], [30, 36], [30, 37], [30, 41], [30, 60], [30, 69], [30, 81], [30, 84], [30, 121], [30, 141], [30, 152], [30, 153], [30, 165], [30, 190], [30, 194], [30, 202], [30, 203], [30, 215], [30, 222], [30, 223], [30, 224], [30, 237], [30, 239], [30, 248], [30, 254], [30, 259], [30, 266], [30, 268], [30, 278], [31, 39], [31, 57], [31, 77], [31, 81], [31, 108], [31, 119], [31, 136], [31, 152], [31, 168], [31, 179], [31, 200], [31, 217], [31, 243], [31, 262], [31, 280], [32, 37], [32, 60], [32, 95], [32, 97], [32, 116], [32, 120], [32, 133], [32, 138], [32, 139], [32, 149], [32, 156], [32, 169], [32, 176], [32, 191], [32, 194], [32, 195], [32, 213], [33, 40], [33, 68], [33, 77], [33, 78], [33, 81], [33, 142], [33, 148], [33, 154], [33, 159], [33, 162], [33, 169], [33, 170], [33, 192], [33, 194], [33, 203], [33, 219], [33, 224], [33, 242], [33, 251], [33, 256], [33, 293], [33, 295], [34, 54], [34, 68], [34, 115], [34, 126], [34, 162], [34, 180], [34, 189], [34, 191], [34, 210], [34, 228], [34, 235], [34, 241], [34, 248], [34, 272], [34, 277], [34, 283], [35, 44], [35, 64], [35, 72], [35, 85], [35, 96], [35, 131], [35, 161], [35, 166], [35, 171], [35, 175], [35, 197], [35, 200], [35, 210], [35, 259], [35, 269], [35, 270], [35, 283], [35, 286], [36, 40], [36, 41], [36, 45], [36, 53], [36, 85], [36, 86], [36, 88], [36, 108], [36, 109], [36, 116], [36, 125], [36, 135], [36, 166], [36, 167], [36, 172], [36, 174], [36, 180], [36, 187], [36, 211], [36, 232], [36, 249], [36, 253], [36, 256], [36, 258], [36, 260], [36, 261], [36, 267], [36, 275], [36, 285], [37, 52], [37, 55], [37, 58], [37, 61], [37, 71], [37, 73], [37, 76], [37, 89], [37, 90], [37, 98], [37, 102], [37, 103], [37, 108], [37, 112], [37, 165], [37, 188], [37, 197], [37, 225], [37, 289], [38, 59], [38, 73], [38, 81], [38, 85], [38, 89], [38, 94], [38, 100], [38, 127], [38, 169], [38, 188], [38, 253], [38, 256], [38, 264], [38, 293], [39, 40], [39, 56], [39, 66], [39, 76], [39, 99], [39, 112], [39, 125], [39, 128], [39, 143], [39, 156], [39, 170], [39, 224], [39, 249], [39, 292], [40, 41], [40, 70], [40, 112], [40, 118], [40, 141], [40, 147], [40, 155], [40, 171], [40, 188], [40, 198], [40, 206], [40, 231], [40, 267], [40, 298], [41, 55], [41, 64], [41, 68], [41, 87], [41, 103], [41, 120], [41, 146], [41, 149], [41, 211], [41, 230], [41, 257], [41, 277], [41, 287], [42, 63], [42, 94], [42, 97], [42, 100], [42, 109], [42, 115], [42, 128], [42, 183], [42, 196], [42, 207], [42, 219], [42, 239], [42, 252], [42, 254], [42, 258], [42, 275], [42, 277], [43, 59], [43, 77], [43, 81], [43, 116], [43, 117], [43, 118], [43, 137], [43, 188], [43, 203], [43, 233], [43, 248], [43, 253], [43, 275], [43, 278], [43, 294], [44, 45], [44, 51], [44, 67], [44, 74], [44, 102], [44, 108], [44, 116], [44, 132], [44, 169], [44, 174], [44, 175], [44, 182], [44, 190], [44, 207], [44, 212], [44, 233], [44, 248], [44, 249], [44, 274], [44, 285], [45, 59], [45, 61], [45, 98], [45, 99], [45, 156], [45, 159], [45, 171], [45, 182], [45, 184], [45, 199], [45, 211], [45, 215], [45, 223], [45, 225], [45, 228], [45, 257], [45, 263], [45, 264], [45, 292], [45, 293], [46, 50], [46, 51], [46, 64], [46, 67], [46, 68], [46, 73], [46, 75], [46, 79], [46, 132], [46, 134], [46, 144], [46, 183], [46, 185], [46, 223], [46, 280], [46, 289], [46, 292], [46, 296], [47, 90], [47, 94], [47, 109], [47, 141], [47, 151], [47, 172], [47, 193], [47, 199], [47, 200], [47, 216], [47, 294], [48, 87], [48, 98], [48, 99], [48, 111], [48, 123], [48, 145], [48, 175], [48, 193], [48, 224], [48, 268], [48, 278], [49, 52], [49, 95], [49, 127], [49, 185], [49, 190], [49, 193], [49, 202], [49, 203], [49, 223], [49, 271], [49, 276], [49, 278], [49, 290], [49, 292], [50, 55], [50, 59], [50, 69], [50, 72], [50, 82], [50, 84], [50, 92], [50, 95], [50, 108], [50, 117], [50, 124], [50, 140], [50, 155], [50, 175], [50, 201], [50, 263], [50, 267], [51, 68], [51, 77], [51, 78], [51, 99], [51, 102], [51, 107], [51, 132], [51, 149], [51, 160], [51, 172], [51, 182], [51, 217], [51, 224], [51, 229], [51, 247], [51, 250], [51, 255], [51, 295], [52, 66], [52, 74], [52, 97], [52, 104], [52, 136], [52, 156], [52, 175], [52, 183], [52, 192], [52, 193], [52, 214], [52, 223], [52, 237], [52, 263], [52, 269], [52, 272], [52, 273], [52, 276], [52, 293], [53, 62], [53, 87], [53, 108], [53, 118], [53, 120], [53, 173], [53, 175], [53, 189], [53, 231], [53, 273], [54, 70], [54, 73], [54, 74], [54, 134], [54, 135], [54, 147], [54, 148], [54, 156], [54, 158], [54, 167], [54, 168], [54, 171], [54, 181], [54, 192], [54, 199], [54, 208], [54, 229], [54, 235], [54, 248], [54, 250], [54, 253], [54, 257], [55, 108], [55, 110], [55, 141], [55, 244], [55, 270], [55, 280], [56, 63], [56, 66], [56, 78], [56, 93], [56, 100], [56, 111], [56, 112], [56, 120], [56, 168], [56, 173], [56, 178], [56, 187], [56, 191], [56, 213], [56, 231], [56, 236], [56, 251], [56, 252], [56, 255], [56, 256], [56, 258], [56, 262], [56, 268], [56, 269], [56, 279], [56, 281], [56, 290], [56, 296], [57, 73], [57, 100], [57, 105], [57, 114], [57, 158], [57, 169], [57, 171], [57, 212], [57, 232], [57, 244], [57, 246], [57, 249], [57, 251], [57, 256], [58, 62], [58, 66], [58, 76], [58, 84], [58, 93], [58, 141], [58, 145], [58, 150], [58, 189], [58, 192], [58, 196], [58, 213], [58, 241], [58, 244], [58, 284], [58, 293], [58, 294], [58, 295], [59, 77], [59, 81], [59, 98], [59, 107], [59, 155], [59, 163], [59, 177], [59, 179], [59, 189], [59, 212], [59, 224], [59, 238], [59, 239], [59, 251], [59, 270], [59, 291], [60, 64], [60, 92], [60, 116], [60, 135], [60, 176], [60, 196], [60, 202], [60, 203], [60, 214], [60, 216], [60, 231], [60, 278], [61, 64], [61, 89], [61, 97], [61, 104], [61, 109], [61, 116], [61, 134], [61, 143], [61, 147], [61, 153], [61, 172], [61, 195], [61, 200], [61, 227], [61, 249], [61, 252], [61, 258], [61, 294], [62, 76], [62, 87], [62, 92], [62, 96], [62, 103], [62, 128], [62, 137], [62, 158], [62, 190], [62, 198], [62, 199], [62, 205], [62, 213], [62, 221], [62, 237], [62, 246], [62, 252], [63, 66], [63, 67], [63, 122], [63, 134], [63, 150], [63, 178], [63, 233], [63, 278], [63, 281], [63, 282], [63, 285], [64, 84], [64, 96], [64, 102], [64, 107], [64, 121], [64, 147], [64, 149], [64, 151], [64, 164], [64, 192], [64, 199], [64, 240], [64, 255], [64, 286], [64, 289], [64, 291], [64, 295], [65, 67], [65, 164], [65, 168], [65, 175], [65, 197], [65, 204], [65, 261], [66, 68], [66, 71], [66, 134], [66, 140], [66, 174], [66, 185], [66, 214], [66, 232], [66, 261], [66, 262], [66, 280], [67, 69], [67, 98], [67, 103], [67, 131], [67, 150], [67, 172], [67, 175], [67, 194], [67, 210], [67, 254], [67, 290], [67, 299], [68, 69], [68, 72], [68, 73], [68, 79], [68, 83], [68, 86], [68, 113], [68, 130], [68, 142], [68, 143], [68, 154], [68, 164], [68, 166], [68, 172], [68, 173], [68, 197], [68, 222], [68, 223], [68, 225], [68, 247], [68, 252], [68, 273], [68, 276], [68, 279], [68, 283], [68, 297], [68, 299], [69, 79], [69, 85], [69, 92], [69, 93], [69, 94], [69, 106], [69, 113], [69, 121], [69, 179], [69, 189], [69, 212], [69, 220], [69, 240], [69, 259], [69, 297], [70, 77], [70, 84], [70, 93], [70, 95], [70, 111], [70, 125], [70, 146], [70, 220], [70, 221], [70, 246], [70, 254], [70, 262], [70, 274], [71, 101], [71, 111], [71, 130], [71, 141], [71, 183], [71, 192], [71, 205], [71, 217], [71, 234], [71, 240], [71, 248], [71, 252], [71, 266], [72, 90], [72, 92], [72, 94], [72, 124], [72, 129], [72, 161], [72, 199], [72, 200], [72, 213], [72, 271], [72, 279], [72, 288], [73, 83], [73, 95], [73, 102], [73, 113], [73, 120], [73, 134], [73, 162], [73, 166], [73, 193], [73, 199], [73, 222], [73, 240], [74, 90], [74, 134], [74, 153], [74, 174], [74, 191], [74, 223], [74, 258], [74, 282], [74, 287], [75, 131], [75, 140], [75, 155], [75, 168], [75, 170], [75, 174], [75, 190], [75, 195], [75, 214], [75, 216], [75, 279], [76, 87], [76, 104], [76, 123], [76, 141], [76, 157], [76, 188], [76, 193], [76, 203], [76, 207], [76, 223], [76, 247], [76, 250], [76, 258], [77, 100], [77, 102], [77, 104], [77, 106], [77, 146], [77, 148], [77, 149], [77, 164], [77, 171], [77, 173], [77, 176], [77, 178], [77, 184], [77, 191], [77, 206], [77, 264], [77, 273], [77, 279], [78, 92], [78, 106], [78, 119], [78, 159], [78, 168], [78, 187], [78, 190], [78, 192], [78, 199], [78, 228], [78, 259], [78, 289], [78, 297], [79, 98], [79, 167], [79, 194], [79, 207], [79, 224], [79, 225], [79, 234], [79, 258], [79, 277], [79, 279], [80, 88], [80, 98], [80, 127], [80, 135], [80, 168], [80, 203], [80, 207], [80, 226], [80, 269], [81, 87], [81, 111], [81, 114], [81, 117], [81, 127], [81, 144], [81, 168], [81, 183], [81, 190], [81, 193], [81, 209], [81, 222], [81, 230], [81, 237], [81, 238], [81, 239], [81, 248], [81, 249], [81, 251], [81, 272], [81, 280], [81, 286], [82, 88], [82, 91], [82, 103], [82, 106], [82, 125], [82, 127], [82, 132], [82, 141], [82, 143], [82, 177], [82, 221], [82, 234], [82, 285], [83, 85], [83, 89], [83, 102], [83, 150], [83, 167], [83, 175], [83, 179], [83, 195], [83, 223], [83, 225], [83, 244], [83, 250], [83, 264], [83, 275], [84, 88], [84, 102], [84, 108], [84, 131], [84, 165], [84, 216], [84, 224], [84, 252], [85, 143], [85, 183], [85, 191], [85, 202], [85, 215], [85, 229], [85, 260], [85, 265], [85, 286], [85, 293], [86, 103], [86, 150], [86, 179], [86, 195], [86, 196], [86, 221], [86, 248], [86, 260], [86, 261], [86, 262], [86, 264], [86, 293], [86, 294], [87, 92], [87, 108], [87, 128], [87, 174], [87, 188], [87, 215], [87, 221], [87, 223], [87, 248], [87, 258], [87, 269], [87, 275], [87, 278], [87, 288], [88, 92], [88, 93], [88, 96], [88, 109], [88, 151], [88, 175], [88, 227], [88, 250], [88, 299], [89, 108], [89, 132], [89, 154], [89, 155], [89, 166], [89, 183], [89, 189], [89, 195], [89, 204], [89, 205], [89, 206], [89, 226], [89, 254], [89, 260], [89, 273], [90, 143], [90, 154], [90, 155], [90, 159], [90, 181], [90, 193], [90, 198], [90, 207], [90, 215], [90, 233], [90, 243], [90, 253], [91, 102], [91, 135], [91, 139], [91, 142], [91, 157], [91, 177], [91, 194], [91, 197], [91, 214], [91, 225], [91, 247], [91, 260], [91, 284], [91, 289], [91, 299], [92, 142], [92, 146], [92, 149], [92, 151], [92, 179], [92, 189], [92, 213], [92, 242], [92, 269], [92, 273], [92, 281], [93, 121], [93, 154], [93, 170], [93, 178], [93, 219], [93, 228], [93, 234], [93, 265], [94, 99], [94, 103], [94, 133], [94, 144], [94, 150], [94, 155], [94, 178], [94, 213], [94, 220], [94, 221], [94, 242], [94, 246], [94, 269], [94, 274], [94, 282], [94, 299], [95, 101], [95, 117], [95, 119], [95, 120], [95, 138], [95, 144], [95, 146], [95, 152], [95, 157], [95, 176], [95, 204], [95, 206], [95, 208], [95, 231], [95, 249], [95, 251], [95, 269], [95, 286], [95, 298], [96, 120], [96, 124], [96, 135], [96, 146], [96, 172], [96, 174], [96, 180], [96, 181], [96, 189], [96, 201], [96, 209], [96, 221], [96, 278], [96, 285], [96, 292], [97, 138], [97, 153], [97, 166], [97, 191], [97, 237], [97, 241], [97, 244], [97, 249], [97, 258], [97, 264], [98, 109], [98, 114], [98, 115], [98, 130], [98, 136], [98, 138], [98, 147], [98, 167], [98, 170], [98, 179], [98, 198], [98, 204], [98, 216], [98, 229], [98, 235], [98, 237], [98, 250], [98, 261], [98, 266], [98, 274], [98, 282], [98, 295], [99, 112], [99, 119], [99, 127], [99, 132], [99, 139], [99, 169], [99, 170], [99, 194], [99, 235], [99, 269], [99, 278], [99, 280], [100, 102], [100, 109], [100, 129], [100, 130], [100, 155], [100, 200], [100, 218], [100, 220], [100, 238], [100, 256], [100, 290], [101, 102], [101, 108], [101, 123], [101, 130], [101, 132], [101, 138], [101, 158], [101, 162], [101, 190], [101, 216], [101, 222], [101, 256], [101, 298], [102, 129], [102, 148], [102, 163], [102, 172], [102, 180], [102, 184], [102, 194], [102, 218], [102, 229], [102, 230], [102, 238], [102, 270], [102, 280], [102, 286], [102, 290], [103, 114], [103, 118], [103, 120], [103, 139], [103, 149], [103, 156], [103, 162], [103, 201], [103, 241], [103, 266], [103, 271], [104, 115], [104, 116], [104, 137], [104, 158], [104, 171], [104, 186], [104, 199], [104, 211], [104, 228], [104, 245], [104, 266], [104, 270], [105, 124], [105, 138], [105, 158], [105, 159], [105, 204], [105, 213], [105, 267], [105, 268], [105, 269], [105, 277], [106, 122], [106, 133], [106, 163], [106, 168], [106, 173], [106, 176], [106, 178], [106, 182], [106, 201], [106, 212], [106, 217], [106, 220], [106, 221], [106, 230], [106, 233], [106, 247], [106, 257], [106, 271], [106, 279], [106, 293], [106, 298], [107, 114], [107, 116], [107, 130], [107, 139], [107, 155], [107, 189], [107, 191], [107, 206], [107, 228], [107, 248], [107, 272], [107, 273], [107, 278], [108, 122], [108, 134], [108, 136], [108, 137], [108, 155], [108, 170], [108, 190], [108, 201], [108, 207], [108, 227], [108, 243], [108, 247], [108, 284], [108, 287], [108, 294], [108, 295], [109, 172], [109, 202], [109, 207], [109, 213], [109, 241], [109, 258], [109, 277], [110, 114], [110, 125], [110, 150], [110, 165], [110, 171], [110, 174], [110, 179], [110, 187], [110, 195], [110, 205], [110, 207], [110, 220], [110, 249], [110, 272], [110, 273], [110, 275], [110, 293], [111, 119], [111, 161], [111, 172], [111, 183], [111, 186], [111, 187], [111, 206], [111, 209], [111, 210], [111, 236], [111, 262], [111, 268], [111, 276], [111, 277], [111, 294], [111, 297], [112, 135], [112, 136], [112, 152], [112, 165], [112, 195], [112, 196], [112, 204], [112, 205], [112, 223], [112, 245], [112, 258], [112, 272], [112, 293], [113, 166], [113, 198], [113, 214], [113, 219], [113, 232], [113, 262], [113, 276], [114, 149], [114, 173], [114, 190], [114, 220], [114, 227], [114, 251], [114, 263], [114, 282], [114, 287], [114, 294], [114, 298], [115, 121], [115, 128], [115, 151], [115, 164], [115, 172], [115, 188], [115, 209], [115, 242], [115, 253], [115, 266], [115, 291], [115, 293], [116, 120], [116, 124], [116, 129], [116, 131], [116, 132], [116, 185], [116, 190], [116, 196], [116, 224], [116, 228], [116, 236], [116, 238], [116, 240], [116, 241], [116, 264], [116, 266], [116, 271], [116, 275], [116, 297], [117, 136], [117, 147], [117, 154], [117, 223], [117, 251], [117, 293], [118, 127], [118, 139], [118, 143], [118, 159], [118, 172], [118, 178], [118, 187], [118, 193], [118, 231], [118, 248], [118, 255], [118, 270], [118, 292], [119, 122], [119, 125], [119, 134], [119, 145], [119, 167], [119, 177], [119, 283], [119, 297], [119, 299], [120, 139], [120, 176], [120, 186], [120, 207], [120, 210], [120, 211], [120, 212], [120, 216], [120, 229], [120, 235], [120, 249], [120, 281], [121, 146], [121, 152], [121, 164], [121, 168], [121, 171], [121, 174], [121, 199], [121, 205], [121, 247], [121, 257], [121, 276], [121, 281], [121, 286], [121, 293], [121, 294], [122, 149], [122, 156], [122, 209], [122, 217], [122, 226], [122, 255], [122, 261], [123, 126], [123, 128], [123, 156], [123, 163], [123, 166], [123, 183], [123, 192], [123, 195], [123, 215], [123, 223], [123, 238], [123, 248], [123, 249], [123, 263], [123, 269], [123, 272], [124, 179], [124, 199], [124, 201], [124, 209], [124, 214], [124, 216], [124, 225], [124, 229], [124, 236], [124, 276], [124, 284], [125, 129], [125, 148], [125, 153], [125, 173], [125, 187], [125, 191], [125, 193], [125, 199], [125, 214], [125, 238], [125, 288], [126, 139], [126, 141], [126, 154], [126, 156], [126, 173], [126, 175], [126, 187], [126, 201], [126, 213], [126, 223], [126, 231], [126, 253], [126, 261], [126, 265], [126, 291], [126, 296], [127, 128], [127, 131], [127, 163], [127, 169], [127, 175], [127, 182], [127, 186], [127, 198], [127, 228], [127, 245], [127, 252], [127, 280], [128, 158], [128, 160], [128, 173], [128, 181], [128, 187], [128, 236], [128, 237], [128, 260], [128, 263], [128, 268], [129, 131], [129, 135], [129, 157], [129, 166], [129, 167], [129, 177], [129, 221], [129, 235], [129, 245], [129, 250], [129, 255], [129, 292], [130, 163], [130, 199], [130, 215], [130, 229], [130, 248], [130, 251], [130, 273], [131, 132], [131, 160], [131, 167], [131, 183], [131, 186], [131, 207], [131, 214], [131, 223], [131, 226], [131, 228], [131, 229], [131, 230], [131, 247], [131, 272], [131, 274], [131, 287], [131, 289], [132, 138], [132, 158], [132, 168], [132, 180], [132, 184], [132, 188], [132, 196], [132, 209], [132, 216], [132, 227], [132, 243], [132, 281], [132, 291], [133, 161], [133, 178], [133, 200], [133, 215], [133, 226], [133, 230], [133, 246], [133, 248], [133, 261], [133, 295], [133, 296], [134, 159], [134, 165], [134, 166], [134, 180], [134, 185], [134, 189], [134, 201], [134, 202], [134, 220], [134, 252], [134, 267], [134, 289], [134, 296], [135, 137], [135, 147], [135, 211], [135, 212], [135, 251], [135, 263], [135, 283], [135, 292], [135, 294], [136, 141], [136, 165], [136, 174], [136, 197], [136, 218], [136, 238], [136, 244], [136, 257], [136, 263], [136, 296], [137, 147], [137, 149], [137, 156], [137, 157], [137, 169], [137, 175], [137, 177], [137, 181], [137, 188], [137, 200], [137, 205], [137, 213], [137, 217], [137, 248], [137, 255], [137, 267], [137, 268], [137, 274], [137, 275], [138, 154], [138, 178], [138, 197], [138, 217], [138, 226], [138, 252], [138, 287], [138, 292], [139, 141], [139, 142], [139, 147], [139, 175], [139, 193], [139, 210], [139, 215], [139, 221], [139, 255], [139, 260], [139, 275], [139, 294], [139, 296], [140, 151], [140, 206], [140, 251], [140, 255], [140, 260], [140, 265], [140, 266], [140, 282], [141, 148], [141, 162], [141, 163], [141, 180], [141, 189], [141, 190], [141, 204], [141, 208], [141, 221], [141, 248], [141, 254], [141, 266], [141, 270], [141, 271], [141, 274], [141, 284], [141, 288], [142, 228], [142, 244], [142, 255], [142, 256], [142, 259], [142, 274], [142, 286], [142, 292], [142, 295], [143, 149], [143, 179], [143, 209], [143, 243], [143, 247], [143, 258], [143, 269], [143, 273], [143, 278], [143, 283], [144, 145], [144, 152], [144, 168], [144, 173], [144, 177], [144, 181], [144, 209], [144, 245], [144, 256], [144, 257], [144, 259], [144, 269], [144, 276], [145, 188], [145, 200], [145, 220], [145, 227], [145, 248], [145, 283], [145, 291], [145, 299], [146, 163], [146, 189], [146, 195], [146, 212], [146, 235], [146, 251], [146, 252], [146, 272], [146, 275], [146, 276], [146, 298], [147, 183], [147, 195], [147, 204], [147, 209], [147, 213], [147, 221], [147, 234], [147, 241], [147, 246], [147, 253], [147, 258], [147, 260], [147, 267], [147, 271], [147, 278], [147, 283], [148, 168], [148, 177], [148, 179], [148, 186], [148, 192], [148, 215], [148, 235], [148, 243], [148, 286], [148, 296], [149, 155], [149, 177], [149, 196], [149, 214], [149, 228], [149, 231], [149, 249], [149, 252], [149, 285], [150, 172], [150, 177], [150, 210], [150, 229], [150, 258], [150, 269], [150, 287], [151, 165], [151, 213], [151, 220], [151, 243], [151, 255], [151, 277], [152, 169], [152, 175], [152, 177], [152, 182], [152, 185], [152, 202], [152, 227], [152, 259], [152, 267], [152, 282], [152, 287], [153, 176], [153, 193], [153, 227], [153, 246], [153, 251], [153, 269], [154, 161], [154, 209], [154, 223], [154, 228], [154, 255], [154, 283], [155, 186], [155, 194], [155, 197], [155, 199], [155, 205], [155, 221], [155, 226], [155, 238], [155, 241], [155, 258], [155, 262], [155, 266], [155, 283], [155, 284], [156, 157], [156, 160], [156, 163], [156, 170], [156, 192], [156, 214], [156, 215], [156, 218], [156, 233], [156, 244], [156, 245], [156, 249], [156, 255], [156, 257], [156, 263], [156, 264], [156, 270], [157, 168], [157, 234], [157, 264], [157, 274], [157, 291], [157, 299], [158, 162], [158, 217], [158, 220], [158, 229], [158, 231], [158, 246], [158, 256], [159, 173], [159, 182], [159, 195], [159, 224], [159, 228], [159, 229], [159, 247], [159, 274], [159, 290], [160, 213], [160, 231], [160, 237], [160, 239], [160, 240], [160, 254], [160, 273], [160, 294], [161, 163], [161, 181], [161, 193], [161, 194], [161, 229], [161, 232], [161, 250], [161, 252], [161, 253], [162, 217], [162, 228], [162, 278], [162, 284], [162, 288], [162, 291], [162, 295], [163, 189], [163, 219], [163, 220], [163, 264], [163, 277], [163, 291], [164, 179], [164, 208], [164, 212], [164, 253], [164, 261], [164, 263], [164, 267], [164, 275], [164, 289], [164, 298], [165, 169], [165, 176], [165, 183], [165, 187], [165, 197], [165, 201], [165, 203], [165, 217], [165, 234], [165, 271], [165, 282], [165, 288], [165, 290], [166, 179], [166, 187], [166, 189], [166, 193], [166, 204], [166, 206], [166, 227], [166, 229], [166, 239], [166, 244], [166, 295], [167, 179], [167, 184], [167, 204], [167, 206], [167, 207], [167, 260], [168, 176], [168, 193], [168, 200], [168, 211], [168, 249], [168, 268], [168, 299], [169, 177], [169, 188], [169, 196], [169, 216], [169, 251], [169, 269], [170, 204], [170, 218], [170, 248], [170, 259], [170, 272], [170, 294], [171, 183], [171, 190], [171, 199], [171, 217], [171, 228], [171, 247], [171, 252], [171, 292], [172, 199], [172, 214], [172, 218], [172, 231], [172, 241], [172, 243], [172, 267], [172, 272], [173, 174], [173, 182], [173, 193], [173, 217], [173, 219], [173, 262], [173, 263], [173, 264], [173, 274], [173, 281], [173, 295], [173, 299], [174, 204], [174, 215], [174, 266], [174, 289], [174, 296], [175, 183], [175, 191], [175, 209], [175, 212], [175, 226], [175, 227], [175, 231], [175, 232], [175, 236], [175, 249], [175, 254], [175, 255], [175, 256], [175, 261], [175, 265], [175, 268], [175, 277], [175, 278], [175, 283], [175, 285], [175, 290], [175, 294], [175, 298], [176, 181], [176, 193], [176, 208], [176, 210], [176, 212], [176, 242], [176, 256], [176, 288], [176, 292], [177, 239], [177, 262], [177, 282], [178, 184], [178, 205], [178, 254], [178, 256], [178, 291], [178, 298], [179, 202], [179, 218], [179, 224], [179, 274], [179, 284], [179, 290], [180, 183], [180, 203], [180, 215], [180, 227], [180, 230], [180, 233], [180, 250], [180, 255], [180, 266], [180, 287], [181, 189], [181, 194], [181, 217], [181, 230], [181, 263], [181, 282], [181, 298], [182, 183], [182, 206], [182, 226], [182, 245], [182, 267], [182, 280], [182, 286], [183, 187], [183, 198], [183, 207], [183, 259], [183, 278], [184, 193], [184, 220], [184, 241], [184, 275], [184, 282], [185, 199], [185, 205], [185, 237], [185, 246], [185, 259], [185, 278], [185, 288], [186, 187], [186, 199], [186, 214], [186, 217], [186, 231], [186, 248], [186, 261], [186, 295], [186, 296], [187, 198], [187, 203], [187, 216], [187, 218], [187, 224], [187, 243], [187, 278], [188, 249], [188, 295], [189, 192], [189, 199], [189, 200], [189, 203], [189, 213], [189, 217], [189, 232], [189, 251], [189, 254], [189, 264], [189, 270], [189, 288], [190, 210], [190, 215], [190, 220], [190, 244], [190, 248], [190, 261], [190, 265], [190, 270], [191, 204], [191, 221], [191, 238], [191, 261], [192, 205], [192, 215], [192, 224], [192, 288], [193, 204], [193, 226], [193, 238], [193, 246], [193, 260], [193, 262], [193, 265], [193, 268], [193, 284], [193, 288], [194, 220], [194, 223], [194, 236], [194, 240], [194, 245], [194, 265], [194, 275], [194, 297], [195, 220], [195, 246], [195, 275], [195, 298], [196, 199], [196, 201], [196, 203], [196, 213], [196, 214], [196, 230], [196, 241], [196, 262], [196, 294], [196, 298], [197, 202], [197, 228], [197, 238], [197, 249], [197, 251], [197, 266], [197, 269], [197, 280], [198, 247], [198, 269], [198, 287], [198, 292], [199, 207], [199, 226], [199, 237], [199, 240], [199, 242], [199, 257], [199, 264], [199, 289], [199, 293], [200, 237], [200, 253], [200, 278], [201, 204], [201, 233], [201, 248], [201, 272], [201, 283], [201, 287], [202, 206], [202, 217], [202, 226], [202, 227], [202, 231], [202, 253], [202, 254], [202, 263], [202, 269], [202, 290], [202, 295], [203, 208], [203, 233], [203, 238], [203, 275], [204, 244], [204, 268], [204, 294], [205, 211], [205, 231], [205, 254], [205, 266], [205, 274], [205, 281], [206, 269], [206, 271], [207, 213], [207, 221], [207, 227], [207, 230], [207, 251], [207, 267], [207, 268], [207, 273], [208, 231], [208, 244], [208, 279], [208, 292], [209, 227], [209, 253], [209, 266], [209, 271], [209, 277], [210, 232], [210, 273], [211, 234], [211, 235], [211, 245], [211, 259], [211, 269], [211, 281], [211, 299], [212, 216], [212, 240], [212, 250], [212, 256], [212, 273], [213, 223], [213, 237], [213, 266], [213, 275], [214, 289], [214, 297], [215, 224], [215, 225], [215, 229], [215, 246], [215, 248], [215, 261], [215, 262], [215, 267], [215, 287], [216, 220], [216, 235], [216, 260], [216, 282], [216, 293], [217, 219], [217, 228], [217, 293], [218, 249], [218, 250], [218, 272], [219, 230], [219, 236], [219, 244], [219, 269], [219, 270], [220, 229], [220, 256], [220, 270], [220, 281], [220, 292], [221, 244], [221, 246], [221, 249], [221, 272], [221, 284], [222, 232], [222, 243], [222, 245], [222, 261], [222, 269], [222, 290], [222, 292], [222, 299], [223, 230], [223, 249], [223, 296], [224, 240], [224, 243], [224, 262], [224, 269], [224, 271], [225, 239], [225, 247], [225, 251], [225, 266], [225, 285], [225, 286], [225, 296], [226, 231], [226, 243], [226, 254], [226, 256], [226, 268], [226, 284], [227, 231], [227, 235], [228, 235], [228, 250], [228, 253], [228, 263], [228, 267], [228, 276], [228, 287], [228, 296], [229, 243], [229, 287], [230, 234], [230, 244], [230, 253], [230, 295], [231, 248], [231, 253], [231, 281], [231, 286], [231, 288], [232, 260], [232, 261], [232, 272], [233, 279], [233, 286], [234, 243], [234, 249], [234, 268], [234, 278], [234, 295], [235, 237], [235, 238], [235, 269], [235, 287], [236, 256], [236, 266], [236, 277], [236, 279], [236, 288], [237, 257], [237, 271], [237, 272], [238, 271], [238, 273], [239, 243], [239, 256], [239, 261], [239, 275], [239, 278], [239, 282], [239, 285], [240, 251], [240, 267], [240, 293], [241, 263], [241, 268], [241, 275], [241, 276], [241, 277], [241, 289], [242, 279], [242, 281], [243, 269], [244, 268], [244, 279], [244, 281], [244, 287], [245, 274], [245, 277], [245, 288], [245, 298], [246, 266], [246, 270], [246, 290], [247, 253], [247, 277], [247, 283], [247, 285], [248, 271], [248, 293], [249, 264], [249, 288], [250, 254], [250, 256], [250, 263], [250, 281], [250, 288], [250, 291], [251, 262], [251, 267], [251, 268], [251, 276], [252, 271], [252, 272], [252, 291], [253, 272], [253, 278], [254, 259], [254, 274], [254, 279], [254, 290], [255, 266], [256, 258], [256, 278], [256, 299], [257, 265], [257, 274], [257, 278], [257, 279], [258, 264], [258, 271], [258, 294], [259, 283], [260, 279], [260, 297], [262, 267], [262, 274], [262, 294], [263, 271], [264, 273], [264, 285], [266, 267], [266, 298], [267, 296], [268, 294], [269, 294], [270, 279], [271, 276], [271, 277], [271, 298], [272, 277], [272, 284], [273, 283], [273, 287], [273, 288], [273, 295], [274, 279], [274, 281], [274, 282], [275, 283], [275, 290], [275, 293], [275, 294], [276, 291], [277, 283], [278, 292], [280, 283], [282, 285], [284, 297], [284, 298], [285, 286], [285, 289], [286, 291], [288, 295], [294, 298], [294, 299]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l6-s1/tests/run.py b/tasks/construct-nppc-dominating-set-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-dominating-set-l6-s1/tests/test.sh b/tasks/construct-nppc-dominating-set-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-dominating-set-l6-s6/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-dominating-set-l6-s6/environment/instance.json b/tasks/construct-nppc-dominating-set-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5645bca713ea75b9d23571da650ead44b168eee2 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 300, "k": 20, "edges": [[0, 10], [0, 33], [0, 56], [0, 78], [0, 79], [0, 86], [0, 92], [0, 94], [0, 96], [0, 109], [0, 132], [0, 168], [0, 169], [0, 175], [0, 189], [0, 218], [0, 231], [0, 240], [0, 286], [0, 292], [1, 46], [1, 70], [1, 77], [1, 95], [1, 113], [1, 133], [1, 156], [1, 162], [1, 230], [1, 240], [1, 246], [1, 268], [1, 297], [2, 33], [2, 47], [2, 53], [2, 55], [2, 64], [2, 82], [2, 86], [2, 94], [2, 144], [2, 149], [2, 155], [2, 157], [2, 188], [2, 190], [2, 191], [2, 203], [2, 225], [2, 248], [2, 259], [2, 290], [3, 19], [3, 66], [3, 74], [3, 81], [3, 85], [3, 88], [3, 146], [3, 156], [3, 165], [3, 173], [3, 187], [3, 195], [3, 202], [3, 221], [3, 224], [3, 227], [3, 231], [3, 241], [3, 246], [3, 291], [3, 293], [4, 14], [4, 29], [4, 48], [4, 55], [4, 64], [4, 70], [4, 80], [4, 86], [4, 95], [4, 126], [4, 143], [4, 161], [4, 162], [4, 218], [4, 225], [4, 234], [4, 245], [4, 253], [4, 259], [4, 266], [4, 281], [5, 37], [5, 69], [5, 88], [5, 103], [5, 119], [5, 123], [5, 126], [5, 156], [5, 168], [5, 172], [5, 173], [5, 174], [5, 208], [5, 211], [5, 220], [5, 227], [5, 239], [5, 257], [5, 263], [5, 279], [5, 296], [5, 299], [6, 36], [6, 47], [6, 56], [6, 86], [6, 103], [6, 105], [6, 119], [6, 122], [6, 129], [6, 145], [6, 146], [6, 179], [6, 186], [6, 190], [6, 199], [6, 238], [6, 240], [6, 244], [6, 251], [6, 253], [6, 280], [6, 283], [6, 286], [6, 290], [7, 37], [7, 40], [7, 55], [7, 65], [7, 71], [7, 86], [7, 105], [7, 106], [7, 116], [7, 140], [7, 149], [7, 151], [7, 154], [7, 194], [7, 217], [7, 229], [7, 244], [7, 286], [7, 298], [8, 10], [8, 50], [8, 63], [8, 68], [8, 79], [8, 114], [8, 186], [8, 207], [8, 210], [8, 244], [8, 245], [8, 267], [9, 27], [9, 30], [9, 43], [9, 46], [9, 56], [9, 58], [9, 87], [9, 94], [9, 125], [9, 130], [9, 146], [9, 203], [9, 208], [9, 215], [9, 235], [9, 248], [9, 255], [9, 259], [9, 265], [10, 34], [10, 54], [10, 59], [10, 70], [10, 76], [10, 82], [10, 87], [10, 94], [10, 117], [10, 127], [10, 132], [10, 145], [10, 157], [10, 201], [10, 227], [10, 229], [10, 230], [10, 262], [10, 284], [10, 289], [11, 15], [11, 27], [11, 28], [11, 33], [11, 35], [11, 42], [11, 77], [11, 86], [11, 87], [11, 105], [11, 116], [11, 144], [11, 148], [11, 149], [11, 162], [11, 184], [11, 192], [11, 220], [11, 236], [11, 289], [12, 13], [12, 88], [12, 106], [12, 116], [12, 184], [12, 222], [12, 294], [13, 23], [13, 51], [13, 52], [13, 55], [13, 138], [13, 146], [13, 161], [13, 202], [13, 216], [13, 226], [13, 246], [13, 251], [13, 252], [13, 258], [13, 273], [13, 295], [14, 18], [14, 43], [14, 58], [14, 131], [14, 135], [14, 151], [14, 173], [14, 192], [14, 215], [14, 216], [14, 232], [14, 240], [14, 246], [14, 258], [14, 260], [14, 276], [14, 278], [14, 280], [14, 289], [14, 299], [15, 35], [15, 38], [15, 47], [15, 66], [15, 76], [15, 90], [15, 122], [15, 141], [15, 181], [15, 183], [15, 222], [15, 249], [15, 258], [15, 268], [16, 66], [16, 70], [16, 86], [16, 125], [16, 130], [16, 136], [16, 137], [16, 151], [16, 181], [16, 187], [16, 218], [16, 228], [16, 269], [16, 278], [17, 65], [17, 103], [17, 129], [17, 169], [17, 230], [17, 281], [17, 284], [17, 285], [17, 289], [18, 20], [18, 25], [18, 43], [18, 50], [18, 71], [18, 78], [18, 109], [18, 126], [18, 131], [18, 136], [18, 141], [18, 173], [18, 199], [18, 202], [18, 208], [18, 249], [19, 71], [19, 92], [19, 104], [19, 106], [19, 107], [19, 119], [19, 121], [19, 145], [19, 157], [19, 163], [19, 170], [19, 190], [19, 212], [19, 227], [19, 228], [19, 253], [19, 256], [19, 260], [19, 270], [19, 273], [19, 279], [19, 289], [19, 290], [20, 43], [20, 75], [20, 84], [20, 87], [20, 94], [20, 115], [20, 140], [20, 169], [20, 218], [20, 220], [20, 230], [20, 238], [20, 244], [20, 253], [20, 277], [20, 290], [21, 31], [21, 34], [21, 41], [21, 65], [21, 81], [21, 97], [21, 103], [21, 106], [21, 123], [21, 176], [21, 189], [21, 200], [21, 207], [21, 214], [21, 232], [21, 238], [21, 253], [21, 278], [21, 298], [22, 30], [22, 46], [22, 72], [22, 116], [22, 117], [22, 187], [22, 194], [22, 214], [22, 267], [22, 268], [22, 276], [22, 284], [22, 294], [23, 35], [23, 45], [23, 46], [23, 53], [23, 62], [23, 66], [23, 81], [23, 86], [23, 105], [23, 108], [23, 114], [23, 124], [23, 130], [23, 133], [23, 140], [23, 184], [23, 196], [23, 243], [23, 267], [24, 26], [24, 28], [24, 67], [24, 85], [24, 98], [24, 118], [24, 123], [24, 130], [24, 134], [24, 138], [24, 143], [24, 155], [24, 170], [24, 187], [24, 207], [24, 216], [24, 232], [24, 272], [24, 273], [24, 275], [24, 279], [25, 53], [25, 55], [25, 76], [25, 90], [25, 122], [25, 152], [25, 193], [25, 198], [25, 207], [25, 273], [25, 294], [26, 42], [26, 67], [26, 71], [26, 76], [26, 83], [26, 91], [26, 113], [26, 127], [26, 153], [26, 156], [26, 183], [26, 205], [26, 218], [26, 223], [26, 225], [26, 240], [26, 244], [26, 247], [26, 254], [26, 255], [26, 263], [26, 264], [26, 273], [26, 289], [27, 62], [27, 87], [27, 95], [27, 98], [27, 119], [27, 132], [27, 161], [27, 170], [27, 185], [27, 195], [27, 216], [27, 218], [27, 225], [27, 229], [27, 263], [27, 265], [27, 269], [27, 281], [27, 288], [28, 64], [28, 66], [28, 72], [28, 82], [28, 92], [28, 95], [28, 119], [28, 128], [28, 129], [28, 144], [28, 156], [28, 161], [28, 202], [28, 234], [28, 235], [28, 242], [28, 291], [29, 62], [29, 63], [29, 67], [29, 71], [29, 121], [29, 140], [29, 151], [29, 158], [29, 163], [29, 170], [29, 183], [29, 242], [29, 253], [29, 267], [29, 278], [29, 289], [29, 296], [30, 69], [30, 83], [30, 84], [30, 89], [30, 137], [30, 159], [30, 166], [30, 178], [30, 202], [30, 213], [30, 256], [30, 257], [30, 278], [30, 280], [30, 288], [30, 291], [31, 43], [31, 51], [31, 99], [31, 107], [31, 116], [31, 124], [31, 130], [31, 140], [31, 141], [31, 143], [31, 145], [31, 155], [31, 170], [31, 176], [31, 182], [31, 193], [31, 203], [31, 229], [31, 260], [31, 268], [31, 279], [31, 280], [32, 41], [32, 76], [32, 80], [32, 164], [32, 194], [32, 202], [32, 231], [32, 269], [32, 274], [33, 40], [33, 59], [33, 80], [33, 82], [33, 86], [33, 88], [33, 96], [33, 131], [33, 148], [33, 187], [33, 194], [33, 217], [33, 272], [33, 292], [34, 36], [34, 37], [34, 42], [34, 58], [34, 61], [34, 67], [34, 68], [34, 77], [34, 104], [34, 109], [34, 121], [34, 133], [34, 146], [34, 148], [34, 152], [34, 153], [34, 160], [34, 165], [34, 166], [34, 224], [34, 228], [34, 251], [34, 260], [34, 264], [34, 273], [34, 285], [34, 286], [34, 295], [34, 298], [35, 70], [35, 84], [35, 88], [35, 95], [35, 99], [35, 123], [35, 135], [35, 154], [35, 156], [35, 186], [35, 252], [35, 256], [35, 274], [35, 288], [35, 293], [35, 299], [36, 45], [36, 80], [36, 115], [36, 118], [36, 125], [36, 126], [36, 127], [36, 135], [36, 143], [36, 150], [36, 166], [36, 170], [36, 182], [36, 203], [36, 205], [36, 206], [36, 225], [36, 230], [36, 253], [36, 275], [36, 281], [37, 59], [37, 73], [37, 94], [37, 96], [37, 99], [37, 129], [37, 132], [37, 133], [37, 152], [37, 192], [37, 205], [37, 220], [37, 234], [37, 255], [37, 264], [37, 288], [37, 297], [38, 42], [38, 46], [38, 81], [38, 97], [38, 103], [38, 117], [38, 132], [38, 156], [38, 211], [38, 230], [38, 237], [38, 257], [38, 259], [38, 281], [39, 41], [39, 57], [39, 73], [39, 82], [39, 83], [39, 86], [39, 87], [39, 98], [39, 103], [39, 127], [39, 140], [39, 148], [39, 173], [39, 182], [39, 199], [39, 226], [39, 261], [39, 286], [39, 290], [39, 291], [40, 53], [40, 62], [40, 97], [40, 108], [40, 119], [40, 129], [40, 147], [40, 158], [40, 168], [40, 170], [40, 189], [40, 193], [40, 210], [40, 242], [41, 44], [41, 58], [41, 68], [41, 79], [41, 86], [41, 90], [41, 168], [41, 192], [41, 201], [41, 204], [41, 211], [41, 218], [41, 226], [41, 228], [41, 235], [41, 249], [41, 260], [41, 263], [41, 286], [41, 299], [42, 46], [42, 57], [42, 76], [42, 86], [42, 119], [42, 126], [42, 141], [42, 151], [42, 152], [42, 161], [42, 173], [42, 174], [42, 213], [42, 223], [42, 224], [42, 228], [42, 246], [42, 248], [42, 276], [43, 47], [43, 52], [43, 53], [43, 84], [43, 86], [43, 101], [43, 122], [43, 138], [43, 159], [43, 162], [43, 164], [43, 168], [43, 171], [43, 190], [43, 192], [43, 193], [43, 209], [43, 222], [43, 231], [43, 265], [43, 270], [43, 298], [44, 63], [44, 68], [44, 79], [44, 85], [44, 124], [44, 143], [44, 168], [44, 190], [44, 198], [44, 205], [44, 217], [44, 225], [44, 242], [44, 251], [44, 269], [44, 278], [44, 283], [45, 68], [45, 85], [45, 87], [45, 100], [45, 108], [45, 125], [45, 133], [45, 175], [45, 185], [45, 218], [45, 257], [45, 269], [46, 48], [46, 56], [46, 61], [46, 70], [46, 85], [46, 108], [46, 125], [46, 139], [46, 141], [46, 164], [46, 191], [46, 197], [46, 230], [46, 231], [46, 234], [46, 235], [46, 248], [46, 270], [47, 60], [47, 70], [47, 74], [47, 77], [47, 119], [47, 125], [47, 136], [47, 150], [47, 176], [47, 182], [47, 183], [47, 190], [47, 198], [47, 214], [47, 264], [47, 279], [48, 98], [48, 156], [48, 174], [48, 181], [48, 194], [48, 216], [48, 218], [48, 243], [48, 261], [48, 282], [48, 287], [48, 288], [49, 52], [49, 61], [49, 70], [49, 71], [49, 81], [49, 88], [49, 106], [49, 118], [49, 146], [49, 177], [49, 187], [49, 209], [49, 278], [49, 288], [49, 297], [50, 85], [50, 87], [50, 145], [50, 159], [50, 161], [50, 163], [50, 174], [50, 180], [50, 186], [50, 202], [50, 203], [50, 206], [50, 277], [51, 86], [51, 92], [51, 110], [51, 142], [51, 184], [51, 226], [51, 235], [51, 242], [51, 264], [51, 298], [52, 58], [52, 60], [52, 112], [52, 164], [52, 167], [52, 176], [52, 203], [52, 206], [52, 208], [52, 249], [52, 258], [52, 267], [52, 277], [53, 67], [53, 69], [53, 72], [53, 75], [53, 80], [53, 83], [53, 112], [53, 114], [53, 126], [53, 129], [53, 133], [53, 155], [53, 167], [53, 172], [53, 200], [53, 204], [53, 222], [53, 224], [53, 239], [53, 251], [53, 256], [53, 282], [53, 296], [54, 64], [54, 68], [54, 85], [54, 102], [54, 125], [54, 143], [54, 156], [54, 189], [54, 210], [54, 212], [54, 251], [54, 255], [54, 256], [54, 264], [54, 294], [54, 296], [55, 81], [55, 82], [55, 93], [55, 95], [55, 116], [55, 130], [55, 140], [55, 141], [55, 142], [55, 184], [55, 185], [55, 209], [55, 223], [55, 232], [55, 277], [56, 62], [56, 86], [56, 111], [56, 115], [56, 135], [56, 210], [56, 226], [56, 242], [56, 265], [56, 276], [56, 278], [56, 288], [57, 59], [57, 70], [57, 97], [57, 100], [57, 105], [57, 106], [57, 113], [57, 132], [57, 134], [57, 143], [57, 149], [57, 154], [57, 161], [57, 173], [57, 175], [57, 197], [57, 202], [57, 210], [57, 211], [57, 263], [57, 268], [57, 292], [57, 296], [58, 59], [58, 83], [58, 117], [58, 160], [58, 169], [58, 217], [58, 223], [58, 226], [58, 230], [58, 245], [58, 286], [58, 287], [58, 289], [58, 297], [59, 67], [59, 85], [59, 95], [59, 167], [59, 199], [59, 217], [59, 222], [59, 233], [59, 253], [59, 262], [59, 263], [59, 296], [59, 298], [60, 63], [60, 81], [60, 87], [60, 112], [60, 131], [60, 136], [60, 164], [60, 182], [60, 219], [60, 220], [60, 240], [60, 269], [60, 271], [60, 294], [60, 295], [61, 62], [61, 81], [61, 90], [61, 115], [61, 155], [61, 182], [61, 217], [61, 229], [61, 236], [61, 238], [61, 243], [61, 260], [61, 289], [62, 98], [62, 107], [62, 123], [62, 125], [62, 128], [62, 130], [62, 133], [62, 157], [62, 202], [62, 257], [62, 293], [63, 93], [63, 95], [63, 110], [63, 115], [63, 125], [63, 129], [63, 130], [63, 153], [63, 166], [63, 202], [63, 211], [63, 223], [63, 224], [63, 254], [63, 257], [63, 260], [63, 289], [64, 86], [64, 104], [64, 117], [64, 131], [64, 148], [64, 150], [64, 169], [64, 216], [64, 219], [64, 239], [64, 242], [64, 256], [64, 260], [65, 79], [65, 104], [65, 147], [65, 232], [65, 235], [65, 253], [65, 266], [65, 288], [65, 289], [65, 296], [66, 81], [66, 85], [66, 92], [66, 163], [66, 194], [66, 196], [66, 208], [66, 219], [66, 222], [66, 226], [66, 227], [66, 233], [66, 236], [66, 251], [66, 257], [66, 287], [67, 90], [67, 135], [67, 149], [67, 179], [67, 186], [67, 202], [67, 207], [67, 215], [67, 221], [67, 223], [67, 247], [67, 256], [67, 260], [67, 264], [67, 286], [68, 103], [68, 110], [68, 129], [68, 132], [68, 133], [68, 139], [68, 151], [68, 158], [68, 172], [68, 212], [68, 213], [68, 216], [68, 217], [68, 223], [68, 227], [68, 241], [68, 250], [68, 290], [69, 72], [69, 86], [69, 107], [69, 125], [69, 137], [69, 153], [69, 175], [69, 191], [69, 203], [69, 211], [69, 220], [69, 241], [69, 243], [69, 246], [69, 247], [69, 251], [69, 269], [69, 284], [69, 291], [69, 292], [69, 295], [70, 76], [70, 79], [70, 84], [70, 99], [70, 108], [70, 111], [70, 125], [70, 178], [70, 185], [70, 193], [70, 196], [70, 207], [70, 208], [70, 222], [70, 225], [70, 227], [70, 229], [70, 249], [70, 255], [70, 278], [70, 299], [71, 72], [71, 84], [71, 85], [71, 105], [71, 109], [71, 131], [71, 141], [71, 154], [71, 173], [71, 193], [71, 196], [71, 197], [71, 199], [71, 200], [71, 229], [71, 236], [71, 240], [71, 241], [71, 250], [71, 258], [71, 267], [71, 293], [72, 111], [72, 115], [72, 145], [72, 147], [72, 155], [72, 167], [72, 220], [72, 228], [72, 274], [72, 280], [72, 293], [73, 84], [73, 88], [73, 94], [73, 101], [73, 122], [73, 129], [73, 193], [73, 203], [73, 218], [73, 228], [73, 232], [73, 237], [73, 243], [73, 250], [73, 254], [73, 260], [73, 261], [73, 284], [73, 294], [73, 296], [74, 95], [74, 116], [74, 132], [74, 135], [74, 141], [74, 142], [74, 170], [74, 171], [74, 174], [74, 187], [74, 196], [74, 235], [74, 251], [74, 260], [74, 267], [74, 278], [74, 288], [74, 289], [75, 110], [75, 116], [75, 133], [75, 153], [75, 206], [75, 221], [75, 225], [75, 236], [75, 255], [75, 265], [75, 274], [75, 292], [75, 294], [75, 295], [76, 94], [76, 104], [76, 110], [76, 117], [76, 130], [76, 138], [76, 145], [76, 156], [76, 157], [76, 171], [76, 175], [76, 177], [76, 183], [76, 188], [76, 191], [76, 219], [76, 226], [76, 227], [76, 236], [76, 266], [76, 273], [76, 285], [76, 286], [76, 287], [77, 81], [77, 116], [77, 144], [77, 164], [77, 172], [77, 192], [77, 194], [77, 202], [77, 209], [77, 210], [77, 213], [77, 218], [77, 219], [77, 238], [77, 243], [77, 267], [77, 276], [77, 283], [77, 285], [78, 101], [78, 106], [78, 107], [78, 116], [78, 119], [78, 120], [78, 124], [78, 126], [78, 132], [78, 136], [78, 167], [78, 177], [78, 178], [78, 181], [78, 185], [78, 188], [78, 216], [78, 231], [78, 235], [78, 255], [78, 272], [78, 273], [79, 85], [79, 99], [79, 114], [79, 122], [79, 132], [79, 195], [79, 207], [79, 213], [79, 229], [79, 236], [79, 272], [80, 107], [80, 112], [80, 136], [80, 151], [80, 215], [80, 217], [80, 244], [80, 249], [80, 290], [80, 292], [81, 82], [81, 113], [81, 128], [81, 135], [81, 136], [81, 146], [81, 165], [81, 170], [81, 172], [81, 208], [81, 225], [81, 266], [81, 294], [82, 84], [82, 88], [82, 90], [82, 92], [82, 94], [82, 99], [82, 102], [82, 106], [82, 116], [82, 134], [82, 143], [82, 150], [82, 152], [82, 167], [82, 179], [82, 180], [82, 182], [82, 184], [82, 185], [82, 186], [82, 187], [82, 194], [82, 195], [82, 199], [82, 202], [82, 210], [82, 215], [82, 219], [82, 231], [82, 237], [82, 239], [82, 244], [82, 245], [82, 268], [82, 271], [82, 273], [82, 278], [82, 279], [82, 289], [83, 92], [83, 129], [83, 153], [83, 165], [83, 173], [83, 177], [83, 186], [83, 206], [83, 218], [83, 227], [83, 241], [83, 269], [83, 294], [84, 129], [84, 154], [84, 169], [84, 188], [84, 233], [84, 236], [84, 253], [84, 270], [85, 86], [85, 95], [85, 96], [85, 98], [85, 111], [85, 117], [85, 120], [85, 133], [85, 139], [85, 149], [85, 155], [85, 176], [85, 187], [85, 192], [85, 193], [85, 197], [85, 204], [85, 207], [85, 213], [85, 252], [85, 265], [86, 87], [86, 97], [86, 105], [86, 109], [86, 118], [86, 122], [86, 132], [86, 135], [86, 154], [86, 157], [86, 166], [86, 171], [86, 172], [86, 173], [86, 186], [86, 226], [86, 227], [86, 235], [86, 241], [87, 168], [87, 198], [87, 202], [87, 217], [87, 260], [87, 277], [87, 285], [87, 287], [87, 289], [87, 294], [88, 108], [88, 109], [88, 148], [88, 171], [88, 178], [88, 202], [88, 221], [88, 240], [88, 246], [88, 259], [88, 268], [88, 298], [89, 126], [89, 147], [89, 168], [89, 213], [89, 220], [89, 251], [89, 260], [89, 272], [89, 273], [89, 285], [90, 96], [90, 108], [90, 125], [90, 131], [90, 133], [90, 176], [90, 208], [90, 231], [90, 244], [90, 256], [90, 275], [90, 280], [90, 285], [90, 299], [91, 127], [91, 162], [91, 184], [91, 191], [91, 194], [91, 210], [91, 233], [91, 245], [91, 257], [91, 272], [91, 288], [91, 289], [92, 94], [92, 111], [92, 121], [92, 123], [92, 125], [92, 130], [92, 146], [92, 150], [92, 181], [92, 191], [92, 221], [92, 245], [92, 280], [92, 285], [92, 287], [93, 112], [93, 117], [93, 119], [93, 131], [93, 157], [93, 162], [93, 183], [93, 214], [93, 228], [93, 253], [93, 287], [93, 288], [93, 293], [94, 99], [94, 142], [94, 168], [94, 223], [94, 247], [94, 250], [94, 260], [94, 284], [94, 290], [95, 106], [95, 108], [95, 114], [95, 135], [95, 139], [95, 150], [95, 155], [95, 165], [95, 170], [95, 175], [95, 185], [95, 203], [95, 244], [95, 268], [95, 282], [95, 285], [95, 292], [95, 299], [96, 125], [96, 127], [96, 148], [96, 173], [96, 179], [96, 188], [96, 192], [96, 228], [96, 237], [96, 239], [96, 281], [96, 283], [96, 284], [96, 295], [97, 159], [97, 168], [97, 210], [97, 232], [97, 289], [98, 101], [98, 121], [98, 130], [98, 131], [98, 136], [98, 163], [98, 168], [98, 190], [98, 193], [98, 195], [98, 206], [98, 211], [98, 213], [98, 228], [98, 230], [98, 233], [98, 260], [98, 293], [98, 294], [99, 106], [99, 132], [99, 144], [99, 148], [99, 149], [99, 157], [99, 159], [99, 169], [99, 180], [99, 181], [99, 194], [99, 197], [99, 198], [99, 211], [99, 225], [99, 238], [99, 258], [99, 263], [100, 109], [100, 118], [100, 137], [100, 158], [100, 203], [100, 218], [100, 253], [100, 254], [100, 258], [100, 289], [101, 129], [101, 136], [101, 164], [101, 173], [101, 176], [101, 193], [101, 198], [101, 209], [101, 216], [101, 217], [101, 225], [101, 250], [101, 261], [101, 290], [102, 131], [102, 134], [102, 153], [102, 158], [102, 165], [102, 176], [102, 190], [102, 231], [102, 240], [102, 283], [102, 299], [103, 122], [103, 126], [103, 131], [103, 147], [103, 155], [103, 158], [103, 189], [103, 231], [103, 235], [103, 240], [103, 268], [103, 270], [103, 274], [103, 279], [103, 290], [103, 291], [103, 293], [103, 297], [103, 298], [104, 109], [104, 110], [104, 116], [104, 121], [104, 129], [104, 179], [104, 182], [104, 187], [104, 189], [104, 192], [104, 223], [105, 112], [105, 121], [105, 123], [105, 131], [105, 148], [105, 150], [105, 153], [105, 165], [105, 221], [105, 232], [105, 253], [105, 262], [105, 275], [105, 276], [105, 288], [106, 109], [106, 129], [106, 137], [106, 198], [106, 199], [106, 247], [106, 252], [106, 261], [106, 297], [107, 124], [107, 130], [107, 158], [107, 161], [107, 171], [107, 213], [107, 216], [107, 219], [107, 222], [107, 239], [107, 247], [107, 249], [107, 250], [107, 257], [107, 272], [107, 295], [108, 137], [108, 158], [108, 181], [108, 191], [108, 207], [108, 220], [108, 222], [108, 247], [108, 260], [108, 278], [108, 286], [109, 155], [109, 212], [109, 230], [109, 257], [109, 270], [109, 288], [109, 290], [110, 136], [110, 170], [110, 194], [110, 206], [110, 228], [110, 231], [110, 250], [110, 257], [110, 275], [110, 284], [111, 124], [111, 131], [111, 138], [111, 181], [111, 230], [111, 232], [111, 237], [111, 263], [111, 271], [111, 273], [111, 279], [111, 285], [112, 143], [112, 208], [112, 209], [112, 222], [112, 234], [112, 240], [112, 244], [112, 260], [112, 262], [112, 283], [112, 296], [113, 115], [113, 145], [113, 155], [113, 176], [113, 178], [113, 183], [113, 195], [113, 197], [113, 207], [113, 226], [113, 263], [113, 282], [113, 289], [114, 122], [114, 139], [114, 152], [114, 154], [114, 171], [114, 174], [114, 186], [114, 196], [114, 205], [114, 211], [114, 214], [114, 266], [114, 267], [114, 277], [114, 280], [114, 281], [114, 282], [114, 285], [114, 287], [114, 293], [114, 298], [115, 123], [115, 138], [115, 142], [115, 150], [115, 162], [115, 201], [115, 238], [115, 248], [115, 249], [115, 264], [115, 268], [115, 271], [115, 281], [116, 119], [116, 127], [116, 161], [116, 191], [116, 194], [116, 206], [116, 222], [116, 233], [116, 234], [116, 241], [116, 242], [116, 247], [116, 266], [116, 294], [116, 299], [117, 118], [117, 122], [117, 123], [117, 126], [117, 128], [117, 138], [117, 139], [117, 149], [117, 174], [117, 176], [117, 185], [117, 208], [117, 238], [117, 277], [117, 281], [117, 287], [118, 158], [118, 180], [118, 200], [118, 205], [118, 229], [118, 260], [118, 266], [118, 278], [119, 121], [119, 165], [119, 221], [119, 235], [119, 242], [119, 250], [119, 264], [119, 271], [119, 294], [120, 124], [120, 137], [120, 148], [120, 217], [120, 230], [120, 231], [120, 234], [120, 251], [120, 252], [120, 262], [120, 276], [120, 287], [120, 296], [121, 125], [121, 127], [121, 144], [121, 152], [121, 168], [121, 193], [121, 252], [121, 256], [121, 260], [121, 269], [121, 275], [121, 286], [121, 289], [122, 153], [122, 160], [122, 181], [122, 209], [122, 221], [122, 223], [122, 225], [122, 246], [122, 261], [122, 262], [122, 264], [122, 273], [122, 283], [122, 285], [123, 132], [123, 141], [123, 160], [123, 180], [123, 183], [123, 195], [123, 216], [123, 249], [123, 272], [123, 276], [123, 290], [123, 297], [124, 134], [124, 158], [124, 159], [124, 189], [124, 208], [124, 260], [124, 261], [124, 268], [125, 129], [125, 130], [125, 153], [125, 167], [125, 175], [125, 190], [125, 205], [125, 207], [125, 227], [125, 237], [125, 248], [125, 256], [125, 271], [125, 276], [125, 294], [125, 299], [126, 127], [126, 135], [126, 150], [126, 164], [126, 205], [126, 243], [126, 244], [126, 261], [126, 269], [126, 275], [126, 299], [127, 136], [127, 141], [127, 168], [127, 207], [127, 217], [127, 219], [127, 290], [128, 165], [128, 176], [128, 180], [128, 184], [128, 204], [128, 217], [128, 220], [128, 229], [128, 254], [128, 288], [129, 133], [129, 140], [129, 148], [129, 150], [129, 162], [129, 171], [129, 202], [129, 206], [129, 221], [129, 236], [129, 246], [129, 248], [129, 260], [129, 269], [129, 272], [129, 281], [129, 284], [130, 131], [130, 183], [130, 217], [130, 259], [130, 276], [130, 277], [130, 289], [131, 160], [131, 174], [131, 179], [131, 236], [131, 248], [131, 260], [131, 272], [131, 277], [132, 167], [132, 168], [132, 178], [132, 194], [132, 241], [132, 250], [132, 255], [132, 282], [132, 296], [132, 297], [133, 141], [133, 147], [133, 154], [133, 162], [133, 163], [133, 177], [133, 181], [133, 185], [133, 202], [133, 213], [133, 227], [133, 232], [133, 239], [133, 260], [133, 263], [133, 266], [133, 291], [133, 298], [134, 135], [134, 145], [134, 146], [134, 173], [134, 189], [134, 233], [134, 240], [134, 251], [134, 267], [134, 270], [134, 289], [135, 149], [135, 156], [135, 164], [135, 171], [135, 202], [135, 230], [135, 249], [135, 254], [135, 295], [136, 139], [136, 148], [136, 181], [136, 183], [136, 201], [136, 207], [136, 228], [136, 235], [136, 255], [136, 284], [137, 140], [137, 141], [137, 155], [137, 184], [137, 192], [137, 195], [137, 204], [137, 272], [137, 281], [137, 282], [137, 298], [138, 204], [138, 217], [138, 225], [138, 245], [138, 268], [138, 270], [138, 281], [139, 142], [139, 147], [139, 167], [139, 170], [139, 238], [139, 241], [139, 249], [139, 255], [139, 277], [140, 143], [140, 144], [140, 147], [140, 157], [140, 191], [140, 192], [140, 215], [140, 222], [140, 250], [140, 256], [140, 268], [140, 269], [140, 273], [140, 276], [140, 296], [141, 175], [141, 179], [141, 185], [141, 200], [141, 202], [141, 214], [141, 220], [141, 247], [141, 271], [142, 151], [142, 182], [142, 267], [142, 288], [143, 151], [143, 175], [143, 194], [143, 195], [143, 200], [143, 229], [143, 231], [143, 256], [143, 257], [143, 266], [143, 274], [144, 179], [144, 221], [144, 231], [144, 244], [144, 248], [144, 259], [144, 272], [144, 275], [144, 288], [144, 295], [144, 298], [145, 211], [145, 223], [145, 235], [145, 276], [145, 285], [145, 289], [145, 292], [146, 166], [146, 174], [146, 212], [146, 219], [146, 230], [146, 245], [146, 249], [146, 263], [146, 271], [146, 275], [146, 298], [147, 161], [147, 185], [147, 212], [147, 225], [147, 236], [147, 266], [147, 274], [147, 289], [148, 160], [148, 175], [148, 176], [148, 210], [148, 212], [148, 217], [148, 240], [148, 299], [149, 179], [149, 194], [149, 255], [149, 265], [149, 271], [150, 173], [150, 175], [150, 193], [150, 203], [150, 226], [150, 238], [150, 257], [150, 261], [150, 266], [150, 273], [150, 281], [151, 152], [151, 153], [151, 178], [151, 198], [151, 202], [151, 208], [151, 212], [151, 220], [151, 250], [151, 253], [151, 257], [151, 277], [151, 288], [151, 292], [152, 180], [152, 226], [152, 241], [152, 266], [153, 160], [153, 171], [153, 182], [153, 226], [153, 227], [153, 231], [153, 237], [153, 243], [153, 256], [153, 287], [154, 171], [154, 172], [154, 191], [154, 195], [154, 196], [154, 204], [154, 224], [154, 225], [154, 242], [154, 284], [155, 163], [155, 165], [155, 191], [155, 283], [155, 288], [156, 184], [156, 205], [156, 223], [156, 265], [156, 279], [156, 288], [157, 275], [157, 293], [158, 189], [158, 196], [158, 217], [158, 229], [158, 245], [158, 260], [158, 288], [159, 162], [159, 164], [159, 173], [159, 176], [159, 200], [159, 210], [159, 220], [159, 226], [159, 245], [159, 247], [159, 250], [159, 258], [159, 259], [159, 285], [159, 289], [159, 292], [159, 296], [160, 167], [160, 193], [160, 227], [160, 233], [160, 256], [160, 261], [160, 274], [161, 163], [161, 165], [161, 201], [161, 211], [161, 228], [161, 254], [161, 264], [161, 265], [161, 281], [161, 282], [161, 296], [162, 183], [162, 185], [162, 191], [162, 204], [162, 209], [162, 238], [162, 270], [162, 290], [163, 178], [163, 195], [163, 200], [163, 203], [163, 224], [163, 225], [163, 241], [163, 251], [163, 255], [163, 260], [163, 299], [164, 172], [164, 176], [164, 211], [164, 221], [164, 270], [164, 284], [164, 288], [164, 296], [164, 297], [165, 173], [165, 174], [165, 196], [165, 212], [165, 216], [165, 264], [165, 270], [166, 187], [166, 192], [166, 216], [166, 248], [166, 254], [166, 258], [166, 268], [166, 280], [166, 285], [166, 287], [167, 231], [168, 196], [168, 210], [168, 212], [168, 249], [168, 266], [168, 288], [168, 295], [169, 172], [169, 190], [169, 193], [169, 202], [169, 215], [169, 237], [169, 258], [169, 264], [169, 287], [169, 289], [169, 291], [170, 172], [170, 173], [170, 176], [170, 191], [170, 194], [170, 221], [170, 266], [170, 279], [170, 288], [171, 177], [171, 180], [171, 186], [171, 193], [171, 221], [171, 233], [171, 249], [171, 251], [171, 260], [171, 272], [171, 299], [172, 182], [172, 202], [172, 210], [172, 212], [172, 220], [172, 223], [172, 230], [172, 250], [172, 268], [172, 269], [172, 273], [172, 274], [172, 290], [173, 179], [173, 185], [173, 187], [173, 191], [173, 196], [173, 216], [173, 233], [173, 244], [173, 249], [173, 255], [173, 259], [173, 290], [173, 296], [174, 179], [174, 191], [174, 201], [174, 212], [174, 215], [174, 216], [174, 229], [174, 231], [174, 232], [174, 245], [174, 268], [174, 273], [174, 283], [174, 297], [174, 298], [175, 197], [175, 245], [175, 251], [175, 264], [175, 265], [175, 269], [175, 275], [175, 294], [176, 205], [176, 208], [176, 220], [176, 231], [176, 236], [176, 237], [176, 247], [176, 263], [176, 281], [177, 178], [177, 180], [177, 202], [177, 224], [177, 234], [177, 235], [177, 243], [177, 245], [177, 261], [178, 203], [178, 213], [178, 246], [178, 259], [178, 281], [179, 196], [179, 203], [179, 205], [179, 212], [179, 224], [179, 225], [179, 247], [179, 283], [179, 290], [180, 189], [180, 201], [180, 205], [180, 223], [180, 284], [180, 293], [180, 294], [181, 212], [181, 216], [181, 234], [181, 256], [181, 285], [181, 294], [182, 192], [182, 236], [182, 245], [182, 257], [182, 281], [183, 186], [183, 188], [183, 203], [183, 211], [183, 257], [183, 272], [183, 277], [183, 283], [184, 196], [184, 241], [184, 247], [184, 248], [184, 284], [185, 190], [185, 201], [185, 247], [185, 264], [185, 288], [186, 193], [186, 204], [186, 291], [186, 293], [187, 223], [187, 227], [187, 229], [187, 239], [187, 249], [187, 250], [187, 279], [187, 280], [187, 292], [187, 294], [187, 296], [188, 189], [188, 198], [188, 229], [188, 230], [188, 256], [188, 259], [188, 269], [189, 217], [189, 233], [189, 258], [189, 285], [189, 290], [189, 294], [190, 197], [190, 198], [190, 239], [190, 250], [191, 192], [191, 200], [191, 232], [191, 236], [191, 256], [191, 258], [191, 266], [192, 194], [192, 205], [192, 211], [192, 212], [192, 215], [192, 251], [192, 260], [192, 265], [192, 274], [192, 299], [193, 196], [193, 215], [193, 217], [193, 237], [193, 251], [193, 278], [193, 296], [194, 211], [194, 216], [194, 229], [194, 242], [194, 260], [194, 269], [195, 197], [195, 212], [195, 238], [195, 269], [195, 283], [195, 299], [196, 213], [196, 219], [196, 228], [196, 238], [196, 248], [196, 255], [196, 257], [196, 258], [196, 298], [197, 205], [197, 238], [197, 245], [197, 260], [197, 262], [197, 264], [197, 286], [198, 271], [198, 273], [198, 289], [198, 293], [199, 203], [199, 235], [200, 215], [200, 260], [200, 269], [200, 299], [201, 211], [201, 234], [201, 238], [201, 240], [201, 259], [201, 271], [201, 289], [201, 292], [202, 208], [202, 229], [202, 245], [202, 246], [202, 248], [202, 251], [202, 253], [202, 265], [202, 289], [203, 220], [203, 230], [203, 235], [204, 216], [204, 247], [204, 252], [204, 275], [204, 285], [204, 287], [204, 295], [204, 298], [205, 207], [205, 211], [205, 228], [205, 240], [205, 253], [205, 260], [205, 282], [206, 221], [206, 233], [206, 256], [206, 284], [207, 223], [207, 241], [207, 262], [207, 269], [207, 278], [207, 281], [207, 282], [207, 292], [207, 294], [208, 220], [208, 235], [208, 249], [209, 220], [209, 222], [209, 227], [209, 254], [209, 255], [209, 260], [209, 270], [209, 281], [210, 218], [210, 230], [210, 235], [210, 245], [210, 253], [210, 281], [210, 288], [210, 291], [210, 293], [211, 226], [211, 229], [211, 254], [211, 267], [211, 270], [212, 213], [212, 214], [212, 219], [212, 253], [212, 274], [212, 281], [213, 219], [213, 228], [213, 245], [213, 260], [213, 263], [214, 215], [214, 223], [214, 234], [214, 236], [214, 250], [214, 263], [214, 269], [214, 272], [214, 285], [215, 244], [215, 260], [215, 267], [215, 275], [215, 290], [216, 224], [216, 225], [216, 229], [216, 234], [216, 243], [216, 247], [216, 273], [217, 227], [217, 230], [217, 238], [217, 243], [217, 244], [217, 245], [217, 260], [217, 281], [217, 299], [218, 222], [218, 225], [218, 260], [218, 277], [218, 289], [219, 224], [219, 233], [219, 245], [219, 250], [219, 258], [219, 265], [219, 283], [220, 238], [220, 247], [220, 263], [220, 266], [220, 269], [220, 278], [220, 293], [221, 232], [221, 241], [221, 265], [221, 274], [221, 278], [222, 233], [222, 234], [222, 249], [222, 268], [222, 280], [222, 282], [223, 230], [223, 248], [223, 264], [223, 271], [223, 278], [223, 292], [224, 241], [224, 267], [224, 288], [225, 249], [226, 247], [226, 250], [226, 266], [226, 287], [226, 294], [227, 252], [227, 262], [227, 293], [228, 235], [228, 244], [228, 251], [228, 284], [228, 285], [228, 294], [229, 249], [229, 254], [229, 259], [229, 291], [230, 236], [230, 240], [230, 243], [230, 244], [230, 257], [230, 270], [230, 275], [230, 292], [230, 297], [231, 241], [231, 272], [232, 245], [232, 253], [232, 258], [232, 264], [232, 270], [232, 275], [232, 276], [232, 289], [232, 297], [233, 283], [234, 235], [234, 237], [234, 253], [234, 278], [234, 282], [234, 288], [235, 269], [235, 293], [235, 296], [236, 241], [236, 268], [237, 266], [237, 275], [237, 295], [237, 297], [238, 263], [238, 267], [239, 240], [239, 278], [239, 295], [240, 265], [240, 270], [240, 281], [241, 243], [241, 253], [241, 296], [241, 298], [242, 252], [242, 277], [242, 280], [242, 281], [242, 286], [243, 249], [243, 251], [243, 256], [243, 261], [243, 294], [243, 295], [244, 259], [244, 263], [244, 273], [244, 274], [244, 283], [244, 292], [244, 295], [245, 250], [245, 264], [245, 279], [245, 288], [245, 289], [246, 257], [246, 269], [246, 272], [247, 253], [247, 275], [247, 287], [247, 290], [247, 296], [248, 252], [248, 288], [249, 287], [249, 290], [249, 296], [250, 255], [251, 258], [251, 285], [251, 286], [251, 291], [252, 255], [254, 261], [254, 288], [254, 297], [255, 265], [255, 266], [255, 273], [255, 278], [256, 257], [256, 260], [257, 275], [257, 286], [257, 293], [258, 289], [259, 289], [260, 261], [260, 276], [260, 286], [261, 295], [262, 266], [262, 280], [262, 281], [262, 297], [263, 275], [264, 268], [264, 288], [265, 268], [265, 287], [265, 289], [265, 298], [266, 267], [266, 269], [266, 294], [267, 275], [267, 281], [268, 276], [269, 294], [269, 299], [270, 271], [270, 283], [270, 298], [271, 275], [271, 280], [271, 289], [273, 286], [273, 290], [273, 298], [274, 279], [274, 287], [275, 280], [275, 298], [277, 280], [277, 292], [279, 294], [280, 293], [281, 286], [281, 291], [281, 298], [281, 299], [282, 288], [283, 288], [289, 299], [291, 299]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l6-s6/solution/solve.sh b/tasks/construct-nppc-dominating-set-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..48e9ddc07dc101380a150cd6fcfb21eee85df774 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"dominating_set": [34, 76, 82, 85, 86, 103, 114, 116, 125, 129, 202, 216, 220, 230, 249, 255, 260, 281, 288, 289]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l6-s6/tests/check.py b/tasks/construct-nppc-dominating-set-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s6/tests/check.py @@ -0,0 +1,23 @@ +"""Dominating set of size <= k. Accepts any valid dominating set.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier has no type/range checks (out-of-range labels and floats are silently used) + d = int_list(ans.get("dominating_set"), None, 0, n - 1, "dominating_set") + if len(set(d)) != len(d): + raise Invalid("dominating_set contains duplicates") + if not d or len(d) > k: + raise Invalid(f"dominating_set must have 1..{k} vertices, got {len(d)}") + dom = set(d) + s = set(d) + for u, v in inst["edges"]: + if u in s: + dom.add(v) + if v in s: + dom.add(u) + if len(dom) != n: + miss = min(set(range(n)) - dom) + raise Invalid(f"vertex {miss} is not dominated") + return None, {"size": len(d)} diff --git a/tasks/construct-nppc-dominating-set-l6-s6/tests/instance.json b/tasks/construct-nppc-dominating-set-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5645bca713ea75b9d23571da650ead44b168eee2 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 300, "k": 20, "edges": [[0, 10], [0, 33], [0, 56], [0, 78], [0, 79], [0, 86], [0, 92], [0, 94], [0, 96], [0, 109], [0, 132], [0, 168], [0, 169], [0, 175], [0, 189], [0, 218], [0, 231], [0, 240], [0, 286], [0, 292], [1, 46], [1, 70], [1, 77], [1, 95], [1, 113], [1, 133], [1, 156], [1, 162], [1, 230], [1, 240], [1, 246], [1, 268], [1, 297], [2, 33], [2, 47], [2, 53], [2, 55], [2, 64], [2, 82], [2, 86], [2, 94], [2, 144], [2, 149], [2, 155], [2, 157], [2, 188], [2, 190], [2, 191], [2, 203], [2, 225], [2, 248], [2, 259], [2, 290], [3, 19], [3, 66], [3, 74], [3, 81], [3, 85], [3, 88], [3, 146], [3, 156], [3, 165], [3, 173], [3, 187], [3, 195], [3, 202], [3, 221], [3, 224], [3, 227], [3, 231], [3, 241], [3, 246], [3, 291], [3, 293], [4, 14], [4, 29], [4, 48], [4, 55], [4, 64], [4, 70], [4, 80], [4, 86], [4, 95], [4, 126], [4, 143], [4, 161], [4, 162], [4, 218], [4, 225], [4, 234], [4, 245], [4, 253], [4, 259], [4, 266], [4, 281], [5, 37], [5, 69], [5, 88], [5, 103], [5, 119], [5, 123], [5, 126], [5, 156], [5, 168], [5, 172], [5, 173], [5, 174], [5, 208], [5, 211], [5, 220], [5, 227], [5, 239], [5, 257], [5, 263], [5, 279], [5, 296], [5, 299], [6, 36], [6, 47], [6, 56], [6, 86], [6, 103], [6, 105], [6, 119], [6, 122], [6, 129], [6, 145], [6, 146], [6, 179], [6, 186], [6, 190], [6, 199], [6, 238], [6, 240], [6, 244], [6, 251], [6, 253], [6, 280], [6, 283], [6, 286], [6, 290], [7, 37], [7, 40], [7, 55], [7, 65], [7, 71], [7, 86], [7, 105], [7, 106], [7, 116], [7, 140], [7, 149], [7, 151], [7, 154], [7, 194], [7, 217], [7, 229], [7, 244], [7, 286], [7, 298], [8, 10], [8, 50], [8, 63], [8, 68], [8, 79], [8, 114], [8, 186], [8, 207], [8, 210], [8, 244], [8, 245], [8, 267], [9, 27], [9, 30], [9, 43], [9, 46], [9, 56], [9, 58], [9, 87], [9, 94], [9, 125], [9, 130], [9, 146], [9, 203], [9, 208], [9, 215], [9, 235], [9, 248], [9, 255], [9, 259], [9, 265], [10, 34], [10, 54], [10, 59], [10, 70], [10, 76], [10, 82], [10, 87], [10, 94], [10, 117], [10, 127], [10, 132], [10, 145], [10, 157], [10, 201], [10, 227], [10, 229], [10, 230], [10, 262], [10, 284], [10, 289], [11, 15], [11, 27], [11, 28], [11, 33], [11, 35], [11, 42], [11, 77], [11, 86], [11, 87], [11, 105], [11, 116], [11, 144], [11, 148], [11, 149], [11, 162], [11, 184], [11, 192], [11, 220], [11, 236], [11, 289], [12, 13], [12, 88], [12, 106], [12, 116], [12, 184], [12, 222], [12, 294], [13, 23], [13, 51], [13, 52], [13, 55], [13, 138], [13, 146], [13, 161], [13, 202], [13, 216], [13, 226], [13, 246], [13, 251], [13, 252], [13, 258], [13, 273], [13, 295], [14, 18], [14, 43], [14, 58], [14, 131], [14, 135], [14, 151], [14, 173], [14, 192], [14, 215], [14, 216], [14, 232], [14, 240], [14, 246], [14, 258], [14, 260], [14, 276], [14, 278], [14, 280], [14, 289], [14, 299], [15, 35], [15, 38], [15, 47], [15, 66], [15, 76], [15, 90], [15, 122], [15, 141], [15, 181], [15, 183], [15, 222], [15, 249], [15, 258], [15, 268], [16, 66], [16, 70], [16, 86], [16, 125], [16, 130], [16, 136], [16, 137], [16, 151], [16, 181], [16, 187], [16, 218], [16, 228], [16, 269], [16, 278], [17, 65], [17, 103], [17, 129], [17, 169], [17, 230], [17, 281], [17, 284], [17, 285], [17, 289], [18, 20], [18, 25], [18, 43], [18, 50], [18, 71], [18, 78], [18, 109], [18, 126], [18, 131], [18, 136], [18, 141], [18, 173], [18, 199], [18, 202], [18, 208], [18, 249], [19, 71], [19, 92], [19, 104], [19, 106], [19, 107], [19, 119], [19, 121], [19, 145], [19, 157], [19, 163], [19, 170], [19, 190], [19, 212], [19, 227], [19, 228], [19, 253], [19, 256], [19, 260], [19, 270], [19, 273], [19, 279], [19, 289], [19, 290], [20, 43], [20, 75], [20, 84], [20, 87], [20, 94], [20, 115], [20, 140], [20, 169], [20, 218], [20, 220], [20, 230], [20, 238], [20, 244], [20, 253], [20, 277], [20, 290], [21, 31], [21, 34], [21, 41], [21, 65], [21, 81], [21, 97], [21, 103], [21, 106], [21, 123], [21, 176], [21, 189], [21, 200], [21, 207], [21, 214], [21, 232], [21, 238], [21, 253], [21, 278], [21, 298], [22, 30], [22, 46], [22, 72], [22, 116], [22, 117], [22, 187], [22, 194], [22, 214], [22, 267], [22, 268], [22, 276], [22, 284], [22, 294], [23, 35], [23, 45], [23, 46], [23, 53], [23, 62], [23, 66], [23, 81], [23, 86], [23, 105], [23, 108], [23, 114], [23, 124], [23, 130], [23, 133], [23, 140], [23, 184], [23, 196], [23, 243], [23, 267], [24, 26], [24, 28], [24, 67], [24, 85], [24, 98], [24, 118], [24, 123], [24, 130], [24, 134], [24, 138], [24, 143], [24, 155], [24, 170], [24, 187], [24, 207], [24, 216], [24, 232], [24, 272], [24, 273], [24, 275], [24, 279], [25, 53], [25, 55], [25, 76], [25, 90], [25, 122], [25, 152], [25, 193], [25, 198], [25, 207], [25, 273], [25, 294], [26, 42], [26, 67], [26, 71], [26, 76], [26, 83], [26, 91], [26, 113], [26, 127], [26, 153], [26, 156], [26, 183], [26, 205], [26, 218], [26, 223], [26, 225], [26, 240], [26, 244], [26, 247], [26, 254], [26, 255], [26, 263], [26, 264], [26, 273], [26, 289], [27, 62], [27, 87], [27, 95], [27, 98], [27, 119], [27, 132], [27, 161], [27, 170], [27, 185], [27, 195], [27, 216], [27, 218], [27, 225], [27, 229], [27, 263], [27, 265], [27, 269], [27, 281], [27, 288], [28, 64], [28, 66], [28, 72], [28, 82], [28, 92], [28, 95], [28, 119], [28, 128], [28, 129], [28, 144], [28, 156], [28, 161], [28, 202], [28, 234], [28, 235], [28, 242], [28, 291], [29, 62], [29, 63], [29, 67], [29, 71], [29, 121], [29, 140], [29, 151], [29, 158], [29, 163], [29, 170], [29, 183], [29, 242], [29, 253], [29, 267], [29, 278], [29, 289], [29, 296], [30, 69], [30, 83], [30, 84], [30, 89], [30, 137], [30, 159], [30, 166], [30, 178], [30, 202], [30, 213], [30, 256], [30, 257], [30, 278], [30, 280], [30, 288], [30, 291], [31, 43], [31, 51], [31, 99], [31, 107], [31, 116], [31, 124], [31, 130], [31, 140], [31, 141], [31, 143], [31, 145], [31, 155], [31, 170], [31, 176], [31, 182], [31, 193], [31, 203], [31, 229], [31, 260], [31, 268], [31, 279], [31, 280], [32, 41], [32, 76], [32, 80], [32, 164], [32, 194], [32, 202], [32, 231], [32, 269], [32, 274], [33, 40], [33, 59], [33, 80], [33, 82], [33, 86], [33, 88], [33, 96], [33, 131], [33, 148], [33, 187], [33, 194], [33, 217], [33, 272], [33, 292], [34, 36], [34, 37], [34, 42], [34, 58], [34, 61], [34, 67], [34, 68], [34, 77], [34, 104], [34, 109], [34, 121], [34, 133], [34, 146], [34, 148], [34, 152], [34, 153], [34, 160], [34, 165], [34, 166], [34, 224], [34, 228], [34, 251], [34, 260], [34, 264], [34, 273], [34, 285], [34, 286], [34, 295], [34, 298], [35, 70], [35, 84], [35, 88], [35, 95], [35, 99], [35, 123], [35, 135], [35, 154], [35, 156], [35, 186], [35, 252], [35, 256], [35, 274], [35, 288], [35, 293], [35, 299], [36, 45], [36, 80], [36, 115], [36, 118], [36, 125], [36, 126], [36, 127], [36, 135], [36, 143], [36, 150], [36, 166], [36, 170], [36, 182], [36, 203], [36, 205], [36, 206], [36, 225], [36, 230], [36, 253], [36, 275], [36, 281], [37, 59], [37, 73], [37, 94], [37, 96], [37, 99], [37, 129], [37, 132], [37, 133], [37, 152], [37, 192], [37, 205], [37, 220], [37, 234], [37, 255], [37, 264], [37, 288], [37, 297], [38, 42], [38, 46], [38, 81], [38, 97], [38, 103], [38, 117], [38, 132], [38, 156], [38, 211], [38, 230], [38, 237], [38, 257], [38, 259], [38, 281], [39, 41], [39, 57], [39, 73], [39, 82], [39, 83], [39, 86], [39, 87], [39, 98], [39, 103], [39, 127], [39, 140], [39, 148], [39, 173], [39, 182], [39, 199], [39, 226], [39, 261], [39, 286], [39, 290], [39, 291], [40, 53], [40, 62], [40, 97], [40, 108], [40, 119], [40, 129], [40, 147], [40, 158], [40, 168], [40, 170], [40, 189], [40, 193], [40, 210], [40, 242], [41, 44], [41, 58], [41, 68], [41, 79], [41, 86], [41, 90], [41, 168], [41, 192], [41, 201], [41, 204], [41, 211], [41, 218], [41, 226], [41, 228], [41, 235], [41, 249], [41, 260], [41, 263], [41, 286], [41, 299], [42, 46], [42, 57], [42, 76], [42, 86], [42, 119], [42, 126], [42, 141], [42, 151], [42, 152], [42, 161], [42, 173], [42, 174], [42, 213], [42, 223], [42, 224], [42, 228], [42, 246], [42, 248], [42, 276], [43, 47], [43, 52], [43, 53], [43, 84], [43, 86], [43, 101], [43, 122], [43, 138], [43, 159], [43, 162], [43, 164], [43, 168], [43, 171], [43, 190], [43, 192], [43, 193], [43, 209], [43, 222], [43, 231], [43, 265], [43, 270], [43, 298], [44, 63], [44, 68], [44, 79], [44, 85], [44, 124], [44, 143], [44, 168], [44, 190], [44, 198], [44, 205], [44, 217], [44, 225], [44, 242], [44, 251], [44, 269], [44, 278], [44, 283], [45, 68], [45, 85], [45, 87], [45, 100], [45, 108], [45, 125], [45, 133], [45, 175], [45, 185], [45, 218], [45, 257], [45, 269], [46, 48], [46, 56], [46, 61], [46, 70], [46, 85], [46, 108], [46, 125], [46, 139], [46, 141], [46, 164], [46, 191], [46, 197], [46, 230], [46, 231], [46, 234], [46, 235], [46, 248], [46, 270], [47, 60], [47, 70], [47, 74], [47, 77], [47, 119], [47, 125], [47, 136], [47, 150], [47, 176], [47, 182], [47, 183], [47, 190], [47, 198], [47, 214], [47, 264], [47, 279], [48, 98], [48, 156], [48, 174], [48, 181], [48, 194], [48, 216], [48, 218], [48, 243], [48, 261], [48, 282], [48, 287], [48, 288], [49, 52], [49, 61], [49, 70], [49, 71], [49, 81], [49, 88], [49, 106], [49, 118], [49, 146], [49, 177], [49, 187], [49, 209], [49, 278], [49, 288], [49, 297], [50, 85], [50, 87], [50, 145], [50, 159], [50, 161], [50, 163], [50, 174], [50, 180], [50, 186], [50, 202], [50, 203], [50, 206], [50, 277], [51, 86], [51, 92], [51, 110], [51, 142], [51, 184], [51, 226], [51, 235], [51, 242], [51, 264], [51, 298], [52, 58], [52, 60], [52, 112], [52, 164], [52, 167], [52, 176], [52, 203], [52, 206], [52, 208], [52, 249], [52, 258], [52, 267], [52, 277], [53, 67], [53, 69], [53, 72], [53, 75], [53, 80], [53, 83], [53, 112], [53, 114], [53, 126], [53, 129], [53, 133], [53, 155], [53, 167], [53, 172], [53, 200], [53, 204], [53, 222], [53, 224], [53, 239], [53, 251], [53, 256], [53, 282], [53, 296], [54, 64], [54, 68], [54, 85], [54, 102], [54, 125], [54, 143], [54, 156], [54, 189], [54, 210], [54, 212], [54, 251], [54, 255], [54, 256], [54, 264], [54, 294], [54, 296], [55, 81], [55, 82], [55, 93], [55, 95], [55, 116], [55, 130], [55, 140], [55, 141], [55, 142], [55, 184], [55, 185], [55, 209], [55, 223], [55, 232], [55, 277], [56, 62], [56, 86], [56, 111], [56, 115], [56, 135], [56, 210], [56, 226], [56, 242], [56, 265], [56, 276], [56, 278], [56, 288], [57, 59], [57, 70], [57, 97], [57, 100], [57, 105], [57, 106], [57, 113], [57, 132], [57, 134], [57, 143], [57, 149], [57, 154], [57, 161], [57, 173], [57, 175], [57, 197], [57, 202], [57, 210], [57, 211], [57, 263], [57, 268], [57, 292], [57, 296], [58, 59], [58, 83], [58, 117], [58, 160], [58, 169], [58, 217], [58, 223], [58, 226], [58, 230], [58, 245], [58, 286], [58, 287], [58, 289], [58, 297], [59, 67], [59, 85], [59, 95], [59, 167], [59, 199], [59, 217], [59, 222], [59, 233], [59, 253], [59, 262], [59, 263], [59, 296], [59, 298], [60, 63], [60, 81], [60, 87], [60, 112], [60, 131], [60, 136], [60, 164], [60, 182], [60, 219], [60, 220], [60, 240], [60, 269], [60, 271], [60, 294], [60, 295], [61, 62], [61, 81], [61, 90], [61, 115], [61, 155], [61, 182], [61, 217], [61, 229], [61, 236], [61, 238], [61, 243], [61, 260], [61, 289], [62, 98], [62, 107], [62, 123], [62, 125], [62, 128], [62, 130], [62, 133], [62, 157], [62, 202], [62, 257], [62, 293], [63, 93], [63, 95], [63, 110], [63, 115], [63, 125], [63, 129], [63, 130], [63, 153], [63, 166], [63, 202], [63, 211], [63, 223], [63, 224], [63, 254], [63, 257], [63, 260], [63, 289], [64, 86], [64, 104], [64, 117], [64, 131], [64, 148], [64, 150], [64, 169], [64, 216], [64, 219], [64, 239], [64, 242], [64, 256], [64, 260], [65, 79], [65, 104], [65, 147], [65, 232], [65, 235], [65, 253], [65, 266], [65, 288], [65, 289], [65, 296], [66, 81], [66, 85], [66, 92], [66, 163], [66, 194], [66, 196], [66, 208], [66, 219], [66, 222], [66, 226], [66, 227], [66, 233], [66, 236], [66, 251], [66, 257], [66, 287], [67, 90], [67, 135], [67, 149], [67, 179], [67, 186], [67, 202], [67, 207], [67, 215], [67, 221], [67, 223], [67, 247], [67, 256], [67, 260], [67, 264], [67, 286], [68, 103], [68, 110], [68, 129], [68, 132], [68, 133], [68, 139], [68, 151], [68, 158], [68, 172], [68, 212], [68, 213], [68, 216], [68, 217], [68, 223], [68, 227], [68, 241], [68, 250], [68, 290], [69, 72], [69, 86], [69, 107], [69, 125], [69, 137], [69, 153], [69, 175], [69, 191], [69, 203], [69, 211], [69, 220], [69, 241], [69, 243], [69, 246], [69, 247], [69, 251], [69, 269], [69, 284], [69, 291], [69, 292], [69, 295], [70, 76], [70, 79], [70, 84], [70, 99], [70, 108], [70, 111], [70, 125], [70, 178], [70, 185], [70, 193], [70, 196], [70, 207], [70, 208], [70, 222], [70, 225], [70, 227], [70, 229], [70, 249], [70, 255], [70, 278], [70, 299], [71, 72], [71, 84], [71, 85], [71, 105], [71, 109], [71, 131], [71, 141], [71, 154], [71, 173], [71, 193], [71, 196], [71, 197], [71, 199], [71, 200], [71, 229], [71, 236], [71, 240], [71, 241], [71, 250], [71, 258], [71, 267], [71, 293], [72, 111], [72, 115], [72, 145], [72, 147], [72, 155], [72, 167], [72, 220], [72, 228], [72, 274], [72, 280], [72, 293], [73, 84], [73, 88], [73, 94], [73, 101], [73, 122], [73, 129], [73, 193], [73, 203], [73, 218], [73, 228], [73, 232], [73, 237], [73, 243], [73, 250], [73, 254], [73, 260], [73, 261], [73, 284], [73, 294], [73, 296], [74, 95], [74, 116], [74, 132], [74, 135], [74, 141], [74, 142], [74, 170], [74, 171], [74, 174], [74, 187], [74, 196], [74, 235], [74, 251], [74, 260], [74, 267], [74, 278], [74, 288], [74, 289], [75, 110], [75, 116], [75, 133], [75, 153], [75, 206], [75, 221], [75, 225], [75, 236], [75, 255], [75, 265], [75, 274], [75, 292], [75, 294], [75, 295], [76, 94], [76, 104], [76, 110], [76, 117], [76, 130], [76, 138], [76, 145], [76, 156], [76, 157], [76, 171], [76, 175], [76, 177], [76, 183], [76, 188], [76, 191], [76, 219], [76, 226], [76, 227], [76, 236], [76, 266], [76, 273], [76, 285], [76, 286], [76, 287], [77, 81], [77, 116], [77, 144], [77, 164], [77, 172], [77, 192], [77, 194], [77, 202], [77, 209], [77, 210], [77, 213], [77, 218], [77, 219], [77, 238], [77, 243], [77, 267], [77, 276], [77, 283], [77, 285], [78, 101], [78, 106], [78, 107], [78, 116], [78, 119], [78, 120], [78, 124], [78, 126], [78, 132], [78, 136], [78, 167], [78, 177], [78, 178], [78, 181], [78, 185], [78, 188], [78, 216], [78, 231], [78, 235], [78, 255], [78, 272], [78, 273], [79, 85], [79, 99], [79, 114], [79, 122], [79, 132], [79, 195], [79, 207], [79, 213], [79, 229], [79, 236], [79, 272], [80, 107], [80, 112], [80, 136], [80, 151], [80, 215], [80, 217], [80, 244], [80, 249], [80, 290], [80, 292], [81, 82], [81, 113], [81, 128], [81, 135], [81, 136], [81, 146], [81, 165], [81, 170], [81, 172], [81, 208], [81, 225], [81, 266], [81, 294], [82, 84], [82, 88], [82, 90], [82, 92], [82, 94], [82, 99], [82, 102], [82, 106], [82, 116], [82, 134], [82, 143], [82, 150], [82, 152], [82, 167], [82, 179], [82, 180], [82, 182], [82, 184], [82, 185], [82, 186], [82, 187], [82, 194], [82, 195], [82, 199], [82, 202], [82, 210], [82, 215], [82, 219], [82, 231], [82, 237], [82, 239], [82, 244], [82, 245], [82, 268], [82, 271], [82, 273], [82, 278], [82, 279], [82, 289], [83, 92], [83, 129], [83, 153], [83, 165], [83, 173], [83, 177], [83, 186], [83, 206], [83, 218], [83, 227], [83, 241], [83, 269], [83, 294], [84, 129], [84, 154], [84, 169], [84, 188], [84, 233], [84, 236], [84, 253], [84, 270], [85, 86], [85, 95], [85, 96], [85, 98], [85, 111], [85, 117], [85, 120], [85, 133], [85, 139], [85, 149], [85, 155], [85, 176], [85, 187], [85, 192], [85, 193], [85, 197], [85, 204], [85, 207], [85, 213], [85, 252], [85, 265], [86, 87], [86, 97], [86, 105], [86, 109], [86, 118], [86, 122], [86, 132], [86, 135], [86, 154], [86, 157], [86, 166], [86, 171], [86, 172], [86, 173], [86, 186], [86, 226], [86, 227], [86, 235], [86, 241], [87, 168], [87, 198], [87, 202], [87, 217], [87, 260], [87, 277], [87, 285], [87, 287], [87, 289], [87, 294], [88, 108], [88, 109], [88, 148], [88, 171], [88, 178], [88, 202], [88, 221], [88, 240], [88, 246], [88, 259], [88, 268], [88, 298], [89, 126], [89, 147], [89, 168], [89, 213], [89, 220], [89, 251], [89, 260], [89, 272], [89, 273], [89, 285], [90, 96], [90, 108], [90, 125], [90, 131], [90, 133], [90, 176], [90, 208], [90, 231], [90, 244], [90, 256], [90, 275], [90, 280], [90, 285], [90, 299], [91, 127], [91, 162], [91, 184], [91, 191], [91, 194], [91, 210], [91, 233], [91, 245], [91, 257], [91, 272], [91, 288], [91, 289], [92, 94], [92, 111], [92, 121], [92, 123], [92, 125], [92, 130], [92, 146], [92, 150], [92, 181], [92, 191], [92, 221], [92, 245], [92, 280], [92, 285], [92, 287], [93, 112], [93, 117], [93, 119], [93, 131], [93, 157], [93, 162], [93, 183], [93, 214], [93, 228], [93, 253], [93, 287], [93, 288], [93, 293], [94, 99], [94, 142], [94, 168], [94, 223], [94, 247], [94, 250], [94, 260], [94, 284], [94, 290], [95, 106], [95, 108], [95, 114], [95, 135], [95, 139], [95, 150], [95, 155], [95, 165], [95, 170], [95, 175], [95, 185], [95, 203], [95, 244], [95, 268], [95, 282], [95, 285], [95, 292], [95, 299], [96, 125], [96, 127], [96, 148], [96, 173], [96, 179], [96, 188], [96, 192], [96, 228], [96, 237], [96, 239], [96, 281], [96, 283], [96, 284], [96, 295], [97, 159], [97, 168], [97, 210], [97, 232], [97, 289], [98, 101], [98, 121], [98, 130], [98, 131], [98, 136], [98, 163], [98, 168], [98, 190], [98, 193], [98, 195], [98, 206], [98, 211], [98, 213], [98, 228], [98, 230], [98, 233], [98, 260], [98, 293], [98, 294], [99, 106], [99, 132], [99, 144], [99, 148], [99, 149], [99, 157], [99, 159], [99, 169], [99, 180], [99, 181], [99, 194], [99, 197], [99, 198], [99, 211], [99, 225], [99, 238], [99, 258], [99, 263], [100, 109], [100, 118], [100, 137], [100, 158], [100, 203], [100, 218], [100, 253], [100, 254], [100, 258], [100, 289], [101, 129], [101, 136], [101, 164], [101, 173], [101, 176], [101, 193], [101, 198], [101, 209], [101, 216], [101, 217], [101, 225], [101, 250], [101, 261], [101, 290], [102, 131], [102, 134], [102, 153], [102, 158], [102, 165], [102, 176], [102, 190], [102, 231], [102, 240], [102, 283], [102, 299], [103, 122], [103, 126], [103, 131], [103, 147], [103, 155], [103, 158], [103, 189], [103, 231], [103, 235], [103, 240], [103, 268], [103, 270], [103, 274], [103, 279], [103, 290], [103, 291], [103, 293], [103, 297], [103, 298], [104, 109], [104, 110], [104, 116], [104, 121], [104, 129], [104, 179], [104, 182], [104, 187], [104, 189], [104, 192], [104, 223], [105, 112], [105, 121], [105, 123], [105, 131], [105, 148], [105, 150], [105, 153], [105, 165], [105, 221], [105, 232], [105, 253], [105, 262], [105, 275], [105, 276], [105, 288], [106, 109], [106, 129], [106, 137], [106, 198], [106, 199], [106, 247], [106, 252], [106, 261], [106, 297], [107, 124], [107, 130], [107, 158], [107, 161], [107, 171], [107, 213], [107, 216], [107, 219], [107, 222], [107, 239], [107, 247], [107, 249], [107, 250], [107, 257], [107, 272], [107, 295], [108, 137], [108, 158], [108, 181], [108, 191], [108, 207], [108, 220], [108, 222], [108, 247], [108, 260], [108, 278], [108, 286], [109, 155], [109, 212], [109, 230], [109, 257], [109, 270], [109, 288], [109, 290], [110, 136], [110, 170], [110, 194], [110, 206], [110, 228], [110, 231], [110, 250], [110, 257], [110, 275], [110, 284], [111, 124], [111, 131], [111, 138], [111, 181], [111, 230], [111, 232], [111, 237], [111, 263], [111, 271], [111, 273], [111, 279], [111, 285], [112, 143], [112, 208], [112, 209], [112, 222], [112, 234], [112, 240], [112, 244], [112, 260], [112, 262], [112, 283], [112, 296], [113, 115], [113, 145], [113, 155], [113, 176], [113, 178], [113, 183], [113, 195], [113, 197], [113, 207], [113, 226], [113, 263], [113, 282], [113, 289], [114, 122], [114, 139], [114, 152], [114, 154], [114, 171], [114, 174], [114, 186], [114, 196], [114, 205], [114, 211], [114, 214], [114, 266], [114, 267], [114, 277], [114, 280], [114, 281], [114, 282], [114, 285], [114, 287], [114, 293], [114, 298], [115, 123], [115, 138], [115, 142], [115, 150], [115, 162], [115, 201], [115, 238], [115, 248], [115, 249], [115, 264], [115, 268], [115, 271], [115, 281], [116, 119], [116, 127], [116, 161], [116, 191], [116, 194], [116, 206], [116, 222], [116, 233], [116, 234], [116, 241], [116, 242], [116, 247], [116, 266], [116, 294], [116, 299], [117, 118], [117, 122], [117, 123], [117, 126], [117, 128], [117, 138], [117, 139], [117, 149], [117, 174], [117, 176], [117, 185], [117, 208], [117, 238], [117, 277], [117, 281], [117, 287], [118, 158], [118, 180], [118, 200], [118, 205], [118, 229], [118, 260], [118, 266], [118, 278], [119, 121], [119, 165], [119, 221], [119, 235], [119, 242], [119, 250], [119, 264], [119, 271], [119, 294], [120, 124], [120, 137], [120, 148], [120, 217], [120, 230], [120, 231], [120, 234], [120, 251], [120, 252], [120, 262], [120, 276], [120, 287], [120, 296], [121, 125], [121, 127], [121, 144], [121, 152], [121, 168], [121, 193], [121, 252], [121, 256], [121, 260], [121, 269], [121, 275], [121, 286], [121, 289], [122, 153], [122, 160], [122, 181], [122, 209], [122, 221], [122, 223], [122, 225], [122, 246], [122, 261], [122, 262], [122, 264], [122, 273], [122, 283], [122, 285], [123, 132], [123, 141], [123, 160], [123, 180], [123, 183], [123, 195], [123, 216], [123, 249], [123, 272], [123, 276], [123, 290], [123, 297], [124, 134], [124, 158], [124, 159], [124, 189], [124, 208], [124, 260], [124, 261], [124, 268], [125, 129], [125, 130], [125, 153], [125, 167], [125, 175], [125, 190], [125, 205], [125, 207], [125, 227], [125, 237], [125, 248], [125, 256], [125, 271], [125, 276], [125, 294], [125, 299], [126, 127], [126, 135], [126, 150], [126, 164], [126, 205], [126, 243], [126, 244], [126, 261], [126, 269], [126, 275], [126, 299], [127, 136], [127, 141], [127, 168], [127, 207], [127, 217], [127, 219], [127, 290], [128, 165], [128, 176], [128, 180], [128, 184], [128, 204], [128, 217], [128, 220], [128, 229], [128, 254], [128, 288], [129, 133], [129, 140], [129, 148], [129, 150], [129, 162], [129, 171], [129, 202], [129, 206], [129, 221], [129, 236], [129, 246], [129, 248], [129, 260], [129, 269], [129, 272], [129, 281], [129, 284], [130, 131], [130, 183], [130, 217], [130, 259], [130, 276], [130, 277], [130, 289], [131, 160], [131, 174], [131, 179], [131, 236], [131, 248], [131, 260], [131, 272], [131, 277], [132, 167], [132, 168], [132, 178], [132, 194], [132, 241], [132, 250], [132, 255], [132, 282], [132, 296], [132, 297], [133, 141], [133, 147], [133, 154], [133, 162], [133, 163], [133, 177], [133, 181], [133, 185], [133, 202], [133, 213], [133, 227], [133, 232], [133, 239], [133, 260], [133, 263], [133, 266], [133, 291], [133, 298], [134, 135], [134, 145], [134, 146], [134, 173], [134, 189], [134, 233], [134, 240], [134, 251], [134, 267], [134, 270], [134, 289], [135, 149], [135, 156], [135, 164], [135, 171], [135, 202], [135, 230], [135, 249], [135, 254], [135, 295], [136, 139], [136, 148], [136, 181], [136, 183], [136, 201], [136, 207], [136, 228], [136, 235], [136, 255], [136, 284], [137, 140], [137, 141], [137, 155], [137, 184], [137, 192], [137, 195], [137, 204], [137, 272], [137, 281], [137, 282], [137, 298], [138, 204], [138, 217], [138, 225], [138, 245], [138, 268], [138, 270], [138, 281], [139, 142], [139, 147], [139, 167], [139, 170], [139, 238], [139, 241], [139, 249], [139, 255], [139, 277], [140, 143], [140, 144], [140, 147], [140, 157], [140, 191], [140, 192], [140, 215], [140, 222], [140, 250], [140, 256], [140, 268], [140, 269], [140, 273], [140, 276], [140, 296], [141, 175], [141, 179], [141, 185], [141, 200], [141, 202], [141, 214], [141, 220], [141, 247], [141, 271], [142, 151], [142, 182], [142, 267], [142, 288], [143, 151], [143, 175], [143, 194], [143, 195], [143, 200], [143, 229], [143, 231], [143, 256], [143, 257], [143, 266], [143, 274], [144, 179], [144, 221], [144, 231], [144, 244], [144, 248], [144, 259], [144, 272], [144, 275], [144, 288], [144, 295], [144, 298], [145, 211], [145, 223], [145, 235], [145, 276], [145, 285], [145, 289], [145, 292], [146, 166], [146, 174], [146, 212], [146, 219], [146, 230], [146, 245], [146, 249], [146, 263], [146, 271], [146, 275], [146, 298], [147, 161], [147, 185], [147, 212], [147, 225], [147, 236], [147, 266], [147, 274], [147, 289], [148, 160], [148, 175], [148, 176], [148, 210], [148, 212], [148, 217], [148, 240], [148, 299], [149, 179], [149, 194], [149, 255], [149, 265], [149, 271], [150, 173], [150, 175], [150, 193], [150, 203], [150, 226], [150, 238], [150, 257], [150, 261], [150, 266], [150, 273], [150, 281], [151, 152], [151, 153], [151, 178], [151, 198], [151, 202], [151, 208], [151, 212], [151, 220], [151, 250], [151, 253], [151, 257], [151, 277], [151, 288], [151, 292], [152, 180], [152, 226], [152, 241], [152, 266], [153, 160], [153, 171], [153, 182], [153, 226], [153, 227], [153, 231], [153, 237], [153, 243], [153, 256], [153, 287], [154, 171], [154, 172], [154, 191], [154, 195], [154, 196], [154, 204], [154, 224], [154, 225], [154, 242], [154, 284], [155, 163], [155, 165], [155, 191], [155, 283], [155, 288], [156, 184], [156, 205], [156, 223], [156, 265], [156, 279], [156, 288], [157, 275], [157, 293], [158, 189], [158, 196], [158, 217], [158, 229], [158, 245], [158, 260], [158, 288], [159, 162], [159, 164], [159, 173], [159, 176], [159, 200], [159, 210], [159, 220], [159, 226], [159, 245], [159, 247], [159, 250], [159, 258], [159, 259], [159, 285], [159, 289], [159, 292], [159, 296], [160, 167], [160, 193], [160, 227], [160, 233], [160, 256], [160, 261], [160, 274], [161, 163], [161, 165], [161, 201], [161, 211], [161, 228], [161, 254], [161, 264], [161, 265], [161, 281], [161, 282], [161, 296], [162, 183], [162, 185], [162, 191], [162, 204], [162, 209], [162, 238], [162, 270], [162, 290], [163, 178], [163, 195], [163, 200], [163, 203], [163, 224], [163, 225], [163, 241], [163, 251], [163, 255], [163, 260], [163, 299], [164, 172], [164, 176], [164, 211], [164, 221], [164, 270], [164, 284], [164, 288], [164, 296], [164, 297], [165, 173], [165, 174], [165, 196], [165, 212], [165, 216], [165, 264], [165, 270], [166, 187], [166, 192], [166, 216], [166, 248], [166, 254], [166, 258], [166, 268], [166, 280], [166, 285], [166, 287], [167, 231], [168, 196], [168, 210], [168, 212], [168, 249], [168, 266], [168, 288], [168, 295], [169, 172], [169, 190], [169, 193], [169, 202], [169, 215], [169, 237], [169, 258], [169, 264], [169, 287], [169, 289], [169, 291], [170, 172], [170, 173], [170, 176], [170, 191], [170, 194], [170, 221], [170, 266], [170, 279], [170, 288], [171, 177], [171, 180], [171, 186], [171, 193], [171, 221], [171, 233], [171, 249], [171, 251], [171, 260], [171, 272], [171, 299], [172, 182], [172, 202], [172, 210], [172, 212], [172, 220], [172, 223], [172, 230], [172, 250], [172, 268], [172, 269], [172, 273], [172, 274], [172, 290], [173, 179], [173, 185], [173, 187], [173, 191], [173, 196], [173, 216], [173, 233], [173, 244], [173, 249], [173, 255], [173, 259], [173, 290], [173, 296], [174, 179], [174, 191], [174, 201], [174, 212], [174, 215], [174, 216], [174, 229], [174, 231], [174, 232], [174, 245], [174, 268], [174, 273], [174, 283], [174, 297], [174, 298], [175, 197], [175, 245], [175, 251], [175, 264], [175, 265], [175, 269], [175, 275], [175, 294], [176, 205], [176, 208], [176, 220], [176, 231], [176, 236], [176, 237], [176, 247], [176, 263], [176, 281], [177, 178], [177, 180], [177, 202], [177, 224], [177, 234], [177, 235], [177, 243], [177, 245], [177, 261], [178, 203], [178, 213], [178, 246], [178, 259], [178, 281], [179, 196], [179, 203], [179, 205], [179, 212], [179, 224], [179, 225], [179, 247], [179, 283], [179, 290], [180, 189], [180, 201], [180, 205], [180, 223], [180, 284], [180, 293], [180, 294], [181, 212], [181, 216], [181, 234], [181, 256], [181, 285], [181, 294], [182, 192], [182, 236], [182, 245], [182, 257], [182, 281], [183, 186], [183, 188], [183, 203], [183, 211], [183, 257], [183, 272], [183, 277], [183, 283], [184, 196], [184, 241], [184, 247], [184, 248], [184, 284], [185, 190], [185, 201], [185, 247], [185, 264], [185, 288], [186, 193], [186, 204], [186, 291], [186, 293], [187, 223], [187, 227], [187, 229], [187, 239], [187, 249], [187, 250], [187, 279], [187, 280], [187, 292], [187, 294], [187, 296], [188, 189], [188, 198], [188, 229], [188, 230], [188, 256], [188, 259], [188, 269], [189, 217], [189, 233], [189, 258], [189, 285], [189, 290], [189, 294], [190, 197], [190, 198], [190, 239], [190, 250], [191, 192], [191, 200], [191, 232], [191, 236], [191, 256], [191, 258], [191, 266], [192, 194], [192, 205], [192, 211], [192, 212], [192, 215], [192, 251], [192, 260], [192, 265], [192, 274], [192, 299], [193, 196], [193, 215], [193, 217], [193, 237], [193, 251], [193, 278], [193, 296], [194, 211], [194, 216], [194, 229], [194, 242], [194, 260], [194, 269], [195, 197], [195, 212], [195, 238], [195, 269], [195, 283], [195, 299], [196, 213], [196, 219], [196, 228], [196, 238], [196, 248], [196, 255], [196, 257], [196, 258], [196, 298], [197, 205], [197, 238], [197, 245], [197, 260], [197, 262], [197, 264], [197, 286], [198, 271], [198, 273], [198, 289], [198, 293], [199, 203], [199, 235], [200, 215], [200, 260], [200, 269], [200, 299], [201, 211], [201, 234], [201, 238], [201, 240], [201, 259], [201, 271], [201, 289], [201, 292], [202, 208], [202, 229], [202, 245], [202, 246], [202, 248], [202, 251], [202, 253], [202, 265], [202, 289], [203, 220], [203, 230], [203, 235], [204, 216], [204, 247], [204, 252], [204, 275], [204, 285], [204, 287], [204, 295], [204, 298], [205, 207], [205, 211], [205, 228], [205, 240], [205, 253], [205, 260], [205, 282], [206, 221], [206, 233], [206, 256], [206, 284], [207, 223], [207, 241], [207, 262], [207, 269], [207, 278], [207, 281], [207, 282], [207, 292], [207, 294], [208, 220], [208, 235], [208, 249], [209, 220], [209, 222], [209, 227], [209, 254], [209, 255], [209, 260], [209, 270], [209, 281], [210, 218], [210, 230], [210, 235], [210, 245], [210, 253], [210, 281], [210, 288], [210, 291], [210, 293], [211, 226], [211, 229], [211, 254], [211, 267], [211, 270], [212, 213], [212, 214], [212, 219], [212, 253], [212, 274], [212, 281], [213, 219], [213, 228], [213, 245], [213, 260], [213, 263], [214, 215], [214, 223], [214, 234], [214, 236], [214, 250], [214, 263], [214, 269], [214, 272], [214, 285], [215, 244], [215, 260], [215, 267], [215, 275], [215, 290], [216, 224], [216, 225], [216, 229], [216, 234], [216, 243], [216, 247], [216, 273], [217, 227], [217, 230], [217, 238], [217, 243], [217, 244], [217, 245], [217, 260], [217, 281], [217, 299], [218, 222], [218, 225], [218, 260], [218, 277], [218, 289], [219, 224], [219, 233], [219, 245], [219, 250], [219, 258], [219, 265], [219, 283], [220, 238], [220, 247], [220, 263], [220, 266], [220, 269], [220, 278], [220, 293], [221, 232], [221, 241], [221, 265], [221, 274], [221, 278], [222, 233], [222, 234], [222, 249], [222, 268], [222, 280], [222, 282], [223, 230], [223, 248], [223, 264], [223, 271], [223, 278], [223, 292], [224, 241], [224, 267], [224, 288], [225, 249], [226, 247], [226, 250], [226, 266], [226, 287], [226, 294], [227, 252], [227, 262], [227, 293], [228, 235], [228, 244], [228, 251], [228, 284], [228, 285], [228, 294], [229, 249], [229, 254], [229, 259], [229, 291], [230, 236], [230, 240], [230, 243], [230, 244], [230, 257], [230, 270], [230, 275], [230, 292], [230, 297], [231, 241], [231, 272], [232, 245], [232, 253], [232, 258], [232, 264], [232, 270], [232, 275], [232, 276], [232, 289], [232, 297], [233, 283], [234, 235], [234, 237], [234, 253], [234, 278], [234, 282], [234, 288], [235, 269], [235, 293], [235, 296], [236, 241], [236, 268], [237, 266], [237, 275], [237, 295], [237, 297], [238, 263], [238, 267], [239, 240], [239, 278], [239, 295], [240, 265], [240, 270], [240, 281], [241, 243], [241, 253], [241, 296], [241, 298], [242, 252], [242, 277], [242, 280], [242, 281], [242, 286], [243, 249], [243, 251], [243, 256], [243, 261], [243, 294], [243, 295], [244, 259], [244, 263], [244, 273], [244, 274], [244, 283], [244, 292], [244, 295], [245, 250], [245, 264], [245, 279], [245, 288], [245, 289], [246, 257], [246, 269], [246, 272], [247, 253], [247, 275], [247, 287], [247, 290], [247, 296], [248, 252], [248, 288], [249, 287], [249, 290], [249, 296], [250, 255], [251, 258], [251, 285], [251, 286], [251, 291], [252, 255], [254, 261], [254, 288], [254, 297], [255, 265], [255, 266], [255, 273], [255, 278], [256, 257], [256, 260], [257, 275], [257, 286], [257, 293], [258, 289], [259, 289], [260, 261], [260, 276], [260, 286], [261, 295], [262, 266], [262, 280], [262, 281], [262, 297], [263, 275], [264, 268], [264, 288], [265, 268], [265, 287], [265, 289], [265, 298], [266, 267], [266, 269], [266, 294], [267, 275], [267, 281], [268, 276], [269, 294], [269, 299], [270, 271], [270, 283], [270, 298], [271, 275], [271, 280], [271, 289], [273, 286], [273, 290], [273, 298], [274, 279], [274, 287], [275, 280], [275, 298], [277, 280], [277, 292], [279, 294], [280, 293], [281, 286], [281, 291], [281, 298], [281, 299], [282, 288], [283, 288], [289, 299], [291, 299]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l6-s6/tests/run.py b/tasks/construct-nppc-dominating-set-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-dominating-set-l6-s6/tests/test.sh b/tasks/construct-nppc-dominating-set-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quad-diophantine-l2-s8/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quad-diophantine-l2-s8/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d60ae11d118784fc4d3bbe2995710d61a0f44e97 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"a": 74, "b": 830, "c": 217514, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s8/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6f312cc4fbe188cc4e489a406fa2e6d1844c2666 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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": 34, "y": 159} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l2-s8/tests/check.py b/tasks/construct-nppc-quad-diophantine-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s8/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l2-s8/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d60ae11d118784fc4d3bbe2995710d61a0f44e97 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"a": 74, "b": 830, "c": 217514, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s8/tests/run.py b/tasks/construct-nppc-quad-diophantine-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quad-diophantine-l2-s8/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quad-diophantine-l6-s0/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l6-s0/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..299a4da68cb2a2836a8fa51c2ae59683eecffd13 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"a": 5877870180, "b": 3987024243, "c": 166435860223745549608143329040, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s0/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..733c08e47472a67ce15e562bb6f948b4e133b432 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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": 5321247480, "y": 5743183280} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l6-s0/tests/check.py b/tasks/construct-nppc-quad-diophantine-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s0/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l6-s0/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..299a4da68cb2a2836a8fa51c2ae59683eecffd13 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"a": 5877870180, "b": 3987024243, "c": 166435860223745549608143329040, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s0/tests/run.py b/tasks/construct-nppc-quad-diophantine-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l6-s0/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-nppc-quad-diophantine-l6-s7/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l6-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quad-diophantine-l6-s7/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4786dd578f86efcec235bd9c039abf3517db6704 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s7/environment/instance.json @@ -0,0 +1 @@ +{"a": 8499667983, "b": 7980065863, "c": 148468647729573796485120421324, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s7/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l6-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..eceffa5f82fd26212e4c071f816b7b9186d58ffe --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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": 4179423648, "y": 1670742484} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l6-s7/tests/check.py b/tasks/construct-nppc-quad-diophantine-l6-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s7/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l6-s7/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l6-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4786dd578f86efcec235bd9c039abf3517db6704 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s7/tests/instance.json @@ -0,0 +1 @@ +{"a": 8499667983, "b": 7980065863, "c": 148468647729573796485120421324, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l6-s7/tests/run.py b/tasks/construct-nppc-quad-diophantine-l6-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quad-diophantine-l6-s7/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l6-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l6-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s8/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l2-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s8/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7ffd3e1a94bbb5c6540c5a5c5c47cbef251050f6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s8/environment/instance.json @@ -0,0 +1 @@ +{"a": 2586, "b": 5709, "c": 11811, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s8/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l2-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4a5c753a07b57ffddfc9a0f2ecb1707876970efe --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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": 9063} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s8/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l2-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s8/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s8/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7ffd3e1a94bbb5c6540c5a5c5c47cbef251050f6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s8/tests/instance.json @@ -0,0 +1 @@ +{"a": 2586, "b": 5709, "c": 11811, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s8/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l2-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s8/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l2-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s0/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l6-s0/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2df5df8c1e0e144cff8c779aac73c429741d1b46 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"a": 69949447710857463966058429949540960708984393755, "b": 116752723035413833583551890218610134433309379219, "c": 170690396901712565523618602570108501781620541, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s0/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..990d3f52b6f333f2fd78dc47d928a399c2724e47 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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": 167764679954075549326197778087457773127852696} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s0/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s0/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s0/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2df5df8c1e0e144cff8c779aac73c429741d1b46 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"a": 69949447710857463966058429949540960708984393755, "b": 116752723035413833583551890218610134433309379219, "c": 170690396901712565523618602570108501781620541, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s0/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l6-s0/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-nppc-quadratic-congruence-l6-s7/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l6-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s7/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..57fb7196eecbcada1a045ad9cee399212feb49a0 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s7/environment/instance.json @@ -0,0 +1 @@ +{"a": 153879964348175119621192249586863784264926265037, "b": 258583211762801849157885436569255510813072484469, "c": 33159055645726876205987857463064569187576621730, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s7/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l6-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..095390abee6fe2d9fef7e07ef533c72bb73aa014 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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": 33146452745072971592474474663902396844682688447} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s7/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l6-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s7/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s7/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l6-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..57fb7196eecbcada1a045ad9cee399212feb49a0 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s7/tests/instance.json @@ -0,0 +1 @@ +{"a": 153879964348175119621192249586863784264926265037, "b": 258583211762801849157885436569255510813072484469, "c": 33159055645726876205987857463064569187576621730, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s7/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l6-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l6-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quadratic-congruence-l6-s7/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l6-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-rg-graph-color-l3-s6/environment/Dockerfile b/tasks/construct-rg-graph-color-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l3-s6/environment/instance.json b/tasks/construct-rg-graph-color-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4bfff175071a22b1f46968402a8a7dace7ea73bd --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 3, "edges": [[0, 5], [1, 2], [3, 5], [3, 7], [4, 5], [4, 7], [4, 8], [4, 9], [5, 6], [6, 8]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l3-s6/solution/solve.sh b/tasks/construct-rg-graph-color-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1e0375008d262cab2f7448ec7f245e8d53239187 --- /dev/null +++ b/tasks/construct-rg-graph-color-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' +{"coloring": [1, 1, 2, 1, 1, 2, 1, 2, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-rg-graph-color-l3-s6/tests/check.py b/tasks/construct-rg-graph-color-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e9328912405d1c894970c90415be62bf9556ed36 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s6/tests/check.py @@ -0,0 +1,13 @@ +"""Proper colouring with colours 1..k (Reasoning Gym graph_color, Apache-2.0). Any valid colouring. +Upstream note: its verifier checks `color in allowed_colors`, so True (== 1) and 1.0 were accepted as +colours, and extra keys were ignored. Here colours must be ints in 1..k, one per vertex.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_vertices"], inst["num_colors"] + c = int_list(ans.get("coloring"), n, 1, k, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"adjacent vertices {u} and {v} share colour {c[u]}") + return None, {} diff --git a/tasks/construct-rg-graph-color-l3-s6/tests/instance.json b/tasks/construct-rg-graph-color-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4bfff175071a22b1f46968402a8a7dace7ea73bd --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 3, "edges": [[0, 5], [1, 2], [3, 5], [3, 7], [4, 5], [4, 7], [4, 8], [4, 9], [5, 6], [6, 8]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l3-s6/tests/run.py b/tasks/construct-rg-graph-color-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l3-s6/tests/test.sh b/tasks/construct-rg-graph-color-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l3-s8/environment/Dockerfile b/tasks/construct-rg-graph-color-l3-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l3-s8/environment/instance.json b/tasks/construct-rg-graph-color-l3-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dddc85cea787e8eeb5fe33e6c951d887f8cc1a33 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 3, "edges": [[1, 9], [2, 6], [2, 7], [3, 5], [3, 6], [4, 7], [8, 9]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l3-s8/solution/solve.sh b/tasks/construct-rg-graph-color-l3-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0543710a078c670d4828dc4e236fdbb5c49c996a --- /dev/null +++ b/tasks/construct-rg-graph-color-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' +{"coloring": [1, 1, 1, 1, 1, 2, 2, 2, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rg-graph-color-l3-s8/tests/check.py b/tasks/construct-rg-graph-color-l3-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e9328912405d1c894970c90415be62bf9556ed36 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s8/tests/check.py @@ -0,0 +1,13 @@ +"""Proper colouring with colours 1..k (Reasoning Gym graph_color, Apache-2.0). Any valid colouring. +Upstream note: its verifier checks `color in allowed_colors`, so True (== 1) and 1.0 were accepted as +colours, and extra keys were ignored. Here colours must be ints in 1..k, one per vertex.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_vertices"], inst["num_colors"] + c = int_list(ans.get("coloring"), n, 1, k, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"adjacent vertices {u} and {v} share colour {c[u]}") + return None, {} diff --git a/tasks/construct-rg-graph-color-l3-s8/tests/instance.json b/tasks/construct-rg-graph-color-l3-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dddc85cea787e8eeb5fe33e6c951d887f8cc1a33 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 3, "edges": [[1, 9], [2, 6], [2, 7], [3, 5], [3, 6], [4, 7], [8, 9]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l3-s8/tests/run.py b/tasks/construct-rg-graph-color-l3-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-graph-color-l3-s8/tests/test.sh b/tasks/construct-rg-graph-color-l3-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-rg-intermediate-integration-l1-s2/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s2/environment/instance.json b/tasks/construct-rg-intermediate-integration-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..935117b7d36d2d751221a9512fe9e3eb47ff6630 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "(9*x + 8)**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-s2/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2ab2a9617d134d437f12cc30369705f5591cb3b2 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "729*x**4/4 + 648*x**3 + 864*x**2 + 512*x + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l1-s2/tests/check.py b/tasks/construct-rg-intermediate-integration-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s2/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-intermediate-integration-l1-s2/tests/instance.json b/tasks/construct-rg-intermediate-integration-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..935117b7d36d2d751221a9512fe9e3eb47ff6630 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "(9*x + 8)**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-s2/tests/run.py b/tasks/construct-rg-intermediate-integration-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s2/tests/test.sh b/tasks/construct-rg-intermediate-integration-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s3/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s3/environment/instance.json b/tasks/construct-rg-intermediate-integration-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..136ec487519adac57dd07e3279f0e7f711b9d24c --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "(4*x - 10)**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-s3/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5c8d34111442e38204f486bbbf8055848d1cfd04 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "256*x**5/5 - 640*x**4 + 3200*x**3 - 8000*x**2 + 10000*x + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l1-s3/tests/check.py b/tasks/construct-rg-intermediate-integration-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s3/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-intermediate-integration-l1-s3/tests/instance.json b/tasks/construct-rg-intermediate-integration-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..136ec487519adac57dd07e3279f0e7f711b9d24c --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "(4*x - 10)**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-s3/tests/run.py b/tasks/construct-rg-intermediate-integration-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l1-s3/tests/test.sh b/tasks/construct-rg-intermediate-integration-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-simple-integration-l3-s0/environment/Dockerfile b/tasks/construct-rg-simple-integration-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l3-s0/environment/instance.json b/tasks/construct-rg-simple-integration-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1015265fb1941c53ca82d7620efee84e484d512c --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-2*x**4 - 4*x**3 + 3*x**2", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l3-s0/solution/solve.sh b/tasks/construct-rg-simple-integration-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..549441c16c21063ec7b4e418aae2f7ad793074f9 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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' +{"antiderivative": "-2*x**5/5 - x**4 + x**3 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l3-s0/tests/check.py b/tasks/construct-rg-simple-integration-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s0/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-simple-integration-l3-s0/tests/instance.json b/tasks/construct-rg-simple-integration-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1015265fb1941c53ca82d7620efee84e484d512c --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-2*x**4 - 4*x**3 + 3*x**2", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l3-s0/tests/run.py b/tasks/construct-rg-simple-integration-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l3-s0/tests/test.sh b/tasks/construct-rg-simple-integration-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l3-s9/environment/Dockerfile b/tasks/construct-rg-simple-integration-l3-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l3-s9/environment/instance.json b/tasks/construct-rg-simple-integration-l3-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f5b2c7da29b4c5f166b69da2ed59b43e20e48af5 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s9/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "9*x**8 - 35*x**6/4 + 45*x**4/8 + x**2/2", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l3-s9/solution/solve.sh b/tasks/construct-rg-simple-integration-l3-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..505474bd6a27b97ffad170de382b67bda06b74e5 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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' +{"antiderivative": "x**9 - 5*x**7/4 + 9*x**5/8 + x**3/6 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l3-s9/tests/check.py b/tasks/construct-rg-simple-integration-l3-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-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-simple-integration-l3-s9/tests/instance.json b/tasks/construct-rg-simple-integration-l3-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f5b2c7da29b4c5f166b69da2ed59b43e20e48af5 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s9/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "9*x**8 - 35*x**6/4 + 45*x**4/8 + x**2/2", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l3-s9/tests/run.py b/tasks/construct-rg-simple-integration-l3-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l3-s9/tests/test.sh b/tasks/construct-rg-simple-integration-l3-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-antiderivative-l2-s0/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-antiderivative-l2-s0/environment/instance.json b/tasks/construct-rlve-antiderivative-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8b0cac3c72254d29a9a1a7967b1e09b4fef5522b --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "7/(12*x**(5/12))", "max_ops": 28, "max_len": 580, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l2-s0/solution/solve.sh b/tasks/construct-rlve-antiderivative-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..43e107a098f5c8e5014dba684e737f2192cb0d8b --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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' +{"F": "x**(7/12)"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l2-s0/tests/check.py b/tasks/construct-rlve-antiderivative-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s0/tests/check.py @@ -0,0 +1,107 @@ +"""Antiderivative check. The answer string is tokenised against a whitelist (x, integers, + - * / ** ( ) and a few +elementary functions) before sympy parses it, so no Python eval of untrusted text and no `integrate`/`Integral`.""" +import re +import signal + +import sympy +from sympy.parsing.sympy_parser import auto_number, parse_expr + +from run import Invalid + +x = sympy.Symbol("x") +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "exp": sympy.exp, "log": sympy.log, + "sqrt": sympy.sqrt, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "E": sympy.E, "pi": sympy.pi, "x": x} +TOK = re.compile(r"\s*(?:(\d+)|([A-Za-z]+)|(\*\*|[-+*/()]))") +NPTS = 40 + + +def safe_parse(s, max_len): + if not isinstance(s, str) or not s.strip(): + raise Invalid("F must be a non-empty string") + if len(s) > max_len: + raise Invalid("expression too long") + pos = 0 + while pos < len(s): + m = TOK.match(s, pos) + if not m or m.end() == pos: + if s[pos:].strip() == "": + break + raise Invalid(f"illegal character near position {pos}") + if m.group(1) and len(m.group(1)) > 12: + raise Invalid("integer literal too long") + if m.group(2) and m.group(2) not in FUNCS: + raise Invalid(f"unknown name {m.group(2)!r}") + pos = m.end() + try: + e = parse_expr(s, local_dict=dict(FUNCS), global_dict={"__builtins__": {}, "Integer": sympy.Integer}, + transformations=(auto_number,)) + except Invalid: + raise + except Exception as ex: + raise Invalid(f"cannot parse F: {type(ex).__name__}") + if not isinstance(e, sympy.Expr): + raise Invalid("F is not an expression") + if e.free_symbols - {x}: + raise Invalid("F may only contain the variable x") + return e + + +def _val(e, pt): + v = e.evalf(40, subs={x: pt}) + if not v.is_number or v.has(sympy.zoo, sympy.nan, sympy.oo, -sympy.oo): + return None + return v + + +class _Timeout(Exception): + pass + + +def _alarm(*_): + raise _Timeout() + + +def check(inst, ans): + old = None + try: + old = signal.signal(signal.SIGALRM, _alarm) + signal.alarm(40) + except ValueError: # not in main thread + old = None + try: + return _check(inst, ans) + except _Timeout: + raise Invalid("evaluation timed out") + except RecursionError: + raise Invalid("expression too deep") + finally: + if old is not None: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + + +def _check(inst, ans): + F = safe_parse(ans.get("F"), inst["max_len"]) + if sympy.count_ops(F) > inst["max_ops"]: + raise Invalid("expression too complex") + if any(isinstance(a, sympy.Rational) and max(abs(a.p), abs(a.q)) > 10 ** 12 for a in F.atoms(sympy.Rational)): + raise Invalid("numeric constants too large") + D = sympy.diff(F, x) + f = sympy.sympify(inst["f_prime"]) # trusted instance data + ok = 0 + for k in range(NPTS): + pt = sympy.Rational(2 * k + 1, NPTS // 2 * 2) * 2 - 2 + sympy.Rational(1, 997) + vf = _val(f, pt) + if vf is None: + continue + vd = _val(D, pt) + if vd is None: + continue + err = sympy.Abs(vd - vf).evalf(40) + if err > sympy.Float("1e-20", 40) * (1 + sympy.Abs(vf).evalf(40)): + raise Invalid(f"F'(x) != f(x) at x = {float(pt):.4f}") + ok += 1 + if ok < NPTS // 4: + raise Invalid("F' could not be compared with f on enough test points") + return None, {"points_checked": ok} diff --git a/tasks/construct-rlve-antiderivative-l2-s0/tests/instance.json b/tasks/construct-rlve-antiderivative-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8b0cac3c72254d29a9a1a7967b1e09b4fef5522b --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "7/(12*x**(5/12))", "max_ops": 28, "max_len": 580, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l2-s0/tests/run.py b/tasks/construct-rlve-antiderivative-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-antiderivative-l2-s0/tests/test.sh b/tasks/construct-rlve-antiderivative-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-antiderivative-l2-s7/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l2-s7/environment/instance.json b/tasks/construct-rlve-antiderivative-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cff6ab6bf14b64746e927df54b6e342bdb406192 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "x*(2*x + 4) + (x + 2)**2", "max_ops": 32, "max_len": 640, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l2-s7/solution/solve.sh b/tasks/construct-rlve-antiderivative-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c9d8282707a63f2c9e60c8ca9dff4be4d9bce225 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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' +{"F": "x*(x + 2)**2"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l2-s7/tests/check.py b/tasks/construct-rlve-antiderivative-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s7/tests/check.py @@ -0,0 +1,107 @@ +"""Antiderivative check. The answer string is tokenised against a whitelist (x, integers, + - * / ** ( ) and a few +elementary functions) before sympy parses it, so no Python eval of untrusted text and no `integrate`/`Integral`.""" +import re +import signal + +import sympy +from sympy.parsing.sympy_parser import auto_number, parse_expr + +from run import Invalid + +x = sympy.Symbol("x") +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "exp": sympy.exp, "log": sympy.log, + "sqrt": sympy.sqrt, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "E": sympy.E, "pi": sympy.pi, "x": x} +TOK = re.compile(r"\s*(?:(\d+)|([A-Za-z]+)|(\*\*|[-+*/()]))") +NPTS = 40 + + +def safe_parse(s, max_len): + if not isinstance(s, str) or not s.strip(): + raise Invalid("F must be a non-empty string") + if len(s) > max_len: + raise Invalid("expression too long") + pos = 0 + while pos < len(s): + m = TOK.match(s, pos) + if not m or m.end() == pos: + if s[pos:].strip() == "": + break + raise Invalid(f"illegal character near position {pos}") + if m.group(1) and len(m.group(1)) > 12: + raise Invalid("integer literal too long") + if m.group(2) and m.group(2) not in FUNCS: + raise Invalid(f"unknown name {m.group(2)!r}") + pos = m.end() + try: + e = parse_expr(s, local_dict=dict(FUNCS), global_dict={"__builtins__": {}, "Integer": sympy.Integer}, + transformations=(auto_number,)) + except Invalid: + raise + except Exception as ex: + raise Invalid(f"cannot parse F: {type(ex).__name__}") + if not isinstance(e, sympy.Expr): + raise Invalid("F is not an expression") + if e.free_symbols - {x}: + raise Invalid("F may only contain the variable x") + return e + + +def _val(e, pt): + v = e.evalf(40, subs={x: pt}) + if not v.is_number or v.has(sympy.zoo, sympy.nan, sympy.oo, -sympy.oo): + return None + return v + + +class _Timeout(Exception): + pass + + +def _alarm(*_): + raise _Timeout() + + +def check(inst, ans): + old = None + try: + old = signal.signal(signal.SIGALRM, _alarm) + signal.alarm(40) + except ValueError: # not in main thread + old = None + try: + return _check(inst, ans) + except _Timeout: + raise Invalid("evaluation timed out") + except RecursionError: + raise Invalid("expression too deep") + finally: + if old is not None: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + + +def _check(inst, ans): + F = safe_parse(ans.get("F"), inst["max_len"]) + if sympy.count_ops(F) > inst["max_ops"]: + raise Invalid("expression too complex") + if any(isinstance(a, sympy.Rational) and max(abs(a.p), abs(a.q)) > 10 ** 12 for a in F.atoms(sympy.Rational)): + raise Invalid("numeric constants too large") + D = sympy.diff(F, x) + f = sympy.sympify(inst["f_prime"]) # trusted instance data + ok = 0 + for k in range(NPTS): + pt = sympy.Rational(2 * k + 1, NPTS // 2 * 2) * 2 - 2 + sympy.Rational(1, 997) + vf = _val(f, pt) + if vf is None: + continue + vd = _val(D, pt) + if vd is None: + continue + err = sympy.Abs(vd - vf).evalf(40) + if err > sympy.Float("1e-20", 40) * (1 + sympy.Abs(vf).evalf(40)): + raise Invalid(f"F'(x) != f(x) at x = {float(pt):.4f}") + ok += 1 + if ok < NPTS // 4: + raise Invalid("F' could not be compared with f on enough test points") + return None, {"points_checked": ok} diff --git a/tasks/construct-rlve-antiderivative-l2-s7/tests/instance.json b/tasks/construct-rlve-antiderivative-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cff6ab6bf14b64746e927df54b6e342bdb406192 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "x*(2*x + 4) + (x + 2)**2", "max_ops": 32, "max_len": 640, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l2-s7/tests/run.py b/tasks/construct-rlve-antiderivative-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l2-s7/tests/test.sh b/tasks/construct-rlve-antiderivative-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l6-s6/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-antiderivative-l6-s6/environment/instance.json b/tasks/construct-rlve-antiderivative-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a3125a42ad865dab381b1e940e745155e174b29e --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "-2*sin(x - 1/3)", "max_ops": 40, "max_len": 760, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s6/solution/solve.sh b/tasks/construct-rlve-antiderivative-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c79ba1dcc0056c7bbac6d03d9fe6ad9bd759799c --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"F": "2*cos(x - 1/3) - 1"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l6-s6/tests/check.py b/tasks/construct-rlve-antiderivative-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s6/tests/check.py @@ -0,0 +1,107 @@ +"""Antiderivative check. The answer string is tokenised against a whitelist (x, integers, + - * / ** ( ) and a few +elementary functions) before sympy parses it, so no Python eval of untrusted text and no `integrate`/`Integral`.""" +import re +import signal + +import sympy +from sympy.parsing.sympy_parser import auto_number, parse_expr + +from run import Invalid + +x = sympy.Symbol("x") +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "exp": sympy.exp, "log": sympy.log, + "sqrt": sympy.sqrt, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "E": sympy.E, "pi": sympy.pi, "x": x} +TOK = re.compile(r"\s*(?:(\d+)|([A-Za-z]+)|(\*\*|[-+*/()]))") +NPTS = 40 + + +def safe_parse(s, max_len): + if not isinstance(s, str) or not s.strip(): + raise Invalid("F must be a non-empty string") + if len(s) > max_len: + raise Invalid("expression too long") + pos = 0 + while pos < len(s): + m = TOK.match(s, pos) + if not m or m.end() == pos: + if s[pos:].strip() == "": + break + raise Invalid(f"illegal character near position {pos}") + if m.group(1) and len(m.group(1)) > 12: + raise Invalid("integer literal too long") + if m.group(2) and m.group(2) not in FUNCS: + raise Invalid(f"unknown name {m.group(2)!r}") + pos = m.end() + try: + e = parse_expr(s, local_dict=dict(FUNCS), global_dict={"__builtins__": {}, "Integer": sympy.Integer}, + transformations=(auto_number,)) + except Invalid: + raise + except Exception as ex: + raise Invalid(f"cannot parse F: {type(ex).__name__}") + if not isinstance(e, sympy.Expr): + raise Invalid("F is not an expression") + if e.free_symbols - {x}: + raise Invalid("F may only contain the variable x") + return e + + +def _val(e, pt): + v = e.evalf(40, subs={x: pt}) + if not v.is_number or v.has(sympy.zoo, sympy.nan, sympy.oo, -sympy.oo): + return None + return v + + +class _Timeout(Exception): + pass + + +def _alarm(*_): + raise _Timeout() + + +def check(inst, ans): + old = None + try: + old = signal.signal(signal.SIGALRM, _alarm) + signal.alarm(40) + except ValueError: # not in main thread + old = None + try: + return _check(inst, ans) + except _Timeout: + raise Invalid("evaluation timed out") + except RecursionError: + raise Invalid("expression too deep") + finally: + if old is not None: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + + +def _check(inst, ans): + F = safe_parse(ans.get("F"), inst["max_len"]) + if sympy.count_ops(F) > inst["max_ops"]: + raise Invalid("expression too complex") + if any(isinstance(a, sympy.Rational) and max(abs(a.p), abs(a.q)) > 10 ** 12 for a in F.atoms(sympy.Rational)): + raise Invalid("numeric constants too large") + D = sympy.diff(F, x) + f = sympy.sympify(inst["f_prime"]) # trusted instance data + ok = 0 + for k in range(NPTS): + pt = sympy.Rational(2 * k + 1, NPTS // 2 * 2) * 2 - 2 + sympy.Rational(1, 997) + vf = _val(f, pt) + if vf is None: + continue + vd = _val(D, pt) + if vd is None: + continue + err = sympy.Abs(vd - vf).evalf(40) + if err > sympy.Float("1e-20", 40) * (1 + sympy.Abs(vf).evalf(40)): + raise Invalid(f"F'(x) != f(x) at x = {float(pt):.4f}") + ok += 1 + if ok < NPTS // 4: + raise Invalid("F' could not be compared with f on enough test points") + return None, {"points_checked": ok} diff --git a/tasks/construct-rlve-antiderivative-l6-s6/tests/instance.json b/tasks/construct-rlve-antiderivative-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a3125a42ad865dab381b1e940e745155e174b29e --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "-2*sin(x - 1/3)", "max_ops": 40, "max_len": 760, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s6/tests/run.py b/tasks/construct-rlve-antiderivative-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-antiderivative-l6-s6/tests/test.sh b/tasks/construct-rlve-antiderivative-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-antiderivative-l6-s8/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-antiderivative-l6-s8/environment/instance.json b/tasks/construct-rlve-antiderivative-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1da81140f9428053c5203305ecba9f4bb2aebb73 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "2*cos(2*x)/3 - 2", "max_ops": 48, "max_len": 860, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s8/solution/solve.sh b/tasks/construct-rlve-antiderivative-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..86c51654d30ae70f19ef2096dc53bbd7963d58ac --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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' +{"F": "-2*x + sin(2*x)/3 - 4/3"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l6-s8/tests/check.py b/tasks/construct-rlve-antiderivative-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s8/tests/check.py @@ -0,0 +1,107 @@ +"""Antiderivative check. The answer string is tokenised against a whitelist (x, integers, + - * / ** ( ) and a few +elementary functions) before sympy parses it, so no Python eval of untrusted text and no `integrate`/`Integral`.""" +import re +import signal + +import sympy +from sympy.parsing.sympy_parser import auto_number, parse_expr + +from run import Invalid + +x = sympy.Symbol("x") +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "exp": sympy.exp, "log": sympy.log, + "sqrt": sympy.sqrt, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "E": sympy.E, "pi": sympy.pi, "x": x} +TOK = re.compile(r"\s*(?:(\d+)|([A-Za-z]+)|(\*\*|[-+*/()]))") +NPTS = 40 + + +def safe_parse(s, max_len): + if not isinstance(s, str) or not s.strip(): + raise Invalid("F must be a non-empty string") + if len(s) > max_len: + raise Invalid("expression too long") + pos = 0 + while pos < len(s): + m = TOK.match(s, pos) + if not m or m.end() == pos: + if s[pos:].strip() == "": + break + raise Invalid(f"illegal character near position {pos}") + if m.group(1) and len(m.group(1)) > 12: + raise Invalid("integer literal too long") + if m.group(2) and m.group(2) not in FUNCS: + raise Invalid(f"unknown name {m.group(2)!r}") + pos = m.end() + try: + e = parse_expr(s, local_dict=dict(FUNCS), global_dict={"__builtins__": {}, "Integer": sympy.Integer}, + transformations=(auto_number,)) + except Invalid: + raise + except Exception as ex: + raise Invalid(f"cannot parse F: {type(ex).__name__}") + if not isinstance(e, sympy.Expr): + raise Invalid("F is not an expression") + if e.free_symbols - {x}: + raise Invalid("F may only contain the variable x") + return e + + +def _val(e, pt): + v = e.evalf(40, subs={x: pt}) + if not v.is_number or v.has(sympy.zoo, sympy.nan, sympy.oo, -sympy.oo): + return None + return v + + +class _Timeout(Exception): + pass + + +def _alarm(*_): + raise _Timeout() + + +def check(inst, ans): + old = None + try: + old = signal.signal(signal.SIGALRM, _alarm) + signal.alarm(40) + except ValueError: # not in main thread + old = None + try: + return _check(inst, ans) + except _Timeout: + raise Invalid("evaluation timed out") + except RecursionError: + raise Invalid("expression too deep") + finally: + if old is not None: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + + +def _check(inst, ans): + F = safe_parse(ans.get("F"), inst["max_len"]) + if sympy.count_ops(F) > inst["max_ops"]: + raise Invalid("expression too complex") + if any(isinstance(a, sympy.Rational) and max(abs(a.p), abs(a.q)) > 10 ** 12 for a in F.atoms(sympy.Rational)): + raise Invalid("numeric constants too large") + D = sympy.diff(F, x) + f = sympy.sympify(inst["f_prime"]) # trusted instance data + ok = 0 + for k in range(NPTS): + pt = sympy.Rational(2 * k + 1, NPTS // 2 * 2) * 2 - 2 + sympy.Rational(1, 997) + vf = _val(f, pt) + if vf is None: + continue + vd = _val(D, pt) + if vd is None: + continue + err = sympy.Abs(vd - vf).evalf(40) + if err > sympy.Float("1e-20", 40) * (1 + sympy.Abs(vf).evalf(40)): + raise Invalid(f"F'(x) != f(x) at x = {float(pt):.4f}") + ok += 1 + if ok < NPTS // 4: + raise Invalid("F' could not be compared with f on enough test points") + return None, {"points_checked": ok} diff --git a/tasks/construct-rlve-antiderivative-l6-s8/tests/instance.json b/tasks/construct-rlve-antiderivative-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1da81140f9428053c5203305ecba9f4bb2aebb73 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "2*cos(2*x)/3 - 2", "max_ops": 48, "max_len": 860, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s8/tests/run.py b/tasks/construct-rlve-antiderivative-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-antiderivative-l6-s8/tests/test.sh b/tasks/construct-rlve-antiderivative-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-bezout-identity-l3-s3/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-bezout-identity-l3-s3/environment/instance.json b/tasks/construct-rlve-bezout-identity-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8bd22d5af28e8529df15ae4ecb2c7601dd614d64 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"A": [346, 118, -2, -428, 222, -418], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s3/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..38579d9004352bf477b24c9d3f83f942ab792cea --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"X": [0, 0, -1, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l3-s3/tests/check.py b/tasks/construct-rlve-bezout-identity-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s3/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-s3/tests/instance.json b/tasks/construct-rlve-bezout-identity-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8bd22d5af28e8529df15ae4ecb2c7601dd614d64 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"A": [346, 118, -2, -428, 222, -418], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s3/tests/run.py b/tasks/construct-rlve-bezout-identity-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-bezout-identity-l3-s3/tests/test.sh b/tasks/construct-rlve-bezout-identity-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s8/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s8/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6e60e369800888ac7eeae1c6af547cdef65ffba6 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"mod": 66, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s8/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4a4eca1049d223e4267545a6d62eb053b79e1216 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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' +{"L": 1, "R": 15} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s8/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s8/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s8/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6e60e369800888ac7eeae1c6af547cdef65ffba6 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"mod": 66, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s8/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s8/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s9/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l1-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s9/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4def0362c154dbe60d31813aebd468b48760a05d --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s9/environment/instance.json @@ -0,0 +1 @@ +{"mod": 63, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s9/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l1-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..53ba94071658d50cfe93e6fbee5cd25dc4b79847 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"L": 3, "R": 15} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s9/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l1-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s9/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s9/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4def0362c154dbe60d31813aebd468b48760a05d --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s9/tests/instance.json @@ -0,0 +1 @@ +{"mod": 63, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s9/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l1-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s9/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l1-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s6/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l5-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s6/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f51ef9c1eb97a3ca7257c833ab726216a0a56380 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s6/environment/instance.json @@ -0,0 +1 @@ +{"mod": 294208032536424, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s6/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l5-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9ca2d4dd0e36fb665015708bcd492cef2f5fdc0f --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"L": 3416065072848, "R": 13416065072847} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s6/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l5-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s6/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s6/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l5-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f51ef9c1eb97a3ca7257c833ab726216a0a56380 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s6/tests/instance.json @@ -0,0 +1 @@ +{"mod": 294208032536424, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s6/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l5-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l5-s6/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l5-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l5-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-crt-l4-s7/environment/Dockerfile b/tasks/construct-rlve-crt-l4-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l4-s7/environment/instance.json b/tasks/construct-rlve-crt-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8baf8bde566fdab27664a4789f866912675601b9 --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"moduli": [121952, 240234, 257629, 526334, 346469], "residues": [66026, 73366, 38576, 27500, 207365], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l4-s7/solution/solve.sh b/tasks/construct-rlve-crt-l4-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6b483504fbaca27abee1bc646c9009840479e8de --- /dev/null +++ b/tasks/construct-rlve-crt-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' +{"x": 553834} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l4-s7/tests/check.py b/tasks/construct-rlve-crt-l4-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s7/tests/check.py @@ -0,0 +1,11 @@ +from run import Invalid, as_int + + +def check(inst, ans): + x = as_int(ans.get("x"), "x", lo=0) + if x.bit_length() > 20000: + raise Invalid("x is unreasonably large") + for a, b in zip(inst["residues"], inst["moduli"]): + if x % b != a: + raise Invalid(f"x mod {b} = {x % b}, need {a}") + return None, {} diff --git a/tasks/construct-rlve-crt-l4-s7/tests/instance.json b/tasks/construct-rlve-crt-l4-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8baf8bde566fdab27664a4789f866912675601b9 --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s7/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [121952, 240234, 257629, 526334, 346469], "residues": [66026, 73366, 38576, 27500, 207365], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l4-s7/tests/run.py b/tasks/construct-rlve-crt-l4-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l4-s7/tests/test.sh b/tasks/construct-rlve-crt-l4-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l4-s9/environment/Dockerfile b/tasks/construct-rlve-crt-l4-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-crt-l4-s9/environment/instance.json b/tasks/construct-rlve-crt-l4-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a2bbd8651f99bd42751e8e52290b776990060a30 --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s9/environment/instance.json @@ -0,0 +1 @@ +{"moduli": [17945, 55175, 118462, 51193, 24055], "residues": [5691, 20956, 12844, 28920, 11031], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l4-s9/solution/solve.sh b/tasks/construct-rlve-crt-l4-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3f57d8702d3e7f35ecaabc3becfd26f76b28e94c --- /dev/null +++ b/tasks/construct-rlve-crt-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' +{"x": 131306} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l4-s9/tests/check.py b/tasks/construct-rlve-crt-l4-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s9/tests/check.py @@ -0,0 +1,11 @@ +from run import Invalid, as_int + + +def check(inst, ans): + x = as_int(ans.get("x"), "x", lo=0) + if x.bit_length() > 20000: + raise Invalid("x is unreasonably large") + for a, b in zip(inst["residues"], inst["moduli"]): + if x % b != a: + raise Invalid(f"x mod {b} = {x % b}, need {a}") + return None, {} diff --git a/tasks/construct-rlve-crt-l4-s9/tests/instance.json b/tasks/construct-rlve-crt-l4-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a2bbd8651f99bd42751e8e52290b776990060a30 --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s9/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [17945, 55175, 118462, 51193, 24055], "residues": [5691, 20956, 12844, 28920, 11031], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l4-s9/tests/run.py b/tasks/construct-rlve-crt-l4-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-crt-l4-s9/tests/test.sh b/tasks/construct-rlve-crt-l4-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..37a95f08c02b7aa2a2046292d9e50c4f4d90ed97 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"A": [4, 7, 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-s1/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..160a8afb6e6d2f9c672059c0659942ce401d98b7 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"B": [6, 2, 7, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/tests/check.py @@ -0,0 +1,22 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + n = len(A) + B = int_list(ans.get("B"), n, name="B") + if Counter(B) != Counter(A): + raise Invalid("B is not a permutation of A") + d = [a - b for a, b in zip(A, B)] + # count subsets (including empty and full) with sum 0; the empty and full sets always qualify + ways = Counter({0: 1}) + for x in d: + nxt = Counter(ways) + for s, c in ways.items(): + nxt[s + x] += c + ways = nxt + if ways[0] != 2: + raise Invalid(f"{ways[0] - 2} non-empty proper subsets have equal sums in A and B") + return None, {} diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..37a95f08c02b7aa2a2046292d9e50c4f4d90ed97 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"A": [4, 7, 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-s1/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2be6dee00b62905cb9a2833acbdd069d4fb51095 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"A": [2, 7, 4, 1], "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-s6/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..da3f0996776111c0f186ac55a847fa6e284091fd --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"B": [4, 1, 7, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/tests/check.py @@ -0,0 +1,22 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + n = len(A) + B = int_list(ans.get("B"), n, name="B") + if Counter(B) != Counter(A): + raise Invalid("B is not a permutation of A") + d = [a - b for a, b in zip(A, B)] + # count subsets (including empty and full) with sum 0; the empty and full sets always qualify + ways = Counter({0: 1}) + for x in d: + nxt = Counter(ways) + for s, c in ways.items(): + nxt[s + x] += c + ways = nxt + if ways[0] != 2: + raise Invalid(f"{ways[0] - 2} non-empty proper subsets have equal sums in A and B") + return None, {} diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2be6dee00b62905cb9a2833acbdd069d4fb51095 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"A": [2, 7, 4, 1], "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-s6/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8d4678ca7c3ed216ea9536083d28f600cb23be7e --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"A": [19, 1, 26, 25, 33, 0, 20, 34, 11, 32, 31, 9, 35, 2, 30, 8, 16, 27], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..69a124d4fce9fe269d5f76eae66c5a87698033f5 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"B": [20, 2, 27, 26, 34, 1, 25, 35, 16, 33, 32, 11, 0, 8, 31, 9, 19, 30]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/tests/check.py @@ -0,0 +1,22 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + n = len(A) + B = int_list(ans.get("B"), n, name="B") + if Counter(B) != Counter(A): + raise Invalid("B is not a permutation of A") + d = [a - b for a, b in zip(A, B)] + # count subsets (including empty and full) with sum 0; the empty and full sets always qualify + ways = Counter({0: 1}) + for x in d: + nxt = Counter(ways) + for s, c in ways.items(): + nxt[s + x] += c + ways = nxt + if ways[0] != 2: + raise Invalid(f"{ways[0] - 2} non-empty proper subsets have equal sums in A and B") + return None, {} diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8d4678ca7c3ed216ea9536083d28f600cb23be7e --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"A": [19, 1, 26, 25, 33, 0, 20, 34, 11, 32, 31, 9, 35, 2, 30, 8, 16, 27], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8451b649ce1646e0f17aa6d4cf410fda2b7c12e8 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"A": [5, 22, 26, 17, 24, 35, 3, 6, 7, 28, 33, 13, 27, 2, 30, 18, 34, 31], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..db185ec93fa04a92f698ab2e81ce960a96e34dee --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"B": [6, 24, 27, 18, 26, 2, 5, 7, 13, 30, 34, 17, 28, 3, 31, 22, 35, 33]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/tests/check.py @@ -0,0 +1,22 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + n = len(A) + B = int_list(ans.get("B"), n, name="B") + if Counter(B) != Counter(A): + raise Invalid("B is not a permutation of A") + d = [a - b for a, b in zip(A, B)] + # count subsets (including empty and full) with sum 0; the empty and full sets always qualify + ways = Counter({0: 1}) + for x in d: + nxt = Counter(ways) + for s, c in ways.items(): + nxt[s + x] += c + ways = nxt + if ways[0] != 2: + raise Invalid(f"{ways[0] - 2} non-empty proper subsets have equal sums in A and B") + return None, {} diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8451b649ce1646e0f17aa6d4cf410fda2b7c12e8 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"A": [5, 22, 26, 17, 24, 35, 3, 6, 7, 28, 33, 13, 27, 2, 30, 18, 34, 31], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-even-degree-partition-l4-s0/environment/Dockerfile b/tasks/construct-rlve-even-degree-partition-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l4-s0/environment/instance.json b/tasks/construct-rlve-even-degree-partition-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fb2c533d23a8bea62de09d9b1500fdd49252022b --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "edges": [[0, 3], [0, 6], [0, 9], [0, 15], [0, 16], [0, 17], [1, 2], [1, 3], [1, 6], [1, 8], [1, 12], [1, 16], [1, 17], [2, 3], [2, 5], [2, 8], [2, 9], [2, 13], [2, 16], [2, 17], [3, 4], [3, 6], [3, 7], [3, 8], [3, 9], [3, 11], [3, 12], [3, 13], [3, 15], [3, 16], [3, 17], [4, 6], [4, 8], [4, 9], [4, 13], [4, 16], [4, 17], [5, 12], [5, 13], [6, 9], [6, 10], [7, 14], [7, 15], [7, 17], [8, 9], [8, 10], [8, 11], [8, 14], [8, 16], [8, 17], [9, 12], [9, 15], [9, 16], [10, 13], [10, 14], [10, 15], [12, 13], [13, 15], [13, 16], [14, 17], [15, 16]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l4-s0/solution/solve.sh b/tasks/construct-rlve-even-degree-partition-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..134268712b1d33c162223e8312fb2f5126fa9ca1 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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' +{"groups": [2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 1, 2, 2, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-even-degree-partition-l4-s0/tests/check.py b/tasks/construct-rlve-even-degree-partition-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c7f0f71ea6d10264ececcc933b97a4a0e6eaf8e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s0/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-s0/tests/instance.json b/tasks/construct-rlve-even-degree-partition-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fb2c533d23a8bea62de09d9b1500fdd49252022b --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "edges": [[0, 3], [0, 6], [0, 9], [0, 15], [0, 16], [0, 17], [1, 2], [1, 3], [1, 6], [1, 8], [1, 12], [1, 16], [1, 17], [2, 3], [2, 5], [2, 8], [2, 9], [2, 13], [2, 16], [2, 17], [3, 4], [3, 6], [3, 7], [3, 8], [3, 9], [3, 11], [3, 12], [3, 13], [3, 15], [3, 16], [3, 17], [4, 6], [4, 8], [4, 9], [4, 13], [4, 16], [4, 17], [5, 12], [5, 13], [6, 9], [6, 10], [7, 14], [7, 15], [7, 17], [8, 9], [8, 10], [8, 11], [8, 14], [8, 16], [8, 17], [9, 12], [9, 15], [9, 16], [10, 13], [10, 14], [10, 15], [12, 13], [13, 15], [13, 16], [14, 17], [15, 16]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l4-s0/tests/run.py b/tasks/construct-rlve-even-degree-partition-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l4-s0/tests/test.sh b/tasks/construct-rlve-even-degree-partition-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l4-s7/environment/Dockerfile b/tasks/construct-rlve-even-degree-partition-l4-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l4-s7/environment/instance.json b/tasks/construct-rlve-even-degree-partition-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..adb82f5707f57993572e413e214da5de85614583 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "edges": [[0, 1], [0, 3], [0, 9], [0, 10], [0, 13], [0, 14], [0, 15], [1, 3], [1, 4], [1, 5], [1, 6], [1, 10], [1, 11], [1, 14], [1, 15], [1, 16], [1, 17], [2, 4], [2, 9], [2, 10], [2, 12], [2, 15], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [4, 5], [4, 6], [4, 8], [4, 10], [4, 13], [4, 14], [5, 8], [5, 10], [5, 11], [5, 12], [5, 13], [5, 15], [5, 16], [5, 17], [6, 9], [6, 10], [6, 14], [8, 10], [8, 12], [8, 13], [8, 17], [9, 10], [9, 11], [9, 12], [10, 11], [10, 13], [10, 14], [10, 15], [10, 17], [11, 12], [11, 13], [11, 15], [11, 16], [12, 14], [13, 14], [13, 15], [13, 16], [13, 17], [14, 17], [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-s7/solution/solve.sh b/tasks/construct-rlve-even-degree-partition-l4-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4512dd73001720af5181faa7888ce7f4bd385890 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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' +{"groups": [2, 2, 2, 2, 1, 2, 1, 1, 1, 1, 2, 2, 1, 2, 2, 2, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-even-degree-partition-l4-s7/tests/check.py b/tasks/construct-rlve-even-degree-partition-l4-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c7f0f71ea6d10264ececcc933b97a4a0e6eaf8e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s7/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + g = int_list(ans.get("groups"), n, 1, 2, "groups") + deg = [0] * n + for u, v in inst["edges"]: + if g[u] == g[v]: + deg[u] += 1 + deg[v] += 1 + for v in range(n): + if deg[v] % 2: + raise Invalid(f"vertex {v} has {deg[v]} same-group neighbours") + return None, {} diff --git a/tasks/construct-rlve-even-degree-partition-l4-s7/tests/instance.json b/tasks/construct-rlve-even-degree-partition-l4-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..adb82f5707f57993572e413e214da5de85614583 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "edges": [[0, 1], [0, 3], [0, 9], [0, 10], [0, 13], [0, 14], [0, 15], [1, 3], [1, 4], [1, 5], [1, 6], [1, 10], [1, 11], [1, 14], [1, 15], [1, 16], [1, 17], [2, 4], [2, 9], [2, 10], [2, 12], [2, 15], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [4, 5], [4, 6], [4, 8], [4, 10], [4, 13], [4, 14], [5, 8], [5, 10], [5, 11], [5, 12], [5, 13], [5, 15], [5, 16], [5, 17], [6, 9], [6, 10], [6, 14], [8, 10], [8, 12], [8, 13], [8, 17], [9, 10], [9, 11], [9, 12], [10, 11], [10, 13], [10, 14], [10, 15], [10, 17], [11, 12], [11, 13], [11, 15], [11, 16], [12, 14], [13, 14], [13, 15], [13, 16], [13, 17], [14, 17], [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-s7/tests/run.py b/tasks/construct-rlve-even-degree-partition-l4-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l4-s7/tests/test.sh b/tasks/construct-rlve-even-degree-partition-l4-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-graph-isomorphism-l2-s3/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l2-s3/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c939948a2a0cef7daca1dda1124b97d50cd28fdb --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[1, 4], [1, 3], [3, 7], [0, 5], [4, 6], [3, 6], [2, 3], [4, 7], [1, 5], [4, 5], [3, 4], [0, 3]], "edges2": [[5, 7], [5, 6], [6, 7], [1, 5], [3, 4], [3, 5], [1, 7], [2, 7], [4, 7], [3, 6], [0, 7], [2, 5]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s3/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3cc71a1132996235efc9a119ba7fb69257ed7d84 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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' +{"p": [4, 6, 0, 7, 5, 3, 2, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s3/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s3/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-s3/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c939948a2a0cef7daca1dda1124b97d50cd28fdb --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[1, 4], [1, 3], [3, 7], [0, 5], [4, 6], [3, 6], [2, 3], [4, 7], [1, 5], [4, 5], [3, 4], [0, 3]], "edges2": [[5, 7], [5, 6], [6, 7], [1, 5], [3, 4], [3, 5], [1, 7], [2, 7], [4, 7], [3, 6], [0, 7], [2, 5]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s3/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l2-s3/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l6-s2/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s2/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bfc9e08c342ccc1f086b033205a70c85a1719f6f --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges1": [[4, 36], [30, 34], [0, 6], [27, 32], [19, 26], [22, 31], [26, 29], [7, 34], [10, 12], [8, 38], [2, 16], [20, 33], [15, 23], [3, 10], [19, 35], [1, 26], [3, 39], [4, 16], [17, 36], [0, 24], [18, 38], [21, 39], [15, 17], [7, 26], [4, 29], [12, 14], [32, 39], [13, 32], [14, 34], [20, 29], [11, 24], [10, 29], [28, 29], [33, 36], [17, 22], [4, 30], [2, 4], [2, 13], [0, 16], [16, 37], [5, 22], [35, 39], [14, 25], [2, 10], [30, 35], [5, 16], [7, 31], [6, 37], [9, 20], [35, 38], [15, 34], [8, 32], [1, 33], [5, 12], [26, 32], [3, 25], [21, 31], [10, 28], [11, 29], [16, 21], [4, 9], [24, 27], [2, 20], [6, 14], [25, 28], [3, 30], [6, 17], [2, 8], [37, 39], [1, 22], [10, 20], [17, 33], [13, 25], [11, 14], [19, 21], [21, 36], [16, 28], [12, 21], [2, 33], [8, 15], [12, 27], [24, 33], [1, 16], [14, 33], [28, 33], [1, 32], [7, 38], [22, 23], [3, 16], [13, 23], [14, 22], [0, 10], [6, 8], [9, 12], [3, 6], [7, 21], [27, 35], [2, 28], [3, 18], [26, 28], [6, 12], [30, 32], [12, 16], [4, 35], [31, 33], [5, 10], [20, 36], [25, 27], [27, 30], [7, 18], [16, 23], [5, 11], [22, 36], [1, 25], [24, 34], [32, 35], [1, 17], [18, 29], [0, 22], [4, 26], [2, 6], [20, 34], [18, 25], [19, 23], [3, 14], [13, 21], [22, 25], [15, 16], [24, 37], [10, 34], [3, 7], [20, 22], [36, 39], [22, 38], [14, 37], [23, 33], [12, 36], [14, 20], [17, 19], [8, 10], [12, 31], [5, 28], [24, 30], [2, 31], [0, 30], [7, 22], [16, 33], [8, 9], [6, 28], [23, 38], [21, 26], [25, 33], [13, 28], [6, 16], [15, 28], [13, 26], [26, 34], [9, 35], [4, 20], [0, 17], [22, 24], [0, 14], [10, 38], [5, 18], [5, 26], [1, 20], [18, 19], [18, 34], [13, 29], [22, 35], [31, 36], [0, 25], [12, 35], [1, 31], [0, 39], [6, 10], [23, 25], [20, 37], [1, 3], [7, 28], [9, 17], [3, 26], [22, 29], [9, 28], [23, 31], [2, 22], [4, 37], [4, 34], [19, 28], [9, 36], [31, 34], [0, 8], [10, 31], [2, 24], [7, 10], [5, 15], [22, 28], [21, 28], [4, 8], [4, 17], [0, 11], [11, 31], [13, 15], [23, 39], [27, 31], [5, 39], [14, 38], [13, 22], [4, 18], [16, 32], [6, 22], [32, 36], [9, 24], [11, 17], [22, 37], [28, 37], [20, 21], [11, 35], [16, 18], [2, 23], [28, 35], [23, 34], [4, 22], [5, 19], [17, 38], [0, 4], [8, 22], [1, 35], [2, 27], [27, 37], [26, 37], [3, 28], [4, 27], [14, 32], [28, 30], [29, 33], [12, 38], [22, 27], [7, 12], [1, 36], [9, 33], [6, 30], [29, 36], [13, 38], [1, 5], [11, 23], [7, 24], [16, 27], [25, 30], [21, 32], [27, 34], [13, 17], [6, 27], [16, 35], [3, 27], [2, 34], [18, 21], [6, 31], [20, 39], [17, 23], [12, 32], [17, 31], [14, 15], [8, 27], [4, 33], [15, 29], [3, 34], [10, 35], [14, 35], [22, 26], [26, 35], [26, 31], [4, 31], [15, 25], [0, 32], [0, 20], [1, 28], [5, 37], [29, 32], [30, 38], [18, 27], [1, 38], [0, 19], [25, 36], [14, 16], [8, 20], [26, 30], [2, 17], [2, 25], [11, 39], [8, 31], [21, 35], [5, 30], [15, 19], [5, 24], [3, 21], [8, 25], [8, 34], [20, 35], [0, 1], [3, 12], [7, 39], [24, 38], [18, 22], [3, 9], [0, 13], [3, 33], [6, 29], [13, 37], [0, 5], [23, 27], [10, 37], [6, 21], [4, 19], [15, 35], [21, 37], [11, 21], [33, 39], [11, 27], [10, 39], [26, 33], [33, 34], [10, 15], [4, 12], [2, 3], [29, 38], [12, 26], [4, 10], [18, 35], [19, 29], [12, 30], [20, 31], [9, 27], [16, 39], [25, 34], [9, 10], [6, 36], [12, 33], [12, 34], [1, 8], [1, 12], [6, 24], [30, 33], [1, 21], [18, 20], [21, 29], [9, 15], [15, 36], [21, 24], [5, 14], [8, 33], [19, 27], [9, 30], [8, 23], [21, 25], [5, 34], [37, 38], [15, 24], [15, 27], [25, 39], [11, 19], [11, 36], [20, 28], [6, 26], [1, 23], [5, 7], [0, 35], [20, 30], [21, 34], [24, 35], [0, 21], [34, 37], [11, 20], [3, 8], [5, 13], [11, 18], [26, 39], [18, 24], [10, 21], [21, 38], [13, 33], [10, 19], [11, 12], [29, 39], [10, 30], [7, 19], [1, 24], [3, 5], [11, 33], [0, 7], [14, 21], [8, 24], [0, 15], [1, 34], [5, 9], [8, 35], [19, 24], [32, 38], [6, 9], [9, 16], [32, 37], [21, 22], [0, 9], [12, 20], [8, 17], [29, 34], [4, 32], [8, 12], [31, 32], [19, 38], [2, 35], [0, 31], [9, 29], [12, 28], [0, 29], [0, 38], [8, 16], [2, 14], [6, 39], [21, 30], [29, 35], [38, 39], [8, 30], [6, 33], [28, 36], [1, 18], [29, 30], [9, 23], [12, 24]], "edges2": [[25, 27], [1, 32], [8, 11], [21, 34], [26, 32], [28, 31], [12, 24], [2, 21], [2, 20], [6, 7], [32, 34], [20, 22], [20, 32], [9, 12], [11, 24], [0, 30], [0, 4], [26, 28], [24, 38], [26, 37], [10, 19], [17, 18], [18, 27], [6, 39], [16, 30], [20, 37], [4, 31], [12, 26], [15, 38], [24, 26], [1, 31], [6, 11], [0, 12], [4, 17], [5, 8], [21, 22], [12, 22], [13, 31], [28, 30], [11, 39], [20, 39], [26, 36], [3, 8], [6, 17], [16, 31], [3, 23], [25, 38], [12, 31], [7, 21], [4, 16], [19, 33], [13, 19], [0, 13], [32, 37], [10, 15], [6, 12], [15, 36], [5, 22], [7, 11], [7, 18], [14, 39], [9, 34], [1, 26], [1, 14], [15, 16], [23, 26], [5, 28], [7, 14], [16, 33], [10, 12], [19, 23], [13, 18], [2, 34], [11, 37], [10, 18], [4, 12], [5, 11], [14, 20], [7, 38], [10, 39], [8, 32], [0, 37], [14, 17], [35, 38], [2, 32], [1, 8], [2, 25], [19, 37], [27, 31], [9, 39], [0, 10], [17, 20], [3, 25], [15, 31], [33, 36], [4, 14], [8, 37], [2, 30], [1, 11], [30, 32], [12, 35], [9, 10], [8, 29], [21, 24], [35, 39], [3, 32], [16, 20], [5, 24], [10, 38], [23, 28], [22, 33], [24, 35], [18, 39], [9, 28], [3, 12], [18, 31], [8, 9], [11, 27], [16, 19], [11, 34], [10, 16], [15, 17], [2, 24], [7, 23], [22, 26], [11, 36], [3, 6], [1, 36], [19, 36], [7, 27], [31, 34], [28, 39], [14, 34], [1, 7], [7, 31], [15, 25], [4, 30], [1, 27], [14, 36], [30, 39], [5, 12], [13, 14], [28, 35], [3, 28], [29, 37], [11, 17], [11, 28], [37, 39], [21, 31], [26, 29], [12, 16], [27, 37], [5, 13], [11, 20], [8, 26], [22, 24], [31, 33], [2, 3], [8, 31], [8, 13], [0, 6], [3, 11], [15, 39], [1, 18], [17, 30], [14, 37], [19, 24], [19, 29], [29, 35], [21, 38], [1, 6], [29, 32], [27, 39], [27, 29], [29, 38], [15, 24], [23, 32], [4, 11], [2, 29], [8, 28], [20, 27], [14, 28], [6, 37], [22, 36], [26, 35], [21, 39], [26, 27], [10, 33], [0, 22], [12, 34], [21, 29], [6, 16], [10, 34], [9, 24], [4, 19], [1, 15], [28, 33], [4, 18], [7, 15], [3, 35], [10, 24], [3, 9], [23, 35], [17, 25], [15, 34], [6, 28], [6, 30], [9, 19], [31, 37], [14, 18], [0, 24], [1, 20], [24, 36], [5, 25], [22, 23], [36, 37], [8, 15], [2, 18], [16, 36], [26, 38], [0, 11], [17, 22], [6, 10], [15, 26], [4, 15], [1, 29], [11, 30], [22, 38], [14, 33], [31, 39], [27, 34], [2, 14], [23, 37], [16, 27], [13, 36], [24, 39], [27, 28], [9, 33], [31, 36], [3, 22], [30, 34], [13, 33], [3, 31], [24, 27], [13, 39], [8, 36], [13, 34], [13, 22], [8, 27], [21, 30], [15, 33], [11, 35], [8, 24], [16, 24], [4, 27], [29, 34], [8, 16], [2, 33], [33, 35], [13, 21], [0, 36], [12, 30], [9, 17], [34, 36], [5, 15], [2, 11], [0, 8], [13, 24], [0, 23], [10, 14], [30, 38], [19, 32], [1, 33], [13, 37], [4, 8], [11, 23], [9, 13], [6, 29], [19, 35], [5, 16], [5, 21], [4, 26], [9, 27], [33, 39], [19, 21], [0, 34], [10, 37], [8, 39], [24, 29], [9, 23], [2, 17], [12, 29], [4, 5], [15, 23], [15, 18], [7, 12], [11, 26], [3, 36], [13, 29], [3, 27], [10, 31], [7, 30], [4, 32], [30, 31], [5, 17], [20, 34], [9, 31], [0, 26], [16, 35], [23, 30], [15, 37], [16, 22], [16, 17], [5, 27], [6, 15], [15, 22], [9, 14], [5, 23], [9, 22], [12, 20], [12, 18], [0, 25], [5, 7], [18, 25], [22, 28], [19, 30], [11, 16], [11, 38], [14, 31], [3, 19], [9, 16], [13, 16], [9, 26], [9, 21], [28, 38], [0, 31], [22, 30], [1, 16], [9, 30], [4, 25], [4, 33], [0, 39], [24, 37], [17, 23], [8, 17], [1, 4], [20, 33], [8, 33], [13, 25], [24, 32], [3, 38], [25, 31], [21, 25], [1, 10], [11, 12], [19, 31], [26, 33], [8, 34], [19, 22], [29, 39], [30, 36], [34, 35], [18, 38], [6, 21], [23, 39], [29, 30], [9, 36], [4, 10], [4, 28], [12, 25], [12, 32], [14, 35], [3, 20], [1, 35], [25, 30], [6, 35], [7, 36], [8, 19], [30, 33], [7, 10], [9, 11], [25, 33], [20, 29], [7, 20], [28, 36], [0, 15], [23, 29], [8, 14], [3, 18], [18, 23], [17, 34], [16, 23], [5, 33], [6, 8], [27, 30], [11, 22], [3, 30], [1, 19], [2, 19], [12, 27], [9, 20], [1, 34], [18, 21], [1, 37], [15, 27], [6, 9], [11, 32], [1, 21], [2, 22], [3, 34], [12, 38], [13, 15], [2, 9], [29, 36], [7, 24], [13, 30], [17, 29], [0, 19], [12, 14], [0, 35], [0, 5], [0, 14], [7, 37], [10, 25], [14, 21], [2, 26], [1, 22], [12, 33], [11, 19]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s2/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3e14d3c5ad3eb8ceebe0f864ab0baa80bc6adbe9 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"p": [30, 27, 10, 37, 33, 29, 0, 32, 31, 13, 19, 17, 8, 38, 6, 21, 39, 25, 20, 2, 16, 11, 12, 18, 34, 7, 26, 14, 24, 22, 36, 4, 28, 15, 1, 9, 5, 35, 3, 23]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s2/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s2/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("p"), n, 0, n - 1, "p") + if len(set(p)) != n: + raise Invalid("p is not a permutation") + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + img = {(min(p[u], p[v]), max(p[u], p[v])) for u, v in inst["edges1"]} + if img != e2: + raise Invalid(f"{len(img - e2)} edges of G1 are not mapped onto edges of G2") + return None, {} diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s2/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bfc9e08c342ccc1f086b033205a70c85a1719f6f --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges1": [[4, 36], [30, 34], [0, 6], [27, 32], [19, 26], [22, 31], [26, 29], [7, 34], [10, 12], [8, 38], [2, 16], [20, 33], [15, 23], [3, 10], [19, 35], [1, 26], [3, 39], [4, 16], [17, 36], [0, 24], [18, 38], [21, 39], [15, 17], [7, 26], [4, 29], [12, 14], [32, 39], [13, 32], [14, 34], [20, 29], [11, 24], [10, 29], [28, 29], [33, 36], [17, 22], [4, 30], [2, 4], [2, 13], [0, 16], [16, 37], [5, 22], [35, 39], [14, 25], [2, 10], [30, 35], [5, 16], [7, 31], [6, 37], [9, 20], [35, 38], [15, 34], [8, 32], [1, 33], [5, 12], [26, 32], [3, 25], [21, 31], [10, 28], [11, 29], [16, 21], [4, 9], [24, 27], [2, 20], [6, 14], [25, 28], [3, 30], [6, 17], [2, 8], [37, 39], [1, 22], [10, 20], [17, 33], [13, 25], [11, 14], [19, 21], [21, 36], [16, 28], [12, 21], [2, 33], [8, 15], [12, 27], [24, 33], [1, 16], [14, 33], [28, 33], [1, 32], [7, 38], [22, 23], [3, 16], [13, 23], [14, 22], [0, 10], [6, 8], [9, 12], [3, 6], [7, 21], [27, 35], [2, 28], [3, 18], [26, 28], [6, 12], [30, 32], [12, 16], [4, 35], [31, 33], [5, 10], [20, 36], [25, 27], [27, 30], [7, 18], [16, 23], [5, 11], [22, 36], [1, 25], [24, 34], [32, 35], [1, 17], [18, 29], [0, 22], [4, 26], [2, 6], [20, 34], [18, 25], [19, 23], [3, 14], [13, 21], [22, 25], [15, 16], [24, 37], [10, 34], [3, 7], [20, 22], [36, 39], [22, 38], [14, 37], [23, 33], [12, 36], [14, 20], [17, 19], [8, 10], [12, 31], [5, 28], [24, 30], [2, 31], [0, 30], [7, 22], [16, 33], [8, 9], [6, 28], [23, 38], [21, 26], [25, 33], [13, 28], [6, 16], [15, 28], [13, 26], [26, 34], [9, 35], [4, 20], [0, 17], [22, 24], [0, 14], [10, 38], [5, 18], [5, 26], [1, 20], [18, 19], [18, 34], [13, 29], [22, 35], [31, 36], [0, 25], [12, 35], [1, 31], [0, 39], [6, 10], [23, 25], [20, 37], [1, 3], [7, 28], [9, 17], [3, 26], [22, 29], [9, 28], [23, 31], [2, 22], [4, 37], [4, 34], [19, 28], [9, 36], [31, 34], [0, 8], [10, 31], [2, 24], [7, 10], [5, 15], [22, 28], [21, 28], [4, 8], [4, 17], [0, 11], [11, 31], [13, 15], [23, 39], [27, 31], [5, 39], [14, 38], [13, 22], [4, 18], [16, 32], [6, 22], [32, 36], [9, 24], [11, 17], [22, 37], [28, 37], [20, 21], [11, 35], [16, 18], [2, 23], [28, 35], [23, 34], [4, 22], [5, 19], [17, 38], [0, 4], [8, 22], [1, 35], [2, 27], [27, 37], [26, 37], [3, 28], [4, 27], [14, 32], [28, 30], [29, 33], [12, 38], [22, 27], [7, 12], [1, 36], [9, 33], [6, 30], [29, 36], [13, 38], [1, 5], [11, 23], [7, 24], [16, 27], [25, 30], [21, 32], [27, 34], [13, 17], [6, 27], [16, 35], [3, 27], [2, 34], [18, 21], [6, 31], [20, 39], [17, 23], [12, 32], [17, 31], [14, 15], [8, 27], [4, 33], [15, 29], [3, 34], [10, 35], [14, 35], [22, 26], [26, 35], [26, 31], [4, 31], [15, 25], [0, 32], [0, 20], [1, 28], [5, 37], [29, 32], [30, 38], [18, 27], [1, 38], [0, 19], [25, 36], [14, 16], [8, 20], [26, 30], [2, 17], [2, 25], [11, 39], [8, 31], [21, 35], [5, 30], [15, 19], [5, 24], [3, 21], [8, 25], [8, 34], [20, 35], [0, 1], [3, 12], [7, 39], [24, 38], [18, 22], [3, 9], [0, 13], [3, 33], [6, 29], [13, 37], [0, 5], [23, 27], [10, 37], [6, 21], [4, 19], [15, 35], [21, 37], [11, 21], [33, 39], [11, 27], [10, 39], [26, 33], [33, 34], [10, 15], [4, 12], [2, 3], [29, 38], [12, 26], [4, 10], [18, 35], [19, 29], [12, 30], [20, 31], [9, 27], [16, 39], [25, 34], [9, 10], [6, 36], [12, 33], [12, 34], [1, 8], [1, 12], [6, 24], [30, 33], [1, 21], [18, 20], [21, 29], [9, 15], [15, 36], [21, 24], [5, 14], [8, 33], [19, 27], [9, 30], [8, 23], [21, 25], [5, 34], [37, 38], [15, 24], [15, 27], [25, 39], [11, 19], [11, 36], [20, 28], [6, 26], [1, 23], [5, 7], [0, 35], [20, 30], [21, 34], [24, 35], [0, 21], [34, 37], [11, 20], [3, 8], [5, 13], [11, 18], [26, 39], [18, 24], [10, 21], [21, 38], [13, 33], [10, 19], [11, 12], [29, 39], [10, 30], [7, 19], [1, 24], [3, 5], [11, 33], [0, 7], [14, 21], [8, 24], [0, 15], [1, 34], [5, 9], [8, 35], [19, 24], [32, 38], [6, 9], [9, 16], [32, 37], [21, 22], [0, 9], [12, 20], [8, 17], [29, 34], [4, 32], [8, 12], [31, 32], [19, 38], [2, 35], [0, 31], [9, 29], [12, 28], [0, 29], [0, 38], [8, 16], [2, 14], [6, 39], [21, 30], [29, 35], [38, 39], [8, 30], [6, 33], [28, 36], [1, 18], [29, 30], [9, 23], [12, 24]], "edges2": [[25, 27], [1, 32], [8, 11], [21, 34], [26, 32], [28, 31], [12, 24], [2, 21], [2, 20], [6, 7], [32, 34], [20, 22], [20, 32], [9, 12], [11, 24], [0, 30], [0, 4], [26, 28], [24, 38], [26, 37], [10, 19], [17, 18], [18, 27], [6, 39], [16, 30], [20, 37], [4, 31], [12, 26], [15, 38], [24, 26], [1, 31], [6, 11], [0, 12], [4, 17], [5, 8], [21, 22], [12, 22], [13, 31], [28, 30], [11, 39], [20, 39], [26, 36], [3, 8], [6, 17], [16, 31], [3, 23], [25, 38], [12, 31], [7, 21], [4, 16], [19, 33], [13, 19], [0, 13], [32, 37], [10, 15], [6, 12], [15, 36], [5, 22], [7, 11], [7, 18], [14, 39], [9, 34], [1, 26], [1, 14], [15, 16], [23, 26], [5, 28], [7, 14], [16, 33], [10, 12], [19, 23], [13, 18], [2, 34], [11, 37], [10, 18], [4, 12], [5, 11], [14, 20], [7, 38], [10, 39], [8, 32], [0, 37], [14, 17], [35, 38], [2, 32], [1, 8], [2, 25], [19, 37], [27, 31], [9, 39], [0, 10], [17, 20], [3, 25], [15, 31], [33, 36], [4, 14], [8, 37], [2, 30], [1, 11], [30, 32], [12, 35], [9, 10], [8, 29], [21, 24], [35, 39], [3, 32], [16, 20], [5, 24], [10, 38], [23, 28], [22, 33], [24, 35], [18, 39], [9, 28], [3, 12], [18, 31], [8, 9], [11, 27], [16, 19], [11, 34], [10, 16], [15, 17], [2, 24], [7, 23], [22, 26], [11, 36], [3, 6], [1, 36], [19, 36], [7, 27], [31, 34], [28, 39], [14, 34], [1, 7], [7, 31], [15, 25], [4, 30], [1, 27], [14, 36], [30, 39], [5, 12], [13, 14], [28, 35], [3, 28], [29, 37], [11, 17], [11, 28], [37, 39], [21, 31], [26, 29], [12, 16], [27, 37], [5, 13], [11, 20], [8, 26], [22, 24], [31, 33], [2, 3], [8, 31], [8, 13], [0, 6], [3, 11], [15, 39], [1, 18], [17, 30], [14, 37], [19, 24], [19, 29], [29, 35], [21, 38], [1, 6], [29, 32], [27, 39], [27, 29], [29, 38], [15, 24], [23, 32], [4, 11], [2, 29], [8, 28], [20, 27], [14, 28], [6, 37], [22, 36], [26, 35], [21, 39], [26, 27], [10, 33], [0, 22], [12, 34], [21, 29], [6, 16], [10, 34], [9, 24], [4, 19], [1, 15], [28, 33], [4, 18], [7, 15], [3, 35], [10, 24], [3, 9], [23, 35], [17, 25], [15, 34], [6, 28], [6, 30], [9, 19], [31, 37], [14, 18], [0, 24], [1, 20], [24, 36], [5, 25], [22, 23], [36, 37], [8, 15], [2, 18], [16, 36], [26, 38], [0, 11], [17, 22], [6, 10], [15, 26], [4, 15], [1, 29], [11, 30], [22, 38], [14, 33], [31, 39], [27, 34], [2, 14], [23, 37], [16, 27], [13, 36], [24, 39], [27, 28], [9, 33], [31, 36], [3, 22], [30, 34], [13, 33], [3, 31], [24, 27], [13, 39], [8, 36], [13, 34], [13, 22], [8, 27], [21, 30], [15, 33], [11, 35], [8, 24], [16, 24], [4, 27], [29, 34], [8, 16], [2, 33], [33, 35], [13, 21], [0, 36], [12, 30], [9, 17], [34, 36], [5, 15], [2, 11], [0, 8], [13, 24], [0, 23], [10, 14], [30, 38], [19, 32], [1, 33], [13, 37], [4, 8], [11, 23], [9, 13], [6, 29], [19, 35], [5, 16], [5, 21], [4, 26], [9, 27], [33, 39], [19, 21], [0, 34], [10, 37], [8, 39], [24, 29], [9, 23], [2, 17], [12, 29], [4, 5], [15, 23], [15, 18], [7, 12], [11, 26], [3, 36], [13, 29], [3, 27], [10, 31], [7, 30], [4, 32], [30, 31], [5, 17], [20, 34], [9, 31], [0, 26], [16, 35], [23, 30], [15, 37], [16, 22], [16, 17], [5, 27], [6, 15], [15, 22], [9, 14], [5, 23], [9, 22], [12, 20], [12, 18], [0, 25], [5, 7], [18, 25], [22, 28], [19, 30], [11, 16], [11, 38], [14, 31], [3, 19], [9, 16], [13, 16], [9, 26], [9, 21], [28, 38], [0, 31], [22, 30], [1, 16], [9, 30], [4, 25], [4, 33], [0, 39], [24, 37], [17, 23], [8, 17], [1, 4], [20, 33], [8, 33], [13, 25], [24, 32], [3, 38], [25, 31], [21, 25], [1, 10], [11, 12], [19, 31], [26, 33], [8, 34], [19, 22], [29, 39], [30, 36], [34, 35], [18, 38], [6, 21], [23, 39], [29, 30], [9, 36], [4, 10], [4, 28], [12, 25], [12, 32], [14, 35], [3, 20], [1, 35], [25, 30], [6, 35], [7, 36], [8, 19], [30, 33], [7, 10], [9, 11], [25, 33], [20, 29], [7, 20], [28, 36], [0, 15], [23, 29], [8, 14], [3, 18], [18, 23], [17, 34], [16, 23], [5, 33], [6, 8], [27, 30], [11, 22], [3, 30], [1, 19], [2, 19], [12, 27], [9, 20], [1, 34], [18, 21], [1, 37], [15, 27], [6, 9], [11, 32], [1, 21], [2, 22], [3, 34], [12, 38], [13, 15], [2, 9], [29, 36], [7, 24], [13, 30], [17, 29], [0, 19], [12, 14], [0, 35], [0, 5], [0, 14], [7, 37], [10, 25], [14, 21], [2, 26], [1, 22], [12, 33], [11, 19]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s2/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s2/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s5/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l6-s5/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..233ca16173d9601a72a7d42ad7e64e5979237697 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges1": [[13, 37], [14, 22], [8, 12], [33, 39], [4, 34], [18, 36], [12, 14], [15, 24], [9, 39], [31, 35], [15, 39], [13, 34], [2, 20], [24, 39], [9, 19], [5, 25], [19, 28], [10, 15], [12, 30], [8, 38], [1, 24], [29, 39], [15, 21], [16, 37], [25, 38], [3, 29], [25, 35], [8, 36], [9, 11], [27, 36], [3, 27], [2, 4], [5, 19], [20, 24], [13, 32], [12, 18], [3, 24], [9, 25], [17, 22], [30, 32], [25, 37], [10, 11], [29, 30], [0, 30], [10, 39], [27, 33], [14, 31], [13, 16], [1, 34], [4, 21], [5, 38], [30, 34], [6, 23], [5, 12], [15, 27], [21, 38], [3, 36], [13, 20], [3, 13], [7, 39], [14, 17], [14, 37], [16, 21], [35, 38], [0, 37], [18, 38], [6, 35], [4, 27], [26, 28], [20, 21], [3, 5], [25, 39], [12, 13], [6, 26], [1, 10], [13, 18], [13, 24], [3, 4], [4, 29], [17, 37], [17, 25], [28, 38], [7, 20], [9, 16], [6, 36], [0, 10], [23, 24], [16, 32], [0, 19], [4, 8], [3, 37], [4, 16], [19, 20], [20, 27], [0, 9], [25, 28], [12, 23], [29, 37], [7, 21], [19, 36], [26, 32], [15, 31], [8, 9], [7, 9], [17, 29], [6, 13], [19, 22], [16, 25], [4, 36], [4, 31], [3, 8], [0, 39], [20, 23], [15, 35], [17, 20], [9, 38], [6, 31], [7, 33], [11, 25], [4, 15], [3, 17], [5, 18], [5, 21], [3, 22], [30, 36], [4, 7], [14, 18], [12, 27], [10, 25], [17, 30], [16, 22], [8, 24], [4, 13], [1, 26], [5, 14], [3, 25], [1, 3], [14, 25], [5, 9], [0, 12], [13, 27], [9, 20], [19, 34], [8, 34], [23, 39], [0, 34], [10, 18], [4, 37], [7, 17], [8, 31], [8, 21], [22, 32], [34, 37], [18, 30], [8, 18], [14, 29], [13, 29], [0, 20], [21, 27], [8, 39], [18, 27], [15, 20], [2, 29], [25, 33], [6, 15], [10, 37], [13, 39], [12, 22], [11, 33], [6, 37], [22, 33], [17, 38], [28, 36], [5, 15], [16, 38], [5, 20], [19, 38], [8, 15], [3, 12], [6, 9], [15, 28], [17, 35], [2, 37], [0, 33], [22, 24], [9, 13], [20, 30], [18, 34], [2, 7], [32, 38], [28, 30], [33, 36], [14, 34], [0, 1], [0, 17], [6, 8], [10, 20], [7, 13], [35, 36], [20, 31], [5, 31], [18, 31], [8, 33], [15, 22], [3, 31], [16, 27], [34, 39], [6, 16], [30, 38], [2, 19], [1, 35], [16, 19], [31, 37], [19, 24], [20, 33], [28, 39], [3, 39], [11, 32], [9, 27], [3, 28], [18, 28], [8, 28], [33, 37], [12, 15], [21, 25], [13, 19], [4, 12], [12, 20], [10, 29], [7, 24], [4, 39], [11, 31], [16, 33], [8, 32], [17, 24], [9, 37], [9, 15], [7, 10], [24, 28], [22, 30], [24, 30], [9, 34], [12, 37], [34, 38], [0, 11], [23, 37], [11, 24], [1, 36], [11, 28], [0, 4], [12, 28], [23, 35], [1, 27], [27, 30], [25, 27], [35, 39], [16, 36], [18, 19], [7, 28], [17, 33], [1, 12], [17, 27], [16, 35], [2, 8], [1, 31], [2, 14], [8, 27], [2, 17], [8, 22], [20, 32], [23, 34], [22, 23], [5, 35], [13, 31], [3, 10], [32, 35], [16, 29], [12, 38], [6, 28], [4, 19], [23, 38], [11, 18], [12, 32], [21, 28], [15, 17], [24, 38], [4, 33], [3, 15], [1, 18], [4, 11], [12, 36], [3, 9], [14, 20], [20, 28], [19, 32], [8, 29], [22, 25], [2, 33], [24, 25], [7, 32], [2, 31], [29, 33], [22, 39], [3, 26], [4, 32], [24, 27], [16, 18], [16, 34], [23, 31], [7, 15], [8, 16], [9, 26], [10, 30], [7, 11], [27, 28], [21, 35], [15, 37], [10, 12], [6, 27], [33, 34], [28, 29], [16, 31], [14, 39], [31, 36], [9, 18], [21, 33], [28, 34], [6, 39], [2, 25], [25, 36], [20, 35], [2, 35], [11, 26], [20, 29], [11, 38], [2, 39], [12, 19], [0, 14], [4, 20], [2, 23], [2, 5], [27, 29], [3, 6], [2, 6], [11, 21], [12, 34], [1, 30], [6, 17], [2, 21], [3, 35], [1, 11], [4, 18], [13, 21], [2, 15], [2, 36], [34, 36], [29, 34], [5, 28], [14, 24], [11, 29], [7, 35], [15, 34], [11, 15], [10, 33], [6, 14], [25, 26], [14, 35], [0, 28], [2, 12], [5, 24], [13, 28], [21, 30], [9, 36], [1, 28], [24, 33], [2, 32], [24, 37], [20, 26], [19, 37], [33, 38], [5, 10], [0, 32], [38, 39], [17, 21], [10, 21], [12, 35], [32, 36], [22, 37], [14, 36], [9, 24], [37, 38], [13, 17], [8, 23], [3, 30], [31, 38], [18, 32], [13, 33], [18, 35], [12, 39], [13, 14], [17, 39], [6, 19], [18, 24], [22, 34], [24, 36], [3, 32], [1, 39], [1, 2], [0, 3], [14, 30], [19, 35], [16, 28], [19, 29], [10, 32], [1, 17], [20, 37], [4, 35], [16, 26], [5, 7], [19, 27], [2, 27], [1, 25], [30, 35], [7, 36], [7, 19], [18, 20], [18, 26], [17, 31], [17, 26]], "edges2": [[18, 30], [1, 4], [2, 30], [22, 39], [1, 22], [15, 18], [9, 22], [8, 11], [3, 18], [17, 28], [17, 33], [29, 30], [2, 8], [19, 24], [22, 30], [11, 18], [11, 17], [9, 17], [14, 19], [11, 13], [14, 36], [14, 20], [26, 35], [23, 37], [0, 21], [28, 32], [16, 33], [22, 24], [9, 10], [14, 27], [5, 20], [5, 36], [24, 28], [5, 9], [19, 38], [6, 9], [31, 34], [11, 34], [0, 27], [26, 32], [27, 37], [4, 6], [21, 25], [15, 28], [5, 21], [4, 18], [1, 24], [14, 38], [6, 19], [5, 39], [23, 26], [28, 29], [6, 18], [4, 14], [30, 38], [4, 30], [14, 23], [1, 12], [11, 26], [17, 37], [5, 33], [17, 32], [6, 21], [17, 22], [2, 22], [3, 12], [0, 30], [21, 23], [12, 14], [3, 27], [36, 39], [27, 35], [25, 37], [18, 20], [26, 39], [11, 36], [6, 26], [0, 12], [12, 31], [3, 17], [22, 34], [4, 9], [25, 29], [15, 27], [0, 9], [10, 37], [26, 31], [15, 23], [12, 26], [1, 9], [2, 6], [5, 25], [3, 9], [16, 39], [13, 34], [36, 37], [14, 15], [1, 23], [10, 28], [30, 35], [31, 38], [26, 36], [4, 15], [3, 20], [21, 22], [2, 31], [8, 18], [29, 36], [6, 7], [35, 39], [21, 24], [1, 5], [15, 19], [4, 39], [31, 36], [0, 35], [19, 20], [2, 39], [7, 22], [17, 31], [18, 36], [21, 34], [12, 20], [10, 32], [29, 37], [35, 37], [1, 20], [20, 33], [8, 27], [22, 36], [18, 28], [1, 18], [19, 33], [10, 31], [6, 17], [24, 27], [13, 22], [32, 33], [15, 24], [21, 30], [5, 30], [16, 18], [8, 29], [11, 38], [24, 35], [12, 27], [17, 24], [27, 28], [8, 10], [28, 39], [34, 35], [0, 16], [15, 35], [18, 26], [26, 27], [3, 39], [8, 13], [17, 36], [7, 27], [15, 38], [14, 32], [20, 25], [25, 31], [31, 33], [3, 25], [10, 13], [26, 29], [14, 39], [3, 26], [10, 36], [11, 29], [14, 33], [6, 11], [12, 32], [3, 22], [9, 19], [4, 34], [12, 35], [37, 38], [9, 38], [9, 37], [27, 34], [11, 30], [21, 31], [9, 29], [9, 34], [6, 36], [12, 15], [17, 27], [38, 39], [19, 34], [0, 17], [8, 30], [5, 18], [10, 33], [9, 32], [24, 32], [5, 10], [27, 30], [15, 21], [32, 36], [4, 31], [1, 25], [11, 39], [13, 14], [7, 28], [2, 23], [1, 16], [3, 24], [6, 13], [35, 38], [4, 24], [14, 18], [10, 14], [0, 20], [7, 9], [24, 39], [19, 25], [6, 25], [3, 34], [1, 35], [8, 21], [13, 17], [10, 25], [0, 26], [7, 12], [18, 31], [10, 38], [2, 37], [6, 20], [16, 29], [3, 36], [12, 13], [24, 37], [25, 35], [33, 35], [9, 21], [8, 38], [11, 12], [6, 29], [8, 23], [4, 16], [13, 28], [1, 27], [8, 12], [20, 38], [12, 38], [13, 16], [5, 23], [7, 31], [5, 28], [23, 29], [17, 35], [5, 35], [12, 24], [4, 28], [7, 8], [35, 36], [14, 35], [12, 34], [2, 11], [1, 32], [23, 31], [16, 17], [9, 23], [15, 39], [1, 2], [25, 34], [12, 29], [3, 10], [0, 36], [0, 8], [6, 10], [26, 34], [5, 38], [9, 26], [7, 23], [17, 34], [25, 27], [13, 20], [6, 16], [23, 32], [5, 15], [1, 10], [2, 20], [6, 34], [23, 28], [24, 36], [30, 34], [4, 25], [17, 39], [5, 6], [11, 31], [2, 12], [18, 39], [20, 27], [2, 16], [15, 33], [14, 22], [8, 20], [36, 38], [1, 26], [16, 21], [25, 32], [1, 39], [21, 35], [15, 34], [2, 3], [17, 25], [13, 24], [12, 16], [1, 31], [32, 38], [13, 23], [15, 25], [16, 36], [9, 20], [22, 27], [2, 17], [9, 39], [6, 31], [18, 21], [1, 11], [19, 29], [27, 31], [13, 35], [20, 34], [4, 12], [11, 14], [19, 35], [3, 28], [5, 13], [11, 28], [23, 27], [5, 32], [13, 33], [6, 38], [16, 35], [4, 26], [14, 28], [25, 36], [2, 36], [5, 29], [18, 19], [4, 36], [24, 31], [26, 28], [26, 38], [0, 7], [8, 39], [1, 15], [31, 37], [23, 38], [16, 25], [31, 39], [20, 23], [13, 27], [5, 19], [12, 28], [3, 15], [3, 23], [14, 26], [0, 3], [20, 24], [30, 31], [9, 16], [33, 36], [19, 28], [16, 23], [22, 28], [3, 32], [23, 24], [1, 6], [16, 32], [5, 31], [0, 29], [10, 27], [3, 35], [8, 22], [4, 8], [10, 17], [16, 30], [27, 39], [17, 29], [12, 37], [16, 20], [24, 26], [2, 38], [0, 10], [0, 6], [20, 29], [18, 29], [12, 21], [16, 38], [4, 5], [13, 15], [9, 35], [22, 31], [2, 24], [14, 16], [1, 28], [16, 19], [20, 31], [10, 39], [3, 29], [13, 29], [7, 32], [21, 39], [11, 37], [15, 16], [31, 35], [0, 34], [22, 35], [7, 29], [19, 22], [6, 32], [20, 37], [5, 24], [3, 14], [9, 30], [0, 15], [20, 26], [2, 18], [9, 14], [30, 37], [17, 38], [13, 18], [9, 12], [13, 37]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s5/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3fe11644c15dca61c9159b479283b4f5fd26d98b --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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' +{"p": [21, 0, 36, 9, 39, 37, 32, 2, 14, 23, 30, 8, 35, 1, 25, 38, 28, 6, 27, 24, 31, 11, 19, 33, 20, 29, 7, 26, 12, 4, 34, 10, 22, 18, 15, 17, 3, 5, 13, 16]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s5/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s5/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("p"), n, 0, n - 1, "p") + if len(set(p)) != n: + raise Invalid("p is not a permutation") + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + img = {(min(p[u], p[v]), max(p[u], p[v])) for u, v in inst["edges1"]} + if img != e2: + raise Invalid(f"{len(img - e2)} edges of G1 are not mapped onto edges of G2") + return None, {} diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s5/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..233ca16173d9601a72a7d42ad7e64e5979237697 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges1": [[13, 37], [14, 22], [8, 12], [33, 39], [4, 34], [18, 36], [12, 14], [15, 24], [9, 39], [31, 35], [15, 39], [13, 34], [2, 20], [24, 39], [9, 19], [5, 25], [19, 28], [10, 15], [12, 30], [8, 38], [1, 24], [29, 39], [15, 21], [16, 37], [25, 38], [3, 29], [25, 35], [8, 36], [9, 11], [27, 36], [3, 27], [2, 4], [5, 19], [20, 24], [13, 32], [12, 18], [3, 24], [9, 25], [17, 22], [30, 32], [25, 37], [10, 11], [29, 30], [0, 30], [10, 39], [27, 33], [14, 31], [13, 16], [1, 34], [4, 21], [5, 38], [30, 34], [6, 23], [5, 12], [15, 27], [21, 38], [3, 36], [13, 20], [3, 13], [7, 39], [14, 17], [14, 37], [16, 21], [35, 38], [0, 37], [18, 38], [6, 35], [4, 27], [26, 28], [20, 21], [3, 5], [25, 39], [12, 13], [6, 26], [1, 10], [13, 18], [13, 24], [3, 4], [4, 29], [17, 37], [17, 25], [28, 38], [7, 20], [9, 16], [6, 36], [0, 10], [23, 24], [16, 32], [0, 19], [4, 8], [3, 37], [4, 16], [19, 20], [20, 27], [0, 9], [25, 28], [12, 23], [29, 37], [7, 21], [19, 36], [26, 32], [15, 31], [8, 9], [7, 9], [17, 29], [6, 13], [19, 22], [16, 25], [4, 36], [4, 31], [3, 8], [0, 39], [20, 23], [15, 35], [17, 20], [9, 38], [6, 31], [7, 33], [11, 25], [4, 15], [3, 17], [5, 18], [5, 21], [3, 22], [30, 36], [4, 7], [14, 18], [12, 27], [10, 25], [17, 30], [16, 22], [8, 24], [4, 13], [1, 26], [5, 14], [3, 25], [1, 3], [14, 25], [5, 9], [0, 12], [13, 27], [9, 20], [19, 34], [8, 34], [23, 39], [0, 34], [10, 18], [4, 37], [7, 17], [8, 31], [8, 21], [22, 32], [34, 37], [18, 30], [8, 18], [14, 29], [13, 29], [0, 20], [21, 27], [8, 39], [18, 27], [15, 20], [2, 29], [25, 33], [6, 15], [10, 37], [13, 39], [12, 22], [11, 33], [6, 37], [22, 33], [17, 38], [28, 36], [5, 15], [16, 38], [5, 20], [19, 38], [8, 15], [3, 12], [6, 9], [15, 28], [17, 35], [2, 37], [0, 33], [22, 24], [9, 13], [20, 30], [18, 34], [2, 7], [32, 38], [28, 30], [33, 36], [14, 34], [0, 1], [0, 17], [6, 8], [10, 20], [7, 13], [35, 36], [20, 31], [5, 31], [18, 31], [8, 33], [15, 22], [3, 31], [16, 27], [34, 39], [6, 16], [30, 38], [2, 19], [1, 35], [16, 19], [31, 37], [19, 24], [20, 33], [28, 39], [3, 39], [11, 32], [9, 27], [3, 28], [18, 28], [8, 28], [33, 37], [12, 15], [21, 25], [13, 19], [4, 12], [12, 20], [10, 29], [7, 24], [4, 39], [11, 31], [16, 33], [8, 32], [17, 24], [9, 37], [9, 15], [7, 10], [24, 28], [22, 30], [24, 30], [9, 34], [12, 37], [34, 38], [0, 11], [23, 37], [11, 24], [1, 36], [11, 28], [0, 4], [12, 28], [23, 35], [1, 27], [27, 30], [25, 27], [35, 39], [16, 36], [18, 19], [7, 28], [17, 33], [1, 12], [17, 27], [16, 35], [2, 8], [1, 31], [2, 14], [8, 27], [2, 17], [8, 22], [20, 32], [23, 34], [22, 23], [5, 35], [13, 31], [3, 10], [32, 35], [16, 29], [12, 38], [6, 28], [4, 19], [23, 38], [11, 18], [12, 32], [21, 28], [15, 17], [24, 38], [4, 33], [3, 15], [1, 18], [4, 11], [12, 36], [3, 9], [14, 20], [20, 28], [19, 32], [8, 29], [22, 25], [2, 33], [24, 25], [7, 32], [2, 31], [29, 33], [22, 39], [3, 26], [4, 32], [24, 27], [16, 18], [16, 34], [23, 31], [7, 15], [8, 16], [9, 26], [10, 30], [7, 11], [27, 28], [21, 35], [15, 37], [10, 12], [6, 27], [33, 34], [28, 29], [16, 31], [14, 39], [31, 36], [9, 18], [21, 33], [28, 34], [6, 39], [2, 25], [25, 36], [20, 35], [2, 35], [11, 26], [20, 29], [11, 38], [2, 39], [12, 19], [0, 14], [4, 20], [2, 23], [2, 5], [27, 29], [3, 6], [2, 6], [11, 21], [12, 34], [1, 30], [6, 17], [2, 21], [3, 35], [1, 11], [4, 18], [13, 21], [2, 15], [2, 36], [34, 36], [29, 34], [5, 28], [14, 24], [11, 29], [7, 35], [15, 34], [11, 15], [10, 33], [6, 14], [25, 26], [14, 35], [0, 28], [2, 12], [5, 24], [13, 28], [21, 30], [9, 36], [1, 28], [24, 33], [2, 32], [24, 37], [20, 26], [19, 37], [33, 38], [5, 10], [0, 32], [38, 39], [17, 21], [10, 21], [12, 35], [32, 36], [22, 37], [14, 36], [9, 24], [37, 38], [13, 17], [8, 23], [3, 30], [31, 38], [18, 32], [13, 33], [18, 35], [12, 39], [13, 14], [17, 39], [6, 19], [18, 24], [22, 34], [24, 36], [3, 32], [1, 39], [1, 2], [0, 3], [14, 30], [19, 35], [16, 28], [19, 29], [10, 32], [1, 17], [20, 37], [4, 35], [16, 26], [5, 7], [19, 27], [2, 27], [1, 25], [30, 35], [7, 36], [7, 19], [18, 20], [18, 26], [17, 31], [17, 26]], "edges2": [[18, 30], [1, 4], [2, 30], [22, 39], [1, 22], [15, 18], [9, 22], [8, 11], [3, 18], [17, 28], [17, 33], [29, 30], [2, 8], [19, 24], [22, 30], [11, 18], [11, 17], [9, 17], [14, 19], [11, 13], [14, 36], [14, 20], [26, 35], [23, 37], [0, 21], [28, 32], [16, 33], [22, 24], [9, 10], [14, 27], [5, 20], [5, 36], [24, 28], [5, 9], [19, 38], [6, 9], [31, 34], [11, 34], [0, 27], [26, 32], [27, 37], [4, 6], [21, 25], [15, 28], [5, 21], [4, 18], [1, 24], [14, 38], [6, 19], [5, 39], [23, 26], [28, 29], [6, 18], [4, 14], [30, 38], [4, 30], [14, 23], [1, 12], [11, 26], [17, 37], [5, 33], [17, 32], [6, 21], [17, 22], [2, 22], [3, 12], [0, 30], [21, 23], [12, 14], [3, 27], [36, 39], [27, 35], [25, 37], [18, 20], [26, 39], [11, 36], [6, 26], [0, 12], [12, 31], [3, 17], [22, 34], [4, 9], [25, 29], [15, 27], [0, 9], [10, 37], [26, 31], [15, 23], [12, 26], [1, 9], [2, 6], [5, 25], [3, 9], [16, 39], [13, 34], [36, 37], [14, 15], [1, 23], [10, 28], [30, 35], [31, 38], [26, 36], [4, 15], [3, 20], [21, 22], [2, 31], [8, 18], [29, 36], [6, 7], [35, 39], [21, 24], [1, 5], [15, 19], [4, 39], [31, 36], [0, 35], [19, 20], [2, 39], [7, 22], [17, 31], [18, 36], [21, 34], [12, 20], [10, 32], [29, 37], [35, 37], [1, 20], [20, 33], [8, 27], [22, 36], [18, 28], [1, 18], [19, 33], [10, 31], [6, 17], [24, 27], [13, 22], [32, 33], [15, 24], [21, 30], [5, 30], [16, 18], [8, 29], [11, 38], [24, 35], [12, 27], [17, 24], [27, 28], [8, 10], [28, 39], [34, 35], [0, 16], [15, 35], [18, 26], [26, 27], [3, 39], [8, 13], [17, 36], [7, 27], [15, 38], [14, 32], [20, 25], [25, 31], [31, 33], [3, 25], [10, 13], [26, 29], [14, 39], [3, 26], [10, 36], [11, 29], [14, 33], [6, 11], [12, 32], [3, 22], [9, 19], [4, 34], [12, 35], [37, 38], [9, 38], [9, 37], [27, 34], [11, 30], [21, 31], [9, 29], [9, 34], [6, 36], [12, 15], [17, 27], [38, 39], [19, 34], [0, 17], [8, 30], [5, 18], [10, 33], [9, 32], [24, 32], [5, 10], [27, 30], [15, 21], [32, 36], [4, 31], [1, 25], [11, 39], [13, 14], [7, 28], [2, 23], [1, 16], [3, 24], [6, 13], [35, 38], [4, 24], [14, 18], [10, 14], [0, 20], [7, 9], [24, 39], [19, 25], [6, 25], [3, 34], [1, 35], [8, 21], [13, 17], [10, 25], [0, 26], [7, 12], [18, 31], [10, 38], [2, 37], [6, 20], [16, 29], [3, 36], [12, 13], [24, 37], [25, 35], [33, 35], [9, 21], [8, 38], [11, 12], [6, 29], [8, 23], [4, 16], [13, 28], [1, 27], [8, 12], [20, 38], [12, 38], [13, 16], [5, 23], [7, 31], [5, 28], [23, 29], [17, 35], [5, 35], [12, 24], [4, 28], [7, 8], [35, 36], [14, 35], [12, 34], [2, 11], [1, 32], [23, 31], [16, 17], [9, 23], [15, 39], [1, 2], [25, 34], [12, 29], [3, 10], [0, 36], [0, 8], [6, 10], [26, 34], [5, 38], [9, 26], [7, 23], [17, 34], [25, 27], [13, 20], [6, 16], [23, 32], [5, 15], [1, 10], [2, 20], [6, 34], [23, 28], [24, 36], [30, 34], [4, 25], [17, 39], [5, 6], [11, 31], [2, 12], [18, 39], [20, 27], [2, 16], [15, 33], [14, 22], [8, 20], [36, 38], [1, 26], [16, 21], [25, 32], [1, 39], [21, 35], [15, 34], [2, 3], [17, 25], [13, 24], [12, 16], [1, 31], [32, 38], [13, 23], [15, 25], [16, 36], [9, 20], [22, 27], [2, 17], [9, 39], [6, 31], [18, 21], [1, 11], [19, 29], [27, 31], [13, 35], [20, 34], [4, 12], [11, 14], [19, 35], [3, 28], [5, 13], [11, 28], [23, 27], [5, 32], [13, 33], [6, 38], [16, 35], [4, 26], [14, 28], [25, 36], [2, 36], [5, 29], [18, 19], [4, 36], [24, 31], [26, 28], [26, 38], [0, 7], [8, 39], [1, 15], [31, 37], [23, 38], [16, 25], [31, 39], [20, 23], [13, 27], [5, 19], [12, 28], [3, 15], [3, 23], [14, 26], [0, 3], [20, 24], [30, 31], [9, 16], [33, 36], [19, 28], [16, 23], [22, 28], [3, 32], [23, 24], [1, 6], [16, 32], [5, 31], [0, 29], [10, 27], [3, 35], [8, 22], [4, 8], [10, 17], [16, 30], [27, 39], [17, 29], [12, 37], [16, 20], [24, 26], [2, 38], [0, 10], [0, 6], [20, 29], [18, 29], [12, 21], [16, 38], [4, 5], [13, 15], [9, 35], [22, 31], [2, 24], [14, 16], [1, 28], [16, 19], [20, 31], [10, 39], [3, 29], [13, 29], [7, 32], [21, 39], [11, 37], [15, 16], [31, 35], [0, 34], [22, 35], [7, 29], [19, 22], [6, 32], [20, 37], [5, 24], [3, 14], [9, 30], [0, 15], [20, 26], [2, 18], [9, 14], [30, 37], [17, 38], [13, 18], [9, 12], [13, 37]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s5/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l6-s5/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-grid-parity-construction-l2-s4/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s4/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7d54b8cb5f4719015d0b912ad573c1a63d11a112 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["00011", "01011", "11000", "11110"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s4/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..921e124d8725ee2877900163db49534fbc6c508c --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["00000", "00011", "01111", "01101"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s4/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s4/tests/check.py @@ -0,0 +1,22 @@ +from run import Invalid + + +def check(inst, ans): + P = inst["parity"] + N, M = len(P), len(P[0]) + G = ans.get("grid") + if not isinstance(G, list) or len(G) != N: + raise Invalid(f"grid must be a list of {N} strings") + for r in G: + if not isinstance(r, str) or len(r) != M or set(r) - {"0", "1"}: + raise Invalid(f"each row must be a string of {M} characters '0'/'1'") + for i in range(N): + for j in range(M): + v = int(G[i][j]) + for di, dj in ((-1, 0), (1, 0), (0, -1), (0, 1)): + a, b = i + di, j + dj + if 0 <= a < N and 0 <= b < M: + v ^= int(G[a][b]) + if v != int(P[i][j]): + raise Invalid(f"parity mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s4/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7d54b8cb5f4719015d0b912ad573c1a63d11a112 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["00011", "01011", "11000", "11110"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s4/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s4/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l6-s2/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l6-s2/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e74bf2320c026479cbf12a70285ebd0c470d0f66 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["1101110101100000001", "1000010100111111101", "0100011100001110011", "1000110110111110110", "0001101001001101001", "1111010100101001001"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s2/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..124b4f6a01d98e4070727b112e228bdbbd230c18 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["1111011110111111111", "1011111001111111111", "1110111100111111100", "1011111110101110110", "1111110110100101011", "1101110111011110111"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s2/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s2/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-s2/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e74bf2320c026479cbf12a70285ebd0c470d0f66 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["1101110101100000001", "1000010100111111101", "0100011100001110011", "1000110110111110110", "0001101001001101001", "1111010100101001001"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s2/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l6-s2/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l6-s5/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l6-s5/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c4859f0e5c23b9e6555fdacedad2e6453dc27dad --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "100000", "110000", "100000", "000000", "010000", "101100", "001110", "111000", "101000", "000000"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s5/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..86542e768ddefe9d780e8af602b6e8f78b6396bf --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "100000", "000000", "000000", "000000", "010000", "010100", "101000", "000000", "000000"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s5/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s5/tests/check.py @@ -0,0 +1,22 @@ +from run import Invalid + + +def check(inst, ans): + P = inst["parity"] + N, M = len(P), len(P[0]) + G = ans.get("grid") + if not isinstance(G, list) or len(G) != N: + raise Invalid(f"grid must be a list of {N} strings") + for r in G: + if not isinstance(r, str) or len(r) != M or set(r) - {"0", "1"}: + raise Invalid(f"each row must be a string of {M} characters '0'/'1'") + for i in range(N): + for j in range(M): + v = int(G[i][j]) + for di, dj in ((-1, 0), (1, 0), (0, -1), (0, 1)): + a, b = i + di, j + dj + if 0 <= a < N and 0 <= b < M: + v ^= int(G[a][b]) + if v != int(P[i][j]): + raise Invalid(f"parity mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s5/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c4859f0e5c23b9e6555fdacedad2e6453dc27dad --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "000000", "100000", "110000", "100000", "000000", "010000", "101100", "001110", "111000", "101000", "000000"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s5/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l6-s5/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-imp-party-l4-s4/environment/Dockerfile b/tasks/construct-rlve-imp-party-l4-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-imp-party-l4-s4/environment/instance.json b/tasks/construct-rlve-imp-party-l4-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3f24dac74a54af9a0f3712a2fc7dcb61c1858437 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [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, 23], [0, 25], [0, 27], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 21], [1, 23], [1, 25], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [2, 3], [2, 7], [2, 11], [2, 15], [2, 18], [2, 25], [2, 27], [2, 28], [2, 31], [2, 32], [2, 33], [3, 5], [3, 6], [3, 7], [3, 8], [3, 11], [3, 12], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 31], [3, 32], [3, 33], [3, 35], [4, 7], [4, 8], [4, 11], [4, 16], [4, 19], [4, 23], [4, 25], [4, 27], [4, 29], [4, 32], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 12], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 27], [5, 28], [5, 29], [5, 31], [5, 32], [5, 33], [5, 35], [6, 7], [6, 8], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 21], [6, 23], [6, 25], [6, 26], [6, 27], [6, 28], [6, 29], [6, 31], [6, 32], [6, 33], [6, 34], [7, 8], [7, 11], [7, 12], [7, 14], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 21], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 31], [7, 32], [7, 33], [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, 31], [8, 32], [8, 33], [8, 34], [8, 35], [9, 12], [9, 14], [9, 15], [9, 16], [9, 23], [9, 25], [9, 28], [9, 31], [10, 11], [10, 15], [10, 16], [10, 21], [10, 23], [10, 25], [10, 28], [10, 32], [11, 12], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 31], [11, 32], [11, 33], [11, 34], [11, 35], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [12, 25], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 32], [12, 33], [12, 35], [13, 14], [13, 15], [13, 18], [13, 19], [13, 25], [13, 29], [13, 32], [13, 33], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [14, 21], [14, 22], [14, 23], [14, 25], [14, 27], [14, 28], [14, 29], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [15, 16], [15, 17], [15, 18], [15, 19], [15, 21], [15, 23], [15, 24], [15, 25], [15, 27], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 27], [16, 28], [16, 29], [16, 31], [16, 32], [16, 33], [16, 35], [17, 18], [17, 19], [17, 21], [17, 22], [17, 23], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [17, 31], [17, 32], [17, 33], [17, 35], [18, 19], [18, 21], [18, 23], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 31], [18, 32], [18, 33], [18, 35], [19, 21], [19, 23], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [19, 31], [19, 32], [19, 33], [19, 34], [20, 23], [20, 25], [20, 28], [20, 32], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [22, 23], [22, 25], [22, 29], [22, 32], [22, 33], [23, 24], [23, 25], [23, 27], [23, 28], [23, 29], [23, 30], [23, 31], [23, 32], [23, 33], [23, 34], [24, 25], [24, 28], [24, 29], [24, 32], [24, 33], [25, 27], [25, 28], [25, 29], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [26, 32], [26, 33], [27, 28], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 35], [28, 29], [28, 31], [28, 32], [28, 33], [28, 34], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [30, 32], [31, 32], [31, 33], [31, 34], [31, 35], [32, 33], [32, 34], [33, 34]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s4/solution/solve.sh b/tasks/construct-rlve-imp-party-l4-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c4ce92e7a067b5142981b989f073c943ecaea041 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [6, 7, 11, 14, 16, 17, 19, 23, 25, 27, 31, 33]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l4-s4/tests/check.py b/tasks/construct-rlve-imp-party-l4-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s4/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-s4/tests/instance.json b/tasks/construct-rlve-imp-party-l4-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3f24dac74a54af9a0f3712a2fc7dcb61c1858437 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [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, 23], [0, 25], [0, 27], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 21], [1, 23], [1, 25], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [2, 3], [2, 7], [2, 11], [2, 15], [2, 18], [2, 25], [2, 27], [2, 28], [2, 31], [2, 32], [2, 33], [3, 5], [3, 6], [3, 7], [3, 8], [3, 11], [3, 12], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 31], [3, 32], [3, 33], [3, 35], [4, 7], [4, 8], [4, 11], [4, 16], [4, 19], [4, 23], [4, 25], [4, 27], [4, 29], [4, 32], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 12], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 27], [5, 28], [5, 29], [5, 31], [5, 32], [5, 33], [5, 35], [6, 7], [6, 8], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 21], [6, 23], [6, 25], [6, 26], [6, 27], [6, 28], [6, 29], [6, 31], [6, 32], [6, 33], [6, 34], [7, 8], [7, 11], [7, 12], [7, 14], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 21], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 31], [7, 32], [7, 33], [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, 31], [8, 32], [8, 33], [8, 34], [8, 35], [9, 12], [9, 14], [9, 15], [9, 16], [9, 23], [9, 25], [9, 28], [9, 31], [10, 11], [10, 15], [10, 16], [10, 21], [10, 23], [10, 25], [10, 28], [10, 32], [11, 12], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 31], [11, 32], [11, 33], [11, 34], [11, 35], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 22], [12, 23], [12, 25], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 32], [12, 33], [12, 35], [13, 14], [13, 15], [13, 18], [13, 19], [13, 25], [13, 29], [13, 32], [13, 33], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [14, 21], [14, 22], [14, 23], [14, 25], [14, 27], [14, 28], [14, 29], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [15, 16], [15, 17], [15, 18], [15, 19], [15, 21], [15, 23], [15, 24], [15, 25], [15, 27], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [15, 35], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 27], [16, 28], [16, 29], [16, 31], [16, 32], [16, 33], [16, 35], [17, 18], [17, 19], [17, 21], [17, 22], [17, 23], [17, 25], [17, 26], [17, 27], [17, 28], [17, 29], [17, 31], [17, 32], [17, 33], [17, 35], [18, 19], [18, 21], [18, 23], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 31], [18, 32], [18, 33], [18, 35], [19, 21], [19, 23], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [19, 31], [19, 32], [19, 33], [19, 34], [20, 23], [20, 25], [20, 28], [20, 32], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [22, 23], [22, 25], [22, 29], [22, 32], [22, 33], [23, 24], [23, 25], [23, 27], [23, 28], [23, 29], [23, 30], [23, 31], [23, 32], [23, 33], [23, 34], [24, 25], [24, 28], [24, 29], [24, 32], [24, 33], [25, 27], [25, 28], [25, 29], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [26, 32], [26, 33], [27, 28], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 35], [28, 29], [28, 31], [28, 32], [28, 33], [28, 34], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [30, 32], [31, 32], [31, 33], [31, 34], [31, 35], [32, 33], [32, 34], [33, 34]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s4/tests/run.py b/tasks/construct-rlve-imp-party-l4-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-imp-party-l4-s4/tests/test.sh b/tasks/construct-rlve-imp-party-l4-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-integer-linear-system-l3-s4/environment/Dockerfile b/tasks/construct-rlve-integer-linear-system-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-integer-linear-system-l3-s4/environment/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..34f72d98ce9c2542457de393dcfe1616f857d3b7 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 1, 1, 0, 0, 1, 0, 0], [1, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 0, 1, 0, 0, 1, 1], [0, 1, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 0, 0, 1, 1], [0, 1, 1, 0, 0, 0, 1, 0], [1, 1, 0, 0, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 1, 1, 0, 1, 1], [1, 1, 0, 0, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 1, 1], [1, 0, 1, 1, 0, 1, 0, 1], [1, 1, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 1, 1], [1, 0, 0, 1, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 0, 1, 1, 1, 1]], "rhs": [22, 13, 14, 13, 16, 15, 6, 17, 12, 24, 17, 22, 22, 15, 23, 22, 24, 15, 11, 22], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s4/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3879132ae991028cad99f7d5afa5b751dc001c04 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [7, 4, 5, 3, 2, 6, 3, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l3-s4/tests/check.py b/tasks/construct-rlve-integer-linear-system-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s4/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-s4/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..34f72d98ce9c2542457de393dcfe1616f857d3b7 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 1, 1, 0, 0, 1, 0, 0], [1, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 0, 1, 0, 0, 1, 1], [0, 1, 0, 0, 0, 0, 0, 1], [0, 1, 1, 1, 0, 0, 1, 1], [0, 1, 1, 0, 0, 0, 1, 0], [1, 1, 0, 0, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 1, 1, 0, 1, 1], [1, 1, 0, 0, 1, 1, 1, 0], [0, 1, 0, 0, 0, 1, 1, 1], [1, 0, 1, 1, 0, 1, 0, 1], [1, 1, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 1, 1], [1, 0, 0, 1, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 0, 1, 1, 1, 1]], "rhs": [22, 13, 14, 13, 16, 15, 6, 17, 12, 24, 17, 22, 22, 15, 23, 22, 24, 15, 11, 22], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s4/tests/run.py b/tasks/construct-rlve-integer-linear-system-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-integer-linear-system-l3-s4/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s2/environment/Dockerfile b/tasks/construct-rlve-largest-convex-polygon-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s2/environment/instance.json b/tasks/construct-rlve-largest-convex-polygon-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4355fef1dc97fab595ebc1324cf4922b25b65c3d --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"points": [[2, 14], [12, 11], [1, 2], [5, 12], [2, 1], [11, 16], [18, 7], [12, 8], [1, 9], [9, 12], [13, 10], [18, 16], [11, 15], [4, 8], [0, 18], [14, 2], [4, 17], [13, 11]], "k": 9, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s2/solution/solve.sh b/tasks/construct-rlve-largest-convex-polygon-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..319811a7ce1900cb9b42e3f040a6b2cd3f5811b9 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [2, 8, 0, 16, 12, 17, 10, 7, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s2/tests/check.py b/tasks/construct-rlve-largest-convex-polygon-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3a09cc858f41ce5745e4e491188cd42360c65dae --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s2/tests/check.py @@ -0,0 +1,27 @@ +from run import Invalid, int_list + + +def _cross(o, a, b): + return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) + + +def check(inst, ans): + P, k = inst["points"], inst["k"] + idx = int_list(ans.get("indices"), None, 0, len(P) - 1, "indices") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + if len(idx) < k: + raise Invalid(f"{len(idx)} points given, need {k}") + pts = sorted(tuple(P[i]) for i in idx) + lower, upper = [], [] + for p in pts: # monotone chain, strict (collinear points dropped) + while len(lower) >= 2 and _cross(lower[-2], lower[-1], p) <= 0: + lower.pop() + lower.append(p) + for p in reversed(pts): + while len(upper) >= 2 and _cross(upper[-2], upper[-1], p) <= 0: + upper.pop() + upper.append(p) + if len(lower) + len(upper) - 2 != len(pts): + raise Invalid("the chosen points are not in convex position") + return None, {} diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s2/tests/instance.json b/tasks/construct-rlve-largest-convex-polygon-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4355fef1dc97fab595ebc1324cf4922b25b65c3d --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"points": [[2, 14], [12, 11], [1, 2], [5, 12], [2, 1], [11, 16], [18, 7], [12, 8], [1, 9], [9, 12], [13, 10], [18, 16], [11, 15], [4, 8], [0, 18], [14, 2], [4, 17], [13, 11]], "k": 9, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s2/tests/run.py b/tasks/construct-rlve-largest-convex-polygon-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s2/tests/test.sh b/tasks/construct-rlve-largest-convex-polygon-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s5/environment/Dockerfile b/tasks/construct-rlve-largest-convex-polygon-l4-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-largest-convex-polygon-l4-s5/environment/instance.json b/tasks/construct-rlve-largest-convex-polygon-l4-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..258d435bd33219e3d9ff2bf41716b5e17ddf8206 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s5/environment/instance.json @@ -0,0 +1 @@ +{"points": [[4, 4], [9, 10], [6, 2], [10, 5], [6, 15], [2, 7], [0, 0], [11, 16], [17, 0], [4, 6], [10, 7], [0, 18], [3, 13], [5, 6], [15, 9], [11, 17], [3, 15], [2, 8]], "k": 9, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s5/solution/solve.sh b/tasks/construct-rlve-largest-convex-polygon-l4-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..86c985c2eb669268114889294ac0cfbc5d1a98e7 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [5, 17, 12, 4, 15, 7, 1, 13, 9]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s5/tests/check.py b/tasks/construct-rlve-largest-convex-polygon-l4-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3a09cc858f41ce5745e4e491188cd42360c65dae --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s5/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-s5/tests/instance.json b/tasks/construct-rlve-largest-convex-polygon-l4-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..258d435bd33219e3d9ff2bf41716b5e17ddf8206 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s5/tests/instance.json @@ -0,0 +1 @@ +{"points": [[4, 4], [9, 10], [6, 2], [10, 5], [6, 15], [2, 7], [0, 0], [11, 16], [17, 0], [4, 6], [10, 7], [0, 18], [3, 13], [5, 6], [15, 9], [11, 17], [3, 15], [2, 8]], "k": 9, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s5/tests/run.py b/tasks/construct-rlve-largest-convex-polygon-l4-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-largest-convex-polygon-l4-s5/tests/test.sh b/tasks/construct-rlve-largest-convex-polygon-l4-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-rectangle-l6-s2/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l6-s2/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..046a680d987c159749394c6ed95800a04c3e0fda --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"points": [[-42, -3], [-6, -7], [4, -20], [7, 3], [55, -53], [-49, 1], [-31, 58], [-13, 43], [50, -59], [-46, 22], [17, -10], [-40, 5], [-46, 35], [49, 50], [31, -18], [52, -17], [-16, -3], [57, 20], [42, -22], [-49, 49], [-14, -4], [31, -4], [22, 25], [23, -54], [7, -45], [-41, -3], [-48, 58], [-33, -47], [60, 11], [-33, 0], [16, 3], [4, -41], [18, 49], [45, 24], [-33, 52], [59, -25], [40, 5], [-54, 34], [0, 48], [-20, 6], [-34, -23], [-12, 28], [47, -52], [22, 14], [38, -10], [36, -20], [2, 27], [4, 38], [23, -11], [-30, -13], [-60, -15], [-56, -44], [25, -54], [-57, 34], [-6, 32], [-1, 36], [-51, 52], [59, -52], [-44, -22], [-48, 20]], "area": 269, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l6-s2/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..33673bef2f42d9610e99874bc933d17b99a88802 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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' +{"indices": [1, 2, 10, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l6-s2/tests/check.py b/tasks/construct-rlve-largest-rectangle-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s2/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-s2/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..046a680d987c159749394c6ed95800a04c3e0fda --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"points": [[-42, -3], [-6, -7], [4, -20], [7, 3], [55, -53], [-49, 1], [-31, 58], [-13, 43], [50, -59], [-46, 22], [17, -10], [-40, 5], [-46, 35], [49, 50], [31, -18], [52, -17], [-16, -3], [57, 20], [42, -22], [-49, 49], [-14, -4], [31, -4], [22, 25], [23, -54], [7, -45], [-41, -3], [-48, 58], [-33, -47], [60, 11], [-33, 0], [16, 3], [4, -41], [18, 49], [45, 24], [-33, 52], [59, -25], [40, 5], [-54, 34], [0, 48], [-20, 6], [-34, -23], [-12, 28], [47, -52], [22, 14], [38, -10], [36, -20], [2, 27], [4, 38], [23, -11], [-30, -13], [-60, -15], [-56, -44], [25, -54], [-57, 34], [-6, 32], [-1, 36], [-51, 52], [59, -52], [-44, -22], [-48, 20]], "area": 269, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l6-s2/tests/run.py b/tasks/construct-rlve-largest-rectangle-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l6-s2/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l6-s5/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l6-s5/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3666d822e5a0fe6483047ac35b425ac4d780d989 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"points": [[12, 42], [47, 43], [3, -57], [10, -10], [35, 55], [-4, 5], [-18, 32], [-38, 3], [-21, -18], [-17, 57], [27, -53], [-26, -20], [20, -26], [-6, -40], [-18, -18], [-20, 17], [54, 53], [60, 12], [-43, -28], [14, 5], [47, -53], [-50, 7], [-52, 35], [4, 26], [-30, -21], [-27, -3], [10, -46], [29, 1], [3, 34], [31, 18], [30, -45], [45, -23], [8, 47], [26, 11], [2, 36], [34, 19], [51, -14], [-19, -9], [30, 4], [40, -45], [-27, -23], [18, 19], [12, 52], [35, 47], [39, -24], [-2, -39], [-12, -60], [-24, -24], [-27, 18], [8, 27], [6, -24], [-12, 28], [-9, -16], [36, 30], [0, -15], [-27, -15], [-21, 59], [-11, -38], [49, -38], [-34, 45]], "area": 45, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l6-s5/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f51e625ba57fd33e44f3ae09f455a2630327d107 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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' +{"indices": [8, 47, 24, 55]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l6-s5/tests/check.py b/tasks/construct-rlve-largest-rectangle-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s5/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-s5/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3666d822e5a0fe6483047ac35b425ac4d780d989 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"points": [[12, 42], [47, 43], [3, -57], [10, -10], [35, 55], [-4, 5], [-18, 32], [-38, 3], [-21, -18], [-17, 57], [27, -53], [-26, -20], [20, -26], [-6, -40], [-18, -18], [-20, 17], [54, 53], [60, 12], [-43, -28], [14, 5], [47, -53], [-50, 7], [-52, 35], [4, 26], [-30, -21], [-27, -3], [10, -46], [29, 1], [3, 34], [31, 18], [30, -45], [45, -23], [8, 47], [26, 11], [2, 36], [34, 19], [51, -14], [-19, -9], [30, 4], [40, -45], [-27, -23], [18, 19], [12, 52], [35, 47], [39, -24], [-2, -39], [-12, -60], [-24, -24], [-27, 18], [8, 27], [6, -24], [-12, 28], [-9, -16], [36, 30], [0, -15], [-27, -15], [-21, 59], [-11, -38], [49, -38], [-34, 45]], "area": 45, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l6-s5/tests/run.py b/tasks/construct-rlve-largest-rectangle-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l6-s5/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-matrix-permutation-equivalence-l1-s8/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..153e2ff6a4f0a6f084f4c1f78093640291e2454e --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"A": ["100", "000"], "B": ["000", "010"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5f8d5de1bac69ca909d5dda6ec14992c8a171c45 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"a": [1, 0], "b": [1, 0, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..153e2ff6a4f0a6f084f4c1f78093640291e2454e --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"A": ["100", "000"], "B": ["000", "010"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b85bf75664e65de3a9898313218e03b9c6c231bb --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/environment/instance.json @@ -0,0 +1 @@ +{"A": ["111", "101", "110"], "B": ["111", "011", "110"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cd6beae962631594a973bdd060fdd5fe4c024c70 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"a": [0, 2, 1], "b": [2, 0, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b85bf75664e65de3a9898313218e03b9c6c231bb --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/tests/instance.json @@ -0,0 +1 @@ +{"A": ["111", "101", "110"], "B": ["111", "011", "110"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ae08e3bb1c15a62673ad2cdfecc702df2deebdcb --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/environment/instance.json @@ -0,0 +1 @@ +{"A": ["111011101111", "101110111111"], "B": ["110011111111", "111111010111"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5b5eb9e3b93d862baf1c1a7331eeb689ae8e0ee1 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"a": [0, 1], "b": [10, 4, 7, 3, 8, 0, 1, 2, 5, 9, 6, 11]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ae08e3bb1c15a62673ad2cdfecc702df2deebdcb --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/tests/instance.json @@ -0,0 +1 @@ +{"A": ["111011101111", "101110111111"], "B": ["110011111111", "111111010111"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l5-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s3/environment/Dockerfile b/tasks/construct-rlve-max-achromatic-coloring-l4-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s3/environment/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l4-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..71c4c53a3a912f59392044e94ed937eed7e41a67 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 6, "edges": [[0, 6], [0, 11], [1, 3], [1, 5], [1, 7], [1, 11], [2, 3], [2, 5], [2, 6], [2, 7], [3, 4], [3, 9], [3, 11], [4, 5], [4, 10], [4, 11], [5, 7], [5, 8], [6, 9], [6, 11], [7, 9], [7, 11], [8, 11]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s3/solution/solve.sh b/tasks/construct-rlve-max-achromatic-coloring-l4-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..48faa7c57a32cb30f5cb1d69b48e83ced9917add --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 1, 0, 2, 0, 2, 1, 3, 4, 4, 4, 5]} +RLMATH_EOF diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s3/tests/check.py b/tasks/construct-rlve-max-achromatic-coloring-l4-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..bb676a518264e5db4fb0964e27ccffccf6980807 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s3/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + if len(set(c)) != k: + raise Invalid(f"uses {len(set(c))} colours, need all {k}") + pairs = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pairs.add((min(c[u], c[v]), max(c[u], c[v]))) + if len(pairs) != k * (k - 1) // 2: + raise Invalid("some pair of colours is not joined by an edge") + return None, {} diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s3/tests/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l4-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..71c4c53a3a912f59392044e94ed937eed7e41a67 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 6, "edges": [[0, 6], [0, 11], [1, 3], [1, 5], [1, 7], [1, 11], [2, 3], [2, 5], [2, 6], [2, 7], [3, 4], [3, 9], [3, 11], [4, 5], [4, 10], [4, 11], [5, 7], [5, 8], [6, 9], [6, 11], [7, 9], [7, 11], [8, 11]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s3/tests/run.py b/tasks/construct-rlve-max-achromatic-coloring-l4-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s3/tests/test.sh b/tasks/construct-rlve-max-achromatic-coloring-l4-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s4/environment/Dockerfile b/tasks/construct-rlve-max-achromatic-coloring-l4-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s4/environment/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l4-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bdbbea0054d343ad884948486a06aab54925a5ad --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 6, "edges": [[0, 2], [0, 3], [0, 5], [0, 11], [1, 2], [1, 5], [1, 6], [1, 7], [1, 10], [2, 5], [2, 6], [2, 9], [2, 10], [3, 4], [3, 7], [3, 9], [3, 10], [3, 11], [4, 5], [5, 8], [6, 10], [6, 11], [7, 10]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s4/solution/solve.sh b/tasks/construct-rlve-max-achromatic-coloring-l4-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..dfe0dbf8e8df0f513ccbba6328d89136d8a684a8 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 0, 1, 2, 0, 2, 3, 4, 3, 4, 5, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s4/tests/check.py b/tasks/construct-rlve-max-achromatic-coloring-l4-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..bb676a518264e5db4fb0964e27ccffccf6980807 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-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("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-s4/tests/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l4-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bdbbea0054d343ad884948486a06aab54925a5ad --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 6, "edges": [[0, 2], [0, 3], [0, 5], [0, 11], [1, 2], [1, 5], [1, 6], [1, 7], [1, 10], [2, 5], [2, 6], [2, 9], [2, 10], [3, 4], [3, 7], [3, 9], [3, 10], [3, 11], [4, 5], [5, 8], [6, 10], [6, 11], [7, 10]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s4/tests/run.py b/tasks/construct-rlve-max-achromatic-coloring-l4-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s4/tests/test.sh b/tasks/construct-rlve-max-achromatic-coloring-l4-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-maximum-clique-l6-s0/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l6-s0/environment/instance.json b/tasks/construct-rlve-maximum-clique-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1f818f2d1b0727dbe9288bb4753265cdcc683eb3 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 10, "edges": [[0, 1], [0, 3], [0, 5], [0, 6], [0, 8], [0, 10], [0, 13], [0, 14], [0, 16], [0, 17], [0, 18], [0, 19], [0, 21], [0, 23], [0, 24], [0, 26], [0, 27], [0, 28], [0, 31], [0, 32], [0, 36], [0, 37], [0, 39], [0, 40], [0, 42], [0, 44], [0, 45], [0, 50], [0, 51], [0, 53], [0, 55], [1, 2], [1, 3], [1, 4], [1, 5], [1, 9], [1, 10], [1, 12], [1, 14], [1, 15], [1, 17], [1, 18], [1, 19], [1, 20], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 31], [1, 33], [1, 34], [1, 35], [1, 39], [1, 41], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 47], [1, 49], [1, 50], [1, 52], [1, 53], [2, 4], [2, 6], [2, 8], [2, 9], [2, 10], [2, 11], [2, 17], [2, 18], [2, 20], [2, 21], [2, 23], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 35], [2, 38], [2, 39], [2, 40], [2, 42], [2, 45], [2, 46], [2, 47], [2, 48], [2, 50], [2, 51], [2, 53], [2, 54], [2, 55], [3, 4], [3, 7], [3, 8], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 19], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 32], [3, 33], [3, 34], [3, 35], [3, 38], [3, 40], [3, 41], [3, 44], [3, 47], [3, 48], [3, 50], [3, 54], [3, 55], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 23], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 39], [4, 40], [4, 43], [4, 47], [4, 49], [4, 51], [5, 6], [5, 12], [5, 14], [5, 15], [5, 16], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 24], [5, 25], [5, 26], [5, 27], [5, 32], [5, 33], [5, 34], [5, 35], [5, 36], [5, 40], [5, 41], [5, 43], [5, 45], [5, 47], [5, 48], [5, 50], [5, 51], [5, 52], [5, 53], [5, 55], [6, 7], [6, 9], [6, 10], [6, 12], [6, 14], [6, 15], [6, 16], [6, 17], [6, 21], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 28], [6, 30], [6, 33], [6, 34], [6, 35], [6, 36], [6, 39], [6, 42], [6, 44], [6, 46], [6, 49], [6, 51], [6, 52], [6, 53], [6, 55], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 18], [7, 19], [7, 20], [7, 21], [7, 23], [7, 24], [7, 27], [7, 29], [7, 30], [7, 32], [7, 34], [7, 36], [7, 37], [7, 38], [7, 42], [7, 43], [7, 44], [7, 47], [7, 48], [7, 50], [7, 51], [7, 53], [7, 55], [8, 9], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 19], [8, 20], [8, 23], [8, 26], [8, 29], [8, 34], [8, 36], [8, 38], [8, 40], [8, 43], [8, 45], [8, 47], [8, 48], [8, 49], [8, 51], [8, 53], [8, 55], [9, 13], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 27], [9, 29], [9, 30], [9, 31], [9, 32], [9, 35], [9, 37], [9, 40], [9, 41], [9, 42], [9, 43], [9, 45], [9, 46], [9, 47], [9, 48], [9, 49], [9, 50], [9, 52], [9, 53], [9, 55], [10, 12], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 23], [10, 25], [10, 26], [10, 29], [10, 31], [10, 32], [10, 33], [10, 38], [10, 39], [10, 42], [10, 45], [10, 47], [10, 49], [10, 54], [10, 55], [11, 13], [11, 14], [11, 16], [11, 18], [11, 19], [11, 20], [11, 22], [11, 23], [11, 24], [11, 27], [11, 28], [11, 29], [11, 31], [11, 32], [11, 36], [11, 38], [11, 39], [11, 40], [11, 41], [11, 42], [11, 45], [11, 47], [11, 50], [11, 54], [11, 55], [12, 14], [12, 17], [12, 19], [12, 20], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 32], [12, 39], [12, 40], [12, 43], [12, 45], [12, 46], [12, 48], [12, 50], [12, 51], [12, 53], [12, 54], [13, 14], [13, 16], [13, 21], [13, 22], [13, 24], [13, 26], [13, 28], [13, 29], [13, 30], [13, 32], [13, 33], [13, 34], [13, 35], [13, 36], [13, 37], [13, 39], [13, 41], [13, 42], [13, 43], [13, 44], [13, 46], [13, 48], [13, 50], [13, 51], [13, 52], [13, 54], [13, 55], [14, 16], [14, 18], [14, 19], [14, 20], [14, 21], [14, 24], [14, 25], [14, 26], [14, 28], [14, 31], [14, 33], [14, 34], [14, 35], [14, 37], [14, 38], [14, 39], [14, 41], [14, 45], [14, 46], [14, 47], [14, 49], [14, 50], [14, 51], [14, 52], [14, 55], [15, 19], [15, 22], [15, 23], [15, 26], [15, 30], [15, 33], [15, 34], [15, 36], [15, 40], [15, 41], [15, 43], [15, 44], [15, 46], [15, 49], [15, 50], [15, 51], [15, 52], [15, 53], [16, 17], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 26], [16, 30], [16, 31], [16, 32], [16, 33], [16, 34], [16, 35], [16, 36], [16, 37], [16, 38], [16, 41], [16, 42], [16, 43], [16, 44], [16, 45], [16, 46], [16, 47], [16, 48], [16, 49], [16, 50], [16, 52], [16, 55], [17, 18], [17, 19], [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, 36], [17, 38], [17, 39], [17, 42], [17, 43], [17, 44], [17, 49], [17, 50], [17, 51], [17, 53], [17, 54], [17, 55], [18, 19], [18, 24], [18, 27], [18, 28], [18, 31], [18, 32], [18, 34], [18, 36], [18, 40], [18, 42], [18, 43], [18, 46], [18, 47], [18, 48], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [18, 55], [19, 23], [19, 24], [19, 25], [19, 27], [19, 29], [19, 30], [19, 31], [19, 33], [19, 35], [19, 38], [19, 40], [19, 41], [19, 43], [19, 46], [19, 47], [19, 48], [19, 49], [19, 50], [19, 51], [19, 52], [19, 54], [19, 55], [20, 22], [20, 23], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 33], [20, 34], [20, 35], [20, 36], [20, 39], [20, 40], [20, 41], [20, 42], [20, 43], [20, 45], [20, 46], [20, 47], [20, 48], [20, 49], [20, 50], [20, 51], [20, 52], [20, 53], [20, 54], [21, 22], [21, 23], [21, 24], [21, 27], [21, 28], [21, 30], [21, 32], [21, 34], [21, 35], [21, 36], [21, 38], [21, 40], [21, 41], [21, 45], [21, 47], [21, 49], [21, 51], [21, 52], [21, 53], [21, 54], [21, 55], [22, 24], [22, 25], [22, 26], [22, 27], [22, 29], [22, 30], [22, 31], [22, 32], [22, 33], [22, 34], [22, 35], [22, 36], [22, 38], [22, 39], [22, 41], [22, 42], [22, 46], [22, 47], [22, 49], [22, 51], [22, 55], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 31], [23, 32], [23, 33], [23, 34], [23, 37], [23, 38], [23, 39], [23, 41], [23, 42], [23, 43], [23, 46], [23, 47], [23, 50], [23, 51], [23, 52], [23, 53], [23, 55], [24, 25], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 33], [24, 34], [24, 35], [24, 37], [24, 38], [24, 39], [24, 40], [24, 41], [24, 43], [24, 47], [24, 49], [24, 50], [24, 51], [24, 53], [24, 54], [25, 26], [25, 28], [25, 30], [25, 31], [25, 32], [25, 33], [25, 35], [25, 37], [25, 40], [25, 41], [25, 43], [25, 45], [25, 46], [25, 47], [25, 50], [25, 53], [26, 28], [26, 30], [26, 32], [26, 33], [26, 35], [26, 41], [26, 43], [26, 46], [26, 47], [26, 49], [26, 51], [26, 52], [26, 53], [26, 54], [26, 55], [27, 32], [27, 33], [27, 35], [27, 36], [27, 40], [27, 41], [27, 42], [27, 44], [27, 46], [27, 47], [27, 49], [27, 50], [27, 51], [27, 52], [27, 53], [27, 54], [27, 55], [28, 30], [28, 33], [28, 37], [28, 38], [28, 39], [28, 41], [28, 42], [28, 44], [28, 45], [28, 47], [28, 48], [28, 49], [28, 50], [28, 51], [28, 52], [28, 53], [28, 54], [28, 55], [29, 31], [29, 32], [29, 33], [29, 35], [29, 36], [29, 39], [29, 41], [29, 42], [29, 46], [29, 48], [29, 49], [29, 50], [29, 52], [29, 53], [29, 54], [29, 55], [30, 33], [30, 35], [30, 36], [30, 40], [30, 41], [30, 42], [30, 43], [30, 44], [30, 45], [30, 46], [30, 47], [30, 48], [30, 49], [30, 50], [30, 53], [30, 54], [31, 33], [31, 35], [31, 37], [31, 38], [31, 39], [31, 40], [31, 41], [31, 44], [31, 46], [31, 47], [31, 49], [31, 51], [31, 52], [31, 53], [31, 54], [31, 55], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 38], [32, 39], [32, 42], [32, 43], [32, 45], [32, 46], [32, 50], [32, 51], [32, 52], [32, 55], [33, 34], [33, 35], [33, 36], [33, 38], [33, 43], [33, 45], [33, 46], [33, 48], [33, 49], [33, 50], [33, 51], [33, 53], [33, 54], [33, 55], [34, 35], [34, 36], [34, 37], [34, 40], [34, 43], [34, 45], [34, 46], [34, 48], [34, 49], [34, 50], [34, 51], [34, 53], [34, 54], [34, 55], [35, 36], [35, 37], [35, 39], [35, 40], [35, 41], [35, 44], [35, 45], [35, 51], [35, 54], [35, 55], [36, 37], [36, 39], [36, 40], [36, 42], [36, 43], [36, 44], [36, 45], [36, 46], [36, 49], [36, 51], [36, 52], [36, 53], [36, 54], [37, 38], [37, 39], [37, 40], [37, 41], [37, 43], [37, 44], [37, 47], [37, 49], [37, 50], [37, 51], [37, 52], [37, 55], [38, 39], [38, 40], [38, 42], [38, 43], [38, 45], [38, 46], [38, 48], [38, 49], [38, 50], [38, 51], [38, 52], [38, 53], [38, 54], [39, 41], [39, 43], [39, 44], [39, 47], [39, 48], [39, 50], [39, 51], [39, 53], [39, 54], [39, 55], [40, 44], [40, 46], [40, 47], [40, 48], [40, 49], [40, 53], [41, 42], [41, 52], [41, 53], [41, 55], [42, 43], [42, 44], [42, 45], [42, 46], [42, 47], [42, 48], [42, 49], [42, 50], [42, 51], [42, 52], [42, 53], [43, 44], [43, 45], [43, 46], [43, 47], [43, 50], [43, 51], [44, 45], [44, 48], [44, 49], [44, 50], [44, 55], [45, 46], [45, 47], [45, 50], [45, 51], [45, 54], [45, 55], [46, 48], [46, 49], [46, 50], [46, 51], [46, 53], [46, 54], [47, 48], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [47, 54], [47, 55], [48, 49], [48, 51], [48, 54], [49, 51], [49, 54], [49, 55], [50, 51], [50, 52], [50, 53], [51, 54], [52, 54], [53, 54], [53, 55], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s0/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..25e30955d6a0ccb6a7aa5fb0e390ffcb6df4097a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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' +{"clique": [1, 2, 9, 20, 23, 27, 42, 46, 50, 53]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l6-s0/tests/check.py b/tasks/construct-rlve-maximum-clique-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s0/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l6-s0/tests/instance.json b/tasks/construct-rlve-maximum-clique-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1f818f2d1b0727dbe9288bb4753265cdcc683eb3 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 10, "edges": [[0, 1], [0, 3], [0, 5], [0, 6], [0, 8], [0, 10], [0, 13], [0, 14], [0, 16], [0, 17], [0, 18], [0, 19], [0, 21], [0, 23], [0, 24], [0, 26], [0, 27], [0, 28], [0, 31], [0, 32], [0, 36], [0, 37], [0, 39], [0, 40], [0, 42], [0, 44], [0, 45], [0, 50], [0, 51], [0, 53], [0, 55], [1, 2], [1, 3], [1, 4], [1, 5], [1, 9], [1, 10], [1, 12], [1, 14], [1, 15], [1, 17], [1, 18], [1, 19], [1, 20], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 31], [1, 33], [1, 34], [1, 35], [1, 39], [1, 41], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 47], [1, 49], [1, 50], [1, 52], [1, 53], [2, 4], [2, 6], [2, 8], [2, 9], [2, 10], [2, 11], [2, 17], [2, 18], [2, 20], [2, 21], [2, 23], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 35], [2, 38], [2, 39], [2, 40], [2, 42], [2, 45], [2, 46], [2, 47], [2, 48], [2, 50], [2, 51], [2, 53], [2, 54], [2, 55], [3, 4], [3, 7], [3, 8], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 19], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 32], [3, 33], [3, 34], [3, 35], [3, 38], [3, 40], [3, 41], [3, 44], [3, 47], [3, 48], [3, 50], [3, 54], [3, 55], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 23], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 39], [4, 40], [4, 43], [4, 47], [4, 49], [4, 51], [5, 6], [5, 12], [5, 14], [5, 15], [5, 16], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 24], [5, 25], [5, 26], [5, 27], [5, 32], [5, 33], [5, 34], [5, 35], [5, 36], [5, 40], [5, 41], [5, 43], [5, 45], [5, 47], [5, 48], [5, 50], [5, 51], [5, 52], [5, 53], [5, 55], [6, 7], [6, 9], [6, 10], [6, 12], [6, 14], [6, 15], [6, 16], [6, 17], [6, 21], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 28], [6, 30], [6, 33], [6, 34], [6, 35], [6, 36], [6, 39], [6, 42], [6, 44], [6, 46], [6, 49], [6, 51], [6, 52], [6, 53], [6, 55], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 18], [7, 19], [7, 20], [7, 21], [7, 23], [7, 24], [7, 27], [7, 29], [7, 30], [7, 32], [7, 34], [7, 36], [7, 37], [7, 38], [7, 42], [7, 43], [7, 44], [7, 47], [7, 48], [7, 50], [7, 51], [7, 53], [7, 55], [8, 9], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 17], [8, 19], [8, 20], [8, 23], [8, 26], [8, 29], [8, 34], [8, 36], [8, 38], [8, 40], [8, 43], [8, 45], [8, 47], [8, 48], [8, 49], [8, 51], [8, 53], [8, 55], [9, 13], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 27], [9, 29], [9, 30], [9, 31], [9, 32], [9, 35], [9, 37], [9, 40], [9, 41], [9, 42], [9, 43], [9, 45], [9, 46], [9, 47], [9, 48], [9, 49], [9, 50], [9, 52], [9, 53], [9, 55], [10, 12], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 23], [10, 25], [10, 26], [10, 29], [10, 31], [10, 32], [10, 33], [10, 38], [10, 39], [10, 42], [10, 45], [10, 47], [10, 49], [10, 54], [10, 55], [11, 13], [11, 14], [11, 16], [11, 18], [11, 19], [11, 20], [11, 22], [11, 23], [11, 24], [11, 27], [11, 28], [11, 29], [11, 31], [11, 32], [11, 36], [11, 38], [11, 39], [11, 40], [11, 41], [11, 42], [11, 45], [11, 47], [11, 50], [11, 54], [11, 55], [12, 14], [12, 17], [12, 19], [12, 20], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 32], [12, 39], [12, 40], [12, 43], [12, 45], [12, 46], [12, 48], [12, 50], [12, 51], [12, 53], [12, 54], [13, 14], [13, 16], [13, 21], [13, 22], [13, 24], [13, 26], [13, 28], [13, 29], [13, 30], [13, 32], [13, 33], [13, 34], [13, 35], [13, 36], [13, 37], [13, 39], [13, 41], [13, 42], [13, 43], [13, 44], [13, 46], [13, 48], [13, 50], [13, 51], [13, 52], [13, 54], [13, 55], [14, 16], [14, 18], [14, 19], [14, 20], [14, 21], [14, 24], [14, 25], [14, 26], [14, 28], [14, 31], [14, 33], [14, 34], [14, 35], [14, 37], [14, 38], [14, 39], [14, 41], [14, 45], [14, 46], [14, 47], [14, 49], [14, 50], [14, 51], [14, 52], [14, 55], [15, 19], [15, 22], [15, 23], [15, 26], [15, 30], [15, 33], [15, 34], [15, 36], [15, 40], [15, 41], [15, 43], [15, 44], [15, 46], [15, 49], [15, 50], [15, 51], [15, 52], [15, 53], [16, 17], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 26], [16, 30], [16, 31], [16, 32], [16, 33], [16, 34], [16, 35], [16, 36], [16, 37], [16, 38], [16, 41], [16, 42], [16, 43], [16, 44], [16, 45], [16, 46], [16, 47], [16, 48], [16, 49], [16, 50], [16, 52], [16, 55], [17, 18], [17, 19], [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, 36], [17, 38], [17, 39], [17, 42], [17, 43], [17, 44], [17, 49], [17, 50], [17, 51], [17, 53], [17, 54], [17, 55], [18, 19], [18, 24], [18, 27], [18, 28], [18, 31], [18, 32], [18, 34], [18, 36], [18, 40], [18, 42], [18, 43], [18, 46], [18, 47], [18, 48], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [18, 55], [19, 23], [19, 24], [19, 25], [19, 27], [19, 29], [19, 30], [19, 31], [19, 33], [19, 35], [19, 38], [19, 40], [19, 41], [19, 43], [19, 46], [19, 47], [19, 48], [19, 49], [19, 50], [19, 51], [19, 52], [19, 54], [19, 55], [20, 22], [20, 23], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 33], [20, 34], [20, 35], [20, 36], [20, 39], [20, 40], [20, 41], [20, 42], [20, 43], [20, 45], [20, 46], [20, 47], [20, 48], [20, 49], [20, 50], [20, 51], [20, 52], [20, 53], [20, 54], [21, 22], [21, 23], [21, 24], [21, 27], [21, 28], [21, 30], [21, 32], [21, 34], [21, 35], [21, 36], [21, 38], [21, 40], [21, 41], [21, 45], [21, 47], [21, 49], [21, 51], [21, 52], [21, 53], [21, 54], [21, 55], [22, 24], [22, 25], [22, 26], [22, 27], [22, 29], [22, 30], [22, 31], [22, 32], [22, 33], [22, 34], [22, 35], [22, 36], [22, 38], [22, 39], [22, 41], [22, 42], [22, 46], [22, 47], [22, 49], [22, 51], [22, 55], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 31], [23, 32], [23, 33], [23, 34], [23, 37], [23, 38], [23, 39], [23, 41], [23, 42], [23, 43], [23, 46], [23, 47], [23, 50], [23, 51], [23, 52], [23, 53], [23, 55], [24, 25], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 33], [24, 34], [24, 35], [24, 37], [24, 38], [24, 39], [24, 40], [24, 41], [24, 43], [24, 47], [24, 49], [24, 50], [24, 51], [24, 53], [24, 54], [25, 26], [25, 28], [25, 30], [25, 31], [25, 32], [25, 33], [25, 35], [25, 37], [25, 40], [25, 41], [25, 43], [25, 45], [25, 46], [25, 47], [25, 50], [25, 53], [26, 28], [26, 30], [26, 32], [26, 33], [26, 35], [26, 41], [26, 43], [26, 46], [26, 47], [26, 49], [26, 51], [26, 52], [26, 53], [26, 54], [26, 55], [27, 32], [27, 33], [27, 35], [27, 36], [27, 40], [27, 41], [27, 42], [27, 44], [27, 46], [27, 47], [27, 49], [27, 50], [27, 51], [27, 52], [27, 53], [27, 54], [27, 55], [28, 30], [28, 33], [28, 37], [28, 38], [28, 39], [28, 41], [28, 42], [28, 44], [28, 45], [28, 47], [28, 48], [28, 49], [28, 50], [28, 51], [28, 52], [28, 53], [28, 54], [28, 55], [29, 31], [29, 32], [29, 33], [29, 35], [29, 36], [29, 39], [29, 41], [29, 42], [29, 46], [29, 48], [29, 49], [29, 50], [29, 52], [29, 53], [29, 54], [29, 55], [30, 33], [30, 35], [30, 36], [30, 40], [30, 41], [30, 42], [30, 43], [30, 44], [30, 45], [30, 46], [30, 47], [30, 48], [30, 49], [30, 50], [30, 53], [30, 54], [31, 33], [31, 35], [31, 37], [31, 38], [31, 39], [31, 40], [31, 41], [31, 44], [31, 46], [31, 47], [31, 49], [31, 51], [31, 52], [31, 53], [31, 54], [31, 55], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 38], [32, 39], [32, 42], [32, 43], [32, 45], [32, 46], [32, 50], [32, 51], [32, 52], [32, 55], [33, 34], [33, 35], [33, 36], [33, 38], [33, 43], [33, 45], [33, 46], [33, 48], [33, 49], [33, 50], [33, 51], [33, 53], [33, 54], [33, 55], [34, 35], [34, 36], [34, 37], [34, 40], [34, 43], [34, 45], [34, 46], [34, 48], [34, 49], [34, 50], [34, 51], [34, 53], [34, 54], [34, 55], [35, 36], [35, 37], [35, 39], [35, 40], [35, 41], [35, 44], [35, 45], [35, 51], [35, 54], [35, 55], [36, 37], [36, 39], [36, 40], [36, 42], [36, 43], [36, 44], [36, 45], [36, 46], [36, 49], [36, 51], [36, 52], [36, 53], [36, 54], [37, 38], [37, 39], [37, 40], [37, 41], [37, 43], [37, 44], [37, 47], [37, 49], [37, 50], [37, 51], [37, 52], [37, 55], [38, 39], [38, 40], [38, 42], [38, 43], [38, 45], [38, 46], [38, 48], [38, 49], [38, 50], [38, 51], [38, 52], [38, 53], [38, 54], [39, 41], [39, 43], [39, 44], [39, 47], [39, 48], [39, 50], [39, 51], [39, 53], [39, 54], [39, 55], [40, 44], [40, 46], [40, 47], [40, 48], [40, 49], [40, 53], [41, 42], [41, 52], [41, 53], [41, 55], [42, 43], [42, 44], [42, 45], [42, 46], [42, 47], [42, 48], [42, 49], [42, 50], [42, 51], [42, 52], [42, 53], [43, 44], [43, 45], [43, 46], [43, 47], [43, 50], [43, 51], [44, 45], [44, 48], [44, 49], [44, 50], [44, 55], [45, 46], [45, 47], [45, 50], [45, 51], [45, 54], [45, 55], [46, 48], [46, 49], [46, 50], [46, 51], [46, 53], [46, 54], [47, 48], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [47, 54], [47, 55], [48, 49], [48, 51], [48, 54], [49, 51], [49, 54], [49, 55], [50, 51], [50, 52], [50, 53], [51, 54], [52, 54], [53, 54], [53, 55], [54, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s0/tests/run.py b/tasks/construct-rlve-maximum-clique-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l6-s0/tests/test.sh b/tasks/construct-rlve-maximum-clique-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-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-maximum-clique-l6-s1/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-maximum-clique-l6-s1/environment/instance.json b/tasks/construct-rlve-maximum-clique-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f24c226e302274ffd7db233c0156b1364cea2d5d --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 9, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 6], [0, 8], [0, 9], [0, 10], [0, 11], [0, 13], [0, 14], [0, 17], [0, 21], [0, 22], [0, 24], [0, 25], [0, 26], [0, 27], [0, 30], [0, 32], [0, 36], [0, 38], [0, 39], [0, 41], [0, 42], [0, 45], [0, 46], [0, 48], [0, 49], [0, 50], [0, 51], [0, 53], [0, 54], [0, 55], [1, 2], [1, 3], [1, 5], [1, 6], [1, 7], [1, 9], [1, 11], [1, 12], [1, 16], [1, 17], [1, 18], [1, 20], [1, 22], [1, 26], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [1, 38], [1, 41], [1, 42], [1, 43], [1, 44], [1, 46], [1, 49], [1, 50], [1, 53], [1, 54], [2, 3], [2, 6], [2, 7], [2, 8], [2, 10], [2, 11], [2, 12], [2, 13], [2, 15], [2, 16], [2, 17], [2, 19], [2, 21], [2, 22], [2, 23], [2, 26], [2, 27], [2, 29], [2, 30], [2, 32], [2, 35], [2, 36], [2, 37], [2, 40], [2, 41], [2, 43], [2, 45], [2, 46], [2, 47], [2, 48], [2, 49], [2, 50], [2, 52], [2, 55], [3, 4], [3, 10], [3, 12], [3, 14], [3, 15], [3, 16], [3, 19], [3, 20], [3, 25], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 34], [3, 35], [3, 37], [3, 42], [3, 45], [3, 46], [3, 47], [3, 48], [3, 50], [3, 51], [3, 53], [4, 6], [4, 13], [4, 15], [4, 16], [4, 17], [4, 19], [4, 20], [4, 22], [4, 23], [4, 24], [4, 29], [4, 30], [4, 31], [4, 32], [4, 34], [4, 35], [4, 36], [4, 37], [4, 39], [4, 41], [4, 42], [4, 44], [4, 45], [4, 47], [4, 48], [4, 50], [5, 9], [5, 10], [5, 12], [5, 15], [5, 16], [5, 17], [5, 19], [5, 21], [5, 22], [5, 23], [5, 26], [5, 27], [5, 29], [5, 31], [5, 32], [5, 34], [5, 37], [5, 39], [5, 40], [5, 41], [5, 42], [5, 44], [5, 45], [5, 47], [5, 48], [5, 49], [5, 51], [5, 52], [5, 53], [5, 55], [6, 7], [6, 10], [6, 13], [6, 17], [6, 18], [6, 19], [6, 24], [6, 26], [6, 28], [6, 29], [6, 33], [6, 35], [6, 36], [6, 37], [6, 40], [6, 41], [6, 43], [6, 44], [6, 45], [6, 47], [6, 48], [6, 49], [6, 50], [6, 51], [6, 52], [6, 53], [6, 54], [7, 8], [7, 9], [7, 11], [7, 13], [7, 15], [7, 16], [7, 17], [7, 18], [7, 21], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 32], [7, 34], [7, 35], [7, 36], [7, 37], [7, 38], [7, 39], [7, 40], [7, 41], [7, 43], [7, 44], [7, 45], [7, 46], [7, 48], [7, 49], [7, 51], [7, 52], [7, 53], [7, 55], [8, 12], [8, 13], [8, 14], [8, 16], [8, 17], [8, 18], [8, 20], [8, 21], [8, 22], [8, 23], [8, 24], [8, 26], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 34], [8, 37], [8, 38], [8, 41], [8, 43], [8, 44], [8, 45], [8, 46], [8, 49], [8, 51], [8, 52], [8, 54], [8, 55], [9, 10], [9, 11], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 24], [9, 26], [9, 27], [9, 28], [9, 32], [9, 33], [9, 34], [9, 35], [9, 37], [9, 43], [9, 45], [9, 51], [9, 52], [9, 53], [9, 54], [9, 55], [10, 12], [10, 13], [10, 14], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 23], [10, 25], [10, 26], [10, 27], [10, 28], [10, 29], [10, 30], [10, 32], [10, 33], [10, 34], [10, 35], [10, 36], [10, 40], [10, 42], [10, 43], [10, 44], [10, 45], [10, 50], [10, 51], [10, 52], [10, 53], [10, 54], [10, 55], [11, 12], [11, 17], [11, 18], [11, 21], [11, 23], [11, 25], [11, 27], [11, 28], [11, 29], [11, 32], [11, 35], [11, 37], [11, 38], [11, 40], [11, 42], [11, 43], [11, 44], [11, 45], [11, 46], [11, 48], [11, 50], [11, 52], [11, 54], [11, 55], [12, 13], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 21], [12, 23], [12, 24], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [12, 37], [12, 38], [12, 39], [12, 41], [12, 42], [12, 43], [12, 44], [12, 45], [12, 46], [12, 50], [12, 51], [12, 53], [12, 54], [13, 18], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 27], [13, 28], [13, 31], [13, 33], [13, 36], [13, 37], [13, 38], [13, 39], [13, 40], [13, 42], [13, 43], [13, 44], [13, 46], [13, 47], [13, 48], [13, 51], [13, 54], [13, 55], [14, 16], [14, 18], [14, 19], [14, 21], [14, 22], [14, 23], [14, 25], [14, 26], [14, 27], [14, 29], [14, 30], [14, 31], [14, 32], [14, 34], [14, 35], [14, 36], [14, 38], [14, 42], [14, 44], [14, 45], [14, 46], [14, 48], [14, 49], [14, 52], [14, 53], [14, 54], [14, 55], [15, 17], [15, 18], [15, 20], [15, 21], [15, 24], [15, 25], [15, 26], [15, 27], [15, 29], [15, 30], [15, 32], [15, 33], [15, 37], [15, 38], [15, 39], [15, 40], [15, 43], [15, 45], [15, 49], [15, 50], [15, 52], [15, 53], [15, 55], [16, 17], [16, 19], [16, 20], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 30], [16, 33], [16, 34], [16, 37], [16, 38], [16, 39], [16, 40], [16, 42], [16, 43], [16, 44], [16, 45], [16, 48], [16, 49], [16, 51], [16, 52], [16, 53], [16, 54], [17, 19], [17, 20], [17, 22], [17, 23], [17, 24], [17, 26], [17, 29], [17, 30], [17, 32], [17, 38], [17, 39], [17, 41], [17, 43], [17, 44], [17, 45], [17, 47], [17, 48], [17, 49], [17, 52], [17, 53], [17, 54], [17, 55], [18, 19], [18, 20], [18, 22], [18, 25], [18, 27], [18, 28], [18, 29], [18, 30], [18, 32], [18, 33], [18, 34], [18, 38], [18, 40], [18, 41], [18, 42], [18, 43], [18, 44], [18, 45], [18, 48], [18, 49], [18, 50], [18, 52], [18, 53], [18, 54], [18, 55], [19, 20], [19, 21], [19, 23], [19, 24], [19, 25], [19, 26], [19, 29], [19, 31], [19, 33], [19, 34], [19, 35], [19, 36], [19, 37], [19, 39], [19, 40], [19, 41], [19, 45], [19, 48], [19, 49], [19, 50], [19, 54], [20, 22], [20, 24], [20, 26], [20, 29], [20, 30], [20, 33], [20, 34], [20, 35], [20, 36], [20, 37], [20, 38], [20, 40], [20, 41], [20, 44], [20, 45], [20, 46], [20, 48], [20, 50], [20, 51], [20, 54], [20, 55], [21, 22], [21, 23], [21, 24], [21, 25], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [21, 36], [21, 37], [21, 38], [21, 40], [21, 42], [21, 44], [21, 45], [21, 46], [21, 48], [21, 49], [21, 51], [21, 52], [22, 23], [22, 24], [22, 27], [22, 28], [22, 30], [22, 33], [22, 34], [22, 35], [22, 37], [22, 39], [22, 40], [22, 41], [22, 42], [22, 43], [22, 44], [22, 45], [22, 46], [22, 48], [22, 51], [22, 52], [23, 24], [23, 25], [23, 26], [23, 27], [23, 32], [23, 33], [23, 34], [23, 36], [23, 37], [23, 38], [23, 39], [23, 41], [23, 42], [23, 44], [23, 45], [23, 46], [23, 47], [23, 48], [23, 49], [23, 50], [23, 51], [23, 53], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [24, 38], [24, 41], [24, 42], [24, 44], [24, 45], [24, 46], [24, 48], [24, 49], [24, 50], [24, 51], [24, 53], [24, 54], [25, 26], [25, 29], [25, 30], [25, 31], [25, 32], [25, 34], [25, 38], [25, 39], [25, 42], [25, 43], [25, 44], [25, 46], [25, 47], [25, 48], [25, 50], [26, 29], [26, 30], [26, 31], [26, 34], [26, 35], [26, 36], [26, 37], [26, 39], [26, 42], [26, 44], [26, 45], [26, 46], [26, 48], [26, 49], [26, 51], [26, 52], [26, 53], [26, 55], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 34], [27, 36], [27, 37], [27, 38], [27, 39], [27, 41], [27, 43], [27, 44], [27, 45], [27, 46], [27, 48], [27, 49], [27, 50], [27, 51], [27, 55], [28, 31], [28, 32], [28, 33], [28, 34], [28, 36], [28, 38], [28, 39], [28, 41], [28, 42], [28, 45], [28, 46], [28, 48], [28, 49], [28, 50], [28, 54], [29, 31], [29, 32], [29, 35], [29, 36], [29, 37], [29, 39], [29, 41], [29, 42], [29, 44], [29, 45], [29, 46], [29, 48], [29, 49], [29, 52], [29, 54], [30, 33], [30, 34], [30, 35], [30, 36], [30, 39], [30, 40], [30, 41], [30, 44], [30, 45], [30, 47], [30, 52], [30, 54], [30, 55], [31, 34], [31, 37], [31, 38], [31, 39], [31, 42], [31, 43], [31, 47], [31, 52], [32, 34], [32, 35], [32, 37], [32, 38], [32, 40], [32, 41], [32, 44], [32, 48], [32, 49], [32, 51], [32, 53], [32, 55], [33, 35], [33, 36], [33, 39], [33, 41], [33, 42], [33, 43], [33, 44], [33, 45], [33, 48], [33, 51], [33, 53], [33, 55], [34, 35], [34, 39], [34, 41], [34, 42], [34, 43], [34, 44], [34, 49], [34, 50], [34, 52], [34, 53], [34, 54], [35, 36], [35, 37], [35, 38], [35, 40], [35, 43], [35, 44], [35, 45], [35, 47], [35, 48], [35, 51], [35, 52], [35, 53], [35, 54], [35, 55], [36, 37], [36, 39], [36, 40], [36, 41], [36, 42], [36, 44], [36, 45], [36, 48], [36, 49], [36, 50], [36, 53], [36, 54], [37, 38], [37, 40], [37, 42], [37, 43], [37, 44], [37, 45], [37, 46], [37, 47], [37, 51], [37, 53], [37, 54], [38, 45], [38, 46], [38, 48], [38, 50], [38, 51], [38, 53], [38, 54], [38, 55], [39, 40], [39, 43], [39, 44], [39, 47], [39, 50], [39, 51], [39, 55], [40, 42], [40, 43], [40, 45], [40, 46], [40, 47], [40, 48], [40, 52], [40, 54], [40, 55], [41, 42], [41, 43], [41, 48], [41, 49], [41, 52], [41, 53], [41, 55], [42, 43], [42, 45], [42, 46], [42, 47], [42, 48], [42, 49], [42, 50], [42, 53], [42, 54], [42, 55], [43, 44], [43, 46], [43, 47], [43, 48], [43, 49], [43, 50], [43, 51], [43, 52], [43, 53], [43, 55], [44, 47], [44, 48], [44, 51], [44, 52], [44, 53], [44, 55], [45, 47], [45, 48], [45, 50], [45, 51], [45, 52], [45, 54], [46, 47], [46, 48], [46, 50], [46, 51], [46, 52], [46, 54], [47, 53], [47, 54], [48, 51], [48, 52], [48, 53], [48, 54], [49, 51], [49, 53], [49, 54], [49, 55], [50, 52], [50, 54], [50, 55], [51, 54], [51, 55], [52, 54], [52, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s1/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5dbba7b85786fbcc10c0874660f804b619238423 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [2, 6, 10, 19, 26, 29, 35, 36, 45]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l6-s1/tests/check.py b/tasks/construct-rlve-maximum-clique-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s1/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l6-s1/tests/instance.json b/tasks/construct-rlve-maximum-clique-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f24c226e302274ffd7db233c0156b1364cea2d5d --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 56, "k": 9, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 6], [0, 8], [0, 9], [0, 10], [0, 11], [0, 13], [0, 14], [0, 17], [0, 21], [0, 22], [0, 24], [0, 25], [0, 26], [0, 27], [0, 30], [0, 32], [0, 36], [0, 38], [0, 39], [0, 41], [0, 42], [0, 45], [0, 46], [0, 48], [0, 49], [0, 50], [0, 51], [0, 53], [0, 54], [0, 55], [1, 2], [1, 3], [1, 5], [1, 6], [1, 7], [1, 9], [1, 11], [1, 12], [1, 16], [1, 17], [1, 18], [1, 20], [1, 22], [1, 26], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [1, 38], [1, 41], [1, 42], [1, 43], [1, 44], [1, 46], [1, 49], [1, 50], [1, 53], [1, 54], [2, 3], [2, 6], [2, 7], [2, 8], [2, 10], [2, 11], [2, 12], [2, 13], [2, 15], [2, 16], [2, 17], [2, 19], [2, 21], [2, 22], [2, 23], [2, 26], [2, 27], [2, 29], [2, 30], [2, 32], [2, 35], [2, 36], [2, 37], [2, 40], [2, 41], [2, 43], [2, 45], [2, 46], [2, 47], [2, 48], [2, 49], [2, 50], [2, 52], [2, 55], [3, 4], [3, 10], [3, 12], [3, 14], [3, 15], [3, 16], [3, 19], [3, 20], [3, 25], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 34], [3, 35], [3, 37], [3, 42], [3, 45], [3, 46], [3, 47], [3, 48], [3, 50], [3, 51], [3, 53], [4, 6], [4, 13], [4, 15], [4, 16], [4, 17], [4, 19], [4, 20], [4, 22], [4, 23], [4, 24], [4, 29], [4, 30], [4, 31], [4, 32], [4, 34], [4, 35], [4, 36], [4, 37], [4, 39], [4, 41], [4, 42], [4, 44], [4, 45], [4, 47], [4, 48], [4, 50], [5, 9], [5, 10], [5, 12], [5, 15], [5, 16], [5, 17], [5, 19], [5, 21], [5, 22], [5, 23], [5, 26], [5, 27], [5, 29], [5, 31], [5, 32], [5, 34], [5, 37], [5, 39], [5, 40], [5, 41], [5, 42], [5, 44], [5, 45], [5, 47], [5, 48], [5, 49], [5, 51], [5, 52], [5, 53], [5, 55], [6, 7], [6, 10], [6, 13], [6, 17], [6, 18], [6, 19], [6, 24], [6, 26], [6, 28], [6, 29], [6, 33], [6, 35], [6, 36], [6, 37], [6, 40], [6, 41], [6, 43], [6, 44], [6, 45], [6, 47], [6, 48], [6, 49], [6, 50], [6, 51], [6, 52], [6, 53], [6, 54], [7, 8], [7, 9], [7, 11], [7, 13], [7, 15], [7, 16], [7, 17], [7, 18], [7, 21], [7, 23], [7, 24], [7, 25], [7, 26], [7, 27], [7, 28], [7, 32], [7, 34], [7, 35], [7, 36], [7, 37], [7, 38], [7, 39], [7, 40], [7, 41], [7, 43], [7, 44], [7, 45], [7, 46], [7, 48], [7, 49], [7, 51], [7, 52], [7, 53], [7, 55], [8, 12], [8, 13], [8, 14], [8, 16], [8, 17], [8, 18], [8, 20], [8, 21], [8, 22], [8, 23], [8, 24], [8, 26], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 34], [8, 37], [8, 38], [8, 41], [8, 43], [8, 44], [8, 45], [8, 46], [8, 49], [8, 51], [8, 52], [8, 54], [8, 55], [9, 10], [9, 11], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 24], [9, 26], [9, 27], [9, 28], [9, 32], [9, 33], [9, 34], [9, 35], [9, 37], [9, 43], [9, 45], [9, 51], [9, 52], [9, 53], [9, 54], [9, 55], [10, 12], [10, 13], [10, 14], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 23], [10, 25], [10, 26], [10, 27], [10, 28], [10, 29], [10, 30], [10, 32], [10, 33], [10, 34], [10, 35], [10, 36], [10, 40], [10, 42], [10, 43], [10, 44], [10, 45], [10, 50], [10, 51], [10, 52], [10, 53], [10, 54], [10, 55], [11, 12], [11, 17], [11, 18], [11, 21], [11, 23], [11, 25], [11, 27], [11, 28], [11, 29], [11, 32], [11, 35], [11, 37], [11, 38], [11, 40], [11, 42], [11, 43], [11, 44], [11, 45], [11, 46], [11, 48], [11, 50], [11, 52], [11, 54], [11, 55], [12, 13], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 21], [12, 23], [12, 24], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [12, 37], [12, 38], [12, 39], [12, 41], [12, 42], [12, 43], [12, 44], [12, 45], [12, 46], [12, 50], [12, 51], [12, 53], [12, 54], [13, 18], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 27], [13, 28], [13, 31], [13, 33], [13, 36], [13, 37], [13, 38], [13, 39], [13, 40], [13, 42], [13, 43], [13, 44], [13, 46], [13, 47], [13, 48], [13, 51], [13, 54], [13, 55], [14, 16], [14, 18], [14, 19], [14, 21], [14, 22], [14, 23], [14, 25], [14, 26], [14, 27], [14, 29], [14, 30], [14, 31], [14, 32], [14, 34], [14, 35], [14, 36], [14, 38], [14, 42], [14, 44], [14, 45], [14, 46], [14, 48], [14, 49], [14, 52], [14, 53], [14, 54], [14, 55], [15, 17], [15, 18], [15, 20], [15, 21], [15, 24], [15, 25], [15, 26], [15, 27], [15, 29], [15, 30], [15, 32], [15, 33], [15, 37], [15, 38], [15, 39], [15, 40], [15, 43], [15, 45], [15, 49], [15, 50], [15, 52], [15, 53], [15, 55], [16, 17], [16, 19], [16, 20], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 30], [16, 33], [16, 34], [16, 37], [16, 38], [16, 39], [16, 40], [16, 42], [16, 43], [16, 44], [16, 45], [16, 48], [16, 49], [16, 51], [16, 52], [16, 53], [16, 54], [17, 19], [17, 20], [17, 22], [17, 23], [17, 24], [17, 26], [17, 29], [17, 30], [17, 32], [17, 38], [17, 39], [17, 41], [17, 43], [17, 44], [17, 45], [17, 47], [17, 48], [17, 49], [17, 52], [17, 53], [17, 54], [17, 55], [18, 19], [18, 20], [18, 22], [18, 25], [18, 27], [18, 28], [18, 29], [18, 30], [18, 32], [18, 33], [18, 34], [18, 38], [18, 40], [18, 41], [18, 42], [18, 43], [18, 44], [18, 45], [18, 48], [18, 49], [18, 50], [18, 52], [18, 53], [18, 54], [18, 55], [19, 20], [19, 21], [19, 23], [19, 24], [19, 25], [19, 26], [19, 29], [19, 31], [19, 33], [19, 34], [19, 35], [19, 36], [19, 37], [19, 39], [19, 40], [19, 41], [19, 45], [19, 48], [19, 49], [19, 50], [19, 54], [20, 22], [20, 24], [20, 26], [20, 29], [20, 30], [20, 33], [20, 34], [20, 35], [20, 36], [20, 37], [20, 38], [20, 40], [20, 41], [20, 44], [20, 45], [20, 46], [20, 48], [20, 50], [20, 51], [20, 54], [20, 55], [21, 22], [21, 23], [21, 24], [21, 25], [21, 28], [21, 29], [21, 30], [21, 31], [21, 32], [21, 33], [21, 34], [21, 36], [21, 37], [21, 38], [21, 40], [21, 42], [21, 44], [21, 45], [21, 46], [21, 48], [21, 49], [21, 51], [21, 52], [22, 23], [22, 24], [22, 27], [22, 28], [22, 30], [22, 33], [22, 34], [22, 35], [22, 37], [22, 39], [22, 40], [22, 41], [22, 42], [22, 43], [22, 44], [22, 45], [22, 46], [22, 48], [22, 51], [22, 52], [23, 24], [23, 25], [23, 26], [23, 27], [23, 32], [23, 33], [23, 34], [23, 36], [23, 37], [23, 38], [23, 39], [23, 41], [23, 42], [23, 44], [23, 45], [23, 46], [23, 47], [23, 48], [23, 49], [23, 50], [23, 51], [23, 53], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [24, 38], [24, 41], [24, 42], [24, 44], [24, 45], [24, 46], [24, 48], [24, 49], [24, 50], [24, 51], [24, 53], [24, 54], [25, 26], [25, 29], [25, 30], [25, 31], [25, 32], [25, 34], [25, 38], [25, 39], [25, 42], [25, 43], [25, 44], [25, 46], [25, 47], [25, 48], [25, 50], [26, 29], [26, 30], [26, 31], [26, 34], [26, 35], [26, 36], [26, 37], [26, 39], [26, 42], [26, 44], [26, 45], [26, 46], [26, 48], [26, 49], [26, 51], [26, 52], [26, 53], [26, 55], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 34], [27, 36], [27, 37], [27, 38], [27, 39], [27, 41], [27, 43], [27, 44], [27, 45], [27, 46], [27, 48], [27, 49], [27, 50], [27, 51], [27, 55], [28, 31], [28, 32], [28, 33], [28, 34], [28, 36], [28, 38], [28, 39], [28, 41], [28, 42], [28, 45], [28, 46], [28, 48], [28, 49], [28, 50], [28, 54], [29, 31], [29, 32], [29, 35], [29, 36], [29, 37], [29, 39], [29, 41], [29, 42], [29, 44], [29, 45], [29, 46], [29, 48], [29, 49], [29, 52], [29, 54], [30, 33], [30, 34], [30, 35], [30, 36], [30, 39], [30, 40], [30, 41], [30, 44], [30, 45], [30, 47], [30, 52], [30, 54], [30, 55], [31, 34], [31, 37], [31, 38], [31, 39], [31, 42], [31, 43], [31, 47], [31, 52], [32, 34], [32, 35], [32, 37], [32, 38], [32, 40], [32, 41], [32, 44], [32, 48], [32, 49], [32, 51], [32, 53], [32, 55], [33, 35], [33, 36], [33, 39], [33, 41], [33, 42], [33, 43], [33, 44], [33, 45], [33, 48], [33, 51], [33, 53], [33, 55], [34, 35], [34, 39], [34, 41], [34, 42], [34, 43], [34, 44], [34, 49], [34, 50], [34, 52], [34, 53], [34, 54], [35, 36], [35, 37], [35, 38], [35, 40], [35, 43], [35, 44], [35, 45], [35, 47], [35, 48], [35, 51], [35, 52], [35, 53], [35, 54], [35, 55], [36, 37], [36, 39], [36, 40], [36, 41], [36, 42], [36, 44], [36, 45], [36, 48], [36, 49], [36, 50], [36, 53], [36, 54], [37, 38], [37, 40], [37, 42], [37, 43], [37, 44], [37, 45], [37, 46], [37, 47], [37, 51], [37, 53], [37, 54], [38, 45], [38, 46], [38, 48], [38, 50], [38, 51], [38, 53], [38, 54], [38, 55], [39, 40], [39, 43], [39, 44], [39, 47], [39, 50], [39, 51], [39, 55], [40, 42], [40, 43], [40, 45], [40, 46], [40, 47], [40, 48], [40, 52], [40, 54], [40, 55], [41, 42], [41, 43], [41, 48], [41, 49], [41, 52], [41, 53], [41, 55], [42, 43], [42, 45], [42, 46], [42, 47], [42, 48], [42, 49], [42, 50], [42, 53], [42, 54], [42, 55], [43, 44], [43, 46], [43, 47], [43, 48], [43, 49], [43, 50], [43, 51], [43, 52], [43, 53], [43, 55], [44, 47], [44, 48], [44, 51], [44, 52], [44, 53], [44, 55], [45, 47], [45, 48], [45, 50], [45, 51], [45, 52], [45, 54], [46, 47], [46, 48], [46, 50], [46, 51], [46, 52], [46, 54], [47, 53], [47, 54], [48, 51], [48, 52], [48, 53], [48, 54], [49, 51], [49, 53], [49, 54], [49, 55], [50, 52], [50, 54], [50, 55], [51, 54], [51, 55], [52, 54], [52, 55]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l6-s1/tests/run.py b/tasks/construct-rlve-maximum-clique-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-maximum-clique-l6-s1/tests/test.sh b/tasks/construct-rlve-maximum-clique-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l6-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s2/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l1-s2/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e4a25726e757e9bcf8e9f5999b207d12677f860e --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 1], [0, 3], [0, 5], [2, 3], [3, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s2/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5568051aa557ee297f3f543d42b02b3f624bd2eb --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 1, 0, 1, 0, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s2/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s2/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-s2/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e4a25726e757e9bcf8e9f5999b207d12677f860e --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 1], [0, 3], [0, 5], [2, 3], [3, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s2/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l1-s2/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l1-s5/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l1-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l1-s5/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a69b742999300ec78a02a549e9d324e7f81a9027 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[3, 4], [3, 5], [4, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s5/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l1-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6513022ca9c1c71a657a7572e37008665ef3f7cf --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 0, 0, 0, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s5/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l1-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s5/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s5/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a69b742999300ec78a02a549e9d324e7f81a9027 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[3, 4], [3, 5], [4, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s5/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l1-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l1-s5/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l1-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l5-s3/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l5-s3/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8f40f666978f3995afc35d5af811b19425e9823b --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 24, "k": 6, "edges": [[0, 1], [0, 7], [0, 8], [0, 10], [0, 14], [0, 16], [0, 20], [0, 21], [0, 22], [0, 23], [1, 3], [1, 5], [1, 9], [1, 10], [1, 13], [1, 14], [1, 15], [1, 22], [2, 4], [2, 5], [2, 9], [2, 10], [2, 14], [2, 17], [2, 18], [2, 21], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 16], [3, 17], [3, 21], [4, 6], [4, 7], [4, 8], [4, 10], [4, 11], [4, 14], [4, 15], [4, 18], [5, 6], [5, 8], [5, 9], [5, 11], [5, 12], [5, 13], [5, 14], [5, 18], [5, 19], [5, 20], [6, 9], [6, 16], [6, 17], [6, 18], [6, 20], [6, 21], [6, 23], [7, 8], [7, 9], [7, 10], [7, 14], [7, 17], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [8, 9], [8, 11], [8, 12], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 22], [9, 12], [9, 15], [9, 16], [9, 17], [9, 20], [10, 13], [10, 15], [10, 17], [10, 23], [11, 12], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 20], [11, 22], [11, 23], [12, 13], [12, 17], [13, 14], [13, 15], [13, 16], [13, 17], [13, 20], [13, 21], [13, 23], [14, 15], [14, 16], [14, 19], [14, 20], [15, 17], [15, 18], [15, 19], [15, 21], [16, 20], [16, 22], [18, 19], [18, 20], [18, 22], [18, 23], [19, 22], [19, 23], [20, 21], [20, 23], [21, 23]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s3/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0a1822f2397fedea20600d0a8d90247a1c75fd4a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 1, 0, 0, 1, 2, 0, 3, 4, 5, 2, 5, 3, 5, 4, 0, 3, 1, 3, 1, 1, 2, 2, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s3/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s3/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s3/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8f40f666978f3995afc35d5af811b19425e9823b --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 24, "k": 6, "edges": [[0, 1], [0, 7], [0, 8], [0, 10], [0, 14], [0, 16], [0, 20], [0, 21], [0, 22], [0, 23], [1, 3], [1, 5], [1, 9], [1, 10], [1, 13], [1, 14], [1, 15], [1, 22], [2, 4], [2, 5], [2, 9], [2, 10], [2, 14], [2, 17], [2, 18], [2, 21], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 16], [3, 17], [3, 21], [4, 6], [4, 7], [4, 8], [4, 10], [4, 11], [4, 14], [4, 15], [4, 18], [5, 6], [5, 8], [5, 9], [5, 11], [5, 12], [5, 13], [5, 14], [5, 18], [5, 19], [5, 20], [6, 9], [6, 16], [6, 17], [6, 18], [6, 20], [6, 21], [6, 23], [7, 8], [7, 9], [7, 10], [7, 14], [7, 17], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [8, 9], [8, 11], [8, 12], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 22], [9, 12], [9, 15], [9, 16], [9, 17], [9, 20], [10, 13], [10, 15], [10, 17], [10, 23], [11, 12], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 20], [11, 22], [11, 23], [12, 13], [12, 17], [13, 14], [13, 15], [13, 16], [13, 17], [13, 20], [13, 21], [13, 23], [14, 15], [14, 16], [14, 19], [14, 20], [15, 17], [15, 18], [15, 19], [15, 21], [16, 20], [16, 22], [18, 19], [18, 20], [18, 22], [18, 23], [19, 22], [19, 23], [20, 21], [20, 23], [21, 23]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s3/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l5-s3/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l5-s4/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l5-s4/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..659380a0fc74dfe0c40ac986c2166b7e021dd882 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 24, "k": 7, "edges": [[0, 5], [0, 6], [0, 8], [0, 9], [0, 10], [0, 11], [0, 14], [0, 16], [0, 17], [0, 20], [1, 2], [1, 3], [1, 9], [1, 10], [1, 11], [1, 14], [1, 16], [1, 19], [1, 21], [1, 22], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 13], [2, 14], [2, 16], [2, 17], [2, 18], [2, 22], [3, 4], [3, 5], [3, 6], [3, 8], [3, 16], [3, 18], [3, 21], [3, 22], [4, 5], [4, 7], [4, 9], [4, 10], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 20], [5, 8], [5, 9], [5, 10], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [6, 7], [6, 8], [6, 10], [6, 16], [6, 18], [6, 21], [6, 23], [7, 8], [7, 11], [7, 12], [7, 14], [7, 15], [7, 16], [7, 20], [7, 21], [7, 22], [7, 23], [8, 9], [8, 11], [8, 12], [8, 13], [8, 15], [8, 19], [8, 21], [8, 22], [8, 23], [9, 11], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 19], [9, 20], [10, 11], [10, 12], [10, 13], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [11, 12], [11, 13], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 22], [12, 13], [12, 14], [12, 17], [12, 20], [12, 22], [12, 23], [13, 14], [13, 18], [13, 19], [13, 22], [13, 23], [14, 17], [14, 18], [14, 20], [14, 21], [14, 22], [15, 16], [15, 19], [15, 20], [15, 21], [15, 23], [16, 18], [16, 19], [16, 21], [16, 23], [17, 18], [17, 19], [17, 22], [18, 19], [18, 22], [19, 20], [19, 21], [19, 22], [22, 23]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s4/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..468db11d224b6cc03e5356363998f3d660fb8327 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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' +{"colors": [0, 0, 1, 1, 2, 3, 2, 0, 4, 5, 4, 3, 1, 6, 4, 1, 6, 6, 0, 2, 6, 5, 5, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s4/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s4/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s4/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..659380a0fc74dfe0c40ac986c2166b7e021dd882 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 24, "k": 7, "edges": [[0, 5], [0, 6], [0, 8], [0, 9], [0, 10], [0, 11], [0, 14], [0, 16], [0, 17], [0, 20], [1, 2], [1, 3], [1, 9], [1, 10], [1, 11], [1, 14], [1, 16], [1, 19], [1, 21], [1, 22], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 13], [2, 14], [2, 16], [2, 17], [2, 18], [2, 22], [3, 4], [3, 5], [3, 6], [3, 8], [3, 16], [3, 18], [3, 21], [3, 22], [4, 5], [4, 7], [4, 9], [4, 10], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 20], [5, 8], [5, 9], [5, 10], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [6, 7], [6, 8], [6, 10], [6, 16], [6, 18], [6, 21], [6, 23], [7, 8], [7, 11], [7, 12], [7, 14], [7, 15], [7, 16], [7, 20], [7, 21], [7, 22], [7, 23], [8, 9], [8, 11], [8, 12], [8, 13], [8, 15], [8, 19], [8, 21], [8, 22], [8, 23], [9, 11], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 19], [9, 20], [10, 11], [10, 12], [10, 13], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [11, 12], [11, 13], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 22], [12, 13], [12, 14], [12, 17], [12, 20], [12, 22], [12, 23], [13, 14], [13, 18], [13, 19], [13, 22], [13, 23], [14, 17], [14, 18], [14, 20], [14, 21], [14, 22], [15, 16], [15, 19], [15, 20], [15, 21], [15, 23], [16, 18], [16, 19], [16, 21], [16, 23], [17, 18], [17, 19], [17, 22], [18, 19], [18, 22], [19, 20], [19, 21], [19, 22], [22, 23]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s4/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l5-s4/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-harmonious-coloring-l1-s6/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l1-s6/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..17399f941d16df271d45a03018594ffb335b1a0b --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 4], [0, 5]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s6/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6513022ca9c1c71a657a7572e37008665ef3f7cf --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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' +{"colors": [0, 0, 0, 0, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s6/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s6/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + seen = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pair = (min(c[u], c[v]), max(c[u], c[v])) + if pair in seen: + raise Invalid(f"colour pair {pair} appears on two edges") + seen.add(pair) + return None, {} diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s6/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..17399f941d16df271d45a03018594ffb335b1a0b --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 4], [0, 5]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s6/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l1-s6/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l1-s8/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s8/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4db3fff456d16b93e0a90950b1354f8aae73f8a6 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 4], [2, 3], [3, 4]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s8/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..507750783edb4737b84f155ecabef4d2b36c3f75 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 0, 0, 1, 2, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s8/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s8/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + seen = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pair = (min(c[u], c[v]), max(c[u], c[v])) + if pair in seen: + raise Invalid(f"colour pair {pair} appears on two edges") + seen.add(pair) + return None, {} diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s8/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4db3fff456d16b93e0a90950b1354f8aae73f8a6 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 4], [2, 3], [3, 4]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s8/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s8/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s0/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l5-s0/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4fb2fcd52994e24271acbb0f77e3990b37f20a21 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 9, "edges": [[0, 4], [0, 11], [1, 4], [1, 9], [1, 13], [2, 3], [2, 5], [2, 14], [3, 5], [4, 6], [4, 8], [4, 9], [5, 8], [5, 10], [5, 11], [5, 12], [5, 14], [6, 9], [6, 13], [6, 14], [7, 11], [9, 11], [10, 11], [10, 12], [11, 14], [12, 13]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s0/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7cc799234db678768fd8f39427433bb4cb7e4871 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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' +{"colors": [0, 1, 0, 2, 3, 4, 2, 2, 5, 6, 3, 7, 8, 5, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s0/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s0/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + seen = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pair = (min(c[u], c[v]), max(c[u], c[v])) + if pair in seen: + raise Invalid(f"colour pair {pair} appears on two edges") + seen.add(pair) + return None, {} diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s0/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4fb2fcd52994e24271acbb0f77e3990b37f20a21 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 9, "edges": [[0, 4], [0, 11], [1, 4], [1, 9], [1, 13], [2, 3], [2, 5], [2, 14], [3, 5], [4, 6], [4, 8], [4, 9], [5, 8], [5, 10], [5, 11], [5, 12], [5, 14], [6, 9], [6, 13], [6, 14], [7, 11], [9, 11], [10, 11], [10, 12], [11, 14], [12, 13]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s0/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l5-s0/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s7/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s7/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3e59385644ae86e67e9b145cd2fe2423e22502e7 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 8, "edges": [[0, 5], [0, 6], [0, 8], [0, 9], [0, 12], [1, 4], [1, 7], [1, 10], [1, 13], [1, 14], [2, 12], [2, 14], [3, 8], [4, 9], [5, 9], [8, 9], [9, 12], [9, 14], [11, 12], [11, 14], [12, 13]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s7/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..90d1dd2d2ad8430de0aac7f3b3ac2d3bb0d2aa2b --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 1, 2, 1, 2, 3, 1, 4, 5, 4, 6, 5, 6, 3, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s7/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s7/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + seen = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pair = (min(c[u], c[v]), max(c[u], c[v])) + if pair in seen: + raise Invalid(f"colour pair {pair} appears on two edges") + seen.add(pair) + return None, {} diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s7/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3e59385644ae86e67e9b145cd2fe2423e22502e7 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 8, "edges": [[0, 5], [0, 6], [0, 8], [0, 9], [0, 12], [1, 4], [1, 7], [1, 10], [1, 13], [1, 14], [2, 12], [2, 14], [3, 8], [4, 9], [5, 9], [8, 9], [9, 12], [9, 14], [11, 12], [11, 14], [12, 13]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s7/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s7/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s9/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l5-s9/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..34e447eeefb6798be451c2b14c8f25ad3651445f --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 9, "edges": [[0, 10], [0, 11], [0, 12], [1, 6], [1, 10], [1, 13], [2, 10], [2, 12], [3, 6], [3, 7], [3, 9], [3, 12], [4, 6], [4, 13], [5, 10], [5, 11], [5, 12], [5, 14], [6, 7], [8, 10], [8, 11], [9, 14], [10, 12], [10, 13], [10, 14], [11, 13]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s9/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ccc7b036a625fa431e9056b24e8b9c9908fb7d2 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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' +{"colors": [0, 1, 2, 3, 0, 4, 4, 5, 3, 0, 6, 2, 7, 5, 8]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s9/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s9/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + seen = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pair = (min(c[u], c[v]), max(c[u], c[v])) + if pair in seen: + raise Invalid(f"colour pair {pair} appears on two edges") + seen.add(pair) + return None, {} diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s9/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..34e447eeefb6798be451c2b14c8f25ad3651445f --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 9, "edges": [[0, 10], [0, 11], [0, 12], [1, 6], [1, 10], [1, 13], [2, 10], [2, 12], [3, 6], [3, 7], [3, 9], [3, 12], [4, 6], [4, 13], [5, 10], [5, 11], [5, 12], [5, 14], [6, 7], [8, 10], [8, 11], [9, 14], [10, 12], [10, 13], [10, 14], [11, 13]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s9/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l5-s9/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-pairwise-sums-recovery-l3-s1/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-pairwise-sums-recovery-l3-s1/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fdc68b328c6f3d6092dab75abf299deaba161c79 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [6, 29, 16, 18, 19, 21, 10, 22, 3, 16, 13, 24, 10, 15, 17, 28, 17, 11, 27, 23, 23, 5, 12, 14, 22, 9, 15, 17], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s1/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b9caa26d9914983e00257ec1ede1acaf54188469 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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' +{"numbers": [1, 2, 4, 8, 9, 13, 14, 15]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s1/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s1/tests/check.py @@ -0,0 +1,14 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("numbers"), n, 1, None, "numbers") + if len(set(x)) != n: + raise Invalid("numbers must be distinct") + got = Counter(x[i] + x[j] for i in range(n) for j in range(i + 1, n)) + if got != Counter(inst["sums"]): + raise Invalid("pairwise sums do not match") + return None, {} diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s1/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fdc68b328c6f3d6092dab75abf299deaba161c79 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [6, 29, 16, 18, 19, 21, 10, 22, 3, 16, 13, 24, 10, 15, 17, 28, 17, 11, 27, 23, 23, 5, 12, 14, 22, 9, 15, 17], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s1/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-pairwise-sums-recovery-l3-s1/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-pairwise-sums-recovery-l3-s8/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l3-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-pairwise-sums-recovery-l3-s8/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a48a91b2b500546823bddd268c64672cf432357e --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [21, 22, 11, 12, 5, 13, 23, 23, 9, 24, 6, 16, 12, 14, 11, 9, 10, 13, 15, 17, 7, 8, 20, 20, 19, 31, 21, 22], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s8/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3c189332dc546b8ee7c8ef65efb35ba8c4a8e68a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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' +{"numbers": [1, 4, 5, 6, 7, 8, 15, 16]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s8/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s8/tests/check.py @@ -0,0 +1,14 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("numbers"), n, 1, None, "numbers") + if len(set(x)) != n: + raise Invalid("numbers must be distinct") + got = Counter(x[i] + x[j] for i in range(n) for j in range(i + 1, n)) + if got != Counter(inst["sums"]): + raise Invalid("pairwise sums do not match") + return None, {} diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s8/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a48a91b2b500546823bddd268c64672cf432357e --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [21, 22, 11, 12, 5, 13, 23, 23, 9, 24, 6, 16, 12, 14, 11, 9, 10, 13, 15, 17, 7, 8, 20, 20, 19, 31, 21, 22], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s8/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-pairwise-sums-recovery-l3-s8/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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-pan-solar-panels-l2-s3/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l2-s3/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e1a544c69f50b9e8647627908220f6c2af1f09ff --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"A": 791, "B": 822, "C": 119, "D": 729, "target": 411, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s3/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..71a3eef4b71e17751d25b27eac086a02a3a347ef --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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": 822, "Y": 411} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s3/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s3/tests/check.py @@ -0,0 +1,12 @@ +import math + +from run import Invalid, as_int + + +def check(inst, ans): + X = as_int(ans.get("X"), "X", lo=inst["A"], hi=inst["B"]) + Y = as_int(ans.get("Y"), "Y", lo=inst["C"], hi=inst["D"]) + g = math.gcd(X, Y) + if g < inst["target"]: + raise Invalid(f"gcd(X, Y) = {g} < {inst['target']}") + return None, {"gcd": g} diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s3/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e1a544c69f50b9e8647627908220f6c2af1f09ff --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"A": 791, "B": 822, "C": 119, "D": 729, "target": 411, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s3/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l2-s3/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s2/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s2/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6edd830a3c569fc7b43c7f61d10a79b59a45a73f --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"A": 75902618468, "B": 93763097709, "C": 27284805205, "D": 37650187878, "target": 31254365903, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s2/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6bf22c3f94eaf1c60d1ede823e4f510a2fb1ff5f --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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": 93763097709, "Y": 31254365903} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s2/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s2/tests/check.py @@ -0,0 +1,12 @@ +import math + +from run import Invalid, as_int + + +def check(inst, ans): + X = as_int(ans.get("X"), "X", lo=inst["A"], hi=inst["B"]) + Y = as_int(ans.get("Y"), "Y", lo=inst["C"], hi=inst["D"]) + g = math.gcd(X, Y) + if g < inst["target"]: + raise Invalid(f"gcd(X, Y) = {g} < {inst['target']}") + return None, {"gcd": g} diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s2/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6edd830a3c569fc7b43c7f61d10a79b59a45a73f --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"A": 75902618468, "B": 93763097709, "C": 27284805205, "D": 37650187878, "target": 31254365903, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s2/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s2/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s5/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s5/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7531eea23565ac9eaa768bc3fca564c41b4e13fe --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"A": 63502323648, "B": 89787137638, "C": 35308634788, "D": 38651163703, "target": 38651163703, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s5/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..728aa6e2954ebfeaab3dd452aa990951a92c237b --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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": 77302327406, "Y": 38651163703} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s5/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s5/tests/check.py @@ -0,0 +1,12 @@ +import math + +from run import Invalid, as_int + + +def check(inst, ans): + X = as_int(ans.get("X"), "X", lo=inst["A"], hi=inst["B"]) + Y = as_int(ans.get("Y"), "Y", lo=inst["C"], hi=inst["D"]) + g = math.gcd(X, Y) + if g < inst["target"]: + raise Invalid(f"gcd(X, Y) = {g} < {inst['target']}") + return None, {"gcd": g} diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s5/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7531eea23565ac9eaa768bc3fca564c41b4e13fe --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"A": 63502323648, "B": 89787137638, "C": 35308634788, "D": 38651163703, "target": 38651163703, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s5/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s5/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-polynomial-global-minimum-l3-s0/environment/Dockerfile b/tasks/construct-rlve-polynomial-global-minimum-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s0/environment/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7a5e3adf59d36a2c79ae2bac52a563db79f0d8d0 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [5, -2, 43, -32, 32, -12, 2], "fmin": "4.97633548420288359252975785584755474318034134", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s0/solution/solve.sh b/tasks/construct-rlve-polynomial-global-minimum-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6f82159abdff0c83664764cd923822b004b20e54 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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' +{"x0": 0.023871924416206353} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s0/tests/check.py b/tasks/construct-rlve-polynomial-global-minimum-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3be068f4391ad0838c29a4f7d521b8072cf39991 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s0/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-s0/tests/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7a5e3adf59d36a2c79ae2bac52a563db79f0d8d0 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [5, -2, 43, -32, 32, -12, 2], "fmin": "4.97633548420288359252975785584755474318034134", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s0/tests/run.py b/tasks/construct-rlve-polynomial-global-minimum-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s0/tests/test.sh b/tasks/construct-rlve-polynomial-global-minimum-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s7/environment/Dockerfile b/tasks/construct-rlve-polynomial-global-minimum-l3-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s7/environment/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l3-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8f0afb8341af649833e506142407f28827632134 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s7/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [146, 356, 506, 312, 121, 24, 2], "fmin": "61.0494148059365849200539747958503145605441076", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s7/solution/solve.sh b/tasks/construct-rlve-polynomial-global-minimum-l3-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..34ab7f21d5626a80b1502ba51af6e5fd8cd29371 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x0": -0.5869653520946588} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s7/tests/check.py b/tasks/construct-rlve-polynomial-global-minimum-l3-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3be068f4391ad0838c29a4f7d521b8072cf39991 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s7/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-s7/tests/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l3-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8f0afb8341af649833e506142407f28827632134 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s7/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [146, 356, 506, 312, 121, 24, 2], "fmin": "61.0494148059365849200539747958503145605441076", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s7/tests/run.py b/tasks/construct-rlve-polynomial-global-minimum-l3-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s7/tests/test.sh b/tasks/construct-rlve-polynomial-global-minimum-l3-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s9/environment/Dockerfile b/tasks/construct-rlve-polynomial-global-minimum-l3-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-global-minimum-l3-s9/environment/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l3-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..01a7092c9d43b29bc64d6b38aa7c2d8f83869adf --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s9/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [65, 190, 241, 160, 62, 12, 1], "fmin": "6.69375361817812410334478160913312142495056204", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s9/solution/solve.sh b/tasks/construct-rlve-polynomial-global-minimum-l3-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e2934a039c9342dbc1ded9705ceaf8b325805ba1 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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' +{"x0": -0.900475393694498} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s9/tests/check.py b/tasks/construct-rlve-polynomial-global-minimum-l3-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3be068f4391ad0838c29a4f7d521b8072cf39991 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s9/tests/check.py @@ -0,0 +1,19 @@ +from fractions import Fraction + +from run import Invalid, num + + +def check(inst, ans): + x0 = Fraction(num(ans.get("x0"), "x0")) + if abs(x0) > 10 ** 6: + raise Invalid("x0 out of range") + v = Fraction(0) + for a in reversed(inst["coeffs"]): + v = v * x0 + a + fmin = Fraction(inst["fmin"]) + tol = Fraction(1, 10 ** 9) * max(Fraction(1), abs(fmin)) + if v > fmin + tol: + raise Invalid(f"f(x0) = {float(v)} is above the global minimum {float(fmin)}") + if v < fmin - tol: # cannot happen for a correct f_min; guards against a bad instance + raise Invalid("internal: f(x0) below recorded minimum") + return None, {"f_x0": float(v)} diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s9/tests/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l3-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..01a7092c9d43b29bc64d6b38aa7c2d8f83869adf --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s9/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [65, 190, 241, 160, 62, 12, 1], "fmin": "6.69375361817812410334478160913312142495056204", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s9/tests/run.py b/tasks/construct-rlve-polynomial-global-minimum-l3-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-global-minimum-l3-s9/tests/test.sh b/tasks/construct-rlve-polynomial-global-minimum-l3-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-integer-roots-l4-s2/environment/Dockerfile b/tasks/construct-rlve-polynomial-integer-roots-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s2/environment/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fb98e131e086034f3a114d76b9edd3b816c718f9 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [0, -101039400, -98597250, 19947951, 16543665, -1930980, -911816, 79714, 21638, -1292, -238, 7, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s2/solution/solve.sh b/tasks/construct-rlve-polynomial-integer-roots-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..af9ab1046e05fc92f04b37a0973c7c8b03f6b3b0 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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' +{"roots": [-11, -9, -9, -5, -3, -1, 0, 4, 5, 6, 7, 9]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s2/tests/check.py b/tasks/construct-rlve-polynomial-integer-roots-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2d30553cb884c5e03c8afe73ef652efc483ab791 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s2/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-s2/tests/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fb98e131e086034f3a114d76b9edd3b816c718f9 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [0, -101039400, -98597250, 19947951, 16543665, -1930980, -911816, 79714, 21638, -1292, -238, 7, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s2/tests/run.py b/tasks/construct-rlve-polynomial-integer-roots-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s2/tests/test.sh b/tasks/construct-rlve-polynomial-integer-roots-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s5/environment/Dockerfile b/tasks/construct-rlve-polynomial-integer-roots-l4-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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-polynomial-integer-roots-l4-s5/environment/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l4-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6ace925170d7136a48eaf6cdc3fe834d5e38cba7 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s5/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [-1428840000, -642978000, 929505600, 31855680, -105826072, 9363241, 3011639, -420075, -24549, 5739, -59, -25, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s5/solution/solve.sh b/tasks/construct-rlve-polynomial-integer-roots-l4-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7b59d5b30814ced8ea0a9a5d597fdd2b9c252bbb --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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' +{"roots": [-10, -9, -7, -3, -1, 2, 5, 7, 9, 10, 10, 12]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s5/tests/check.py b/tasks/construct-rlve-polynomial-integer-roots-l4-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2d30553cb884c5e03c8afe73ef652efc483ab791 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s5/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + c = inst["coeffs"] # c[i] = coefficient of x^i, monic of degree len(c) - 1 + n = len(c) - 1 + r = int_list(ans.get("roots"), n, name="roots") + bound = 1 + max(abs(v) for v in c) # Cauchy bound on roots + if any(abs(a) > bound for a in r): # any integer root divides the constant term / is bounded by max|c_i| + raise Invalid("root out of range") + prod = [1] + for a in r: # multiply by (x - a) + nxt = [0] * (len(prod) + 1) + for i, v in enumerate(prod): + nxt[i + 1] += v + nxt[i] -= a * v + prod = nxt + if prod != c: + raise Invalid("the product does not expand to P(x)") + return None, {} diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s5/tests/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l4-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6ace925170d7136a48eaf6cdc3fe834d5e38cba7 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s5/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [-1428840000, -642978000, 929505600, 31855680, -105826072, 9363241, 3011639, -420075, -24549, 5739, -59, -25, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s5/tests/run.py b/tasks/construct-rlve-polynomial-integer-roots-l4-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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-polynomial-integer-roots-l4-s5/tests/test.sh b/tasks/construct-rlve-polynomial-integer-roots-l4-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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-polynomial-interpolation-l3-s2/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-interpolation-l3-s2/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..807067d560683dd3aca39c750443c9ce6b76b281 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"X": [0, 2, -2, -3, 3, 6, -4], "Y": [-4, 86, 450, 3821, 1265, 105962, 18632], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s2/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7113fe73cd32e1a95aba84b5437ee6e41251acab --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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' +{"coeffs": [-4, -3, 4, -2, 4, -5, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s2/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s2/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + X, Y = inst["X"], inst["Y"] + c = int_list(ans.get("coeffs"), len(X), name="coeffs") + for x, y in zip(X, Y): + v = 0 + for a in reversed(c): + v = v * x + a + if v != y: + raise Invalid(f"f({x}) = {v}, need {y}") + return None, {} diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s2/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..807067d560683dd3aca39c750443c9ce6b76b281 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"X": [0, 2, -2, -3, 3, 6, -4], "Y": [-4, 86, 450, 3821, 1265, 105962, 18632], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s2/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-interpolation-l3-s2/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-prefix-product-permutation-l3-s0/environment/Dockerfile b/tasks/construct-rlve-prefix-product-permutation-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s0/environment/instance.json b/tasks/construct-rlve-prefix-product-permutation-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6750c901be7fbbc3235de12282df0896a7a4a46e --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 281, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s0/solution/solve.sh b/tasks/construct-rlve-prefix-product-permutation-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..064dc90735d13e8f3cceb932f722710da62b15f8 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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' +{"perm": [1, 2, 142, 95, 212, 226, 48, 242, 247, 126, 254, 231, 165, 174, 262, 76, 124, 249, 204, 75, 268, 175, 116, 111, 83, 46, 228, 230, 272, 127, 179, 137, 203, 265, 125, 274, 243, 39, 38, 246, 275, 49, 88, 184, 199, 26, 56, 7, 42, 196, 164, 271, 255, 229, 256, 47, 277, 213, 64, 182, 90, 130, 69, 59, 102, 148, 133, 152, 63, 225, 278, 96, 122, 78, 20, 16, 160, 74, 264, 250, 138, 171, 25, 238, 185, 163, 233, 43, 100, 61, 154, 106, 169, 140, 4, 72, 162, 198, 239, 89, 223, 65, 136, 252, 128, 92, 115, 261, 269, 166, 24, 201, 139, 190, 107, 23, 173, 270, 232, 197, 186, 73, 206, 17, 35, 10, 30, 105, 192, 62, 215, 134, 67, 132, 217, 103, 32, 81, 113, 94, 280, 3, 189, 170, 202, 251, 180, 66, 151, 216, 149, 68, 221, 91, 178, 253, 273, 248, 266, 77, 210, 97, 86, 51, 13, 110, 260, 176, 93, 144, 82, 259, 117, 14, 22, 168, 191, 155, 31, 147, 218, 60, 194, 44, 85, 121, 211, 279, 143, 114, 177, 129, 222, 183, 240, 50, 120, 98, 45, 258, 112, 145, 33, 19, 209, 123, 267, 263, 205, 161, 187, 5, 58, 220, 131, 150, 135, 181, 224, 214, 153, 193, 101, 219, 70, 6, 236, 27, 54, 28, 12, 119, 87, 241, 276, 227, 257, 84, 99, 195, 234, 8, 37, 245, 244, 40, 9, 158, 18, 80, 146, 104, 156, 11, 53, 55, 237, 200, 172, 167, 108, 15, 208, 79, 34, 159, 207, 21, 109, 118, 52, 29, 157, 36, 41, 235, 57, 71, 188, 141, 281]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s0/tests/check.py b/tasks/construct-rlve-prefix-product-permutation-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3d93850acd79cc0f8fff05cdbb0c63aabc484815 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s0/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 1 + for v in p: + acc = acc * v % n + if acc in seen: + raise Invalid(f"prefix product residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s0/tests/instance.json b/tasks/construct-rlve-prefix-product-permutation-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6750c901be7fbbc3235de12282df0896a7a4a46e --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 281, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s0/tests/run.py b/tasks/construct-rlve-prefix-product-permutation-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s0/tests/test.sh b/tasks/construct-rlve-prefix-product-permutation-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s7/environment/Dockerfile b/tasks/construct-rlve-prefix-product-permutation-l3-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s7/environment/instance.json b/tasks/construct-rlve-prefix-product-permutation-l3-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3e89b2dcc36b942220edff12794e9d908841c070 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 191, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s7/solution/solve.sh b/tasks/construct-rlve-prefix-product-permutation-l3-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..633716740de5ee17cbed9d23a4f70356cafa14db --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [1, 2, 97, 65, 49, 154, 33, 83, 25, 86, 173, 140, 17, 148, 42, 52, 13, 46, 139, 182, 87, 92, 166, 109, 9, 108, 170, 93, 117, 113, 122, 38, 7, 111, 119, 132, 70, 32, 187, 50, 44, 15, 142, 41, 179, 18, 55, 127, 5, 40, 150, 16, 181, 174, 47, 67, 59, 125, 57, 69, 157, 120, 115, 95, 4, 145, 56, 135, 60, 37, 162, 114, 131, 158, 112, 164, 94, 130, 121, 163, 118, 159, 8, 169, 167, 10, 21, 102, 90, 89, 105, 22, 28, 77, 64, 190, 3, 129, 116, 165, 171, 88, 104, 103, 91, 172, 183, 26, 24, 185, 34, 75, 30, 72, 63, 99, 29, 81, 35, 62, 79, 31, 156, 133, 58, 137, 48, 189, 98, 78, 73, 36, 124, 136, 68, 134, 126, 146, 19, 12, 177, 43, 153, 188, 66, 138, 175, 14, 152, 51, 178, 149, 143, 6, 161, 123, 61, 74, 82, 186, 155, 71, 80, 76, 100, 23, 85, 184, 84, 27, 101, 106, 11, 54, 147, 180, 141, 151, 45, 176, 53, 20, 107, 168, 110, 160, 39, 144, 128, 96, 191]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s7/tests/check.py b/tasks/construct-rlve-prefix-product-permutation-l3-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3d93850acd79cc0f8fff05cdbb0c63aabc484815 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s7/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 1 + for v in p: + acc = acc * v % n + if acc in seen: + raise Invalid(f"prefix product residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s7/tests/instance.json b/tasks/construct-rlve-prefix-product-permutation-l3-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3e89b2dcc36b942220edff12794e9d908841c070 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 191, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s7/tests/run.py b/tasks/construct-rlve-prefix-product-permutation-l3-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s7/tests/test.sh b/tasks/construct-rlve-prefix-product-permutation-l3-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s9/environment/Dockerfile b/tasks/construct-rlve-prefix-product-permutation-l3-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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-prefix-product-permutation-l3-s9/environment/instance.json b/tasks/construct-rlve-prefix-product-permutation-l3-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..829acf37169ec95b74d88cb54f5d00fed411070a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 197, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s9/solution/solve.sh b/tasks/construct-rlve-prefix-product-permutation-l3-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..295f6ff13861ce61d68db064efd9bb1589f45ff6 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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' +{"perm": [1, 2, 100, 67, 149, 80, 34, 170, 75, 23, 139, 19, 116, 92, 184, 93, 38, 59, 12, 84, 70, 123, 10, 61, 157, 135, 145, 74, 191, 35, 47, 90, 118, 7, 30, 153, 105, 17, 141, 97, 134, 174, 62, 56, 104, 163, 31, 110, 79, 194, 68, 86, 73, 172, 136, 44, 96, 160, 18, 188, 24, 43, 144, 173, 158, 98, 4, 51, 114, 21, 77, 112, 53, 28, 9, 177, 71, 88, 49, 6, 166, 91, 186, 20, 130, 52, 127, 78, 151, 32, 82, 14, 16, 162, 154, 57, 40, 66, 196, 3, 133, 159, 142, 45, 37, 183, 185, 117, 167, 48, 121, 72, 147, 69, 179, 13, 108, 33, 193, 150, 111, 128, 22, 190, 171, 146, 87, 122, 178, 85, 148, 195, 101, 41, 26, 55, 156, 175, 11, 181, 39, 103, 155, 63, 27, 126, 113, 131, 5, 120, 89, 168, 36, 95, 143, 137, 25, 65, 102, 58, 182, 94, 46, 169, 192, 81, 109, 152, 164, 8, 125, 54, 64, 42, 138, 189, 76, 129, 115, 187, 140, 161, 106, 15, 107, 83, 180, 60, 176, 124, 29, 165, 119, 50, 132, 99, 197]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s9/tests/check.py b/tasks/construct-rlve-prefix-product-permutation-l3-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3d93850acd79cc0f8fff05cdbb0c63aabc484815 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s9/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 1 + for v in p: + acc = acc * v % n + if acc in seen: + raise Invalid(f"prefix product residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s9/tests/instance.json b/tasks/construct-rlve-prefix-product-permutation-l3-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..829acf37169ec95b74d88cb54f5d00fed411070a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 197, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s9/tests/run.py b/tasks/construct-rlve-prefix-product-permutation-l3-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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-prefix-product-permutation-l3-s9/tests/test.sh b/tasks/construct-rlve-prefix-product-permutation-l3-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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-s6/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l2-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s6/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cb3b20548cddcc5188b9b0ed77bcfed8203951c2 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 84, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s6/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c7782bc954ec52db30fbbfdf0dc4e28ebf22be06 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [84, 1, 82, 3, 80, 5, 78, 7, 76, 9, 74, 11, 72, 13, 70, 15, 68, 17, 66, 19, 64, 21, 62, 23, 60, 25, 58, 27, 56, 29, 54, 31, 52, 33, 50, 35, 48, 37, 46, 39, 44, 41, 42, 43, 40, 45, 38, 47, 36, 49, 34, 51, 32, 53, 30, 55, 28, 57, 26, 59, 24, 61, 22, 63, 20, 65, 18, 67, 16, 69, 14, 71, 12, 73, 10, 75, 8, 77, 6, 79, 4, 81, 2, 83]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s6/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s6/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s6/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l2-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cb3b20548cddcc5188b9b0ed77bcfed8203951c2 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 84, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s6/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l2-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-sum-permutation-l2-s6/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l2-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l2-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s8/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s8/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b4b5099b48a769f6ac0836be5abd3b69b5663e45 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 10712, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s8/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..946b03b5c3b1222a4867a0c8a1f8da887cf20b9e --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [10712, 1, 10710, 3, 10708, 5, 10706, 7, 10704, 9, 10702, 11, 10700, 13, 10698, 15, 10696, 17, 10694, 19, 10692, 21, 10690, 23, 10688, 25, 10686, 27, 10684, 29, 10682, 31, 10680, 33, 10678, 35, 10676, 37, 10674, 39, 10672, 41, 10670, 43, 10668, 45, 10666, 47, 10664, 49, 10662, 51, 10660, 53, 10658, 55, 10656, 57, 10654, 59, 10652, 61, 10650, 63, 10648, 65, 10646, 67, 10644, 69, 10642, 71, 10640, 73, 10638, 75, 10636, 77, 10634, 79, 10632, 81, 10630, 83, 10628, 85, 10626, 87, 10624, 89, 10622, 91, 10620, 93, 10618, 95, 10616, 97, 10614, 99, 10612, 101, 10610, 103, 10608, 105, 10606, 107, 10604, 109, 10602, 111, 10600, 113, 10598, 115, 10596, 117, 10594, 119, 10592, 121, 10590, 123, 10588, 125, 10586, 127, 10584, 129, 10582, 131, 10580, 133, 10578, 135, 10576, 137, 10574, 139, 10572, 141, 10570, 143, 10568, 145, 10566, 147, 10564, 149, 10562, 151, 10560, 153, 10558, 155, 10556, 157, 10554, 159, 10552, 161, 10550, 163, 10548, 165, 10546, 167, 10544, 169, 10542, 171, 10540, 173, 10538, 175, 10536, 177, 10534, 179, 10532, 181, 10530, 183, 10528, 185, 10526, 187, 10524, 189, 10522, 191, 10520, 193, 10518, 195, 10516, 197, 10514, 199, 10512, 201, 10510, 203, 10508, 205, 10506, 207, 10504, 209, 10502, 211, 10500, 213, 10498, 215, 10496, 217, 10494, 219, 10492, 221, 10490, 223, 10488, 225, 10486, 227, 10484, 229, 10482, 231, 10480, 233, 10478, 235, 10476, 237, 10474, 239, 10472, 241, 10470, 243, 10468, 245, 10466, 247, 10464, 249, 10462, 251, 10460, 253, 10458, 255, 10456, 257, 10454, 259, 10452, 261, 10450, 263, 10448, 265, 10446, 267, 10444, 269, 10442, 271, 10440, 273, 10438, 275, 10436, 277, 10434, 279, 10432, 281, 10430, 283, 10428, 285, 10426, 287, 10424, 289, 10422, 291, 10420, 293, 10418, 295, 10416, 297, 10414, 299, 10412, 301, 10410, 303, 10408, 305, 10406, 307, 10404, 309, 10402, 311, 10400, 313, 10398, 315, 10396, 317, 10394, 319, 10392, 321, 10390, 323, 10388, 325, 10386, 327, 10384, 329, 10382, 331, 10380, 333, 10378, 335, 10376, 337, 10374, 339, 10372, 341, 10370, 343, 10368, 345, 10366, 347, 10364, 349, 10362, 351, 10360, 353, 10358, 355, 10356, 357, 10354, 359, 10352, 361, 10350, 363, 10348, 365, 10346, 367, 10344, 369, 10342, 371, 10340, 373, 10338, 375, 10336, 377, 10334, 379, 10332, 381, 10330, 383, 10328, 385, 10326, 387, 10324, 389, 10322, 391, 10320, 393, 10318, 395, 10316, 397, 10314, 399, 10312, 401, 10310, 403, 10308, 405, 10306, 407, 10304, 409, 10302, 411, 10300, 413, 10298, 415, 10296, 417, 10294, 419, 10292, 421, 10290, 423, 10288, 425, 10286, 427, 10284, 429, 10282, 431, 10280, 433, 10278, 435, 10276, 437, 10274, 439, 10272, 441, 10270, 443, 10268, 445, 10266, 447, 10264, 449, 10262, 451, 10260, 453, 10258, 455, 10256, 457, 10254, 459, 10252, 461, 10250, 463, 10248, 465, 10246, 467, 10244, 469, 10242, 471, 10240, 473, 10238, 475, 10236, 477, 10234, 479, 10232, 481, 10230, 483, 10228, 485, 10226, 487, 10224, 489, 10222, 491, 10220, 493, 10218, 495, 10216, 497, 10214, 499, 10212, 501, 10210, 503, 10208, 505, 10206, 507, 10204, 509, 10202, 511, 10200, 513, 10198, 515, 10196, 517, 10194, 519, 10192, 521, 10190, 523, 10188, 525, 10186, 527, 10184, 529, 10182, 531, 10180, 533, 10178, 535, 10176, 537, 10174, 539, 10172, 541, 10170, 543, 10168, 545, 10166, 547, 10164, 549, 10162, 551, 10160, 553, 10158, 555, 10156, 557, 10154, 559, 10152, 561, 10150, 563, 10148, 565, 10146, 567, 10144, 569, 10142, 571, 10140, 573, 10138, 575, 10136, 577, 10134, 579, 10132, 581, 10130, 583, 10128, 585, 10126, 587, 10124, 589, 10122, 591, 10120, 593, 10118, 595, 10116, 597, 10114, 599, 10112, 601, 10110, 603, 10108, 605, 10106, 607, 10104, 609, 10102, 611, 10100, 613, 10098, 615, 10096, 617, 10094, 619, 10092, 621, 10090, 623, 10088, 625, 10086, 627, 10084, 629, 10082, 631, 10080, 633, 10078, 635, 10076, 637, 10074, 639, 10072, 641, 10070, 643, 10068, 645, 10066, 647, 10064, 649, 10062, 651, 10060, 653, 10058, 655, 10056, 657, 10054, 659, 10052, 661, 10050, 663, 10048, 665, 10046, 667, 10044, 669, 10042, 671, 10040, 673, 10038, 675, 10036, 677, 10034, 679, 10032, 681, 10030, 683, 10028, 685, 10026, 687, 10024, 689, 10022, 691, 10020, 693, 10018, 695, 10016, 697, 10014, 699, 10012, 701, 10010, 703, 10008, 705, 10006, 707, 10004, 709, 10002, 711, 10000, 713, 9998, 715, 9996, 717, 9994, 719, 9992, 721, 9990, 723, 9988, 725, 9986, 727, 9984, 729, 9982, 731, 9980, 733, 9978, 735, 9976, 737, 9974, 739, 9972, 741, 9970, 743, 9968, 745, 9966, 747, 9964, 749, 9962, 751, 9960, 753, 9958, 755, 9956, 757, 9954, 759, 9952, 761, 9950, 763, 9948, 765, 9946, 767, 9944, 769, 9942, 771, 9940, 773, 9938, 775, 9936, 777, 9934, 779, 9932, 781, 9930, 783, 9928, 785, 9926, 787, 9924, 789, 9922, 791, 9920, 793, 9918, 795, 9916, 797, 9914, 799, 9912, 801, 9910, 803, 9908, 805, 9906, 807, 9904, 809, 9902, 811, 9900, 813, 9898, 815, 9896, 817, 9894, 819, 9892, 821, 9890, 823, 9888, 825, 9886, 827, 9884, 829, 9882, 831, 9880, 833, 9878, 835, 9876, 837, 9874, 839, 9872, 841, 9870, 843, 9868, 845, 9866, 847, 9864, 849, 9862, 851, 9860, 853, 9858, 855, 9856, 857, 9854, 859, 9852, 861, 9850, 863, 9848, 865, 9846, 867, 9844, 869, 9842, 871, 9840, 873, 9838, 875, 9836, 877, 9834, 879, 9832, 881, 9830, 883, 9828, 885, 9826, 887, 9824, 889, 9822, 891, 9820, 893, 9818, 895, 9816, 897, 9814, 899, 9812, 901, 9810, 903, 9808, 905, 9806, 907, 9804, 909, 9802, 911, 9800, 913, 9798, 915, 9796, 917, 9794, 919, 9792, 921, 9790, 923, 9788, 925, 9786, 927, 9784, 929, 9782, 931, 9780, 933, 9778, 935, 9776, 937, 9774, 939, 9772, 941, 9770, 943, 9768, 945, 9766, 947, 9764, 949, 9762, 951, 9760, 953, 9758, 955, 9756, 957, 9754, 959, 9752, 961, 9750, 963, 9748, 965, 9746, 967, 9744, 969, 9742, 971, 9740, 973, 9738, 975, 9736, 977, 9734, 979, 9732, 981, 9730, 983, 9728, 985, 9726, 987, 9724, 989, 9722, 991, 9720, 993, 9718, 995, 9716, 997, 9714, 999, 9712, 1001, 9710, 1003, 9708, 1005, 9706, 1007, 9704, 1009, 9702, 1011, 9700, 1013, 9698, 1015, 9696, 1017, 9694, 1019, 9692, 1021, 9690, 1023, 9688, 1025, 9686, 1027, 9684, 1029, 9682, 1031, 9680, 1033, 9678, 1035, 9676, 1037, 9674, 1039, 9672, 1041, 9670, 1043, 9668, 1045, 9666, 1047, 9664, 1049, 9662, 1051, 9660, 1053, 9658, 1055, 9656, 1057, 9654, 1059, 9652, 1061, 9650, 1063, 9648, 1065, 9646, 1067, 9644, 1069, 9642, 1071, 9640, 1073, 9638, 1075, 9636, 1077, 9634, 1079, 9632, 1081, 9630, 1083, 9628, 1085, 9626, 1087, 9624, 1089, 9622, 1091, 9620, 1093, 9618, 1095, 9616, 1097, 9614, 1099, 9612, 1101, 9610, 1103, 9608, 1105, 9606, 1107, 9604, 1109, 9602, 1111, 9600, 1113, 9598, 1115, 9596, 1117, 9594, 1119, 9592, 1121, 9590, 1123, 9588, 1125, 9586, 1127, 9584, 1129, 9582, 1131, 9580, 1133, 9578, 1135, 9576, 1137, 9574, 1139, 9572, 1141, 9570, 1143, 9568, 1145, 9566, 1147, 9564, 1149, 9562, 1151, 9560, 1153, 9558, 1155, 9556, 1157, 9554, 1159, 9552, 1161, 9550, 1163, 9548, 1165, 9546, 1167, 9544, 1169, 9542, 1171, 9540, 1173, 9538, 1175, 9536, 1177, 9534, 1179, 9532, 1181, 9530, 1183, 9528, 1185, 9526, 1187, 9524, 1189, 9522, 1191, 9520, 1193, 9518, 1195, 9516, 1197, 9514, 1199, 9512, 1201, 9510, 1203, 9508, 1205, 9506, 1207, 9504, 1209, 9502, 1211, 9500, 1213, 9498, 1215, 9496, 1217, 9494, 1219, 9492, 1221, 9490, 1223, 9488, 1225, 9486, 1227, 9484, 1229, 9482, 1231, 9480, 1233, 9478, 1235, 9476, 1237, 9474, 1239, 9472, 1241, 9470, 1243, 9468, 1245, 9466, 1247, 9464, 1249, 9462, 1251, 9460, 1253, 9458, 1255, 9456, 1257, 9454, 1259, 9452, 1261, 9450, 1263, 9448, 1265, 9446, 1267, 9444, 1269, 9442, 1271, 9440, 1273, 9438, 1275, 9436, 1277, 9434, 1279, 9432, 1281, 9430, 1283, 9428, 1285, 9426, 1287, 9424, 1289, 9422, 1291, 9420, 1293, 9418, 1295, 9416, 1297, 9414, 1299, 9412, 1301, 9410, 1303, 9408, 1305, 9406, 1307, 9404, 1309, 9402, 1311, 9400, 1313, 9398, 1315, 9396, 1317, 9394, 1319, 9392, 1321, 9390, 1323, 9388, 1325, 9386, 1327, 9384, 1329, 9382, 1331, 9380, 1333, 9378, 1335, 9376, 1337, 9374, 1339, 9372, 1341, 9370, 1343, 9368, 1345, 9366, 1347, 9364, 1349, 9362, 1351, 9360, 1353, 9358, 1355, 9356, 1357, 9354, 1359, 9352, 1361, 9350, 1363, 9348, 1365, 9346, 1367, 9344, 1369, 9342, 1371, 9340, 1373, 9338, 1375, 9336, 1377, 9334, 1379, 9332, 1381, 9330, 1383, 9328, 1385, 9326, 1387, 9324, 1389, 9322, 1391, 9320, 1393, 9318, 1395, 9316, 1397, 9314, 1399, 9312, 1401, 9310, 1403, 9308, 1405, 9306, 1407, 9304, 1409, 9302, 1411, 9300, 1413, 9298, 1415, 9296, 1417, 9294, 1419, 9292, 1421, 9290, 1423, 9288, 1425, 9286, 1427, 9284, 1429, 9282, 1431, 9280, 1433, 9278, 1435, 9276, 1437, 9274, 1439, 9272, 1441, 9270, 1443, 9268, 1445, 9266, 1447, 9264, 1449, 9262, 1451, 9260, 1453, 9258, 1455, 9256, 1457, 9254, 1459, 9252, 1461, 9250, 1463, 9248, 1465, 9246, 1467, 9244, 1469, 9242, 1471, 9240, 1473, 9238, 1475, 9236, 1477, 9234, 1479, 9232, 1481, 9230, 1483, 9228, 1485, 9226, 1487, 9224, 1489, 9222, 1491, 9220, 1493, 9218, 1495, 9216, 1497, 9214, 1499, 9212, 1501, 9210, 1503, 9208, 1505, 9206, 1507, 9204, 1509, 9202, 1511, 9200, 1513, 9198, 1515, 9196, 1517, 9194, 1519, 9192, 1521, 9190, 1523, 9188, 1525, 9186, 1527, 9184, 1529, 9182, 1531, 9180, 1533, 9178, 1535, 9176, 1537, 9174, 1539, 9172, 1541, 9170, 1543, 9168, 1545, 9166, 1547, 9164, 1549, 9162, 1551, 9160, 1553, 9158, 1555, 9156, 1557, 9154, 1559, 9152, 1561, 9150, 1563, 9148, 1565, 9146, 1567, 9144, 1569, 9142, 1571, 9140, 1573, 9138, 1575, 9136, 1577, 9134, 1579, 9132, 1581, 9130, 1583, 9128, 1585, 9126, 1587, 9124, 1589, 9122, 1591, 9120, 1593, 9118, 1595, 9116, 1597, 9114, 1599, 9112, 1601, 9110, 1603, 9108, 1605, 9106, 1607, 9104, 1609, 9102, 1611, 9100, 1613, 9098, 1615, 9096, 1617, 9094, 1619, 9092, 1621, 9090, 1623, 9088, 1625, 9086, 1627, 9084, 1629, 9082, 1631, 9080, 1633, 9078, 1635, 9076, 1637, 9074, 1639, 9072, 1641, 9070, 1643, 9068, 1645, 9066, 1647, 9064, 1649, 9062, 1651, 9060, 1653, 9058, 1655, 9056, 1657, 9054, 1659, 9052, 1661, 9050, 1663, 9048, 1665, 9046, 1667, 9044, 1669, 9042, 1671, 9040, 1673, 9038, 1675, 9036, 1677, 9034, 1679, 9032, 1681, 9030, 1683, 9028, 1685, 9026, 1687, 9024, 1689, 9022, 1691, 9020, 1693, 9018, 1695, 9016, 1697, 9014, 1699, 9012, 1701, 9010, 1703, 9008, 1705, 9006, 1707, 9004, 1709, 9002, 1711, 9000, 1713, 8998, 1715, 8996, 1717, 8994, 1719, 8992, 1721, 8990, 1723, 8988, 1725, 8986, 1727, 8984, 1729, 8982, 1731, 8980, 1733, 8978, 1735, 8976, 1737, 8974, 1739, 8972, 1741, 8970, 1743, 8968, 1745, 8966, 1747, 8964, 1749, 8962, 1751, 8960, 1753, 8958, 1755, 8956, 1757, 8954, 1759, 8952, 1761, 8950, 1763, 8948, 1765, 8946, 1767, 8944, 1769, 8942, 1771, 8940, 1773, 8938, 1775, 8936, 1777, 8934, 1779, 8932, 1781, 8930, 1783, 8928, 1785, 8926, 1787, 8924, 1789, 8922, 1791, 8920, 1793, 8918, 1795, 8916, 1797, 8914, 1799, 8912, 1801, 8910, 1803, 8908, 1805, 8906, 1807, 8904, 1809, 8902, 1811, 8900, 1813, 8898, 1815, 8896, 1817, 8894, 1819, 8892, 1821, 8890, 1823, 8888, 1825, 8886, 1827, 8884, 1829, 8882, 1831, 8880, 1833, 8878, 1835, 8876, 1837, 8874, 1839, 8872, 1841, 8870, 1843, 8868, 1845, 8866, 1847, 8864, 1849, 8862, 1851, 8860, 1853, 8858, 1855, 8856, 1857, 8854, 1859, 8852, 1861, 8850, 1863, 8848, 1865, 8846, 1867, 8844, 1869, 8842, 1871, 8840, 1873, 8838, 1875, 8836, 1877, 8834, 1879, 8832, 1881, 8830, 1883, 8828, 1885, 8826, 1887, 8824, 1889, 8822, 1891, 8820, 1893, 8818, 1895, 8816, 1897, 8814, 1899, 8812, 1901, 8810, 1903, 8808, 1905, 8806, 1907, 8804, 1909, 8802, 1911, 8800, 1913, 8798, 1915, 8796, 1917, 8794, 1919, 8792, 1921, 8790, 1923, 8788, 1925, 8786, 1927, 8784, 1929, 8782, 1931, 8780, 1933, 8778, 1935, 8776, 1937, 8774, 1939, 8772, 1941, 8770, 1943, 8768, 1945, 8766, 1947, 8764, 1949, 8762, 1951, 8760, 1953, 8758, 1955, 8756, 1957, 8754, 1959, 8752, 1961, 8750, 1963, 8748, 1965, 8746, 1967, 8744, 1969, 8742, 1971, 8740, 1973, 8738, 1975, 8736, 1977, 8734, 1979, 8732, 1981, 8730, 1983, 8728, 1985, 8726, 1987, 8724, 1989, 8722, 1991, 8720, 1993, 8718, 1995, 8716, 1997, 8714, 1999, 8712, 2001, 8710, 2003, 8708, 2005, 8706, 2007, 8704, 2009, 8702, 2011, 8700, 2013, 8698, 2015, 8696, 2017, 8694, 2019, 8692, 2021, 8690, 2023, 8688, 2025, 8686, 2027, 8684, 2029, 8682, 2031, 8680, 2033, 8678, 2035, 8676, 2037, 8674, 2039, 8672, 2041, 8670, 2043, 8668, 2045, 8666, 2047, 8664, 2049, 8662, 2051, 8660, 2053, 8658, 2055, 8656, 2057, 8654, 2059, 8652, 2061, 8650, 2063, 8648, 2065, 8646, 2067, 8644, 2069, 8642, 2071, 8640, 2073, 8638, 2075, 8636, 2077, 8634, 2079, 8632, 2081, 8630, 2083, 8628, 2085, 8626, 2087, 8624, 2089, 8622, 2091, 8620, 2093, 8618, 2095, 8616, 2097, 8614, 2099, 8612, 2101, 8610, 2103, 8608, 2105, 8606, 2107, 8604, 2109, 8602, 2111, 8600, 2113, 8598, 2115, 8596, 2117, 8594, 2119, 8592, 2121, 8590, 2123, 8588, 2125, 8586, 2127, 8584, 2129, 8582, 2131, 8580, 2133, 8578, 2135, 8576, 2137, 8574, 2139, 8572, 2141, 8570, 2143, 8568, 2145, 8566, 2147, 8564, 2149, 8562, 2151, 8560, 2153, 8558, 2155, 8556, 2157, 8554, 2159, 8552, 2161, 8550, 2163, 8548, 2165, 8546, 2167, 8544, 2169, 8542, 2171, 8540, 2173, 8538, 2175, 8536, 2177, 8534, 2179, 8532, 2181, 8530, 2183, 8528, 2185, 8526, 2187, 8524, 2189, 8522, 2191, 8520, 2193, 8518, 2195, 8516, 2197, 8514, 2199, 8512, 2201, 8510, 2203, 8508, 2205, 8506, 2207, 8504, 2209, 8502, 2211, 8500, 2213, 8498, 2215, 8496, 2217, 8494, 2219, 8492, 2221, 8490, 2223, 8488, 2225, 8486, 2227, 8484, 2229, 8482, 2231, 8480, 2233, 8478, 2235, 8476, 2237, 8474, 2239, 8472, 2241, 8470, 2243, 8468, 2245, 8466, 2247, 8464, 2249, 8462, 2251, 8460, 2253, 8458, 2255, 8456, 2257, 8454, 2259, 8452, 2261, 8450, 2263, 8448, 2265, 8446, 2267, 8444, 2269, 8442, 2271, 8440, 2273, 8438, 2275, 8436, 2277, 8434, 2279, 8432, 2281, 8430, 2283, 8428, 2285, 8426, 2287, 8424, 2289, 8422, 2291, 8420, 2293, 8418, 2295, 8416, 2297, 8414, 2299, 8412, 2301, 8410, 2303, 8408, 2305, 8406, 2307, 8404, 2309, 8402, 2311, 8400, 2313, 8398, 2315, 8396, 2317, 8394, 2319, 8392, 2321, 8390, 2323, 8388, 2325, 8386, 2327, 8384, 2329, 8382, 2331, 8380, 2333, 8378, 2335, 8376, 2337, 8374, 2339, 8372, 2341, 8370, 2343, 8368, 2345, 8366, 2347, 8364, 2349, 8362, 2351, 8360, 2353, 8358, 2355, 8356, 2357, 8354, 2359, 8352, 2361, 8350, 2363, 8348, 2365, 8346, 2367, 8344, 2369, 8342, 2371, 8340, 2373, 8338, 2375, 8336, 2377, 8334, 2379, 8332, 2381, 8330, 2383, 8328, 2385, 8326, 2387, 8324, 2389, 8322, 2391, 8320, 2393, 8318, 2395, 8316, 2397, 8314, 2399, 8312, 2401, 8310, 2403, 8308, 2405, 8306, 2407, 8304, 2409, 8302, 2411, 8300, 2413, 8298, 2415, 8296, 2417, 8294, 2419, 8292, 2421, 8290, 2423, 8288, 2425, 8286, 2427, 8284, 2429, 8282, 2431, 8280, 2433, 8278, 2435, 8276, 2437, 8274, 2439, 8272, 2441, 8270, 2443, 8268, 2445, 8266, 2447, 8264, 2449, 8262, 2451, 8260, 2453, 8258, 2455, 8256, 2457, 8254, 2459, 8252, 2461, 8250, 2463, 8248, 2465, 8246, 2467, 8244, 2469, 8242, 2471, 8240, 2473, 8238, 2475, 8236, 2477, 8234, 2479, 8232, 2481, 8230, 2483, 8228, 2485, 8226, 2487, 8224, 2489, 8222, 2491, 8220, 2493, 8218, 2495, 8216, 2497, 8214, 2499, 8212, 2501, 8210, 2503, 8208, 2505, 8206, 2507, 8204, 2509, 8202, 2511, 8200, 2513, 8198, 2515, 8196, 2517, 8194, 2519, 8192, 2521, 8190, 2523, 8188, 2525, 8186, 2527, 8184, 2529, 8182, 2531, 8180, 2533, 8178, 2535, 8176, 2537, 8174, 2539, 8172, 2541, 8170, 2543, 8168, 2545, 8166, 2547, 8164, 2549, 8162, 2551, 8160, 2553, 8158, 2555, 8156, 2557, 8154, 2559, 8152, 2561, 8150, 2563, 8148, 2565, 8146, 2567, 8144, 2569, 8142, 2571, 8140, 2573, 8138, 2575, 8136, 2577, 8134, 2579, 8132, 2581, 8130, 2583, 8128, 2585, 8126, 2587, 8124, 2589, 8122, 2591, 8120, 2593, 8118, 2595, 8116, 2597, 8114, 2599, 8112, 2601, 8110, 2603, 8108, 2605, 8106, 2607, 8104, 2609, 8102, 2611, 8100, 2613, 8098, 2615, 8096, 2617, 8094, 2619, 8092, 2621, 8090, 2623, 8088, 2625, 8086, 2627, 8084, 2629, 8082, 2631, 8080, 2633, 8078, 2635, 8076, 2637, 8074, 2639, 8072, 2641, 8070, 2643, 8068, 2645, 8066, 2647, 8064, 2649, 8062, 2651, 8060, 2653, 8058, 2655, 8056, 2657, 8054, 2659, 8052, 2661, 8050, 2663, 8048, 2665, 8046, 2667, 8044, 2669, 8042, 2671, 8040, 2673, 8038, 2675, 8036, 2677, 8034, 2679, 8032, 2681, 8030, 2683, 8028, 2685, 8026, 2687, 8024, 2689, 8022, 2691, 8020, 2693, 8018, 2695, 8016, 2697, 8014, 2699, 8012, 2701, 8010, 2703, 8008, 2705, 8006, 2707, 8004, 2709, 8002, 2711, 8000, 2713, 7998, 2715, 7996, 2717, 7994, 2719, 7992, 2721, 7990, 2723, 7988, 2725, 7986, 2727, 7984, 2729, 7982, 2731, 7980, 2733, 7978, 2735, 7976, 2737, 7974, 2739, 7972, 2741, 7970, 2743, 7968, 2745, 7966, 2747, 7964, 2749, 7962, 2751, 7960, 2753, 7958, 2755, 7956, 2757, 7954, 2759, 7952, 2761, 7950, 2763, 7948, 2765, 7946, 2767, 7944, 2769, 7942, 2771, 7940, 2773, 7938, 2775, 7936, 2777, 7934, 2779, 7932, 2781, 7930, 2783, 7928, 2785, 7926, 2787, 7924, 2789, 7922, 2791, 7920, 2793, 7918, 2795, 7916, 2797, 7914, 2799, 7912, 2801, 7910, 2803, 7908, 2805, 7906, 2807, 7904, 2809, 7902, 2811, 7900, 2813, 7898, 2815, 7896, 2817, 7894, 2819, 7892, 2821, 7890, 2823, 7888, 2825, 7886, 2827, 7884, 2829, 7882, 2831, 7880, 2833, 7878, 2835, 7876, 2837, 7874, 2839, 7872, 2841, 7870, 2843, 7868, 2845, 7866, 2847, 7864, 2849, 7862, 2851, 7860, 2853, 7858, 2855, 7856, 2857, 7854, 2859, 7852, 2861, 7850, 2863, 7848, 2865, 7846, 2867, 7844, 2869, 7842, 2871, 7840, 2873, 7838, 2875, 7836, 2877, 7834, 2879, 7832, 2881, 7830, 2883, 7828, 2885, 7826, 2887, 7824, 2889, 7822, 2891, 7820, 2893, 7818, 2895, 7816, 2897, 7814, 2899, 7812, 2901, 7810, 2903, 7808, 2905, 7806, 2907, 7804, 2909, 7802, 2911, 7800, 2913, 7798, 2915, 7796, 2917, 7794, 2919, 7792, 2921, 7790, 2923, 7788, 2925, 7786, 2927, 7784, 2929, 7782, 2931, 7780, 2933, 7778, 2935, 7776, 2937, 7774, 2939, 7772, 2941, 7770, 2943, 7768, 2945, 7766, 2947, 7764, 2949, 7762, 2951, 7760, 2953, 7758, 2955, 7756, 2957, 7754, 2959, 7752, 2961, 7750, 2963, 7748, 2965, 7746, 2967, 7744, 2969, 7742, 2971, 7740, 2973, 7738, 2975, 7736, 2977, 7734, 2979, 7732, 2981, 7730, 2983, 7728, 2985, 7726, 2987, 7724, 2989, 7722, 2991, 7720, 2993, 7718, 2995, 7716, 2997, 7714, 2999, 7712, 3001, 7710, 3003, 7708, 3005, 7706, 3007, 7704, 3009, 7702, 3011, 7700, 3013, 7698, 3015, 7696, 3017, 7694, 3019, 7692, 3021, 7690, 3023, 7688, 3025, 7686, 3027, 7684, 3029, 7682, 3031, 7680, 3033, 7678, 3035, 7676, 3037, 7674, 3039, 7672, 3041, 7670, 3043, 7668, 3045, 7666, 3047, 7664, 3049, 7662, 3051, 7660, 3053, 7658, 3055, 7656, 3057, 7654, 3059, 7652, 3061, 7650, 3063, 7648, 3065, 7646, 3067, 7644, 3069, 7642, 3071, 7640, 3073, 7638, 3075, 7636, 3077, 7634, 3079, 7632, 3081, 7630, 3083, 7628, 3085, 7626, 3087, 7624, 3089, 7622, 3091, 7620, 3093, 7618, 3095, 7616, 3097, 7614, 3099, 7612, 3101, 7610, 3103, 7608, 3105, 7606, 3107, 7604, 3109, 7602, 3111, 7600, 3113, 7598, 3115, 7596, 3117, 7594, 3119, 7592, 3121, 7590, 3123, 7588, 3125, 7586, 3127, 7584, 3129, 7582, 3131, 7580, 3133, 7578, 3135, 7576, 3137, 7574, 3139, 7572, 3141, 7570, 3143, 7568, 3145, 7566, 3147, 7564, 3149, 7562, 3151, 7560, 3153, 7558, 3155, 7556, 3157, 7554, 3159, 7552, 3161, 7550, 3163, 7548, 3165, 7546, 3167, 7544, 3169, 7542, 3171, 7540, 3173, 7538, 3175, 7536, 3177, 7534, 3179, 7532, 3181, 7530, 3183, 7528, 3185, 7526, 3187, 7524, 3189, 7522, 3191, 7520, 3193, 7518, 3195, 7516, 3197, 7514, 3199, 7512, 3201, 7510, 3203, 7508, 3205, 7506, 3207, 7504, 3209, 7502, 3211, 7500, 3213, 7498, 3215, 7496, 3217, 7494, 3219, 7492, 3221, 7490, 3223, 7488, 3225, 7486, 3227, 7484, 3229, 7482, 3231, 7480, 3233, 7478, 3235, 7476, 3237, 7474, 3239, 7472, 3241, 7470, 3243, 7468, 3245, 7466, 3247, 7464, 3249, 7462, 3251, 7460, 3253, 7458, 3255, 7456, 3257, 7454, 3259, 7452, 3261, 7450, 3263, 7448, 3265, 7446, 3267, 7444, 3269, 7442, 3271, 7440, 3273, 7438, 3275, 7436, 3277, 7434, 3279, 7432, 3281, 7430, 3283, 7428, 3285, 7426, 3287, 7424, 3289, 7422, 3291, 7420, 3293, 7418, 3295, 7416, 3297, 7414, 3299, 7412, 3301, 7410, 3303, 7408, 3305, 7406, 3307, 7404, 3309, 7402, 3311, 7400, 3313, 7398, 3315, 7396, 3317, 7394, 3319, 7392, 3321, 7390, 3323, 7388, 3325, 7386, 3327, 7384, 3329, 7382, 3331, 7380, 3333, 7378, 3335, 7376, 3337, 7374, 3339, 7372, 3341, 7370, 3343, 7368, 3345, 7366, 3347, 7364, 3349, 7362, 3351, 7360, 3353, 7358, 3355, 7356, 3357, 7354, 3359, 7352, 3361, 7350, 3363, 7348, 3365, 7346, 3367, 7344, 3369, 7342, 3371, 7340, 3373, 7338, 3375, 7336, 3377, 7334, 3379, 7332, 3381, 7330, 3383, 7328, 3385, 7326, 3387, 7324, 3389, 7322, 3391, 7320, 3393, 7318, 3395, 7316, 3397, 7314, 3399, 7312, 3401, 7310, 3403, 7308, 3405, 7306, 3407, 7304, 3409, 7302, 3411, 7300, 3413, 7298, 3415, 7296, 3417, 7294, 3419, 7292, 3421, 7290, 3423, 7288, 3425, 7286, 3427, 7284, 3429, 7282, 3431, 7280, 3433, 7278, 3435, 7276, 3437, 7274, 3439, 7272, 3441, 7270, 3443, 7268, 3445, 7266, 3447, 7264, 3449, 7262, 3451, 7260, 3453, 7258, 3455, 7256, 3457, 7254, 3459, 7252, 3461, 7250, 3463, 7248, 3465, 7246, 3467, 7244, 3469, 7242, 3471, 7240, 3473, 7238, 3475, 7236, 3477, 7234, 3479, 7232, 3481, 7230, 3483, 7228, 3485, 7226, 3487, 7224, 3489, 7222, 3491, 7220, 3493, 7218, 3495, 7216, 3497, 7214, 3499, 7212, 3501, 7210, 3503, 7208, 3505, 7206, 3507, 7204, 3509, 7202, 3511, 7200, 3513, 7198, 3515, 7196, 3517, 7194, 3519, 7192, 3521, 7190, 3523, 7188, 3525, 7186, 3527, 7184, 3529, 7182, 3531, 7180, 3533, 7178, 3535, 7176, 3537, 7174, 3539, 7172, 3541, 7170, 3543, 7168, 3545, 7166, 3547, 7164, 3549, 7162, 3551, 7160, 3553, 7158, 3555, 7156, 3557, 7154, 3559, 7152, 3561, 7150, 3563, 7148, 3565, 7146, 3567, 7144, 3569, 7142, 3571, 7140, 3573, 7138, 3575, 7136, 3577, 7134, 3579, 7132, 3581, 7130, 3583, 7128, 3585, 7126, 3587, 7124, 3589, 7122, 3591, 7120, 3593, 7118, 3595, 7116, 3597, 7114, 3599, 7112, 3601, 7110, 3603, 7108, 3605, 7106, 3607, 7104, 3609, 7102, 3611, 7100, 3613, 7098, 3615, 7096, 3617, 7094, 3619, 7092, 3621, 7090, 3623, 7088, 3625, 7086, 3627, 7084, 3629, 7082, 3631, 7080, 3633, 7078, 3635, 7076, 3637, 7074, 3639, 7072, 3641, 7070, 3643, 7068, 3645, 7066, 3647, 7064, 3649, 7062, 3651, 7060, 3653, 7058, 3655, 7056, 3657, 7054, 3659, 7052, 3661, 7050, 3663, 7048, 3665, 7046, 3667, 7044, 3669, 7042, 3671, 7040, 3673, 7038, 3675, 7036, 3677, 7034, 3679, 7032, 3681, 7030, 3683, 7028, 3685, 7026, 3687, 7024, 3689, 7022, 3691, 7020, 3693, 7018, 3695, 7016, 3697, 7014, 3699, 7012, 3701, 7010, 3703, 7008, 3705, 7006, 3707, 7004, 3709, 7002, 3711, 7000, 3713, 6998, 3715, 6996, 3717, 6994, 3719, 6992, 3721, 6990, 3723, 6988, 3725, 6986, 3727, 6984, 3729, 6982, 3731, 6980, 3733, 6978, 3735, 6976, 3737, 6974, 3739, 6972, 3741, 6970, 3743, 6968, 3745, 6966, 3747, 6964, 3749, 6962, 3751, 6960, 3753, 6958, 3755, 6956, 3757, 6954, 3759, 6952, 3761, 6950, 3763, 6948, 3765, 6946, 3767, 6944, 3769, 6942, 3771, 6940, 3773, 6938, 3775, 6936, 3777, 6934, 3779, 6932, 3781, 6930, 3783, 6928, 3785, 6926, 3787, 6924, 3789, 6922, 3791, 6920, 3793, 6918, 3795, 6916, 3797, 6914, 3799, 6912, 3801, 6910, 3803, 6908, 3805, 6906, 3807, 6904, 3809, 6902, 3811, 6900, 3813, 6898, 3815, 6896, 3817, 6894, 3819, 6892, 3821, 6890, 3823, 6888, 3825, 6886, 3827, 6884, 3829, 6882, 3831, 6880, 3833, 6878, 3835, 6876, 3837, 6874, 3839, 6872, 3841, 6870, 3843, 6868, 3845, 6866, 3847, 6864, 3849, 6862, 3851, 6860, 3853, 6858, 3855, 6856, 3857, 6854, 3859, 6852, 3861, 6850, 3863, 6848, 3865, 6846, 3867, 6844, 3869, 6842, 3871, 6840, 3873, 6838, 3875, 6836, 3877, 6834, 3879, 6832, 3881, 6830, 3883, 6828, 3885, 6826, 3887, 6824, 3889, 6822, 3891, 6820, 3893, 6818, 3895, 6816, 3897, 6814, 3899, 6812, 3901, 6810, 3903, 6808, 3905, 6806, 3907, 6804, 3909, 6802, 3911, 6800, 3913, 6798, 3915, 6796, 3917, 6794, 3919, 6792, 3921, 6790, 3923, 6788, 3925, 6786, 3927, 6784, 3929, 6782, 3931, 6780, 3933, 6778, 3935, 6776, 3937, 6774, 3939, 6772, 3941, 6770, 3943, 6768, 3945, 6766, 3947, 6764, 3949, 6762, 3951, 6760, 3953, 6758, 3955, 6756, 3957, 6754, 3959, 6752, 3961, 6750, 3963, 6748, 3965, 6746, 3967, 6744, 3969, 6742, 3971, 6740, 3973, 6738, 3975, 6736, 3977, 6734, 3979, 6732, 3981, 6730, 3983, 6728, 3985, 6726, 3987, 6724, 3989, 6722, 3991, 6720, 3993, 6718, 3995, 6716, 3997, 6714, 3999, 6712, 4001, 6710, 4003, 6708, 4005, 6706, 4007, 6704, 4009, 6702, 4011, 6700, 4013, 6698, 4015, 6696, 4017, 6694, 4019, 6692, 4021, 6690, 4023, 6688, 4025, 6686, 4027, 6684, 4029, 6682, 4031, 6680, 4033, 6678, 4035, 6676, 4037, 6674, 4039, 6672, 4041, 6670, 4043, 6668, 4045, 6666, 4047, 6664, 4049, 6662, 4051, 6660, 4053, 6658, 4055, 6656, 4057, 6654, 4059, 6652, 4061, 6650, 4063, 6648, 4065, 6646, 4067, 6644, 4069, 6642, 4071, 6640, 4073, 6638, 4075, 6636, 4077, 6634, 4079, 6632, 4081, 6630, 4083, 6628, 4085, 6626, 4087, 6624, 4089, 6622, 4091, 6620, 4093, 6618, 4095, 6616, 4097, 6614, 4099, 6612, 4101, 6610, 4103, 6608, 4105, 6606, 4107, 6604, 4109, 6602, 4111, 6600, 4113, 6598, 4115, 6596, 4117, 6594, 4119, 6592, 4121, 6590, 4123, 6588, 4125, 6586, 4127, 6584, 4129, 6582, 4131, 6580, 4133, 6578, 4135, 6576, 4137, 6574, 4139, 6572, 4141, 6570, 4143, 6568, 4145, 6566, 4147, 6564, 4149, 6562, 4151, 6560, 4153, 6558, 4155, 6556, 4157, 6554, 4159, 6552, 4161, 6550, 4163, 6548, 4165, 6546, 4167, 6544, 4169, 6542, 4171, 6540, 4173, 6538, 4175, 6536, 4177, 6534, 4179, 6532, 4181, 6530, 4183, 6528, 4185, 6526, 4187, 6524, 4189, 6522, 4191, 6520, 4193, 6518, 4195, 6516, 4197, 6514, 4199, 6512, 4201, 6510, 4203, 6508, 4205, 6506, 4207, 6504, 4209, 6502, 4211, 6500, 4213, 6498, 4215, 6496, 4217, 6494, 4219, 6492, 4221, 6490, 4223, 6488, 4225, 6486, 4227, 6484, 4229, 6482, 4231, 6480, 4233, 6478, 4235, 6476, 4237, 6474, 4239, 6472, 4241, 6470, 4243, 6468, 4245, 6466, 4247, 6464, 4249, 6462, 4251, 6460, 4253, 6458, 4255, 6456, 4257, 6454, 4259, 6452, 4261, 6450, 4263, 6448, 4265, 6446, 4267, 6444, 4269, 6442, 4271, 6440, 4273, 6438, 4275, 6436, 4277, 6434, 4279, 6432, 4281, 6430, 4283, 6428, 4285, 6426, 4287, 6424, 4289, 6422, 4291, 6420, 4293, 6418, 4295, 6416, 4297, 6414, 4299, 6412, 4301, 6410, 4303, 6408, 4305, 6406, 4307, 6404, 4309, 6402, 4311, 6400, 4313, 6398, 4315, 6396, 4317, 6394, 4319, 6392, 4321, 6390, 4323, 6388, 4325, 6386, 4327, 6384, 4329, 6382, 4331, 6380, 4333, 6378, 4335, 6376, 4337, 6374, 4339, 6372, 4341, 6370, 4343, 6368, 4345, 6366, 4347, 6364, 4349, 6362, 4351, 6360, 4353, 6358, 4355, 6356, 4357, 6354, 4359, 6352, 4361, 6350, 4363, 6348, 4365, 6346, 4367, 6344, 4369, 6342, 4371, 6340, 4373, 6338, 4375, 6336, 4377, 6334, 4379, 6332, 4381, 6330, 4383, 6328, 4385, 6326, 4387, 6324, 4389, 6322, 4391, 6320, 4393, 6318, 4395, 6316, 4397, 6314, 4399, 6312, 4401, 6310, 4403, 6308, 4405, 6306, 4407, 6304, 4409, 6302, 4411, 6300, 4413, 6298, 4415, 6296, 4417, 6294, 4419, 6292, 4421, 6290, 4423, 6288, 4425, 6286, 4427, 6284, 4429, 6282, 4431, 6280, 4433, 6278, 4435, 6276, 4437, 6274, 4439, 6272, 4441, 6270, 4443, 6268, 4445, 6266, 4447, 6264, 4449, 6262, 4451, 6260, 4453, 6258, 4455, 6256, 4457, 6254, 4459, 6252, 4461, 6250, 4463, 6248, 4465, 6246, 4467, 6244, 4469, 6242, 4471, 6240, 4473, 6238, 4475, 6236, 4477, 6234, 4479, 6232, 4481, 6230, 4483, 6228, 4485, 6226, 4487, 6224, 4489, 6222, 4491, 6220, 4493, 6218, 4495, 6216, 4497, 6214, 4499, 6212, 4501, 6210, 4503, 6208, 4505, 6206, 4507, 6204, 4509, 6202, 4511, 6200, 4513, 6198, 4515, 6196, 4517, 6194, 4519, 6192, 4521, 6190, 4523, 6188, 4525, 6186, 4527, 6184, 4529, 6182, 4531, 6180, 4533, 6178, 4535, 6176, 4537, 6174, 4539, 6172, 4541, 6170, 4543, 6168, 4545, 6166, 4547, 6164, 4549, 6162, 4551, 6160, 4553, 6158, 4555, 6156, 4557, 6154, 4559, 6152, 4561, 6150, 4563, 6148, 4565, 6146, 4567, 6144, 4569, 6142, 4571, 6140, 4573, 6138, 4575, 6136, 4577, 6134, 4579, 6132, 4581, 6130, 4583, 6128, 4585, 6126, 4587, 6124, 4589, 6122, 4591, 6120, 4593, 6118, 4595, 6116, 4597, 6114, 4599, 6112, 4601, 6110, 4603, 6108, 4605, 6106, 4607, 6104, 4609, 6102, 4611, 6100, 4613, 6098, 4615, 6096, 4617, 6094, 4619, 6092, 4621, 6090, 4623, 6088, 4625, 6086, 4627, 6084, 4629, 6082, 4631, 6080, 4633, 6078, 4635, 6076, 4637, 6074, 4639, 6072, 4641, 6070, 4643, 6068, 4645, 6066, 4647, 6064, 4649, 6062, 4651, 6060, 4653, 6058, 4655, 6056, 4657, 6054, 4659, 6052, 4661, 6050, 4663, 6048, 4665, 6046, 4667, 6044, 4669, 6042, 4671, 6040, 4673, 6038, 4675, 6036, 4677, 6034, 4679, 6032, 4681, 6030, 4683, 6028, 4685, 6026, 4687, 6024, 4689, 6022, 4691, 6020, 4693, 6018, 4695, 6016, 4697, 6014, 4699, 6012, 4701, 6010, 4703, 6008, 4705, 6006, 4707, 6004, 4709, 6002, 4711, 6000, 4713, 5998, 4715, 5996, 4717, 5994, 4719, 5992, 4721, 5990, 4723, 5988, 4725, 5986, 4727, 5984, 4729, 5982, 4731, 5980, 4733, 5978, 4735, 5976, 4737, 5974, 4739, 5972, 4741, 5970, 4743, 5968, 4745, 5966, 4747, 5964, 4749, 5962, 4751, 5960, 4753, 5958, 4755, 5956, 4757, 5954, 4759, 5952, 4761, 5950, 4763, 5948, 4765, 5946, 4767, 5944, 4769, 5942, 4771, 5940, 4773, 5938, 4775, 5936, 4777, 5934, 4779, 5932, 4781, 5930, 4783, 5928, 4785, 5926, 4787, 5924, 4789, 5922, 4791, 5920, 4793, 5918, 4795, 5916, 4797, 5914, 4799, 5912, 4801, 5910, 4803, 5908, 4805, 5906, 4807, 5904, 4809, 5902, 4811, 5900, 4813, 5898, 4815, 5896, 4817, 5894, 4819, 5892, 4821, 5890, 4823, 5888, 4825, 5886, 4827, 5884, 4829, 5882, 4831, 5880, 4833, 5878, 4835, 5876, 4837, 5874, 4839, 5872, 4841, 5870, 4843, 5868, 4845, 5866, 4847, 5864, 4849, 5862, 4851, 5860, 4853, 5858, 4855, 5856, 4857, 5854, 4859, 5852, 4861, 5850, 4863, 5848, 4865, 5846, 4867, 5844, 4869, 5842, 4871, 5840, 4873, 5838, 4875, 5836, 4877, 5834, 4879, 5832, 4881, 5830, 4883, 5828, 4885, 5826, 4887, 5824, 4889, 5822, 4891, 5820, 4893, 5818, 4895, 5816, 4897, 5814, 4899, 5812, 4901, 5810, 4903, 5808, 4905, 5806, 4907, 5804, 4909, 5802, 4911, 5800, 4913, 5798, 4915, 5796, 4917, 5794, 4919, 5792, 4921, 5790, 4923, 5788, 4925, 5786, 4927, 5784, 4929, 5782, 4931, 5780, 4933, 5778, 4935, 5776, 4937, 5774, 4939, 5772, 4941, 5770, 4943, 5768, 4945, 5766, 4947, 5764, 4949, 5762, 4951, 5760, 4953, 5758, 4955, 5756, 4957, 5754, 4959, 5752, 4961, 5750, 4963, 5748, 4965, 5746, 4967, 5744, 4969, 5742, 4971, 5740, 4973, 5738, 4975, 5736, 4977, 5734, 4979, 5732, 4981, 5730, 4983, 5728, 4985, 5726, 4987, 5724, 4989, 5722, 4991, 5720, 4993, 5718, 4995, 5716, 4997, 5714, 4999, 5712, 5001, 5710, 5003, 5708, 5005, 5706, 5007, 5704, 5009, 5702, 5011, 5700, 5013, 5698, 5015, 5696, 5017, 5694, 5019, 5692, 5021, 5690, 5023, 5688, 5025, 5686, 5027, 5684, 5029, 5682, 5031, 5680, 5033, 5678, 5035, 5676, 5037, 5674, 5039, 5672, 5041, 5670, 5043, 5668, 5045, 5666, 5047, 5664, 5049, 5662, 5051, 5660, 5053, 5658, 5055, 5656, 5057, 5654, 5059, 5652, 5061, 5650, 5063, 5648, 5065, 5646, 5067, 5644, 5069, 5642, 5071, 5640, 5073, 5638, 5075, 5636, 5077, 5634, 5079, 5632, 5081, 5630, 5083, 5628, 5085, 5626, 5087, 5624, 5089, 5622, 5091, 5620, 5093, 5618, 5095, 5616, 5097, 5614, 5099, 5612, 5101, 5610, 5103, 5608, 5105, 5606, 5107, 5604, 5109, 5602, 5111, 5600, 5113, 5598, 5115, 5596, 5117, 5594, 5119, 5592, 5121, 5590, 5123, 5588, 5125, 5586, 5127, 5584, 5129, 5582, 5131, 5580, 5133, 5578, 5135, 5576, 5137, 5574, 5139, 5572, 5141, 5570, 5143, 5568, 5145, 5566, 5147, 5564, 5149, 5562, 5151, 5560, 5153, 5558, 5155, 5556, 5157, 5554, 5159, 5552, 5161, 5550, 5163, 5548, 5165, 5546, 5167, 5544, 5169, 5542, 5171, 5540, 5173, 5538, 5175, 5536, 5177, 5534, 5179, 5532, 5181, 5530, 5183, 5528, 5185, 5526, 5187, 5524, 5189, 5522, 5191, 5520, 5193, 5518, 5195, 5516, 5197, 5514, 5199, 5512, 5201, 5510, 5203, 5508, 5205, 5506, 5207, 5504, 5209, 5502, 5211, 5500, 5213, 5498, 5215, 5496, 5217, 5494, 5219, 5492, 5221, 5490, 5223, 5488, 5225, 5486, 5227, 5484, 5229, 5482, 5231, 5480, 5233, 5478, 5235, 5476, 5237, 5474, 5239, 5472, 5241, 5470, 5243, 5468, 5245, 5466, 5247, 5464, 5249, 5462, 5251, 5460, 5253, 5458, 5255, 5456, 5257, 5454, 5259, 5452, 5261, 5450, 5263, 5448, 5265, 5446, 5267, 5444, 5269, 5442, 5271, 5440, 5273, 5438, 5275, 5436, 5277, 5434, 5279, 5432, 5281, 5430, 5283, 5428, 5285, 5426, 5287, 5424, 5289, 5422, 5291, 5420, 5293, 5418, 5295, 5416, 5297, 5414, 5299, 5412, 5301, 5410, 5303, 5408, 5305, 5406, 5307, 5404, 5309, 5402, 5311, 5400, 5313, 5398, 5315, 5396, 5317, 5394, 5319, 5392, 5321, 5390, 5323, 5388, 5325, 5386, 5327, 5384, 5329, 5382, 5331, 5380, 5333, 5378, 5335, 5376, 5337, 5374, 5339, 5372, 5341, 5370, 5343, 5368, 5345, 5366, 5347, 5364, 5349, 5362, 5351, 5360, 5353, 5358, 5355, 5356, 5357, 5354, 5359, 5352, 5361, 5350, 5363, 5348, 5365, 5346, 5367, 5344, 5369, 5342, 5371, 5340, 5373, 5338, 5375, 5336, 5377, 5334, 5379, 5332, 5381, 5330, 5383, 5328, 5385, 5326, 5387, 5324, 5389, 5322, 5391, 5320, 5393, 5318, 5395, 5316, 5397, 5314, 5399, 5312, 5401, 5310, 5403, 5308, 5405, 5306, 5407, 5304, 5409, 5302, 5411, 5300, 5413, 5298, 5415, 5296, 5417, 5294, 5419, 5292, 5421, 5290, 5423, 5288, 5425, 5286, 5427, 5284, 5429, 5282, 5431, 5280, 5433, 5278, 5435, 5276, 5437, 5274, 5439, 5272, 5441, 5270, 5443, 5268, 5445, 5266, 5447, 5264, 5449, 5262, 5451, 5260, 5453, 5258, 5455, 5256, 5457, 5254, 5459, 5252, 5461, 5250, 5463, 5248, 5465, 5246, 5467, 5244, 5469, 5242, 5471, 5240, 5473, 5238, 5475, 5236, 5477, 5234, 5479, 5232, 5481, 5230, 5483, 5228, 5485, 5226, 5487, 5224, 5489, 5222, 5491, 5220, 5493, 5218, 5495, 5216, 5497, 5214, 5499, 5212, 5501, 5210, 5503, 5208, 5505, 5206, 5507, 5204, 5509, 5202, 5511, 5200, 5513, 5198, 5515, 5196, 5517, 5194, 5519, 5192, 5521, 5190, 5523, 5188, 5525, 5186, 5527, 5184, 5529, 5182, 5531, 5180, 5533, 5178, 5535, 5176, 5537, 5174, 5539, 5172, 5541, 5170, 5543, 5168, 5545, 5166, 5547, 5164, 5549, 5162, 5551, 5160, 5553, 5158, 5555, 5156, 5557, 5154, 5559, 5152, 5561, 5150, 5563, 5148, 5565, 5146, 5567, 5144, 5569, 5142, 5571, 5140, 5573, 5138, 5575, 5136, 5577, 5134, 5579, 5132, 5581, 5130, 5583, 5128, 5585, 5126, 5587, 5124, 5589, 5122, 5591, 5120, 5593, 5118, 5595, 5116, 5597, 5114, 5599, 5112, 5601, 5110, 5603, 5108, 5605, 5106, 5607, 5104, 5609, 5102, 5611, 5100, 5613, 5098, 5615, 5096, 5617, 5094, 5619, 5092, 5621, 5090, 5623, 5088, 5625, 5086, 5627, 5084, 5629, 5082, 5631, 5080, 5633, 5078, 5635, 5076, 5637, 5074, 5639, 5072, 5641, 5070, 5643, 5068, 5645, 5066, 5647, 5064, 5649, 5062, 5651, 5060, 5653, 5058, 5655, 5056, 5657, 5054, 5659, 5052, 5661, 5050, 5663, 5048, 5665, 5046, 5667, 5044, 5669, 5042, 5671, 5040, 5673, 5038, 5675, 5036, 5677, 5034, 5679, 5032, 5681, 5030, 5683, 5028, 5685, 5026, 5687, 5024, 5689, 5022, 5691, 5020, 5693, 5018, 5695, 5016, 5697, 5014, 5699, 5012, 5701, 5010, 5703, 5008, 5705, 5006, 5707, 5004, 5709, 5002, 5711, 5000, 5713, 4998, 5715, 4996, 5717, 4994, 5719, 4992, 5721, 4990, 5723, 4988, 5725, 4986, 5727, 4984, 5729, 4982, 5731, 4980, 5733, 4978, 5735, 4976, 5737, 4974, 5739, 4972, 5741, 4970, 5743, 4968, 5745, 4966, 5747, 4964, 5749, 4962, 5751, 4960, 5753, 4958, 5755, 4956, 5757, 4954, 5759, 4952, 5761, 4950, 5763, 4948, 5765, 4946, 5767, 4944, 5769, 4942, 5771, 4940, 5773, 4938, 5775, 4936, 5777, 4934, 5779, 4932, 5781, 4930, 5783, 4928, 5785, 4926, 5787, 4924, 5789, 4922, 5791, 4920, 5793, 4918, 5795, 4916, 5797, 4914, 5799, 4912, 5801, 4910, 5803, 4908, 5805, 4906, 5807, 4904, 5809, 4902, 5811, 4900, 5813, 4898, 5815, 4896, 5817, 4894, 5819, 4892, 5821, 4890, 5823, 4888, 5825, 4886, 5827, 4884, 5829, 4882, 5831, 4880, 5833, 4878, 5835, 4876, 5837, 4874, 5839, 4872, 5841, 4870, 5843, 4868, 5845, 4866, 5847, 4864, 5849, 4862, 5851, 4860, 5853, 4858, 5855, 4856, 5857, 4854, 5859, 4852, 5861, 4850, 5863, 4848, 5865, 4846, 5867, 4844, 5869, 4842, 5871, 4840, 5873, 4838, 5875, 4836, 5877, 4834, 5879, 4832, 5881, 4830, 5883, 4828, 5885, 4826, 5887, 4824, 5889, 4822, 5891, 4820, 5893, 4818, 5895, 4816, 5897, 4814, 5899, 4812, 5901, 4810, 5903, 4808, 5905, 4806, 5907, 4804, 5909, 4802, 5911, 4800, 5913, 4798, 5915, 4796, 5917, 4794, 5919, 4792, 5921, 4790, 5923, 4788, 5925, 4786, 5927, 4784, 5929, 4782, 5931, 4780, 5933, 4778, 5935, 4776, 5937, 4774, 5939, 4772, 5941, 4770, 5943, 4768, 5945, 4766, 5947, 4764, 5949, 4762, 5951, 4760, 5953, 4758, 5955, 4756, 5957, 4754, 5959, 4752, 5961, 4750, 5963, 4748, 5965, 4746, 5967, 4744, 5969, 4742, 5971, 4740, 5973, 4738, 5975, 4736, 5977, 4734, 5979, 4732, 5981, 4730, 5983, 4728, 5985, 4726, 5987, 4724, 5989, 4722, 5991, 4720, 5993, 4718, 5995, 4716, 5997, 4714, 5999, 4712, 6001, 4710, 6003, 4708, 6005, 4706, 6007, 4704, 6009, 4702, 6011, 4700, 6013, 4698, 6015, 4696, 6017, 4694, 6019, 4692, 6021, 4690, 6023, 4688, 6025, 4686, 6027, 4684, 6029, 4682, 6031, 4680, 6033, 4678, 6035, 4676, 6037, 4674, 6039, 4672, 6041, 4670, 6043, 4668, 6045, 4666, 6047, 4664, 6049, 4662, 6051, 4660, 6053, 4658, 6055, 4656, 6057, 4654, 6059, 4652, 6061, 4650, 6063, 4648, 6065, 4646, 6067, 4644, 6069, 4642, 6071, 4640, 6073, 4638, 6075, 4636, 6077, 4634, 6079, 4632, 6081, 4630, 6083, 4628, 6085, 4626, 6087, 4624, 6089, 4622, 6091, 4620, 6093, 4618, 6095, 4616, 6097, 4614, 6099, 4612, 6101, 4610, 6103, 4608, 6105, 4606, 6107, 4604, 6109, 4602, 6111, 4600, 6113, 4598, 6115, 4596, 6117, 4594, 6119, 4592, 6121, 4590, 6123, 4588, 6125, 4586, 6127, 4584, 6129, 4582, 6131, 4580, 6133, 4578, 6135, 4576, 6137, 4574, 6139, 4572, 6141, 4570, 6143, 4568, 6145, 4566, 6147, 4564, 6149, 4562, 6151, 4560, 6153, 4558, 6155, 4556, 6157, 4554, 6159, 4552, 6161, 4550, 6163, 4548, 6165, 4546, 6167, 4544, 6169, 4542, 6171, 4540, 6173, 4538, 6175, 4536, 6177, 4534, 6179, 4532, 6181, 4530, 6183, 4528, 6185, 4526, 6187, 4524, 6189, 4522, 6191, 4520, 6193, 4518, 6195, 4516, 6197, 4514, 6199, 4512, 6201, 4510, 6203, 4508, 6205, 4506, 6207, 4504, 6209, 4502, 6211, 4500, 6213, 4498, 6215, 4496, 6217, 4494, 6219, 4492, 6221, 4490, 6223, 4488, 6225, 4486, 6227, 4484, 6229, 4482, 6231, 4480, 6233, 4478, 6235, 4476, 6237, 4474, 6239, 4472, 6241, 4470, 6243, 4468, 6245, 4466, 6247, 4464, 6249, 4462, 6251, 4460, 6253, 4458, 6255, 4456, 6257, 4454, 6259, 4452, 6261, 4450, 6263, 4448, 6265, 4446, 6267, 4444, 6269, 4442, 6271, 4440, 6273, 4438, 6275, 4436, 6277, 4434, 6279, 4432, 6281, 4430, 6283, 4428, 6285, 4426, 6287, 4424, 6289, 4422, 6291, 4420, 6293, 4418, 6295, 4416, 6297, 4414, 6299, 4412, 6301, 4410, 6303, 4408, 6305, 4406, 6307, 4404, 6309, 4402, 6311, 4400, 6313, 4398, 6315, 4396, 6317, 4394, 6319, 4392, 6321, 4390, 6323, 4388, 6325, 4386, 6327, 4384, 6329, 4382, 6331, 4380, 6333, 4378, 6335, 4376, 6337, 4374, 6339, 4372, 6341, 4370, 6343, 4368, 6345, 4366, 6347, 4364, 6349, 4362, 6351, 4360, 6353, 4358, 6355, 4356, 6357, 4354, 6359, 4352, 6361, 4350, 6363, 4348, 6365, 4346, 6367, 4344, 6369, 4342, 6371, 4340, 6373, 4338, 6375, 4336, 6377, 4334, 6379, 4332, 6381, 4330, 6383, 4328, 6385, 4326, 6387, 4324, 6389, 4322, 6391, 4320, 6393, 4318, 6395, 4316, 6397, 4314, 6399, 4312, 6401, 4310, 6403, 4308, 6405, 4306, 6407, 4304, 6409, 4302, 6411, 4300, 6413, 4298, 6415, 4296, 6417, 4294, 6419, 4292, 6421, 4290, 6423, 4288, 6425, 4286, 6427, 4284, 6429, 4282, 6431, 4280, 6433, 4278, 6435, 4276, 6437, 4274, 6439, 4272, 6441, 4270, 6443, 4268, 6445, 4266, 6447, 4264, 6449, 4262, 6451, 4260, 6453, 4258, 6455, 4256, 6457, 4254, 6459, 4252, 6461, 4250, 6463, 4248, 6465, 4246, 6467, 4244, 6469, 4242, 6471, 4240, 6473, 4238, 6475, 4236, 6477, 4234, 6479, 4232, 6481, 4230, 6483, 4228, 6485, 4226, 6487, 4224, 6489, 4222, 6491, 4220, 6493, 4218, 6495, 4216, 6497, 4214, 6499, 4212, 6501, 4210, 6503, 4208, 6505, 4206, 6507, 4204, 6509, 4202, 6511, 4200, 6513, 4198, 6515, 4196, 6517, 4194, 6519, 4192, 6521, 4190, 6523, 4188, 6525, 4186, 6527, 4184, 6529, 4182, 6531, 4180, 6533, 4178, 6535, 4176, 6537, 4174, 6539, 4172, 6541, 4170, 6543, 4168, 6545, 4166, 6547, 4164, 6549, 4162, 6551, 4160, 6553, 4158, 6555, 4156, 6557, 4154, 6559, 4152, 6561, 4150, 6563, 4148, 6565, 4146, 6567, 4144, 6569, 4142, 6571, 4140, 6573, 4138, 6575, 4136, 6577, 4134, 6579, 4132, 6581, 4130, 6583, 4128, 6585, 4126, 6587, 4124, 6589, 4122, 6591, 4120, 6593, 4118, 6595, 4116, 6597, 4114, 6599, 4112, 6601, 4110, 6603, 4108, 6605, 4106, 6607, 4104, 6609, 4102, 6611, 4100, 6613, 4098, 6615, 4096, 6617, 4094, 6619, 4092, 6621, 4090, 6623, 4088, 6625, 4086, 6627, 4084, 6629, 4082, 6631, 4080, 6633, 4078, 6635, 4076, 6637, 4074, 6639, 4072, 6641, 4070, 6643, 4068, 6645, 4066, 6647, 4064, 6649, 4062, 6651, 4060, 6653, 4058, 6655, 4056, 6657, 4054, 6659, 4052, 6661, 4050, 6663, 4048, 6665, 4046, 6667, 4044, 6669, 4042, 6671, 4040, 6673, 4038, 6675, 4036, 6677, 4034, 6679, 4032, 6681, 4030, 6683, 4028, 6685, 4026, 6687, 4024, 6689, 4022, 6691, 4020, 6693, 4018, 6695, 4016, 6697, 4014, 6699, 4012, 6701, 4010, 6703, 4008, 6705, 4006, 6707, 4004, 6709, 4002, 6711, 4000, 6713, 3998, 6715, 3996, 6717, 3994, 6719, 3992, 6721, 3990, 6723, 3988, 6725, 3986, 6727, 3984, 6729, 3982, 6731, 3980, 6733, 3978, 6735, 3976, 6737, 3974, 6739, 3972, 6741, 3970, 6743, 3968, 6745, 3966, 6747, 3964, 6749, 3962, 6751, 3960, 6753, 3958, 6755, 3956, 6757, 3954, 6759, 3952, 6761, 3950, 6763, 3948, 6765, 3946, 6767, 3944, 6769, 3942, 6771, 3940, 6773, 3938, 6775, 3936, 6777, 3934, 6779, 3932, 6781, 3930, 6783, 3928, 6785, 3926, 6787, 3924, 6789, 3922, 6791, 3920, 6793, 3918, 6795, 3916, 6797, 3914, 6799, 3912, 6801, 3910, 6803, 3908, 6805, 3906, 6807, 3904, 6809, 3902, 6811, 3900, 6813, 3898, 6815, 3896, 6817, 3894, 6819, 3892, 6821, 3890, 6823, 3888, 6825, 3886, 6827, 3884, 6829, 3882, 6831, 3880, 6833, 3878, 6835, 3876, 6837, 3874, 6839, 3872, 6841, 3870, 6843, 3868, 6845, 3866, 6847, 3864, 6849, 3862, 6851, 3860, 6853, 3858, 6855, 3856, 6857, 3854, 6859, 3852, 6861, 3850, 6863, 3848, 6865, 3846, 6867, 3844, 6869, 3842, 6871, 3840, 6873, 3838, 6875, 3836, 6877, 3834, 6879, 3832, 6881, 3830, 6883, 3828, 6885, 3826, 6887, 3824, 6889, 3822, 6891, 3820, 6893, 3818, 6895, 3816, 6897, 3814, 6899, 3812, 6901, 3810, 6903, 3808, 6905, 3806, 6907, 3804, 6909, 3802, 6911, 3800, 6913, 3798, 6915, 3796, 6917, 3794, 6919, 3792, 6921, 3790, 6923, 3788, 6925, 3786, 6927, 3784, 6929, 3782, 6931, 3780, 6933, 3778, 6935, 3776, 6937, 3774, 6939, 3772, 6941, 3770, 6943, 3768, 6945, 3766, 6947, 3764, 6949, 3762, 6951, 3760, 6953, 3758, 6955, 3756, 6957, 3754, 6959, 3752, 6961, 3750, 6963, 3748, 6965, 3746, 6967, 3744, 6969, 3742, 6971, 3740, 6973, 3738, 6975, 3736, 6977, 3734, 6979, 3732, 6981, 3730, 6983, 3728, 6985, 3726, 6987, 3724, 6989, 3722, 6991, 3720, 6993, 3718, 6995, 3716, 6997, 3714, 6999, 3712, 7001, 3710, 7003, 3708, 7005, 3706, 7007, 3704, 7009, 3702, 7011, 3700, 7013, 3698, 7015, 3696, 7017, 3694, 7019, 3692, 7021, 3690, 7023, 3688, 7025, 3686, 7027, 3684, 7029, 3682, 7031, 3680, 7033, 3678, 7035, 3676, 7037, 3674, 7039, 3672, 7041, 3670, 7043, 3668, 7045, 3666, 7047, 3664, 7049, 3662, 7051, 3660, 7053, 3658, 7055, 3656, 7057, 3654, 7059, 3652, 7061, 3650, 7063, 3648, 7065, 3646, 7067, 3644, 7069, 3642, 7071, 3640, 7073, 3638, 7075, 3636, 7077, 3634, 7079, 3632, 7081, 3630, 7083, 3628, 7085, 3626, 7087, 3624, 7089, 3622, 7091, 3620, 7093, 3618, 7095, 3616, 7097, 3614, 7099, 3612, 7101, 3610, 7103, 3608, 7105, 3606, 7107, 3604, 7109, 3602, 7111, 3600, 7113, 3598, 7115, 3596, 7117, 3594, 7119, 3592, 7121, 3590, 7123, 3588, 7125, 3586, 7127, 3584, 7129, 3582, 7131, 3580, 7133, 3578, 7135, 3576, 7137, 3574, 7139, 3572, 7141, 3570, 7143, 3568, 7145, 3566, 7147, 3564, 7149, 3562, 7151, 3560, 7153, 3558, 7155, 3556, 7157, 3554, 7159, 3552, 7161, 3550, 7163, 3548, 7165, 3546, 7167, 3544, 7169, 3542, 7171, 3540, 7173, 3538, 7175, 3536, 7177, 3534, 7179, 3532, 7181, 3530, 7183, 3528, 7185, 3526, 7187, 3524, 7189, 3522, 7191, 3520, 7193, 3518, 7195, 3516, 7197, 3514, 7199, 3512, 7201, 3510, 7203, 3508, 7205, 3506, 7207, 3504, 7209, 3502, 7211, 3500, 7213, 3498, 7215, 3496, 7217, 3494, 7219, 3492, 7221, 3490, 7223, 3488, 7225, 3486, 7227, 3484, 7229, 3482, 7231, 3480, 7233, 3478, 7235, 3476, 7237, 3474, 7239, 3472, 7241, 3470, 7243, 3468, 7245, 3466, 7247, 3464, 7249, 3462, 7251, 3460, 7253, 3458, 7255, 3456, 7257, 3454, 7259, 3452, 7261, 3450, 7263, 3448, 7265, 3446, 7267, 3444, 7269, 3442, 7271, 3440, 7273, 3438, 7275, 3436, 7277, 3434, 7279, 3432, 7281, 3430, 7283, 3428, 7285, 3426, 7287, 3424, 7289, 3422, 7291, 3420, 7293, 3418, 7295, 3416, 7297, 3414, 7299, 3412, 7301, 3410, 7303, 3408, 7305, 3406, 7307, 3404, 7309, 3402, 7311, 3400, 7313, 3398, 7315, 3396, 7317, 3394, 7319, 3392, 7321, 3390, 7323, 3388, 7325, 3386, 7327, 3384, 7329, 3382, 7331, 3380, 7333, 3378, 7335, 3376, 7337, 3374, 7339, 3372, 7341, 3370, 7343, 3368, 7345, 3366, 7347, 3364, 7349, 3362, 7351, 3360, 7353, 3358, 7355, 3356, 7357, 3354, 7359, 3352, 7361, 3350, 7363, 3348, 7365, 3346, 7367, 3344, 7369, 3342, 7371, 3340, 7373, 3338, 7375, 3336, 7377, 3334, 7379, 3332, 7381, 3330, 7383, 3328, 7385, 3326, 7387, 3324, 7389, 3322, 7391, 3320, 7393, 3318, 7395, 3316, 7397, 3314, 7399, 3312, 7401, 3310, 7403, 3308, 7405, 3306, 7407, 3304, 7409, 3302, 7411, 3300, 7413, 3298, 7415, 3296, 7417, 3294, 7419, 3292, 7421, 3290, 7423, 3288, 7425, 3286, 7427, 3284, 7429, 3282, 7431, 3280, 7433, 3278, 7435, 3276, 7437, 3274, 7439, 3272, 7441, 3270, 7443, 3268, 7445, 3266, 7447, 3264, 7449, 3262, 7451, 3260, 7453, 3258, 7455, 3256, 7457, 3254, 7459, 3252, 7461, 3250, 7463, 3248, 7465, 3246, 7467, 3244, 7469, 3242, 7471, 3240, 7473, 3238, 7475, 3236, 7477, 3234, 7479, 3232, 7481, 3230, 7483, 3228, 7485, 3226, 7487, 3224, 7489, 3222, 7491, 3220, 7493, 3218, 7495, 3216, 7497, 3214, 7499, 3212, 7501, 3210, 7503, 3208, 7505, 3206, 7507, 3204, 7509, 3202, 7511, 3200, 7513, 3198, 7515, 3196, 7517, 3194, 7519, 3192, 7521, 3190, 7523, 3188, 7525, 3186, 7527, 3184, 7529, 3182, 7531, 3180, 7533, 3178, 7535, 3176, 7537, 3174, 7539, 3172, 7541, 3170, 7543, 3168, 7545, 3166, 7547, 3164, 7549, 3162, 7551, 3160, 7553, 3158, 7555, 3156, 7557, 3154, 7559, 3152, 7561, 3150, 7563, 3148, 7565, 3146, 7567, 3144, 7569, 3142, 7571, 3140, 7573, 3138, 7575, 3136, 7577, 3134, 7579, 3132, 7581, 3130, 7583, 3128, 7585, 3126, 7587, 3124, 7589, 3122, 7591, 3120, 7593, 3118, 7595, 3116, 7597, 3114, 7599, 3112, 7601, 3110, 7603, 3108, 7605, 3106, 7607, 3104, 7609, 3102, 7611, 3100, 7613, 3098, 7615, 3096, 7617, 3094, 7619, 3092, 7621, 3090, 7623, 3088, 7625, 3086, 7627, 3084, 7629, 3082, 7631, 3080, 7633, 3078, 7635, 3076, 7637, 3074, 7639, 3072, 7641, 3070, 7643, 3068, 7645, 3066, 7647, 3064, 7649, 3062, 7651, 3060, 7653, 3058, 7655, 3056, 7657, 3054, 7659, 3052, 7661, 3050, 7663, 3048, 7665, 3046, 7667, 3044, 7669, 3042, 7671, 3040, 7673, 3038, 7675, 3036, 7677, 3034, 7679, 3032, 7681, 3030, 7683, 3028, 7685, 3026, 7687, 3024, 7689, 3022, 7691, 3020, 7693, 3018, 7695, 3016, 7697, 3014, 7699, 3012, 7701, 3010, 7703, 3008, 7705, 3006, 7707, 3004, 7709, 3002, 7711, 3000, 7713, 2998, 7715, 2996, 7717, 2994, 7719, 2992, 7721, 2990, 7723, 2988, 7725, 2986, 7727, 2984, 7729, 2982, 7731, 2980, 7733, 2978, 7735, 2976, 7737, 2974, 7739, 2972, 7741, 2970, 7743, 2968, 7745, 2966, 7747, 2964, 7749, 2962, 7751, 2960, 7753, 2958, 7755, 2956, 7757, 2954, 7759, 2952, 7761, 2950, 7763, 2948, 7765, 2946, 7767, 2944, 7769, 2942, 7771, 2940, 7773, 2938, 7775, 2936, 7777, 2934, 7779, 2932, 7781, 2930, 7783, 2928, 7785, 2926, 7787, 2924, 7789, 2922, 7791, 2920, 7793, 2918, 7795, 2916, 7797, 2914, 7799, 2912, 7801, 2910, 7803, 2908, 7805, 2906, 7807, 2904, 7809, 2902, 7811, 2900, 7813, 2898, 7815, 2896, 7817, 2894, 7819, 2892, 7821, 2890, 7823, 2888, 7825, 2886, 7827, 2884, 7829, 2882, 7831, 2880, 7833, 2878, 7835, 2876, 7837, 2874, 7839, 2872, 7841, 2870, 7843, 2868, 7845, 2866, 7847, 2864, 7849, 2862, 7851, 2860, 7853, 2858, 7855, 2856, 7857, 2854, 7859, 2852, 7861, 2850, 7863, 2848, 7865, 2846, 7867, 2844, 7869, 2842, 7871, 2840, 7873, 2838, 7875, 2836, 7877, 2834, 7879, 2832, 7881, 2830, 7883, 2828, 7885, 2826, 7887, 2824, 7889, 2822, 7891, 2820, 7893, 2818, 7895, 2816, 7897, 2814, 7899, 2812, 7901, 2810, 7903, 2808, 7905, 2806, 7907, 2804, 7909, 2802, 7911, 2800, 7913, 2798, 7915, 2796, 7917, 2794, 7919, 2792, 7921, 2790, 7923, 2788, 7925, 2786, 7927, 2784, 7929, 2782, 7931, 2780, 7933, 2778, 7935, 2776, 7937, 2774, 7939, 2772, 7941, 2770, 7943, 2768, 7945, 2766, 7947, 2764, 7949, 2762, 7951, 2760, 7953, 2758, 7955, 2756, 7957, 2754, 7959, 2752, 7961, 2750, 7963, 2748, 7965, 2746, 7967, 2744, 7969, 2742, 7971, 2740, 7973, 2738, 7975, 2736, 7977, 2734, 7979, 2732, 7981, 2730, 7983, 2728, 7985, 2726, 7987, 2724, 7989, 2722, 7991, 2720, 7993, 2718, 7995, 2716, 7997, 2714, 7999, 2712, 8001, 2710, 8003, 2708, 8005, 2706, 8007, 2704, 8009, 2702, 8011, 2700, 8013, 2698, 8015, 2696, 8017, 2694, 8019, 2692, 8021, 2690, 8023, 2688, 8025, 2686, 8027, 2684, 8029, 2682, 8031, 2680, 8033, 2678, 8035, 2676, 8037, 2674, 8039, 2672, 8041, 2670, 8043, 2668, 8045, 2666, 8047, 2664, 8049, 2662, 8051, 2660, 8053, 2658, 8055, 2656, 8057, 2654, 8059, 2652, 8061, 2650, 8063, 2648, 8065, 2646, 8067, 2644, 8069, 2642, 8071, 2640, 8073, 2638, 8075, 2636, 8077, 2634, 8079, 2632, 8081, 2630, 8083, 2628, 8085, 2626, 8087, 2624, 8089, 2622, 8091, 2620, 8093, 2618, 8095, 2616, 8097, 2614, 8099, 2612, 8101, 2610, 8103, 2608, 8105, 2606, 8107, 2604, 8109, 2602, 8111, 2600, 8113, 2598, 8115, 2596, 8117, 2594, 8119, 2592, 8121, 2590, 8123, 2588, 8125, 2586, 8127, 2584, 8129, 2582, 8131, 2580, 8133, 2578, 8135, 2576, 8137, 2574, 8139, 2572, 8141, 2570, 8143, 2568, 8145, 2566, 8147, 2564, 8149, 2562, 8151, 2560, 8153, 2558, 8155, 2556, 8157, 2554, 8159, 2552, 8161, 2550, 8163, 2548, 8165, 2546, 8167, 2544, 8169, 2542, 8171, 2540, 8173, 2538, 8175, 2536, 8177, 2534, 8179, 2532, 8181, 2530, 8183, 2528, 8185, 2526, 8187, 2524, 8189, 2522, 8191, 2520, 8193, 2518, 8195, 2516, 8197, 2514, 8199, 2512, 8201, 2510, 8203, 2508, 8205, 2506, 8207, 2504, 8209, 2502, 8211, 2500, 8213, 2498, 8215, 2496, 8217, 2494, 8219, 2492, 8221, 2490, 8223, 2488, 8225, 2486, 8227, 2484, 8229, 2482, 8231, 2480, 8233, 2478, 8235, 2476, 8237, 2474, 8239, 2472, 8241, 2470, 8243, 2468, 8245, 2466, 8247, 2464, 8249, 2462, 8251, 2460, 8253, 2458, 8255, 2456, 8257, 2454, 8259, 2452, 8261, 2450, 8263, 2448, 8265, 2446, 8267, 2444, 8269, 2442, 8271, 2440, 8273, 2438, 8275, 2436, 8277, 2434, 8279, 2432, 8281, 2430, 8283, 2428, 8285, 2426, 8287, 2424, 8289, 2422, 8291, 2420, 8293, 2418, 8295, 2416, 8297, 2414, 8299, 2412, 8301, 2410, 8303, 2408, 8305, 2406, 8307, 2404, 8309, 2402, 8311, 2400, 8313, 2398, 8315, 2396, 8317, 2394, 8319, 2392, 8321, 2390, 8323, 2388, 8325, 2386, 8327, 2384, 8329, 2382, 8331, 2380, 8333, 2378, 8335, 2376, 8337, 2374, 8339, 2372, 8341, 2370, 8343, 2368, 8345, 2366, 8347, 2364, 8349, 2362, 8351, 2360, 8353, 2358, 8355, 2356, 8357, 2354, 8359, 2352, 8361, 2350, 8363, 2348, 8365, 2346, 8367, 2344, 8369, 2342, 8371, 2340, 8373, 2338, 8375, 2336, 8377, 2334, 8379, 2332, 8381, 2330, 8383, 2328, 8385, 2326, 8387, 2324, 8389, 2322, 8391, 2320, 8393, 2318, 8395, 2316, 8397, 2314, 8399, 2312, 8401, 2310, 8403, 2308, 8405, 2306, 8407, 2304, 8409, 2302, 8411, 2300, 8413, 2298, 8415, 2296, 8417, 2294, 8419, 2292, 8421, 2290, 8423, 2288, 8425, 2286, 8427, 2284, 8429, 2282, 8431, 2280, 8433, 2278, 8435, 2276, 8437, 2274, 8439, 2272, 8441, 2270, 8443, 2268, 8445, 2266, 8447, 2264, 8449, 2262, 8451, 2260, 8453, 2258, 8455, 2256, 8457, 2254, 8459, 2252, 8461, 2250, 8463, 2248, 8465, 2246, 8467, 2244, 8469, 2242, 8471, 2240, 8473, 2238, 8475, 2236, 8477, 2234, 8479, 2232, 8481, 2230, 8483, 2228, 8485, 2226, 8487, 2224, 8489, 2222, 8491, 2220, 8493, 2218, 8495, 2216, 8497, 2214, 8499, 2212, 8501, 2210, 8503, 2208, 8505, 2206, 8507, 2204, 8509, 2202, 8511, 2200, 8513, 2198, 8515, 2196, 8517, 2194, 8519, 2192, 8521, 2190, 8523, 2188, 8525, 2186, 8527, 2184, 8529, 2182, 8531, 2180, 8533, 2178, 8535, 2176, 8537, 2174, 8539, 2172, 8541, 2170, 8543, 2168, 8545, 2166, 8547, 2164, 8549, 2162, 8551, 2160, 8553, 2158, 8555, 2156, 8557, 2154, 8559, 2152, 8561, 2150, 8563, 2148, 8565, 2146, 8567, 2144, 8569, 2142, 8571, 2140, 8573, 2138, 8575, 2136, 8577, 2134, 8579, 2132, 8581, 2130, 8583, 2128, 8585, 2126, 8587, 2124, 8589, 2122, 8591, 2120, 8593, 2118, 8595, 2116, 8597, 2114, 8599, 2112, 8601, 2110, 8603, 2108, 8605, 2106, 8607, 2104, 8609, 2102, 8611, 2100, 8613, 2098, 8615, 2096, 8617, 2094, 8619, 2092, 8621, 2090, 8623, 2088, 8625, 2086, 8627, 2084, 8629, 2082, 8631, 2080, 8633, 2078, 8635, 2076, 8637, 2074, 8639, 2072, 8641, 2070, 8643, 2068, 8645, 2066, 8647, 2064, 8649, 2062, 8651, 2060, 8653, 2058, 8655, 2056, 8657, 2054, 8659, 2052, 8661, 2050, 8663, 2048, 8665, 2046, 8667, 2044, 8669, 2042, 8671, 2040, 8673, 2038, 8675, 2036, 8677, 2034, 8679, 2032, 8681, 2030, 8683, 2028, 8685, 2026, 8687, 2024, 8689, 2022, 8691, 2020, 8693, 2018, 8695, 2016, 8697, 2014, 8699, 2012, 8701, 2010, 8703, 2008, 8705, 2006, 8707, 2004, 8709, 2002, 8711, 2000, 8713, 1998, 8715, 1996, 8717, 1994, 8719, 1992, 8721, 1990, 8723, 1988, 8725, 1986, 8727, 1984, 8729, 1982, 8731, 1980, 8733, 1978, 8735, 1976, 8737, 1974, 8739, 1972, 8741, 1970, 8743, 1968, 8745, 1966, 8747, 1964, 8749, 1962, 8751, 1960, 8753, 1958, 8755, 1956, 8757, 1954, 8759, 1952, 8761, 1950, 8763, 1948, 8765, 1946, 8767, 1944, 8769, 1942, 8771, 1940, 8773, 1938, 8775, 1936, 8777, 1934, 8779, 1932, 8781, 1930, 8783, 1928, 8785, 1926, 8787, 1924, 8789, 1922, 8791, 1920, 8793, 1918, 8795, 1916, 8797, 1914, 8799, 1912, 8801, 1910, 8803, 1908, 8805, 1906, 8807, 1904, 8809, 1902, 8811, 1900, 8813, 1898, 8815, 1896, 8817, 1894, 8819, 1892, 8821, 1890, 8823, 1888, 8825, 1886, 8827, 1884, 8829, 1882, 8831, 1880, 8833, 1878, 8835, 1876, 8837, 1874, 8839, 1872, 8841, 1870, 8843, 1868, 8845, 1866, 8847, 1864, 8849, 1862, 8851, 1860, 8853, 1858, 8855, 1856, 8857, 1854, 8859, 1852, 8861, 1850, 8863, 1848, 8865, 1846, 8867, 1844, 8869, 1842, 8871, 1840, 8873, 1838, 8875, 1836, 8877, 1834, 8879, 1832, 8881, 1830, 8883, 1828, 8885, 1826, 8887, 1824, 8889, 1822, 8891, 1820, 8893, 1818, 8895, 1816, 8897, 1814, 8899, 1812, 8901, 1810, 8903, 1808, 8905, 1806, 8907, 1804, 8909, 1802, 8911, 1800, 8913, 1798, 8915, 1796, 8917, 1794, 8919, 1792, 8921, 1790, 8923, 1788, 8925, 1786, 8927, 1784, 8929, 1782, 8931, 1780, 8933, 1778, 8935, 1776, 8937, 1774, 8939, 1772, 8941, 1770, 8943, 1768, 8945, 1766, 8947, 1764, 8949, 1762, 8951, 1760, 8953, 1758, 8955, 1756, 8957, 1754, 8959, 1752, 8961, 1750, 8963, 1748, 8965, 1746, 8967, 1744, 8969, 1742, 8971, 1740, 8973, 1738, 8975, 1736, 8977, 1734, 8979, 1732, 8981, 1730, 8983, 1728, 8985, 1726, 8987, 1724, 8989, 1722, 8991, 1720, 8993, 1718, 8995, 1716, 8997, 1714, 8999, 1712, 9001, 1710, 9003, 1708, 9005, 1706, 9007, 1704, 9009, 1702, 9011, 1700, 9013, 1698, 9015, 1696, 9017, 1694, 9019, 1692, 9021, 1690, 9023, 1688, 9025, 1686, 9027, 1684, 9029, 1682, 9031, 1680, 9033, 1678, 9035, 1676, 9037, 1674, 9039, 1672, 9041, 1670, 9043, 1668, 9045, 1666, 9047, 1664, 9049, 1662, 9051, 1660, 9053, 1658, 9055, 1656, 9057, 1654, 9059, 1652, 9061, 1650, 9063, 1648, 9065, 1646, 9067, 1644, 9069, 1642, 9071, 1640, 9073, 1638, 9075, 1636, 9077, 1634, 9079, 1632, 9081, 1630, 9083, 1628, 9085, 1626, 9087, 1624, 9089, 1622, 9091, 1620, 9093, 1618, 9095, 1616, 9097, 1614, 9099, 1612, 9101, 1610, 9103, 1608, 9105, 1606, 9107, 1604, 9109, 1602, 9111, 1600, 9113, 1598, 9115, 1596, 9117, 1594, 9119, 1592, 9121, 1590, 9123, 1588, 9125, 1586, 9127, 1584, 9129, 1582, 9131, 1580, 9133, 1578, 9135, 1576, 9137, 1574, 9139, 1572, 9141, 1570, 9143, 1568, 9145, 1566, 9147, 1564, 9149, 1562, 9151, 1560, 9153, 1558, 9155, 1556, 9157, 1554, 9159, 1552, 9161, 1550, 9163, 1548, 9165, 1546, 9167, 1544, 9169, 1542, 9171, 1540, 9173, 1538, 9175, 1536, 9177, 1534, 9179, 1532, 9181, 1530, 9183, 1528, 9185, 1526, 9187, 1524, 9189, 1522, 9191, 1520, 9193, 1518, 9195, 1516, 9197, 1514, 9199, 1512, 9201, 1510, 9203, 1508, 9205, 1506, 9207, 1504, 9209, 1502, 9211, 1500, 9213, 1498, 9215, 1496, 9217, 1494, 9219, 1492, 9221, 1490, 9223, 1488, 9225, 1486, 9227, 1484, 9229, 1482, 9231, 1480, 9233, 1478, 9235, 1476, 9237, 1474, 9239, 1472, 9241, 1470, 9243, 1468, 9245, 1466, 9247, 1464, 9249, 1462, 9251, 1460, 9253, 1458, 9255, 1456, 9257, 1454, 9259, 1452, 9261, 1450, 9263, 1448, 9265, 1446, 9267, 1444, 9269, 1442, 9271, 1440, 9273, 1438, 9275, 1436, 9277, 1434, 9279, 1432, 9281, 1430, 9283, 1428, 9285, 1426, 9287, 1424, 9289, 1422, 9291, 1420, 9293, 1418, 9295, 1416, 9297, 1414, 9299, 1412, 9301, 1410, 9303, 1408, 9305, 1406, 9307, 1404, 9309, 1402, 9311, 1400, 9313, 1398, 9315, 1396, 9317, 1394, 9319, 1392, 9321, 1390, 9323, 1388, 9325, 1386, 9327, 1384, 9329, 1382, 9331, 1380, 9333, 1378, 9335, 1376, 9337, 1374, 9339, 1372, 9341, 1370, 9343, 1368, 9345, 1366, 9347, 1364, 9349, 1362, 9351, 1360, 9353, 1358, 9355, 1356, 9357, 1354, 9359, 1352, 9361, 1350, 9363, 1348, 9365, 1346, 9367, 1344, 9369, 1342, 9371, 1340, 9373, 1338, 9375, 1336, 9377, 1334, 9379, 1332, 9381, 1330, 9383, 1328, 9385, 1326, 9387, 1324, 9389, 1322, 9391, 1320, 9393, 1318, 9395, 1316, 9397, 1314, 9399, 1312, 9401, 1310, 9403, 1308, 9405, 1306, 9407, 1304, 9409, 1302, 9411, 1300, 9413, 1298, 9415, 1296, 9417, 1294, 9419, 1292, 9421, 1290, 9423, 1288, 9425, 1286, 9427, 1284, 9429, 1282, 9431, 1280, 9433, 1278, 9435, 1276, 9437, 1274, 9439, 1272, 9441, 1270, 9443, 1268, 9445, 1266, 9447, 1264, 9449, 1262, 9451, 1260, 9453, 1258, 9455, 1256, 9457, 1254, 9459, 1252, 9461, 1250, 9463, 1248, 9465, 1246, 9467, 1244, 9469, 1242, 9471, 1240, 9473, 1238, 9475, 1236, 9477, 1234, 9479, 1232, 9481, 1230, 9483, 1228, 9485, 1226, 9487, 1224, 9489, 1222, 9491, 1220, 9493, 1218, 9495, 1216, 9497, 1214, 9499, 1212, 9501, 1210, 9503, 1208, 9505, 1206, 9507, 1204, 9509, 1202, 9511, 1200, 9513, 1198, 9515, 1196, 9517, 1194, 9519, 1192, 9521, 1190, 9523, 1188, 9525, 1186, 9527, 1184, 9529, 1182, 9531, 1180, 9533, 1178, 9535, 1176, 9537, 1174, 9539, 1172, 9541, 1170, 9543, 1168, 9545, 1166, 9547, 1164, 9549, 1162, 9551, 1160, 9553, 1158, 9555, 1156, 9557, 1154, 9559, 1152, 9561, 1150, 9563, 1148, 9565, 1146, 9567, 1144, 9569, 1142, 9571, 1140, 9573, 1138, 9575, 1136, 9577, 1134, 9579, 1132, 9581, 1130, 9583, 1128, 9585, 1126, 9587, 1124, 9589, 1122, 9591, 1120, 9593, 1118, 9595, 1116, 9597, 1114, 9599, 1112, 9601, 1110, 9603, 1108, 9605, 1106, 9607, 1104, 9609, 1102, 9611, 1100, 9613, 1098, 9615, 1096, 9617, 1094, 9619, 1092, 9621, 1090, 9623, 1088, 9625, 1086, 9627, 1084, 9629, 1082, 9631, 1080, 9633, 1078, 9635, 1076, 9637, 1074, 9639, 1072, 9641, 1070, 9643, 1068, 9645, 1066, 9647, 1064, 9649, 1062, 9651, 1060, 9653, 1058, 9655, 1056, 9657, 1054, 9659, 1052, 9661, 1050, 9663, 1048, 9665, 1046, 9667, 1044, 9669, 1042, 9671, 1040, 9673, 1038, 9675, 1036, 9677, 1034, 9679, 1032, 9681, 1030, 9683, 1028, 9685, 1026, 9687, 1024, 9689, 1022, 9691, 1020, 9693, 1018, 9695, 1016, 9697, 1014, 9699, 1012, 9701, 1010, 9703, 1008, 9705, 1006, 9707, 1004, 9709, 1002, 9711, 1000, 9713, 998, 9715, 996, 9717, 994, 9719, 992, 9721, 990, 9723, 988, 9725, 986, 9727, 984, 9729, 982, 9731, 980, 9733, 978, 9735, 976, 9737, 974, 9739, 972, 9741, 970, 9743, 968, 9745, 966, 9747, 964, 9749, 962, 9751, 960, 9753, 958, 9755, 956, 9757, 954, 9759, 952, 9761, 950, 9763, 948, 9765, 946, 9767, 944, 9769, 942, 9771, 940, 9773, 938, 9775, 936, 9777, 934, 9779, 932, 9781, 930, 9783, 928, 9785, 926, 9787, 924, 9789, 922, 9791, 920, 9793, 918, 9795, 916, 9797, 914, 9799, 912, 9801, 910, 9803, 908, 9805, 906, 9807, 904, 9809, 902, 9811, 900, 9813, 898, 9815, 896, 9817, 894, 9819, 892, 9821, 890, 9823, 888, 9825, 886, 9827, 884, 9829, 882, 9831, 880, 9833, 878, 9835, 876, 9837, 874, 9839, 872, 9841, 870, 9843, 868, 9845, 866, 9847, 864, 9849, 862, 9851, 860, 9853, 858, 9855, 856, 9857, 854, 9859, 852, 9861, 850, 9863, 848, 9865, 846, 9867, 844, 9869, 842, 9871, 840, 9873, 838, 9875, 836, 9877, 834, 9879, 832, 9881, 830, 9883, 828, 9885, 826, 9887, 824, 9889, 822, 9891, 820, 9893, 818, 9895, 816, 9897, 814, 9899, 812, 9901, 810, 9903, 808, 9905, 806, 9907, 804, 9909, 802, 9911, 800, 9913, 798, 9915, 796, 9917, 794, 9919, 792, 9921, 790, 9923, 788, 9925, 786, 9927, 784, 9929, 782, 9931, 780, 9933, 778, 9935, 776, 9937, 774, 9939, 772, 9941, 770, 9943, 768, 9945, 766, 9947, 764, 9949, 762, 9951, 760, 9953, 758, 9955, 756, 9957, 754, 9959, 752, 9961, 750, 9963, 748, 9965, 746, 9967, 744, 9969, 742, 9971, 740, 9973, 738, 9975, 736, 9977, 734, 9979, 732, 9981, 730, 9983, 728, 9985, 726, 9987, 724, 9989, 722, 9991, 720, 9993, 718, 9995, 716, 9997, 714, 9999, 712, 10001, 710, 10003, 708, 10005, 706, 10007, 704, 10009, 702, 10011, 700, 10013, 698, 10015, 696, 10017, 694, 10019, 692, 10021, 690, 10023, 688, 10025, 686, 10027, 684, 10029, 682, 10031, 680, 10033, 678, 10035, 676, 10037, 674, 10039, 672, 10041, 670, 10043, 668, 10045, 666, 10047, 664, 10049, 662, 10051, 660, 10053, 658, 10055, 656, 10057, 654, 10059, 652, 10061, 650, 10063, 648, 10065, 646, 10067, 644, 10069, 642, 10071, 640, 10073, 638, 10075, 636, 10077, 634, 10079, 632, 10081, 630, 10083, 628, 10085, 626, 10087, 624, 10089, 622, 10091, 620, 10093, 618, 10095, 616, 10097, 614, 10099, 612, 10101, 610, 10103, 608, 10105, 606, 10107, 604, 10109, 602, 10111, 600, 10113, 598, 10115, 596, 10117, 594, 10119, 592, 10121, 590, 10123, 588, 10125, 586, 10127, 584, 10129, 582, 10131, 580, 10133, 578, 10135, 576, 10137, 574, 10139, 572, 10141, 570, 10143, 568, 10145, 566, 10147, 564, 10149, 562, 10151, 560, 10153, 558, 10155, 556, 10157, 554, 10159, 552, 10161, 550, 10163, 548, 10165, 546, 10167, 544, 10169, 542, 10171, 540, 10173, 538, 10175, 536, 10177, 534, 10179, 532, 10181, 530, 10183, 528, 10185, 526, 10187, 524, 10189, 522, 10191, 520, 10193, 518, 10195, 516, 10197, 514, 10199, 512, 10201, 510, 10203, 508, 10205, 506, 10207, 504, 10209, 502, 10211, 500, 10213, 498, 10215, 496, 10217, 494, 10219, 492, 10221, 490, 10223, 488, 10225, 486, 10227, 484, 10229, 482, 10231, 480, 10233, 478, 10235, 476, 10237, 474, 10239, 472, 10241, 470, 10243, 468, 10245, 466, 10247, 464, 10249, 462, 10251, 460, 10253, 458, 10255, 456, 10257, 454, 10259, 452, 10261, 450, 10263, 448, 10265, 446, 10267, 444, 10269, 442, 10271, 440, 10273, 438, 10275, 436, 10277, 434, 10279, 432, 10281, 430, 10283, 428, 10285, 426, 10287, 424, 10289, 422, 10291, 420, 10293, 418, 10295, 416, 10297, 414, 10299, 412, 10301, 410, 10303, 408, 10305, 406, 10307, 404, 10309, 402, 10311, 400, 10313, 398, 10315, 396, 10317, 394, 10319, 392, 10321, 390, 10323, 388, 10325, 386, 10327, 384, 10329, 382, 10331, 380, 10333, 378, 10335, 376, 10337, 374, 10339, 372, 10341, 370, 10343, 368, 10345, 366, 10347, 364, 10349, 362, 10351, 360, 10353, 358, 10355, 356, 10357, 354, 10359, 352, 10361, 350, 10363, 348, 10365, 346, 10367, 344, 10369, 342, 10371, 340, 10373, 338, 10375, 336, 10377, 334, 10379, 332, 10381, 330, 10383, 328, 10385, 326, 10387, 324, 10389, 322, 10391, 320, 10393, 318, 10395, 316, 10397, 314, 10399, 312, 10401, 310, 10403, 308, 10405, 306, 10407, 304, 10409, 302, 10411, 300, 10413, 298, 10415, 296, 10417, 294, 10419, 292, 10421, 290, 10423, 288, 10425, 286, 10427, 284, 10429, 282, 10431, 280, 10433, 278, 10435, 276, 10437, 274, 10439, 272, 10441, 270, 10443, 268, 10445, 266, 10447, 264, 10449, 262, 10451, 260, 10453, 258, 10455, 256, 10457, 254, 10459, 252, 10461, 250, 10463, 248, 10465, 246, 10467, 244, 10469, 242, 10471, 240, 10473, 238, 10475, 236, 10477, 234, 10479, 232, 10481, 230, 10483, 228, 10485, 226, 10487, 224, 10489, 222, 10491, 220, 10493, 218, 10495, 216, 10497, 214, 10499, 212, 10501, 210, 10503, 208, 10505, 206, 10507, 204, 10509, 202, 10511, 200, 10513, 198, 10515, 196, 10517, 194, 10519, 192, 10521, 190, 10523, 188, 10525, 186, 10527, 184, 10529, 182, 10531, 180, 10533, 178, 10535, 176, 10537, 174, 10539, 172, 10541, 170, 10543, 168, 10545, 166, 10547, 164, 10549, 162, 10551, 160, 10553, 158, 10555, 156, 10557, 154, 10559, 152, 10561, 150, 10563, 148, 10565, 146, 10567, 144, 10569, 142, 10571, 140, 10573, 138, 10575, 136, 10577, 134, 10579, 132, 10581, 130, 10583, 128, 10585, 126, 10587, 124, 10589, 122, 10591, 120, 10593, 118, 10595, 116, 10597, 114, 10599, 112, 10601, 110, 10603, 108, 10605, 106, 10607, 104, 10609, 102, 10611, 100, 10613, 98, 10615, 96, 10617, 94, 10619, 92, 10621, 90, 10623, 88, 10625, 86, 10627, 84, 10629, 82, 10631, 80, 10633, 78, 10635, 76, 10637, 74, 10639, 72, 10641, 70, 10643, 68, 10645, 66, 10647, 64, 10649, 62, 10651, 60, 10653, 58, 10655, 56, 10657, 54, 10659, 52, 10661, 50, 10663, 48, 10665, 46, 10667, 44, 10669, 42, 10671, 40, 10673, 38, 10675, 36, 10677, 34, 10679, 32, 10681, 30, 10683, 28, 10685, 26, 10687, 24, 10689, 22, 10691, 20, 10693, 18, 10695, 16, 10697, 14, 10699, 12, 10701, 10, 10703, 8, 10705, 6, 10707, 4, 10709, 2, 10711]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s8/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s8/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 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-s8/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b4b5099b48a769f6ac0836be5abd3b69b5663e45 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 10712, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s8/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s8/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s9/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l6-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s9/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bc9ec44bf226d9d07eb20478da9905e764d5e276 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 22966, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s9/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..54c3336a07eef43b4e96406f08afab97e6e06d52 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [22966, 1, 22964, 3, 22962, 5, 22960, 7, 22958, 9, 22956, 11, 22954, 13, 22952, 15, 22950, 17, 22948, 19, 22946, 21, 22944, 23, 22942, 25, 22940, 27, 22938, 29, 22936, 31, 22934, 33, 22932, 35, 22930, 37, 22928, 39, 22926, 41, 22924, 43, 22922, 45, 22920, 47, 22918, 49, 22916, 51, 22914, 53, 22912, 55, 22910, 57, 22908, 59, 22906, 61, 22904, 63, 22902, 65, 22900, 67, 22898, 69, 22896, 71, 22894, 73, 22892, 75, 22890, 77, 22888, 79, 22886, 81, 22884, 83, 22882, 85, 22880, 87, 22878, 89, 22876, 91, 22874, 93, 22872, 95, 22870, 97, 22868, 99, 22866, 101, 22864, 103, 22862, 105, 22860, 107, 22858, 109, 22856, 111, 22854, 113, 22852, 115, 22850, 117, 22848, 119, 22846, 121, 22844, 123, 22842, 125, 22840, 127, 22838, 129, 22836, 131, 22834, 133, 22832, 135, 22830, 137, 22828, 139, 22826, 141, 22824, 143, 22822, 145, 22820, 147, 22818, 149, 22816, 151, 22814, 153, 22812, 155, 22810, 157, 22808, 159, 22806, 161, 22804, 163, 22802, 165, 22800, 167, 22798, 169, 22796, 171, 22794, 173, 22792, 175, 22790, 177, 22788, 179, 22786, 181, 22784, 183, 22782, 185, 22780, 187, 22778, 189, 22776, 191, 22774, 193, 22772, 195, 22770, 197, 22768, 199, 22766, 201, 22764, 203, 22762, 205, 22760, 207, 22758, 209, 22756, 211, 22754, 213, 22752, 215, 22750, 217, 22748, 219, 22746, 221, 22744, 223, 22742, 225, 22740, 227, 22738, 229, 22736, 231, 22734, 233, 22732, 235, 22730, 237, 22728, 239, 22726, 241, 22724, 243, 22722, 245, 22720, 247, 22718, 249, 22716, 251, 22714, 253, 22712, 255, 22710, 257, 22708, 259, 22706, 261, 22704, 263, 22702, 265, 22700, 267, 22698, 269, 22696, 271, 22694, 273, 22692, 275, 22690, 277, 22688, 279, 22686, 281, 22684, 283, 22682, 285, 22680, 287, 22678, 289, 22676, 291, 22674, 293, 22672, 295, 22670, 297, 22668, 299, 22666, 301, 22664, 303, 22662, 305, 22660, 307, 22658, 309, 22656, 311, 22654, 313, 22652, 315, 22650, 317, 22648, 319, 22646, 321, 22644, 323, 22642, 325, 22640, 327, 22638, 329, 22636, 331, 22634, 333, 22632, 335, 22630, 337, 22628, 339, 22626, 341, 22624, 343, 22622, 345, 22620, 347, 22618, 349, 22616, 351, 22614, 353, 22612, 355, 22610, 357, 22608, 359, 22606, 361, 22604, 363, 22602, 365, 22600, 367, 22598, 369, 22596, 371, 22594, 373, 22592, 375, 22590, 377, 22588, 379, 22586, 381, 22584, 383, 22582, 385, 22580, 387, 22578, 389, 22576, 391, 22574, 393, 22572, 395, 22570, 397, 22568, 399, 22566, 401, 22564, 403, 22562, 405, 22560, 407, 22558, 409, 22556, 411, 22554, 413, 22552, 415, 22550, 417, 22548, 419, 22546, 421, 22544, 423, 22542, 425, 22540, 427, 22538, 429, 22536, 431, 22534, 433, 22532, 435, 22530, 437, 22528, 439, 22526, 441, 22524, 443, 22522, 445, 22520, 447, 22518, 449, 22516, 451, 22514, 453, 22512, 455, 22510, 457, 22508, 459, 22506, 461, 22504, 463, 22502, 465, 22500, 467, 22498, 469, 22496, 471, 22494, 473, 22492, 475, 22490, 477, 22488, 479, 22486, 481, 22484, 483, 22482, 485, 22480, 487, 22478, 489, 22476, 491, 22474, 493, 22472, 495, 22470, 497, 22468, 499, 22466, 501, 22464, 503, 22462, 505, 22460, 507, 22458, 509, 22456, 511, 22454, 513, 22452, 515, 22450, 517, 22448, 519, 22446, 521, 22444, 523, 22442, 525, 22440, 527, 22438, 529, 22436, 531, 22434, 533, 22432, 535, 22430, 537, 22428, 539, 22426, 541, 22424, 543, 22422, 545, 22420, 547, 22418, 549, 22416, 551, 22414, 553, 22412, 555, 22410, 557, 22408, 559, 22406, 561, 22404, 563, 22402, 565, 22400, 567, 22398, 569, 22396, 571, 22394, 573, 22392, 575, 22390, 577, 22388, 579, 22386, 581, 22384, 583, 22382, 585, 22380, 587, 22378, 589, 22376, 591, 22374, 593, 22372, 595, 22370, 597, 22368, 599, 22366, 601, 22364, 603, 22362, 605, 22360, 607, 22358, 609, 22356, 611, 22354, 613, 22352, 615, 22350, 617, 22348, 619, 22346, 621, 22344, 623, 22342, 625, 22340, 627, 22338, 629, 22336, 631, 22334, 633, 22332, 635, 22330, 637, 22328, 639, 22326, 641, 22324, 643, 22322, 645, 22320, 647, 22318, 649, 22316, 651, 22314, 653, 22312, 655, 22310, 657, 22308, 659, 22306, 661, 22304, 663, 22302, 665, 22300, 667, 22298, 669, 22296, 671, 22294, 673, 22292, 675, 22290, 677, 22288, 679, 22286, 681, 22284, 683, 22282, 685, 22280, 687, 22278, 689, 22276, 691, 22274, 693, 22272, 695, 22270, 697, 22268, 699, 22266, 701, 22264, 703, 22262, 705, 22260, 707, 22258, 709, 22256, 711, 22254, 713, 22252, 715, 22250, 717, 22248, 719, 22246, 721, 22244, 723, 22242, 725, 22240, 727, 22238, 729, 22236, 731, 22234, 733, 22232, 735, 22230, 737, 22228, 739, 22226, 741, 22224, 743, 22222, 745, 22220, 747, 22218, 749, 22216, 751, 22214, 753, 22212, 755, 22210, 757, 22208, 759, 22206, 761, 22204, 763, 22202, 765, 22200, 767, 22198, 769, 22196, 771, 22194, 773, 22192, 775, 22190, 777, 22188, 779, 22186, 781, 22184, 783, 22182, 785, 22180, 787, 22178, 789, 22176, 791, 22174, 793, 22172, 795, 22170, 797, 22168, 799, 22166, 801, 22164, 803, 22162, 805, 22160, 807, 22158, 809, 22156, 811, 22154, 813, 22152, 815, 22150, 817, 22148, 819, 22146, 821, 22144, 823, 22142, 825, 22140, 827, 22138, 829, 22136, 831, 22134, 833, 22132, 835, 22130, 837, 22128, 839, 22126, 841, 22124, 843, 22122, 845, 22120, 847, 22118, 849, 22116, 851, 22114, 853, 22112, 855, 22110, 857, 22108, 859, 22106, 861, 22104, 863, 22102, 865, 22100, 867, 22098, 869, 22096, 871, 22094, 873, 22092, 875, 22090, 877, 22088, 879, 22086, 881, 22084, 883, 22082, 885, 22080, 887, 22078, 889, 22076, 891, 22074, 893, 22072, 895, 22070, 897, 22068, 899, 22066, 901, 22064, 903, 22062, 905, 22060, 907, 22058, 909, 22056, 911, 22054, 913, 22052, 915, 22050, 917, 22048, 919, 22046, 921, 22044, 923, 22042, 925, 22040, 927, 22038, 929, 22036, 931, 22034, 933, 22032, 935, 22030, 937, 22028, 939, 22026, 941, 22024, 943, 22022, 945, 22020, 947, 22018, 949, 22016, 951, 22014, 953, 22012, 955, 22010, 957, 22008, 959, 22006, 961, 22004, 963, 22002, 965, 22000, 967, 21998, 969, 21996, 971, 21994, 973, 21992, 975, 21990, 977, 21988, 979, 21986, 981, 21984, 983, 21982, 985, 21980, 987, 21978, 989, 21976, 991, 21974, 993, 21972, 995, 21970, 997, 21968, 999, 21966, 1001, 21964, 1003, 21962, 1005, 21960, 1007, 21958, 1009, 21956, 1011, 21954, 1013, 21952, 1015, 21950, 1017, 21948, 1019, 21946, 1021, 21944, 1023, 21942, 1025, 21940, 1027, 21938, 1029, 21936, 1031, 21934, 1033, 21932, 1035, 21930, 1037, 21928, 1039, 21926, 1041, 21924, 1043, 21922, 1045, 21920, 1047, 21918, 1049, 21916, 1051, 21914, 1053, 21912, 1055, 21910, 1057, 21908, 1059, 21906, 1061, 21904, 1063, 21902, 1065, 21900, 1067, 21898, 1069, 21896, 1071, 21894, 1073, 21892, 1075, 21890, 1077, 21888, 1079, 21886, 1081, 21884, 1083, 21882, 1085, 21880, 1087, 21878, 1089, 21876, 1091, 21874, 1093, 21872, 1095, 21870, 1097, 21868, 1099, 21866, 1101, 21864, 1103, 21862, 1105, 21860, 1107, 21858, 1109, 21856, 1111, 21854, 1113, 21852, 1115, 21850, 1117, 21848, 1119, 21846, 1121, 21844, 1123, 21842, 1125, 21840, 1127, 21838, 1129, 21836, 1131, 21834, 1133, 21832, 1135, 21830, 1137, 21828, 1139, 21826, 1141, 21824, 1143, 21822, 1145, 21820, 1147, 21818, 1149, 21816, 1151, 21814, 1153, 21812, 1155, 21810, 1157, 21808, 1159, 21806, 1161, 21804, 1163, 21802, 1165, 21800, 1167, 21798, 1169, 21796, 1171, 21794, 1173, 21792, 1175, 21790, 1177, 21788, 1179, 21786, 1181, 21784, 1183, 21782, 1185, 21780, 1187, 21778, 1189, 21776, 1191, 21774, 1193, 21772, 1195, 21770, 1197, 21768, 1199, 21766, 1201, 21764, 1203, 21762, 1205, 21760, 1207, 21758, 1209, 21756, 1211, 21754, 1213, 21752, 1215, 21750, 1217, 21748, 1219, 21746, 1221, 21744, 1223, 21742, 1225, 21740, 1227, 21738, 1229, 21736, 1231, 21734, 1233, 21732, 1235, 21730, 1237, 21728, 1239, 21726, 1241, 21724, 1243, 21722, 1245, 21720, 1247, 21718, 1249, 21716, 1251, 21714, 1253, 21712, 1255, 21710, 1257, 21708, 1259, 21706, 1261, 21704, 1263, 21702, 1265, 21700, 1267, 21698, 1269, 21696, 1271, 21694, 1273, 21692, 1275, 21690, 1277, 21688, 1279, 21686, 1281, 21684, 1283, 21682, 1285, 21680, 1287, 21678, 1289, 21676, 1291, 21674, 1293, 21672, 1295, 21670, 1297, 21668, 1299, 21666, 1301, 21664, 1303, 21662, 1305, 21660, 1307, 21658, 1309, 21656, 1311, 21654, 1313, 21652, 1315, 21650, 1317, 21648, 1319, 21646, 1321, 21644, 1323, 21642, 1325, 21640, 1327, 21638, 1329, 21636, 1331, 21634, 1333, 21632, 1335, 21630, 1337, 21628, 1339, 21626, 1341, 21624, 1343, 21622, 1345, 21620, 1347, 21618, 1349, 21616, 1351, 21614, 1353, 21612, 1355, 21610, 1357, 21608, 1359, 21606, 1361, 21604, 1363, 21602, 1365, 21600, 1367, 21598, 1369, 21596, 1371, 21594, 1373, 21592, 1375, 21590, 1377, 21588, 1379, 21586, 1381, 21584, 1383, 21582, 1385, 21580, 1387, 21578, 1389, 21576, 1391, 21574, 1393, 21572, 1395, 21570, 1397, 21568, 1399, 21566, 1401, 21564, 1403, 21562, 1405, 21560, 1407, 21558, 1409, 21556, 1411, 21554, 1413, 21552, 1415, 21550, 1417, 21548, 1419, 21546, 1421, 21544, 1423, 21542, 1425, 21540, 1427, 21538, 1429, 21536, 1431, 21534, 1433, 21532, 1435, 21530, 1437, 21528, 1439, 21526, 1441, 21524, 1443, 21522, 1445, 21520, 1447, 21518, 1449, 21516, 1451, 21514, 1453, 21512, 1455, 21510, 1457, 21508, 1459, 21506, 1461, 21504, 1463, 21502, 1465, 21500, 1467, 21498, 1469, 21496, 1471, 21494, 1473, 21492, 1475, 21490, 1477, 21488, 1479, 21486, 1481, 21484, 1483, 21482, 1485, 21480, 1487, 21478, 1489, 21476, 1491, 21474, 1493, 21472, 1495, 21470, 1497, 21468, 1499, 21466, 1501, 21464, 1503, 21462, 1505, 21460, 1507, 21458, 1509, 21456, 1511, 21454, 1513, 21452, 1515, 21450, 1517, 21448, 1519, 21446, 1521, 21444, 1523, 21442, 1525, 21440, 1527, 21438, 1529, 21436, 1531, 21434, 1533, 21432, 1535, 21430, 1537, 21428, 1539, 21426, 1541, 21424, 1543, 21422, 1545, 21420, 1547, 21418, 1549, 21416, 1551, 21414, 1553, 21412, 1555, 21410, 1557, 21408, 1559, 21406, 1561, 21404, 1563, 21402, 1565, 21400, 1567, 21398, 1569, 21396, 1571, 21394, 1573, 21392, 1575, 21390, 1577, 21388, 1579, 21386, 1581, 21384, 1583, 21382, 1585, 21380, 1587, 21378, 1589, 21376, 1591, 21374, 1593, 21372, 1595, 21370, 1597, 21368, 1599, 21366, 1601, 21364, 1603, 21362, 1605, 21360, 1607, 21358, 1609, 21356, 1611, 21354, 1613, 21352, 1615, 21350, 1617, 21348, 1619, 21346, 1621, 21344, 1623, 21342, 1625, 21340, 1627, 21338, 1629, 21336, 1631, 21334, 1633, 21332, 1635, 21330, 1637, 21328, 1639, 21326, 1641, 21324, 1643, 21322, 1645, 21320, 1647, 21318, 1649, 21316, 1651, 21314, 1653, 21312, 1655, 21310, 1657, 21308, 1659, 21306, 1661, 21304, 1663, 21302, 1665, 21300, 1667, 21298, 1669, 21296, 1671, 21294, 1673, 21292, 1675, 21290, 1677, 21288, 1679, 21286, 1681, 21284, 1683, 21282, 1685, 21280, 1687, 21278, 1689, 21276, 1691, 21274, 1693, 21272, 1695, 21270, 1697, 21268, 1699, 21266, 1701, 21264, 1703, 21262, 1705, 21260, 1707, 21258, 1709, 21256, 1711, 21254, 1713, 21252, 1715, 21250, 1717, 21248, 1719, 21246, 1721, 21244, 1723, 21242, 1725, 21240, 1727, 21238, 1729, 21236, 1731, 21234, 1733, 21232, 1735, 21230, 1737, 21228, 1739, 21226, 1741, 21224, 1743, 21222, 1745, 21220, 1747, 21218, 1749, 21216, 1751, 21214, 1753, 21212, 1755, 21210, 1757, 21208, 1759, 21206, 1761, 21204, 1763, 21202, 1765, 21200, 1767, 21198, 1769, 21196, 1771, 21194, 1773, 21192, 1775, 21190, 1777, 21188, 1779, 21186, 1781, 21184, 1783, 21182, 1785, 21180, 1787, 21178, 1789, 21176, 1791, 21174, 1793, 21172, 1795, 21170, 1797, 21168, 1799, 21166, 1801, 21164, 1803, 21162, 1805, 21160, 1807, 21158, 1809, 21156, 1811, 21154, 1813, 21152, 1815, 21150, 1817, 21148, 1819, 21146, 1821, 21144, 1823, 21142, 1825, 21140, 1827, 21138, 1829, 21136, 1831, 21134, 1833, 21132, 1835, 21130, 1837, 21128, 1839, 21126, 1841, 21124, 1843, 21122, 1845, 21120, 1847, 21118, 1849, 21116, 1851, 21114, 1853, 21112, 1855, 21110, 1857, 21108, 1859, 21106, 1861, 21104, 1863, 21102, 1865, 21100, 1867, 21098, 1869, 21096, 1871, 21094, 1873, 21092, 1875, 21090, 1877, 21088, 1879, 21086, 1881, 21084, 1883, 21082, 1885, 21080, 1887, 21078, 1889, 21076, 1891, 21074, 1893, 21072, 1895, 21070, 1897, 21068, 1899, 21066, 1901, 21064, 1903, 21062, 1905, 21060, 1907, 21058, 1909, 21056, 1911, 21054, 1913, 21052, 1915, 21050, 1917, 21048, 1919, 21046, 1921, 21044, 1923, 21042, 1925, 21040, 1927, 21038, 1929, 21036, 1931, 21034, 1933, 21032, 1935, 21030, 1937, 21028, 1939, 21026, 1941, 21024, 1943, 21022, 1945, 21020, 1947, 21018, 1949, 21016, 1951, 21014, 1953, 21012, 1955, 21010, 1957, 21008, 1959, 21006, 1961, 21004, 1963, 21002, 1965, 21000, 1967, 20998, 1969, 20996, 1971, 20994, 1973, 20992, 1975, 20990, 1977, 20988, 1979, 20986, 1981, 20984, 1983, 20982, 1985, 20980, 1987, 20978, 1989, 20976, 1991, 20974, 1993, 20972, 1995, 20970, 1997, 20968, 1999, 20966, 2001, 20964, 2003, 20962, 2005, 20960, 2007, 20958, 2009, 20956, 2011, 20954, 2013, 20952, 2015, 20950, 2017, 20948, 2019, 20946, 2021, 20944, 2023, 20942, 2025, 20940, 2027, 20938, 2029, 20936, 2031, 20934, 2033, 20932, 2035, 20930, 2037, 20928, 2039, 20926, 2041, 20924, 2043, 20922, 2045, 20920, 2047, 20918, 2049, 20916, 2051, 20914, 2053, 20912, 2055, 20910, 2057, 20908, 2059, 20906, 2061, 20904, 2063, 20902, 2065, 20900, 2067, 20898, 2069, 20896, 2071, 20894, 2073, 20892, 2075, 20890, 2077, 20888, 2079, 20886, 2081, 20884, 2083, 20882, 2085, 20880, 2087, 20878, 2089, 20876, 2091, 20874, 2093, 20872, 2095, 20870, 2097, 20868, 2099, 20866, 2101, 20864, 2103, 20862, 2105, 20860, 2107, 20858, 2109, 20856, 2111, 20854, 2113, 20852, 2115, 20850, 2117, 20848, 2119, 20846, 2121, 20844, 2123, 20842, 2125, 20840, 2127, 20838, 2129, 20836, 2131, 20834, 2133, 20832, 2135, 20830, 2137, 20828, 2139, 20826, 2141, 20824, 2143, 20822, 2145, 20820, 2147, 20818, 2149, 20816, 2151, 20814, 2153, 20812, 2155, 20810, 2157, 20808, 2159, 20806, 2161, 20804, 2163, 20802, 2165, 20800, 2167, 20798, 2169, 20796, 2171, 20794, 2173, 20792, 2175, 20790, 2177, 20788, 2179, 20786, 2181, 20784, 2183, 20782, 2185, 20780, 2187, 20778, 2189, 20776, 2191, 20774, 2193, 20772, 2195, 20770, 2197, 20768, 2199, 20766, 2201, 20764, 2203, 20762, 2205, 20760, 2207, 20758, 2209, 20756, 2211, 20754, 2213, 20752, 2215, 20750, 2217, 20748, 2219, 20746, 2221, 20744, 2223, 20742, 2225, 20740, 2227, 20738, 2229, 20736, 2231, 20734, 2233, 20732, 2235, 20730, 2237, 20728, 2239, 20726, 2241, 20724, 2243, 20722, 2245, 20720, 2247, 20718, 2249, 20716, 2251, 20714, 2253, 20712, 2255, 20710, 2257, 20708, 2259, 20706, 2261, 20704, 2263, 20702, 2265, 20700, 2267, 20698, 2269, 20696, 2271, 20694, 2273, 20692, 2275, 20690, 2277, 20688, 2279, 20686, 2281, 20684, 2283, 20682, 2285, 20680, 2287, 20678, 2289, 20676, 2291, 20674, 2293, 20672, 2295, 20670, 2297, 20668, 2299, 20666, 2301, 20664, 2303, 20662, 2305, 20660, 2307, 20658, 2309, 20656, 2311, 20654, 2313, 20652, 2315, 20650, 2317, 20648, 2319, 20646, 2321, 20644, 2323, 20642, 2325, 20640, 2327, 20638, 2329, 20636, 2331, 20634, 2333, 20632, 2335, 20630, 2337, 20628, 2339, 20626, 2341, 20624, 2343, 20622, 2345, 20620, 2347, 20618, 2349, 20616, 2351, 20614, 2353, 20612, 2355, 20610, 2357, 20608, 2359, 20606, 2361, 20604, 2363, 20602, 2365, 20600, 2367, 20598, 2369, 20596, 2371, 20594, 2373, 20592, 2375, 20590, 2377, 20588, 2379, 20586, 2381, 20584, 2383, 20582, 2385, 20580, 2387, 20578, 2389, 20576, 2391, 20574, 2393, 20572, 2395, 20570, 2397, 20568, 2399, 20566, 2401, 20564, 2403, 20562, 2405, 20560, 2407, 20558, 2409, 20556, 2411, 20554, 2413, 20552, 2415, 20550, 2417, 20548, 2419, 20546, 2421, 20544, 2423, 20542, 2425, 20540, 2427, 20538, 2429, 20536, 2431, 20534, 2433, 20532, 2435, 20530, 2437, 20528, 2439, 20526, 2441, 20524, 2443, 20522, 2445, 20520, 2447, 20518, 2449, 20516, 2451, 20514, 2453, 20512, 2455, 20510, 2457, 20508, 2459, 20506, 2461, 20504, 2463, 20502, 2465, 20500, 2467, 20498, 2469, 20496, 2471, 20494, 2473, 20492, 2475, 20490, 2477, 20488, 2479, 20486, 2481, 20484, 2483, 20482, 2485, 20480, 2487, 20478, 2489, 20476, 2491, 20474, 2493, 20472, 2495, 20470, 2497, 20468, 2499, 20466, 2501, 20464, 2503, 20462, 2505, 20460, 2507, 20458, 2509, 20456, 2511, 20454, 2513, 20452, 2515, 20450, 2517, 20448, 2519, 20446, 2521, 20444, 2523, 20442, 2525, 20440, 2527, 20438, 2529, 20436, 2531, 20434, 2533, 20432, 2535, 20430, 2537, 20428, 2539, 20426, 2541, 20424, 2543, 20422, 2545, 20420, 2547, 20418, 2549, 20416, 2551, 20414, 2553, 20412, 2555, 20410, 2557, 20408, 2559, 20406, 2561, 20404, 2563, 20402, 2565, 20400, 2567, 20398, 2569, 20396, 2571, 20394, 2573, 20392, 2575, 20390, 2577, 20388, 2579, 20386, 2581, 20384, 2583, 20382, 2585, 20380, 2587, 20378, 2589, 20376, 2591, 20374, 2593, 20372, 2595, 20370, 2597, 20368, 2599, 20366, 2601, 20364, 2603, 20362, 2605, 20360, 2607, 20358, 2609, 20356, 2611, 20354, 2613, 20352, 2615, 20350, 2617, 20348, 2619, 20346, 2621, 20344, 2623, 20342, 2625, 20340, 2627, 20338, 2629, 20336, 2631, 20334, 2633, 20332, 2635, 20330, 2637, 20328, 2639, 20326, 2641, 20324, 2643, 20322, 2645, 20320, 2647, 20318, 2649, 20316, 2651, 20314, 2653, 20312, 2655, 20310, 2657, 20308, 2659, 20306, 2661, 20304, 2663, 20302, 2665, 20300, 2667, 20298, 2669, 20296, 2671, 20294, 2673, 20292, 2675, 20290, 2677, 20288, 2679, 20286, 2681, 20284, 2683, 20282, 2685, 20280, 2687, 20278, 2689, 20276, 2691, 20274, 2693, 20272, 2695, 20270, 2697, 20268, 2699, 20266, 2701, 20264, 2703, 20262, 2705, 20260, 2707, 20258, 2709, 20256, 2711, 20254, 2713, 20252, 2715, 20250, 2717, 20248, 2719, 20246, 2721, 20244, 2723, 20242, 2725, 20240, 2727, 20238, 2729, 20236, 2731, 20234, 2733, 20232, 2735, 20230, 2737, 20228, 2739, 20226, 2741, 20224, 2743, 20222, 2745, 20220, 2747, 20218, 2749, 20216, 2751, 20214, 2753, 20212, 2755, 20210, 2757, 20208, 2759, 20206, 2761, 20204, 2763, 20202, 2765, 20200, 2767, 20198, 2769, 20196, 2771, 20194, 2773, 20192, 2775, 20190, 2777, 20188, 2779, 20186, 2781, 20184, 2783, 20182, 2785, 20180, 2787, 20178, 2789, 20176, 2791, 20174, 2793, 20172, 2795, 20170, 2797, 20168, 2799, 20166, 2801, 20164, 2803, 20162, 2805, 20160, 2807, 20158, 2809, 20156, 2811, 20154, 2813, 20152, 2815, 20150, 2817, 20148, 2819, 20146, 2821, 20144, 2823, 20142, 2825, 20140, 2827, 20138, 2829, 20136, 2831, 20134, 2833, 20132, 2835, 20130, 2837, 20128, 2839, 20126, 2841, 20124, 2843, 20122, 2845, 20120, 2847, 20118, 2849, 20116, 2851, 20114, 2853, 20112, 2855, 20110, 2857, 20108, 2859, 20106, 2861, 20104, 2863, 20102, 2865, 20100, 2867, 20098, 2869, 20096, 2871, 20094, 2873, 20092, 2875, 20090, 2877, 20088, 2879, 20086, 2881, 20084, 2883, 20082, 2885, 20080, 2887, 20078, 2889, 20076, 2891, 20074, 2893, 20072, 2895, 20070, 2897, 20068, 2899, 20066, 2901, 20064, 2903, 20062, 2905, 20060, 2907, 20058, 2909, 20056, 2911, 20054, 2913, 20052, 2915, 20050, 2917, 20048, 2919, 20046, 2921, 20044, 2923, 20042, 2925, 20040, 2927, 20038, 2929, 20036, 2931, 20034, 2933, 20032, 2935, 20030, 2937, 20028, 2939, 20026, 2941, 20024, 2943, 20022, 2945, 20020, 2947, 20018, 2949, 20016, 2951, 20014, 2953, 20012, 2955, 20010, 2957, 20008, 2959, 20006, 2961, 20004, 2963, 20002, 2965, 20000, 2967, 19998, 2969, 19996, 2971, 19994, 2973, 19992, 2975, 19990, 2977, 19988, 2979, 19986, 2981, 19984, 2983, 19982, 2985, 19980, 2987, 19978, 2989, 19976, 2991, 19974, 2993, 19972, 2995, 19970, 2997, 19968, 2999, 19966, 3001, 19964, 3003, 19962, 3005, 19960, 3007, 19958, 3009, 19956, 3011, 19954, 3013, 19952, 3015, 19950, 3017, 19948, 3019, 19946, 3021, 19944, 3023, 19942, 3025, 19940, 3027, 19938, 3029, 19936, 3031, 19934, 3033, 19932, 3035, 19930, 3037, 19928, 3039, 19926, 3041, 19924, 3043, 19922, 3045, 19920, 3047, 19918, 3049, 19916, 3051, 19914, 3053, 19912, 3055, 19910, 3057, 19908, 3059, 19906, 3061, 19904, 3063, 19902, 3065, 19900, 3067, 19898, 3069, 19896, 3071, 19894, 3073, 19892, 3075, 19890, 3077, 19888, 3079, 19886, 3081, 19884, 3083, 19882, 3085, 19880, 3087, 19878, 3089, 19876, 3091, 19874, 3093, 19872, 3095, 19870, 3097, 19868, 3099, 19866, 3101, 19864, 3103, 19862, 3105, 19860, 3107, 19858, 3109, 19856, 3111, 19854, 3113, 19852, 3115, 19850, 3117, 19848, 3119, 19846, 3121, 19844, 3123, 19842, 3125, 19840, 3127, 19838, 3129, 19836, 3131, 19834, 3133, 19832, 3135, 19830, 3137, 19828, 3139, 19826, 3141, 19824, 3143, 19822, 3145, 19820, 3147, 19818, 3149, 19816, 3151, 19814, 3153, 19812, 3155, 19810, 3157, 19808, 3159, 19806, 3161, 19804, 3163, 19802, 3165, 19800, 3167, 19798, 3169, 19796, 3171, 19794, 3173, 19792, 3175, 19790, 3177, 19788, 3179, 19786, 3181, 19784, 3183, 19782, 3185, 19780, 3187, 19778, 3189, 19776, 3191, 19774, 3193, 19772, 3195, 19770, 3197, 19768, 3199, 19766, 3201, 19764, 3203, 19762, 3205, 19760, 3207, 19758, 3209, 19756, 3211, 19754, 3213, 19752, 3215, 19750, 3217, 19748, 3219, 19746, 3221, 19744, 3223, 19742, 3225, 19740, 3227, 19738, 3229, 19736, 3231, 19734, 3233, 19732, 3235, 19730, 3237, 19728, 3239, 19726, 3241, 19724, 3243, 19722, 3245, 19720, 3247, 19718, 3249, 19716, 3251, 19714, 3253, 19712, 3255, 19710, 3257, 19708, 3259, 19706, 3261, 19704, 3263, 19702, 3265, 19700, 3267, 19698, 3269, 19696, 3271, 19694, 3273, 19692, 3275, 19690, 3277, 19688, 3279, 19686, 3281, 19684, 3283, 19682, 3285, 19680, 3287, 19678, 3289, 19676, 3291, 19674, 3293, 19672, 3295, 19670, 3297, 19668, 3299, 19666, 3301, 19664, 3303, 19662, 3305, 19660, 3307, 19658, 3309, 19656, 3311, 19654, 3313, 19652, 3315, 19650, 3317, 19648, 3319, 19646, 3321, 19644, 3323, 19642, 3325, 19640, 3327, 19638, 3329, 19636, 3331, 19634, 3333, 19632, 3335, 19630, 3337, 19628, 3339, 19626, 3341, 19624, 3343, 19622, 3345, 19620, 3347, 19618, 3349, 19616, 3351, 19614, 3353, 19612, 3355, 19610, 3357, 19608, 3359, 19606, 3361, 19604, 3363, 19602, 3365, 19600, 3367, 19598, 3369, 19596, 3371, 19594, 3373, 19592, 3375, 19590, 3377, 19588, 3379, 19586, 3381, 19584, 3383, 19582, 3385, 19580, 3387, 19578, 3389, 19576, 3391, 19574, 3393, 19572, 3395, 19570, 3397, 19568, 3399, 19566, 3401, 19564, 3403, 19562, 3405, 19560, 3407, 19558, 3409, 19556, 3411, 19554, 3413, 19552, 3415, 19550, 3417, 19548, 3419, 19546, 3421, 19544, 3423, 19542, 3425, 19540, 3427, 19538, 3429, 19536, 3431, 19534, 3433, 19532, 3435, 19530, 3437, 19528, 3439, 19526, 3441, 19524, 3443, 19522, 3445, 19520, 3447, 19518, 3449, 19516, 3451, 19514, 3453, 19512, 3455, 19510, 3457, 19508, 3459, 19506, 3461, 19504, 3463, 19502, 3465, 19500, 3467, 19498, 3469, 19496, 3471, 19494, 3473, 19492, 3475, 19490, 3477, 19488, 3479, 19486, 3481, 19484, 3483, 19482, 3485, 19480, 3487, 19478, 3489, 19476, 3491, 19474, 3493, 19472, 3495, 19470, 3497, 19468, 3499, 19466, 3501, 19464, 3503, 19462, 3505, 19460, 3507, 19458, 3509, 19456, 3511, 19454, 3513, 19452, 3515, 19450, 3517, 19448, 3519, 19446, 3521, 19444, 3523, 19442, 3525, 19440, 3527, 19438, 3529, 19436, 3531, 19434, 3533, 19432, 3535, 19430, 3537, 19428, 3539, 19426, 3541, 19424, 3543, 19422, 3545, 19420, 3547, 19418, 3549, 19416, 3551, 19414, 3553, 19412, 3555, 19410, 3557, 19408, 3559, 19406, 3561, 19404, 3563, 19402, 3565, 19400, 3567, 19398, 3569, 19396, 3571, 19394, 3573, 19392, 3575, 19390, 3577, 19388, 3579, 19386, 3581, 19384, 3583, 19382, 3585, 19380, 3587, 19378, 3589, 19376, 3591, 19374, 3593, 19372, 3595, 19370, 3597, 19368, 3599, 19366, 3601, 19364, 3603, 19362, 3605, 19360, 3607, 19358, 3609, 19356, 3611, 19354, 3613, 19352, 3615, 19350, 3617, 19348, 3619, 19346, 3621, 19344, 3623, 19342, 3625, 19340, 3627, 19338, 3629, 19336, 3631, 19334, 3633, 19332, 3635, 19330, 3637, 19328, 3639, 19326, 3641, 19324, 3643, 19322, 3645, 19320, 3647, 19318, 3649, 19316, 3651, 19314, 3653, 19312, 3655, 19310, 3657, 19308, 3659, 19306, 3661, 19304, 3663, 19302, 3665, 19300, 3667, 19298, 3669, 19296, 3671, 19294, 3673, 19292, 3675, 19290, 3677, 19288, 3679, 19286, 3681, 19284, 3683, 19282, 3685, 19280, 3687, 19278, 3689, 19276, 3691, 19274, 3693, 19272, 3695, 19270, 3697, 19268, 3699, 19266, 3701, 19264, 3703, 19262, 3705, 19260, 3707, 19258, 3709, 19256, 3711, 19254, 3713, 19252, 3715, 19250, 3717, 19248, 3719, 19246, 3721, 19244, 3723, 19242, 3725, 19240, 3727, 19238, 3729, 19236, 3731, 19234, 3733, 19232, 3735, 19230, 3737, 19228, 3739, 19226, 3741, 19224, 3743, 19222, 3745, 19220, 3747, 19218, 3749, 19216, 3751, 19214, 3753, 19212, 3755, 19210, 3757, 19208, 3759, 19206, 3761, 19204, 3763, 19202, 3765, 19200, 3767, 19198, 3769, 19196, 3771, 19194, 3773, 19192, 3775, 19190, 3777, 19188, 3779, 19186, 3781, 19184, 3783, 19182, 3785, 19180, 3787, 19178, 3789, 19176, 3791, 19174, 3793, 19172, 3795, 19170, 3797, 19168, 3799, 19166, 3801, 19164, 3803, 19162, 3805, 19160, 3807, 19158, 3809, 19156, 3811, 19154, 3813, 19152, 3815, 19150, 3817, 19148, 3819, 19146, 3821, 19144, 3823, 19142, 3825, 19140, 3827, 19138, 3829, 19136, 3831, 19134, 3833, 19132, 3835, 19130, 3837, 19128, 3839, 19126, 3841, 19124, 3843, 19122, 3845, 19120, 3847, 19118, 3849, 19116, 3851, 19114, 3853, 19112, 3855, 19110, 3857, 19108, 3859, 19106, 3861, 19104, 3863, 19102, 3865, 19100, 3867, 19098, 3869, 19096, 3871, 19094, 3873, 19092, 3875, 19090, 3877, 19088, 3879, 19086, 3881, 19084, 3883, 19082, 3885, 19080, 3887, 19078, 3889, 19076, 3891, 19074, 3893, 19072, 3895, 19070, 3897, 19068, 3899, 19066, 3901, 19064, 3903, 19062, 3905, 19060, 3907, 19058, 3909, 19056, 3911, 19054, 3913, 19052, 3915, 19050, 3917, 19048, 3919, 19046, 3921, 19044, 3923, 19042, 3925, 19040, 3927, 19038, 3929, 19036, 3931, 19034, 3933, 19032, 3935, 19030, 3937, 19028, 3939, 19026, 3941, 19024, 3943, 19022, 3945, 19020, 3947, 19018, 3949, 19016, 3951, 19014, 3953, 19012, 3955, 19010, 3957, 19008, 3959, 19006, 3961, 19004, 3963, 19002, 3965, 19000, 3967, 18998, 3969, 18996, 3971, 18994, 3973, 18992, 3975, 18990, 3977, 18988, 3979, 18986, 3981, 18984, 3983, 18982, 3985, 18980, 3987, 18978, 3989, 18976, 3991, 18974, 3993, 18972, 3995, 18970, 3997, 18968, 3999, 18966, 4001, 18964, 4003, 18962, 4005, 18960, 4007, 18958, 4009, 18956, 4011, 18954, 4013, 18952, 4015, 18950, 4017, 18948, 4019, 18946, 4021, 18944, 4023, 18942, 4025, 18940, 4027, 18938, 4029, 18936, 4031, 18934, 4033, 18932, 4035, 18930, 4037, 18928, 4039, 18926, 4041, 18924, 4043, 18922, 4045, 18920, 4047, 18918, 4049, 18916, 4051, 18914, 4053, 18912, 4055, 18910, 4057, 18908, 4059, 18906, 4061, 18904, 4063, 18902, 4065, 18900, 4067, 18898, 4069, 18896, 4071, 18894, 4073, 18892, 4075, 18890, 4077, 18888, 4079, 18886, 4081, 18884, 4083, 18882, 4085, 18880, 4087, 18878, 4089, 18876, 4091, 18874, 4093, 18872, 4095, 18870, 4097, 18868, 4099, 18866, 4101, 18864, 4103, 18862, 4105, 18860, 4107, 18858, 4109, 18856, 4111, 18854, 4113, 18852, 4115, 18850, 4117, 18848, 4119, 18846, 4121, 18844, 4123, 18842, 4125, 18840, 4127, 18838, 4129, 18836, 4131, 18834, 4133, 18832, 4135, 18830, 4137, 18828, 4139, 18826, 4141, 18824, 4143, 18822, 4145, 18820, 4147, 18818, 4149, 18816, 4151, 18814, 4153, 18812, 4155, 18810, 4157, 18808, 4159, 18806, 4161, 18804, 4163, 18802, 4165, 18800, 4167, 18798, 4169, 18796, 4171, 18794, 4173, 18792, 4175, 18790, 4177, 18788, 4179, 18786, 4181, 18784, 4183, 18782, 4185, 18780, 4187, 18778, 4189, 18776, 4191, 18774, 4193, 18772, 4195, 18770, 4197, 18768, 4199, 18766, 4201, 18764, 4203, 18762, 4205, 18760, 4207, 18758, 4209, 18756, 4211, 18754, 4213, 18752, 4215, 18750, 4217, 18748, 4219, 18746, 4221, 18744, 4223, 18742, 4225, 18740, 4227, 18738, 4229, 18736, 4231, 18734, 4233, 18732, 4235, 18730, 4237, 18728, 4239, 18726, 4241, 18724, 4243, 18722, 4245, 18720, 4247, 18718, 4249, 18716, 4251, 18714, 4253, 18712, 4255, 18710, 4257, 18708, 4259, 18706, 4261, 18704, 4263, 18702, 4265, 18700, 4267, 18698, 4269, 18696, 4271, 18694, 4273, 18692, 4275, 18690, 4277, 18688, 4279, 18686, 4281, 18684, 4283, 18682, 4285, 18680, 4287, 18678, 4289, 18676, 4291, 18674, 4293, 18672, 4295, 18670, 4297, 18668, 4299, 18666, 4301, 18664, 4303, 18662, 4305, 18660, 4307, 18658, 4309, 18656, 4311, 18654, 4313, 18652, 4315, 18650, 4317, 18648, 4319, 18646, 4321, 18644, 4323, 18642, 4325, 18640, 4327, 18638, 4329, 18636, 4331, 18634, 4333, 18632, 4335, 18630, 4337, 18628, 4339, 18626, 4341, 18624, 4343, 18622, 4345, 18620, 4347, 18618, 4349, 18616, 4351, 18614, 4353, 18612, 4355, 18610, 4357, 18608, 4359, 18606, 4361, 18604, 4363, 18602, 4365, 18600, 4367, 18598, 4369, 18596, 4371, 18594, 4373, 18592, 4375, 18590, 4377, 18588, 4379, 18586, 4381, 18584, 4383, 18582, 4385, 18580, 4387, 18578, 4389, 18576, 4391, 18574, 4393, 18572, 4395, 18570, 4397, 18568, 4399, 18566, 4401, 18564, 4403, 18562, 4405, 18560, 4407, 18558, 4409, 18556, 4411, 18554, 4413, 18552, 4415, 18550, 4417, 18548, 4419, 18546, 4421, 18544, 4423, 18542, 4425, 18540, 4427, 18538, 4429, 18536, 4431, 18534, 4433, 18532, 4435, 18530, 4437, 18528, 4439, 18526, 4441, 18524, 4443, 18522, 4445, 18520, 4447, 18518, 4449, 18516, 4451, 18514, 4453, 18512, 4455, 18510, 4457, 18508, 4459, 18506, 4461, 18504, 4463, 18502, 4465, 18500, 4467, 18498, 4469, 18496, 4471, 18494, 4473, 18492, 4475, 18490, 4477, 18488, 4479, 18486, 4481, 18484, 4483, 18482, 4485, 18480, 4487, 18478, 4489, 18476, 4491, 18474, 4493, 18472, 4495, 18470, 4497, 18468, 4499, 18466, 4501, 18464, 4503, 18462, 4505, 18460, 4507, 18458, 4509, 18456, 4511, 18454, 4513, 18452, 4515, 18450, 4517, 18448, 4519, 18446, 4521, 18444, 4523, 18442, 4525, 18440, 4527, 18438, 4529, 18436, 4531, 18434, 4533, 18432, 4535, 18430, 4537, 18428, 4539, 18426, 4541, 18424, 4543, 18422, 4545, 18420, 4547, 18418, 4549, 18416, 4551, 18414, 4553, 18412, 4555, 18410, 4557, 18408, 4559, 18406, 4561, 18404, 4563, 18402, 4565, 18400, 4567, 18398, 4569, 18396, 4571, 18394, 4573, 18392, 4575, 18390, 4577, 18388, 4579, 18386, 4581, 18384, 4583, 18382, 4585, 18380, 4587, 18378, 4589, 18376, 4591, 18374, 4593, 18372, 4595, 18370, 4597, 18368, 4599, 18366, 4601, 18364, 4603, 18362, 4605, 18360, 4607, 18358, 4609, 18356, 4611, 18354, 4613, 18352, 4615, 18350, 4617, 18348, 4619, 18346, 4621, 18344, 4623, 18342, 4625, 18340, 4627, 18338, 4629, 18336, 4631, 18334, 4633, 18332, 4635, 18330, 4637, 18328, 4639, 18326, 4641, 18324, 4643, 18322, 4645, 18320, 4647, 18318, 4649, 18316, 4651, 18314, 4653, 18312, 4655, 18310, 4657, 18308, 4659, 18306, 4661, 18304, 4663, 18302, 4665, 18300, 4667, 18298, 4669, 18296, 4671, 18294, 4673, 18292, 4675, 18290, 4677, 18288, 4679, 18286, 4681, 18284, 4683, 18282, 4685, 18280, 4687, 18278, 4689, 18276, 4691, 18274, 4693, 18272, 4695, 18270, 4697, 18268, 4699, 18266, 4701, 18264, 4703, 18262, 4705, 18260, 4707, 18258, 4709, 18256, 4711, 18254, 4713, 18252, 4715, 18250, 4717, 18248, 4719, 18246, 4721, 18244, 4723, 18242, 4725, 18240, 4727, 18238, 4729, 18236, 4731, 18234, 4733, 18232, 4735, 18230, 4737, 18228, 4739, 18226, 4741, 18224, 4743, 18222, 4745, 18220, 4747, 18218, 4749, 18216, 4751, 18214, 4753, 18212, 4755, 18210, 4757, 18208, 4759, 18206, 4761, 18204, 4763, 18202, 4765, 18200, 4767, 18198, 4769, 18196, 4771, 18194, 4773, 18192, 4775, 18190, 4777, 18188, 4779, 18186, 4781, 18184, 4783, 18182, 4785, 18180, 4787, 18178, 4789, 18176, 4791, 18174, 4793, 18172, 4795, 18170, 4797, 18168, 4799, 18166, 4801, 18164, 4803, 18162, 4805, 18160, 4807, 18158, 4809, 18156, 4811, 18154, 4813, 18152, 4815, 18150, 4817, 18148, 4819, 18146, 4821, 18144, 4823, 18142, 4825, 18140, 4827, 18138, 4829, 18136, 4831, 18134, 4833, 18132, 4835, 18130, 4837, 18128, 4839, 18126, 4841, 18124, 4843, 18122, 4845, 18120, 4847, 18118, 4849, 18116, 4851, 18114, 4853, 18112, 4855, 18110, 4857, 18108, 4859, 18106, 4861, 18104, 4863, 18102, 4865, 18100, 4867, 18098, 4869, 18096, 4871, 18094, 4873, 18092, 4875, 18090, 4877, 18088, 4879, 18086, 4881, 18084, 4883, 18082, 4885, 18080, 4887, 18078, 4889, 18076, 4891, 18074, 4893, 18072, 4895, 18070, 4897, 18068, 4899, 18066, 4901, 18064, 4903, 18062, 4905, 18060, 4907, 18058, 4909, 18056, 4911, 18054, 4913, 18052, 4915, 18050, 4917, 18048, 4919, 18046, 4921, 18044, 4923, 18042, 4925, 18040, 4927, 18038, 4929, 18036, 4931, 18034, 4933, 18032, 4935, 18030, 4937, 18028, 4939, 18026, 4941, 18024, 4943, 18022, 4945, 18020, 4947, 18018, 4949, 18016, 4951, 18014, 4953, 18012, 4955, 18010, 4957, 18008, 4959, 18006, 4961, 18004, 4963, 18002, 4965, 18000, 4967, 17998, 4969, 17996, 4971, 17994, 4973, 17992, 4975, 17990, 4977, 17988, 4979, 17986, 4981, 17984, 4983, 17982, 4985, 17980, 4987, 17978, 4989, 17976, 4991, 17974, 4993, 17972, 4995, 17970, 4997, 17968, 4999, 17966, 5001, 17964, 5003, 17962, 5005, 17960, 5007, 17958, 5009, 17956, 5011, 17954, 5013, 17952, 5015, 17950, 5017, 17948, 5019, 17946, 5021, 17944, 5023, 17942, 5025, 17940, 5027, 17938, 5029, 17936, 5031, 17934, 5033, 17932, 5035, 17930, 5037, 17928, 5039, 17926, 5041, 17924, 5043, 17922, 5045, 17920, 5047, 17918, 5049, 17916, 5051, 17914, 5053, 17912, 5055, 17910, 5057, 17908, 5059, 17906, 5061, 17904, 5063, 17902, 5065, 17900, 5067, 17898, 5069, 17896, 5071, 17894, 5073, 17892, 5075, 17890, 5077, 17888, 5079, 17886, 5081, 17884, 5083, 17882, 5085, 17880, 5087, 17878, 5089, 17876, 5091, 17874, 5093, 17872, 5095, 17870, 5097, 17868, 5099, 17866, 5101, 17864, 5103, 17862, 5105, 17860, 5107, 17858, 5109, 17856, 5111, 17854, 5113, 17852, 5115, 17850, 5117, 17848, 5119, 17846, 5121, 17844, 5123, 17842, 5125, 17840, 5127, 17838, 5129, 17836, 5131, 17834, 5133, 17832, 5135, 17830, 5137, 17828, 5139, 17826, 5141, 17824, 5143, 17822, 5145, 17820, 5147, 17818, 5149, 17816, 5151, 17814, 5153, 17812, 5155, 17810, 5157, 17808, 5159, 17806, 5161, 17804, 5163, 17802, 5165, 17800, 5167, 17798, 5169, 17796, 5171, 17794, 5173, 17792, 5175, 17790, 5177, 17788, 5179, 17786, 5181, 17784, 5183, 17782, 5185, 17780, 5187, 17778, 5189, 17776, 5191, 17774, 5193, 17772, 5195, 17770, 5197, 17768, 5199, 17766, 5201, 17764, 5203, 17762, 5205, 17760, 5207, 17758, 5209, 17756, 5211, 17754, 5213, 17752, 5215, 17750, 5217, 17748, 5219, 17746, 5221, 17744, 5223, 17742, 5225, 17740, 5227, 17738, 5229, 17736, 5231, 17734, 5233, 17732, 5235, 17730, 5237, 17728, 5239, 17726, 5241, 17724, 5243, 17722, 5245, 17720, 5247, 17718, 5249, 17716, 5251, 17714, 5253, 17712, 5255, 17710, 5257, 17708, 5259, 17706, 5261, 17704, 5263, 17702, 5265, 17700, 5267, 17698, 5269, 17696, 5271, 17694, 5273, 17692, 5275, 17690, 5277, 17688, 5279, 17686, 5281, 17684, 5283, 17682, 5285, 17680, 5287, 17678, 5289, 17676, 5291, 17674, 5293, 17672, 5295, 17670, 5297, 17668, 5299, 17666, 5301, 17664, 5303, 17662, 5305, 17660, 5307, 17658, 5309, 17656, 5311, 17654, 5313, 17652, 5315, 17650, 5317, 17648, 5319, 17646, 5321, 17644, 5323, 17642, 5325, 17640, 5327, 17638, 5329, 17636, 5331, 17634, 5333, 17632, 5335, 17630, 5337, 17628, 5339, 17626, 5341, 17624, 5343, 17622, 5345, 17620, 5347, 17618, 5349, 17616, 5351, 17614, 5353, 17612, 5355, 17610, 5357, 17608, 5359, 17606, 5361, 17604, 5363, 17602, 5365, 17600, 5367, 17598, 5369, 17596, 5371, 17594, 5373, 17592, 5375, 17590, 5377, 17588, 5379, 17586, 5381, 17584, 5383, 17582, 5385, 17580, 5387, 17578, 5389, 17576, 5391, 17574, 5393, 17572, 5395, 17570, 5397, 17568, 5399, 17566, 5401, 17564, 5403, 17562, 5405, 17560, 5407, 17558, 5409, 17556, 5411, 17554, 5413, 17552, 5415, 17550, 5417, 17548, 5419, 17546, 5421, 17544, 5423, 17542, 5425, 17540, 5427, 17538, 5429, 17536, 5431, 17534, 5433, 17532, 5435, 17530, 5437, 17528, 5439, 17526, 5441, 17524, 5443, 17522, 5445, 17520, 5447, 17518, 5449, 17516, 5451, 17514, 5453, 17512, 5455, 17510, 5457, 17508, 5459, 17506, 5461, 17504, 5463, 17502, 5465, 17500, 5467, 17498, 5469, 17496, 5471, 17494, 5473, 17492, 5475, 17490, 5477, 17488, 5479, 17486, 5481, 17484, 5483, 17482, 5485, 17480, 5487, 17478, 5489, 17476, 5491, 17474, 5493, 17472, 5495, 17470, 5497, 17468, 5499, 17466, 5501, 17464, 5503, 17462, 5505, 17460, 5507, 17458, 5509, 17456, 5511, 17454, 5513, 17452, 5515, 17450, 5517, 17448, 5519, 17446, 5521, 17444, 5523, 17442, 5525, 17440, 5527, 17438, 5529, 17436, 5531, 17434, 5533, 17432, 5535, 17430, 5537, 17428, 5539, 17426, 5541, 17424, 5543, 17422, 5545, 17420, 5547, 17418, 5549, 17416, 5551, 17414, 5553, 17412, 5555, 17410, 5557, 17408, 5559, 17406, 5561, 17404, 5563, 17402, 5565, 17400, 5567, 17398, 5569, 17396, 5571, 17394, 5573, 17392, 5575, 17390, 5577, 17388, 5579, 17386, 5581, 17384, 5583, 17382, 5585, 17380, 5587, 17378, 5589, 17376, 5591, 17374, 5593, 17372, 5595, 17370, 5597, 17368, 5599, 17366, 5601, 17364, 5603, 17362, 5605, 17360, 5607, 17358, 5609, 17356, 5611, 17354, 5613, 17352, 5615, 17350, 5617, 17348, 5619, 17346, 5621, 17344, 5623, 17342, 5625, 17340, 5627, 17338, 5629, 17336, 5631, 17334, 5633, 17332, 5635, 17330, 5637, 17328, 5639, 17326, 5641, 17324, 5643, 17322, 5645, 17320, 5647, 17318, 5649, 17316, 5651, 17314, 5653, 17312, 5655, 17310, 5657, 17308, 5659, 17306, 5661, 17304, 5663, 17302, 5665, 17300, 5667, 17298, 5669, 17296, 5671, 17294, 5673, 17292, 5675, 17290, 5677, 17288, 5679, 17286, 5681, 17284, 5683, 17282, 5685, 17280, 5687, 17278, 5689, 17276, 5691, 17274, 5693, 17272, 5695, 17270, 5697, 17268, 5699, 17266, 5701, 17264, 5703, 17262, 5705, 17260, 5707, 17258, 5709, 17256, 5711, 17254, 5713, 17252, 5715, 17250, 5717, 17248, 5719, 17246, 5721, 17244, 5723, 17242, 5725, 17240, 5727, 17238, 5729, 17236, 5731, 17234, 5733, 17232, 5735, 17230, 5737, 17228, 5739, 17226, 5741, 17224, 5743, 17222, 5745, 17220, 5747, 17218, 5749, 17216, 5751, 17214, 5753, 17212, 5755, 17210, 5757, 17208, 5759, 17206, 5761, 17204, 5763, 17202, 5765, 17200, 5767, 17198, 5769, 17196, 5771, 17194, 5773, 17192, 5775, 17190, 5777, 17188, 5779, 17186, 5781, 17184, 5783, 17182, 5785, 17180, 5787, 17178, 5789, 17176, 5791, 17174, 5793, 17172, 5795, 17170, 5797, 17168, 5799, 17166, 5801, 17164, 5803, 17162, 5805, 17160, 5807, 17158, 5809, 17156, 5811, 17154, 5813, 17152, 5815, 17150, 5817, 17148, 5819, 17146, 5821, 17144, 5823, 17142, 5825, 17140, 5827, 17138, 5829, 17136, 5831, 17134, 5833, 17132, 5835, 17130, 5837, 17128, 5839, 17126, 5841, 17124, 5843, 17122, 5845, 17120, 5847, 17118, 5849, 17116, 5851, 17114, 5853, 17112, 5855, 17110, 5857, 17108, 5859, 17106, 5861, 17104, 5863, 17102, 5865, 17100, 5867, 17098, 5869, 17096, 5871, 17094, 5873, 17092, 5875, 17090, 5877, 17088, 5879, 17086, 5881, 17084, 5883, 17082, 5885, 17080, 5887, 17078, 5889, 17076, 5891, 17074, 5893, 17072, 5895, 17070, 5897, 17068, 5899, 17066, 5901, 17064, 5903, 17062, 5905, 17060, 5907, 17058, 5909, 17056, 5911, 17054, 5913, 17052, 5915, 17050, 5917, 17048, 5919, 17046, 5921, 17044, 5923, 17042, 5925, 17040, 5927, 17038, 5929, 17036, 5931, 17034, 5933, 17032, 5935, 17030, 5937, 17028, 5939, 17026, 5941, 17024, 5943, 17022, 5945, 17020, 5947, 17018, 5949, 17016, 5951, 17014, 5953, 17012, 5955, 17010, 5957, 17008, 5959, 17006, 5961, 17004, 5963, 17002, 5965, 17000, 5967, 16998, 5969, 16996, 5971, 16994, 5973, 16992, 5975, 16990, 5977, 16988, 5979, 16986, 5981, 16984, 5983, 16982, 5985, 16980, 5987, 16978, 5989, 16976, 5991, 16974, 5993, 16972, 5995, 16970, 5997, 16968, 5999, 16966, 6001, 16964, 6003, 16962, 6005, 16960, 6007, 16958, 6009, 16956, 6011, 16954, 6013, 16952, 6015, 16950, 6017, 16948, 6019, 16946, 6021, 16944, 6023, 16942, 6025, 16940, 6027, 16938, 6029, 16936, 6031, 16934, 6033, 16932, 6035, 16930, 6037, 16928, 6039, 16926, 6041, 16924, 6043, 16922, 6045, 16920, 6047, 16918, 6049, 16916, 6051, 16914, 6053, 16912, 6055, 16910, 6057, 16908, 6059, 16906, 6061, 16904, 6063, 16902, 6065, 16900, 6067, 16898, 6069, 16896, 6071, 16894, 6073, 16892, 6075, 16890, 6077, 16888, 6079, 16886, 6081, 16884, 6083, 16882, 6085, 16880, 6087, 16878, 6089, 16876, 6091, 16874, 6093, 16872, 6095, 16870, 6097, 16868, 6099, 16866, 6101, 16864, 6103, 16862, 6105, 16860, 6107, 16858, 6109, 16856, 6111, 16854, 6113, 16852, 6115, 16850, 6117, 16848, 6119, 16846, 6121, 16844, 6123, 16842, 6125, 16840, 6127, 16838, 6129, 16836, 6131, 16834, 6133, 16832, 6135, 16830, 6137, 16828, 6139, 16826, 6141, 16824, 6143, 16822, 6145, 16820, 6147, 16818, 6149, 16816, 6151, 16814, 6153, 16812, 6155, 16810, 6157, 16808, 6159, 16806, 6161, 16804, 6163, 16802, 6165, 16800, 6167, 16798, 6169, 16796, 6171, 16794, 6173, 16792, 6175, 16790, 6177, 16788, 6179, 16786, 6181, 16784, 6183, 16782, 6185, 16780, 6187, 16778, 6189, 16776, 6191, 16774, 6193, 16772, 6195, 16770, 6197, 16768, 6199, 16766, 6201, 16764, 6203, 16762, 6205, 16760, 6207, 16758, 6209, 16756, 6211, 16754, 6213, 16752, 6215, 16750, 6217, 16748, 6219, 16746, 6221, 16744, 6223, 16742, 6225, 16740, 6227, 16738, 6229, 16736, 6231, 16734, 6233, 16732, 6235, 16730, 6237, 16728, 6239, 16726, 6241, 16724, 6243, 16722, 6245, 16720, 6247, 16718, 6249, 16716, 6251, 16714, 6253, 16712, 6255, 16710, 6257, 16708, 6259, 16706, 6261, 16704, 6263, 16702, 6265, 16700, 6267, 16698, 6269, 16696, 6271, 16694, 6273, 16692, 6275, 16690, 6277, 16688, 6279, 16686, 6281, 16684, 6283, 16682, 6285, 16680, 6287, 16678, 6289, 16676, 6291, 16674, 6293, 16672, 6295, 16670, 6297, 16668, 6299, 16666, 6301, 16664, 6303, 16662, 6305, 16660, 6307, 16658, 6309, 16656, 6311, 16654, 6313, 16652, 6315, 16650, 6317, 16648, 6319, 16646, 6321, 16644, 6323, 16642, 6325, 16640, 6327, 16638, 6329, 16636, 6331, 16634, 6333, 16632, 6335, 16630, 6337, 16628, 6339, 16626, 6341, 16624, 6343, 16622, 6345, 16620, 6347, 16618, 6349, 16616, 6351, 16614, 6353, 16612, 6355, 16610, 6357, 16608, 6359, 16606, 6361, 16604, 6363, 16602, 6365, 16600, 6367, 16598, 6369, 16596, 6371, 16594, 6373, 16592, 6375, 16590, 6377, 16588, 6379, 16586, 6381, 16584, 6383, 16582, 6385, 16580, 6387, 16578, 6389, 16576, 6391, 16574, 6393, 16572, 6395, 16570, 6397, 16568, 6399, 16566, 6401, 16564, 6403, 16562, 6405, 16560, 6407, 16558, 6409, 16556, 6411, 16554, 6413, 16552, 6415, 16550, 6417, 16548, 6419, 16546, 6421, 16544, 6423, 16542, 6425, 16540, 6427, 16538, 6429, 16536, 6431, 16534, 6433, 16532, 6435, 16530, 6437, 16528, 6439, 16526, 6441, 16524, 6443, 16522, 6445, 16520, 6447, 16518, 6449, 16516, 6451, 16514, 6453, 16512, 6455, 16510, 6457, 16508, 6459, 16506, 6461, 16504, 6463, 16502, 6465, 16500, 6467, 16498, 6469, 16496, 6471, 16494, 6473, 16492, 6475, 16490, 6477, 16488, 6479, 16486, 6481, 16484, 6483, 16482, 6485, 16480, 6487, 16478, 6489, 16476, 6491, 16474, 6493, 16472, 6495, 16470, 6497, 16468, 6499, 16466, 6501, 16464, 6503, 16462, 6505, 16460, 6507, 16458, 6509, 16456, 6511, 16454, 6513, 16452, 6515, 16450, 6517, 16448, 6519, 16446, 6521, 16444, 6523, 16442, 6525, 16440, 6527, 16438, 6529, 16436, 6531, 16434, 6533, 16432, 6535, 16430, 6537, 16428, 6539, 16426, 6541, 16424, 6543, 16422, 6545, 16420, 6547, 16418, 6549, 16416, 6551, 16414, 6553, 16412, 6555, 16410, 6557, 16408, 6559, 16406, 6561, 16404, 6563, 16402, 6565, 16400, 6567, 16398, 6569, 16396, 6571, 16394, 6573, 16392, 6575, 16390, 6577, 16388, 6579, 16386, 6581, 16384, 6583, 16382, 6585, 16380, 6587, 16378, 6589, 16376, 6591, 16374, 6593, 16372, 6595, 16370, 6597, 16368, 6599, 16366, 6601, 16364, 6603, 16362, 6605, 16360, 6607, 16358, 6609, 16356, 6611, 16354, 6613, 16352, 6615, 16350, 6617, 16348, 6619, 16346, 6621, 16344, 6623, 16342, 6625, 16340, 6627, 16338, 6629, 16336, 6631, 16334, 6633, 16332, 6635, 16330, 6637, 16328, 6639, 16326, 6641, 16324, 6643, 16322, 6645, 16320, 6647, 16318, 6649, 16316, 6651, 16314, 6653, 16312, 6655, 16310, 6657, 16308, 6659, 16306, 6661, 16304, 6663, 16302, 6665, 16300, 6667, 16298, 6669, 16296, 6671, 16294, 6673, 16292, 6675, 16290, 6677, 16288, 6679, 16286, 6681, 16284, 6683, 16282, 6685, 16280, 6687, 16278, 6689, 16276, 6691, 16274, 6693, 16272, 6695, 16270, 6697, 16268, 6699, 16266, 6701, 16264, 6703, 16262, 6705, 16260, 6707, 16258, 6709, 16256, 6711, 16254, 6713, 16252, 6715, 16250, 6717, 16248, 6719, 16246, 6721, 16244, 6723, 16242, 6725, 16240, 6727, 16238, 6729, 16236, 6731, 16234, 6733, 16232, 6735, 16230, 6737, 16228, 6739, 16226, 6741, 16224, 6743, 16222, 6745, 16220, 6747, 16218, 6749, 16216, 6751, 16214, 6753, 16212, 6755, 16210, 6757, 16208, 6759, 16206, 6761, 16204, 6763, 16202, 6765, 16200, 6767, 16198, 6769, 16196, 6771, 16194, 6773, 16192, 6775, 16190, 6777, 16188, 6779, 16186, 6781, 16184, 6783, 16182, 6785, 16180, 6787, 16178, 6789, 16176, 6791, 16174, 6793, 16172, 6795, 16170, 6797, 16168, 6799, 16166, 6801, 16164, 6803, 16162, 6805, 16160, 6807, 16158, 6809, 16156, 6811, 16154, 6813, 16152, 6815, 16150, 6817, 16148, 6819, 16146, 6821, 16144, 6823, 16142, 6825, 16140, 6827, 16138, 6829, 16136, 6831, 16134, 6833, 16132, 6835, 16130, 6837, 16128, 6839, 16126, 6841, 16124, 6843, 16122, 6845, 16120, 6847, 16118, 6849, 16116, 6851, 16114, 6853, 16112, 6855, 16110, 6857, 16108, 6859, 16106, 6861, 16104, 6863, 16102, 6865, 16100, 6867, 16098, 6869, 16096, 6871, 16094, 6873, 16092, 6875, 16090, 6877, 16088, 6879, 16086, 6881, 16084, 6883, 16082, 6885, 16080, 6887, 16078, 6889, 16076, 6891, 16074, 6893, 16072, 6895, 16070, 6897, 16068, 6899, 16066, 6901, 16064, 6903, 16062, 6905, 16060, 6907, 16058, 6909, 16056, 6911, 16054, 6913, 16052, 6915, 16050, 6917, 16048, 6919, 16046, 6921, 16044, 6923, 16042, 6925, 16040, 6927, 16038, 6929, 16036, 6931, 16034, 6933, 16032, 6935, 16030, 6937, 16028, 6939, 16026, 6941, 16024, 6943, 16022, 6945, 16020, 6947, 16018, 6949, 16016, 6951, 16014, 6953, 16012, 6955, 16010, 6957, 16008, 6959, 16006, 6961, 16004, 6963, 16002, 6965, 16000, 6967, 15998, 6969, 15996, 6971, 15994, 6973, 15992, 6975, 15990, 6977, 15988, 6979, 15986, 6981, 15984, 6983, 15982, 6985, 15980, 6987, 15978, 6989, 15976, 6991, 15974, 6993, 15972, 6995, 15970, 6997, 15968, 6999, 15966, 7001, 15964, 7003, 15962, 7005, 15960, 7007, 15958, 7009, 15956, 7011, 15954, 7013, 15952, 7015, 15950, 7017, 15948, 7019, 15946, 7021, 15944, 7023, 15942, 7025, 15940, 7027, 15938, 7029, 15936, 7031, 15934, 7033, 15932, 7035, 15930, 7037, 15928, 7039, 15926, 7041, 15924, 7043, 15922, 7045, 15920, 7047, 15918, 7049, 15916, 7051, 15914, 7053, 15912, 7055, 15910, 7057, 15908, 7059, 15906, 7061, 15904, 7063, 15902, 7065, 15900, 7067, 15898, 7069, 15896, 7071, 15894, 7073, 15892, 7075, 15890, 7077, 15888, 7079, 15886, 7081, 15884, 7083, 15882, 7085, 15880, 7087, 15878, 7089, 15876, 7091, 15874, 7093, 15872, 7095, 15870, 7097, 15868, 7099, 15866, 7101, 15864, 7103, 15862, 7105, 15860, 7107, 15858, 7109, 15856, 7111, 15854, 7113, 15852, 7115, 15850, 7117, 15848, 7119, 15846, 7121, 15844, 7123, 15842, 7125, 15840, 7127, 15838, 7129, 15836, 7131, 15834, 7133, 15832, 7135, 15830, 7137, 15828, 7139, 15826, 7141, 15824, 7143, 15822, 7145, 15820, 7147, 15818, 7149, 15816, 7151, 15814, 7153, 15812, 7155, 15810, 7157, 15808, 7159, 15806, 7161, 15804, 7163, 15802, 7165, 15800, 7167, 15798, 7169, 15796, 7171, 15794, 7173, 15792, 7175, 15790, 7177, 15788, 7179, 15786, 7181, 15784, 7183, 15782, 7185, 15780, 7187, 15778, 7189, 15776, 7191, 15774, 7193, 15772, 7195, 15770, 7197, 15768, 7199, 15766, 7201, 15764, 7203, 15762, 7205, 15760, 7207, 15758, 7209, 15756, 7211, 15754, 7213, 15752, 7215, 15750, 7217, 15748, 7219, 15746, 7221, 15744, 7223, 15742, 7225, 15740, 7227, 15738, 7229, 15736, 7231, 15734, 7233, 15732, 7235, 15730, 7237, 15728, 7239, 15726, 7241, 15724, 7243, 15722, 7245, 15720, 7247, 15718, 7249, 15716, 7251, 15714, 7253, 15712, 7255, 15710, 7257, 15708, 7259, 15706, 7261, 15704, 7263, 15702, 7265, 15700, 7267, 15698, 7269, 15696, 7271, 15694, 7273, 15692, 7275, 15690, 7277, 15688, 7279, 15686, 7281, 15684, 7283, 15682, 7285, 15680, 7287, 15678, 7289, 15676, 7291, 15674, 7293, 15672, 7295, 15670, 7297, 15668, 7299, 15666, 7301, 15664, 7303, 15662, 7305, 15660, 7307, 15658, 7309, 15656, 7311, 15654, 7313, 15652, 7315, 15650, 7317, 15648, 7319, 15646, 7321, 15644, 7323, 15642, 7325, 15640, 7327, 15638, 7329, 15636, 7331, 15634, 7333, 15632, 7335, 15630, 7337, 15628, 7339, 15626, 7341, 15624, 7343, 15622, 7345, 15620, 7347, 15618, 7349, 15616, 7351, 15614, 7353, 15612, 7355, 15610, 7357, 15608, 7359, 15606, 7361, 15604, 7363, 15602, 7365, 15600, 7367, 15598, 7369, 15596, 7371, 15594, 7373, 15592, 7375, 15590, 7377, 15588, 7379, 15586, 7381, 15584, 7383, 15582, 7385, 15580, 7387, 15578, 7389, 15576, 7391, 15574, 7393, 15572, 7395, 15570, 7397, 15568, 7399, 15566, 7401, 15564, 7403, 15562, 7405, 15560, 7407, 15558, 7409, 15556, 7411, 15554, 7413, 15552, 7415, 15550, 7417, 15548, 7419, 15546, 7421, 15544, 7423, 15542, 7425, 15540, 7427, 15538, 7429, 15536, 7431, 15534, 7433, 15532, 7435, 15530, 7437, 15528, 7439, 15526, 7441, 15524, 7443, 15522, 7445, 15520, 7447, 15518, 7449, 15516, 7451, 15514, 7453, 15512, 7455, 15510, 7457, 15508, 7459, 15506, 7461, 15504, 7463, 15502, 7465, 15500, 7467, 15498, 7469, 15496, 7471, 15494, 7473, 15492, 7475, 15490, 7477, 15488, 7479, 15486, 7481, 15484, 7483, 15482, 7485, 15480, 7487, 15478, 7489, 15476, 7491, 15474, 7493, 15472, 7495, 15470, 7497, 15468, 7499, 15466, 7501, 15464, 7503, 15462, 7505, 15460, 7507, 15458, 7509, 15456, 7511, 15454, 7513, 15452, 7515, 15450, 7517, 15448, 7519, 15446, 7521, 15444, 7523, 15442, 7525, 15440, 7527, 15438, 7529, 15436, 7531, 15434, 7533, 15432, 7535, 15430, 7537, 15428, 7539, 15426, 7541, 15424, 7543, 15422, 7545, 15420, 7547, 15418, 7549, 15416, 7551, 15414, 7553, 15412, 7555, 15410, 7557, 15408, 7559, 15406, 7561, 15404, 7563, 15402, 7565, 15400, 7567, 15398, 7569, 15396, 7571, 15394, 7573, 15392, 7575, 15390, 7577, 15388, 7579, 15386, 7581, 15384, 7583, 15382, 7585, 15380, 7587, 15378, 7589, 15376, 7591, 15374, 7593, 15372, 7595, 15370, 7597, 15368, 7599, 15366, 7601, 15364, 7603, 15362, 7605, 15360, 7607, 15358, 7609, 15356, 7611, 15354, 7613, 15352, 7615, 15350, 7617, 15348, 7619, 15346, 7621, 15344, 7623, 15342, 7625, 15340, 7627, 15338, 7629, 15336, 7631, 15334, 7633, 15332, 7635, 15330, 7637, 15328, 7639, 15326, 7641, 15324, 7643, 15322, 7645, 15320, 7647, 15318, 7649, 15316, 7651, 15314, 7653, 15312, 7655, 15310, 7657, 15308, 7659, 15306, 7661, 15304, 7663, 15302, 7665, 15300, 7667, 15298, 7669, 15296, 7671, 15294, 7673, 15292, 7675, 15290, 7677, 15288, 7679, 15286, 7681, 15284, 7683, 15282, 7685, 15280, 7687, 15278, 7689, 15276, 7691, 15274, 7693, 15272, 7695, 15270, 7697, 15268, 7699, 15266, 7701, 15264, 7703, 15262, 7705, 15260, 7707, 15258, 7709, 15256, 7711, 15254, 7713, 15252, 7715, 15250, 7717, 15248, 7719, 15246, 7721, 15244, 7723, 15242, 7725, 15240, 7727, 15238, 7729, 15236, 7731, 15234, 7733, 15232, 7735, 15230, 7737, 15228, 7739, 15226, 7741, 15224, 7743, 15222, 7745, 15220, 7747, 15218, 7749, 15216, 7751, 15214, 7753, 15212, 7755, 15210, 7757, 15208, 7759, 15206, 7761, 15204, 7763, 15202, 7765, 15200, 7767, 15198, 7769, 15196, 7771, 15194, 7773, 15192, 7775, 15190, 7777, 15188, 7779, 15186, 7781, 15184, 7783, 15182, 7785, 15180, 7787, 15178, 7789, 15176, 7791, 15174, 7793, 15172, 7795, 15170, 7797, 15168, 7799, 15166, 7801, 15164, 7803, 15162, 7805, 15160, 7807, 15158, 7809, 15156, 7811, 15154, 7813, 15152, 7815, 15150, 7817, 15148, 7819, 15146, 7821, 15144, 7823, 15142, 7825, 15140, 7827, 15138, 7829, 15136, 7831, 15134, 7833, 15132, 7835, 15130, 7837, 15128, 7839, 15126, 7841, 15124, 7843, 15122, 7845, 15120, 7847, 15118, 7849, 15116, 7851, 15114, 7853, 15112, 7855, 15110, 7857, 15108, 7859, 15106, 7861, 15104, 7863, 15102, 7865, 15100, 7867, 15098, 7869, 15096, 7871, 15094, 7873, 15092, 7875, 15090, 7877, 15088, 7879, 15086, 7881, 15084, 7883, 15082, 7885, 15080, 7887, 15078, 7889, 15076, 7891, 15074, 7893, 15072, 7895, 15070, 7897, 15068, 7899, 15066, 7901, 15064, 7903, 15062, 7905, 15060, 7907, 15058, 7909, 15056, 7911, 15054, 7913, 15052, 7915, 15050, 7917, 15048, 7919, 15046, 7921, 15044, 7923, 15042, 7925, 15040, 7927, 15038, 7929, 15036, 7931, 15034, 7933, 15032, 7935, 15030, 7937, 15028, 7939, 15026, 7941, 15024, 7943, 15022, 7945, 15020, 7947, 15018, 7949, 15016, 7951, 15014, 7953, 15012, 7955, 15010, 7957, 15008, 7959, 15006, 7961, 15004, 7963, 15002, 7965, 15000, 7967, 14998, 7969, 14996, 7971, 14994, 7973, 14992, 7975, 14990, 7977, 14988, 7979, 14986, 7981, 14984, 7983, 14982, 7985, 14980, 7987, 14978, 7989, 14976, 7991, 14974, 7993, 14972, 7995, 14970, 7997, 14968, 7999, 14966, 8001, 14964, 8003, 14962, 8005, 14960, 8007, 14958, 8009, 14956, 8011, 14954, 8013, 14952, 8015, 14950, 8017, 14948, 8019, 14946, 8021, 14944, 8023, 14942, 8025, 14940, 8027, 14938, 8029, 14936, 8031, 14934, 8033, 14932, 8035, 14930, 8037, 14928, 8039, 14926, 8041, 14924, 8043, 14922, 8045, 14920, 8047, 14918, 8049, 14916, 8051, 14914, 8053, 14912, 8055, 14910, 8057, 14908, 8059, 14906, 8061, 14904, 8063, 14902, 8065, 14900, 8067, 14898, 8069, 14896, 8071, 14894, 8073, 14892, 8075, 14890, 8077, 14888, 8079, 14886, 8081, 14884, 8083, 14882, 8085, 14880, 8087, 14878, 8089, 14876, 8091, 14874, 8093, 14872, 8095, 14870, 8097, 14868, 8099, 14866, 8101, 14864, 8103, 14862, 8105, 14860, 8107, 14858, 8109, 14856, 8111, 14854, 8113, 14852, 8115, 14850, 8117, 14848, 8119, 14846, 8121, 14844, 8123, 14842, 8125, 14840, 8127, 14838, 8129, 14836, 8131, 14834, 8133, 14832, 8135, 14830, 8137, 14828, 8139, 14826, 8141, 14824, 8143, 14822, 8145, 14820, 8147, 14818, 8149, 14816, 8151, 14814, 8153, 14812, 8155, 14810, 8157, 14808, 8159, 14806, 8161, 14804, 8163, 14802, 8165, 14800, 8167, 14798, 8169, 14796, 8171, 14794, 8173, 14792, 8175, 14790, 8177, 14788, 8179, 14786, 8181, 14784, 8183, 14782, 8185, 14780, 8187, 14778, 8189, 14776, 8191, 14774, 8193, 14772, 8195, 14770, 8197, 14768, 8199, 14766, 8201, 14764, 8203, 14762, 8205, 14760, 8207, 14758, 8209, 14756, 8211, 14754, 8213, 14752, 8215, 14750, 8217, 14748, 8219, 14746, 8221, 14744, 8223, 14742, 8225, 14740, 8227, 14738, 8229, 14736, 8231, 14734, 8233, 14732, 8235, 14730, 8237, 14728, 8239, 14726, 8241, 14724, 8243, 14722, 8245, 14720, 8247, 14718, 8249, 14716, 8251, 14714, 8253, 14712, 8255, 14710, 8257, 14708, 8259, 14706, 8261, 14704, 8263, 14702, 8265, 14700, 8267, 14698, 8269, 14696, 8271, 14694, 8273, 14692, 8275, 14690, 8277, 14688, 8279, 14686, 8281, 14684, 8283, 14682, 8285, 14680, 8287, 14678, 8289, 14676, 8291, 14674, 8293, 14672, 8295, 14670, 8297, 14668, 8299, 14666, 8301, 14664, 8303, 14662, 8305, 14660, 8307, 14658, 8309, 14656, 8311, 14654, 8313, 14652, 8315, 14650, 8317, 14648, 8319, 14646, 8321, 14644, 8323, 14642, 8325, 14640, 8327, 14638, 8329, 14636, 8331, 14634, 8333, 14632, 8335, 14630, 8337, 14628, 8339, 14626, 8341, 14624, 8343, 14622, 8345, 14620, 8347, 14618, 8349, 14616, 8351, 14614, 8353, 14612, 8355, 14610, 8357, 14608, 8359, 14606, 8361, 14604, 8363, 14602, 8365, 14600, 8367, 14598, 8369, 14596, 8371, 14594, 8373, 14592, 8375, 14590, 8377, 14588, 8379, 14586, 8381, 14584, 8383, 14582, 8385, 14580, 8387, 14578, 8389, 14576, 8391, 14574, 8393, 14572, 8395, 14570, 8397, 14568, 8399, 14566, 8401, 14564, 8403, 14562, 8405, 14560, 8407, 14558, 8409, 14556, 8411, 14554, 8413, 14552, 8415, 14550, 8417, 14548, 8419, 14546, 8421, 14544, 8423, 14542, 8425, 14540, 8427, 14538, 8429, 14536, 8431, 14534, 8433, 14532, 8435, 14530, 8437, 14528, 8439, 14526, 8441, 14524, 8443, 14522, 8445, 14520, 8447, 14518, 8449, 14516, 8451, 14514, 8453, 14512, 8455, 14510, 8457, 14508, 8459, 14506, 8461, 14504, 8463, 14502, 8465, 14500, 8467, 14498, 8469, 14496, 8471, 14494, 8473, 14492, 8475, 14490, 8477, 14488, 8479, 14486, 8481, 14484, 8483, 14482, 8485, 14480, 8487, 14478, 8489, 14476, 8491, 14474, 8493, 14472, 8495, 14470, 8497, 14468, 8499, 14466, 8501, 14464, 8503, 14462, 8505, 14460, 8507, 14458, 8509, 14456, 8511, 14454, 8513, 14452, 8515, 14450, 8517, 14448, 8519, 14446, 8521, 14444, 8523, 14442, 8525, 14440, 8527, 14438, 8529, 14436, 8531, 14434, 8533, 14432, 8535, 14430, 8537, 14428, 8539, 14426, 8541, 14424, 8543, 14422, 8545, 14420, 8547, 14418, 8549, 14416, 8551, 14414, 8553, 14412, 8555, 14410, 8557, 14408, 8559, 14406, 8561, 14404, 8563, 14402, 8565, 14400, 8567, 14398, 8569, 14396, 8571, 14394, 8573, 14392, 8575, 14390, 8577, 14388, 8579, 14386, 8581, 14384, 8583, 14382, 8585, 14380, 8587, 14378, 8589, 14376, 8591, 14374, 8593, 14372, 8595, 14370, 8597, 14368, 8599, 14366, 8601, 14364, 8603, 14362, 8605, 14360, 8607, 14358, 8609, 14356, 8611, 14354, 8613, 14352, 8615, 14350, 8617, 14348, 8619, 14346, 8621, 14344, 8623, 14342, 8625, 14340, 8627, 14338, 8629, 14336, 8631, 14334, 8633, 14332, 8635, 14330, 8637, 14328, 8639, 14326, 8641, 14324, 8643, 14322, 8645, 14320, 8647, 14318, 8649, 14316, 8651, 14314, 8653, 14312, 8655, 14310, 8657, 14308, 8659, 14306, 8661, 14304, 8663, 14302, 8665, 14300, 8667, 14298, 8669, 14296, 8671, 14294, 8673, 14292, 8675, 14290, 8677, 14288, 8679, 14286, 8681, 14284, 8683, 14282, 8685, 14280, 8687, 14278, 8689, 14276, 8691, 14274, 8693, 14272, 8695, 14270, 8697, 14268, 8699, 14266, 8701, 14264, 8703, 14262, 8705, 14260, 8707, 14258, 8709, 14256, 8711, 14254, 8713, 14252, 8715, 14250, 8717, 14248, 8719, 14246, 8721, 14244, 8723, 14242, 8725, 14240, 8727, 14238, 8729, 14236, 8731, 14234, 8733, 14232, 8735, 14230, 8737, 14228, 8739, 14226, 8741, 14224, 8743, 14222, 8745, 14220, 8747, 14218, 8749, 14216, 8751, 14214, 8753, 14212, 8755, 14210, 8757, 14208, 8759, 14206, 8761, 14204, 8763, 14202, 8765, 14200, 8767, 14198, 8769, 14196, 8771, 14194, 8773, 14192, 8775, 14190, 8777, 14188, 8779, 14186, 8781, 14184, 8783, 14182, 8785, 14180, 8787, 14178, 8789, 14176, 8791, 14174, 8793, 14172, 8795, 14170, 8797, 14168, 8799, 14166, 8801, 14164, 8803, 14162, 8805, 14160, 8807, 14158, 8809, 14156, 8811, 14154, 8813, 14152, 8815, 14150, 8817, 14148, 8819, 14146, 8821, 14144, 8823, 14142, 8825, 14140, 8827, 14138, 8829, 14136, 8831, 14134, 8833, 14132, 8835, 14130, 8837, 14128, 8839, 14126, 8841, 14124, 8843, 14122, 8845, 14120, 8847, 14118, 8849, 14116, 8851, 14114, 8853, 14112, 8855, 14110, 8857, 14108, 8859, 14106, 8861, 14104, 8863, 14102, 8865, 14100, 8867, 14098, 8869, 14096, 8871, 14094, 8873, 14092, 8875, 14090, 8877, 14088, 8879, 14086, 8881, 14084, 8883, 14082, 8885, 14080, 8887, 14078, 8889, 14076, 8891, 14074, 8893, 14072, 8895, 14070, 8897, 14068, 8899, 14066, 8901, 14064, 8903, 14062, 8905, 14060, 8907, 14058, 8909, 14056, 8911, 14054, 8913, 14052, 8915, 14050, 8917, 14048, 8919, 14046, 8921, 14044, 8923, 14042, 8925, 14040, 8927, 14038, 8929, 14036, 8931, 14034, 8933, 14032, 8935, 14030, 8937, 14028, 8939, 14026, 8941, 14024, 8943, 14022, 8945, 14020, 8947, 14018, 8949, 14016, 8951, 14014, 8953, 14012, 8955, 14010, 8957, 14008, 8959, 14006, 8961, 14004, 8963, 14002, 8965, 14000, 8967, 13998, 8969, 13996, 8971, 13994, 8973, 13992, 8975, 13990, 8977, 13988, 8979, 13986, 8981, 13984, 8983, 13982, 8985, 13980, 8987, 13978, 8989, 13976, 8991, 13974, 8993, 13972, 8995, 13970, 8997, 13968, 8999, 13966, 9001, 13964, 9003, 13962, 9005, 13960, 9007, 13958, 9009, 13956, 9011, 13954, 9013, 13952, 9015, 13950, 9017, 13948, 9019, 13946, 9021, 13944, 9023, 13942, 9025, 13940, 9027, 13938, 9029, 13936, 9031, 13934, 9033, 13932, 9035, 13930, 9037, 13928, 9039, 13926, 9041, 13924, 9043, 13922, 9045, 13920, 9047, 13918, 9049, 13916, 9051, 13914, 9053, 13912, 9055, 13910, 9057, 13908, 9059, 13906, 9061, 13904, 9063, 13902, 9065, 13900, 9067, 13898, 9069, 13896, 9071, 13894, 9073, 13892, 9075, 13890, 9077, 13888, 9079, 13886, 9081, 13884, 9083, 13882, 9085, 13880, 9087, 13878, 9089, 13876, 9091, 13874, 9093, 13872, 9095, 13870, 9097, 13868, 9099, 13866, 9101, 13864, 9103, 13862, 9105, 13860, 9107, 13858, 9109, 13856, 9111, 13854, 9113, 13852, 9115, 13850, 9117, 13848, 9119, 13846, 9121, 13844, 9123, 13842, 9125, 13840, 9127, 13838, 9129, 13836, 9131, 13834, 9133, 13832, 9135, 13830, 9137, 13828, 9139, 13826, 9141, 13824, 9143, 13822, 9145, 13820, 9147, 13818, 9149, 13816, 9151, 13814, 9153, 13812, 9155, 13810, 9157, 13808, 9159, 13806, 9161, 13804, 9163, 13802, 9165, 13800, 9167, 13798, 9169, 13796, 9171, 13794, 9173, 13792, 9175, 13790, 9177, 13788, 9179, 13786, 9181, 13784, 9183, 13782, 9185, 13780, 9187, 13778, 9189, 13776, 9191, 13774, 9193, 13772, 9195, 13770, 9197, 13768, 9199, 13766, 9201, 13764, 9203, 13762, 9205, 13760, 9207, 13758, 9209, 13756, 9211, 13754, 9213, 13752, 9215, 13750, 9217, 13748, 9219, 13746, 9221, 13744, 9223, 13742, 9225, 13740, 9227, 13738, 9229, 13736, 9231, 13734, 9233, 13732, 9235, 13730, 9237, 13728, 9239, 13726, 9241, 13724, 9243, 13722, 9245, 13720, 9247, 13718, 9249, 13716, 9251, 13714, 9253, 13712, 9255, 13710, 9257, 13708, 9259, 13706, 9261, 13704, 9263, 13702, 9265, 13700, 9267, 13698, 9269, 13696, 9271, 13694, 9273, 13692, 9275, 13690, 9277, 13688, 9279, 13686, 9281, 13684, 9283, 13682, 9285, 13680, 9287, 13678, 9289, 13676, 9291, 13674, 9293, 13672, 9295, 13670, 9297, 13668, 9299, 13666, 9301, 13664, 9303, 13662, 9305, 13660, 9307, 13658, 9309, 13656, 9311, 13654, 9313, 13652, 9315, 13650, 9317, 13648, 9319, 13646, 9321, 13644, 9323, 13642, 9325, 13640, 9327, 13638, 9329, 13636, 9331, 13634, 9333, 13632, 9335, 13630, 9337, 13628, 9339, 13626, 9341, 13624, 9343, 13622, 9345, 13620, 9347, 13618, 9349, 13616, 9351, 13614, 9353, 13612, 9355, 13610, 9357, 13608, 9359, 13606, 9361, 13604, 9363, 13602, 9365, 13600, 9367, 13598, 9369, 13596, 9371, 13594, 9373, 13592, 9375, 13590, 9377, 13588, 9379, 13586, 9381, 13584, 9383, 13582, 9385, 13580, 9387, 13578, 9389, 13576, 9391, 13574, 9393, 13572, 9395, 13570, 9397, 13568, 9399, 13566, 9401, 13564, 9403, 13562, 9405, 13560, 9407, 13558, 9409, 13556, 9411, 13554, 9413, 13552, 9415, 13550, 9417, 13548, 9419, 13546, 9421, 13544, 9423, 13542, 9425, 13540, 9427, 13538, 9429, 13536, 9431, 13534, 9433, 13532, 9435, 13530, 9437, 13528, 9439, 13526, 9441, 13524, 9443, 13522, 9445, 13520, 9447, 13518, 9449, 13516, 9451, 13514, 9453, 13512, 9455, 13510, 9457, 13508, 9459, 13506, 9461, 13504, 9463, 13502, 9465, 13500, 9467, 13498, 9469, 13496, 9471, 13494, 9473, 13492, 9475, 13490, 9477, 13488, 9479, 13486, 9481, 13484, 9483, 13482, 9485, 13480, 9487, 13478, 9489, 13476, 9491, 13474, 9493, 13472, 9495, 13470, 9497, 13468, 9499, 13466, 9501, 13464, 9503, 13462, 9505, 13460, 9507, 13458, 9509, 13456, 9511, 13454, 9513, 13452, 9515, 13450, 9517, 13448, 9519, 13446, 9521, 13444, 9523, 13442, 9525, 13440, 9527, 13438, 9529, 13436, 9531, 13434, 9533, 13432, 9535, 13430, 9537, 13428, 9539, 13426, 9541, 13424, 9543, 13422, 9545, 13420, 9547, 13418, 9549, 13416, 9551, 13414, 9553, 13412, 9555, 13410, 9557, 13408, 9559, 13406, 9561, 13404, 9563, 13402, 9565, 13400, 9567, 13398, 9569, 13396, 9571, 13394, 9573, 13392, 9575, 13390, 9577, 13388, 9579, 13386, 9581, 13384, 9583, 13382, 9585, 13380, 9587, 13378, 9589, 13376, 9591, 13374, 9593, 13372, 9595, 13370, 9597, 13368, 9599, 13366, 9601, 13364, 9603, 13362, 9605, 13360, 9607, 13358, 9609, 13356, 9611, 13354, 9613, 13352, 9615, 13350, 9617, 13348, 9619, 13346, 9621, 13344, 9623, 13342, 9625, 13340, 9627, 13338, 9629, 13336, 9631, 13334, 9633, 13332, 9635, 13330, 9637, 13328, 9639, 13326, 9641, 13324, 9643, 13322, 9645, 13320, 9647, 13318, 9649, 13316, 9651, 13314, 9653, 13312, 9655, 13310, 9657, 13308, 9659, 13306, 9661, 13304, 9663, 13302, 9665, 13300, 9667, 13298, 9669, 13296, 9671, 13294, 9673, 13292, 9675, 13290, 9677, 13288, 9679, 13286, 9681, 13284, 9683, 13282, 9685, 13280, 9687, 13278, 9689, 13276, 9691, 13274, 9693, 13272, 9695, 13270, 9697, 13268, 9699, 13266, 9701, 13264, 9703, 13262, 9705, 13260, 9707, 13258, 9709, 13256, 9711, 13254, 9713, 13252, 9715, 13250, 9717, 13248, 9719, 13246, 9721, 13244, 9723, 13242, 9725, 13240, 9727, 13238, 9729, 13236, 9731, 13234, 9733, 13232, 9735, 13230, 9737, 13228, 9739, 13226, 9741, 13224, 9743, 13222, 9745, 13220, 9747, 13218, 9749, 13216, 9751, 13214, 9753, 13212, 9755, 13210, 9757, 13208, 9759, 13206, 9761, 13204, 9763, 13202, 9765, 13200, 9767, 13198, 9769, 13196, 9771, 13194, 9773, 13192, 9775, 13190, 9777, 13188, 9779, 13186, 9781, 13184, 9783, 13182, 9785, 13180, 9787, 13178, 9789, 13176, 9791, 13174, 9793, 13172, 9795, 13170, 9797, 13168, 9799, 13166, 9801, 13164, 9803, 13162, 9805, 13160, 9807, 13158, 9809, 13156, 9811, 13154, 9813, 13152, 9815, 13150, 9817, 13148, 9819, 13146, 9821, 13144, 9823, 13142, 9825, 13140, 9827, 13138, 9829, 13136, 9831, 13134, 9833, 13132, 9835, 13130, 9837, 13128, 9839, 13126, 9841, 13124, 9843, 13122, 9845, 13120, 9847, 13118, 9849, 13116, 9851, 13114, 9853, 13112, 9855, 13110, 9857, 13108, 9859, 13106, 9861, 13104, 9863, 13102, 9865, 13100, 9867, 13098, 9869, 13096, 9871, 13094, 9873, 13092, 9875, 13090, 9877, 13088, 9879, 13086, 9881, 13084, 9883, 13082, 9885, 13080, 9887, 13078, 9889, 13076, 9891, 13074, 9893, 13072, 9895, 13070, 9897, 13068, 9899, 13066, 9901, 13064, 9903, 13062, 9905, 13060, 9907, 13058, 9909, 13056, 9911, 13054, 9913, 13052, 9915, 13050, 9917, 13048, 9919, 13046, 9921, 13044, 9923, 13042, 9925, 13040, 9927, 13038, 9929, 13036, 9931, 13034, 9933, 13032, 9935, 13030, 9937, 13028, 9939, 13026, 9941, 13024, 9943, 13022, 9945, 13020, 9947, 13018, 9949, 13016, 9951, 13014, 9953, 13012, 9955, 13010, 9957, 13008, 9959, 13006, 9961, 13004, 9963, 13002, 9965, 13000, 9967, 12998, 9969, 12996, 9971, 12994, 9973, 12992, 9975, 12990, 9977, 12988, 9979, 12986, 9981, 12984, 9983, 12982, 9985, 12980, 9987, 12978, 9989, 12976, 9991, 12974, 9993, 12972, 9995, 12970, 9997, 12968, 9999, 12966, 10001, 12964, 10003, 12962, 10005, 12960, 10007, 12958, 10009, 12956, 10011, 12954, 10013, 12952, 10015, 12950, 10017, 12948, 10019, 12946, 10021, 12944, 10023, 12942, 10025, 12940, 10027, 12938, 10029, 12936, 10031, 12934, 10033, 12932, 10035, 12930, 10037, 12928, 10039, 12926, 10041, 12924, 10043, 12922, 10045, 12920, 10047, 12918, 10049, 12916, 10051, 12914, 10053, 12912, 10055, 12910, 10057, 12908, 10059, 12906, 10061, 12904, 10063, 12902, 10065, 12900, 10067, 12898, 10069, 12896, 10071, 12894, 10073, 12892, 10075, 12890, 10077, 12888, 10079, 12886, 10081, 12884, 10083, 12882, 10085, 12880, 10087, 12878, 10089, 12876, 10091, 12874, 10093, 12872, 10095, 12870, 10097, 12868, 10099, 12866, 10101, 12864, 10103, 12862, 10105, 12860, 10107, 12858, 10109, 12856, 10111, 12854, 10113, 12852, 10115, 12850, 10117, 12848, 10119, 12846, 10121, 12844, 10123, 12842, 10125, 12840, 10127, 12838, 10129, 12836, 10131, 12834, 10133, 12832, 10135, 12830, 10137, 12828, 10139, 12826, 10141, 12824, 10143, 12822, 10145, 12820, 10147, 12818, 10149, 12816, 10151, 12814, 10153, 12812, 10155, 12810, 10157, 12808, 10159, 12806, 10161, 12804, 10163, 12802, 10165, 12800, 10167, 12798, 10169, 12796, 10171, 12794, 10173, 12792, 10175, 12790, 10177, 12788, 10179, 12786, 10181, 12784, 10183, 12782, 10185, 12780, 10187, 12778, 10189, 12776, 10191, 12774, 10193, 12772, 10195, 12770, 10197, 12768, 10199, 12766, 10201, 12764, 10203, 12762, 10205, 12760, 10207, 12758, 10209, 12756, 10211, 12754, 10213, 12752, 10215, 12750, 10217, 12748, 10219, 12746, 10221, 12744, 10223, 12742, 10225, 12740, 10227, 12738, 10229, 12736, 10231, 12734, 10233, 12732, 10235, 12730, 10237, 12728, 10239, 12726, 10241, 12724, 10243, 12722, 10245, 12720, 10247, 12718, 10249, 12716, 10251, 12714, 10253, 12712, 10255, 12710, 10257, 12708, 10259, 12706, 10261, 12704, 10263, 12702, 10265, 12700, 10267, 12698, 10269, 12696, 10271, 12694, 10273, 12692, 10275, 12690, 10277, 12688, 10279, 12686, 10281, 12684, 10283, 12682, 10285, 12680, 10287, 12678, 10289, 12676, 10291, 12674, 10293, 12672, 10295, 12670, 10297, 12668, 10299, 12666, 10301, 12664, 10303, 12662, 10305, 12660, 10307, 12658, 10309, 12656, 10311, 12654, 10313, 12652, 10315, 12650, 10317, 12648, 10319, 12646, 10321, 12644, 10323, 12642, 10325, 12640, 10327, 12638, 10329, 12636, 10331, 12634, 10333, 12632, 10335, 12630, 10337, 12628, 10339, 12626, 10341, 12624, 10343, 12622, 10345, 12620, 10347, 12618, 10349, 12616, 10351, 12614, 10353, 12612, 10355, 12610, 10357, 12608, 10359, 12606, 10361, 12604, 10363, 12602, 10365, 12600, 10367, 12598, 10369, 12596, 10371, 12594, 10373, 12592, 10375, 12590, 10377, 12588, 10379, 12586, 10381, 12584, 10383, 12582, 10385, 12580, 10387, 12578, 10389, 12576, 10391, 12574, 10393, 12572, 10395, 12570, 10397, 12568, 10399, 12566, 10401, 12564, 10403, 12562, 10405, 12560, 10407, 12558, 10409, 12556, 10411, 12554, 10413, 12552, 10415, 12550, 10417, 12548, 10419, 12546, 10421, 12544, 10423, 12542, 10425, 12540, 10427, 12538, 10429, 12536, 10431, 12534, 10433, 12532, 10435, 12530, 10437, 12528, 10439, 12526, 10441, 12524, 10443, 12522, 10445, 12520, 10447, 12518, 10449, 12516, 10451, 12514, 10453, 12512, 10455, 12510, 10457, 12508, 10459, 12506, 10461, 12504, 10463, 12502, 10465, 12500, 10467, 12498, 10469, 12496, 10471, 12494, 10473, 12492, 10475, 12490, 10477, 12488, 10479, 12486, 10481, 12484, 10483, 12482, 10485, 12480, 10487, 12478, 10489, 12476, 10491, 12474, 10493, 12472, 10495, 12470, 10497, 12468, 10499, 12466, 10501, 12464, 10503, 12462, 10505, 12460, 10507, 12458, 10509, 12456, 10511, 12454, 10513, 12452, 10515, 12450, 10517, 12448, 10519, 12446, 10521, 12444, 10523, 12442, 10525, 12440, 10527, 12438, 10529, 12436, 10531, 12434, 10533, 12432, 10535, 12430, 10537, 12428, 10539, 12426, 10541, 12424, 10543, 12422, 10545, 12420, 10547, 12418, 10549, 12416, 10551, 12414, 10553, 12412, 10555, 12410, 10557, 12408, 10559, 12406, 10561, 12404, 10563, 12402, 10565, 12400, 10567, 12398, 10569, 12396, 10571, 12394, 10573, 12392, 10575, 12390, 10577, 12388, 10579, 12386, 10581, 12384, 10583, 12382, 10585, 12380, 10587, 12378, 10589, 12376, 10591, 12374, 10593, 12372, 10595, 12370, 10597, 12368, 10599, 12366, 10601, 12364, 10603, 12362, 10605, 12360, 10607, 12358, 10609, 12356, 10611, 12354, 10613, 12352, 10615, 12350, 10617, 12348, 10619, 12346, 10621, 12344, 10623, 12342, 10625, 12340, 10627, 12338, 10629, 12336, 10631, 12334, 10633, 12332, 10635, 12330, 10637, 12328, 10639, 12326, 10641, 12324, 10643, 12322, 10645, 12320, 10647, 12318, 10649, 12316, 10651, 12314, 10653, 12312, 10655, 12310, 10657, 12308, 10659, 12306, 10661, 12304, 10663, 12302, 10665, 12300, 10667, 12298, 10669, 12296, 10671, 12294, 10673, 12292, 10675, 12290, 10677, 12288, 10679, 12286, 10681, 12284, 10683, 12282, 10685, 12280, 10687, 12278, 10689, 12276, 10691, 12274, 10693, 12272, 10695, 12270, 10697, 12268, 10699, 12266, 10701, 12264, 10703, 12262, 10705, 12260, 10707, 12258, 10709, 12256, 10711, 12254, 10713, 12252, 10715, 12250, 10717, 12248, 10719, 12246, 10721, 12244, 10723, 12242, 10725, 12240, 10727, 12238, 10729, 12236, 10731, 12234, 10733, 12232, 10735, 12230, 10737, 12228, 10739, 12226, 10741, 12224, 10743, 12222, 10745, 12220, 10747, 12218, 10749, 12216, 10751, 12214, 10753, 12212, 10755, 12210, 10757, 12208, 10759, 12206, 10761, 12204, 10763, 12202, 10765, 12200, 10767, 12198, 10769, 12196, 10771, 12194, 10773, 12192, 10775, 12190, 10777, 12188, 10779, 12186, 10781, 12184, 10783, 12182, 10785, 12180, 10787, 12178, 10789, 12176, 10791, 12174, 10793, 12172, 10795, 12170, 10797, 12168, 10799, 12166, 10801, 12164, 10803, 12162, 10805, 12160, 10807, 12158, 10809, 12156, 10811, 12154, 10813, 12152, 10815, 12150, 10817, 12148, 10819, 12146, 10821, 12144, 10823, 12142, 10825, 12140, 10827, 12138, 10829, 12136, 10831, 12134, 10833, 12132, 10835, 12130, 10837, 12128, 10839, 12126, 10841, 12124, 10843, 12122, 10845, 12120, 10847, 12118, 10849, 12116, 10851, 12114, 10853, 12112, 10855, 12110, 10857, 12108, 10859, 12106, 10861, 12104, 10863, 12102, 10865, 12100, 10867, 12098, 10869, 12096, 10871, 12094, 10873, 12092, 10875, 12090, 10877, 12088, 10879, 12086, 10881, 12084, 10883, 12082, 10885, 12080, 10887, 12078, 10889, 12076, 10891, 12074, 10893, 12072, 10895, 12070, 10897, 12068, 10899, 12066, 10901, 12064, 10903, 12062, 10905, 12060, 10907, 12058, 10909, 12056, 10911, 12054, 10913, 12052, 10915, 12050, 10917, 12048, 10919, 12046, 10921, 12044, 10923, 12042, 10925, 12040, 10927, 12038, 10929, 12036, 10931, 12034, 10933, 12032, 10935, 12030, 10937, 12028, 10939, 12026, 10941, 12024, 10943, 12022, 10945, 12020, 10947, 12018, 10949, 12016, 10951, 12014, 10953, 12012, 10955, 12010, 10957, 12008, 10959, 12006, 10961, 12004, 10963, 12002, 10965, 12000, 10967, 11998, 10969, 11996, 10971, 11994, 10973, 11992, 10975, 11990, 10977, 11988, 10979, 11986, 10981, 11984, 10983, 11982, 10985, 11980, 10987, 11978, 10989, 11976, 10991, 11974, 10993, 11972, 10995, 11970, 10997, 11968, 10999, 11966, 11001, 11964, 11003, 11962, 11005, 11960, 11007, 11958, 11009, 11956, 11011, 11954, 11013, 11952, 11015, 11950, 11017, 11948, 11019, 11946, 11021, 11944, 11023, 11942, 11025, 11940, 11027, 11938, 11029, 11936, 11031, 11934, 11033, 11932, 11035, 11930, 11037, 11928, 11039, 11926, 11041, 11924, 11043, 11922, 11045, 11920, 11047, 11918, 11049, 11916, 11051, 11914, 11053, 11912, 11055, 11910, 11057, 11908, 11059, 11906, 11061, 11904, 11063, 11902, 11065, 11900, 11067, 11898, 11069, 11896, 11071, 11894, 11073, 11892, 11075, 11890, 11077, 11888, 11079, 11886, 11081, 11884, 11083, 11882, 11085, 11880, 11087, 11878, 11089, 11876, 11091, 11874, 11093, 11872, 11095, 11870, 11097, 11868, 11099, 11866, 11101, 11864, 11103, 11862, 11105, 11860, 11107, 11858, 11109, 11856, 11111, 11854, 11113, 11852, 11115, 11850, 11117, 11848, 11119, 11846, 11121, 11844, 11123, 11842, 11125, 11840, 11127, 11838, 11129, 11836, 11131, 11834, 11133, 11832, 11135, 11830, 11137, 11828, 11139, 11826, 11141, 11824, 11143, 11822, 11145, 11820, 11147, 11818, 11149, 11816, 11151, 11814, 11153, 11812, 11155, 11810, 11157, 11808, 11159, 11806, 11161, 11804, 11163, 11802, 11165, 11800, 11167, 11798, 11169, 11796, 11171, 11794, 11173, 11792, 11175, 11790, 11177, 11788, 11179, 11786, 11181, 11784, 11183, 11782, 11185, 11780, 11187, 11778, 11189, 11776, 11191, 11774, 11193, 11772, 11195, 11770, 11197, 11768, 11199, 11766, 11201, 11764, 11203, 11762, 11205, 11760, 11207, 11758, 11209, 11756, 11211, 11754, 11213, 11752, 11215, 11750, 11217, 11748, 11219, 11746, 11221, 11744, 11223, 11742, 11225, 11740, 11227, 11738, 11229, 11736, 11231, 11734, 11233, 11732, 11235, 11730, 11237, 11728, 11239, 11726, 11241, 11724, 11243, 11722, 11245, 11720, 11247, 11718, 11249, 11716, 11251, 11714, 11253, 11712, 11255, 11710, 11257, 11708, 11259, 11706, 11261, 11704, 11263, 11702, 11265, 11700, 11267, 11698, 11269, 11696, 11271, 11694, 11273, 11692, 11275, 11690, 11277, 11688, 11279, 11686, 11281, 11684, 11283, 11682, 11285, 11680, 11287, 11678, 11289, 11676, 11291, 11674, 11293, 11672, 11295, 11670, 11297, 11668, 11299, 11666, 11301, 11664, 11303, 11662, 11305, 11660, 11307, 11658, 11309, 11656, 11311, 11654, 11313, 11652, 11315, 11650, 11317, 11648, 11319, 11646, 11321, 11644, 11323, 11642, 11325, 11640, 11327, 11638, 11329, 11636, 11331, 11634, 11333, 11632, 11335, 11630, 11337, 11628, 11339, 11626, 11341, 11624, 11343, 11622, 11345, 11620, 11347, 11618, 11349, 11616, 11351, 11614, 11353, 11612, 11355, 11610, 11357, 11608, 11359, 11606, 11361, 11604, 11363, 11602, 11365, 11600, 11367, 11598, 11369, 11596, 11371, 11594, 11373, 11592, 11375, 11590, 11377, 11588, 11379, 11586, 11381, 11584, 11383, 11582, 11385, 11580, 11387, 11578, 11389, 11576, 11391, 11574, 11393, 11572, 11395, 11570, 11397, 11568, 11399, 11566, 11401, 11564, 11403, 11562, 11405, 11560, 11407, 11558, 11409, 11556, 11411, 11554, 11413, 11552, 11415, 11550, 11417, 11548, 11419, 11546, 11421, 11544, 11423, 11542, 11425, 11540, 11427, 11538, 11429, 11536, 11431, 11534, 11433, 11532, 11435, 11530, 11437, 11528, 11439, 11526, 11441, 11524, 11443, 11522, 11445, 11520, 11447, 11518, 11449, 11516, 11451, 11514, 11453, 11512, 11455, 11510, 11457, 11508, 11459, 11506, 11461, 11504, 11463, 11502, 11465, 11500, 11467, 11498, 11469, 11496, 11471, 11494, 11473, 11492, 11475, 11490, 11477, 11488, 11479, 11486, 11481, 11484, 11483, 11482, 11485, 11480, 11487, 11478, 11489, 11476, 11491, 11474, 11493, 11472, 11495, 11470, 11497, 11468, 11499, 11466, 11501, 11464, 11503, 11462, 11505, 11460, 11507, 11458, 11509, 11456, 11511, 11454, 11513, 11452, 11515, 11450, 11517, 11448, 11519, 11446, 11521, 11444, 11523, 11442, 11525, 11440, 11527, 11438, 11529, 11436, 11531, 11434, 11533, 11432, 11535, 11430, 11537, 11428, 11539, 11426, 11541, 11424, 11543, 11422, 11545, 11420, 11547, 11418, 11549, 11416, 11551, 11414, 11553, 11412, 11555, 11410, 11557, 11408, 11559, 11406, 11561, 11404, 11563, 11402, 11565, 11400, 11567, 11398, 11569, 11396, 11571, 11394, 11573, 11392, 11575, 11390, 11577, 11388, 11579, 11386, 11581, 11384, 11583, 11382, 11585, 11380, 11587, 11378, 11589, 11376, 11591, 11374, 11593, 11372, 11595, 11370, 11597, 11368, 11599, 11366, 11601, 11364, 11603, 11362, 11605, 11360, 11607, 11358, 11609, 11356, 11611, 11354, 11613, 11352, 11615, 11350, 11617, 11348, 11619, 11346, 11621, 11344, 11623, 11342, 11625, 11340, 11627, 11338, 11629, 11336, 11631, 11334, 11633, 11332, 11635, 11330, 11637, 11328, 11639, 11326, 11641, 11324, 11643, 11322, 11645, 11320, 11647, 11318, 11649, 11316, 11651, 11314, 11653, 11312, 11655, 11310, 11657, 11308, 11659, 11306, 11661, 11304, 11663, 11302, 11665, 11300, 11667, 11298, 11669, 11296, 11671, 11294, 11673, 11292, 11675, 11290, 11677, 11288, 11679, 11286, 11681, 11284, 11683, 11282, 11685, 11280, 11687, 11278, 11689, 11276, 11691, 11274, 11693, 11272, 11695, 11270, 11697, 11268, 11699, 11266, 11701, 11264, 11703, 11262, 11705, 11260, 11707, 11258, 11709, 11256, 11711, 11254, 11713, 11252, 11715, 11250, 11717, 11248, 11719, 11246, 11721, 11244, 11723, 11242, 11725, 11240, 11727, 11238, 11729, 11236, 11731, 11234, 11733, 11232, 11735, 11230, 11737, 11228, 11739, 11226, 11741, 11224, 11743, 11222, 11745, 11220, 11747, 11218, 11749, 11216, 11751, 11214, 11753, 11212, 11755, 11210, 11757, 11208, 11759, 11206, 11761, 11204, 11763, 11202, 11765, 11200, 11767, 11198, 11769, 11196, 11771, 11194, 11773, 11192, 11775, 11190, 11777, 11188, 11779, 11186, 11781, 11184, 11783, 11182, 11785, 11180, 11787, 11178, 11789, 11176, 11791, 11174, 11793, 11172, 11795, 11170, 11797, 11168, 11799, 11166, 11801, 11164, 11803, 11162, 11805, 11160, 11807, 11158, 11809, 11156, 11811, 11154, 11813, 11152, 11815, 11150, 11817, 11148, 11819, 11146, 11821, 11144, 11823, 11142, 11825, 11140, 11827, 11138, 11829, 11136, 11831, 11134, 11833, 11132, 11835, 11130, 11837, 11128, 11839, 11126, 11841, 11124, 11843, 11122, 11845, 11120, 11847, 11118, 11849, 11116, 11851, 11114, 11853, 11112, 11855, 11110, 11857, 11108, 11859, 11106, 11861, 11104, 11863, 11102, 11865, 11100, 11867, 11098, 11869, 11096, 11871, 11094, 11873, 11092, 11875, 11090, 11877, 11088, 11879, 11086, 11881, 11084, 11883, 11082, 11885, 11080, 11887, 11078, 11889, 11076, 11891, 11074, 11893, 11072, 11895, 11070, 11897, 11068, 11899, 11066, 11901, 11064, 11903, 11062, 11905, 11060, 11907, 11058, 11909, 11056, 11911, 11054, 11913, 11052, 11915, 11050, 11917, 11048, 11919, 11046, 11921, 11044, 11923, 11042, 11925, 11040, 11927, 11038, 11929, 11036, 11931, 11034, 11933, 11032, 11935, 11030, 11937, 11028, 11939, 11026, 11941, 11024, 11943, 11022, 11945, 11020, 11947, 11018, 11949, 11016, 11951, 11014, 11953, 11012, 11955, 11010, 11957, 11008, 11959, 11006, 11961, 11004, 11963, 11002, 11965, 11000, 11967, 10998, 11969, 10996, 11971, 10994, 11973, 10992, 11975, 10990, 11977, 10988, 11979, 10986, 11981, 10984, 11983, 10982, 11985, 10980, 11987, 10978, 11989, 10976, 11991, 10974, 11993, 10972, 11995, 10970, 11997, 10968, 11999, 10966, 12001, 10964, 12003, 10962, 12005, 10960, 12007, 10958, 12009, 10956, 12011, 10954, 12013, 10952, 12015, 10950, 12017, 10948, 12019, 10946, 12021, 10944, 12023, 10942, 12025, 10940, 12027, 10938, 12029, 10936, 12031, 10934, 12033, 10932, 12035, 10930, 12037, 10928, 12039, 10926, 12041, 10924, 12043, 10922, 12045, 10920, 12047, 10918, 12049, 10916, 12051, 10914, 12053, 10912, 12055, 10910, 12057, 10908, 12059, 10906, 12061, 10904, 12063, 10902, 12065, 10900, 12067, 10898, 12069, 10896, 12071, 10894, 12073, 10892, 12075, 10890, 12077, 10888, 12079, 10886, 12081, 10884, 12083, 10882, 12085, 10880, 12087, 10878, 12089, 10876, 12091, 10874, 12093, 10872, 12095, 10870, 12097, 10868, 12099, 10866, 12101, 10864, 12103, 10862, 12105, 10860, 12107, 10858, 12109, 10856, 12111, 10854, 12113, 10852, 12115, 10850, 12117, 10848, 12119, 10846, 12121, 10844, 12123, 10842, 12125, 10840, 12127, 10838, 12129, 10836, 12131, 10834, 12133, 10832, 12135, 10830, 12137, 10828, 12139, 10826, 12141, 10824, 12143, 10822, 12145, 10820, 12147, 10818, 12149, 10816, 12151, 10814, 12153, 10812, 12155, 10810, 12157, 10808, 12159, 10806, 12161, 10804, 12163, 10802, 12165, 10800, 12167, 10798, 12169, 10796, 12171, 10794, 12173, 10792, 12175, 10790, 12177, 10788, 12179, 10786, 12181, 10784, 12183, 10782, 12185, 10780, 12187, 10778, 12189, 10776, 12191, 10774, 12193, 10772, 12195, 10770, 12197, 10768, 12199, 10766, 12201, 10764, 12203, 10762, 12205, 10760, 12207, 10758, 12209, 10756, 12211, 10754, 12213, 10752, 12215, 10750, 12217, 10748, 12219, 10746, 12221, 10744, 12223, 10742, 12225, 10740, 12227, 10738, 12229, 10736, 12231, 10734, 12233, 10732, 12235, 10730, 12237, 10728, 12239, 10726, 12241, 10724, 12243, 10722, 12245, 10720, 12247, 10718, 12249, 10716, 12251, 10714, 12253, 10712, 12255, 10710, 12257, 10708, 12259, 10706, 12261, 10704, 12263, 10702, 12265, 10700, 12267, 10698, 12269, 10696, 12271, 10694, 12273, 10692, 12275, 10690, 12277, 10688, 12279, 10686, 12281, 10684, 12283, 10682, 12285, 10680, 12287, 10678, 12289, 10676, 12291, 10674, 12293, 10672, 12295, 10670, 12297, 10668, 12299, 10666, 12301, 10664, 12303, 10662, 12305, 10660, 12307, 10658, 12309, 10656, 12311, 10654, 12313, 10652, 12315, 10650, 12317, 10648, 12319, 10646, 12321, 10644, 12323, 10642, 12325, 10640, 12327, 10638, 12329, 10636, 12331, 10634, 12333, 10632, 12335, 10630, 12337, 10628, 12339, 10626, 12341, 10624, 12343, 10622, 12345, 10620, 12347, 10618, 12349, 10616, 12351, 10614, 12353, 10612, 12355, 10610, 12357, 10608, 12359, 10606, 12361, 10604, 12363, 10602, 12365, 10600, 12367, 10598, 12369, 10596, 12371, 10594, 12373, 10592, 12375, 10590, 12377, 10588, 12379, 10586, 12381, 10584, 12383, 10582, 12385, 10580, 12387, 10578, 12389, 10576, 12391, 10574, 12393, 10572, 12395, 10570, 12397, 10568, 12399, 10566, 12401, 10564, 12403, 10562, 12405, 10560, 12407, 10558, 12409, 10556, 12411, 10554, 12413, 10552, 12415, 10550, 12417, 10548, 12419, 10546, 12421, 10544, 12423, 10542, 12425, 10540, 12427, 10538, 12429, 10536, 12431, 10534, 12433, 10532, 12435, 10530, 12437, 10528, 12439, 10526, 12441, 10524, 12443, 10522, 12445, 10520, 12447, 10518, 12449, 10516, 12451, 10514, 12453, 10512, 12455, 10510, 12457, 10508, 12459, 10506, 12461, 10504, 12463, 10502, 12465, 10500, 12467, 10498, 12469, 10496, 12471, 10494, 12473, 10492, 12475, 10490, 12477, 10488, 12479, 10486, 12481, 10484, 12483, 10482, 12485, 10480, 12487, 10478, 12489, 10476, 12491, 10474, 12493, 10472, 12495, 10470, 12497, 10468, 12499, 10466, 12501, 10464, 12503, 10462, 12505, 10460, 12507, 10458, 12509, 10456, 12511, 10454, 12513, 10452, 12515, 10450, 12517, 10448, 12519, 10446, 12521, 10444, 12523, 10442, 12525, 10440, 12527, 10438, 12529, 10436, 12531, 10434, 12533, 10432, 12535, 10430, 12537, 10428, 12539, 10426, 12541, 10424, 12543, 10422, 12545, 10420, 12547, 10418, 12549, 10416, 12551, 10414, 12553, 10412, 12555, 10410, 12557, 10408, 12559, 10406, 12561, 10404, 12563, 10402, 12565, 10400, 12567, 10398, 12569, 10396, 12571, 10394, 12573, 10392, 12575, 10390, 12577, 10388, 12579, 10386, 12581, 10384, 12583, 10382, 12585, 10380, 12587, 10378, 12589, 10376, 12591, 10374, 12593, 10372, 12595, 10370, 12597, 10368, 12599, 10366, 12601, 10364, 12603, 10362, 12605, 10360, 12607, 10358, 12609, 10356, 12611, 10354, 12613, 10352, 12615, 10350, 12617, 10348, 12619, 10346, 12621, 10344, 12623, 10342, 12625, 10340, 12627, 10338, 12629, 10336, 12631, 10334, 12633, 10332, 12635, 10330, 12637, 10328, 12639, 10326, 12641, 10324, 12643, 10322, 12645, 10320, 12647, 10318, 12649, 10316, 12651, 10314, 12653, 10312, 12655, 10310, 12657, 10308, 12659, 10306, 12661, 10304, 12663, 10302, 12665, 10300, 12667, 10298, 12669, 10296, 12671, 10294, 12673, 10292, 12675, 10290, 12677, 10288, 12679, 10286, 12681, 10284, 12683, 10282, 12685, 10280, 12687, 10278, 12689, 10276, 12691, 10274, 12693, 10272, 12695, 10270, 12697, 10268, 12699, 10266, 12701, 10264, 12703, 10262, 12705, 10260, 12707, 10258, 12709, 10256, 12711, 10254, 12713, 10252, 12715, 10250, 12717, 10248, 12719, 10246, 12721, 10244, 12723, 10242, 12725, 10240, 12727, 10238, 12729, 10236, 12731, 10234, 12733, 10232, 12735, 10230, 12737, 10228, 12739, 10226, 12741, 10224, 12743, 10222, 12745, 10220, 12747, 10218, 12749, 10216, 12751, 10214, 12753, 10212, 12755, 10210, 12757, 10208, 12759, 10206, 12761, 10204, 12763, 10202, 12765, 10200, 12767, 10198, 12769, 10196, 12771, 10194, 12773, 10192, 12775, 10190, 12777, 10188, 12779, 10186, 12781, 10184, 12783, 10182, 12785, 10180, 12787, 10178, 12789, 10176, 12791, 10174, 12793, 10172, 12795, 10170, 12797, 10168, 12799, 10166, 12801, 10164, 12803, 10162, 12805, 10160, 12807, 10158, 12809, 10156, 12811, 10154, 12813, 10152, 12815, 10150, 12817, 10148, 12819, 10146, 12821, 10144, 12823, 10142, 12825, 10140, 12827, 10138, 12829, 10136, 12831, 10134, 12833, 10132, 12835, 10130, 12837, 10128, 12839, 10126, 12841, 10124, 12843, 10122, 12845, 10120, 12847, 10118, 12849, 10116, 12851, 10114, 12853, 10112, 12855, 10110, 12857, 10108, 12859, 10106, 12861, 10104, 12863, 10102, 12865, 10100, 12867, 10098, 12869, 10096, 12871, 10094, 12873, 10092, 12875, 10090, 12877, 10088, 12879, 10086, 12881, 10084, 12883, 10082, 12885, 10080, 12887, 10078, 12889, 10076, 12891, 10074, 12893, 10072, 12895, 10070, 12897, 10068, 12899, 10066, 12901, 10064, 12903, 10062, 12905, 10060, 12907, 10058, 12909, 10056, 12911, 10054, 12913, 10052, 12915, 10050, 12917, 10048, 12919, 10046, 12921, 10044, 12923, 10042, 12925, 10040, 12927, 10038, 12929, 10036, 12931, 10034, 12933, 10032, 12935, 10030, 12937, 10028, 12939, 10026, 12941, 10024, 12943, 10022, 12945, 10020, 12947, 10018, 12949, 10016, 12951, 10014, 12953, 10012, 12955, 10010, 12957, 10008, 12959, 10006, 12961, 10004, 12963, 10002, 12965, 10000, 12967, 9998, 12969, 9996, 12971, 9994, 12973, 9992, 12975, 9990, 12977, 9988, 12979, 9986, 12981, 9984, 12983, 9982, 12985, 9980, 12987, 9978, 12989, 9976, 12991, 9974, 12993, 9972, 12995, 9970, 12997, 9968, 12999, 9966, 13001, 9964, 13003, 9962, 13005, 9960, 13007, 9958, 13009, 9956, 13011, 9954, 13013, 9952, 13015, 9950, 13017, 9948, 13019, 9946, 13021, 9944, 13023, 9942, 13025, 9940, 13027, 9938, 13029, 9936, 13031, 9934, 13033, 9932, 13035, 9930, 13037, 9928, 13039, 9926, 13041, 9924, 13043, 9922, 13045, 9920, 13047, 9918, 13049, 9916, 13051, 9914, 13053, 9912, 13055, 9910, 13057, 9908, 13059, 9906, 13061, 9904, 13063, 9902, 13065, 9900, 13067, 9898, 13069, 9896, 13071, 9894, 13073, 9892, 13075, 9890, 13077, 9888, 13079, 9886, 13081, 9884, 13083, 9882, 13085, 9880, 13087, 9878, 13089, 9876, 13091, 9874, 13093, 9872, 13095, 9870, 13097, 9868, 13099, 9866, 13101, 9864, 13103, 9862, 13105, 9860, 13107, 9858, 13109, 9856, 13111, 9854, 13113, 9852, 13115, 9850, 13117, 9848, 13119, 9846, 13121, 9844, 13123, 9842, 13125, 9840, 13127, 9838, 13129, 9836, 13131, 9834, 13133, 9832, 13135, 9830, 13137, 9828, 13139, 9826, 13141, 9824, 13143, 9822, 13145, 9820, 13147, 9818, 13149, 9816, 13151, 9814, 13153, 9812, 13155, 9810, 13157, 9808, 13159, 9806, 13161, 9804, 13163, 9802, 13165, 9800, 13167, 9798, 13169, 9796, 13171, 9794, 13173, 9792, 13175, 9790, 13177, 9788, 13179, 9786, 13181, 9784, 13183, 9782, 13185, 9780, 13187, 9778, 13189, 9776, 13191, 9774, 13193, 9772, 13195, 9770, 13197, 9768, 13199, 9766, 13201, 9764, 13203, 9762, 13205, 9760, 13207, 9758, 13209, 9756, 13211, 9754, 13213, 9752, 13215, 9750, 13217, 9748, 13219, 9746, 13221, 9744, 13223, 9742, 13225, 9740, 13227, 9738, 13229, 9736, 13231, 9734, 13233, 9732, 13235, 9730, 13237, 9728, 13239, 9726, 13241, 9724, 13243, 9722, 13245, 9720, 13247, 9718, 13249, 9716, 13251, 9714, 13253, 9712, 13255, 9710, 13257, 9708, 13259, 9706, 13261, 9704, 13263, 9702, 13265, 9700, 13267, 9698, 13269, 9696, 13271, 9694, 13273, 9692, 13275, 9690, 13277, 9688, 13279, 9686, 13281, 9684, 13283, 9682, 13285, 9680, 13287, 9678, 13289, 9676, 13291, 9674, 13293, 9672, 13295, 9670, 13297, 9668, 13299, 9666, 13301, 9664, 13303, 9662, 13305, 9660, 13307, 9658, 13309, 9656, 13311, 9654, 13313, 9652, 13315, 9650, 13317, 9648, 13319, 9646, 13321, 9644, 13323, 9642, 13325, 9640, 13327, 9638, 13329, 9636, 13331, 9634, 13333, 9632, 13335, 9630, 13337, 9628, 13339, 9626, 13341, 9624, 13343, 9622, 13345, 9620, 13347, 9618, 13349, 9616, 13351, 9614, 13353, 9612, 13355, 9610, 13357, 9608, 13359, 9606, 13361, 9604, 13363, 9602, 13365, 9600, 13367, 9598, 13369, 9596, 13371, 9594, 13373, 9592, 13375, 9590, 13377, 9588, 13379, 9586, 13381, 9584, 13383, 9582, 13385, 9580, 13387, 9578, 13389, 9576, 13391, 9574, 13393, 9572, 13395, 9570, 13397, 9568, 13399, 9566, 13401, 9564, 13403, 9562, 13405, 9560, 13407, 9558, 13409, 9556, 13411, 9554, 13413, 9552, 13415, 9550, 13417, 9548, 13419, 9546, 13421, 9544, 13423, 9542, 13425, 9540, 13427, 9538, 13429, 9536, 13431, 9534, 13433, 9532, 13435, 9530, 13437, 9528, 13439, 9526, 13441, 9524, 13443, 9522, 13445, 9520, 13447, 9518, 13449, 9516, 13451, 9514, 13453, 9512, 13455, 9510, 13457, 9508, 13459, 9506, 13461, 9504, 13463, 9502, 13465, 9500, 13467, 9498, 13469, 9496, 13471, 9494, 13473, 9492, 13475, 9490, 13477, 9488, 13479, 9486, 13481, 9484, 13483, 9482, 13485, 9480, 13487, 9478, 13489, 9476, 13491, 9474, 13493, 9472, 13495, 9470, 13497, 9468, 13499, 9466, 13501, 9464, 13503, 9462, 13505, 9460, 13507, 9458, 13509, 9456, 13511, 9454, 13513, 9452, 13515, 9450, 13517, 9448, 13519, 9446, 13521, 9444, 13523, 9442, 13525, 9440, 13527, 9438, 13529, 9436, 13531, 9434, 13533, 9432, 13535, 9430, 13537, 9428, 13539, 9426, 13541, 9424, 13543, 9422, 13545, 9420, 13547, 9418, 13549, 9416, 13551, 9414, 13553, 9412, 13555, 9410, 13557, 9408, 13559, 9406, 13561, 9404, 13563, 9402, 13565, 9400, 13567, 9398, 13569, 9396, 13571, 9394, 13573, 9392, 13575, 9390, 13577, 9388, 13579, 9386, 13581, 9384, 13583, 9382, 13585, 9380, 13587, 9378, 13589, 9376, 13591, 9374, 13593, 9372, 13595, 9370, 13597, 9368, 13599, 9366, 13601, 9364, 13603, 9362, 13605, 9360, 13607, 9358, 13609, 9356, 13611, 9354, 13613, 9352, 13615, 9350, 13617, 9348, 13619, 9346, 13621, 9344, 13623, 9342, 13625, 9340, 13627, 9338, 13629, 9336, 13631, 9334, 13633, 9332, 13635, 9330, 13637, 9328, 13639, 9326, 13641, 9324, 13643, 9322, 13645, 9320, 13647, 9318, 13649, 9316, 13651, 9314, 13653, 9312, 13655, 9310, 13657, 9308, 13659, 9306, 13661, 9304, 13663, 9302, 13665, 9300, 13667, 9298, 13669, 9296, 13671, 9294, 13673, 9292, 13675, 9290, 13677, 9288, 13679, 9286, 13681, 9284, 13683, 9282, 13685, 9280, 13687, 9278, 13689, 9276, 13691, 9274, 13693, 9272, 13695, 9270, 13697, 9268, 13699, 9266, 13701, 9264, 13703, 9262, 13705, 9260, 13707, 9258, 13709, 9256, 13711, 9254, 13713, 9252, 13715, 9250, 13717, 9248, 13719, 9246, 13721, 9244, 13723, 9242, 13725, 9240, 13727, 9238, 13729, 9236, 13731, 9234, 13733, 9232, 13735, 9230, 13737, 9228, 13739, 9226, 13741, 9224, 13743, 9222, 13745, 9220, 13747, 9218, 13749, 9216, 13751, 9214, 13753, 9212, 13755, 9210, 13757, 9208, 13759, 9206, 13761, 9204, 13763, 9202, 13765, 9200, 13767, 9198, 13769, 9196, 13771, 9194, 13773, 9192, 13775, 9190, 13777, 9188, 13779, 9186, 13781, 9184, 13783, 9182, 13785, 9180, 13787, 9178, 13789, 9176, 13791, 9174, 13793, 9172, 13795, 9170, 13797, 9168, 13799, 9166, 13801, 9164, 13803, 9162, 13805, 9160, 13807, 9158, 13809, 9156, 13811, 9154, 13813, 9152, 13815, 9150, 13817, 9148, 13819, 9146, 13821, 9144, 13823, 9142, 13825, 9140, 13827, 9138, 13829, 9136, 13831, 9134, 13833, 9132, 13835, 9130, 13837, 9128, 13839, 9126, 13841, 9124, 13843, 9122, 13845, 9120, 13847, 9118, 13849, 9116, 13851, 9114, 13853, 9112, 13855, 9110, 13857, 9108, 13859, 9106, 13861, 9104, 13863, 9102, 13865, 9100, 13867, 9098, 13869, 9096, 13871, 9094, 13873, 9092, 13875, 9090, 13877, 9088, 13879, 9086, 13881, 9084, 13883, 9082, 13885, 9080, 13887, 9078, 13889, 9076, 13891, 9074, 13893, 9072, 13895, 9070, 13897, 9068, 13899, 9066, 13901, 9064, 13903, 9062, 13905, 9060, 13907, 9058, 13909, 9056, 13911, 9054, 13913, 9052, 13915, 9050, 13917, 9048, 13919, 9046, 13921, 9044, 13923, 9042, 13925, 9040, 13927, 9038, 13929, 9036, 13931, 9034, 13933, 9032, 13935, 9030, 13937, 9028, 13939, 9026, 13941, 9024, 13943, 9022, 13945, 9020, 13947, 9018, 13949, 9016, 13951, 9014, 13953, 9012, 13955, 9010, 13957, 9008, 13959, 9006, 13961, 9004, 13963, 9002, 13965, 9000, 13967, 8998, 13969, 8996, 13971, 8994, 13973, 8992, 13975, 8990, 13977, 8988, 13979, 8986, 13981, 8984, 13983, 8982, 13985, 8980, 13987, 8978, 13989, 8976, 13991, 8974, 13993, 8972, 13995, 8970, 13997, 8968, 13999, 8966, 14001, 8964, 14003, 8962, 14005, 8960, 14007, 8958, 14009, 8956, 14011, 8954, 14013, 8952, 14015, 8950, 14017, 8948, 14019, 8946, 14021, 8944, 14023, 8942, 14025, 8940, 14027, 8938, 14029, 8936, 14031, 8934, 14033, 8932, 14035, 8930, 14037, 8928, 14039, 8926, 14041, 8924, 14043, 8922, 14045, 8920, 14047, 8918, 14049, 8916, 14051, 8914, 14053, 8912, 14055, 8910, 14057, 8908, 14059, 8906, 14061, 8904, 14063, 8902, 14065, 8900, 14067, 8898, 14069, 8896, 14071, 8894, 14073, 8892, 14075, 8890, 14077, 8888, 14079, 8886, 14081, 8884, 14083, 8882, 14085, 8880, 14087, 8878, 14089, 8876, 14091, 8874, 14093, 8872, 14095, 8870, 14097, 8868, 14099, 8866, 14101, 8864, 14103, 8862, 14105, 8860, 14107, 8858, 14109, 8856, 14111, 8854, 14113, 8852, 14115, 8850, 14117, 8848, 14119, 8846, 14121, 8844, 14123, 8842, 14125, 8840, 14127, 8838, 14129, 8836, 14131, 8834, 14133, 8832, 14135, 8830, 14137, 8828, 14139, 8826, 14141, 8824, 14143, 8822, 14145, 8820, 14147, 8818, 14149, 8816, 14151, 8814, 14153, 8812, 14155, 8810, 14157, 8808, 14159, 8806, 14161, 8804, 14163, 8802, 14165, 8800, 14167, 8798, 14169, 8796, 14171, 8794, 14173, 8792, 14175, 8790, 14177, 8788, 14179, 8786, 14181, 8784, 14183, 8782, 14185, 8780, 14187, 8778, 14189, 8776, 14191, 8774, 14193, 8772, 14195, 8770, 14197, 8768, 14199, 8766, 14201, 8764, 14203, 8762, 14205, 8760, 14207, 8758, 14209, 8756, 14211, 8754, 14213, 8752, 14215, 8750, 14217, 8748, 14219, 8746, 14221, 8744, 14223, 8742, 14225, 8740, 14227, 8738, 14229, 8736, 14231, 8734, 14233, 8732, 14235, 8730, 14237, 8728, 14239, 8726, 14241, 8724, 14243, 8722, 14245, 8720, 14247, 8718, 14249, 8716, 14251, 8714, 14253, 8712, 14255, 8710, 14257, 8708, 14259, 8706, 14261, 8704, 14263, 8702, 14265, 8700, 14267, 8698, 14269, 8696, 14271, 8694, 14273, 8692, 14275, 8690, 14277, 8688, 14279, 8686, 14281, 8684, 14283, 8682, 14285, 8680, 14287, 8678, 14289, 8676, 14291, 8674, 14293, 8672, 14295, 8670, 14297, 8668, 14299, 8666, 14301, 8664, 14303, 8662, 14305, 8660, 14307, 8658, 14309, 8656, 14311, 8654, 14313, 8652, 14315, 8650, 14317, 8648, 14319, 8646, 14321, 8644, 14323, 8642, 14325, 8640, 14327, 8638, 14329, 8636, 14331, 8634, 14333, 8632, 14335, 8630, 14337, 8628, 14339, 8626, 14341, 8624, 14343, 8622, 14345, 8620, 14347, 8618, 14349, 8616, 14351, 8614, 14353, 8612, 14355, 8610, 14357, 8608, 14359, 8606, 14361, 8604, 14363, 8602, 14365, 8600, 14367, 8598, 14369, 8596, 14371, 8594, 14373, 8592, 14375, 8590, 14377, 8588, 14379, 8586, 14381, 8584, 14383, 8582, 14385, 8580, 14387, 8578, 14389, 8576, 14391, 8574, 14393, 8572, 14395, 8570, 14397, 8568, 14399, 8566, 14401, 8564, 14403, 8562, 14405, 8560, 14407, 8558, 14409, 8556, 14411, 8554, 14413, 8552, 14415, 8550, 14417, 8548, 14419, 8546, 14421, 8544, 14423, 8542, 14425, 8540, 14427, 8538, 14429, 8536, 14431, 8534, 14433, 8532, 14435, 8530, 14437, 8528, 14439, 8526, 14441, 8524, 14443, 8522, 14445, 8520, 14447, 8518, 14449, 8516, 14451, 8514, 14453, 8512, 14455, 8510, 14457, 8508, 14459, 8506, 14461, 8504, 14463, 8502, 14465, 8500, 14467, 8498, 14469, 8496, 14471, 8494, 14473, 8492, 14475, 8490, 14477, 8488, 14479, 8486, 14481, 8484, 14483, 8482, 14485, 8480, 14487, 8478, 14489, 8476, 14491, 8474, 14493, 8472, 14495, 8470, 14497, 8468, 14499, 8466, 14501, 8464, 14503, 8462, 14505, 8460, 14507, 8458, 14509, 8456, 14511, 8454, 14513, 8452, 14515, 8450, 14517, 8448, 14519, 8446, 14521, 8444, 14523, 8442, 14525, 8440, 14527, 8438, 14529, 8436, 14531, 8434, 14533, 8432, 14535, 8430, 14537, 8428, 14539, 8426, 14541, 8424, 14543, 8422, 14545, 8420, 14547, 8418, 14549, 8416, 14551, 8414, 14553, 8412, 14555, 8410, 14557, 8408, 14559, 8406, 14561, 8404, 14563, 8402, 14565, 8400, 14567, 8398, 14569, 8396, 14571, 8394, 14573, 8392, 14575, 8390, 14577, 8388, 14579, 8386, 14581, 8384, 14583, 8382, 14585, 8380, 14587, 8378, 14589, 8376, 14591, 8374, 14593, 8372, 14595, 8370, 14597, 8368, 14599, 8366, 14601, 8364, 14603, 8362, 14605, 8360, 14607, 8358, 14609, 8356, 14611, 8354, 14613, 8352, 14615, 8350, 14617, 8348, 14619, 8346, 14621, 8344, 14623, 8342, 14625, 8340, 14627, 8338, 14629, 8336, 14631, 8334, 14633, 8332, 14635, 8330, 14637, 8328, 14639, 8326, 14641, 8324, 14643, 8322, 14645, 8320, 14647, 8318, 14649, 8316, 14651, 8314, 14653, 8312, 14655, 8310, 14657, 8308, 14659, 8306, 14661, 8304, 14663, 8302, 14665, 8300, 14667, 8298, 14669, 8296, 14671, 8294, 14673, 8292, 14675, 8290, 14677, 8288, 14679, 8286, 14681, 8284, 14683, 8282, 14685, 8280, 14687, 8278, 14689, 8276, 14691, 8274, 14693, 8272, 14695, 8270, 14697, 8268, 14699, 8266, 14701, 8264, 14703, 8262, 14705, 8260, 14707, 8258, 14709, 8256, 14711, 8254, 14713, 8252, 14715, 8250, 14717, 8248, 14719, 8246, 14721, 8244, 14723, 8242, 14725, 8240, 14727, 8238, 14729, 8236, 14731, 8234, 14733, 8232, 14735, 8230, 14737, 8228, 14739, 8226, 14741, 8224, 14743, 8222, 14745, 8220, 14747, 8218, 14749, 8216, 14751, 8214, 14753, 8212, 14755, 8210, 14757, 8208, 14759, 8206, 14761, 8204, 14763, 8202, 14765, 8200, 14767, 8198, 14769, 8196, 14771, 8194, 14773, 8192, 14775, 8190, 14777, 8188, 14779, 8186, 14781, 8184, 14783, 8182, 14785, 8180, 14787, 8178, 14789, 8176, 14791, 8174, 14793, 8172, 14795, 8170, 14797, 8168, 14799, 8166, 14801, 8164, 14803, 8162, 14805, 8160, 14807, 8158, 14809, 8156, 14811, 8154, 14813, 8152, 14815, 8150, 14817, 8148, 14819, 8146, 14821, 8144, 14823, 8142, 14825, 8140, 14827, 8138, 14829, 8136, 14831, 8134, 14833, 8132, 14835, 8130, 14837, 8128, 14839, 8126, 14841, 8124, 14843, 8122, 14845, 8120, 14847, 8118, 14849, 8116, 14851, 8114, 14853, 8112, 14855, 8110, 14857, 8108, 14859, 8106, 14861, 8104, 14863, 8102, 14865, 8100, 14867, 8098, 14869, 8096, 14871, 8094, 14873, 8092, 14875, 8090, 14877, 8088, 14879, 8086, 14881, 8084, 14883, 8082, 14885, 8080, 14887, 8078, 14889, 8076, 14891, 8074, 14893, 8072, 14895, 8070, 14897, 8068, 14899, 8066, 14901, 8064, 14903, 8062, 14905, 8060, 14907, 8058, 14909, 8056, 14911, 8054, 14913, 8052, 14915, 8050, 14917, 8048, 14919, 8046, 14921, 8044, 14923, 8042, 14925, 8040, 14927, 8038, 14929, 8036, 14931, 8034, 14933, 8032, 14935, 8030, 14937, 8028, 14939, 8026, 14941, 8024, 14943, 8022, 14945, 8020, 14947, 8018, 14949, 8016, 14951, 8014, 14953, 8012, 14955, 8010, 14957, 8008, 14959, 8006, 14961, 8004, 14963, 8002, 14965, 8000, 14967, 7998, 14969, 7996, 14971, 7994, 14973, 7992, 14975, 7990, 14977, 7988, 14979, 7986, 14981, 7984, 14983, 7982, 14985, 7980, 14987, 7978, 14989, 7976, 14991, 7974, 14993, 7972, 14995, 7970, 14997, 7968, 14999, 7966, 15001, 7964, 15003, 7962, 15005, 7960, 15007, 7958, 15009, 7956, 15011, 7954, 15013, 7952, 15015, 7950, 15017, 7948, 15019, 7946, 15021, 7944, 15023, 7942, 15025, 7940, 15027, 7938, 15029, 7936, 15031, 7934, 15033, 7932, 15035, 7930, 15037, 7928, 15039, 7926, 15041, 7924, 15043, 7922, 15045, 7920, 15047, 7918, 15049, 7916, 15051, 7914, 15053, 7912, 15055, 7910, 15057, 7908, 15059, 7906, 15061, 7904, 15063, 7902, 15065, 7900, 15067, 7898, 15069, 7896, 15071, 7894, 15073, 7892, 15075, 7890, 15077, 7888, 15079, 7886, 15081, 7884, 15083, 7882, 15085, 7880, 15087, 7878, 15089, 7876, 15091, 7874, 15093, 7872, 15095, 7870, 15097, 7868, 15099, 7866, 15101, 7864, 15103, 7862, 15105, 7860, 15107, 7858, 15109, 7856, 15111, 7854, 15113, 7852, 15115, 7850, 15117, 7848, 15119, 7846, 15121, 7844, 15123, 7842, 15125, 7840, 15127, 7838, 15129, 7836, 15131, 7834, 15133, 7832, 15135, 7830, 15137, 7828, 15139, 7826, 15141, 7824, 15143, 7822, 15145, 7820, 15147, 7818, 15149, 7816, 15151, 7814, 15153, 7812, 15155, 7810, 15157, 7808, 15159, 7806, 15161, 7804, 15163, 7802, 15165, 7800, 15167, 7798, 15169, 7796, 15171, 7794, 15173, 7792, 15175, 7790, 15177, 7788, 15179, 7786, 15181, 7784, 15183, 7782, 15185, 7780, 15187, 7778, 15189, 7776, 15191, 7774, 15193, 7772, 15195, 7770, 15197, 7768, 15199, 7766, 15201, 7764, 15203, 7762, 15205, 7760, 15207, 7758, 15209, 7756, 15211, 7754, 15213, 7752, 15215, 7750, 15217, 7748, 15219, 7746, 15221, 7744, 15223, 7742, 15225, 7740, 15227, 7738, 15229, 7736, 15231, 7734, 15233, 7732, 15235, 7730, 15237, 7728, 15239, 7726, 15241, 7724, 15243, 7722, 15245, 7720, 15247, 7718, 15249, 7716, 15251, 7714, 15253, 7712, 15255, 7710, 15257, 7708, 15259, 7706, 15261, 7704, 15263, 7702, 15265, 7700, 15267, 7698, 15269, 7696, 15271, 7694, 15273, 7692, 15275, 7690, 15277, 7688, 15279, 7686, 15281, 7684, 15283, 7682, 15285, 7680, 15287, 7678, 15289, 7676, 15291, 7674, 15293, 7672, 15295, 7670, 15297, 7668, 15299, 7666, 15301, 7664, 15303, 7662, 15305, 7660, 15307, 7658, 15309, 7656, 15311, 7654, 15313, 7652, 15315, 7650, 15317, 7648, 15319, 7646, 15321, 7644, 15323, 7642, 15325, 7640, 15327, 7638, 15329, 7636, 15331, 7634, 15333, 7632, 15335, 7630, 15337, 7628, 15339, 7626, 15341, 7624, 15343, 7622, 15345, 7620, 15347, 7618, 15349, 7616, 15351, 7614, 15353, 7612, 15355, 7610, 15357, 7608, 15359, 7606, 15361, 7604, 15363, 7602, 15365, 7600, 15367, 7598, 15369, 7596, 15371, 7594, 15373, 7592, 15375, 7590, 15377, 7588, 15379, 7586, 15381, 7584, 15383, 7582, 15385, 7580, 15387, 7578, 15389, 7576, 15391, 7574, 15393, 7572, 15395, 7570, 15397, 7568, 15399, 7566, 15401, 7564, 15403, 7562, 15405, 7560, 15407, 7558, 15409, 7556, 15411, 7554, 15413, 7552, 15415, 7550, 15417, 7548, 15419, 7546, 15421, 7544, 15423, 7542, 15425, 7540, 15427, 7538, 15429, 7536, 15431, 7534, 15433, 7532, 15435, 7530, 15437, 7528, 15439, 7526, 15441, 7524, 15443, 7522, 15445, 7520, 15447, 7518, 15449, 7516, 15451, 7514, 15453, 7512, 15455, 7510, 15457, 7508, 15459, 7506, 15461, 7504, 15463, 7502, 15465, 7500, 15467, 7498, 15469, 7496, 15471, 7494, 15473, 7492, 15475, 7490, 15477, 7488, 15479, 7486, 15481, 7484, 15483, 7482, 15485, 7480, 15487, 7478, 15489, 7476, 15491, 7474, 15493, 7472, 15495, 7470, 15497, 7468, 15499, 7466, 15501, 7464, 15503, 7462, 15505, 7460, 15507, 7458, 15509, 7456, 15511, 7454, 15513, 7452, 15515, 7450, 15517, 7448, 15519, 7446, 15521, 7444, 15523, 7442, 15525, 7440, 15527, 7438, 15529, 7436, 15531, 7434, 15533, 7432, 15535, 7430, 15537, 7428, 15539, 7426, 15541, 7424, 15543, 7422, 15545, 7420, 15547, 7418, 15549, 7416, 15551, 7414, 15553, 7412, 15555, 7410, 15557, 7408, 15559, 7406, 15561, 7404, 15563, 7402, 15565, 7400, 15567, 7398, 15569, 7396, 15571, 7394, 15573, 7392, 15575, 7390, 15577, 7388, 15579, 7386, 15581, 7384, 15583, 7382, 15585, 7380, 15587, 7378, 15589, 7376, 15591, 7374, 15593, 7372, 15595, 7370, 15597, 7368, 15599, 7366, 15601, 7364, 15603, 7362, 15605, 7360, 15607, 7358, 15609, 7356, 15611, 7354, 15613, 7352, 15615, 7350, 15617, 7348, 15619, 7346, 15621, 7344, 15623, 7342, 15625, 7340, 15627, 7338, 15629, 7336, 15631, 7334, 15633, 7332, 15635, 7330, 15637, 7328, 15639, 7326, 15641, 7324, 15643, 7322, 15645, 7320, 15647, 7318, 15649, 7316, 15651, 7314, 15653, 7312, 15655, 7310, 15657, 7308, 15659, 7306, 15661, 7304, 15663, 7302, 15665, 7300, 15667, 7298, 15669, 7296, 15671, 7294, 15673, 7292, 15675, 7290, 15677, 7288, 15679, 7286, 15681, 7284, 15683, 7282, 15685, 7280, 15687, 7278, 15689, 7276, 15691, 7274, 15693, 7272, 15695, 7270, 15697, 7268, 15699, 7266, 15701, 7264, 15703, 7262, 15705, 7260, 15707, 7258, 15709, 7256, 15711, 7254, 15713, 7252, 15715, 7250, 15717, 7248, 15719, 7246, 15721, 7244, 15723, 7242, 15725, 7240, 15727, 7238, 15729, 7236, 15731, 7234, 15733, 7232, 15735, 7230, 15737, 7228, 15739, 7226, 15741, 7224, 15743, 7222, 15745, 7220, 15747, 7218, 15749, 7216, 15751, 7214, 15753, 7212, 15755, 7210, 15757, 7208, 15759, 7206, 15761, 7204, 15763, 7202, 15765, 7200, 15767, 7198, 15769, 7196, 15771, 7194, 15773, 7192, 15775, 7190, 15777, 7188, 15779, 7186, 15781, 7184, 15783, 7182, 15785, 7180, 15787, 7178, 15789, 7176, 15791, 7174, 15793, 7172, 15795, 7170, 15797, 7168, 15799, 7166, 15801, 7164, 15803, 7162, 15805, 7160, 15807, 7158, 15809, 7156, 15811, 7154, 15813, 7152, 15815, 7150, 15817, 7148, 15819, 7146, 15821, 7144, 15823, 7142, 15825, 7140, 15827, 7138, 15829, 7136, 15831, 7134, 15833, 7132, 15835, 7130, 15837, 7128, 15839, 7126, 15841, 7124, 15843, 7122, 15845, 7120, 15847, 7118, 15849, 7116, 15851, 7114, 15853, 7112, 15855, 7110, 15857, 7108, 15859, 7106, 15861, 7104, 15863, 7102, 15865, 7100, 15867, 7098, 15869, 7096, 15871, 7094, 15873, 7092, 15875, 7090, 15877, 7088, 15879, 7086, 15881, 7084, 15883, 7082, 15885, 7080, 15887, 7078, 15889, 7076, 15891, 7074, 15893, 7072, 15895, 7070, 15897, 7068, 15899, 7066, 15901, 7064, 15903, 7062, 15905, 7060, 15907, 7058, 15909, 7056, 15911, 7054, 15913, 7052, 15915, 7050, 15917, 7048, 15919, 7046, 15921, 7044, 15923, 7042, 15925, 7040, 15927, 7038, 15929, 7036, 15931, 7034, 15933, 7032, 15935, 7030, 15937, 7028, 15939, 7026, 15941, 7024, 15943, 7022, 15945, 7020, 15947, 7018, 15949, 7016, 15951, 7014, 15953, 7012, 15955, 7010, 15957, 7008, 15959, 7006, 15961, 7004, 15963, 7002, 15965, 7000, 15967, 6998, 15969, 6996, 15971, 6994, 15973, 6992, 15975, 6990, 15977, 6988, 15979, 6986, 15981, 6984, 15983, 6982, 15985, 6980, 15987, 6978, 15989, 6976, 15991, 6974, 15993, 6972, 15995, 6970, 15997, 6968, 15999, 6966, 16001, 6964, 16003, 6962, 16005, 6960, 16007, 6958, 16009, 6956, 16011, 6954, 16013, 6952, 16015, 6950, 16017, 6948, 16019, 6946, 16021, 6944, 16023, 6942, 16025, 6940, 16027, 6938, 16029, 6936, 16031, 6934, 16033, 6932, 16035, 6930, 16037, 6928, 16039, 6926, 16041, 6924, 16043, 6922, 16045, 6920, 16047, 6918, 16049, 6916, 16051, 6914, 16053, 6912, 16055, 6910, 16057, 6908, 16059, 6906, 16061, 6904, 16063, 6902, 16065, 6900, 16067, 6898, 16069, 6896, 16071, 6894, 16073, 6892, 16075, 6890, 16077, 6888, 16079, 6886, 16081, 6884, 16083, 6882, 16085, 6880, 16087, 6878, 16089, 6876, 16091, 6874, 16093, 6872, 16095, 6870, 16097, 6868, 16099, 6866, 16101, 6864, 16103, 6862, 16105, 6860, 16107, 6858, 16109, 6856, 16111, 6854, 16113, 6852, 16115, 6850, 16117, 6848, 16119, 6846, 16121, 6844, 16123, 6842, 16125, 6840, 16127, 6838, 16129, 6836, 16131, 6834, 16133, 6832, 16135, 6830, 16137, 6828, 16139, 6826, 16141, 6824, 16143, 6822, 16145, 6820, 16147, 6818, 16149, 6816, 16151, 6814, 16153, 6812, 16155, 6810, 16157, 6808, 16159, 6806, 16161, 6804, 16163, 6802, 16165, 6800, 16167, 6798, 16169, 6796, 16171, 6794, 16173, 6792, 16175, 6790, 16177, 6788, 16179, 6786, 16181, 6784, 16183, 6782, 16185, 6780, 16187, 6778, 16189, 6776, 16191, 6774, 16193, 6772, 16195, 6770, 16197, 6768, 16199, 6766, 16201, 6764, 16203, 6762, 16205, 6760, 16207, 6758, 16209, 6756, 16211, 6754, 16213, 6752, 16215, 6750, 16217, 6748, 16219, 6746, 16221, 6744, 16223, 6742, 16225, 6740, 16227, 6738, 16229, 6736, 16231, 6734, 16233, 6732, 16235, 6730, 16237, 6728, 16239, 6726, 16241, 6724, 16243, 6722, 16245, 6720, 16247, 6718, 16249, 6716, 16251, 6714, 16253, 6712, 16255, 6710, 16257, 6708, 16259, 6706, 16261, 6704, 16263, 6702, 16265, 6700, 16267, 6698, 16269, 6696, 16271, 6694, 16273, 6692, 16275, 6690, 16277, 6688, 16279, 6686, 16281, 6684, 16283, 6682, 16285, 6680, 16287, 6678, 16289, 6676, 16291, 6674, 16293, 6672, 16295, 6670, 16297, 6668, 16299, 6666, 16301, 6664, 16303, 6662, 16305, 6660, 16307, 6658, 16309, 6656, 16311, 6654, 16313, 6652, 16315, 6650, 16317, 6648, 16319, 6646, 16321, 6644, 16323, 6642, 16325, 6640, 16327, 6638, 16329, 6636, 16331, 6634, 16333, 6632, 16335, 6630, 16337, 6628, 16339, 6626, 16341, 6624, 16343, 6622, 16345, 6620, 16347, 6618, 16349, 6616, 16351, 6614, 16353, 6612, 16355, 6610, 16357, 6608, 16359, 6606, 16361, 6604, 16363, 6602, 16365, 6600, 16367, 6598, 16369, 6596, 16371, 6594, 16373, 6592, 16375, 6590, 16377, 6588, 16379, 6586, 16381, 6584, 16383, 6582, 16385, 6580, 16387, 6578, 16389, 6576, 16391, 6574, 16393, 6572, 16395, 6570, 16397, 6568, 16399, 6566, 16401, 6564, 16403, 6562, 16405, 6560, 16407, 6558, 16409, 6556, 16411, 6554, 16413, 6552, 16415, 6550, 16417, 6548, 16419, 6546, 16421, 6544, 16423, 6542, 16425, 6540, 16427, 6538, 16429, 6536, 16431, 6534, 16433, 6532, 16435, 6530, 16437, 6528, 16439, 6526, 16441, 6524, 16443, 6522, 16445, 6520, 16447, 6518, 16449, 6516, 16451, 6514, 16453, 6512, 16455, 6510, 16457, 6508, 16459, 6506, 16461, 6504, 16463, 6502, 16465, 6500, 16467, 6498, 16469, 6496, 16471, 6494, 16473, 6492, 16475, 6490, 16477, 6488, 16479, 6486, 16481, 6484, 16483, 6482, 16485, 6480, 16487, 6478, 16489, 6476, 16491, 6474, 16493, 6472, 16495, 6470, 16497, 6468, 16499, 6466, 16501, 6464, 16503, 6462, 16505, 6460, 16507, 6458, 16509, 6456, 16511, 6454, 16513, 6452, 16515, 6450, 16517, 6448, 16519, 6446, 16521, 6444, 16523, 6442, 16525, 6440, 16527, 6438, 16529, 6436, 16531, 6434, 16533, 6432, 16535, 6430, 16537, 6428, 16539, 6426, 16541, 6424, 16543, 6422, 16545, 6420, 16547, 6418, 16549, 6416, 16551, 6414, 16553, 6412, 16555, 6410, 16557, 6408, 16559, 6406, 16561, 6404, 16563, 6402, 16565, 6400, 16567, 6398, 16569, 6396, 16571, 6394, 16573, 6392, 16575, 6390, 16577, 6388, 16579, 6386, 16581, 6384, 16583, 6382, 16585, 6380, 16587, 6378, 16589, 6376, 16591, 6374, 16593, 6372, 16595, 6370, 16597, 6368, 16599, 6366, 16601, 6364, 16603, 6362, 16605, 6360, 16607, 6358, 16609, 6356, 16611, 6354, 16613, 6352, 16615, 6350, 16617, 6348, 16619, 6346, 16621, 6344, 16623, 6342, 16625, 6340, 16627, 6338, 16629, 6336, 16631, 6334, 16633, 6332, 16635, 6330, 16637, 6328, 16639, 6326, 16641, 6324, 16643, 6322, 16645, 6320, 16647, 6318, 16649, 6316, 16651, 6314, 16653, 6312, 16655, 6310, 16657, 6308, 16659, 6306, 16661, 6304, 16663, 6302, 16665, 6300, 16667, 6298, 16669, 6296, 16671, 6294, 16673, 6292, 16675, 6290, 16677, 6288, 16679, 6286, 16681, 6284, 16683, 6282, 16685, 6280, 16687, 6278, 16689, 6276, 16691, 6274, 16693, 6272, 16695, 6270, 16697, 6268, 16699, 6266, 16701, 6264, 16703, 6262, 16705, 6260, 16707, 6258, 16709, 6256, 16711, 6254, 16713, 6252, 16715, 6250, 16717, 6248, 16719, 6246, 16721, 6244, 16723, 6242, 16725, 6240, 16727, 6238, 16729, 6236, 16731, 6234, 16733, 6232, 16735, 6230, 16737, 6228, 16739, 6226, 16741, 6224, 16743, 6222, 16745, 6220, 16747, 6218, 16749, 6216, 16751, 6214, 16753, 6212, 16755, 6210, 16757, 6208, 16759, 6206, 16761, 6204, 16763, 6202, 16765, 6200, 16767, 6198, 16769, 6196, 16771, 6194, 16773, 6192, 16775, 6190, 16777, 6188, 16779, 6186, 16781, 6184, 16783, 6182, 16785, 6180, 16787, 6178, 16789, 6176, 16791, 6174, 16793, 6172, 16795, 6170, 16797, 6168, 16799, 6166, 16801, 6164, 16803, 6162, 16805, 6160, 16807, 6158, 16809, 6156, 16811, 6154, 16813, 6152, 16815, 6150, 16817, 6148, 16819, 6146, 16821, 6144, 16823, 6142, 16825, 6140, 16827, 6138, 16829, 6136, 16831, 6134, 16833, 6132, 16835, 6130, 16837, 6128, 16839, 6126, 16841, 6124, 16843, 6122, 16845, 6120, 16847, 6118, 16849, 6116, 16851, 6114, 16853, 6112, 16855, 6110, 16857, 6108, 16859, 6106, 16861, 6104, 16863, 6102, 16865, 6100, 16867, 6098, 16869, 6096, 16871, 6094, 16873, 6092, 16875, 6090, 16877, 6088, 16879, 6086, 16881, 6084, 16883, 6082, 16885, 6080, 16887, 6078, 16889, 6076, 16891, 6074, 16893, 6072, 16895, 6070, 16897, 6068, 16899, 6066, 16901, 6064, 16903, 6062, 16905, 6060, 16907, 6058, 16909, 6056, 16911, 6054, 16913, 6052, 16915, 6050, 16917, 6048, 16919, 6046, 16921, 6044, 16923, 6042, 16925, 6040, 16927, 6038, 16929, 6036, 16931, 6034, 16933, 6032, 16935, 6030, 16937, 6028, 16939, 6026, 16941, 6024, 16943, 6022, 16945, 6020, 16947, 6018, 16949, 6016, 16951, 6014, 16953, 6012, 16955, 6010, 16957, 6008, 16959, 6006, 16961, 6004, 16963, 6002, 16965, 6000, 16967, 5998, 16969, 5996, 16971, 5994, 16973, 5992, 16975, 5990, 16977, 5988, 16979, 5986, 16981, 5984, 16983, 5982, 16985, 5980, 16987, 5978, 16989, 5976, 16991, 5974, 16993, 5972, 16995, 5970, 16997, 5968, 16999, 5966, 17001, 5964, 17003, 5962, 17005, 5960, 17007, 5958, 17009, 5956, 17011, 5954, 17013, 5952, 17015, 5950, 17017, 5948, 17019, 5946, 17021, 5944, 17023, 5942, 17025, 5940, 17027, 5938, 17029, 5936, 17031, 5934, 17033, 5932, 17035, 5930, 17037, 5928, 17039, 5926, 17041, 5924, 17043, 5922, 17045, 5920, 17047, 5918, 17049, 5916, 17051, 5914, 17053, 5912, 17055, 5910, 17057, 5908, 17059, 5906, 17061, 5904, 17063, 5902, 17065, 5900, 17067, 5898, 17069, 5896, 17071, 5894, 17073, 5892, 17075, 5890, 17077, 5888, 17079, 5886, 17081, 5884, 17083, 5882, 17085, 5880, 17087, 5878, 17089, 5876, 17091, 5874, 17093, 5872, 17095, 5870, 17097, 5868, 17099, 5866, 17101, 5864, 17103, 5862, 17105, 5860, 17107, 5858, 17109, 5856, 17111, 5854, 17113, 5852, 17115, 5850, 17117, 5848, 17119, 5846, 17121, 5844, 17123, 5842, 17125, 5840, 17127, 5838, 17129, 5836, 17131, 5834, 17133, 5832, 17135, 5830, 17137, 5828, 17139, 5826, 17141, 5824, 17143, 5822, 17145, 5820, 17147, 5818, 17149, 5816, 17151, 5814, 17153, 5812, 17155, 5810, 17157, 5808, 17159, 5806, 17161, 5804, 17163, 5802, 17165, 5800, 17167, 5798, 17169, 5796, 17171, 5794, 17173, 5792, 17175, 5790, 17177, 5788, 17179, 5786, 17181, 5784, 17183, 5782, 17185, 5780, 17187, 5778, 17189, 5776, 17191, 5774, 17193, 5772, 17195, 5770, 17197, 5768, 17199, 5766, 17201, 5764, 17203, 5762, 17205, 5760, 17207, 5758, 17209, 5756, 17211, 5754, 17213, 5752, 17215, 5750, 17217, 5748, 17219, 5746, 17221, 5744, 17223, 5742, 17225, 5740, 17227, 5738, 17229, 5736, 17231, 5734, 17233, 5732, 17235, 5730, 17237, 5728, 17239, 5726, 17241, 5724, 17243, 5722, 17245, 5720, 17247, 5718, 17249, 5716, 17251, 5714, 17253, 5712, 17255, 5710, 17257, 5708, 17259, 5706, 17261, 5704, 17263, 5702, 17265, 5700, 17267, 5698, 17269, 5696, 17271, 5694, 17273, 5692, 17275, 5690, 17277, 5688, 17279, 5686, 17281, 5684, 17283, 5682, 17285, 5680, 17287, 5678, 17289, 5676, 17291, 5674, 17293, 5672, 17295, 5670, 17297, 5668, 17299, 5666, 17301, 5664, 17303, 5662, 17305, 5660, 17307, 5658, 17309, 5656, 17311, 5654, 17313, 5652, 17315, 5650, 17317, 5648, 17319, 5646, 17321, 5644, 17323, 5642, 17325, 5640, 17327, 5638, 17329, 5636, 17331, 5634, 17333, 5632, 17335, 5630, 17337, 5628, 17339, 5626, 17341, 5624, 17343, 5622, 17345, 5620, 17347, 5618, 17349, 5616, 17351, 5614, 17353, 5612, 17355, 5610, 17357, 5608, 17359, 5606, 17361, 5604, 17363, 5602, 17365, 5600, 17367, 5598, 17369, 5596, 17371, 5594, 17373, 5592, 17375, 5590, 17377, 5588, 17379, 5586, 17381, 5584, 17383, 5582, 17385, 5580, 17387, 5578, 17389, 5576, 17391, 5574, 17393, 5572, 17395, 5570, 17397, 5568, 17399, 5566, 17401, 5564, 17403, 5562, 17405, 5560, 17407, 5558, 17409, 5556, 17411, 5554, 17413, 5552, 17415, 5550, 17417, 5548, 17419, 5546, 17421, 5544, 17423, 5542, 17425, 5540, 17427, 5538, 17429, 5536, 17431, 5534, 17433, 5532, 17435, 5530, 17437, 5528, 17439, 5526, 17441, 5524, 17443, 5522, 17445, 5520, 17447, 5518, 17449, 5516, 17451, 5514, 17453, 5512, 17455, 5510, 17457, 5508, 17459, 5506, 17461, 5504, 17463, 5502, 17465, 5500, 17467, 5498, 17469, 5496, 17471, 5494, 17473, 5492, 17475, 5490, 17477, 5488, 17479, 5486, 17481, 5484, 17483, 5482, 17485, 5480, 17487, 5478, 17489, 5476, 17491, 5474, 17493, 5472, 17495, 5470, 17497, 5468, 17499, 5466, 17501, 5464, 17503, 5462, 17505, 5460, 17507, 5458, 17509, 5456, 17511, 5454, 17513, 5452, 17515, 5450, 17517, 5448, 17519, 5446, 17521, 5444, 17523, 5442, 17525, 5440, 17527, 5438, 17529, 5436, 17531, 5434, 17533, 5432, 17535, 5430, 17537, 5428, 17539, 5426, 17541, 5424, 17543, 5422, 17545, 5420, 17547, 5418, 17549, 5416, 17551, 5414, 17553, 5412, 17555, 5410, 17557, 5408, 17559, 5406, 17561, 5404, 17563, 5402, 17565, 5400, 17567, 5398, 17569, 5396, 17571, 5394, 17573, 5392, 17575, 5390, 17577, 5388, 17579, 5386, 17581, 5384, 17583, 5382, 17585, 5380, 17587, 5378, 17589, 5376, 17591, 5374, 17593, 5372, 17595, 5370, 17597, 5368, 17599, 5366, 17601, 5364, 17603, 5362, 17605, 5360, 17607, 5358, 17609, 5356, 17611, 5354, 17613, 5352, 17615, 5350, 17617, 5348, 17619, 5346, 17621, 5344, 17623, 5342, 17625, 5340, 17627, 5338, 17629, 5336, 17631, 5334, 17633, 5332, 17635, 5330, 17637, 5328, 17639, 5326, 17641, 5324, 17643, 5322, 17645, 5320, 17647, 5318, 17649, 5316, 17651, 5314, 17653, 5312, 17655, 5310, 17657, 5308, 17659, 5306, 17661, 5304, 17663, 5302, 17665, 5300, 17667, 5298, 17669, 5296, 17671, 5294, 17673, 5292, 17675, 5290, 17677, 5288, 17679, 5286, 17681, 5284, 17683, 5282, 17685, 5280, 17687, 5278, 17689, 5276, 17691, 5274, 17693, 5272, 17695, 5270, 17697, 5268, 17699, 5266, 17701, 5264, 17703, 5262, 17705, 5260, 17707, 5258, 17709, 5256, 17711, 5254, 17713, 5252, 17715, 5250, 17717, 5248, 17719, 5246, 17721, 5244, 17723, 5242, 17725, 5240, 17727, 5238, 17729, 5236, 17731, 5234, 17733, 5232, 17735, 5230, 17737, 5228, 17739, 5226, 17741, 5224, 17743, 5222, 17745, 5220, 17747, 5218, 17749, 5216, 17751, 5214, 17753, 5212, 17755, 5210, 17757, 5208, 17759, 5206, 17761, 5204, 17763, 5202, 17765, 5200, 17767, 5198, 17769, 5196, 17771, 5194, 17773, 5192, 17775, 5190, 17777, 5188, 17779, 5186, 17781, 5184, 17783, 5182, 17785, 5180, 17787, 5178, 17789, 5176, 17791, 5174, 17793, 5172, 17795, 5170, 17797, 5168, 17799, 5166, 17801, 5164, 17803, 5162, 17805, 5160, 17807, 5158, 17809, 5156, 17811, 5154, 17813, 5152, 17815, 5150, 17817, 5148, 17819, 5146, 17821, 5144, 17823, 5142, 17825, 5140, 17827, 5138, 17829, 5136, 17831, 5134, 17833, 5132, 17835, 5130, 17837, 5128, 17839, 5126, 17841, 5124, 17843, 5122, 17845, 5120, 17847, 5118, 17849, 5116, 17851, 5114, 17853, 5112, 17855, 5110, 17857, 5108, 17859, 5106, 17861, 5104, 17863, 5102, 17865, 5100, 17867, 5098, 17869, 5096, 17871, 5094, 17873, 5092, 17875, 5090, 17877, 5088, 17879, 5086, 17881, 5084, 17883, 5082, 17885, 5080, 17887, 5078, 17889, 5076, 17891, 5074, 17893, 5072, 17895, 5070, 17897, 5068, 17899, 5066, 17901, 5064, 17903, 5062, 17905, 5060, 17907, 5058, 17909, 5056, 17911, 5054, 17913, 5052, 17915, 5050, 17917, 5048, 17919, 5046, 17921, 5044, 17923, 5042, 17925, 5040, 17927, 5038, 17929, 5036, 17931, 5034, 17933, 5032, 17935, 5030, 17937, 5028, 17939, 5026, 17941, 5024, 17943, 5022, 17945, 5020, 17947, 5018, 17949, 5016, 17951, 5014, 17953, 5012, 17955, 5010, 17957, 5008, 17959, 5006, 17961, 5004, 17963, 5002, 17965, 5000, 17967, 4998, 17969, 4996, 17971, 4994, 17973, 4992, 17975, 4990, 17977, 4988, 17979, 4986, 17981, 4984, 17983, 4982, 17985, 4980, 17987, 4978, 17989, 4976, 17991, 4974, 17993, 4972, 17995, 4970, 17997, 4968, 17999, 4966, 18001, 4964, 18003, 4962, 18005, 4960, 18007, 4958, 18009, 4956, 18011, 4954, 18013, 4952, 18015, 4950, 18017, 4948, 18019, 4946, 18021, 4944, 18023, 4942, 18025, 4940, 18027, 4938, 18029, 4936, 18031, 4934, 18033, 4932, 18035, 4930, 18037, 4928, 18039, 4926, 18041, 4924, 18043, 4922, 18045, 4920, 18047, 4918, 18049, 4916, 18051, 4914, 18053, 4912, 18055, 4910, 18057, 4908, 18059, 4906, 18061, 4904, 18063, 4902, 18065, 4900, 18067, 4898, 18069, 4896, 18071, 4894, 18073, 4892, 18075, 4890, 18077, 4888, 18079, 4886, 18081, 4884, 18083, 4882, 18085, 4880, 18087, 4878, 18089, 4876, 18091, 4874, 18093, 4872, 18095, 4870, 18097, 4868, 18099, 4866, 18101, 4864, 18103, 4862, 18105, 4860, 18107, 4858, 18109, 4856, 18111, 4854, 18113, 4852, 18115, 4850, 18117, 4848, 18119, 4846, 18121, 4844, 18123, 4842, 18125, 4840, 18127, 4838, 18129, 4836, 18131, 4834, 18133, 4832, 18135, 4830, 18137, 4828, 18139, 4826, 18141, 4824, 18143, 4822, 18145, 4820, 18147, 4818, 18149, 4816, 18151, 4814, 18153, 4812, 18155, 4810, 18157, 4808, 18159, 4806, 18161, 4804, 18163, 4802, 18165, 4800, 18167, 4798, 18169, 4796, 18171, 4794, 18173, 4792, 18175, 4790, 18177, 4788, 18179, 4786, 18181, 4784, 18183, 4782, 18185, 4780, 18187, 4778, 18189, 4776, 18191, 4774, 18193, 4772, 18195, 4770, 18197, 4768, 18199, 4766, 18201, 4764, 18203, 4762, 18205, 4760, 18207, 4758, 18209, 4756, 18211, 4754, 18213, 4752, 18215, 4750, 18217, 4748, 18219, 4746, 18221, 4744, 18223, 4742, 18225, 4740, 18227, 4738, 18229, 4736, 18231, 4734, 18233, 4732, 18235, 4730, 18237, 4728, 18239, 4726, 18241, 4724, 18243, 4722, 18245, 4720, 18247, 4718, 18249, 4716, 18251, 4714, 18253, 4712, 18255, 4710, 18257, 4708, 18259, 4706, 18261, 4704, 18263, 4702, 18265, 4700, 18267, 4698, 18269, 4696, 18271, 4694, 18273, 4692, 18275, 4690, 18277, 4688, 18279, 4686, 18281, 4684, 18283, 4682, 18285, 4680, 18287, 4678, 18289, 4676, 18291, 4674, 18293, 4672, 18295, 4670, 18297, 4668, 18299, 4666, 18301, 4664, 18303, 4662, 18305, 4660, 18307, 4658, 18309, 4656, 18311, 4654, 18313, 4652, 18315, 4650, 18317, 4648, 18319, 4646, 18321, 4644, 18323, 4642, 18325, 4640, 18327, 4638, 18329, 4636, 18331, 4634, 18333, 4632, 18335, 4630, 18337, 4628, 18339, 4626, 18341, 4624, 18343, 4622, 18345, 4620, 18347, 4618, 18349, 4616, 18351, 4614, 18353, 4612, 18355, 4610, 18357, 4608, 18359, 4606, 18361, 4604, 18363, 4602, 18365, 4600, 18367, 4598, 18369, 4596, 18371, 4594, 18373, 4592, 18375, 4590, 18377, 4588, 18379, 4586, 18381, 4584, 18383, 4582, 18385, 4580, 18387, 4578, 18389, 4576, 18391, 4574, 18393, 4572, 18395, 4570, 18397, 4568, 18399, 4566, 18401, 4564, 18403, 4562, 18405, 4560, 18407, 4558, 18409, 4556, 18411, 4554, 18413, 4552, 18415, 4550, 18417, 4548, 18419, 4546, 18421, 4544, 18423, 4542, 18425, 4540, 18427, 4538, 18429, 4536, 18431, 4534, 18433, 4532, 18435, 4530, 18437, 4528, 18439, 4526, 18441, 4524, 18443, 4522, 18445, 4520, 18447, 4518, 18449, 4516, 18451, 4514, 18453, 4512, 18455, 4510, 18457, 4508, 18459, 4506, 18461, 4504, 18463, 4502, 18465, 4500, 18467, 4498, 18469, 4496, 18471, 4494, 18473, 4492, 18475, 4490, 18477, 4488, 18479, 4486, 18481, 4484, 18483, 4482, 18485, 4480, 18487, 4478, 18489, 4476, 18491, 4474, 18493, 4472, 18495, 4470, 18497, 4468, 18499, 4466, 18501, 4464, 18503, 4462, 18505, 4460, 18507, 4458, 18509, 4456, 18511, 4454, 18513, 4452, 18515, 4450, 18517, 4448, 18519, 4446, 18521, 4444, 18523, 4442, 18525, 4440, 18527, 4438, 18529, 4436, 18531, 4434, 18533, 4432, 18535, 4430, 18537, 4428, 18539, 4426, 18541, 4424, 18543, 4422, 18545, 4420, 18547, 4418, 18549, 4416, 18551, 4414, 18553, 4412, 18555, 4410, 18557, 4408, 18559, 4406, 18561, 4404, 18563, 4402, 18565, 4400, 18567, 4398, 18569, 4396, 18571, 4394, 18573, 4392, 18575, 4390, 18577, 4388, 18579, 4386, 18581, 4384, 18583, 4382, 18585, 4380, 18587, 4378, 18589, 4376, 18591, 4374, 18593, 4372, 18595, 4370, 18597, 4368, 18599, 4366, 18601, 4364, 18603, 4362, 18605, 4360, 18607, 4358, 18609, 4356, 18611, 4354, 18613, 4352, 18615, 4350, 18617, 4348, 18619, 4346, 18621, 4344, 18623, 4342, 18625, 4340, 18627, 4338, 18629, 4336, 18631, 4334, 18633, 4332, 18635, 4330, 18637, 4328, 18639, 4326, 18641, 4324, 18643, 4322, 18645, 4320, 18647, 4318, 18649, 4316, 18651, 4314, 18653, 4312, 18655, 4310, 18657, 4308, 18659, 4306, 18661, 4304, 18663, 4302, 18665, 4300, 18667, 4298, 18669, 4296, 18671, 4294, 18673, 4292, 18675, 4290, 18677, 4288, 18679, 4286, 18681, 4284, 18683, 4282, 18685, 4280, 18687, 4278, 18689, 4276, 18691, 4274, 18693, 4272, 18695, 4270, 18697, 4268, 18699, 4266, 18701, 4264, 18703, 4262, 18705, 4260, 18707, 4258, 18709, 4256, 18711, 4254, 18713, 4252, 18715, 4250, 18717, 4248, 18719, 4246, 18721, 4244, 18723, 4242, 18725, 4240, 18727, 4238, 18729, 4236, 18731, 4234, 18733, 4232, 18735, 4230, 18737, 4228, 18739, 4226, 18741, 4224, 18743, 4222, 18745, 4220, 18747, 4218, 18749, 4216, 18751, 4214, 18753, 4212, 18755, 4210, 18757, 4208, 18759, 4206, 18761, 4204, 18763, 4202, 18765, 4200, 18767, 4198, 18769, 4196, 18771, 4194, 18773, 4192, 18775, 4190, 18777, 4188, 18779, 4186, 18781, 4184, 18783, 4182, 18785, 4180, 18787, 4178, 18789, 4176, 18791, 4174, 18793, 4172, 18795, 4170, 18797, 4168, 18799, 4166, 18801, 4164, 18803, 4162, 18805, 4160, 18807, 4158, 18809, 4156, 18811, 4154, 18813, 4152, 18815, 4150, 18817, 4148, 18819, 4146, 18821, 4144, 18823, 4142, 18825, 4140, 18827, 4138, 18829, 4136, 18831, 4134, 18833, 4132, 18835, 4130, 18837, 4128, 18839, 4126, 18841, 4124, 18843, 4122, 18845, 4120, 18847, 4118, 18849, 4116, 18851, 4114, 18853, 4112, 18855, 4110, 18857, 4108, 18859, 4106, 18861, 4104, 18863, 4102, 18865, 4100, 18867, 4098, 18869, 4096, 18871, 4094, 18873, 4092, 18875, 4090, 18877, 4088, 18879, 4086, 18881, 4084, 18883, 4082, 18885, 4080, 18887, 4078, 18889, 4076, 18891, 4074, 18893, 4072, 18895, 4070, 18897, 4068, 18899, 4066, 18901, 4064, 18903, 4062, 18905, 4060, 18907, 4058, 18909, 4056, 18911, 4054, 18913, 4052, 18915, 4050, 18917, 4048, 18919, 4046, 18921, 4044, 18923, 4042, 18925, 4040, 18927, 4038, 18929, 4036, 18931, 4034, 18933, 4032, 18935, 4030, 18937, 4028, 18939, 4026, 18941, 4024, 18943, 4022, 18945, 4020, 18947, 4018, 18949, 4016, 18951, 4014, 18953, 4012, 18955, 4010, 18957, 4008, 18959, 4006, 18961, 4004, 18963, 4002, 18965, 4000, 18967, 3998, 18969, 3996, 18971, 3994, 18973, 3992, 18975, 3990, 18977, 3988, 18979, 3986, 18981, 3984, 18983, 3982, 18985, 3980, 18987, 3978, 18989, 3976, 18991, 3974, 18993, 3972, 18995, 3970, 18997, 3968, 18999, 3966, 19001, 3964, 19003, 3962, 19005, 3960, 19007, 3958, 19009, 3956, 19011, 3954, 19013, 3952, 19015, 3950, 19017, 3948, 19019, 3946, 19021, 3944, 19023, 3942, 19025, 3940, 19027, 3938, 19029, 3936, 19031, 3934, 19033, 3932, 19035, 3930, 19037, 3928, 19039, 3926, 19041, 3924, 19043, 3922, 19045, 3920, 19047, 3918, 19049, 3916, 19051, 3914, 19053, 3912, 19055, 3910, 19057, 3908, 19059, 3906, 19061, 3904, 19063, 3902, 19065, 3900, 19067, 3898, 19069, 3896, 19071, 3894, 19073, 3892, 19075, 3890, 19077, 3888, 19079, 3886, 19081, 3884, 19083, 3882, 19085, 3880, 19087, 3878, 19089, 3876, 19091, 3874, 19093, 3872, 19095, 3870, 19097, 3868, 19099, 3866, 19101, 3864, 19103, 3862, 19105, 3860, 19107, 3858, 19109, 3856, 19111, 3854, 19113, 3852, 19115, 3850, 19117, 3848, 19119, 3846, 19121, 3844, 19123, 3842, 19125, 3840, 19127, 3838, 19129, 3836, 19131, 3834, 19133, 3832, 19135, 3830, 19137, 3828, 19139, 3826, 19141, 3824, 19143, 3822, 19145, 3820, 19147, 3818, 19149, 3816, 19151, 3814, 19153, 3812, 19155, 3810, 19157, 3808, 19159, 3806, 19161, 3804, 19163, 3802, 19165, 3800, 19167, 3798, 19169, 3796, 19171, 3794, 19173, 3792, 19175, 3790, 19177, 3788, 19179, 3786, 19181, 3784, 19183, 3782, 19185, 3780, 19187, 3778, 19189, 3776, 19191, 3774, 19193, 3772, 19195, 3770, 19197, 3768, 19199, 3766, 19201, 3764, 19203, 3762, 19205, 3760, 19207, 3758, 19209, 3756, 19211, 3754, 19213, 3752, 19215, 3750, 19217, 3748, 19219, 3746, 19221, 3744, 19223, 3742, 19225, 3740, 19227, 3738, 19229, 3736, 19231, 3734, 19233, 3732, 19235, 3730, 19237, 3728, 19239, 3726, 19241, 3724, 19243, 3722, 19245, 3720, 19247, 3718, 19249, 3716, 19251, 3714, 19253, 3712, 19255, 3710, 19257, 3708, 19259, 3706, 19261, 3704, 19263, 3702, 19265, 3700, 19267, 3698, 19269, 3696, 19271, 3694, 19273, 3692, 19275, 3690, 19277, 3688, 19279, 3686, 19281, 3684, 19283, 3682, 19285, 3680, 19287, 3678, 19289, 3676, 19291, 3674, 19293, 3672, 19295, 3670, 19297, 3668, 19299, 3666, 19301, 3664, 19303, 3662, 19305, 3660, 19307, 3658, 19309, 3656, 19311, 3654, 19313, 3652, 19315, 3650, 19317, 3648, 19319, 3646, 19321, 3644, 19323, 3642, 19325, 3640, 19327, 3638, 19329, 3636, 19331, 3634, 19333, 3632, 19335, 3630, 19337, 3628, 19339, 3626, 19341, 3624, 19343, 3622, 19345, 3620, 19347, 3618, 19349, 3616, 19351, 3614, 19353, 3612, 19355, 3610, 19357, 3608, 19359, 3606, 19361, 3604, 19363, 3602, 19365, 3600, 19367, 3598, 19369, 3596, 19371, 3594, 19373, 3592, 19375, 3590, 19377, 3588, 19379, 3586, 19381, 3584, 19383, 3582, 19385, 3580, 19387, 3578, 19389, 3576, 19391, 3574, 19393, 3572, 19395, 3570, 19397, 3568, 19399, 3566, 19401, 3564, 19403, 3562, 19405, 3560, 19407, 3558, 19409, 3556, 19411, 3554, 19413, 3552, 19415, 3550, 19417, 3548, 19419, 3546, 19421, 3544, 19423, 3542, 19425, 3540, 19427, 3538, 19429, 3536, 19431, 3534, 19433, 3532, 19435, 3530, 19437, 3528, 19439, 3526, 19441, 3524, 19443, 3522, 19445, 3520, 19447, 3518, 19449, 3516, 19451, 3514, 19453, 3512, 19455, 3510, 19457, 3508, 19459, 3506, 19461, 3504, 19463, 3502, 19465, 3500, 19467, 3498, 19469, 3496, 19471, 3494, 19473, 3492, 19475, 3490, 19477, 3488, 19479, 3486, 19481, 3484, 19483, 3482, 19485, 3480, 19487, 3478, 19489, 3476, 19491, 3474, 19493, 3472, 19495, 3470, 19497, 3468, 19499, 3466, 19501, 3464, 19503, 3462, 19505, 3460, 19507, 3458, 19509, 3456, 19511, 3454, 19513, 3452, 19515, 3450, 19517, 3448, 19519, 3446, 19521, 3444, 19523, 3442, 19525, 3440, 19527, 3438, 19529, 3436, 19531, 3434, 19533, 3432, 19535, 3430, 19537, 3428, 19539, 3426, 19541, 3424, 19543, 3422, 19545, 3420, 19547, 3418, 19549, 3416, 19551, 3414, 19553, 3412, 19555, 3410, 19557, 3408, 19559, 3406, 19561, 3404, 19563, 3402, 19565, 3400, 19567, 3398, 19569, 3396, 19571, 3394, 19573, 3392, 19575, 3390, 19577, 3388, 19579, 3386, 19581, 3384, 19583, 3382, 19585, 3380, 19587, 3378, 19589, 3376, 19591, 3374, 19593, 3372, 19595, 3370, 19597, 3368, 19599, 3366, 19601, 3364, 19603, 3362, 19605, 3360, 19607, 3358, 19609, 3356, 19611, 3354, 19613, 3352, 19615, 3350, 19617, 3348, 19619, 3346, 19621, 3344, 19623, 3342, 19625, 3340, 19627, 3338, 19629, 3336, 19631, 3334, 19633, 3332, 19635, 3330, 19637, 3328, 19639, 3326, 19641, 3324, 19643, 3322, 19645, 3320, 19647, 3318, 19649, 3316, 19651, 3314, 19653, 3312, 19655, 3310, 19657, 3308, 19659, 3306, 19661, 3304, 19663, 3302, 19665, 3300, 19667, 3298, 19669, 3296, 19671, 3294, 19673, 3292, 19675, 3290, 19677, 3288, 19679, 3286, 19681, 3284, 19683, 3282, 19685, 3280, 19687, 3278, 19689, 3276, 19691, 3274, 19693, 3272, 19695, 3270, 19697, 3268, 19699, 3266, 19701, 3264, 19703, 3262, 19705, 3260, 19707, 3258, 19709, 3256, 19711, 3254, 19713, 3252, 19715, 3250, 19717, 3248, 19719, 3246, 19721, 3244, 19723, 3242, 19725, 3240, 19727, 3238, 19729, 3236, 19731, 3234, 19733, 3232, 19735, 3230, 19737, 3228, 19739, 3226, 19741, 3224, 19743, 3222, 19745, 3220, 19747, 3218, 19749, 3216, 19751, 3214, 19753, 3212, 19755, 3210, 19757, 3208, 19759, 3206, 19761, 3204, 19763, 3202, 19765, 3200, 19767, 3198, 19769, 3196, 19771, 3194, 19773, 3192, 19775, 3190, 19777, 3188, 19779, 3186, 19781, 3184, 19783, 3182, 19785, 3180, 19787, 3178, 19789, 3176, 19791, 3174, 19793, 3172, 19795, 3170, 19797, 3168, 19799, 3166, 19801, 3164, 19803, 3162, 19805, 3160, 19807, 3158, 19809, 3156, 19811, 3154, 19813, 3152, 19815, 3150, 19817, 3148, 19819, 3146, 19821, 3144, 19823, 3142, 19825, 3140, 19827, 3138, 19829, 3136, 19831, 3134, 19833, 3132, 19835, 3130, 19837, 3128, 19839, 3126, 19841, 3124, 19843, 3122, 19845, 3120, 19847, 3118, 19849, 3116, 19851, 3114, 19853, 3112, 19855, 3110, 19857, 3108, 19859, 3106, 19861, 3104, 19863, 3102, 19865, 3100, 19867, 3098, 19869, 3096, 19871, 3094, 19873, 3092, 19875, 3090, 19877, 3088, 19879, 3086, 19881, 3084, 19883, 3082, 19885, 3080, 19887, 3078, 19889, 3076, 19891, 3074, 19893, 3072, 19895, 3070, 19897, 3068, 19899, 3066, 19901, 3064, 19903, 3062, 19905, 3060, 19907, 3058, 19909, 3056, 19911, 3054, 19913, 3052, 19915, 3050, 19917, 3048, 19919, 3046, 19921, 3044, 19923, 3042, 19925, 3040, 19927, 3038, 19929, 3036, 19931, 3034, 19933, 3032, 19935, 3030, 19937, 3028, 19939, 3026, 19941, 3024, 19943, 3022, 19945, 3020, 19947, 3018, 19949, 3016, 19951, 3014, 19953, 3012, 19955, 3010, 19957, 3008, 19959, 3006, 19961, 3004, 19963, 3002, 19965, 3000, 19967, 2998, 19969, 2996, 19971, 2994, 19973, 2992, 19975, 2990, 19977, 2988, 19979, 2986, 19981, 2984, 19983, 2982, 19985, 2980, 19987, 2978, 19989, 2976, 19991, 2974, 19993, 2972, 19995, 2970, 19997, 2968, 19999, 2966, 20001, 2964, 20003, 2962, 20005, 2960, 20007, 2958, 20009, 2956, 20011, 2954, 20013, 2952, 20015, 2950, 20017, 2948, 20019, 2946, 20021, 2944, 20023, 2942, 20025, 2940, 20027, 2938, 20029, 2936, 20031, 2934, 20033, 2932, 20035, 2930, 20037, 2928, 20039, 2926, 20041, 2924, 20043, 2922, 20045, 2920, 20047, 2918, 20049, 2916, 20051, 2914, 20053, 2912, 20055, 2910, 20057, 2908, 20059, 2906, 20061, 2904, 20063, 2902, 20065, 2900, 20067, 2898, 20069, 2896, 20071, 2894, 20073, 2892, 20075, 2890, 20077, 2888, 20079, 2886, 20081, 2884, 20083, 2882, 20085, 2880, 20087, 2878, 20089, 2876, 20091, 2874, 20093, 2872, 20095, 2870, 20097, 2868, 20099, 2866, 20101, 2864, 20103, 2862, 20105, 2860, 20107, 2858, 20109, 2856, 20111, 2854, 20113, 2852, 20115, 2850, 20117, 2848, 20119, 2846, 20121, 2844, 20123, 2842, 20125, 2840, 20127, 2838, 20129, 2836, 20131, 2834, 20133, 2832, 20135, 2830, 20137, 2828, 20139, 2826, 20141, 2824, 20143, 2822, 20145, 2820, 20147, 2818, 20149, 2816, 20151, 2814, 20153, 2812, 20155, 2810, 20157, 2808, 20159, 2806, 20161, 2804, 20163, 2802, 20165, 2800, 20167, 2798, 20169, 2796, 20171, 2794, 20173, 2792, 20175, 2790, 20177, 2788, 20179, 2786, 20181, 2784, 20183, 2782, 20185, 2780, 20187, 2778, 20189, 2776, 20191, 2774, 20193, 2772, 20195, 2770, 20197, 2768, 20199, 2766, 20201, 2764, 20203, 2762, 20205, 2760, 20207, 2758, 20209, 2756, 20211, 2754, 20213, 2752, 20215, 2750, 20217, 2748, 20219, 2746, 20221, 2744, 20223, 2742, 20225, 2740, 20227, 2738, 20229, 2736, 20231, 2734, 20233, 2732, 20235, 2730, 20237, 2728, 20239, 2726, 20241, 2724, 20243, 2722, 20245, 2720, 20247, 2718, 20249, 2716, 20251, 2714, 20253, 2712, 20255, 2710, 20257, 2708, 20259, 2706, 20261, 2704, 20263, 2702, 20265, 2700, 20267, 2698, 20269, 2696, 20271, 2694, 20273, 2692, 20275, 2690, 20277, 2688, 20279, 2686, 20281, 2684, 20283, 2682, 20285, 2680, 20287, 2678, 20289, 2676, 20291, 2674, 20293, 2672, 20295, 2670, 20297, 2668, 20299, 2666, 20301, 2664, 20303, 2662, 20305, 2660, 20307, 2658, 20309, 2656, 20311, 2654, 20313, 2652, 20315, 2650, 20317, 2648, 20319, 2646, 20321, 2644, 20323, 2642, 20325, 2640, 20327, 2638, 20329, 2636, 20331, 2634, 20333, 2632, 20335, 2630, 20337, 2628, 20339, 2626, 20341, 2624, 20343, 2622, 20345, 2620, 20347, 2618, 20349, 2616, 20351, 2614, 20353, 2612, 20355, 2610, 20357, 2608, 20359, 2606, 20361, 2604, 20363, 2602, 20365, 2600, 20367, 2598, 20369, 2596, 20371, 2594, 20373, 2592, 20375, 2590, 20377, 2588, 20379, 2586, 20381, 2584, 20383, 2582, 20385, 2580, 20387, 2578, 20389, 2576, 20391, 2574, 20393, 2572, 20395, 2570, 20397, 2568, 20399, 2566, 20401, 2564, 20403, 2562, 20405, 2560, 20407, 2558, 20409, 2556, 20411, 2554, 20413, 2552, 20415, 2550, 20417, 2548, 20419, 2546, 20421, 2544, 20423, 2542, 20425, 2540, 20427, 2538, 20429, 2536, 20431, 2534, 20433, 2532, 20435, 2530, 20437, 2528, 20439, 2526, 20441, 2524, 20443, 2522, 20445, 2520, 20447, 2518, 20449, 2516, 20451, 2514, 20453, 2512, 20455, 2510, 20457, 2508, 20459, 2506, 20461, 2504, 20463, 2502, 20465, 2500, 20467, 2498, 20469, 2496, 20471, 2494, 20473, 2492, 20475, 2490, 20477, 2488, 20479, 2486, 20481, 2484, 20483, 2482, 20485, 2480, 20487, 2478, 20489, 2476, 20491, 2474, 20493, 2472, 20495, 2470, 20497, 2468, 20499, 2466, 20501, 2464, 20503, 2462, 20505, 2460, 20507, 2458, 20509, 2456, 20511, 2454, 20513, 2452, 20515, 2450, 20517, 2448, 20519, 2446, 20521, 2444, 20523, 2442, 20525, 2440, 20527, 2438, 20529, 2436, 20531, 2434, 20533, 2432, 20535, 2430, 20537, 2428, 20539, 2426, 20541, 2424, 20543, 2422, 20545, 2420, 20547, 2418, 20549, 2416, 20551, 2414, 20553, 2412, 20555, 2410, 20557, 2408, 20559, 2406, 20561, 2404, 20563, 2402, 20565, 2400, 20567, 2398, 20569, 2396, 20571, 2394, 20573, 2392, 20575, 2390, 20577, 2388, 20579, 2386, 20581, 2384, 20583, 2382, 20585, 2380, 20587, 2378, 20589, 2376, 20591, 2374, 20593, 2372, 20595, 2370, 20597, 2368, 20599, 2366, 20601, 2364, 20603, 2362, 20605, 2360, 20607, 2358, 20609, 2356, 20611, 2354, 20613, 2352, 20615, 2350, 20617, 2348, 20619, 2346, 20621, 2344, 20623, 2342, 20625, 2340, 20627, 2338, 20629, 2336, 20631, 2334, 20633, 2332, 20635, 2330, 20637, 2328, 20639, 2326, 20641, 2324, 20643, 2322, 20645, 2320, 20647, 2318, 20649, 2316, 20651, 2314, 20653, 2312, 20655, 2310, 20657, 2308, 20659, 2306, 20661, 2304, 20663, 2302, 20665, 2300, 20667, 2298, 20669, 2296, 20671, 2294, 20673, 2292, 20675, 2290, 20677, 2288, 20679, 2286, 20681, 2284, 20683, 2282, 20685, 2280, 20687, 2278, 20689, 2276, 20691, 2274, 20693, 2272, 20695, 2270, 20697, 2268, 20699, 2266, 20701, 2264, 20703, 2262, 20705, 2260, 20707, 2258, 20709, 2256, 20711, 2254, 20713, 2252, 20715, 2250, 20717, 2248, 20719, 2246, 20721, 2244, 20723, 2242, 20725, 2240, 20727, 2238, 20729, 2236, 20731, 2234, 20733, 2232, 20735, 2230, 20737, 2228, 20739, 2226, 20741, 2224, 20743, 2222, 20745, 2220, 20747, 2218, 20749, 2216, 20751, 2214, 20753, 2212, 20755, 2210, 20757, 2208, 20759, 2206, 20761, 2204, 20763, 2202, 20765, 2200, 20767, 2198, 20769, 2196, 20771, 2194, 20773, 2192, 20775, 2190, 20777, 2188, 20779, 2186, 20781, 2184, 20783, 2182, 20785, 2180, 20787, 2178, 20789, 2176, 20791, 2174, 20793, 2172, 20795, 2170, 20797, 2168, 20799, 2166, 20801, 2164, 20803, 2162, 20805, 2160, 20807, 2158, 20809, 2156, 20811, 2154, 20813, 2152, 20815, 2150, 20817, 2148, 20819, 2146, 20821, 2144, 20823, 2142, 20825, 2140, 20827, 2138, 20829, 2136, 20831, 2134, 20833, 2132, 20835, 2130, 20837, 2128, 20839, 2126, 20841, 2124, 20843, 2122, 20845, 2120, 20847, 2118, 20849, 2116, 20851, 2114, 20853, 2112, 20855, 2110, 20857, 2108, 20859, 2106, 20861, 2104, 20863, 2102, 20865, 2100, 20867, 2098, 20869, 2096, 20871, 2094, 20873, 2092, 20875, 2090, 20877, 2088, 20879, 2086, 20881, 2084, 20883, 2082, 20885, 2080, 20887, 2078, 20889, 2076, 20891, 2074, 20893, 2072, 20895, 2070, 20897, 2068, 20899, 2066, 20901, 2064, 20903, 2062, 20905, 2060, 20907, 2058, 20909, 2056, 20911, 2054, 20913, 2052, 20915, 2050, 20917, 2048, 20919, 2046, 20921, 2044, 20923, 2042, 20925, 2040, 20927, 2038, 20929, 2036, 20931, 2034, 20933, 2032, 20935, 2030, 20937, 2028, 20939, 2026, 20941, 2024, 20943, 2022, 20945, 2020, 20947, 2018, 20949, 2016, 20951, 2014, 20953, 2012, 20955, 2010, 20957, 2008, 20959, 2006, 20961, 2004, 20963, 2002, 20965, 2000, 20967, 1998, 20969, 1996, 20971, 1994, 20973, 1992, 20975, 1990, 20977, 1988, 20979, 1986, 20981, 1984, 20983, 1982, 20985, 1980, 20987, 1978, 20989, 1976, 20991, 1974, 20993, 1972, 20995, 1970, 20997, 1968, 20999, 1966, 21001, 1964, 21003, 1962, 21005, 1960, 21007, 1958, 21009, 1956, 21011, 1954, 21013, 1952, 21015, 1950, 21017, 1948, 21019, 1946, 21021, 1944, 21023, 1942, 21025, 1940, 21027, 1938, 21029, 1936, 21031, 1934, 21033, 1932, 21035, 1930, 21037, 1928, 21039, 1926, 21041, 1924, 21043, 1922, 21045, 1920, 21047, 1918, 21049, 1916, 21051, 1914, 21053, 1912, 21055, 1910, 21057, 1908, 21059, 1906, 21061, 1904, 21063, 1902, 21065, 1900, 21067, 1898, 21069, 1896, 21071, 1894, 21073, 1892, 21075, 1890, 21077, 1888, 21079, 1886, 21081, 1884, 21083, 1882, 21085, 1880, 21087, 1878, 21089, 1876, 21091, 1874, 21093, 1872, 21095, 1870, 21097, 1868, 21099, 1866, 21101, 1864, 21103, 1862, 21105, 1860, 21107, 1858, 21109, 1856, 21111, 1854, 21113, 1852, 21115, 1850, 21117, 1848, 21119, 1846, 21121, 1844, 21123, 1842, 21125, 1840, 21127, 1838, 21129, 1836, 21131, 1834, 21133, 1832, 21135, 1830, 21137, 1828, 21139, 1826, 21141, 1824, 21143, 1822, 21145, 1820, 21147, 1818, 21149, 1816, 21151, 1814, 21153, 1812, 21155, 1810, 21157, 1808, 21159, 1806, 21161, 1804, 21163, 1802, 21165, 1800, 21167, 1798, 21169, 1796, 21171, 1794, 21173, 1792, 21175, 1790, 21177, 1788, 21179, 1786, 21181, 1784, 21183, 1782, 21185, 1780, 21187, 1778, 21189, 1776, 21191, 1774, 21193, 1772, 21195, 1770, 21197, 1768, 21199, 1766, 21201, 1764, 21203, 1762, 21205, 1760, 21207, 1758, 21209, 1756, 21211, 1754, 21213, 1752, 21215, 1750, 21217, 1748, 21219, 1746, 21221, 1744, 21223, 1742, 21225, 1740, 21227, 1738, 21229, 1736, 21231, 1734, 21233, 1732, 21235, 1730, 21237, 1728, 21239, 1726, 21241, 1724, 21243, 1722, 21245, 1720, 21247, 1718, 21249, 1716, 21251, 1714, 21253, 1712, 21255, 1710, 21257, 1708, 21259, 1706, 21261, 1704, 21263, 1702, 21265, 1700, 21267, 1698, 21269, 1696, 21271, 1694, 21273, 1692, 21275, 1690, 21277, 1688, 21279, 1686, 21281, 1684, 21283, 1682, 21285, 1680, 21287, 1678, 21289, 1676, 21291, 1674, 21293, 1672, 21295, 1670, 21297, 1668, 21299, 1666, 21301, 1664, 21303, 1662, 21305, 1660, 21307, 1658, 21309, 1656, 21311, 1654, 21313, 1652, 21315, 1650, 21317, 1648, 21319, 1646, 21321, 1644, 21323, 1642, 21325, 1640, 21327, 1638, 21329, 1636, 21331, 1634, 21333, 1632, 21335, 1630, 21337, 1628, 21339, 1626, 21341, 1624, 21343, 1622, 21345, 1620, 21347, 1618, 21349, 1616, 21351, 1614, 21353, 1612, 21355, 1610, 21357, 1608, 21359, 1606, 21361, 1604, 21363, 1602, 21365, 1600, 21367, 1598, 21369, 1596, 21371, 1594, 21373, 1592, 21375, 1590, 21377, 1588, 21379, 1586, 21381, 1584, 21383, 1582, 21385, 1580, 21387, 1578, 21389, 1576, 21391, 1574, 21393, 1572, 21395, 1570, 21397, 1568, 21399, 1566, 21401, 1564, 21403, 1562, 21405, 1560, 21407, 1558, 21409, 1556, 21411, 1554, 21413, 1552, 21415, 1550, 21417, 1548, 21419, 1546, 21421, 1544, 21423, 1542, 21425, 1540, 21427, 1538, 21429, 1536, 21431, 1534, 21433, 1532, 21435, 1530, 21437, 1528, 21439, 1526, 21441, 1524, 21443, 1522, 21445, 1520, 21447, 1518, 21449, 1516, 21451, 1514, 21453, 1512, 21455, 1510, 21457, 1508, 21459, 1506, 21461, 1504, 21463, 1502, 21465, 1500, 21467, 1498, 21469, 1496, 21471, 1494, 21473, 1492, 21475, 1490, 21477, 1488, 21479, 1486, 21481, 1484, 21483, 1482, 21485, 1480, 21487, 1478, 21489, 1476, 21491, 1474, 21493, 1472, 21495, 1470, 21497, 1468, 21499, 1466, 21501, 1464, 21503, 1462, 21505, 1460, 21507, 1458, 21509, 1456, 21511, 1454, 21513, 1452, 21515, 1450, 21517, 1448, 21519, 1446, 21521, 1444, 21523, 1442, 21525, 1440, 21527, 1438, 21529, 1436, 21531, 1434, 21533, 1432, 21535, 1430, 21537, 1428, 21539, 1426, 21541, 1424, 21543, 1422, 21545, 1420, 21547, 1418, 21549, 1416, 21551, 1414, 21553, 1412, 21555, 1410, 21557, 1408, 21559, 1406, 21561, 1404, 21563, 1402, 21565, 1400, 21567, 1398, 21569, 1396, 21571, 1394, 21573, 1392, 21575, 1390, 21577, 1388, 21579, 1386, 21581, 1384, 21583, 1382, 21585, 1380, 21587, 1378, 21589, 1376, 21591, 1374, 21593, 1372, 21595, 1370, 21597, 1368, 21599, 1366, 21601, 1364, 21603, 1362, 21605, 1360, 21607, 1358, 21609, 1356, 21611, 1354, 21613, 1352, 21615, 1350, 21617, 1348, 21619, 1346, 21621, 1344, 21623, 1342, 21625, 1340, 21627, 1338, 21629, 1336, 21631, 1334, 21633, 1332, 21635, 1330, 21637, 1328, 21639, 1326, 21641, 1324, 21643, 1322, 21645, 1320, 21647, 1318, 21649, 1316, 21651, 1314, 21653, 1312, 21655, 1310, 21657, 1308, 21659, 1306, 21661, 1304, 21663, 1302, 21665, 1300, 21667, 1298, 21669, 1296, 21671, 1294, 21673, 1292, 21675, 1290, 21677, 1288, 21679, 1286, 21681, 1284, 21683, 1282, 21685, 1280, 21687, 1278, 21689, 1276, 21691, 1274, 21693, 1272, 21695, 1270, 21697, 1268, 21699, 1266, 21701, 1264, 21703, 1262, 21705, 1260, 21707, 1258, 21709, 1256, 21711, 1254, 21713, 1252, 21715, 1250, 21717, 1248, 21719, 1246, 21721, 1244, 21723, 1242, 21725, 1240, 21727, 1238, 21729, 1236, 21731, 1234, 21733, 1232, 21735, 1230, 21737, 1228, 21739, 1226, 21741, 1224, 21743, 1222, 21745, 1220, 21747, 1218, 21749, 1216, 21751, 1214, 21753, 1212, 21755, 1210, 21757, 1208, 21759, 1206, 21761, 1204, 21763, 1202, 21765, 1200, 21767, 1198, 21769, 1196, 21771, 1194, 21773, 1192, 21775, 1190, 21777, 1188, 21779, 1186, 21781, 1184, 21783, 1182, 21785, 1180, 21787, 1178, 21789, 1176, 21791, 1174, 21793, 1172, 21795, 1170, 21797, 1168, 21799, 1166, 21801, 1164, 21803, 1162, 21805, 1160, 21807, 1158, 21809, 1156, 21811, 1154, 21813, 1152, 21815, 1150, 21817, 1148, 21819, 1146, 21821, 1144, 21823, 1142, 21825, 1140, 21827, 1138, 21829, 1136, 21831, 1134, 21833, 1132, 21835, 1130, 21837, 1128, 21839, 1126, 21841, 1124, 21843, 1122, 21845, 1120, 21847, 1118, 21849, 1116, 21851, 1114, 21853, 1112, 21855, 1110, 21857, 1108, 21859, 1106, 21861, 1104, 21863, 1102, 21865, 1100, 21867, 1098, 21869, 1096, 21871, 1094, 21873, 1092, 21875, 1090, 21877, 1088, 21879, 1086, 21881, 1084, 21883, 1082, 21885, 1080, 21887, 1078, 21889, 1076, 21891, 1074, 21893, 1072, 21895, 1070, 21897, 1068, 21899, 1066, 21901, 1064, 21903, 1062, 21905, 1060, 21907, 1058, 21909, 1056, 21911, 1054, 21913, 1052, 21915, 1050, 21917, 1048, 21919, 1046, 21921, 1044, 21923, 1042, 21925, 1040, 21927, 1038, 21929, 1036, 21931, 1034, 21933, 1032, 21935, 1030, 21937, 1028, 21939, 1026, 21941, 1024, 21943, 1022, 21945, 1020, 21947, 1018, 21949, 1016, 21951, 1014, 21953, 1012, 21955, 1010, 21957, 1008, 21959, 1006, 21961, 1004, 21963, 1002, 21965, 1000, 21967, 998, 21969, 996, 21971, 994, 21973, 992, 21975, 990, 21977, 988, 21979, 986, 21981, 984, 21983, 982, 21985, 980, 21987, 978, 21989, 976, 21991, 974, 21993, 972, 21995, 970, 21997, 968, 21999, 966, 22001, 964, 22003, 962, 22005, 960, 22007, 958, 22009, 956, 22011, 954, 22013, 952, 22015, 950, 22017, 948, 22019, 946, 22021, 944, 22023, 942, 22025, 940, 22027, 938, 22029, 936, 22031, 934, 22033, 932, 22035, 930, 22037, 928, 22039, 926, 22041, 924, 22043, 922, 22045, 920, 22047, 918, 22049, 916, 22051, 914, 22053, 912, 22055, 910, 22057, 908, 22059, 906, 22061, 904, 22063, 902, 22065, 900, 22067, 898, 22069, 896, 22071, 894, 22073, 892, 22075, 890, 22077, 888, 22079, 886, 22081, 884, 22083, 882, 22085, 880, 22087, 878, 22089, 876, 22091, 874, 22093, 872, 22095, 870, 22097, 868, 22099, 866, 22101, 864, 22103, 862, 22105, 860, 22107, 858, 22109, 856, 22111, 854, 22113, 852, 22115, 850, 22117, 848, 22119, 846, 22121, 844, 22123, 842, 22125, 840, 22127, 838, 22129, 836, 22131, 834, 22133, 832, 22135, 830, 22137, 828, 22139, 826, 22141, 824, 22143, 822, 22145, 820, 22147, 818, 22149, 816, 22151, 814, 22153, 812, 22155, 810, 22157, 808, 22159, 806, 22161, 804, 22163, 802, 22165, 800, 22167, 798, 22169, 796, 22171, 794, 22173, 792, 22175, 790, 22177, 788, 22179, 786, 22181, 784, 22183, 782, 22185, 780, 22187, 778, 22189, 776, 22191, 774, 22193, 772, 22195, 770, 22197, 768, 22199, 766, 22201, 764, 22203, 762, 22205, 760, 22207, 758, 22209, 756, 22211, 754, 22213, 752, 22215, 750, 22217, 748, 22219, 746, 22221, 744, 22223, 742, 22225, 740, 22227, 738, 22229, 736, 22231, 734, 22233, 732, 22235, 730, 22237, 728, 22239, 726, 22241, 724, 22243, 722, 22245, 720, 22247, 718, 22249, 716, 22251, 714, 22253, 712, 22255, 710, 22257, 708, 22259, 706, 22261, 704, 22263, 702, 22265, 700, 22267, 698, 22269, 696, 22271, 694, 22273, 692, 22275, 690, 22277, 688, 22279, 686, 22281, 684, 22283, 682, 22285, 680, 22287, 678, 22289, 676, 22291, 674, 22293, 672, 22295, 670, 22297, 668, 22299, 666, 22301, 664, 22303, 662, 22305, 660, 22307, 658, 22309, 656, 22311, 654, 22313, 652, 22315, 650, 22317, 648, 22319, 646, 22321, 644, 22323, 642, 22325, 640, 22327, 638, 22329, 636, 22331, 634, 22333, 632, 22335, 630, 22337, 628, 22339, 626, 22341, 624, 22343, 622, 22345, 620, 22347, 618, 22349, 616, 22351, 614, 22353, 612, 22355, 610, 22357, 608, 22359, 606, 22361, 604, 22363, 602, 22365, 600, 22367, 598, 22369, 596, 22371, 594, 22373, 592, 22375, 590, 22377, 588, 22379, 586, 22381, 584, 22383, 582, 22385, 580, 22387, 578, 22389, 576, 22391, 574, 22393, 572, 22395, 570, 22397, 568, 22399, 566, 22401, 564, 22403, 562, 22405, 560, 22407, 558, 22409, 556, 22411, 554, 22413, 552, 22415, 550, 22417, 548, 22419, 546, 22421, 544, 22423, 542, 22425, 540, 22427, 538, 22429, 536, 22431, 534, 22433, 532, 22435, 530, 22437, 528, 22439, 526, 22441, 524, 22443, 522, 22445, 520, 22447, 518, 22449, 516, 22451, 514, 22453, 512, 22455, 510, 22457, 508, 22459, 506, 22461, 504, 22463, 502, 22465, 500, 22467, 498, 22469, 496, 22471, 494, 22473, 492, 22475, 490, 22477, 488, 22479, 486, 22481, 484, 22483, 482, 22485, 480, 22487, 478, 22489, 476, 22491, 474, 22493, 472, 22495, 470, 22497, 468, 22499, 466, 22501, 464, 22503, 462, 22505, 460, 22507, 458, 22509, 456, 22511, 454, 22513, 452, 22515, 450, 22517, 448, 22519, 446, 22521, 444, 22523, 442, 22525, 440, 22527, 438, 22529, 436, 22531, 434, 22533, 432, 22535, 430, 22537, 428, 22539, 426, 22541, 424, 22543, 422, 22545, 420, 22547, 418, 22549, 416, 22551, 414, 22553, 412, 22555, 410, 22557, 408, 22559, 406, 22561, 404, 22563, 402, 22565, 400, 22567, 398, 22569, 396, 22571, 394, 22573, 392, 22575, 390, 22577, 388, 22579, 386, 22581, 384, 22583, 382, 22585, 380, 22587, 378, 22589, 376, 22591, 374, 22593, 372, 22595, 370, 22597, 368, 22599, 366, 22601, 364, 22603, 362, 22605, 360, 22607, 358, 22609, 356, 22611, 354, 22613, 352, 22615, 350, 22617, 348, 22619, 346, 22621, 344, 22623, 342, 22625, 340, 22627, 338, 22629, 336, 22631, 334, 22633, 332, 22635, 330, 22637, 328, 22639, 326, 22641, 324, 22643, 322, 22645, 320, 22647, 318, 22649, 316, 22651, 314, 22653, 312, 22655, 310, 22657, 308, 22659, 306, 22661, 304, 22663, 302, 22665, 300, 22667, 298, 22669, 296, 22671, 294, 22673, 292, 22675, 290, 22677, 288, 22679, 286, 22681, 284, 22683, 282, 22685, 280, 22687, 278, 22689, 276, 22691, 274, 22693, 272, 22695, 270, 22697, 268, 22699, 266, 22701, 264, 22703, 262, 22705, 260, 22707, 258, 22709, 256, 22711, 254, 22713, 252, 22715, 250, 22717, 248, 22719, 246, 22721, 244, 22723, 242, 22725, 240, 22727, 238, 22729, 236, 22731, 234, 22733, 232, 22735, 230, 22737, 228, 22739, 226, 22741, 224, 22743, 222, 22745, 220, 22747, 218, 22749, 216, 22751, 214, 22753, 212, 22755, 210, 22757, 208, 22759, 206, 22761, 204, 22763, 202, 22765, 200, 22767, 198, 22769, 196, 22771, 194, 22773, 192, 22775, 190, 22777, 188, 22779, 186, 22781, 184, 22783, 182, 22785, 180, 22787, 178, 22789, 176, 22791, 174, 22793, 172, 22795, 170, 22797, 168, 22799, 166, 22801, 164, 22803, 162, 22805, 160, 22807, 158, 22809, 156, 22811, 154, 22813, 152, 22815, 150, 22817, 148, 22819, 146, 22821, 144, 22823, 142, 22825, 140, 22827, 138, 22829, 136, 22831, 134, 22833, 132, 22835, 130, 22837, 128, 22839, 126, 22841, 124, 22843, 122, 22845, 120, 22847, 118, 22849, 116, 22851, 114, 22853, 112, 22855, 110, 22857, 108, 22859, 106, 22861, 104, 22863, 102, 22865, 100, 22867, 98, 22869, 96, 22871, 94, 22873, 92, 22875, 90, 22877, 88, 22879, 86, 22881, 84, 22883, 82, 22885, 80, 22887, 78, 22889, 76, 22891, 74, 22893, 72, 22895, 70, 22897, 68, 22899, 66, 22901, 64, 22903, 62, 22905, 60, 22907, 58, 22909, 56, 22911, 54, 22913, 52, 22915, 50, 22917, 48, 22919, 46, 22921, 44, 22923, 42, 22925, 40, 22927, 38, 22929, 36, 22931, 34, 22933, 32, 22935, 30, 22937, 28, 22939, 26, 22941, 24, 22943, 22, 22945, 20, 22947, 18, 22949, 16, 22951, 14, 22953, 12, 22955, 10, 22957, 8, 22959, 6, 22961, 4, 22963, 2, 22965]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s9/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s9/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s9/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bc9ec44bf226d9d07eb20478da9905e764d5e276 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 22966, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s9/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s9/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s0/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s0/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cc2cb59529f3f7a8f05391723d97e769549f7ef8 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 43, "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-s0/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9992307075de7a0ca2941dfbefdd11b5eb979c46 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-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' +{"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]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s0/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s0/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-s0/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cc2cb59529f3f7a8f05391723d97e769549f7ef8 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 43, "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-s0/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prime-graph-coloring-l3-s0/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l3-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s3/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l1-s3/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bd1fe5851784deccd75196935903f3ee82b32a7f --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"F0": 116, "A": 12, "B": 8992, "S": 10384, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s3/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a9905329f0545a88db99d9b47a6808bfe6bf637d --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s3/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s3/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-s3/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bd1fe5851784deccd75196935903f3ee82b32a7f --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"F0": 116, "A": 12, "B": 8992, "S": 10384, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s3/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l1-s3/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l1-s4/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l1-s4/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b4fbafade0ade291e5d22a8346964b80558e9d82 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"F0": 74, "A": 4, "B": 12677, "S": 348495, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s4/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c621b4e4f01eab810b4e898c046839c8aa6ca435 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [1, 2, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s4/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s4/tests/check.py @@ -0,0 +1,29 @@ +from run import Invalid, int_list + + +def F(inst, n): + F0, A, B = inst["F0"], inst["A"], inst["B"] + if A == 1: + return F0 + n * B + An = A ** n + return An * F0 + B * (An - 1) // (A - 1) + + +def check(inst, ans): + S = inst["S"] + idx = int_list(ans.get("indices"), None, 1, None, "indices") + if not idx: + raise Invalid("need at least one index") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + total = 0 + for n in idx: + # F is strictly increasing with F(n) >= n and, when A >= 2, F(n) >= 2^(n-1); bail out before big powers + if n > S or (inst["A"] >= 2 and n - 1 > S.bit_length()): + raise Invalid(f"F({n}) exceeds S") + total += F(inst, n) + if total > S: + raise Invalid("sum exceeds S") + if total != S: + raise Invalid(f"sum is {total}, need {S}") + return None, {} diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s4/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b4fbafade0ade291e5d22a8346964b80558e9d82 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"F0": 74, "A": 4, "B": 12677, "S": 348495, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s4/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l1-s4/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l5-s2/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l5-s2/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fdb8a6e85d55b3454239495a4e976a936c9e96ad --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"F0": 37, "A": 16, "B": 3753, "S": 104219017961490983349818169994538658321432, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s2/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..24d951ba1fbfad931b91dd1924a0921c0e7513f0 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [1, 3, 4, 5, 6, 7, 11, 12, 13, 14, 15, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 30, 31, 32]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s2/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s2/tests/check.py @@ -0,0 +1,29 @@ +from run import Invalid, int_list + + +def F(inst, n): + F0, A, B = inst["F0"], inst["A"], inst["B"] + if A == 1: + return F0 + n * B + An = A ** n + return An * F0 + B * (An - 1) // (A - 1) + + +def check(inst, ans): + S = inst["S"] + idx = int_list(ans.get("indices"), None, 1, None, "indices") + if not idx: + raise Invalid("need at least one index") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + total = 0 + for n in idx: + # F is strictly increasing with F(n) >= n and, when A >= 2, F(n) >= 2^(n-1); bail out before big powers + if n > S or (inst["A"] >= 2 and n - 1 > S.bit_length()): + raise Invalid(f"F({n}) exceeds S") + total += F(inst, n) + if total > S: + raise Invalid("sum exceeds S") + if total != S: + raise Invalid(f"sum is {total}, need {S}") + return None, {} diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s2/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fdb8a6e85d55b3454239495a4e976a936c9e96ad --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"F0": 37, "A": 16, "B": 3753, "S": 104219017961490983349818169994538658321432, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s2/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s2/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l5-s5/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l5-s5/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9d3cfa7be94fe17d7a036eefc0758f93e88c7332 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"F0": 59, "A": 2, "B": 4657, "S": 20261247114260, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s5/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..18553bfc2739240d63227c0741cfe4e9ed5e57f4 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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' +{"indices": [1, 18, 20, 32]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s5/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s5/tests/check.py @@ -0,0 +1,29 @@ +from run import Invalid, int_list + + +def F(inst, n): + F0, A, B = inst["F0"], inst["A"], inst["B"] + if A == 1: + return F0 + n * B + An = A ** n + return An * F0 + B * (An - 1) // (A - 1) + + +def check(inst, ans): + S = inst["S"] + idx = int_list(ans.get("indices"), None, 1, None, "indices") + if not idx: + raise Invalid("need at least one index") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + total = 0 + for n in idx: + # F is strictly increasing with F(n) >= n and, when A >= 2, F(n) >= 2^(n-1); bail out before big powers + if n > S or (inst["A"] >= 2 and n - 1 > S.bit_length()): + raise Invalid(f"F({n}) exceeds S") + total += F(inst, n) + if total > S: + raise Invalid("sum exceeds S") + if total != S: + raise Invalid(f"sum is {total}, need {S}") + return None, {} diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s5/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9d3cfa7be94fe17d7a036eefc0758f93e88c7332 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"F0": 59, "A": 2, "B": 4657, "S": 20261247114260, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s5/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-recursive-sequence-sum-l5-s5/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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-round-robin-scores-l1-s6/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s6/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ffd6f6758cd079023623995d748920d83d750d52 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"W": [4, 0, 7, 6], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s6/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4300384feb1357c359a88bf54f80d7fe98271020 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": ["0210", "0000", "1202", "2200"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l1-s6/tests/check.py b/tasks/construct-rlve-round-robin-scores-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s6/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l1-s6/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ffd6f6758cd079023623995d748920d83d750d52 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"W": [4, 0, 7, 6], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s6/tests/run.py b/tasks/construct-rlve-round-robin-scores-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s6/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s7/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l1-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s7/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4e78c971f22cd9aea504d9f958a0f64f334f10e3 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s7/environment/instance.json @@ -0,0 +1 @@ +{"W": [2, 3, 7, 2], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s7/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l1-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a1f9a2f805cceb3d27ad995c59e5d4fc3a7656d6 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": ["0101", "1011", "2102", "1100"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l1-s7/tests/check.py b/tasks/construct-rlve-round-robin-scores-l1-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s7/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l1-s7/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l1-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4e78c971f22cd9aea504d9f958a0f64f334f10e3 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l1-s7/tests/instance.json @@ -0,0 +1 @@ +{"W": [2, 3, 7, 2], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l1-s7/tests/run.py b/tasks/construct-rlve-round-robin-scores-l1-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l1-s7/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l1-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l5-s8/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l5-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l5-s8/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a0dd739728c3bf17110f74e4d6dd45271095a6b4 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s8/environment/instance.json @@ -0,0 +1 @@ +{"W": [21, 25, 17, 20, 17, 17, 29, 20, 16, 18, 20, 17, 18, 15, 19, 26, 15, 21], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s8/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l5-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2c52075c2a235733bf16f0b1fe08101352c8a70e --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": ["001111102112111112", "201112021120112111", "110201110111111111", "110020121011112111", "112001211101111010", "101210021110110111", "121102012121221012", "201010101121112111", "012111010111111110", "111211111011111011", "101121001102112111", "021112111100010111", "111111011112011111", "111111011111101011", "101012101102110121", "111121211211121020", "111111111111110001", "011121012111111210"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l5-s8/tests/check.py b/tasks/construct-rlve-round-robin-scores-l5-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s8/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l5-s8/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a0dd739728c3bf17110f74e4d6dd45271095a6b4 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s8/tests/instance.json @@ -0,0 +1 @@ +{"W": [21, 25, 17, 20, 17, 17, 29, 20, 16, 18, 20, 17, 18, 15, 19, 26, 15, 21], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s8/tests/run.py b/tasks/construct-rlve-round-robin-scores-l5-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l5-s8/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l5-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-shortest-path-count-l6-s2/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l6-s2/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d635b9ce1485259a9454c46853db4b7097d64de3 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"K": 713669029456444787, "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-s2/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..86af56d35b81c5927a504d5983df2a1a599df9f7 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 180, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l6-s2/tests/check.py b/tasks/construct-rlve-shortest-path-count-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s2/tests/check.py @@ -0,0 +1,34 @@ +from run import Invalid, as_int + + +def check(inst, ans): + n = as_int(ans.get("n"), "n", lo=2, hi=inst["n_max"]) + adj = ans.get("adj") + if not isinstance(adj, list) or len(adj) != n: + raise Invalid(f"adj must be a list of {n} strings") + for r in adj: + if not isinstance(r, str) or len(r) != n or set(r) - {"Y", "N"}: + raise Invalid("each row must be a string of length n over {'Y','N'}") + for i in range(n): + if adj[i][i] != "N": + raise Invalid("self-loop") + for j in range(i + 1, n): + if adj[i][j] != adj[j][i]: + raise Invalid("matrix not symmetric") + nb = [[j for j in range(n) if adj[i][j] == "Y"] for i in range(n)] + dist = [-1] * n + cnt = [0] * n + dist[0], cnt[0] = 0, 1 + q = [0] + for u in q: # BFS with exact (Python int) path counts + for v in nb[u]: + if dist[v] < 0: + dist[v] = dist[u] + 1 + q.append(v) + if dist[v] == dist[u] + 1: + cnt[v] += cnt[u] + if dist[1] < 0: + raise Invalid("vertex 2 is unreachable from vertex 1") + if cnt[1] != inst["K"]: + raise Invalid(f"{cnt[1]} shortest paths, need {inst['K']}") + return None, {} diff --git a/tasks/construct-rlve-shortest-path-count-l6-s2/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d635b9ce1485259a9454c46853db4b7097d64de3 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"K": 713669029456444787, "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-s2/tests/run.py b/tasks/construct-rlve-shortest-path-count-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l6-s2/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l6-s4/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l6-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-rlve-shortest-path-count-l6-s4/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l6-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f53c931b56c0ab8b28bd83c9f8632d6d08881895 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 174, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l6-s4/tests/check.py b/tasks/construct-rlve-shortest-path-count-l6-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s4/tests/check.py @@ -0,0 +1,34 @@ +from run import Invalid, as_int + + +def check(inst, ans): + n = as_int(ans.get("n"), "n", lo=2, hi=inst["n_max"]) + adj = ans.get("adj") + if not isinstance(adj, list) or len(adj) != n: + raise Invalid(f"adj must be a list of {n} strings") + for r in adj: + if not isinstance(r, str) or len(r) != n or set(r) - {"Y", "N"}: + raise Invalid("each row must be a string of length n over {'Y','N'}") + for i in range(n): + if adj[i][i] != "N": + raise Invalid("self-loop") + for j in range(i + 1, n): + if adj[i][j] != adj[j][i]: + raise Invalid("matrix not symmetric") + nb = [[j for j in range(n) if adj[i][j] == "Y"] for i in range(n)] + dist = [-1] * n + cnt = [0] * n + dist[0], cnt[0] = 0, 1 + q = [0] + for u in q: # BFS with exact (Python int) path counts + for v in nb[u]: + if dist[v] < 0: + dist[v] = dist[u] + 1 + q.append(v) + if dist[v] == dist[u] + 1: + cnt[v] += cnt[u] + if dist[1] < 0: + raise Invalid("vertex 2 is unreachable from vertex 1") + if cnt[1] != inst["K"]: + raise Invalid(f"{cnt[1]} shortest paths, need {inst['K']}") + return None, {} diff --git a/tasks/construct-rlve-shortest-path-count-l6-s4/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b7385382052ffde35fbc823bb1265e281ea72ebd --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s4/tests/instance.json @@ -0,0 +1 @@ +{"K": 187789265141101595, "n_max": 351, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l6-s4/tests/run.py b/tasks/construct-rlve-shortest-path-count-l6-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-rlve-shortest-path-count-l6-s4/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l6-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-rlve-smallest-enclosing-circle-l1-s1/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..320f80f1e6c4bebc958a34a16088050715d4d939 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"points": [[0, 7], [1, 7], [4, 6], [6, 0]], "r_opt": 4.6097722286464435, "r2_num": 85, "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-s1/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..74c9c5a2dcc2b2c4ae06098787d4c663452e9290 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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": 3.0, "y": 3.5, "r": 4.609772229646444} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..320f80f1e6c4bebc958a34a16088050715d4d939 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"points": [[0, 7], [1, 7], [4, 6], [6, 0]], "r_opt": 4.6097722286464435, "r2_num": 85, "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-s1/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s6/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l1-s6/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e7f83bbdfc8b5ed99b0efb3fdca3d94cc6079463 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"points": [[1, 5], [2, 8], [5, 3], [7, 7]], "r_opt": 3.1622776601683795, "r2_num": 10, "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-l1-s6/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d8843f0b8c952c5afa49a2fb8beeff123f29afc8 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 4.0, "y": 6.0, "r": 3.1622776611683796} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s6/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s6/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l1-s6/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e7f83bbdfc8b5ed99b0efb3fdca3d94cc6079463 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"points": [[1, 5], [2, 8], [5, 3], [7, 7]], "r_opt": 3.1622776601683795, "r2_num": 10, "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-l1-s6/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l1-s6/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s9/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s9/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f98dc69fa304c7d589c2231a1a561456f4d79323 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"points": [[2, 73], [2, 99], [3, 95], [5, 42], [7, 100], [12, 27], [12, 111], [13, 7], [17, 35], [23, 35], [23, 115], [24, 10], [26, 89], [29, 55], [29, 70], [31, 117], [32, 27], [32, 36], [34, 20], [39, 80], [39, 96], [41, 110], [42, 71], [42, 100], [43, 31], [44, 33], [45, 83], [49, 15], [54, 107], [60, 107], [61, 46], [64, 29], [67, 75], [68, 90], [68, 95], [69, 0], [69, 9], [75, 30], [75, 62], [79, 24], [81, 58], [82, 15], [83, 29], [84, 44], [85, 60], [86, 90], [93, 75], [96, 49], [100, 31], [103, 97], [103, 101], [104, 14], [109, 87], [110, 46], [114, 16], [114, 74], [116, 9], [117, 87], [117, 99], [120, 103]], "r_opt": 72.86091408974517, "r2_num": 189632530, "r2_den": 35721, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s9/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1ced48b52046ac75a512c17ee05076784a034e81 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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": 62.65079365079365, "y": 58.62433862433863, "r": 72.86091409074517} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s9/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s9/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s9/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f98dc69fa304c7d589c2231a1a561456f4d79323 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"points": [[2, 73], [2, 99], [3, 95], [5, 42], [7, 100], [12, 27], [12, 111], [13, 7], [17, 35], [23, 35], [23, 115], [24, 10], [26, 89], [29, 55], [29, 70], [31, 117], [32, 27], [32, 36], [34, 20], [39, 80], [39, 96], [41, 110], [42, 71], [42, 100], [43, 31], [44, 33], [45, 83], [49, 15], [54, 107], [60, 107], [61, 46], [64, 29], [67, 75], [68, 90], [68, 95], [69, 0], [69, 9], [75, 30], [75, 62], [79, 24], [81, 58], [82, 15], [83, 29], [84, 44], [85, 60], [86, 90], [93, 75], [96, 49], [100, 31], [103, 97], [103, 101], [104, 14], [109, 87], [110, 46], [114, 16], [114, 74], [116, 9], [117, 87], [117, 99], [120, 103]], "r_opt": 72.86091408974517, "r2_num": 189632530, "r2_den": 35721, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s9/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s9/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-subgraph-isomorphism-l1-s3/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l1-s3/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fce01a9654031380aea0811602794e5d2d765ce5 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"n1": 3, "n2": 5, "edges1": [[0, 1]], "edges2": [[2, 3]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s3/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8a151f37e8bfdb4e31034f525d2cd314797e5496 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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' +{"p": [2, 3, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s3/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s3/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-l1-s3/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fce01a9654031380aea0811602794e5d2d765ce5 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"n1": 3, "n2": 5, "edges1": [[0, 1]], "edges2": [[2, 3]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s3/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l1-s3/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l1-s4/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l1-s4/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..78d9ad8d934883d149cb0ae8c33543fd8efb2fd9 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"n1": 4, "n2": 5, "edges1": [[1, 2], [2, 3], [1, 3]], "edges2": [[0, 3], [0, 2], [2, 3]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s4/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0d1bd52f05ab11b11ec869932c9c87cc7ccc1682 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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' +{"p": [1, 3, 2, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s4/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s4/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-l1-s4/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..78d9ad8d934883d149cb0ae8c33543fd8efb2fd9 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"n1": 4, "n2": 5, "edges1": [[1, 2], [2, 3], [1, 3]], "edges2": [[0, 3], [0, 2], [2, 3]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s4/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l1-s4/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l5-s2/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s2/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4055ede82ef8f9a452a16cd05f4ba30851389e32 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"n1": 13, "n2": 26, "edges1": [[9, 12], [6, 9], [4, 11], [5, 11], [7, 10], [2, 3], [0, 3], [9, 10], [5, 8], [0, 7], [5, 9], [6, 8], [1, 4], [0, 2], [1, 2], [3, 12], [8, 10], [8, 11], [4, 6], [1, 7], [2, 5], [1, 6], [3, 4], [2, 8], [0, 1], [8, 9], [1, 10], [3, 6], [2, 10], [6, 7], [1, 9], [5, 10], [0, 4], [4, 12], [2, 12], [5, 6], [11, 12], [0, 10], [3, 5], [10, 11], [4, 9], [1, 8], [0, 12], [1, 12]], "edges2": [[6, 14], [22, 24], [15, 18], [12, 17], [4, 20], [15, 23], [7, 21], [21, 22], [4, 14], [23, 24], [3, 11], [19, 22], [22, 23], [23, 25], [1, 20], [7, 17], [1, 16], [1, 13], [4, 10], [2, 9], [10, 19], [0, 8], [0, 7], [18, 24], [12, 22], [7, 20], [2, 3], [0, 18], [17, 22], [11, 23], [11, 22], [8, 23], [4, 24], [9, 15], [3, 21], [8, 22], [15, 20], [13, 17], [5, 15], [3, 17], [2, 17], [6, 12], [5, 18], [3, 7], [11, 25], [24, 25], [9, 16], [0, 15], [5, 14], [21, 23], [10, 16], [17, 25], [6, 25], [5, 25], [20, 24], [19, 20], [8, 18], [1, 15], [7, 14], [10, 13], [4, 5], [0, 9], [13, 16], [16, 17], [20, 23], [6, 15], [3, 14], [0, 4], [16, 21], [4, 25], [13, 15], [0, 19], [0, 2], [2, 11], [10, 11], [2, 23], [20, 21], [3, 12], [9, 13], [1, 9], [14, 23], [0, 11], [2, 15], [10, 20], [10, 21], [3, 15], [20, 25], [6, 13], [1, 6], [7, 23], [13, 24], [17, 21], [9, 22], [0, 5], [6, 23], [11, 24], [7, 24], [12, 14], [11, 16], [9, 17], [7, 22], [6, 24], [4, 22], [8, 12], [13, 21], [8, 15], [5, 22], [8, 16], [5, 8], [1, 12], [1, 8], [7, 8], [2, 8], [5, 12], [17, 18], [2, 13], [10, 12], [12, 15], [12, 20], [3, 20], [0, 21], [6, 16], [8, 20], [15, 16], [7, 18], [5, 10], [12, 19], [18, 23], [16, 25], [3, 5], [3, 19], [5, 9], [10, 14], [2, 18], [16, 20], [16, 18], [9, 24], [4, 16], [14, 17], [8, 21], [11, 21], [2, 4], [14, 18], [4, 13], [2, 25], [3, 13], [3, 6], [5, 23], [7, 19], [13, 23], [0, 13], [2, 5], [3, 24], [0, 25], [5, 6], [4, 6], [19, 25], [14, 20], [0, 24], [7, 12], [10, 25], [1, 24], [9, 12], [0, 23], [2, 7], [5, 7], [9, 23], [12, 18], [19, 23], [2, 22], [11, 14], [19, 24], [17, 24], [12, 16], [8, 19], [0, 16], [13, 22], [0, 6]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s2/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..56649eb2df6929dcaf764664b32bdaa8163849da --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"p": [16, 20, 21, 11, 25, 22, 24, 1, 7, 19, 8, 5, 10]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s2/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s2/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n1, n2 = inst["n1"], inst["n2"] + p = int_list(ans.get("p"), n1, 0, n2 - 1, "p") + if len(set(p)) != n1: + raise Invalid("p is not injective") + e1 = {(min(u, v), max(u, v)) for u, v in inst["edges1"]} + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + for u in range(n1): + for v in range(u + 1, n1): + a, b = min(p[u], p[v]), max(p[u], p[v]) + if ((u, v) in e1) != ((a, b) in e2): + raise Invalid(f"pair ({u}, {v}) is not preserved") + return None, {} diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s2/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4055ede82ef8f9a452a16cd05f4ba30851389e32 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"n1": 13, "n2": 26, "edges1": [[9, 12], [6, 9], [4, 11], [5, 11], [7, 10], [2, 3], [0, 3], [9, 10], [5, 8], [0, 7], [5, 9], [6, 8], [1, 4], [0, 2], [1, 2], [3, 12], [8, 10], [8, 11], [4, 6], [1, 7], [2, 5], [1, 6], [3, 4], [2, 8], [0, 1], [8, 9], [1, 10], [3, 6], [2, 10], [6, 7], [1, 9], [5, 10], [0, 4], [4, 12], [2, 12], [5, 6], [11, 12], [0, 10], [3, 5], [10, 11], [4, 9], [1, 8], [0, 12], [1, 12]], "edges2": [[6, 14], [22, 24], [15, 18], [12, 17], [4, 20], [15, 23], [7, 21], [21, 22], [4, 14], [23, 24], [3, 11], [19, 22], [22, 23], [23, 25], [1, 20], [7, 17], [1, 16], [1, 13], [4, 10], [2, 9], [10, 19], [0, 8], [0, 7], [18, 24], [12, 22], [7, 20], [2, 3], [0, 18], [17, 22], [11, 23], [11, 22], [8, 23], [4, 24], [9, 15], [3, 21], [8, 22], [15, 20], [13, 17], [5, 15], [3, 17], [2, 17], [6, 12], [5, 18], [3, 7], [11, 25], [24, 25], [9, 16], [0, 15], [5, 14], [21, 23], [10, 16], [17, 25], [6, 25], [5, 25], [20, 24], [19, 20], [8, 18], [1, 15], [7, 14], [10, 13], [4, 5], [0, 9], [13, 16], [16, 17], [20, 23], [6, 15], [3, 14], [0, 4], [16, 21], [4, 25], [13, 15], [0, 19], [0, 2], [2, 11], [10, 11], [2, 23], [20, 21], [3, 12], [9, 13], [1, 9], [14, 23], [0, 11], [2, 15], [10, 20], [10, 21], [3, 15], [20, 25], [6, 13], [1, 6], [7, 23], [13, 24], [17, 21], [9, 22], [0, 5], [6, 23], [11, 24], [7, 24], [12, 14], [11, 16], [9, 17], [7, 22], [6, 24], [4, 22], [8, 12], [13, 21], [8, 15], [5, 22], [8, 16], [5, 8], [1, 12], [1, 8], [7, 8], [2, 8], [5, 12], [17, 18], [2, 13], [10, 12], [12, 15], [12, 20], [3, 20], [0, 21], [6, 16], [8, 20], [15, 16], [7, 18], [5, 10], [12, 19], [18, 23], [16, 25], [3, 5], [3, 19], [5, 9], [10, 14], [2, 18], [16, 20], [16, 18], [9, 24], [4, 16], [14, 17], [8, 21], [11, 21], [2, 4], [14, 18], [4, 13], [2, 25], [3, 13], [3, 6], [5, 23], [7, 19], [13, 23], [0, 13], [2, 5], [3, 24], [0, 25], [5, 6], [4, 6], [19, 25], [14, 20], [0, 24], [7, 12], [10, 25], [1, 24], [9, 12], [0, 23], [2, 7], [5, 7], [9, 23], [12, 18], [19, 23], [2, 22], [11, 14], [19, 24], [17, 24], [12, 16], [8, 19], [0, 16], [13, 22], [0, 6]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s2/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s2/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s5/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l5-s5/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7fbaa89c48d96a7166b7f1b046cf56ec4a5adbb1 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"n1": 24, "n2": 26, "edges1": [[6, 10], [7, 22], [4, 15], [2, 19], [9, 12], [8, 11], [7, 14], [14, 23], [2, 10], [14, 17], [0, 8], [13, 15], [3, 16], [0, 6], [1, 3], [5, 8], [18, 22], [6, 16], [1, 4], [19, 22], [8, 14], [7, 19], [15, 23], [8, 18], [10, 23], [8, 22], [3, 12], [1, 15], [14, 16], [3, 9], [19, 23], [12, 22], [12, 18], [3, 20], [9, 17], [8, 23], [11, 17], [3, 6], [4, 18], [5, 7], [15, 18], [10, 17], [1, 18], [17, 21], [4, 21], [4, 19], [11, 16], [6, 11], [4, 16], [12, 15], [2, 8], [0, 4], [6, 13], [3, 5], [2, 22], [20, 23], [16, 22], [5, 18], [6, 8], [0, 7], [10, 20], [7, 12], [4, 22], [17, 23], [14, 21], [11, 22], [0, 14], [8, 17], [6, 19], [2, 13], [15, 17], [8, 19], [4, 20], [14, 18], [5, 6], [1, 21], [0, 5], [4, 17], [3, 7], [11, 23], [11, 12], [0, 18], [5, 12], [4, 14], [15, 22], [4, 13], [5, 11], [12, 19], [0, 16], [10, 18], [9, 10], [4, 23], [7, 11], [0, 9], [3, 21], [1, 12], [7, 13], [18, 21], [1, 10], [2, 11], [5, 13], [6, 15], [14, 20], [12, 13], [15, 19], [9, 19], [0, 23], [4, 8], [9, 14], [6, 18], [0, 2], [1, 20], [10, 21], [18, 19], [3, 10], [3, 18], [1, 14], [20, 22], [1, 9], [11, 15], [9, 16], [10, 19], [5, 15], [12, 20], [10, 11], [0, 11], [7, 16], [1, 17], [22, 23], [1, 11], [0, 22], [1, 5], [11, 21], [13, 17], [5, 16], [14, 15], [3, 22], [8, 13], [19, 20], [9, 21], [3, 23], [7, 23], [7, 20], [2, 6], [13, 23], [2, 3]], "edges2": [[14, 21], [4, 25], [9, 21], [2, 16], [15, 21], [9, 13], [4, 9], [18, 21], [11, 12], [5, 12], [3, 19], [9, 25], [12, 23], [10, 18], [4, 24], [17, 23], [4, 18], [3, 20], [5, 15], [1, 21], [22, 25], [5, 23], [0, 21], [3, 7], [0, 17], [13, 19], [0, 8], [2, 14], [8, 23], [2, 25], [10, 24], [1, 19], [6, 25], [8, 9], [10, 21], [20, 24], [7, 8], [3, 8], [0, 3], [8, 20], [13, 16], [4, 5], [8, 24], [6, 14], [15, 23], [5, 25], [6, 7], [9, 22], [2, 5], [12, 24], [10, 17], [6, 13], [0, 10], [20, 22], [3, 6], [11, 15], [6, 12], [6, 15], [8, 13], [4, 11], [6, 10], [3, 18], [9, 15], [2, 13], [1, 4], [17, 25], [13, 18], [7, 21], [6, 16], [11, 13], [17, 22], [2, 7], [5, 9], [11, 14], [7, 12], [7, 18], [19, 23], [1, 15], [5, 10], [13, 24], [12, 25], [1, 3], [13, 15], [13, 20], [6, 18], [9, 23], [0, 1], [1, 25], [8, 11], [8, 19], [0, 6], [16, 25], [11, 18], [11, 20], [3, 16], [2, 4], [14, 15], [16, 22], [13, 22], [5, 7], [19, 20], [4, 7], [11, 21], [15, 25], [4, 23], [8, 17], [3, 12], [0, 13], [5, 16], [15, 19], [11, 22], [1, 5], [19, 25], [9, 12], [15, 22], [19, 22], [12, 13], [3, 17], [11, 19], [10, 20], [5, 13], [7, 22], [14, 23], [3, 15], [1, 6], [10, 25], [2, 22], [5, 24], [5, 8], [14, 18], [5, 20], [16, 24], [19, 24], [13, 17], [1, 17], [5, 18], [9, 17], [3, 10], [0, 4], [2, 15], [16, 23], [2, 21], [7, 17], [10, 14], [1, 22], [2, 24], [0, 18], [4, 21], [0, 14], [5, 19], [12, 20], [7, 9], [2, 23], [3, 22], [20, 21], [9, 14], [2, 12], [12, 16], [4, 15], [4, 14], [11, 23], [17, 19], [4, 20], [2, 8], [8, 12], [22, 24], [5, 6], [6, 11], [7, 25], [13, 14], [15, 24], [7, 24], [21, 24], [19, 21], [4, 22], [10, 11], [0, 9], [0, 7]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s5/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..48f9d1493c22ea46cbb16a095e4c6f452604dde2 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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' +{"p": [24, 0, 16, 3, 4, 8, 12, 19, 2, 10, 6, 13, 17, 23, 21, 9, 20, 14, 7, 25, 1, 18, 22, 15]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s5/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s5/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-s5/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7fbaa89c48d96a7166b7f1b046cf56ec4a5adbb1 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"n1": 24, "n2": 26, "edges1": [[6, 10], [7, 22], [4, 15], [2, 19], [9, 12], [8, 11], [7, 14], [14, 23], [2, 10], [14, 17], [0, 8], [13, 15], [3, 16], [0, 6], [1, 3], [5, 8], [18, 22], [6, 16], [1, 4], [19, 22], [8, 14], [7, 19], [15, 23], [8, 18], [10, 23], [8, 22], [3, 12], [1, 15], [14, 16], [3, 9], [19, 23], [12, 22], [12, 18], [3, 20], [9, 17], [8, 23], [11, 17], [3, 6], [4, 18], [5, 7], [15, 18], [10, 17], [1, 18], [17, 21], [4, 21], [4, 19], [11, 16], [6, 11], [4, 16], [12, 15], [2, 8], [0, 4], [6, 13], [3, 5], [2, 22], [20, 23], [16, 22], [5, 18], [6, 8], [0, 7], [10, 20], [7, 12], [4, 22], [17, 23], [14, 21], [11, 22], [0, 14], [8, 17], [6, 19], [2, 13], [15, 17], [8, 19], [4, 20], [14, 18], [5, 6], [1, 21], [0, 5], [4, 17], [3, 7], [11, 23], [11, 12], [0, 18], [5, 12], [4, 14], [15, 22], [4, 13], [5, 11], [12, 19], [0, 16], [10, 18], [9, 10], [4, 23], [7, 11], [0, 9], [3, 21], [1, 12], [7, 13], [18, 21], [1, 10], [2, 11], [5, 13], [6, 15], [14, 20], [12, 13], [15, 19], [9, 19], [0, 23], [4, 8], [9, 14], [6, 18], [0, 2], [1, 20], [10, 21], [18, 19], [3, 10], [3, 18], [1, 14], [20, 22], [1, 9], [11, 15], [9, 16], [10, 19], [5, 15], [12, 20], [10, 11], [0, 11], [7, 16], [1, 17], [22, 23], [1, 11], [0, 22], [1, 5], [11, 21], [13, 17], [5, 16], [14, 15], [3, 22], [8, 13], [19, 20], [9, 21], [3, 23], [7, 23], [7, 20], [2, 6], [13, 23], [2, 3]], "edges2": [[14, 21], [4, 25], [9, 21], [2, 16], [15, 21], [9, 13], [4, 9], [18, 21], [11, 12], [5, 12], [3, 19], [9, 25], [12, 23], [10, 18], [4, 24], [17, 23], [4, 18], [3, 20], [5, 15], [1, 21], [22, 25], [5, 23], [0, 21], [3, 7], [0, 17], [13, 19], [0, 8], [2, 14], [8, 23], [2, 25], [10, 24], [1, 19], [6, 25], [8, 9], [10, 21], [20, 24], [7, 8], [3, 8], [0, 3], [8, 20], [13, 16], [4, 5], [8, 24], [6, 14], [15, 23], [5, 25], [6, 7], [9, 22], [2, 5], [12, 24], [10, 17], [6, 13], [0, 10], [20, 22], [3, 6], [11, 15], [6, 12], [6, 15], [8, 13], [4, 11], [6, 10], [3, 18], [9, 15], [2, 13], [1, 4], [17, 25], [13, 18], [7, 21], [6, 16], [11, 13], [17, 22], [2, 7], [5, 9], [11, 14], [7, 12], [7, 18], [19, 23], [1, 15], [5, 10], [13, 24], [12, 25], [1, 3], [13, 15], [13, 20], [6, 18], [9, 23], [0, 1], [1, 25], [8, 11], [8, 19], [0, 6], [16, 25], [11, 18], [11, 20], [3, 16], [2, 4], [14, 15], [16, 22], [13, 22], [5, 7], [19, 20], [4, 7], [11, 21], [15, 25], [4, 23], [8, 17], [3, 12], [0, 13], [5, 16], [15, 19], [11, 22], [1, 5], [19, 25], [9, 12], [15, 22], [19, 22], [12, 13], [3, 17], [11, 19], [10, 20], [5, 13], [7, 22], [14, 23], [3, 15], [1, 6], [10, 25], [2, 22], [5, 24], [5, 8], [14, 18], [5, 20], [16, 24], [19, 24], [13, 17], [1, 17], [5, 18], [9, 17], [3, 10], [0, 4], [2, 15], [16, 23], [2, 21], [7, 17], [10, 14], [1, 22], [2, 24], [0, 18], [4, 21], [0, 14], [5, 19], [12, 20], [7, 9], [2, 23], [3, 22], [20, 21], [9, 14], [2, 12], [12, 16], [4, 15], [4, 14], [11, 23], [17, 19], [4, 20], [2, 8], [8, 12], [22, 24], [5, 6], [6, 11], [7, 25], [13, 14], [15, 24], [7, 24], [21, 24], [19, 21], [4, 22], [10, 11], [0, 9], [0, 7]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s5/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l5-s5/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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/optimize-ae-p31-furstenberg-sarkozy-k3/environment/Dockerfile b/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==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-p31-furstenberg-sarkozy-k3/environment/instance.json b/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5db7f9f9fc3d42f2f4cdd23c4b09400329c9f5f6 --- /dev/null +++ b/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/environment/instance.json @@ -0,0 +1 @@ +{"k": 3, "max_m": 1000000, "max_size": 3000, "direction": "maximize", "family": "ae_p31_furstenberg_sarkozy", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/solution/solve.sh b/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a6b70d3980d6717b96cf259c20ad050910afdefb --- /dev/null +++ b/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"m": 91, "residues": [0, 16, 18, 22, 38, 41, 44, 47, 63, 67, 69, 85, 87, 89]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/tests/check.py b/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..296ac248623e85e3ff5e54bab1732a30c7889e1a --- /dev/null +++ b/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/tests/check.py @@ -0,0 +1,47 @@ +"""Ruzsa-type modular construction for the Furstenberg-Sarkozy problem. + +A subset A of Z/mZ (m square-free) with no two distinct elements differing by a non-zero k-th power residue +gives subsets of {1..N} with no k-th power differences of size N^{(k-1)/k + log|A|/(k log m)} (Ruzsa 1984). +Score = that exponent. Mirrors upstream `get_score` (furstenberg_sarkozy_problem.ipynb), which silently +reduced/deduplicated the list; here entries must be distinct residues in [0, m). +""" +import math + +import numpy as np + +from run import Invalid, as_int, int_list + + +def squarefree(m): + d = 2 + while d * d <= m: + if m % (d * d) == 0: + return False + d += 1 + return True + + +def check(inst, ans): + k = inst["k"] + m = as_int(ans.get("m"), "m", 2, inst["max_m"]) + if not squarefree(m): + raise Invalid("m must be square-free") + A = int_list(ans.get("residues"), None, 0, m - 1, "residues") + if not 1 <= len(A) <= inst["max_size"]: + raise Invalid(f"need 1 <= |A| <= {inst['max_size']}") + if len(set(A)) != len(A): + raise Invalid("duplicate residues") + y = np.arange(1, m, dtype=np.int64) + r = y % m + for _ in range(k - 1): + r = (r * y) % m + forb = np.zeros(m, dtype=bool) + forb[r] = True + forb[0] = False + a = np.array(A, dtype=np.int64) + diff = (a[:, None] - a[None, :]) % m + np.fill_diagonal(diff, 0) + if forb[diff].any(): + i, j = np.argwhere(forb[diff])[0] + raise Invalid(f"{A[i]} - {A[j]} is a non-zero k-th power residue mod {m} (k = {k})") + return (k - 1) / k + math.log(len(A)) / (k * math.log(m)), {"m": m, "size": len(A)} diff --git a/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/tests/instance.json b/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2ff2f15419010180e0675396620641406df90dd8 --- /dev/null +++ b/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/tests/instance.json @@ -0,0 +1 @@ +{"k": 3, "max_m": 1000000, "max_size": 3000, "direction": "maximize", "best_known": 0.8616817796994568, "baseline": 0.6666666666666666, "family": "ae_p31_furstenberg_sarkozy", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/tests/run.py b/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/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-p31-furstenberg-sarkozy-k3/tests/test.sh b/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p31-furstenberg-sarkozy-k3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n100/environment/Dockerfile b/tasks/optimize-ae-p41-sphere-max-volume-n100/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n100/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n100/environment/instance.json b/tasks/optimize-ae-p41-sphere-max-volume-n100/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4f2b7ee6a90480da38ea60e9968113a1128afd56 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n100/environment/instance.json @@ -0,0 +1 @@ +{"n": 100, "direction": "maximize", "family": "ae_p41_sphere_max_volume", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n100/solution/solve.sh b/tasks/optimize-ae-p41-sphere-max-volume-n100/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..27904ef4132e8d2d448a51a6f88692577cd9b35f --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n100/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"points": [[0.073833351885545, -0.170104592095713, 0.982656126983034], [-0.177341695235486, 0.079857726287005, 0.98090400482579], [0.250587811960338, 0.131115839180673, 0.959173803443817], [-0.227862237897793, -0.309878157821803, 0.923067889077058], [-0.083553435910935, 0.411249076518349, 0.907685529470578], [0.391728946560412, -0.265694272009011, 0.880883071836593], [-0.518684105781253, -0.058201634384294, 0.852982630634938], [0.272771252654725, 0.447607779537711, 0.851612070970399], [0.101841516917694, -0.505343411316493, 0.856887590102058], [-0.448378965016579, 0.332084145931557, 0.829865304583563], [0.588673477109153, 0.016487494288508, 0.808202759139256], [-0.500669352411902, -0.425143053524028, 0.75404481537619], [0.0775253720939, 0.686117351905618, 0.723348322798722], [0.439798483422533, -0.595178262076013, 0.672562361667242], [-0.741327658798737, 0.16374266184003, 0.650862230424784], [0.579586405604204, 0.345309684567972, 0.738133334962164], [-0.217072467000234, -0.656388324204006, 0.722519142943001], [-0.320194644769304, 0.667161615208717, 0.672585138590762], [0.702743966796423, -0.282801620781659, 0.652820159319927], [-0.765439736450661, -0.264137834030181, 0.586799126189011], [0.425805386049638, 0.680400126018441, 0.596443997140727], [0.13635624878715, -0.769065973823772, 0.624455363755641], [-0.654545460142105, 0.524560419864287, 0.544432370932481], [0.840585951393698, 0.120074089027058, 0.52820211232432], [-0.543736909916453, -0.682975325863713, 0.487744684292779], [-0.068273662124464, 0.839239527708715, 0.539458730758311], [0.671042493465269, -0.614486891441663, 0.414858809970664], [-0.916197190588067, 0.042994924736717, 0.398414538396151], [0.724446852591152, 0.534533366142954, 0.43525950678952], [-0.126997799950947, -0.887695366717024, 0.442570327424634], [-0.499187665416743, 0.791079797799357, 0.353559652971759], [0.899303767268954, -0.251249463029269, 0.357947540155497], [-0.818802140801413, -0.484702750368082, 0.307613878107995], [0.210605090473684, 0.901973358239059, 0.376947684557852], [0.340346304255546, -0.87777491735898, 0.337158104804004], [-0.874601640367787, 0.381229881290518, 0.299559256704236], [0.912843048922076, 0.340951526394104, 0.224654456185893], [-0.406247576364625, -0.891301342101847, 0.20135745396015], [-0.208963211239092, 0.925853089840982, 0.314849856885077], [0.83323916212131, -0.537507315322373, 0.129608582595105], [-0.960222458695331, -0.188650420383565, 0.205873380275836], [0.563366346340131, 0.794299825002586, 0.227389858639808], [0.013337525017151, -0.991460522918563, 0.12972332835873], [-0.721616461431413, 0.67672654905118, 0.145982397570686], [0.990290584055841, 0.026367996031794, 0.136489149442761], [-0.71432081951494, -0.695320883089954, 0.07921260219505], [-0.011737949657895, 0.998943244551323, 0.04443663694638], [0.605429247913529, -0.79502494602716, 0.037292907708691], [-0.984254927758904, 0.173186459679005, 0.035336770737677], [0.805512009293496, 0.592425484158844, 0.013507353668068], [-0.267821997438708, -0.960560342101776, -0.074801115427914], [-0.414928518672711, 0.909642625001041, -0.019611710106074], [0.951914742085123, -0.301322850716091, -0.055343142640636], [-0.909387487826631, -0.408071469131885, -0.080573401721123], [0.331469800630283, 0.943003590586819, 0.029529636138749], [0.315368482814565, -0.944635271537407, -0.090592073685774], [-0.869129635139966, 0.477317913453876, -0.129542606186178], [0.942845098963281, 0.286600284109824, -0.170009989439118], [-0.560613492355427, -0.806172672415924, -0.189203949321411], [-0.134436792818281, 0.952159258737308, -0.274443973767971], [0.769175470744074, -0.586580644046366, -0.253559151354833], [-0.984450023989259, -0.081144892433427, -0.155800053592787], [0.582009585750837, 0.79132674479229, -0.187261381685003], [-0.003927381317941, -0.96211361628144, -0.27262055139302], [-0.650979170463935, 0.723497726780967, -0.229732799061998], [0.966333711632048, -0.03146337314202, -0.255360948294675], [-0.759810636564833, -0.546674462633584, -0.351901731264888], [0.22102525489299, 0.929268200357925, -0.295987243818094], [0.493453674077528, -0.771715283628738, -0.401196949830386], [-0.904402477974688, 0.204624393414098, -0.374412894346812], [0.760458653855903, 0.513907854616983, -0.396990368571629], [-0.308088983895785, -0.8671080761009, -0.391413799402446], [-0.394837781596147, 0.808577979363862, -0.436239358050242], [0.84432977473886, -0.286225342381516, -0.452970512139598], [-0.870405690688742, -0.191352622887731, -0.453627718873791], [0.436226877994615, 0.733496767369103, -0.521237568843755], [0.204818161181484, -0.851661657874034, -0.482412625619901], [-0.686244596107605, 0.489094541757721, -0.538381726599181], [0.816144609491396, 0.139267560895094, -0.560814160734613], [-0.49184126272536, -0.653950900336277, -0.574839449090002], [-0.000155876082976, 0.802653942811619, -0.596444988068144], [0.576970643538791, -0.519670637591562, -0.630116897821041], [-0.716911504537777, 0.082563788130419, -0.692257983378261], [0.563533939744869, 0.417373002849734, -0.712902009569213], [-0.113629077406762, -0.765296920585161, -0.633568509405697], [-0.351897268082952, 0.623355418371321, -0.698280985780703], [0.664077144014496, -0.176842977160439, -0.726448971522834], [-0.631999922888147, -0.331441807515543, -0.700515828300979], [0.23982484205379, 0.600677823730597, -0.762673060499811], [0.194853441070733, -0.604974067496623, -0.772035306290771], [-0.454942147560721, 0.299789507846574, -0.838542720055423], [0.512665979397536, 0.088982912717867, -0.853964656653078], [-0.260837209290139, -0.488339833875332, -0.832759363141805], [-0.096308391984418, 0.492856569622733, -0.86476418485798], [0.359811724898042, -0.295992076676284, -0.884830047619743], [-0.414934525157292, -0.105828869773243, -0.903675600066202], [0.221177826670129, 0.312629943926841, -0.923765601843768], [-0.035926984716091, -0.27691217846843, -0.960223357966821], [-0.139127049155097, 0.130251933242821, -0.981671074280944], [0.183914304662891, -0.013596066499935, -0.982848246432833]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n100/tests/check.py b/tasks/optimize-ae-p41-sphere-max-volume-n100/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..58b6521809868700c39ccbae7ef07cd7c99c8d83 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n100/tests/check.py @@ -0,0 +1,23 @@ +"""n points on the unit sphere maximizing the volume of their convex hull (AlphaEvolve problem 41). + +Upstream bug fixed: the notebook summed |det|/6 of origin-pyramids over (QJ-joggled) hull facets, which +over-counts whenever the origin lies outside the hull (e.g. all points in one hemisphere). We use the exact +hull volume (scipy ConvexHull.volume) of the normalized points, without joggling.""" +import numpy as np +from scipy.spatial import ConvexHull + +from run import Invalid, float_matrix + + +def check(inst, ans): + n = inst["n"] + p = np.array(float_matrix(ans.get("points"), n, 3, "points")) + nr = np.linalg.norm(p, axis=1) + if (nr < 1e-9).any() or (nr > 1e9).any(): + raise Invalid("every point needs a non-zero, finite norm (it is projected to the unit sphere)") + p = p / nr[:, None] + try: + v = ConvexHull(p).volume + except Exception as e: # degenerate (coplanar) input + raise Invalid(f"degenerate hull: {type(e).__name__}") + return float(v), {} diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n100/tests/instance.json b/tasks/optimize-ae-p41-sphere-max-volume-n100/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4681de63e6b7c9923b62ddb54dada89a20062135 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n100/tests/instance.json @@ -0,0 +1 @@ +{"n": 100, "direction": "maximize", "best_known": 3.961753339062, "baseline": 2.092960519369956, "family": "ae_p41_sphere_max_volume", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n100/tests/run.py b/tasks/optimize-ae-p41-sphere-max-volume-n100/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n100/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n100/tests/test.sh b/tasks/optimize-ae-p41-sphere-max-volume-n100/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n100/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n16/environment/Dockerfile b/tasks/optimize-ae-p41-sphere-max-volume-n16/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n16/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n16/environment/instance.json b/tasks/optimize-ae-p41-sphere-max-volume-n16/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d5b92afb676add09a90f83e258eb84488bd87a2b --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n16/environment/instance.json @@ -0,0 +1 @@ +{"n": 16, "direction": "maximize", "family": "ae_p41_sphere_max_volume", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n16/solution/solve.sh b/tasks/optimize-ae-p41-sphere-max-volume-n16/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..49d07c402d2830849ffaeb5eae52f0fd10f11d3a --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n16/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"points": [[0.149416994548902, -0.460244767572493, 0.875128170991035], [-0.444778213064685, 0.272659865497073, 0.853128911085602], [0.641401381220424, 0.265747422692511, 0.719710063498364], [-0.624032371210396, -0.592063051062083, 0.509946019936021], [0.013098870583807, 0.905216729959373, 0.424748268261436], [0.763420814154356, -0.604174749830634, 0.228388993130124], [-0.998932243644909, -0.040725120306146, 0.021813692548444], [0.674653869700649, 0.730602206961526, -0.105178758696268], [0.045039015782498, -0.993432894450579, 0.105178758696268], [-0.737587355722845, 0.674899292854263, -0.021813692548444], [0.973107553316303, -0.030002624814606, -0.228388993130124], [-0.573348152244774, -0.700614590860351, -0.424748268261433], [-0.095612478844117, 0.854876196089641, -0.509946019936021], [0.319186797070964, -0.616552684751887, -0.719710063498364], [-0.515814041493742, 0.078146885208486, -0.853128911085601], [0.410854906636044, 0.255634367859592, -0.875128170991035]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n16/tests/check.py b/tasks/optimize-ae-p41-sphere-max-volume-n16/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..58b6521809868700c39ccbae7ef07cd7c99c8d83 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n16/tests/check.py @@ -0,0 +1,23 @@ +"""n points on the unit sphere maximizing the volume of their convex hull (AlphaEvolve problem 41). + +Upstream bug fixed: the notebook summed |det|/6 of origin-pyramids over (QJ-joggled) hull facets, which +over-counts whenever the origin lies outside the hull (e.g. all points in one hemisphere). We use the exact +hull volume (scipy ConvexHull.volume) of the normalized points, without joggling.""" +import numpy as np +from scipy.spatial import ConvexHull + +from run import Invalid, float_matrix + + +def check(inst, ans): + n = inst["n"] + p = np.array(float_matrix(ans.get("points"), n, 3, "points")) + nr = np.linalg.norm(p, axis=1) + if (nr < 1e-9).any() or (nr > 1e9).any(): + raise Invalid("every point needs a non-zero, finite norm (it is projected to the unit sphere)") + p = p / nr[:, None] + try: + v = ConvexHull(p).volume + except Exception as e: # degenerate (coplanar) input + raise Invalid(f"degenerate hull: {type(e).__name__}") + return float(v), {} diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n16/tests/instance.json b/tasks/optimize-ae-p41-sphere-max-volume-n16/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d163d2083c7d57d05c7a461980f588fee4c5c663 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n16/tests/instance.json @@ -0,0 +1 @@ +{"n": 16, "direction": "maximize", "best_known": 2.886455392275, "baseline": 2.024790782548605, "family": "ae_p41_sphere_max_volume", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n16/tests/run.py b/tasks/optimize-ae-p41-sphere-max-volume-n16/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n16/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n16/tests/test.sh b/tasks/optimize-ae-p41-sphere-max-volume-n16/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n16/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/optimize-ae-p60-no5-on-sphere-n12/environment/Dockerfile b/tasks/optimize-ae-p60-no5-on-sphere-n12/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n12/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==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-n12/environment/instance.json b/tasks/optimize-ae-p60-no5-on-sphere-n12/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e0ab3569b9e670c72cf173db525fc7598da2b276 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n12/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "max_points": 48, "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-n12/solution/solve.sh b/tasks/optimize-ae-p60-no5-on-sphere-n12/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8c902d28ca5b8740e4a7bccde99b92ba28213d7f --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n12/solution/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": [[5, 9, 10], [10, 5, 8], [11, 11, 2], [0, 2, 10], [4, 9, 0], [3, 8, 9], [6, 10, 6], [3, 1, 11], [1, 4, 6], [8, 8, 2], [8, 7, 6], [0, 10, 0], [4, 2, 1], [1, 10, 7], [10, 11, 7], [4, 3, 7], [9, 0, 9], [10, 6, 0], [4, 3, 5], [7, 2, 0], [2, 0, 11], [0, 5, 1], [9, 9, 8], [0, 9, 2], [11, 1, 1], [9, 6, 10], [7, 1, 2], [1, 2, 5], [7, 3, 10], [11, 7, 11], [1, 11, 9], [8, 0, 11], [11, 0, 3]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p60-no5-on-sphere-n12/tests/check.py b/tasks/optimize-ae-p60-no5-on-sphere-n12/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..535715270fb95983b4b3896cda93a8746da1a961 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n12/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-n12/tests/instance.json b/tasks/optimize-ae-p60-no5-on-sphere-n12/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a7cc03c424d493f8ec042ad21ffa920d3a9d6352 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n12/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "max_points": 48, "direction": "maximize", "best_known": 33.0, "baseline": 26.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-n12/tests/run.py b/tasks/optimize-ae-p60-no5-on-sphere-n12/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n12/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/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-n12/tests/test.sh b/tasks/optimize-ae-p60-no5-on-sphere-n12/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n12/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt