diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s1/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s1/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aefefac4ebd5724633d4186cdc74484faed08d69 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"N": 577, "t": 178, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s1/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e760e3c318ffc3546c25b67025f764a6a499677a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"factors": [178, 178, 178, 178, 178, 178, 179, 179, 179, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 181, 181, 181, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 183, 183, 183, 183, 183, 183, 183, 183, 183, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 189, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, 191, 191, 191, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 193, 193, 194, 194, 194, 194, 194, 196, 196, 196, 196, 196, 196, 196, 196, 197, 197, 199, 199, 201, 201, 201, 201, 201, 201, 201, 201, 202, 202, 202, 202, 202, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 203, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 205, 206, 206, 206, 206, 206, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, 211, 211, 212, 212, 212, 212, 212, 212, 212, 212, 212, 212, 213, 213, 213, 213, 213, 213, 213, 213, 214, 214, 214, 214, 214, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 215, 218, 218, 218, 218, 218, 219, 219, 219, 219, 219, 219, 219, 223, 223, 226, 226, 226, 226, 226, 227, 227, 229, 229, 233, 233, 236, 236, 236, 236, 236, 236, 236, 236, 236, 237, 237, 237, 237, 237, 237, 237, 239, 239, 241, 241, 242, 242, 249, 249, 249, 249, 249, 249, 251, 251, 253, 253, 254, 254, 254, 254, 257, 257, 262, 262, 262, 262, 263, 263, 269, 269, 271, 271, 274, 274, 274, 274, 277, 277, 278, 278, 278, 278, 281, 281, 283, 283, 293, 298, 298, 298, 302, 302, 302, 307, 311, 313, 314, 314, 314, 317, 326, 326, 326, 331, 334, 334, 334, 337, 346, 346, 346, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s1/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s1/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s1/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..aefefac4ebd5724633d4186cdc74484faed08d69 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"N": 577, "t": 178, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s1/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s1/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s6/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s6/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7e990e40ba2e96355d21f372b0c5c94fd3f66351 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"N": 891, "t": 278, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s6/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..96e360a07ac11a19875a24d650efb04ef7a98dea --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"factors": [278, 278, 278, 278, 278, 278, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 280, 281, 281, 281, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, 283, 283, 283, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 284, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 285, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 286, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 287, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 288, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 289, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 290, 291, 291, 291, 291, 291, 291, 291, 291, 291, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 292, 293, 293, 293, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 295, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 296, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 297, 298, 298, 298, 298, 298, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 299, 300, 300, 300, 300, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 302, 302, 302, 302, 302, 303, 303, 303, 303, 303, 303, 303, 303, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 305, 307, 307, 309, 309, 309, 309, 309, 309, 309, 309, 311, 311, 313, 313, 314, 314, 314, 314, 314, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 316, 317, 317, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 318, 319, 319, 319, 319, 321, 321, 321, 321, 321, 321, 321, 321, 326, 326, 326, 326, 326, 327, 327, 327, 327, 327, 327, 327, 327, 331, 331, 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, 334, 334, 334, 334, 334, 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, 337, 337, 339, 339, 339, 339, 339, 339, 339, 343, 343, 343, 346, 346, 346, 346, 346, 347, 347, 349, 349, 353, 353, 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, 357, 358, 358, 358, 358, 359, 359, 362, 362, 362, 362, 367, 367, 373, 373, 379, 379, 381, 381, 381, 381, 381, 381, 381, 382, 382, 382, 382, 383, 383, 386, 386, 386, 386, 389, 389, 393, 393, 393, 393, 393, 393, 394, 394, 394, 394, 397, 397, 398, 398, 398, 398, 401, 401, 409, 409, 411, 411, 411, 411, 411, 411, 419, 419, 421, 421, 422, 422, 422, 422, 431, 431, 433, 433, 439, 439, 443, 443, 446, 446, 446, 449, 454, 454, 454, 457, 458, 458, 458, 461, 463, 466, 466, 466, 467, 478, 478, 478, 479, 482, 482, 482, 487, 491, 499, 502, 502, 502, 503, 509, 514, 514, 514, 521, 523, 526, 526, 526, 538, 538, 538, 541, 542, 542, 542, 547, 554, 554, 554, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s6/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-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-l4-s6/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7e990e40ba2e96355d21f372b0c5c94fd3f66351 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"N": 891, "t": 278, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s6/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s6/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s8/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s8/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2e074799306ab329fc98096f6592ccf4a87caa92 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"N": 1117, "t": 350, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s8/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..37e9ddbdbbf7a7f2fd95ea037d107db260756859 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"factors": [350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 353, 353, 353, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 354, 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, 356, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 357, 358, 358, 358, 358, 358, 358, 359, 359, 359, 360, 360, 360, 360, 360, 360, 360, 360, 360, 360, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 362, 362, 362, 362, 362, 362, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 363, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 367, 367, 367, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 368, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 369, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 371, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 373, 373, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 379, 379, 380, 381, 381, 381, 381, 381, 381, 381, 381, 382, 382, 382, 382, 382, 383, 383, 386, 386, 386, 386, 386, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 388, 389, 389, 391, 391, 393, 393, 393, 393, 393, 393, 393, 393, 394, 394, 394, 394, 394, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 395, 397, 397, 398, 398, 398, 398, 398, 401, 401, 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, 402, 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, 404, 406, 406, 406, 406, 406, 406, 406, 406, 409, 409, 411, 411, 411, 411, 411, 411, 411, 411, 412, 412, 412, 412, 412, 412, 412, 412, 412, 412, 415, 415, 415, 415, 415, 415, 415, 415, 415, 415, 415, 415, 415, 417, 417, 417, 417, 417, 417, 417, 417, 419, 419, 421, 421, 422, 422, 422, 422, 422, 428, 428, 428, 428, 428, 428, 428, 428, 428, 428, 431, 431, 433, 433, 436, 436, 436, 436, 436, 436, 436, 436, 436, 436, 439, 439, 443, 443, 446, 446, 446, 446, 446, 447, 447, 447, 447, 447, 447, 447, 449, 449, 452, 452, 452, 452, 452, 452, 452, 452, 452, 453, 453, 453, 453, 453, 453, 453, 454, 454, 454, 454, 457, 457, 458, 458, 458, 458, 461, 461, 463, 463, 466, 466, 466, 466, 467, 467, 471, 471, 471, 471, 471, 471, 471, 478, 478, 478, 478, 479, 479, 482, 482, 482, 482, 487, 487, 489, 489, 489, 489, 489, 489, 491, 491, 499, 499, 501, 501, 501, 501, 501, 501, 502, 502, 502, 502, 503, 503, 509, 509, 514, 514, 514, 514, 519, 519, 519, 519, 519, 519, 521, 521, 523, 523, 526, 526, 526, 526, 538, 538, 538, 538, 541, 541, 542, 542, 542, 542, 547, 547, 554, 554, 554, 554, 557, 557, 562, 562, 562, 563, 566, 566, 566, 569, 571, 577, 586, 586, 586, 587, 593, 599, 601, 607, 613, 614, 614, 614, 617, 619, 622, 622, 622, 626, 626, 626, 631, 634, 634, 634, 641, 643, 647, 653, 659, 661, 662, 662, 662, 673, 674, 674, 674, 677, 683, 691, 694, 694, 694, 698, 698, 698, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s8/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-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-l4-s8/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2e074799306ab329fc98096f6592ccf4a87caa92 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"N": 1117, "t": 350, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s8/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p38-factorial-factors-l4-s8/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l4-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p52-erdos-squarefree-l4-s3/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l4-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l4-s3/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l4-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..99f3aca1ebf5436d5e4d565aa9d695174ef4adce --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l4-s3/environment/instance.json @@ -0,0 +1 @@ +{"N": 2865, "t": 115, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l4-s3/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l4-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7d8bc5a0b58eddd46ef465a14998dc6c62934c28 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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' +{"A": [7, 32, 57, 82, 107, 132, 157, 182, 207, 232, 257, 282, 307, 332, 357, 382, 407, 432, 457, 482, 507, 532, 557, 582, 607, 632, 657, 682, 707, 732, 757, 782, 807, 832, 857, 882, 907, 932, 957, 982, 1007, 1032, 1057, 1082, 1107, 1132, 1157, 1182, 1207, 1232, 1257, 1282, 1307, 1332, 1357, 1382, 1407, 1432, 1457, 1482, 1507, 1532, 1557, 1582, 1607, 1632, 1657, 1682, 1707, 1732, 1757, 1782, 1807, 1832, 1857, 1882, 1907, 1932, 1957, 1982, 2007, 2032, 2057, 2082, 2107, 2132, 2157, 2182, 2207, 2232, 2257, 2282, 2307, 2332, 2357, 2382, 2407, 2432, 2457, 2482, 2507, 2532, 2557, 2582, 2607, 2632, 2657, 2682, 2707, 2732, 2757, 2782, 2807, 2832, 2857]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/check.py @@ -0,0 +1,38 @@ +"""Erdos squarefree problem (AlphaEvolve problem 52): A in [1, N], |A| >= t, ab+1 NOT squarefree for all a, b in A +(a = b included). The repo's problem page says "square-free"; the notebook and the Erdos problem ask for +"never squarefree", which is what we check. Exact: for every pair we find a prime p with p^2 | ab+1.""" +import numpy as np + +from run import Invalid, int_list + + +def _primes(n): + s = np.ones(n + 1, dtype=bool) + s[:2] = False + for i in range(2, int(n ** .5) + 1): + if s[i]: + s[i * i::i] = False + return np.nonzero(s)[0] + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + a = ans.get("A") + if not isinstance(a, list) or not (t <= len(a) <= 2 * t + 20): + raise Invalid(f"A must be a list of {t}..{2 * t + 20} integers") + int_list(a, None, 1, n, "A") + if len(set(a)) != len(a): + raise Invalid("A must consist of distinct integers") + x = np.array(sorted(a), dtype=np.int64) + iu, ju = np.triu_indices(len(x)) + va, vb = x[iu], x[ju] + left = np.ones(len(iu), dtype=bool) # pairs without a square divisor found yet + for p in _primes(int((n * n + 1) ** .5) + 1): + q = int(p) * int(p) + idx = np.nonzero(left)[0] + hit = ((va[idx] % q) * (vb[idx] % q) + 1) % q == 0 + left[idx[hit]] = False + if not left.any(): + return None, {"size": len(a)} + k = int(np.nonzero(left)[0][0]) + raise Invalid(f"{int(va[k])}*{int(vb[k])}+1 = {int(va[k]) * int(vb[k]) + 1} is squarefree") diff --git a/tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..99f3aca1ebf5436d5e4d565aa9d695174ef4adce --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/instance.json @@ -0,0 +1 @@ +{"N": 2865, "t": 115, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l4-s3/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l4-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l4-s4/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l4-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l4-s4/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l4-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fc0381f487810286223a7439b5c940da8b4f5dad --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l4-s4/environment/instance.json @@ -0,0 +1 @@ +{"N": 2532, "t": 102, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l4-s4/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l4-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..66aa389dd88ec92f64c98d31a9309a9218fdc0a3 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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' +{"A": [7, 32, 57, 82, 107, 132, 157, 182, 207, 232, 257, 282, 307, 332, 357, 382, 407, 432, 457, 482, 507, 532, 557, 582, 607, 632, 657, 682, 707, 732, 757, 782, 807, 832, 857, 882, 907, 932, 957, 982, 1007, 1032, 1057, 1082, 1107, 1132, 1157, 1182, 1207, 1232, 1257, 1282, 1307, 1332, 1357, 1382, 1407, 1432, 1457, 1482, 1507, 1532, 1557, 1582, 1607, 1632, 1657, 1682, 1707, 1732, 1757, 1782, 1807, 1832, 1857, 1882, 1907, 1932, 1957, 1982, 2007, 2032, 2057, 2082, 2107, 2132, 2157, 2182, 2207, 2232, 2257, 2282, 2307, 2332, 2357, 2382, 2407, 2432, 2457, 2482, 2507, 2532]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/check.py @@ -0,0 +1,38 @@ +"""Erdos squarefree problem (AlphaEvolve problem 52): A in [1, N], |A| >= t, ab+1 NOT squarefree for all a, b in A +(a = b included). The repo's problem page says "square-free"; the notebook and the Erdos problem ask for +"never squarefree", which is what we check. Exact: for every pair we find a prime p with p^2 | ab+1.""" +import numpy as np + +from run import Invalid, int_list + + +def _primes(n): + s = np.ones(n + 1, dtype=bool) + s[:2] = False + for i in range(2, int(n ** .5) + 1): + if s[i]: + s[i * i::i] = False + return np.nonzero(s)[0] + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + a = ans.get("A") + if not isinstance(a, list) or not (t <= len(a) <= 2 * t + 20): + raise Invalid(f"A must be a list of {t}..{2 * t + 20} integers") + int_list(a, None, 1, n, "A") + if len(set(a)) != len(a): + raise Invalid("A must consist of distinct integers") + x = np.array(sorted(a), dtype=np.int64) + iu, ju = np.triu_indices(len(x)) + va, vb = x[iu], x[ju] + left = np.ones(len(iu), dtype=bool) # pairs without a square divisor found yet + for p in _primes(int((n * n + 1) ** .5) + 1): + q = int(p) * int(p) + idx = np.nonzero(left)[0] + hit = ((va[idx] % q) * (vb[idx] % q) + 1) % q == 0 + left[idx[hit]] = False + if not left.any(): + return None, {"size": len(a)} + k = int(np.nonzero(left)[0][0]) + raise Invalid(f"{int(va[k])}*{int(vb[k])}+1 = {int(va[k]) * int(vb[k]) + 1} is squarefree") diff --git a/tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fc0381f487810286223a7439b5c940da8b4f5dad --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/instance.json @@ -0,0 +1 @@ +{"N": 2532, "t": 102, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l4-s4/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l4-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-all-interval-l4-s1/environment/Dockerfile b/tasks/construct-mc-all-interval-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-l4-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-all-interval-l4-s1/environment/instance.json b/tasks/construct-mc-all-interval-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9eec7aa2a434a122e57711f272ffdb53bff41755 --- /dev/null +++ b/tasks/construct-mc-all-interval-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 28, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l4-s1/solution/solve.sh b/tasks/construct-mc-all-interval-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7b0483ab329ff05b3d1b4652d78b82fff92fb3d3 --- /dev/null +++ b/tasks/construct-mc-all-interval-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [0, 27, 1, 26, 2, 25, 3, 24, 4, 23, 5, 22, 6, 21, 7, 20, 8, 19, 9, 18, 10, 17, 11, 16, 12, 15, 13, 14]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l4-s1/tests/check.py b/tasks/construct-mc-all-interval-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l4-s1/tests/check.py @@ -0,0 +1,17 @@ +"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + d = [abs(x[i + 1] - x[i]) for i in range(n - 1)] + if sorted(d) != list(range(1, n)): + raise Invalid("consecutive differences are not a permutation of 1..n-1") + seqs = {"x": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-all-interval-l4-s1/tests/instance.json b/tasks/construct-mc-all-interval-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9eec7aa2a434a122e57711f272ffdb53bff41755 --- /dev/null +++ b/tasks/construct-mc-all-interval-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 28, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l4-s1/tests/run.py b/tasks/construct-mc-all-interval-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-all-interval-l4-s1/tests/test.sh b/tasks/construct-mc-all-interval-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-l4-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-all-interval-l4-s6/environment/Dockerfile b/tasks/construct-mc-all-interval-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-l4-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-all-interval-l4-s6/environment/instance.json b/tasks/construct-mc-all-interval-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ed8d77b58bf1d0109442033a32275bccc0695baf --- /dev/null +++ b/tasks/construct-mc-all-interval-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l4-s6/solution/solve.sh b/tasks/construct-mc-all-interval-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f23a4da64aca9a4ad99b807402947f3f1fd6d714 --- /dev/null +++ b/tasks/construct-mc-all-interval-l4-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [0, 19, 1, 18, 2, 17, 3, 16, 4, 15, 5, 14, 6, 13, 7, 12, 8, 11, 9, 10]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l4-s6/tests/check.py b/tasks/construct-mc-all-interval-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l4-s6/tests/check.py @@ -0,0 +1,17 @@ +"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + d = [abs(x[i + 1] - x[i]) for i in range(n - 1)] + if sorted(d) != list(range(1, n)): + raise Invalid("consecutive differences are not a permutation of 1..n-1") + seqs = {"x": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-all-interval-l4-s6/tests/instance.json b/tasks/construct-mc-all-interval-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ed8d77b58bf1d0109442033a32275bccc0695baf --- /dev/null +++ b/tasks/construct-mc-all-interval-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l4-s6/tests/run.py b/tasks/construct-mc-all-interval-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-l4-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-all-interval-l4-s6/tests/test.sh b/tasks/construct-mc-all-interval-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-l4-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-bibd-l6-s2/environment/Dockerfile b/tasks/construct-mc-bibd-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-bibd-l6-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-bibd-l6-s2/environment/instance.json b/tasks/construct-mc-bibd-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e1d4f9a24aa7a531660d50bbd5ffb715427e2be4 --- /dev/null +++ b/tasks/construct-mc-bibd-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"v": 49, "k": 7, "lambda": 1, "b": 56, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l6-s2/solution/solve.sh b/tasks/construct-mc-bibd-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..94a702f949efb8cd354ae2d2df4b2ce19a4682fd --- /dev/null +++ b/tasks/construct-mc-bibd-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' +{"blocks": [[0, 7, 14, 21, 28, 35, 42], [1, 8, 15, 22, 29, 36, 43], [2, 9, 16, 23, 30, 37, 44], [3, 10, 17, 24, 31, 38, 45], [4, 11, 18, 25, 32, 39, 46], [5, 12, 19, 26, 33, 40, 47], [6, 13, 20, 27, 34, 41, 48], [0, 8, 16, 24, 32, 40, 48], [1, 9, 17, 25, 33, 41, 42], [2, 10, 18, 26, 34, 35, 43], [3, 11, 19, 27, 28, 36, 44], [4, 12, 20, 21, 29, 37, 45], [5, 13, 14, 22, 30, 38, 46], [6, 7, 15, 23, 31, 39, 47], [0, 9, 18, 27, 29, 38, 47], [1, 10, 19, 21, 30, 39, 48], [2, 11, 20, 22, 31, 40, 42], [3, 12, 14, 23, 32, 41, 43], [4, 13, 15, 24, 33, 35, 44], [5, 7, 16, 25, 34, 36, 45], [6, 8, 17, 26, 28, 37, 46], [0, 10, 20, 23, 33, 36, 46], [1, 11, 14, 24, 34, 37, 47], [2, 12, 15, 25, 28, 38, 48], [3, 13, 16, 26, 29, 39, 42], [4, 7, 17, 27, 30, 40, 43], [5, 8, 18, 21, 31, 41, 44], [6, 9, 19, 22, 32, 35, 45], [0, 11, 15, 26, 30, 41, 45], [1, 12, 16, 27, 31, 35, 46], [2, 13, 17, 21, 32, 36, 47], [3, 7, 18, 22, 33, 37, 48], [4, 8, 19, 23, 34, 38, 42], [5, 9, 20, 24, 28, 39, 43], [6, 10, 14, 25, 29, 40, 44], [0, 12, 17, 22, 34, 39, 44], [1, 13, 18, 23, 28, 40, 45], [2, 7, 19, 24, 29, 41, 46], [3, 8, 20, 25, 30, 35, 47], [4, 9, 14, 26, 31, 36, 48], [5, 10, 15, 27, 32, 37, 42], [6, 11, 16, 21, 33, 38, 43], [0, 13, 19, 25, 31, 37, 43], [1, 7, 20, 26, 32, 38, 44], [2, 8, 14, 27, 33, 39, 45], [3, 9, 15, 21, 34, 40, 46], [4, 10, 16, 22, 28, 41, 47], [5, 11, 17, 23, 29, 35, 48], [6, 12, 18, 24, 30, 36, 42], [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, 27], [28, 29, 30, 31, 32, 33, 34], [35, 36, 37, 38, 39, 40, 41], [42, 43, 44, 45, 46, 47, 48]]} +RLMATH_EOF diff --git a/tasks/construct-mc-bibd-l6-s2/tests/check.py b/tasks/construct-mc-bibd-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c4b5da62477026f27ff9869fe33602fcc41e2ea9 --- /dev/null +++ b/tasks/construct-mc-bibd-l6-s2/tests/check.py @@ -0,0 +1,25 @@ +"""Balanced incomplete block design BIBD(v, k, lambda) (MathConstraint bibd, CC-BY-4.0). +Answer = list of b blocks; every block is a k-subset of {0..v-1}, every pair of points lies in exactly +lambda blocks (which forces every point to lie in r blocks). Repeated blocks are allowed, as upstream +(its 0/1 incidence-matrix model does not forbid equal columns).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + v, k, lam, b = inst["v"], inst["k"], inst["lambda"], inst["b"] + blocks = ans.get("blocks") + if not isinstance(blocks, list) or len(blocks) != b: + raise Invalid(f"blocks must be a list of exactly {b} blocks") + pair = {} + for B in blocks: + B = int_list(B, k, 0, v - 1, "block") + if len(set(B)) != k: + raise Invalid("a block contains a repeated point") + for p in itertools.combinations(sorted(B), 2): + pair[p] = pair.get(p, 0) + 1 + for p in itertools.combinations(range(v), 2): + if pair.get(p, 0) != lam: + raise Invalid(f"points {p} lie together in {pair.get(p, 0)} blocks, need {lam}") + return None, {} diff --git a/tasks/construct-mc-bibd-l6-s2/tests/instance.json b/tasks/construct-mc-bibd-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e1d4f9a24aa7a531660d50bbd5ffb715427e2be4 --- /dev/null +++ b/tasks/construct-mc-bibd-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"v": 49, "k": 7, "lambda": 1, "b": 56, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l6-s2/tests/run.py b/tasks/construct-mc-bibd-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-bibd-l6-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-bibd-l6-s2/tests/test.sh b/tasks/construct-mc-bibd-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-bibd-l6-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-costas-array-l2-s0/environment/Dockerfile b/tasks/construct-mc-costas-array-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-costas-array-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-costas-array-l2-s0/environment/instance.json b/tasks/construct-mc-costas-array-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d201639e10aa52fc8da9464a30c86313c85c7454 --- /dev/null +++ b/tasks/construct-mc-costas-array-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 11, "fixed": [], "family": "mc_costas_array", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-costas-array-l2-s0/solution/solve.sh b/tasks/construct-mc-costas-array-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8a15c03f8047d3c21f3bf07d34c153ef1b3b0552 --- /dev/null +++ b/tasks/construct-mc-costas-array-l2-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [9, 3, 8, 4, 1, 0, 7, 2, 5, 6, 10]} +RLMATH_EOF diff --git a/tasks/construct-mc-costas-array-l2-s0/tests/check.py b/tasks/construct-mc-costas-array-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c86323a5b639b23787ecd4d5f358b986bbd91b6c --- /dev/null +++ b/tasks/construct-mc-costas-array-l2-s0/tests/check.py @@ -0,0 +1,22 @@ +"""Costas array of order n (MathConstraint costas_array, CC-BY-4.0). Accepts any valid array. +Adapted from pilot/grader.py check_costas; adds the optional fixed entries (upstream partial assignment).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + for name, i, v in inst.get("fixed", []): + if x[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + vecs = set() + for i, j in itertools.combinations(range(n), 2): + d = (j - i, x[j] - x[i]) + if d in vecs: + raise Invalid(f"repeated displacement vector {d}") + vecs.add(d) + return None, {} diff --git a/tasks/construct-mc-costas-array-l2-s0/tests/instance.json b/tasks/construct-mc-costas-array-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d201639e10aa52fc8da9464a30c86313c85c7454 --- /dev/null +++ b/tasks/construct-mc-costas-array-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 11, "fixed": [], "family": "mc_costas_array", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-costas-array-l2-s0/tests/run.py b/tasks/construct-mc-costas-array-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-costas-array-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-costas-array-l2-s0/tests/test.sh b/tasks/construct-mc-costas-array-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-costas-array-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-costas-array-l6-s1/environment/Dockerfile b/tasks/construct-mc-costas-array-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-costas-array-l6-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-costas-array-l6-s1/environment/instance.json b/tasks/construct-mc-costas-array-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cd13ec31d7443389a6f2562af9f2ea312a529c33 --- /dev/null +++ b/tasks/construct-mc-costas-array-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 30, "fixed": [], "family": "mc_costas_array", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-costas-array-l6-s1/solution/solve.sh b/tasks/construct-mc-costas-array-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..958a53beb6a63f16ac7bf47a6feadd7b07751330 --- /dev/null +++ b/tasks/construct-mc-costas-array-l6-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [0, 23, 17, 28, 13, 25, 3, 2, 9, 22, 24, 10, 15, 11, 8, 29, 6, 12, 1, 16, 4, 26, 27, 20, 7, 5, 19, 14, 18, 21]} +RLMATH_EOF diff --git a/tasks/construct-mc-costas-array-l6-s1/tests/check.py b/tasks/construct-mc-costas-array-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c86323a5b639b23787ecd4d5f358b986bbd91b6c --- /dev/null +++ b/tasks/construct-mc-costas-array-l6-s1/tests/check.py @@ -0,0 +1,22 @@ +"""Costas array of order n (MathConstraint costas_array, CC-BY-4.0). Accepts any valid array. +Adapted from pilot/grader.py check_costas; adds the optional fixed entries (upstream partial assignment).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + for name, i, v in inst.get("fixed", []): + if x[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + vecs = set() + for i, j in itertools.combinations(range(n), 2): + d = (j - i, x[j] - x[i]) + if d in vecs: + raise Invalid(f"repeated displacement vector {d}") + vecs.add(d) + return None, {} diff --git a/tasks/construct-mc-costas-array-l6-s1/tests/instance.json b/tasks/construct-mc-costas-array-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cd13ec31d7443389a6f2562af9f2ea312a529c33 --- /dev/null +++ b/tasks/construct-mc-costas-array-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 30, "fixed": [], "family": "mc_costas_array", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-costas-array-l6-s1/tests/run.py b/tasks/construct-mc-costas-array-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-costas-array-l6-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-costas-array-l6-s1/tests/test.sh b/tasks/construct-mc-costas-array-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-costas-array-l6-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-debruijn-l3-s2/environment/Dockerfile b/tasks/construct-mc-debruijn-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-debruijn-l3-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-debruijn-l3-s2/environment/instance.json b/tasks/construct-mc-debruijn-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2a301bd59688c1d43d0bfab06919ec2af1bbb86a --- /dev/null +++ b/tasks/construct-mc-debruijn-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"b": 3, "n": 4, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l3-s2/solution/solve.sh b/tasks/construct-mc-debruijn-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fbaacbeddb8851efee76dc9fa182c4ac83511e43 --- /dev/null +++ b/tasks/construct-mc-debruijn-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' +{"seq": [0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 1, 1, 0, 0, 1, 2, 0, 0, 2, 1, 0, 0, 2, 2, 0, 1, 0, 1, 0, 2, 0, 1, 1, 1, 0, 1, 1, 2, 0, 1, 2, 1, 0, 1, 2, 2, 0, 2, 0, 2, 1, 1, 0, 2, 1, 2, 0, 2, 2, 1, 0, 2, 2, 2, 1, 1, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, 2, 2, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-mc-debruijn-l3-s2/tests/check.py b/tasks/construct-mc-debruijn-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c9d6f0177d2b3bde8306d74939ee9704c1501a23 --- /dev/null +++ b/tasks/construct-mc-debruijn-l3-s2/tests/check.py @@ -0,0 +1,15 @@ +"""De Bruijn sequence B(b, n) (MathConstraint debruijn, CC-BY-4.0). Accepts any valid cyclic sequence.""" +from run import Invalid, int_list + + +def check(inst, ans): + b, n = inst["b"], inst["n"] + m = b ** n + x = int_list(ans.get("seq"), m, 0, b - 1, "seq") + seen = set() + for i in range(m): + w = tuple(x[(i + k) % m] for k in range(n)) + if w in seen: + raise Invalid(f"window {w} occurs twice") + seen.add(w) + return None, {} diff --git a/tasks/construct-mc-debruijn-l3-s2/tests/instance.json b/tasks/construct-mc-debruijn-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2a301bd59688c1d43d0bfab06919ec2af1bbb86a --- /dev/null +++ b/tasks/construct-mc-debruijn-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"b": 3, "n": 4, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l3-s2/tests/run.py b/tasks/construct-mc-debruijn-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-debruijn-l3-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-debruijn-l3-s2/tests/test.sh b/tasks/construct-mc-debruijn-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-debruijn-l3-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-graceful-graph-l3-s1/environment/Dockerfile b/tasks/construct-mc-graceful-graph-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l3-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-graceful-graph-l3-s1/environment/instance.json b/tasks/construct-mc-graceful-graph-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0a8cc377072493ac9f9eaa850a83322df9e0235d --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"k": 3, "p": 6, "num_vertices": 18, "edges": [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [13, 14], [15, 16], [15, 17], [16, 17], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16], [14, 17]], "fixed": [], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l3-s1/solution/solve.sh b/tasks/construct-mc-graceful-graph-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..87d8751e47f32ab5e95b72c643bf0445bd796efd --- /dev/null +++ b/tasks/construct-mc-graceful-graph-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' +{"labels": [1, 2, 32, 33, 20, 5, 0, 29, 3, 4, 10, 26, 9, 30, 19, 23, 6, 31]} +RLMATH_EOF diff --git a/tasks/construct-mc-graceful-graph-l3-s1/tests/check.py b/tasks/construct-mc-graceful-graph-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f4d33af1d63c0495c3b32d34db6ae10f0fb45923 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l3-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-l3-s1/tests/instance.json b/tasks/construct-mc-graceful-graph-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0a8cc377072493ac9f9eaa850a83322df9e0235d --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"k": 3, "p": 6, "num_vertices": 18, "edges": [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [13, 14], [15, 16], [15, 17], [16, 17], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16], [14, 17]], "fixed": [], "family": "mc_graceful_graph", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graceful-graph-l3-s1/tests/run.py b/tasks/construct-mc-graceful-graph-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l3-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-graceful-graph-l3-s1/tests/test.sh b/tasks/construct-mc-graceful-graph-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graceful-graph-l3-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-graph-k-coloring-l2-s0/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-graph-k-coloring-l2-s0/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..942bffd8f3583a4d59f3afa02aa019f6e160d341 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 32, "k": 4, "edges": [[0, 5], [0, 10], [0, 24], [0, 28], [1, 5], [1, 15], [1, 16], [1, 18], [1, 19], [1, 20], [1, 25], [2, 13], [2, 15], [2, 20], [2, 22], [3, 23], [3, 30], [3, 31], [4, 12], [4, 23], [4, 29], [5, 8], [5, 12], [5, 17], [5, 19], [5, 23], [5, 30], [6, 8], [6, 13], [6, 28], [6, 29], [6, 30], [6, 31], [7, 18], [7, 23], [7, 28], [7, 31], [8, 10], [8, 31], [9, 11], [9, 12], [9, 18], [9, 22], [9, 25], [10, 12], [10, 16], [10, 26], [10, 29], [11, 14], [11, 16], [11, 17], [11, 26], [12, 13], [12, 14], [12, 17], [12, 30], [14, 17], [14, 21], [14, 25], [14, 27], [15, 24], [15, 26], [15, 28], [16, 18], [16, 20], [16, 30], [17, 23], [17, 28], [17, 29], [18, 27], [18, 29], [19, 20], [21, 23], [21, 31], [22, 28], [23, 25], [23, 30], [23, 31], [24, 25], [24, 30], [24, 31], [25, 26], [27, 28], [28, 30], [30, 31]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l2-s0/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f3bc22c01cc205215bf056d938cb3523fdbbfe72 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l2-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [0, 0, 0, 0, 0, 1, 0, 0, 2, 0, 1, 1, 2, 1, 0, 1, 2, 3, 1, 2, 1, 3, 1, 2, 2, 1, 0, 3, 2, 2, 3, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l2-s0/tests/check.py b/tasks/construct-mc-graph-k-coloring-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l2-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-l2-s0/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..942bffd8f3583a4d59f3afa02aa019f6e160d341 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 32, "k": 4, "edges": [[0, 5], [0, 10], [0, 24], [0, 28], [1, 5], [1, 15], [1, 16], [1, 18], [1, 19], [1, 20], [1, 25], [2, 13], [2, 15], [2, 20], [2, 22], [3, 23], [3, 30], [3, 31], [4, 12], [4, 23], [4, 29], [5, 8], [5, 12], [5, 17], [5, 19], [5, 23], [5, 30], [6, 8], [6, 13], [6, 28], [6, 29], [6, 30], [6, 31], [7, 18], [7, 23], [7, 28], [7, 31], [8, 10], [8, 31], [9, 11], [9, 12], [9, 18], [9, 22], [9, 25], [10, 12], [10, 16], [10, 26], [10, 29], [11, 14], [11, 16], [11, 17], [11, 26], [12, 13], [12, 14], [12, 17], [12, 30], [14, 17], [14, 21], [14, 25], [14, 27], [15, 24], [15, 26], [15, 28], [16, 18], [16, 20], [16, 30], [17, 23], [17, 28], [17, 29], [18, 27], [18, 29], [19, 20], [21, 23], [21, 31], [22, 28], [23, 25], [23, 30], [23, 31], [24, 25], [24, 30], [24, 31], [25, 26], [27, 28], [28, 30], [30, 31]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l2-s0/tests/run.py b/tasks/construct-mc-graph-k-coloring-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-graph-k-coloring-l2-s0/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-graph-k-coloring-l2-s7/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-mc-graph-k-coloring-l2-s7/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..63fce7e58fa237ccc4f5686152ab60a999a0f730 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 32, "k": 4, "edges": [[0, 2], [0, 8], [0, 22], [0, 31], [1, 4], [1, 8], [1, 15], [1, 23], [2, 4], [2, 28], [2, 31], [3, 7], [3, 17], [3, 18], [3, 21], [3, 26], [4, 24], [5, 6], [5, 13], [5, 15], [5, 18], [6, 13], [6, 15], [6, 21], [6, 24], [6, 27], [6, 29], [7, 9], [7, 16], [7, 19], [7, 24], [8, 16], [8, 20], [8, 23], [9, 20], [10, 18], [10, 22], [11, 28], [12, 16], [12, 19], [12, 23], [12, 24], [12, 29], [13, 17], [13, 25], [14, 21], [15, 19], [15, 22], [15, 29], [15, 30], [16, 22], [16, 26], [17, 22], [17, 25], [17, 30], [18, 31], [19, 23], [19, 27], [20, 30], [21, 26], [21, 31], [23, 30], [23, 31], [24, 29], [27, 31]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l2-s7/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e2edbc31bcd9641d5b9c2f5f79b4e91caca6cea0 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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' +{"coloring": [0, 0, 1, 0, 2, 0, 1, 1, 1, 0, 0, 0, 0, 2, 0, 3, 2, 3, 1, 2, 2, 3, 1, 3, 3, 0, 1, 0, 2, 2, 0, 2]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l2-s7/tests/check.py b/tasks/construct-mc-graph-k-coloring-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l2-s7/tests/check.py @@ -0,0 +1,11 @@ +"""Proper k-colouring of a given graph (MathConstraint graph_k_coloring, CC-BY-4.0). Any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-mc-graph-k-coloring-l2-s7/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..63fce7e58fa237ccc4f5686152ab60a999a0f730 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 32, "k": 4, "edges": [[0, 2], [0, 8], [0, 22], [0, 31], [1, 4], [1, 8], [1, 15], [1, 23], [2, 4], [2, 28], [2, 31], [3, 7], [3, 17], [3, 18], [3, 21], [3, 26], [4, 24], [5, 6], [5, 13], [5, 15], [5, 18], [6, 13], [6, 15], [6, 21], [6, 24], [6, 27], [6, 29], [7, 9], [7, 16], [7, 19], [7, 24], [8, 16], [8, 20], [8, 23], [9, 20], [10, 18], [10, 22], [11, 28], [12, 16], [12, 19], [12, 23], [12, 24], [12, 29], [13, 17], [13, 25], [14, 21], [15, 19], [15, 22], [15, 29], [15, 30], [16, 22], [16, 26], [17, 22], [17, 25], [17, 30], [18, 31], [19, 23], [19, 27], [20, 30], [21, 26], [21, 31], [23, 30], [23, 31], [24, 29], [27, 31]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l2-s7/tests/run.py b/tasks/construct-mc-graph-k-coloring-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-mc-graph-k-coloring-l2-s7/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-mc-graph-k-coloring-l6-s8/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l6-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-graph-k-coloring-l6-s8/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cd4c1b1c3942df12d35cc46d6b81c924bbbf1660 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 250, "k": 4, "edges": [[0, 12], [0, 31], [0, 41], [0, 44], [0, 87], [0, 121], [0, 147], [0, 155], [0, 174], [0, 233], [1, 50], [1, 54], [1, 74], [1, 80], [1, 93], [1, 114], [1, 136], [1, 142], [1, 186], [2, 7], [2, 38], [2, 141], [2, 182], [2, 213], [2, 214], [2, 218], [3, 5], [3, 20], [3, 24], [3, 38], [3, 60], [3, 85], [3, 249], [4, 6], [4, 32], [4, 42], [4, 62], [4, 68], [4, 105], [4, 109], [4, 119], [4, 127], [4, 149], [4, 223], [4, 228], [5, 11], [5, 20], [5, 43], [5, 93], [5, 109], [5, 115], [5, 125], [5, 127], [5, 166], [5, 187], [5, 202], [5, 232], [5, 244], [5, 249], [6, 13], [6, 19], [6, 59], [6, 70], [6, 133], [6, 174], [6, 189], [6, 191], [6, 244], [6, 245], [6, 247], [7, 80], [7, 151], [7, 158], [7, 188], [8, 15], [8, 21], [8, 64], [8, 73], [8, 149], [8, 162], [9, 36], [9, 66], [9, 79], [9, 87], [9, 90], [9, 150], [9, 157], [9, 199], [10, 32], [10, 55], [10, 56], [10, 88], [10, 115], [10, 183], [10, 197], [10, 226], [10, 242], [11, 36], [11, 47], [11, 126], [11, 151], [11, 178], [12, 61], [12, 78], [12, 162], [12, 166], [12, 211], [12, 217], [12, 230], [13, 112], [13, 149], [13, 151], [13, 191], [13, 203], [13, 240], [14, 92], [14, 154], [14, 179], [14, 208], [15, 29], [15, 31], [15, 51], [15, 78], [15, 85], [15, 105], [15, 115], [15, 130], [15, 134], [15, 183], [16, 42], [16, 84], [16, 98], [16, 133], [16, 148], [16, 152], [16, 221], [16, 222], [16, 235], [16, 237], [17, 40], [17, 89], [17, 123], [17, 164], [17, 227], [18, 74], [18, 77], [18, 123], [18, 189], [18, 220], [18, 244], [19, 39], [19, 58], [19, 65], [19, 74], [19, 186], [20, 26], [20, 52], [20, 63], [20, 81], [20, 102], [20, 123], [20, 211], [21, 62], [21, 73], [21, 130], [21, 145], [21, 155], [21, 171], [21, 191], [21, 206], [21, 219], [21, 222], [22, 26], [22, 37], [22, 42], [22, 58], [22, 78], [22, 104], [22, 139], [22, 147], [22, 161], [22, 176], [22, 209], [23, 30], [23, 47], [23, 95], [23, 141], [23, 151], [23, 157], [23, 172], [23, 246], [24, 27], [24, 33], [24, 117], [24, 197], [24, 207], [25, 26], [25, 36], [25, 57], [25, 78], [25, 122], [25, 127], [25, 145], [25, 150], [25, 154], [25, 156], [25, 196], [26, 100], [26, 114], [26, 125], [26, 148], [26, 156], [26, 158], [26, 224], [26, 230], [27, 30], [27, 45], [27, 65], [27, 68], [27, 86], [27, 92], [27, 104], [27, 138], [27, 150], [27, 159], [27, 244], [28, 62], [28, 109], [28, 112], [28, 115], [28, 131], [28, 151], [28, 171], [28, 188], [28, 198], [28, 232], [29, 48], [29, 71], [29, 99], [29, 103], [29, 120], [29, 208], [30, 66], [30, 74], [30, 104], [30, 115], [30, 176], [30, 202], [30, 231], [31, 37], [31, 98], [31, 105], [31, 135], [31, 152], [31, 179], [31, 182], [31, 208], [31, 222], [31, 239], [32, 38], [32, 53], [32, 170], [32, 216], [32, 221], [33, 78], [33, 99], [33, 106], [33, 110], [33, 120], [33, 148], [33, 210], [34, 58], [34, 100], [34, 113], [34, 131], [34, 156], [34, 160], [34, 162], [34, 233], [34, 249], [35, 42], [35, 57], [35, 89], [35, 93], [35, 151], [35, 187], [35, 207], [35, 212], [35, 214], [35, 245], [36, 83], [36, 152], [36, 164], [36, 192], [36, 197], [36, 216], [36, 242], [36, 246], [37, 54], [37, 87], [37, 121], [37, 133], [37, 201], [37, 203], [37, 211], [38, 57], [38, 99], [38, 134], [38, 145], [38, 147], [38, 201], [38, 243], [39, 79], [39, 80], [39, 89], [39, 101], [39, 127], [39, 171], [39, 183], [40, 69], [40, 103], [40, 104], [40, 146], [40, 180], [41, 52], [41, 70], [41, 119], [41, 153], [41, 163], [41, 207], [41, 216], [41, 232], [42, 81], [42, 104], [42, 120], [42, 170], [42, 182], [42, 191], [43, 64], [43, 92], [43, 97], [43, 99], [43, 153], [43, 175], [43, 207], [43, 210], [44, 61], [44, 76], [44, 78], [44, 86], [44, 112], [44, 116], [44, 120], [44, 131], [44, 156], [44, 172], [44, 181], [44, 236], [45, 71], [45, 85], [45, 117], [45, 127], [45, 132], [45, 178], [45, 179], [45, 187], [45, 204], [45, 217], [45, 231], [46, 61], [46, 68], [46, 77], [46, 97], [46, 158], [46, 225], [47, 79], [47, 120], [47, 133], [47, 210], [48, 100], [48, 140], [48, 143], [48, 154], [48, 207], [48, 210], [48, 216], [48, 246], [49, 82], [49, 137], [49, 144], [49, 155], [49, 188], [49, 203], [50, 67], [50, 80], [50, 136], [50, 209], [51, 87], [51, 128], [51, 145], [51, 168], [51, 203], [51, 210], [52, 56], [52, 143], [52, 152], [52, 156], [52, 169], [52, 200], [52, 209], [53, 83], [53, 98], [53, 103], [53, 116], [53, 127], [53, 147], [53, 222], [53, 244], [54, 100], [54, 151], [54, 158], [54, 166], [54, 179], [54, 214], [54, 236], [55, 56], [55, 65], [55, 144], [55, 201], [55, 202], [55, 211], [56, 64], [56, 124], [56, 176], [56, 187], [56, 195], [56, 220], [56, 244], [57, 71], [57, 100], [57, 115], [57, 149], [57, 154], [57, 180], [57, 198], [57, 201], [58, 61], [58, 66], [58, 84], [58, 170], [58, 199], [58, 225], [58, 236], [59, 118], [59, 126], [59, 180], [59, 210], [60, 73], [60, 115], [60, 122], [60, 167], [60, 192], [60, 211], [60, 215], [61, 122], [61, 166], [61, 175], [61, 200], [61, 210], [61, 220], [61, 228], [62, 82], [62, 83], [62, 90], [62, 101], [62, 152], [62, 167], [62, 182], [62, 206], [62, 207], [62, 246], [63, 87], [63, 99], [63, 137], [63, 177], [63, 217], [63, 220], [63, 221], [64, 91], [64, 111], [64, 141], [64, 158], [64, 165], [64, 171], [64, 192], [65, 72], [65, 116], [65, 127], [65, 132], [65, 190], [65, 228], [66, 93], [66, 99], [66, 127], [66, 210], [66, 231], [66, 247], [67, 82], [67, 107], [67, 112], [67, 173], [67, 209], [68, 118], [68, 125], [68, 158], [69, 81], [69, 87], [69, 103], [69, 121], [69, 140], [69, 150], [69, 175], [69, 184], [69, 189], [69, 217], [69, 221], [69, 226], [70, 77], [70, 93], [70, 125], [70, 140], [70, 178], [70, 197], [70, 231], [70, 247], [71, 74], [71, 99], [71, 102], [71, 105], [71, 121], [71, 177], [71, 206], [71, 213], [72, 97], [72, 104], [72, 142], [72, 176], [72, 178], [72, 195], [72, 199], [72, 219], [72, 224], [73, 81], [73, 97], [73, 118], [73, 176], [73, 186], [74, 175], [74, 202], [74, 226], [74, 229], [75, 94], [75, 143], [75, 171], [75, 218], [75, 230], [76, 81], [76, 84], [76, 106], [76, 133], [76, 155], [76, 197], [76, 227], [77, 87], [77, 104], [77, 106], [77, 157], [77, 174], [78, 154], [78, 176], [78, 201], [79, 124], [79, 126], [79, 146], [79, 153], [79, 187], [80, 95], [80, 107], [80, 138], [80, 150], [80, 163], [80, 193], [80, 211], [80, 225], [80, 227], [80, 241], [80, 247], [81, 209], [81, 219], [81, 224], [81, 228], [81, 238], [82, 110], [82, 144], [82, 194], [82, 199], [82, 201], [82, 237], [83, 116], [83, 119], [83, 132], [83, 136], [83, 152], [83, 171], [83, 173], [83, 208], [83, 222], [83, 224], [84, 105], [84, 119], [84, 122], [84, 127], [84, 129], [84, 202], [84, 208], [85, 91], [85, 94], [85, 123], [85, 135], [86, 91], [86, 164], [86, 166], [86, 169], [86, 180], [86, 215], [86, 216], [86, 232], [86, 238], [87, 122], [87, 200], [87, 243], [88, 89], [88, 101], [88, 123], [88, 130], [88, 145], [88, 146], [88, 164], [88, 168], [88, 179], [88, 185], [88, 197], [88, 199], [88, 248], [89, 106], [89, 140], [89, 143], [89, 146], [89, 162], [89, 240], [90, 111], [90, 132], [90, 160], [90, 234], [91, 102], [91, 109], [91, 143], [91, 152], [91, 226], [92, 111], [92, 126], [92, 128], [93, 117], [93, 139], [93, 170], [93, 213], [93, 217], [94, 97], [94, 122], [94, 145], [94, 166], [94, 188], [94, 232], [94, 233], [94, 249], [95, 108], [95, 110], [95, 146], [95, 153], [95, 179], [95, 207], [95, 209], [95, 220], [96, 123], [96, 127], [96, 135], [96, 141], [96, 177], [96, 238], [96, 243], [97, 217], [97, 219], [97, 226], [97, 248], [98, 120], [98, 145], [98, 164], [98, 178], [98, 223], [98, 240], [99, 113], [99, 126], [99, 141], [99, 175], [99, 181], [99, 184], [99, 221], [99, 224], [99, 236], [99, 245], [100, 120], [100, 158], [100, 212], [100, 217], [100, 228], [100, 234], [100, 241], [100, 247], [101, 124], [101, 133], [101, 143], [101, 178], [101, 186], [101, 193], [101, 206], [101, 214], [101, 229], [102, 222], [103, 121], [103, 123], [103, 135], [103, 147], [103, 149], [103, 165], [103, 184], [103, 224], [104, 105], [104, 117], [104, 172], [104, 182], [104, 184], [104, 187], [105, 157], [105, 163], [105, 224], [105, 248], [106, 135], [106, 150], [106, 235], [107, 116], [107, 142], [107, 196], [107, 233], [108, 155], [108, 156], [108, 161], [108, 195], [108, 201], [108, 234], [109, 117], [109, 249], [110, 111], [110, 185], [111, 157], [111, 172], [111, 218], [111, 235], [111, 236], [111, 238], [112, 139], [112, 181], [112, 201], [113, 134], [113, 135], [113, 136], [113, 137], [113, 166], [113, 188], [114, 135], [114, 145], [114, 150], [114, 160], [114, 179], [114, 237], [115, 233], [115, 243], [116, 123], [116, 151], [116, 168], [116, 171], [116, 181], [116, 228], [116, 241], [117, 132], [117, 187], [117, 207], [117, 217], [117, 238], [118, 146], [118, 160], [118, 194], [118, 214], [118, 215], [119, 214], [120, 145], [120, 177], [120, 193], [120, 221], [120, 230], [121, 136], [121, 183], [121, 196], [121, 227], [121, 233], [122, 241], [123, 176], [123, 213], [123, 230], [124, 148], [124, 216], [124, 249], [125, 214], [125, 218], [125, 249], [126, 143], [126, 170], [126, 190], [126, 192], [126, 199], [126, 244], [127, 129], [127, 164], [127, 167], [127, 168], [127, 181], [127, 206], [127, 207], [127, 218], [127, 249], [128, 135], [128, 149], [128, 199], [128, 233], [128, 241], [129, 133], [129, 144], [130, 158], [130, 189], [130, 236], [131, 134], [131, 190], [131, 191], [131, 192], [132, 172], [132, 201], [132, 243], [132, 248], [133, 181], [133, 191], [133, 195], [133, 198], [133, 205], [133, 223], [133, 229], [134, 189], [134, 249], [135, 152], [135, 169], [135, 245], [136, 138], [136, 239], [136, 244], [137, 146], [137, 154], [137, 179], [137, 195], [137, 204], [137, 222], [137, 248], [138, 154], [138, 163], [138, 237], [139, 171], [139, 177], [139, 204], [139, 230], [139, 234], [139, 239], [139, 241], [140, 146], [140, 200], [140, 207], [140, 216], [141, 171], [141, 175], [141, 219], [142, 169], [142, 200], [142, 207], [142, 210], [143, 147], [143, 215], [143, 226], [144, 185], [144, 188], [144, 200], [144, 207], [146, 187], [147, 177], [148, 169], [149, 156], [149, 172], [149, 193], [149, 208], [149, 213], [149, 233], [150, 201], [150, 240], [150, 246], [151, 166], [151, 173], [151, 196], [151, 209], [152, 156], [152, 199], [153, 186], [153, 195], [154, 186], [155, 166], [155, 202], [155, 223], [156, 175], [156, 189], [157, 167], [157, 248], [158, 160], [158, 184], [158, 216], [158, 223], [159, 179], [159, 221], [159, 235], [160, 221], [161, 165], [161, 195], [161, 245], [162, 170], [162, 205], [162, 212], [163, 177], [163, 191], [164, 177], [164, 224], [165, 197], [165, 232], [166, 185], [167, 177], [167, 180], [167, 209], [167, 231], [167, 233], [169, 170], [170, 191], [171, 186], [171, 223], [171, 230], [172, 208], [172, 222], [173, 177], [173, 186], [173, 238], [175, 219], [176, 203], [176, 215], [176, 241], [177, 193], [177, 202], [177, 247], [178, 218], [179, 218], [181, 203], [181, 206], [181, 235], [182, 183], [183, 202], [183, 216], [183, 225], [184, 219], [184, 236], [185, 204], [185, 229], [185, 242], [186, 240], [188, 245], [189, 195], [189, 217], [189, 219], [189, 223], [189, 241], [190, 195], [190, 235], [191, 215], [191, 218], [191, 236], [192, 198], [192, 222], [192, 230], [192, 231], [193, 219], [194, 219], [194, 226], [194, 232], [194, 249], [196, 202], [196, 206], [196, 218], [196, 242], [197, 206], [197, 234], [197, 246], [198, 215], [198, 223], [198, 242], [199, 204], [199, 230], [199, 232], [200, 215], [200, 218], [200, 246], [200, 247], [202, 229], [203, 232], [205, 242], [206, 226], [206, 232], [206, 234], [208, 211], [208, 216], [209, 218], [210, 211], [210, 214], [210, 218], [211, 228], [211, 239], [212, 230], [212, 236], [213, 224], [215, 227], [216, 232], [220, 228], [220, 235], [221, 230], [221, 240], [221, 248], [222, 246], [223, 227], [224, 245], [226, 231], [228, 238], [231, 244], [234, 242], [235, 238], [238, 245], [245, 247], [245, 249]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l6-s8/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8ba44f17acdfd8f5a094285b81bf7c967c92b8a3 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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' +{"coloring": [1, 2, 1, 2, 2, 3, 1, 0, 2, 3, 2, 0, 3, 2, 1, 3, 1, 1, 0, 3, 0, 1, 0, 2, 0, 3, 2, 3, 0, 2, 0, 2, 1, 3, 3, 0, 1, 1, 0, 2, 0, 0, 3, 0, 3, 2, 1, 3, 3, 2, 0, 0, 3, 0, 0, 1, 0, 2, 1, 0, 3, 0, 3, 3, 1, 2, 2, 2, 0, 3, 2, 3, 0, 0, 1, 0, 1, 3, 2, 0, 1, 2, 0, 2, 3, 0, 0, 2, 1, 3, 2, 3, 2, 1, 3, 0, 2, 2, 3, 1, 1, 0, 1, 1, 2, 0, 0, 0, 2, 1, 1, 0, 1, 0, 1, 1, 1, 3, 1, 1, 0, 0, 1, 3, 1, 1, 3, 1, 1, 0, 0, 2, 0, 2, 1, 3, 3, 1, 2, 2, 0, 0, 3, 1, 3, 2, 2, 2, 0, 3, 2, 3, 0, 2, 0, 3, 1, 1, 3, 1, 0, 1, 1, 3, 2, 2, 2, 0, 3, 1, 2, 3, 1, 0, 2, 2, 1, 1, 1, 3, 3, 0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 0, 0, 2, 2, 3, 1, 3, 1, 2, 1, 3, 2, 3, 3, 0, 2, 2, 0, 1, 1, 2, 3, 2, 2, 2, 2, 0, 2, 3, 2, 2, 3, 0, 3, 3, 0, 3, 3, 3, 1, 3, 1, 2, 0, 3, 2, 3, 1, 1, 0, 3, 3, 3, 2, 2, 0, 3, 3, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l6-s8/tests/check.py b/tasks/construct-mc-graph-k-coloring-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l6-s8/tests/check.py @@ -0,0 +1,11 @@ +"""Proper k-colouring of a given graph (MathConstraint graph_k_coloring, CC-BY-4.0). Any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-mc-graph-k-coloring-l6-s8/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cd4c1b1c3942df12d35cc46d6b81c924bbbf1660 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 250, "k": 4, "edges": [[0, 12], [0, 31], [0, 41], [0, 44], [0, 87], [0, 121], [0, 147], [0, 155], [0, 174], [0, 233], [1, 50], [1, 54], [1, 74], [1, 80], [1, 93], [1, 114], [1, 136], [1, 142], [1, 186], [2, 7], [2, 38], [2, 141], [2, 182], [2, 213], [2, 214], [2, 218], [3, 5], [3, 20], [3, 24], [3, 38], [3, 60], [3, 85], [3, 249], [4, 6], [4, 32], [4, 42], [4, 62], [4, 68], [4, 105], [4, 109], [4, 119], [4, 127], [4, 149], [4, 223], [4, 228], [5, 11], [5, 20], [5, 43], [5, 93], [5, 109], [5, 115], [5, 125], [5, 127], [5, 166], [5, 187], [5, 202], [5, 232], [5, 244], [5, 249], [6, 13], [6, 19], [6, 59], [6, 70], [6, 133], [6, 174], [6, 189], [6, 191], [6, 244], [6, 245], [6, 247], [7, 80], [7, 151], [7, 158], [7, 188], [8, 15], [8, 21], [8, 64], [8, 73], [8, 149], [8, 162], [9, 36], [9, 66], [9, 79], [9, 87], [9, 90], [9, 150], [9, 157], [9, 199], [10, 32], [10, 55], [10, 56], [10, 88], [10, 115], [10, 183], [10, 197], [10, 226], [10, 242], [11, 36], [11, 47], [11, 126], [11, 151], [11, 178], [12, 61], [12, 78], [12, 162], [12, 166], [12, 211], [12, 217], [12, 230], [13, 112], [13, 149], [13, 151], [13, 191], [13, 203], [13, 240], [14, 92], [14, 154], [14, 179], [14, 208], [15, 29], [15, 31], [15, 51], [15, 78], [15, 85], [15, 105], [15, 115], [15, 130], [15, 134], [15, 183], [16, 42], [16, 84], [16, 98], [16, 133], [16, 148], [16, 152], [16, 221], [16, 222], [16, 235], [16, 237], [17, 40], [17, 89], [17, 123], [17, 164], [17, 227], [18, 74], [18, 77], [18, 123], [18, 189], [18, 220], [18, 244], [19, 39], [19, 58], [19, 65], [19, 74], [19, 186], [20, 26], [20, 52], [20, 63], [20, 81], [20, 102], [20, 123], [20, 211], [21, 62], [21, 73], [21, 130], [21, 145], [21, 155], [21, 171], [21, 191], [21, 206], [21, 219], [21, 222], [22, 26], [22, 37], [22, 42], [22, 58], [22, 78], [22, 104], [22, 139], [22, 147], [22, 161], [22, 176], [22, 209], [23, 30], [23, 47], [23, 95], [23, 141], [23, 151], [23, 157], [23, 172], [23, 246], [24, 27], [24, 33], [24, 117], [24, 197], [24, 207], [25, 26], [25, 36], [25, 57], [25, 78], [25, 122], [25, 127], [25, 145], [25, 150], [25, 154], [25, 156], [25, 196], [26, 100], [26, 114], [26, 125], [26, 148], [26, 156], [26, 158], [26, 224], [26, 230], [27, 30], [27, 45], [27, 65], [27, 68], [27, 86], [27, 92], [27, 104], [27, 138], [27, 150], [27, 159], [27, 244], [28, 62], [28, 109], [28, 112], [28, 115], [28, 131], [28, 151], [28, 171], [28, 188], [28, 198], [28, 232], [29, 48], [29, 71], [29, 99], [29, 103], [29, 120], [29, 208], [30, 66], [30, 74], [30, 104], [30, 115], [30, 176], [30, 202], [30, 231], [31, 37], [31, 98], [31, 105], [31, 135], [31, 152], [31, 179], [31, 182], [31, 208], [31, 222], [31, 239], [32, 38], [32, 53], [32, 170], [32, 216], [32, 221], [33, 78], [33, 99], [33, 106], [33, 110], [33, 120], [33, 148], [33, 210], [34, 58], [34, 100], [34, 113], [34, 131], [34, 156], [34, 160], [34, 162], [34, 233], [34, 249], [35, 42], [35, 57], [35, 89], [35, 93], [35, 151], [35, 187], [35, 207], [35, 212], [35, 214], [35, 245], [36, 83], [36, 152], [36, 164], [36, 192], [36, 197], [36, 216], [36, 242], [36, 246], [37, 54], [37, 87], [37, 121], [37, 133], [37, 201], [37, 203], [37, 211], [38, 57], [38, 99], [38, 134], [38, 145], [38, 147], [38, 201], [38, 243], [39, 79], [39, 80], [39, 89], [39, 101], [39, 127], [39, 171], [39, 183], [40, 69], [40, 103], [40, 104], [40, 146], [40, 180], [41, 52], [41, 70], [41, 119], [41, 153], [41, 163], [41, 207], [41, 216], [41, 232], [42, 81], [42, 104], [42, 120], [42, 170], [42, 182], [42, 191], [43, 64], [43, 92], [43, 97], [43, 99], [43, 153], [43, 175], [43, 207], [43, 210], [44, 61], [44, 76], [44, 78], [44, 86], [44, 112], [44, 116], [44, 120], [44, 131], [44, 156], [44, 172], [44, 181], [44, 236], [45, 71], [45, 85], [45, 117], [45, 127], [45, 132], [45, 178], [45, 179], [45, 187], [45, 204], [45, 217], [45, 231], [46, 61], [46, 68], [46, 77], [46, 97], [46, 158], [46, 225], [47, 79], [47, 120], [47, 133], [47, 210], [48, 100], [48, 140], [48, 143], [48, 154], [48, 207], [48, 210], [48, 216], [48, 246], [49, 82], [49, 137], [49, 144], [49, 155], [49, 188], [49, 203], [50, 67], [50, 80], [50, 136], [50, 209], [51, 87], [51, 128], [51, 145], [51, 168], [51, 203], [51, 210], [52, 56], [52, 143], [52, 152], [52, 156], [52, 169], [52, 200], [52, 209], [53, 83], [53, 98], [53, 103], [53, 116], [53, 127], [53, 147], [53, 222], [53, 244], [54, 100], [54, 151], [54, 158], [54, 166], [54, 179], [54, 214], [54, 236], [55, 56], [55, 65], [55, 144], [55, 201], [55, 202], [55, 211], [56, 64], [56, 124], [56, 176], [56, 187], [56, 195], [56, 220], [56, 244], [57, 71], [57, 100], [57, 115], [57, 149], [57, 154], [57, 180], [57, 198], [57, 201], [58, 61], [58, 66], [58, 84], [58, 170], [58, 199], [58, 225], [58, 236], [59, 118], [59, 126], [59, 180], [59, 210], [60, 73], [60, 115], [60, 122], [60, 167], [60, 192], [60, 211], [60, 215], [61, 122], [61, 166], [61, 175], [61, 200], [61, 210], [61, 220], [61, 228], [62, 82], [62, 83], [62, 90], [62, 101], [62, 152], [62, 167], [62, 182], [62, 206], [62, 207], [62, 246], [63, 87], [63, 99], [63, 137], [63, 177], [63, 217], [63, 220], [63, 221], [64, 91], [64, 111], [64, 141], [64, 158], [64, 165], [64, 171], [64, 192], [65, 72], [65, 116], [65, 127], [65, 132], [65, 190], [65, 228], [66, 93], [66, 99], [66, 127], [66, 210], [66, 231], [66, 247], [67, 82], [67, 107], [67, 112], [67, 173], [67, 209], [68, 118], [68, 125], [68, 158], [69, 81], [69, 87], [69, 103], [69, 121], [69, 140], [69, 150], [69, 175], [69, 184], [69, 189], [69, 217], [69, 221], [69, 226], [70, 77], [70, 93], [70, 125], [70, 140], [70, 178], [70, 197], [70, 231], [70, 247], [71, 74], [71, 99], [71, 102], [71, 105], [71, 121], [71, 177], [71, 206], [71, 213], [72, 97], [72, 104], [72, 142], [72, 176], [72, 178], [72, 195], [72, 199], [72, 219], [72, 224], [73, 81], [73, 97], [73, 118], [73, 176], [73, 186], [74, 175], [74, 202], [74, 226], [74, 229], [75, 94], [75, 143], [75, 171], [75, 218], [75, 230], [76, 81], [76, 84], [76, 106], [76, 133], [76, 155], [76, 197], [76, 227], [77, 87], [77, 104], [77, 106], [77, 157], [77, 174], [78, 154], [78, 176], [78, 201], [79, 124], [79, 126], [79, 146], [79, 153], [79, 187], [80, 95], [80, 107], [80, 138], [80, 150], [80, 163], [80, 193], [80, 211], [80, 225], [80, 227], [80, 241], [80, 247], [81, 209], [81, 219], [81, 224], [81, 228], [81, 238], [82, 110], [82, 144], [82, 194], [82, 199], [82, 201], [82, 237], [83, 116], [83, 119], [83, 132], [83, 136], [83, 152], [83, 171], [83, 173], [83, 208], [83, 222], [83, 224], [84, 105], [84, 119], [84, 122], [84, 127], [84, 129], [84, 202], [84, 208], [85, 91], [85, 94], [85, 123], [85, 135], [86, 91], [86, 164], [86, 166], [86, 169], [86, 180], [86, 215], [86, 216], [86, 232], [86, 238], [87, 122], [87, 200], [87, 243], [88, 89], [88, 101], [88, 123], [88, 130], [88, 145], [88, 146], [88, 164], [88, 168], [88, 179], [88, 185], [88, 197], [88, 199], [88, 248], [89, 106], [89, 140], [89, 143], [89, 146], [89, 162], [89, 240], [90, 111], [90, 132], [90, 160], [90, 234], [91, 102], [91, 109], [91, 143], [91, 152], [91, 226], [92, 111], [92, 126], [92, 128], [93, 117], [93, 139], [93, 170], [93, 213], [93, 217], [94, 97], [94, 122], [94, 145], [94, 166], [94, 188], [94, 232], [94, 233], [94, 249], [95, 108], [95, 110], [95, 146], [95, 153], [95, 179], [95, 207], [95, 209], [95, 220], [96, 123], [96, 127], [96, 135], [96, 141], [96, 177], [96, 238], [96, 243], [97, 217], [97, 219], [97, 226], [97, 248], [98, 120], [98, 145], [98, 164], [98, 178], [98, 223], [98, 240], [99, 113], [99, 126], [99, 141], [99, 175], [99, 181], [99, 184], [99, 221], [99, 224], [99, 236], [99, 245], [100, 120], [100, 158], [100, 212], [100, 217], [100, 228], [100, 234], [100, 241], [100, 247], [101, 124], [101, 133], [101, 143], [101, 178], [101, 186], [101, 193], [101, 206], [101, 214], [101, 229], [102, 222], [103, 121], [103, 123], [103, 135], [103, 147], [103, 149], [103, 165], [103, 184], [103, 224], [104, 105], [104, 117], [104, 172], [104, 182], [104, 184], [104, 187], [105, 157], [105, 163], [105, 224], [105, 248], [106, 135], [106, 150], [106, 235], [107, 116], [107, 142], [107, 196], [107, 233], [108, 155], [108, 156], [108, 161], [108, 195], [108, 201], [108, 234], [109, 117], [109, 249], [110, 111], [110, 185], [111, 157], [111, 172], [111, 218], [111, 235], [111, 236], [111, 238], [112, 139], [112, 181], [112, 201], [113, 134], [113, 135], [113, 136], [113, 137], [113, 166], [113, 188], [114, 135], [114, 145], [114, 150], [114, 160], [114, 179], [114, 237], [115, 233], [115, 243], [116, 123], [116, 151], [116, 168], [116, 171], [116, 181], [116, 228], [116, 241], [117, 132], [117, 187], [117, 207], [117, 217], [117, 238], [118, 146], [118, 160], [118, 194], [118, 214], [118, 215], [119, 214], [120, 145], [120, 177], [120, 193], [120, 221], [120, 230], [121, 136], [121, 183], [121, 196], [121, 227], [121, 233], [122, 241], [123, 176], [123, 213], [123, 230], [124, 148], [124, 216], [124, 249], [125, 214], [125, 218], [125, 249], [126, 143], [126, 170], [126, 190], [126, 192], [126, 199], [126, 244], [127, 129], [127, 164], [127, 167], [127, 168], [127, 181], [127, 206], [127, 207], [127, 218], [127, 249], [128, 135], [128, 149], [128, 199], [128, 233], [128, 241], [129, 133], [129, 144], [130, 158], [130, 189], [130, 236], [131, 134], [131, 190], [131, 191], [131, 192], [132, 172], [132, 201], [132, 243], [132, 248], [133, 181], [133, 191], [133, 195], [133, 198], [133, 205], [133, 223], [133, 229], [134, 189], [134, 249], [135, 152], [135, 169], [135, 245], [136, 138], [136, 239], [136, 244], [137, 146], [137, 154], [137, 179], [137, 195], [137, 204], [137, 222], [137, 248], [138, 154], [138, 163], [138, 237], [139, 171], [139, 177], [139, 204], [139, 230], [139, 234], [139, 239], [139, 241], [140, 146], [140, 200], [140, 207], [140, 216], [141, 171], [141, 175], [141, 219], [142, 169], [142, 200], [142, 207], [142, 210], [143, 147], [143, 215], [143, 226], [144, 185], [144, 188], [144, 200], [144, 207], [146, 187], [147, 177], [148, 169], [149, 156], [149, 172], [149, 193], [149, 208], [149, 213], [149, 233], [150, 201], [150, 240], [150, 246], [151, 166], [151, 173], [151, 196], [151, 209], [152, 156], [152, 199], [153, 186], [153, 195], [154, 186], [155, 166], [155, 202], [155, 223], [156, 175], [156, 189], [157, 167], [157, 248], [158, 160], [158, 184], [158, 216], [158, 223], [159, 179], [159, 221], [159, 235], [160, 221], [161, 165], [161, 195], [161, 245], [162, 170], [162, 205], [162, 212], [163, 177], [163, 191], [164, 177], [164, 224], [165, 197], [165, 232], [166, 185], [167, 177], [167, 180], [167, 209], [167, 231], [167, 233], [169, 170], [170, 191], [171, 186], [171, 223], [171, 230], [172, 208], [172, 222], [173, 177], [173, 186], [173, 238], [175, 219], [176, 203], [176, 215], [176, 241], [177, 193], [177, 202], [177, 247], [178, 218], [179, 218], [181, 203], [181, 206], [181, 235], [182, 183], [183, 202], [183, 216], [183, 225], [184, 219], [184, 236], [185, 204], [185, 229], [185, 242], [186, 240], [188, 245], [189, 195], [189, 217], [189, 219], [189, 223], [189, 241], [190, 195], [190, 235], [191, 215], [191, 218], [191, 236], [192, 198], [192, 222], [192, 230], [192, 231], [193, 219], [194, 219], [194, 226], [194, 232], [194, 249], [196, 202], [196, 206], [196, 218], [196, 242], [197, 206], [197, 234], [197, 246], [198, 215], [198, 223], [198, 242], [199, 204], [199, 230], [199, 232], [200, 215], [200, 218], [200, 246], [200, 247], [202, 229], [203, 232], [205, 242], [206, 226], [206, 232], [206, 234], [208, 211], [208, 216], [209, 218], [210, 211], [210, 214], [210, 218], [211, 228], [211, 239], [212, 230], [212, 236], [213, 224], [215, 227], [216, 232], [220, 228], [220, 235], [221, 230], [221, 240], [221, 248], [222, 246], [223, 227], [224, 245], [226, 231], [228, 238], [231, 244], [234, 242], [235, 238], [238, 245], [245, 247], [245, 249]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l6-s8/tests/run.py b/tasks/construct-mc-graph-k-coloring-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l6-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-graph-k-coloring-l6-s8/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l6-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-hadamard-l3-s1/environment/Dockerfile b/tasks/construct-mc-hadamard-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-hadamard-l3-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-hadamard-l3-s1/environment/instance.json b/tasks/construct-mc-hadamard-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a45b7e4d53b97cc4ed3236011c734d2e9e43e1c9 --- /dev/null +++ b/tasks/construct-mc-hadamard-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 19, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l3-s1/solution/solve.sh b/tasks/construct-mc-hadamard-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f8b9bd084ff5715b03ad324ae4fe2d890ae0271e --- /dev/null +++ b/tasks/construct-mc-hadamard-l3-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [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]} +RLMATH_EOF diff --git a/tasks/construct-mc-hadamard-l3-s1/tests/check.py b/tasks/construct-mc-hadamard-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..fc4b93160fd7473dd14935db9d712e52abdd00c2 --- /dev/null +++ b/tasks/construct-mc-hadamard-l3-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-l3-s1/tests/instance.json b/tasks/construct-mc-hadamard-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a45b7e4d53b97cc4ed3236011c734d2e9e43e1c9 --- /dev/null +++ b/tasks/construct-mc-hadamard-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 19, "family": "mc_hadamard", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-hadamard-l3-s1/tests/run.py b/tasks/construct-mc-hadamard-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-hadamard-l3-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-hadamard-l3-s1/tests/test.sh b/tasks/construct-mc-hadamard-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-hadamard-l3-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-langford-l3-s0/environment/Dockerfile b/tasks/construct-mc-langford-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-langford-l3-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-langford-l3-s0/environment/instance.json b/tasks/construct-mc-langford-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..669c042b02cd45f2538054e1e9800599d38e78db --- /dev/null +++ b/tasks/construct-mc-langford-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 16, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l3-s0/solution/solve.sh b/tasks/construct-mc-langford-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..67c03117aeb2e23f8091acdf0fa295f8a7b19b86 --- /dev/null +++ b/tasks/construct-mc-langford-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' +{"seq": [14, 15, 8, 6, 16, 7, 11, 12, 13, 4, 6, 8, 10, 7, 4, 14, 9, 15, 11, 5, 12, 16, 13, 10, 3, 5, 9, 2, 3, 1, 2, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-langford-l3-s0/tests/check.py b/tasks/construct-mc-langford-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4672d7eacf321991933cb280d6c940f1c4a67935 --- /dev/null +++ b/tasks/construct-mc-langford-l3-s0/tests/check.py @@ -0,0 +1,17 @@ +"""Langford sequence L(2, n) (MathConstraint langford, CC-BY-4.0). Accepts any valid sequence.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + seq = int_list(ans.get("seq"), 2 * n, 1, n, "seq") + for v in range(1, n + 1): + pos = [i for i, s in enumerate(seq) if s == v] + if len(pos) != 2: + raise Invalid(f"value {v} occurs {len(pos)} times (need exactly 2)") + if pos[1] - pos[0] != v + 1: + raise Invalid(f"the two copies of {v} are {pos[1] - pos[0]} positions apart (need {v + 1})") + for name, i, v in inst.get("fixed", []): + if seq[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-langford-l3-s0/tests/instance.json b/tasks/construct-mc-langford-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..669c042b02cd45f2538054e1e9800599d38e78db --- /dev/null +++ b/tasks/construct-mc-langford-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 16, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l3-s0/tests/run.py b/tasks/construct-mc-langford-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-langford-l3-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-langford-l3-s0/tests/test.sh b/tasks/construct-mc-langford-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-langford-l3-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-max-clique-l1-s2/environment/Dockerfile b/tasks/construct-mc-max-clique-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-clique-l1-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-max-clique-l1-s2/environment/instance.json b/tasks/construct-mc-max-clique-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8ac18d603037309db5e758d7d83454a62ab67f4e --- /dev/null +++ b/tasks/construct-mc-max-clique-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 25, "k": 5, "edges": [[0, 5], [0, 13], [0, 16], [0, 17], [0, 23], [1, 6], [1, 12], [1, 13], [1, 14], [1, 16], [1, 17], [1, 18], [1, 22], [1, 23], [1, 24], [2, 8], [2, 10], [2, 11], [2, 13], [2, 17], [3, 4], [3, 5], [3, 6], [3, 10], [3, 12], [3, 14], [3, 16], [3, 18], [3, 21], [3, 22], [4, 9], [4, 15], [4, 16], [4, 18], [4, 23], [4, 24], [5, 6], [5, 12], [5, 15], [5, 16], [5, 20], [5, 21], [5, 22], [5, 24], [6, 16], [6, 18], [6, 19], [6, 23], [7, 10], [7, 11], [7, 13], [7, 15], [7, 19], [7, 20], [7, 21], [7, 23], [8, 9], [8, 16], [8, 19], [8, 21], [8, 22], [9, 12], [9, 14], [9, 19], [9, 22], [10, 11], [10, 12], [10, 13], [10, 19], [10, 20], [10, 21], [10, 22], [11, 19], [11, 20], [11, 21], [12, 20], [12, 21], [12, 22], [13, 20], [14, 23], [15, 16], [15, 19], [15, 21], [15, 22], [15, 23], [15, 24], [16, 18], [16, 20], [18, 23], [18, 24], [20, 21], [20, 22], [20, 24], [21, 22], [22, 24], [23, 24]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l1-s2/solution/solve.sh b/tasks/construct-mc-max-clique-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6e797b4f1003db171596e2ee92d76f71b2ada637 --- /dev/null +++ b/tasks/construct-mc-max-clique-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' +{"clique": [7, 10, 11, 20, 21]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-clique-l1-s2/tests/check.py b/tasks/construct-mc-max-clique-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3f70dbd5b155a3514c2102aa4ad460201495210 --- /dev/null +++ b/tasks/construct-mc-max-clique-l1-s2/tests/check.py @@ -0,0 +1,18 @@ +"""Clique of size >= k in a given graph (MathConstraint max_clique decision version, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"clique has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) not in E: + raise Invalid(f"vertices {u} and {v} are not adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-clique-l1-s2/tests/instance.json b/tasks/construct-mc-max-clique-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8ac18d603037309db5e758d7d83454a62ab67f4e --- /dev/null +++ b/tasks/construct-mc-max-clique-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 25, "k": 5, "edges": [[0, 5], [0, 13], [0, 16], [0, 17], [0, 23], [1, 6], [1, 12], [1, 13], [1, 14], [1, 16], [1, 17], [1, 18], [1, 22], [1, 23], [1, 24], [2, 8], [2, 10], [2, 11], [2, 13], [2, 17], [3, 4], [3, 5], [3, 6], [3, 10], [3, 12], [3, 14], [3, 16], [3, 18], [3, 21], [3, 22], [4, 9], [4, 15], [4, 16], [4, 18], [4, 23], [4, 24], [5, 6], [5, 12], [5, 15], [5, 16], [5, 20], [5, 21], [5, 22], [5, 24], [6, 16], [6, 18], [6, 19], [6, 23], [7, 10], [7, 11], [7, 13], [7, 15], [7, 19], [7, 20], [7, 21], [7, 23], [8, 9], [8, 16], [8, 19], [8, 21], [8, 22], [9, 12], [9, 14], [9, 19], [9, 22], [10, 11], [10, 12], [10, 13], [10, 19], [10, 20], [10, 21], [10, 22], [11, 19], [11, 20], [11, 21], [12, 20], [12, 21], [12, 22], [13, 20], [14, 23], [15, 16], [15, 19], [15, 21], [15, 22], [15, 23], [15, 24], [16, 18], [16, 20], [18, 23], [18, 24], [20, 21], [20, 22], [20, 24], [21, 22], [22, 24], [23, 24]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l1-s2/tests/run.py b/tasks/construct-mc-max-clique-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-clique-l1-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-max-clique-l1-s2/tests/test.sh b/tasks/construct-mc-max-clique-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-clique-l1-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-max-clique-l1-s5/environment/Dockerfile b/tasks/construct-mc-max-clique-l1-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-clique-l1-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-max-clique-l1-s5/environment/instance.json b/tasks/construct-mc-max-clique-l1-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..61b7c841dfc08e1d5889e6ea49487e56144ec64b --- /dev/null +++ b/tasks/construct-mc-max-clique-l1-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 25, "k": 5, "edges": [[0, 2], [0, 3], [0, 4], [0, 5], [0, 8], [0, 9], [0, 11], [0, 13], [0, 15], [0, 17], [0, 21], [0, 23], [1, 4], [1, 6], [1, 10], [1, 11], [1, 12], [1, 14], [1, 16], [1, 20], [1, 21], [1, 23], [2, 10], [2, 17], [3, 7], [3, 10], [3, 14], [3, 16], [3, 18], [3, 20], [3, 22], [3, 23], [3, 24], [4, 5], [4, 7], [4, 9], [4, 10], [4, 11], [4, 21], [4, 24], [5, 9], [5, 11], [5, 12], [5, 18], [5, 21], [6, 9], [6, 13], [6, 16], [6, 17], [6, 24], [7, 9], [7, 12], [7, 17], [7, 19], [7, 22], [7, 23], [8, 13], [8, 17], [8, 18], [8, 19], [9, 10], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 19], [9, 21], [9, 22], [10, 12], [10, 15], [10, 16], [10, 18], [10, 24], [11, 12], [11, 13], [11, 17], [11, 23], [11, 24], [12, 13], [12, 16], [12, 18], [12, 19], [14, 15], [14, 20], [15, 17], [15, 19], [16, 17], [16, 21], [17, 18], [17, 19], [17, 22], [17, 24], [18, 20], [18, 21], [18, 22], [18, 23], [19, 20], [19, 22]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l1-s5/solution/solve.sh b/tasks/construct-mc-max-clique-l1-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..437bbbd20042098a6496034616b07e20f38f332d --- /dev/null +++ b/tasks/construct-mc-max-clique-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' +{"clique": [0, 4, 5, 9, 21]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-clique-l1-s5/tests/check.py b/tasks/construct-mc-max-clique-l1-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3f70dbd5b155a3514c2102aa4ad460201495210 --- /dev/null +++ b/tasks/construct-mc-max-clique-l1-s5/tests/check.py @@ -0,0 +1,18 @@ +"""Clique of size >= k in a given graph (MathConstraint max_clique decision version, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"clique has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) not in E: + raise Invalid(f"vertices {u} and {v} are not adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-clique-l1-s5/tests/instance.json b/tasks/construct-mc-max-clique-l1-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..61b7c841dfc08e1d5889e6ea49487e56144ec64b --- /dev/null +++ b/tasks/construct-mc-max-clique-l1-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 25, "k": 5, "edges": [[0, 2], [0, 3], [0, 4], [0, 5], [0, 8], [0, 9], [0, 11], [0, 13], [0, 15], [0, 17], [0, 21], [0, 23], [1, 4], [1, 6], [1, 10], [1, 11], [1, 12], [1, 14], [1, 16], [1, 20], [1, 21], [1, 23], [2, 10], [2, 17], [3, 7], [3, 10], [3, 14], [3, 16], [3, 18], [3, 20], [3, 22], [3, 23], [3, 24], [4, 5], [4, 7], [4, 9], [4, 10], [4, 11], [4, 21], [4, 24], [5, 9], [5, 11], [5, 12], [5, 18], [5, 21], [6, 9], [6, 13], [6, 16], [6, 17], [6, 24], [7, 9], [7, 12], [7, 17], [7, 19], [7, 22], [7, 23], [8, 13], [8, 17], [8, 18], [8, 19], [9, 10], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 19], [9, 21], [9, 22], [10, 12], [10, 15], [10, 16], [10, 18], [10, 24], [11, 12], [11, 13], [11, 17], [11, 23], [11, 24], [12, 13], [12, 16], [12, 18], [12, 19], [14, 15], [14, 20], [15, 17], [15, 19], [16, 17], [16, 21], [17, 18], [17, 19], [17, 22], [17, 24], [18, 20], [18, 21], [18, 22], [18, 23], [19, 20], [19, 22]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l1-s5/tests/run.py b/tasks/construct-mc-max-clique-l1-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-clique-l1-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-max-clique-l1-s5/tests/test.sh b/tasks/construct-mc-max-clique-l1-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-clique-l1-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-max-clique-l5-s4/environment/Dockerfile b/tasks/construct-mc-max-clique-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-clique-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-max-clique-l5-s4/environment/instance.json b/tasks/construct-mc-max-clique-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..874b287b4e25777f512955d43ddacd582556c96e --- /dev/null +++ b/tasks/construct-mc-max-clique-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 12, "edges": [[0, 4], [0, 7], [0, 10], [0, 12], [0, 17], [0, 19], [0, 22], [0, 25], [0, 26], [0, 31], [0, 32], [0, 36], [0, 37], [0, 38], [0, 40], [0, 43], [0, 46], [0, 50], [0, 51], [0, 54], [0, 56], [0, 57], [0, 59], [0, 61], [0, 63], [0, 64], [0, 67], [0, 70], [0, 74], [0, 79], [0, 80], [0, 82], [0, 85], [0, 86], [1, 2], [1, 4], [1, 5], [1, 6], [1, 9], [1, 10], [1, 11], [1, 13], [1, 15], [1, 16], [1, 20], [1, 22], [1, 23], [1, 27], [1, 28], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 36], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 42], [1, 43], [1, 44], [1, 50], [1, 52], [1, 54], [1, 55], [1, 58], [1, 59], [1, 61], [1, 63], [1, 67], [1, 69], [1, 70], [1, 71], [1, 72], [1, 73], [1, 74], [1, 77], [1, 81], [1, 82], [1, 84], [1, 85], [1, 86], [1, 88], [2, 3], [2, 5], [2, 6], [2, 8], [2, 9], [2, 10], [2, 13], [2, 15], [2, 17], [2, 24], [2, 26], [2, 27], [2, 28], [2, 30], [2, 31], [2, 33], [2, 36], [2, 39], [2, 44], [2, 47], [2, 48], [2, 52], [2, 55], [2, 57], [2, 58], [2, 59], [2, 60], [2, 62], [2, 63], [2, 64], [2, 67], [2, 68], [2, 70], [2, 72], [2, 74], [2, 75], [2, 78], [2, 80], [2, 83], [2, 85], [2, 86], [2, 87], [3, 4], [3, 5], [3, 7], [3, 8], [3, 10], [3, 12], [3, 13], [3, 15], [3, 16], [3, 20], [3, 22], [3, 23], [3, 24], [3, 29], [3, 30], [3, 31], [3, 33], [3, 34], [3, 35], [3, 36], [3, 38], [3, 39], [3, 47], [3, 48], [3, 49], [3, 51], [3, 52], [3, 53], [3, 54], [3, 55], [3, 56], [3, 58], [3, 59], [3, 60], [3, 62], [3, 67], [3, 68], [3, 71], [3, 72], [3, 73], [3, 75], [3, 76], [3, 78], [3, 79], [3, 81], [3, 86], [3, 87], [3, 88], [3, 89], [4, 9], [4, 10], [4, 12], [4, 13], [4, 14], [4, 15], [4, 20], [4, 22], [4, 24], [4, 26], [4, 27], [4, 28], [4, 29], [4, 31], [4, 32], [4, 33], [4, 37], [4, 38], [4, 40], [4, 41], [4, 42], [4, 43], [4, 45], [4, 46], [4, 47], [4, 48], [4, 49], [4, 50], [4, 51], [4, 53], [4, 55], [4, 58], [4, 59], [4, 60], [4, 62], [4, 63], [4, 65], [4, 69], [4, 71], [4, 72], [4, 73], [4, 76], [4, 78], [4, 81], [4, 83], [4, 85], [4, 88], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 15], [5, 17], [5, 18], [5, 20], [5, 21], [5, 24], [5, 25], [5, 26], [5, 29], [5, 30], [5, 31], [5, 33], [5, 35], [5, 36], [5, 39], [5, 41], [5, 42], [5, 44], [5, 48], [5, 51], [5, 52], [5, 55], [5, 57], [5, 58], [5, 59], [5, 60], [5, 63], [5, 64], [5, 66], [5, 68], [5, 70], [5, 72], [5, 74], [5, 76], [5, 78], [5, 79], [5, 80], [5, 83], [5, 84], [5, 87], [5, 88], [5, 89], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 14], [6, 16], [6, 17], [6, 20], [6, 21], [6, 22], [6, 24], [6, 28], [6, 29], [6, 33], [6, 35], [6, 36], [6, 40], [6, 41], [6, 42], [6, 43], [6, 44], [6, 45], [6, 46], [6, 47], [6, 48], [6, 49], [6, 50], [6, 51], [6, 52], [6, 55], [6, 57], [6, 58], [6, 59], [6, 60], [6, 64], [6, 65], [6, 70], [6, 72], [6, 74], [6, 75], [6, 76], [6, 79], [6, 81], [6, 82], [6, 85], [6, 86], [6, 87], [6, 88], [7, 8], [7, 10], [7, 16], [7, 18], [7, 19], [7, 20], [7, 28], [7, 29], [7, 31], [7, 32], [7, 33], [7, 35], [7, 36], [7, 37], [7, 38], [7, 40], [7, 46], [7, 47], [7, 48], [7, 49], [7, 50], [7, 51], [7, 52], [7, 53], [7, 54], [7, 55], [7, 57], [7, 59], [7, 61], [7, 63], [7, 65], [7, 66], [7, 73], [7, 74], [7, 75], [7, 76], [7, 78], [7, 79], [7, 81], [7, 82], [7, 85], [7, 86], [8, 9], [8, 10], [8, 11], [8, 13], [8, 14], [8, 15], [8, 16], [8, 19], [8, 20], [8, 21], [8, 25], [8, 26], [8, 28], [8, 31], [8, 34], [8, 35], [8, 39], [8, 40], [8, 42], [8, 45], [8, 48], [8, 49], [8, 51], [8, 52], [8, 54], [8, 55], [8, 56], [8, 57], [8, 58], [8, 59], [8, 63], [8, 64], [8, 65], [8, 68], [8, 70], [8, 74], [8, 75], [8, 80], [8, 81], [8, 84], [8, 85], [8, 86], [8, 87], [9, 10], [9, 11], [9, 14], [9, 15], [9, 17], [9, 19], [9, 20], [9, 21], [9, 22], [9, 24], [9, 25], [9, 26], [9, 30], [9, 31], [9, 32], [9, 33], [9, 36], [9, 37], [9, 38], [9, 39], [9, 40], [9, 42], [9, 45], [9, 48], [9, 51], [9, 53], [9, 54], [9, 58], [9, 59], [9, 61], [9, 64], [9, 65], [9, 67], [9, 69], [9, 70], [9, 75], [9, 77], [9, 79], [9, 84], [9, 87], [9, 89], [10, 11], [10, 13], [10, 14], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 23], [10, 26], [10, 27], [10, 28], [10, 31], [10, 32], [10, 33], [10, 34], [10, 37], [10, 38], [10, 39], [10, 40], [10, 41], [10, 42], [10, 43], [10, 44], [10, 46], [10, 47], [10, 48], [10, 49], [10, 51], [10, 52], [10, 54], [10, 56], [10, 58], [10, 59], [10, 61], [10, 62], [10, 63], [10, 66], [10, 71], [10, 73], [10, 74], [10, 75], [10, 77], [10, 79], [10, 80], [10, 81], [10, 82], [10, 84], [10, 88], [11, 16], [11, 19], [11, 22], [11, 23], [11, 25], [11, 26], [11, 27], [11, 30], [11, 31], [11, 32], [11, 33], [11, 34], [11, 41], [11, 42], [11, 45], [11, 46], [11, 49], [11, 52], [11, 54], [11, 55], [11, 59], [11, 61], [11, 62], [11, 63], [11, 64], [11, 65], [11, 66], [11, 67], [11, 68], [11, 73], [11, 74], [11, 76], [11, 79], [11, 80], [11, 81], [11, 82], [11, 83], [11, 87], [12, 13], [12, 17], [12, 21], [12, 23], [12, 24], [12, 25], [12, 26], [12, 29], [12, 30], [12, 31], [12, 32], [12, 35], [12, 36], [12, 40], [12, 42], [12, 43], [12, 44], [12, 46], [12, 47], [12, 48], [12, 51], [12, 52], [12, 53], [12, 56], [12, 58], [12, 60], [12, 62], [12, 66], [12, 67], [12, 68], [12, 71], [12, 72], [12, 73], [12, 75], [12, 76], [12, 77], [12, 78], [12, 80], [12, 81], [12, 83], [12, 86], [12, 88], [13, 14], [13, 15], [13, 16], [13, 18], [13, 20], [13, 23], [13, 24], [13, 27], [13, 28], [13, 32], [13, 33], [13, 34], [13, 35], [13, 37], [13, 39], [13, 41], [13, 48], [13, 49], [13, 50], [13, 51], [13, 52], [13, 53], [13, 54], [13, 55], [13, 56], [13, 63], [13, 69], [13, 74], [13, 75], [13, 77], [13, 78], [13, 80], [13, 81], [13, 82], [13, 83], [13, 84], [13, 86], [13, 87], [13, 89], [14, 15], [14, 16], [14, 17], [14, 20], [14, 21], [14, 22], [14, 28], [14, 32], [14, 34], [14, 36], [14, 39], [14, 41], [14, 48], [14, 50], [14, 52], [14, 54], [14, 56], [14, 62], [14, 63], [14, 67], [14, 69], [14, 71], [14, 74], [14, 75], [14, 76], [14, 80], [14, 81], [14, 82], [14, 83], [14, 85], [14, 89], [15, 16], [15, 17], [15, 18], [15, 20], [15, 21], [15, 28], [15, 29], [15, 33], [15, 34], [15, 39], [15, 41], [15, 44], [15, 48], [15, 50], [15, 51], [15, 54], [15, 56], [15, 58], [15, 59], [15, 60], [15, 61], [15, 62], [15, 66], [15, 67], [15, 69], [15, 70], [15, 71], [15, 72], [15, 73], [15, 74], [15, 75], [15, 77], [15, 81], [15, 84], [15, 88], [16, 22], [16, 24], [16, 34], [16, 35], [16, 37], [16, 39], [16, 41], [16, 42], [16, 46], [16, 47], [16, 48], [16, 50], [16, 51], [16, 52], [16, 53], [16, 54], [16, 56], [16, 58], [16, 59], [16, 60], [16, 62], [16, 63], [16, 64], [16, 65], [16, 66], [16, 67], [16, 68], [16, 69], [16, 74], [16, 75], [16, 77], [16, 80], [16, 81], [16, 83], [16, 84], [16, 85], [16, 86], [16, 87], [16, 88], [16, 89], [17, 18], [17, 19], [17, 21], [17, 22], [17, 23], [17, 24], [17, 26], [17, 28], [17, 29], [17, 30], [17, 33], [17, 34], [17, 35], [17, 37], [17, 38], [17, 39], [17, 40], [17, 41], [17, 43], [17, 47], [17, 49], [17, 51], [17, 53], [17, 57], [17, 60], [17, 61], [17, 62], [17, 68], [17, 69], [17, 71], [17, 72], [17, 75], [17, 76], [17, 77], [17, 80], [17, 81], [17, 82], [17, 86], [17, 88], [17, 89], [18, 19], [18, 20], [18, 22], [18, 23], [18, 24], [18, 28], [18, 32], [18, 33], [18, 37], [18, 38], [18, 39], [18, 40], [18, 41], [18, 43], [18, 44], [18, 45], [18, 46], [18, 48], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [18, 56], [18, 59], [18, 61], [18, 62], [18, 63], [18, 64], [18, 65], [18, 70], [18, 71], [18, 72], [18, 73], [18, 74], [18, 76], [18, 77], [18, 82], [18, 85], [18, 87], [18, 89], [19, 21], [19, 22], [19, 34], [19, 36], [19, 37], [19, 42], [19, 44], [19, 54], [19, 55], [19, 56], [19, 57], [19, 60], [19, 61], [19, 62], [19, 63], [19, 65], [19, 67], [19, 69], [19, 70], [19, 73], [19, 74], [19, 75], [19, 79], [19, 83], [19, 86], [19, 88], [20, 21], [20, 24], [20, 26], [20, 31], [20, 32], [20, 33], [20, 34], [20, 36], [20, 37], [20, 38], [20, 40], [20, 42], [20, 44], [20, 45], [20, 47], [20, 48], [20, 49], [20, 51], [20, 54], [20, 57], [20, 59], [20, 60], [20, 62], [20, 66], [20, 68], [20, 70], [20, 72], [20, 75], [20, 77], [20, 79], [20, 84], [20, 85], [20, 88], [21, 23], [21, 26], [21, 27], [21, 29], [21, 32], [21, 33], [21, 34], [21, 41], [21, 43], [21, 46], [21, 48], [21, 49], [21, 50], [21, 51], [21, 57], [21, 60], [21, 62], [21, 65], [21, 71], [21, 72], [21, 75], [21, 76], [21, 77], [21, 80], [21, 81], [21, 83], [21, 85], [21, 87], [21, 88], [21, 89], [22, 23], [22, 24], [22, 28], [22, 29], [22, 30], [22, 31], [22, 36], [22, 40], [22, 41], [22, 43], [22, 46], [22, 47], [22, 49], [22, 50], [22, 51], [22, 53], [22, 58], [22, 59], [22, 60], [22, 63], [22, 64], [22, 67], [22, 70], [22, 71], [22, 72], [22, 76], [22, 79], [22, 88], [22, 89], [23, 24], [23, 25], [23, 28], [23, 31], [23, 34], [23, 36], [23, 37], [23, 39], [23, 41], [23, 42], [23, 43], [23, 44], [23, 45], [23, 46], [23, 47], [23, 48], [23, 52], [23, 53], [23, 54], [23, 55], [23, 57], [23, 59], [23, 62], [23, 63], [23, 68], [23, 69], [23, 76], [23, 78], [23, 81], [23, 82], [23, 84], [23, 85], [23, 88], [23, 89], [24, 33], [24, 36], [24, 37], [24, 42], [24, 43], [24, 44], [24, 48], [24, 54], [24, 56], [24, 58], [24, 59], [24, 60], [24, 61], [24, 65], [24, 67], [24, 68], [24, 74], [24, 75], [24, 76], [24, 77], [24, 78], [24, 82], [24, 83], [24, 84], [24, 86], [24, 87], [24, 89], [25, 26], [25, 30], [25, 31], [25, 36], [25, 37], [25, 39], [25, 40], [25, 41], [25, 42], [25, 45], [25, 47], [25, 49], [25, 50], [25, 51], [25, 53], [25, 54], [25, 55], [25, 56], [25, 57], [25, 59], [25, 60], [25, 62], [25, 63], [25, 65], [25, 66], [25, 67], [25, 68], [25, 69], [25, 70], [25, 71], [25, 73], [25, 75], [25, 79], [25, 80], [25, 83], [25, 85], [25, 87], [26, 28], [26, 34], [26, 44], [26, 47], [26, 48], [26, 49], [26, 51], [26, 52], [26, 53], [26, 54], [26, 55], [26, 58], [26, 59], [26, 60], [26, 61], [26, 63], [26, 66], [26, 67], [26, 68], [26, 71], [26, 72], [26, 73], [26, 74], [26, 75], [26, 77], [26, 79], [26, 80], [26, 81], [26, 83], [26, 86], [26, 89], [27, 28], [27, 31], [27, 34], [27, 35], [27, 36], [27, 38], [27, 39], [27, 41], [27, 42], [27, 43], [27, 44], [27, 48], [27, 49], [27, 50], [27, 51], [27, 53], [27, 54], [27, 56], [27, 57], [27, 60], [27, 61], [27, 63], [27, 64], [27, 65], [27, 67], [27, 68], [27, 69], [27, 70], [27, 73], [27, 74], [27, 76], [27, 78], [27, 79], [27, 80], [27, 83], [27, 84], [27, 85], [27, 86], [27, 87], [28, 36], [28, 39], [28, 40], [28, 44], [28, 45], [28, 46], [28, 47], [28, 48], [28, 50], [28, 51], [28, 54], [28, 55], [28, 56], [28, 57], [28, 58], [28, 61], [28, 62], [28, 63], [28, 67], [28, 70], [28, 72], [28, 73], [28, 74], [28, 75], [28, 76], [28, 77], [28, 79], [28, 82], [28, 83], [28, 84], [28, 85], [28, 88], [28, 89], [29, 30], [29, 31], [29, 34], [29, 35], [29, 36], [29, 37], [29, 38], [29, 41], [29, 42], [29, 46], [29, 47], [29, 49], [29, 53], [29, 54], [29, 58], [29, 60], [29, 63], [29, 64], [29, 67], [29, 68], [29, 69], [29, 70], [29, 71], [29, 73], [29, 74], [29, 75], [29, 77], [29, 78], [29, 83], [29, 89], [30, 31], [30, 36], [30, 37], [30, 39], [30, 40], [30, 41], [30, 45], [30, 48], [30, 50], [30, 51], [30, 54], [30, 56], [30, 57], [30, 60], [30, 64], [30, 65], [30, 67], [30, 69], [30, 71], [30, 75], [30, 80], [30, 81], [30, 82], [30, 83], [30, 85], [30, 89], [31, 34], [31, 35], [31, 36], [31, 37], [31, 38], [31, 39], [31, 40], [31, 41], [31, 43], [31, 44], [31, 45], [31, 46], [31, 50], [31, 53], [31, 55], [31, 57], [31, 58], [31, 60], [31, 62], [31, 63], [31, 64], [31, 65], [31, 66], [31, 67], [31, 70], [31, 71], [31, 73], [31, 74], [31, 76], [31, 77], [31, 80], [31, 81], [31, 82], [31, 83], [31, 84], [31, 85], [31, 86], [31, 87], [31, 89], [32, 37], [32, 43], [32, 45], [32, 46], [32, 48], [32, 50], [32, 55], [32, 56], [32, 59], [32, 61], [32, 62], [32, 63], [32, 71], [32, 72], [32, 74], [32, 75], [32, 77], [32, 79], [32, 80], [32, 82], [32, 85], [32, 88], [33, 35], [33, 39], [33, 43], [33, 45], [33, 46], [33, 47], [33, 51], [33, 52], [33, 53], [33, 56], [33, 57], [33, 62], [33, 63], [33, 65], [33, 66], [33, 67], [33, 68], [33, 69], [33, 74], [33, 75], [33, 76], [33, 79], [33, 81], [33, 82], [33, 83], [33, 84], [33, 86], [33, 87], [33, 88], [33, 89], [34, 36], [34, 37], [34, 38], [34, 39], [34, 41], [34, 45], [34, 47], [34, 49], [34, 51], [34, 52], [34, 53], [34, 54], [34, 56], [34, 58], [34, 59], [34, 61], [34, 65], [34, 67], [34, 71], [34, 72], [34, 73], [34, 74], [34, 75], [34, 76], [34, 77], [34, 78], [34, 81], [34, 83], [34, 86], [34, 87], [34, 88], [35, 36], [35, 37], [35, 40], [35, 45], [35, 47], [35, 48], [35, 50], [35, 52], [35, 56], [35, 58], [35, 59], [35, 61], [35, 62], [35, 63], [35, 65], [35, 67], [35, 70], [35, 71], [35, 73], [35, 76], [35, 77], [35, 79], [35, 81], [35, 83], [35, 84], [35, 85], [36, 37], [36, 39], [36, 41], [36, 42], [36, 44], [36, 45], [36, 50], [36, 52], [36, 54], [36, 55], [36, 56], [36, 57], [36, 58], [36, 62], [36, 63], [36, 69], [36, 70], [36, 71], [36, 73], [36, 74], [36, 75], [36, 80], [36, 82], [36, 83], [36, 86], [36, 89], [37, 38], [37, 41], [37, 43], [37, 46], [37, 47], [37, 48], [37, 53], [37, 54], [37, 55], [37, 56], [37, 60], [37, 61], [37, 62], [37, 63], [37, 65], [37, 67], [37, 68], [37, 73], [37, 76], [37, 78], [37, 80], [37, 81], [37, 82], [37, 85], [37, 86], [37, 89], [38, 40], [38, 42], [38, 45], [38, 47], [38, 48], [38, 50], [38, 51], [38, 53], [38, 55], [38, 59], [38, 60], [38, 62], [38, 66], [38, 75], [38, 76], [38, 77], [38, 78], [38, 79], [38, 80], [38, 81], [38, 84], [38, 86], [39, 40], [39, 41], [39, 42], [39, 43], [39, 45], [39, 48], [39, 50], [39, 54], [39, 60], [39, 64], [39, 72], [39, 75], [39, 76], [39, 78], [39, 79], [39, 80], [39, 81], [39, 86], [39, 87], [39, 89], [40, 42], [40, 43], [40, 46], [40, 47], [40, 48], [40, 49], [40, 50], [40, 54], [40, 55], [40, 58], [40, 59], [40, 64], [40, 65], [40, 66], [40, 68], [40, 70], [40, 71], [40, 74], [40, 75], [40, 77], [40, 81], [40, 82], [40, 85], [40, 88], [41, 42], [41, 43], [41, 44], [41, 46], [41, 47], [41, 49], [41, 50], [41, 54], [41, 60], [41, 62], [41, 63], [41, 65], [41, 66], [41, 69], [41, 79], [41, 83], [41, 87], [41, 88], [42, 43], [42, 45], [42, 47], [42, 52], [42, 53], [42, 56], [42, 58], [42, 59], [42, 61], [42, 63], [42, 64], [42, 65], [42, 66], [42, 68], [42, 73], [42, 80], [42, 86], [43, 44], [43, 45], [43, 46], [43, 48], [43, 51], [43, 52], [43, 53], [43, 56], [43, 57], [43, 58], [43, 59], [43, 61], [43, 62], [43, 63], [43, 64], [43, 65], [43, 66], [43, 67], [43, 69], [43, 71], [43, 72], [43, 73], [43, 75], [43, 76], [43, 77], [43, 78], [43, 80], [43, 81], [43, 82], [43, 85], [43, 86], [44, 46], [44, 47], [44, 49], [44, 51], [44, 52], [44, 55], [44, 56], [44, 57], [44, 59], [44, 60], [44, 66], [44, 67], [44, 68], [44, 70], [44, 71], [44, 74], [44, 75], [44, 76], [44, 77], [44, 78], [44, 80], [44, 81], [44, 82], [44, 83], [44, 85], [44, 86], [44, 87], [44, 89], [45, 51], [45, 52], [45, 53], [45, 54], [45, 58], [45, 61], [45, 62], [45, 70], [45, 71], [45, 74], [45, 75], [45, 76], [45, 77], [45, 78], [45, 80], [45, 81], [45, 83], [45, 84], [45, 87], [46, 47], [46, 48], [46, 50], [46, 52], [46, 57], [46, 58], [46, 59], [46, 60], [46, 62], [46, 66], [46, 68], [46, 71], [46, 72], [46, 74], [46, 75], [46, 76], [46, 78], [46, 79], [46, 80], [46, 84], [46, 85], [46, 86], [46, 87], [46, 89], [47, 51], [47, 52], [47, 55], [47, 58], [47, 63], [47, 64], [47, 70], [47, 72], [47, 75], [47, 76], [47, 78], [47, 79], [47, 83], [47, 85], [47, 88], [47, 89], [48, 49], [48, 51], [48, 53], [48, 54], [48, 55], [48, 56], [48, 57], [48, 59], [48, 60], [48, 63], [48, 64], [48, 65], [48, 68], [48, 69], [48, 72], [48, 74], [48, 75], [48, 76], [48, 77], [48, 78], [48, 79], [48, 80], [48, 81], [48, 82], [48, 83], [48, 86], [48, 87], [48, 89], [49, 50], [49, 53], [49, 56], [49, 57], [49, 58], [49, 59], [49, 62], [49, 63], [49, 65], [49, 69], [49, 70], [49, 72], [49, 75], [49, 76], [49, 79], [49, 81], [49, 82], [49, 83], [49, 84], [49, 86], [49, 89], [50, 51], [50, 52], [50, 54], [50, 55], [50, 56], [50, 57], [50, 59], [50, 60], [50, 62], [50, 64], [50, 66], [50, 74], [50, 78], [50, 82], [50, 83], [50, 85], [50, 86], [50, 87], [50, 89], [51, 52], [51, 53], [51, 55], [51, 56], [51, 59], [51, 60], [51, 62], [51, 64], [51, 72], [51, 76], [51, 77], [51, 82], [51, 86], [51, 88], [51, 89], [52, 53], [52, 56], [52, 57], [52, 58], [52, 59], [52, 60], [52, 61], [52, 64], [52, 66], [52, 68], [52, 71], [52, 73], [52, 77], [52, 78], [52, 80], [52, 81], [52, 83], [52, 86], [52, 87], [52, 88], [52, 89], [53, 55], [53, 57], [53, 59], [53, 62], [53, 64], [53, 66], [53, 68], [53, 71], [53, 73], [53, 76], [53, 78], [53, 81], [53, 85], [53, 86], [53, 88], [53, 89], [54, 56], [54, 60], [54, 62], [54, 63], [54, 64], [54, 65], [54, 69], [54, 70], [54, 71], [54, 72], [54, 75], [54, 76], [54, 78], [54, 79], [54, 80], [54, 81], [54, 82], [54, 83], [54, 84], [54, 85], [54, 86], [55, 57], [55, 60], [55, 65], [55, 66], [55, 67], [55, 70], [55, 74], [55, 76], [55, 78], [55, 79], [55, 81], [55, 82], [55, 83], [55, 87], [55, 88], [55, 89], [56, 59], [56, 60], [56, 62], [56, 63], [56, 65], [56, 66], [56, 69], [56, 71], [56, 73], [56, 75], [56, 76], [56, 77], [56, 80], [56, 81], [56, 82], [56, 85], [56, 86], [56, 88], [57, 59], [57, 60], [57, 62], [57, 63], [57, 65], [57, 66], [57, 69], [57, 70], [57, 74], [57, 78], [57, 79], [57, 80], [57, 82], [57, 84], [57, 85], [57, 89], [58, 60], [58, 62], [58, 63], [58, 64], [58, 65], [58, 69], [58, 72], [58, 75], [58, 77], [58, 78], [58, 80], [58, 81], [58, 87], [58, 88], [59, 60], [59, 62], [59, 65], [59, 66], [59, 67], [59, 68], [59, 70], [59, 72], [59, 73], [59, 74], [59, 78], [59, 80], [59, 81], [59, 83], [59, 86], [59, 89], [60, 61], [60, 63], [60, 66], [60, 67], [60, 68], [60, 69], [60, 70], [60, 71], [60, 72], [60, 74], [60, 75], [60, 76], [60, 77], [60, 80], [60, 84], [60, 85], [60, 87], [61, 62], [61, 63], [61, 64], [61, 65], [61, 67], [61, 70], [61, 71], [61, 72], [61, 76], [61, 78], [61, 81], [61, 83], [61, 84], [61, 89], [62, 63], [62, 64], [62, 67], [62, 68], [62, 70], [62, 73], [62, 74], [62, 75], [62, 77], [62, 78], [62, 80], [62, 83], [62, 86], [62, 88], [63, 64], [63, 65], [63, 66], [63, 67], [63, 69], [63, 70], [63, 71], [63, 74], [63, 75], [63, 76], [63, 79], [63, 80], [63, 81], [63, 82], [63, 85], [63, 86], [63, 88], [63, 89], [64, 65], [64, 68], [64, 71], [64, 73], [64, 74], [64, 78], [64, 79], [64, 85], [64, 86], [64, 87], [65, 67], [65, 68], [65, 70], [65, 71], [65, 72], [65, 73], [65, 74], [65, 79], [65, 80], [65, 81], [65, 82], [65, 83], [65, 84], [65, 85], [65, 86], [66, 68], [66, 69], [66, 70], [66, 72], [66, 79], [66, 82], [66, 83], [66, 86], [66, 89], [67, 70], [67, 72], [67, 76], [67, 79], [67, 81], [67, 83], [67, 85], [67, 86], [67, 88], [68, 69], [68, 73], [68, 74], [68, 83], [68, 86], [68, 87], [68, 89], [69, 71], [69, 73], [69, 74], [69, 75], [69, 76], [69, 78], [69, 79], [69, 82], [69, 83], [69, 87], [69, 89], [70, 71], [70, 75], [70, 76], [70, 80], [70, 81], [70, 82], [70, 84], [70, 85], [70, 86], [70, 87], [70, 88], [71, 79], [71, 83], [71, 87], [72, 75], [72, 76], [72, 78], [72, 80], [72, 82], [72, 87], [73, 75], [73, 81], [73, 82], [73, 84], [73, 88], [73, 89], [74, 75], [74, 77], [74, 80], [74, 81], [74, 86], [74, 87], [74, 89], [75, 76], [75, 80], [75, 81], [75, 82], [75, 84], [75, 85], [75, 86], [76, 78], [76, 80], [76, 83], [76, 85], [76, 86], [76, 87], [76, 89], [77, 78], [77, 79], [77, 80], [77, 82], [77, 84], [77, 86], [77, 89], [78, 79], [78, 80], [78, 82], [78, 83], [78, 86], [78, 87], [78, 88], [78, 89], [79, 80], [79, 82], [79, 83], [79, 85], [79, 87], [79, 88], [80, 81], [80, 83], [80, 87], [80, 88], [80, 89], [81, 84], [81, 86], [81, 89], [82, 85], [83, 84], [83, 85], [83, 88], [83, 89], [84, 85], [84, 86], [84, 88], [85, 86], [85, 88], [87, 88], [88, 89]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l5-s4/solution/solve.sh b/tasks/construct-mc-max-clique-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4959ff80bdb920cea84bf6a4d36a376b4a53d73e --- /dev/null +++ b/tasks/construct-mc-max-clique-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' +{"clique": [8, 10, 13, 14, 16, 48, 54, 56, 63, 75, 80, 81]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-clique-l5-s4/tests/check.py b/tasks/construct-mc-max-clique-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3f70dbd5b155a3514c2102aa4ad460201495210 --- /dev/null +++ b/tasks/construct-mc-max-clique-l5-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-l5-s4/tests/instance.json b/tasks/construct-mc-max-clique-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..874b287b4e25777f512955d43ddacd582556c96e --- /dev/null +++ b/tasks/construct-mc-max-clique-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 12, "edges": [[0, 4], [0, 7], [0, 10], [0, 12], [0, 17], [0, 19], [0, 22], [0, 25], [0, 26], [0, 31], [0, 32], [0, 36], [0, 37], [0, 38], [0, 40], [0, 43], [0, 46], [0, 50], [0, 51], [0, 54], [0, 56], [0, 57], [0, 59], [0, 61], [0, 63], [0, 64], [0, 67], [0, 70], [0, 74], [0, 79], [0, 80], [0, 82], [0, 85], [0, 86], [1, 2], [1, 4], [1, 5], [1, 6], [1, 9], [1, 10], [1, 11], [1, 13], [1, 15], [1, 16], [1, 20], [1, 22], [1, 23], [1, 27], [1, 28], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 36], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 42], [1, 43], [1, 44], [1, 50], [1, 52], [1, 54], [1, 55], [1, 58], [1, 59], [1, 61], [1, 63], [1, 67], [1, 69], [1, 70], [1, 71], [1, 72], [1, 73], [1, 74], [1, 77], [1, 81], [1, 82], [1, 84], [1, 85], [1, 86], [1, 88], [2, 3], [2, 5], [2, 6], [2, 8], [2, 9], [2, 10], [2, 13], [2, 15], [2, 17], [2, 24], [2, 26], [2, 27], [2, 28], [2, 30], [2, 31], [2, 33], [2, 36], [2, 39], [2, 44], [2, 47], [2, 48], [2, 52], [2, 55], [2, 57], [2, 58], [2, 59], [2, 60], [2, 62], [2, 63], [2, 64], [2, 67], [2, 68], [2, 70], [2, 72], [2, 74], [2, 75], [2, 78], [2, 80], [2, 83], [2, 85], [2, 86], [2, 87], [3, 4], [3, 5], [3, 7], [3, 8], [3, 10], [3, 12], [3, 13], [3, 15], [3, 16], [3, 20], [3, 22], [3, 23], [3, 24], [3, 29], [3, 30], [3, 31], [3, 33], [3, 34], [3, 35], [3, 36], [3, 38], [3, 39], [3, 47], [3, 48], [3, 49], [3, 51], [3, 52], [3, 53], [3, 54], [3, 55], [3, 56], [3, 58], [3, 59], [3, 60], [3, 62], [3, 67], [3, 68], [3, 71], [3, 72], [3, 73], [3, 75], [3, 76], [3, 78], [3, 79], [3, 81], [3, 86], [3, 87], [3, 88], [3, 89], [4, 9], [4, 10], [4, 12], [4, 13], [4, 14], [4, 15], [4, 20], [4, 22], [4, 24], [4, 26], [4, 27], [4, 28], [4, 29], [4, 31], [4, 32], [4, 33], [4, 37], [4, 38], [4, 40], [4, 41], [4, 42], [4, 43], [4, 45], [4, 46], [4, 47], [4, 48], [4, 49], [4, 50], [4, 51], [4, 53], [4, 55], [4, 58], [4, 59], [4, 60], [4, 62], [4, 63], [4, 65], [4, 69], [4, 71], [4, 72], [4, 73], [4, 76], [4, 78], [4, 81], [4, 83], [4, 85], [4, 88], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 15], [5, 17], [5, 18], [5, 20], [5, 21], [5, 24], [5, 25], [5, 26], [5, 29], [5, 30], [5, 31], [5, 33], [5, 35], [5, 36], [5, 39], [5, 41], [5, 42], [5, 44], [5, 48], [5, 51], [5, 52], [5, 55], [5, 57], [5, 58], [5, 59], [5, 60], [5, 63], [5, 64], [5, 66], [5, 68], [5, 70], [5, 72], [5, 74], [5, 76], [5, 78], [5, 79], [5, 80], [5, 83], [5, 84], [5, 87], [5, 88], [5, 89], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 14], [6, 16], [6, 17], [6, 20], [6, 21], [6, 22], [6, 24], [6, 28], [6, 29], [6, 33], [6, 35], [6, 36], [6, 40], [6, 41], [6, 42], [6, 43], [6, 44], [6, 45], [6, 46], [6, 47], [6, 48], [6, 49], [6, 50], [6, 51], [6, 52], [6, 55], [6, 57], [6, 58], [6, 59], [6, 60], [6, 64], [6, 65], [6, 70], [6, 72], [6, 74], [6, 75], [6, 76], [6, 79], [6, 81], [6, 82], [6, 85], [6, 86], [6, 87], [6, 88], [7, 8], [7, 10], [7, 16], [7, 18], [7, 19], [7, 20], [7, 28], [7, 29], [7, 31], [7, 32], [7, 33], [7, 35], [7, 36], [7, 37], [7, 38], [7, 40], [7, 46], [7, 47], [7, 48], [7, 49], [7, 50], [7, 51], [7, 52], [7, 53], [7, 54], [7, 55], [7, 57], [7, 59], [7, 61], [7, 63], [7, 65], [7, 66], [7, 73], [7, 74], [7, 75], [7, 76], [7, 78], [7, 79], [7, 81], [7, 82], [7, 85], [7, 86], [8, 9], [8, 10], [8, 11], [8, 13], [8, 14], [8, 15], [8, 16], [8, 19], [8, 20], [8, 21], [8, 25], [8, 26], [8, 28], [8, 31], [8, 34], [8, 35], [8, 39], [8, 40], [8, 42], [8, 45], [8, 48], [8, 49], [8, 51], [8, 52], [8, 54], [8, 55], [8, 56], [8, 57], [8, 58], [8, 59], [8, 63], [8, 64], [8, 65], [8, 68], [8, 70], [8, 74], [8, 75], [8, 80], [8, 81], [8, 84], [8, 85], [8, 86], [8, 87], [9, 10], [9, 11], [9, 14], [9, 15], [9, 17], [9, 19], [9, 20], [9, 21], [9, 22], [9, 24], [9, 25], [9, 26], [9, 30], [9, 31], [9, 32], [9, 33], [9, 36], [9, 37], [9, 38], [9, 39], [9, 40], [9, 42], [9, 45], [9, 48], [9, 51], [9, 53], [9, 54], [9, 58], [9, 59], [9, 61], [9, 64], [9, 65], [9, 67], [9, 69], [9, 70], [9, 75], [9, 77], [9, 79], [9, 84], [9, 87], [9, 89], [10, 11], [10, 13], [10, 14], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 23], [10, 26], [10, 27], [10, 28], [10, 31], [10, 32], [10, 33], [10, 34], [10, 37], [10, 38], [10, 39], [10, 40], [10, 41], [10, 42], [10, 43], [10, 44], [10, 46], [10, 47], [10, 48], [10, 49], [10, 51], [10, 52], [10, 54], [10, 56], [10, 58], [10, 59], [10, 61], [10, 62], [10, 63], [10, 66], [10, 71], [10, 73], [10, 74], [10, 75], [10, 77], [10, 79], [10, 80], [10, 81], [10, 82], [10, 84], [10, 88], [11, 16], [11, 19], [11, 22], [11, 23], [11, 25], [11, 26], [11, 27], [11, 30], [11, 31], [11, 32], [11, 33], [11, 34], [11, 41], [11, 42], [11, 45], [11, 46], [11, 49], [11, 52], [11, 54], [11, 55], [11, 59], [11, 61], [11, 62], [11, 63], [11, 64], [11, 65], [11, 66], [11, 67], [11, 68], [11, 73], [11, 74], [11, 76], [11, 79], [11, 80], [11, 81], [11, 82], [11, 83], [11, 87], [12, 13], [12, 17], [12, 21], [12, 23], [12, 24], [12, 25], [12, 26], [12, 29], [12, 30], [12, 31], [12, 32], [12, 35], [12, 36], [12, 40], [12, 42], [12, 43], [12, 44], [12, 46], [12, 47], [12, 48], [12, 51], [12, 52], [12, 53], [12, 56], [12, 58], [12, 60], [12, 62], [12, 66], [12, 67], [12, 68], [12, 71], [12, 72], [12, 73], [12, 75], [12, 76], [12, 77], [12, 78], [12, 80], [12, 81], [12, 83], [12, 86], [12, 88], [13, 14], [13, 15], [13, 16], [13, 18], [13, 20], [13, 23], [13, 24], [13, 27], [13, 28], [13, 32], [13, 33], [13, 34], [13, 35], [13, 37], [13, 39], [13, 41], [13, 48], [13, 49], [13, 50], [13, 51], [13, 52], [13, 53], [13, 54], [13, 55], [13, 56], [13, 63], [13, 69], [13, 74], [13, 75], [13, 77], [13, 78], [13, 80], [13, 81], [13, 82], [13, 83], [13, 84], [13, 86], [13, 87], [13, 89], [14, 15], [14, 16], [14, 17], [14, 20], [14, 21], [14, 22], [14, 28], [14, 32], [14, 34], [14, 36], [14, 39], [14, 41], [14, 48], [14, 50], [14, 52], [14, 54], [14, 56], [14, 62], [14, 63], [14, 67], [14, 69], [14, 71], [14, 74], [14, 75], [14, 76], [14, 80], [14, 81], [14, 82], [14, 83], [14, 85], [14, 89], [15, 16], [15, 17], [15, 18], [15, 20], [15, 21], [15, 28], [15, 29], [15, 33], [15, 34], [15, 39], [15, 41], [15, 44], [15, 48], [15, 50], [15, 51], [15, 54], [15, 56], [15, 58], [15, 59], [15, 60], [15, 61], [15, 62], [15, 66], [15, 67], [15, 69], [15, 70], [15, 71], [15, 72], [15, 73], [15, 74], [15, 75], [15, 77], [15, 81], [15, 84], [15, 88], [16, 22], [16, 24], [16, 34], [16, 35], [16, 37], [16, 39], [16, 41], [16, 42], [16, 46], [16, 47], [16, 48], [16, 50], [16, 51], [16, 52], [16, 53], [16, 54], [16, 56], [16, 58], [16, 59], [16, 60], [16, 62], [16, 63], [16, 64], [16, 65], [16, 66], [16, 67], [16, 68], [16, 69], [16, 74], [16, 75], [16, 77], [16, 80], [16, 81], [16, 83], [16, 84], [16, 85], [16, 86], [16, 87], [16, 88], [16, 89], [17, 18], [17, 19], [17, 21], [17, 22], [17, 23], [17, 24], [17, 26], [17, 28], [17, 29], [17, 30], [17, 33], [17, 34], [17, 35], [17, 37], [17, 38], [17, 39], [17, 40], [17, 41], [17, 43], [17, 47], [17, 49], [17, 51], [17, 53], [17, 57], [17, 60], [17, 61], [17, 62], [17, 68], [17, 69], [17, 71], [17, 72], [17, 75], [17, 76], [17, 77], [17, 80], [17, 81], [17, 82], [17, 86], [17, 88], [17, 89], [18, 19], [18, 20], [18, 22], [18, 23], [18, 24], [18, 28], [18, 32], [18, 33], [18, 37], [18, 38], [18, 39], [18, 40], [18, 41], [18, 43], [18, 44], [18, 45], [18, 46], [18, 48], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [18, 56], [18, 59], [18, 61], [18, 62], [18, 63], [18, 64], [18, 65], [18, 70], [18, 71], [18, 72], [18, 73], [18, 74], [18, 76], [18, 77], [18, 82], [18, 85], [18, 87], [18, 89], [19, 21], [19, 22], [19, 34], [19, 36], [19, 37], [19, 42], [19, 44], [19, 54], [19, 55], [19, 56], [19, 57], [19, 60], [19, 61], [19, 62], [19, 63], [19, 65], [19, 67], [19, 69], [19, 70], [19, 73], [19, 74], [19, 75], [19, 79], [19, 83], [19, 86], [19, 88], [20, 21], [20, 24], [20, 26], [20, 31], [20, 32], [20, 33], [20, 34], [20, 36], [20, 37], [20, 38], [20, 40], [20, 42], [20, 44], [20, 45], [20, 47], [20, 48], [20, 49], [20, 51], [20, 54], [20, 57], [20, 59], [20, 60], [20, 62], [20, 66], [20, 68], [20, 70], [20, 72], [20, 75], [20, 77], [20, 79], [20, 84], [20, 85], [20, 88], [21, 23], [21, 26], [21, 27], [21, 29], [21, 32], [21, 33], [21, 34], [21, 41], [21, 43], [21, 46], [21, 48], [21, 49], [21, 50], [21, 51], [21, 57], [21, 60], [21, 62], [21, 65], [21, 71], [21, 72], [21, 75], [21, 76], [21, 77], [21, 80], [21, 81], [21, 83], [21, 85], [21, 87], [21, 88], [21, 89], [22, 23], [22, 24], [22, 28], [22, 29], [22, 30], [22, 31], [22, 36], [22, 40], [22, 41], [22, 43], [22, 46], [22, 47], [22, 49], [22, 50], [22, 51], [22, 53], [22, 58], [22, 59], [22, 60], [22, 63], [22, 64], [22, 67], [22, 70], [22, 71], [22, 72], [22, 76], [22, 79], [22, 88], [22, 89], [23, 24], [23, 25], [23, 28], [23, 31], [23, 34], [23, 36], [23, 37], [23, 39], [23, 41], [23, 42], [23, 43], [23, 44], [23, 45], [23, 46], [23, 47], [23, 48], [23, 52], [23, 53], [23, 54], [23, 55], [23, 57], [23, 59], [23, 62], [23, 63], [23, 68], [23, 69], [23, 76], [23, 78], [23, 81], [23, 82], [23, 84], [23, 85], [23, 88], [23, 89], [24, 33], [24, 36], [24, 37], [24, 42], [24, 43], [24, 44], [24, 48], [24, 54], [24, 56], [24, 58], [24, 59], [24, 60], [24, 61], [24, 65], [24, 67], [24, 68], [24, 74], [24, 75], [24, 76], [24, 77], [24, 78], [24, 82], [24, 83], [24, 84], [24, 86], [24, 87], [24, 89], [25, 26], [25, 30], [25, 31], [25, 36], [25, 37], [25, 39], [25, 40], [25, 41], [25, 42], [25, 45], [25, 47], [25, 49], [25, 50], [25, 51], [25, 53], [25, 54], [25, 55], [25, 56], [25, 57], [25, 59], [25, 60], [25, 62], [25, 63], [25, 65], [25, 66], [25, 67], [25, 68], [25, 69], [25, 70], [25, 71], [25, 73], [25, 75], [25, 79], [25, 80], [25, 83], [25, 85], [25, 87], [26, 28], [26, 34], [26, 44], [26, 47], [26, 48], [26, 49], [26, 51], [26, 52], [26, 53], [26, 54], [26, 55], [26, 58], [26, 59], [26, 60], [26, 61], [26, 63], [26, 66], [26, 67], [26, 68], [26, 71], [26, 72], [26, 73], [26, 74], [26, 75], [26, 77], [26, 79], [26, 80], [26, 81], [26, 83], [26, 86], [26, 89], [27, 28], [27, 31], [27, 34], [27, 35], [27, 36], [27, 38], [27, 39], [27, 41], [27, 42], [27, 43], [27, 44], [27, 48], [27, 49], [27, 50], [27, 51], [27, 53], [27, 54], [27, 56], [27, 57], [27, 60], [27, 61], [27, 63], [27, 64], [27, 65], [27, 67], [27, 68], [27, 69], [27, 70], [27, 73], [27, 74], [27, 76], [27, 78], [27, 79], [27, 80], [27, 83], [27, 84], [27, 85], [27, 86], [27, 87], [28, 36], [28, 39], [28, 40], [28, 44], [28, 45], [28, 46], [28, 47], [28, 48], [28, 50], [28, 51], [28, 54], [28, 55], [28, 56], [28, 57], [28, 58], [28, 61], [28, 62], [28, 63], [28, 67], [28, 70], [28, 72], [28, 73], [28, 74], [28, 75], [28, 76], [28, 77], [28, 79], [28, 82], [28, 83], [28, 84], [28, 85], [28, 88], [28, 89], [29, 30], [29, 31], [29, 34], [29, 35], [29, 36], [29, 37], [29, 38], [29, 41], [29, 42], [29, 46], [29, 47], [29, 49], [29, 53], [29, 54], [29, 58], [29, 60], [29, 63], [29, 64], [29, 67], [29, 68], [29, 69], [29, 70], [29, 71], [29, 73], [29, 74], [29, 75], [29, 77], [29, 78], [29, 83], [29, 89], [30, 31], [30, 36], [30, 37], [30, 39], [30, 40], [30, 41], [30, 45], [30, 48], [30, 50], [30, 51], [30, 54], [30, 56], [30, 57], [30, 60], [30, 64], [30, 65], [30, 67], [30, 69], [30, 71], [30, 75], [30, 80], [30, 81], [30, 82], [30, 83], [30, 85], [30, 89], [31, 34], [31, 35], [31, 36], [31, 37], [31, 38], [31, 39], [31, 40], [31, 41], [31, 43], [31, 44], [31, 45], [31, 46], [31, 50], [31, 53], [31, 55], [31, 57], [31, 58], [31, 60], [31, 62], [31, 63], [31, 64], [31, 65], [31, 66], [31, 67], [31, 70], [31, 71], [31, 73], [31, 74], [31, 76], [31, 77], [31, 80], [31, 81], [31, 82], [31, 83], [31, 84], [31, 85], [31, 86], [31, 87], [31, 89], [32, 37], [32, 43], [32, 45], [32, 46], [32, 48], [32, 50], [32, 55], [32, 56], [32, 59], [32, 61], [32, 62], [32, 63], [32, 71], [32, 72], [32, 74], [32, 75], [32, 77], [32, 79], [32, 80], [32, 82], [32, 85], [32, 88], [33, 35], [33, 39], [33, 43], [33, 45], [33, 46], [33, 47], [33, 51], [33, 52], [33, 53], [33, 56], [33, 57], [33, 62], [33, 63], [33, 65], [33, 66], [33, 67], [33, 68], [33, 69], [33, 74], [33, 75], [33, 76], [33, 79], [33, 81], [33, 82], [33, 83], [33, 84], [33, 86], [33, 87], [33, 88], [33, 89], [34, 36], [34, 37], [34, 38], [34, 39], [34, 41], [34, 45], [34, 47], [34, 49], [34, 51], [34, 52], [34, 53], [34, 54], [34, 56], [34, 58], [34, 59], [34, 61], [34, 65], [34, 67], [34, 71], [34, 72], [34, 73], [34, 74], [34, 75], [34, 76], [34, 77], [34, 78], [34, 81], [34, 83], [34, 86], [34, 87], [34, 88], [35, 36], [35, 37], [35, 40], [35, 45], [35, 47], [35, 48], [35, 50], [35, 52], [35, 56], [35, 58], [35, 59], [35, 61], [35, 62], [35, 63], [35, 65], [35, 67], [35, 70], [35, 71], [35, 73], [35, 76], [35, 77], [35, 79], [35, 81], [35, 83], [35, 84], [35, 85], [36, 37], [36, 39], [36, 41], [36, 42], [36, 44], [36, 45], [36, 50], [36, 52], [36, 54], [36, 55], [36, 56], [36, 57], [36, 58], [36, 62], [36, 63], [36, 69], [36, 70], [36, 71], [36, 73], [36, 74], [36, 75], [36, 80], [36, 82], [36, 83], [36, 86], [36, 89], [37, 38], [37, 41], [37, 43], [37, 46], [37, 47], [37, 48], [37, 53], [37, 54], [37, 55], [37, 56], [37, 60], [37, 61], [37, 62], [37, 63], [37, 65], [37, 67], [37, 68], [37, 73], [37, 76], [37, 78], [37, 80], [37, 81], [37, 82], [37, 85], [37, 86], [37, 89], [38, 40], [38, 42], [38, 45], [38, 47], [38, 48], [38, 50], [38, 51], [38, 53], [38, 55], [38, 59], [38, 60], [38, 62], [38, 66], [38, 75], [38, 76], [38, 77], [38, 78], [38, 79], [38, 80], [38, 81], [38, 84], [38, 86], [39, 40], [39, 41], [39, 42], [39, 43], [39, 45], [39, 48], [39, 50], [39, 54], [39, 60], [39, 64], [39, 72], [39, 75], [39, 76], [39, 78], [39, 79], [39, 80], [39, 81], [39, 86], [39, 87], [39, 89], [40, 42], [40, 43], [40, 46], [40, 47], [40, 48], [40, 49], [40, 50], [40, 54], [40, 55], [40, 58], [40, 59], [40, 64], [40, 65], [40, 66], [40, 68], [40, 70], [40, 71], [40, 74], [40, 75], [40, 77], [40, 81], [40, 82], [40, 85], [40, 88], [41, 42], [41, 43], [41, 44], [41, 46], [41, 47], [41, 49], [41, 50], [41, 54], [41, 60], [41, 62], [41, 63], [41, 65], [41, 66], [41, 69], [41, 79], [41, 83], [41, 87], [41, 88], [42, 43], [42, 45], [42, 47], [42, 52], [42, 53], [42, 56], [42, 58], [42, 59], [42, 61], [42, 63], [42, 64], [42, 65], [42, 66], [42, 68], [42, 73], [42, 80], [42, 86], [43, 44], [43, 45], [43, 46], [43, 48], [43, 51], [43, 52], [43, 53], [43, 56], [43, 57], [43, 58], [43, 59], [43, 61], [43, 62], [43, 63], [43, 64], [43, 65], [43, 66], [43, 67], [43, 69], [43, 71], [43, 72], [43, 73], [43, 75], [43, 76], [43, 77], [43, 78], [43, 80], [43, 81], [43, 82], [43, 85], [43, 86], [44, 46], [44, 47], [44, 49], [44, 51], [44, 52], [44, 55], [44, 56], [44, 57], [44, 59], [44, 60], [44, 66], [44, 67], [44, 68], [44, 70], [44, 71], [44, 74], [44, 75], [44, 76], [44, 77], [44, 78], [44, 80], [44, 81], [44, 82], [44, 83], [44, 85], [44, 86], [44, 87], [44, 89], [45, 51], [45, 52], [45, 53], [45, 54], [45, 58], [45, 61], [45, 62], [45, 70], [45, 71], [45, 74], [45, 75], [45, 76], [45, 77], [45, 78], [45, 80], [45, 81], [45, 83], [45, 84], [45, 87], [46, 47], [46, 48], [46, 50], [46, 52], [46, 57], [46, 58], [46, 59], [46, 60], [46, 62], [46, 66], [46, 68], [46, 71], [46, 72], [46, 74], [46, 75], [46, 76], [46, 78], [46, 79], [46, 80], [46, 84], [46, 85], [46, 86], [46, 87], [46, 89], [47, 51], [47, 52], [47, 55], [47, 58], [47, 63], [47, 64], [47, 70], [47, 72], [47, 75], [47, 76], [47, 78], [47, 79], [47, 83], [47, 85], [47, 88], [47, 89], [48, 49], [48, 51], [48, 53], [48, 54], [48, 55], [48, 56], [48, 57], [48, 59], [48, 60], [48, 63], [48, 64], [48, 65], [48, 68], [48, 69], [48, 72], [48, 74], [48, 75], [48, 76], [48, 77], [48, 78], [48, 79], [48, 80], [48, 81], [48, 82], [48, 83], [48, 86], [48, 87], [48, 89], [49, 50], [49, 53], [49, 56], [49, 57], [49, 58], [49, 59], [49, 62], [49, 63], [49, 65], [49, 69], [49, 70], [49, 72], [49, 75], [49, 76], [49, 79], [49, 81], [49, 82], [49, 83], [49, 84], [49, 86], [49, 89], [50, 51], [50, 52], [50, 54], [50, 55], [50, 56], [50, 57], [50, 59], [50, 60], [50, 62], [50, 64], [50, 66], [50, 74], [50, 78], [50, 82], [50, 83], [50, 85], [50, 86], [50, 87], [50, 89], [51, 52], [51, 53], [51, 55], [51, 56], [51, 59], [51, 60], [51, 62], [51, 64], [51, 72], [51, 76], [51, 77], [51, 82], [51, 86], [51, 88], [51, 89], [52, 53], [52, 56], [52, 57], [52, 58], [52, 59], [52, 60], [52, 61], [52, 64], [52, 66], [52, 68], [52, 71], [52, 73], [52, 77], [52, 78], [52, 80], [52, 81], [52, 83], [52, 86], [52, 87], [52, 88], [52, 89], [53, 55], [53, 57], [53, 59], [53, 62], [53, 64], [53, 66], [53, 68], [53, 71], [53, 73], [53, 76], [53, 78], [53, 81], [53, 85], [53, 86], [53, 88], [53, 89], [54, 56], [54, 60], [54, 62], [54, 63], [54, 64], [54, 65], [54, 69], [54, 70], [54, 71], [54, 72], [54, 75], [54, 76], [54, 78], [54, 79], [54, 80], [54, 81], [54, 82], [54, 83], [54, 84], [54, 85], [54, 86], [55, 57], [55, 60], [55, 65], [55, 66], [55, 67], [55, 70], [55, 74], [55, 76], [55, 78], [55, 79], [55, 81], [55, 82], [55, 83], [55, 87], [55, 88], [55, 89], [56, 59], [56, 60], [56, 62], [56, 63], [56, 65], [56, 66], [56, 69], [56, 71], [56, 73], [56, 75], [56, 76], [56, 77], [56, 80], [56, 81], [56, 82], [56, 85], [56, 86], [56, 88], [57, 59], [57, 60], [57, 62], [57, 63], [57, 65], [57, 66], [57, 69], [57, 70], [57, 74], [57, 78], [57, 79], [57, 80], [57, 82], [57, 84], [57, 85], [57, 89], [58, 60], [58, 62], [58, 63], [58, 64], [58, 65], [58, 69], [58, 72], [58, 75], [58, 77], [58, 78], [58, 80], [58, 81], [58, 87], [58, 88], [59, 60], [59, 62], [59, 65], [59, 66], [59, 67], [59, 68], [59, 70], [59, 72], [59, 73], [59, 74], [59, 78], [59, 80], [59, 81], [59, 83], [59, 86], [59, 89], [60, 61], [60, 63], [60, 66], [60, 67], [60, 68], [60, 69], [60, 70], [60, 71], [60, 72], [60, 74], [60, 75], [60, 76], [60, 77], [60, 80], [60, 84], [60, 85], [60, 87], [61, 62], [61, 63], [61, 64], [61, 65], [61, 67], [61, 70], [61, 71], [61, 72], [61, 76], [61, 78], [61, 81], [61, 83], [61, 84], [61, 89], [62, 63], [62, 64], [62, 67], [62, 68], [62, 70], [62, 73], [62, 74], [62, 75], [62, 77], [62, 78], [62, 80], [62, 83], [62, 86], [62, 88], [63, 64], [63, 65], [63, 66], [63, 67], [63, 69], [63, 70], [63, 71], [63, 74], [63, 75], [63, 76], [63, 79], [63, 80], [63, 81], [63, 82], [63, 85], [63, 86], [63, 88], [63, 89], [64, 65], [64, 68], [64, 71], [64, 73], [64, 74], [64, 78], [64, 79], [64, 85], [64, 86], [64, 87], [65, 67], [65, 68], [65, 70], [65, 71], [65, 72], [65, 73], [65, 74], [65, 79], [65, 80], [65, 81], [65, 82], [65, 83], [65, 84], [65, 85], [65, 86], [66, 68], [66, 69], [66, 70], [66, 72], [66, 79], [66, 82], [66, 83], [66, 86], [66, 89], [67, 70], [67, 72], [67, 76], [67, 79], [67, 81], [67, 83], [67, 85], [67, 86], [67, 88], [68, 69], [68, 73], [68, 74], [68, 83], [68, 86], [68, 87], [68, 89], [69, 71], [69, 73], [69, 74], [69, 75], [69, 76], [69, 78], [69, 79], [69, 82], [69, 83], [69, 87], [69, 89], [70, 71], [70, 75], [70, 76], [70, 80], [70, 81], [70, 82], [70, 84], [70, 85], [70, 86], [70, 87], [70, 88], [71, 79], [71, 83], [71, 87], [72, 75], [72, 76], [72, 78], [72, 80], [72, 82], [72, 87], [73, 75], [73, 81], [73, 82], [73, 84], [73, 88], [73, 89], [74, 75], [74, 77], [74, 80], [74, 81], [74, 86], [74, 87], [74, 89], [75, 76], [75, 80], [75, 81], [75, 82], [75, 84], [75, 85], [75, 86], [76, 78], [76, 80], [76, 83], [76, 85], [76, 86], [76, 87], [76, 89], [77, 78], [77, 79], [77, 80], [77, 82], [77, 84], [77, 86], [77, 89], [78, 79], [78, 80], [78, 82], [78, 83], [78, 86], [78, 87], [78, 88], [78, 89], [79, 80], [79, 82], [79, 83], [79, 85], [79, 87], [79, 88], [80, 81], [80, 83], [80, 87], [80, 88], [80, 89], [81, 84], [81, 86], [81, 89], [82, 85], [83, 84], [83, 85], [83, 88], [83, 89], [84, 85], [84, 86], [84, 88], [85, 86], [85, 88], [87, 88], [88, 89]], "family": "mc_max_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-clique-l5-s4/tests/run.py b/tasks/construct-mc-max-clique-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-clique-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-max-clique-l5-s4/tests/test.sh b/tasks/construct-mc-max-clique-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-clique-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-max-independent-set-l2-s0/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-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-mc-max-independent-set-l2-s0/environment/instance.json b/tasks/construct-mc-max-independent-set-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e6cc9c78a1ca27576863b865540480e55b72a243 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 30, "k": 9, "edges": [[0, 8], [0, 9], [0, 13], [0, 19], [0, 26], [0, 27], [1, 2], [1, 4], [1, 10], [1, 11], [1, 14], [1, 17], [1, 23], [2, 3], [2, 10], [2, 12], [2, 16], [2, 23], [2, 28], [2, 29], [3, 6], [3, 8], [3, 27], [3, 29], [4, 7], [4, 12], [4, 19], [4, 21], [4, 22], [4, 23], [5, 7], [5, 16], [5, 17], [5, 19], [5, 20], [5, 21], [5, 23], [6, 7], [6, 11], [6, 15], [6, 24], [6, 26], [7, 14], [7, 16], [7, 19], [7, 20], [7, 21], [8, 21], [8, 24], [8, 27], [9, 15], [9, 17], [9, 19], [9, 20], [9, 22], [9, 28], [9, 29], [10, 15], [10, 27], [11, 12], [11, 15], [11, 22], [11, 25], [12, 16], [12, 17], [12, 18], [12, 20], [12, 22], [13, 15], [13, 17], [13, 18], [13, 20], [13, 22], [13, 24], [13, 28], [13, 29], [14, 21], [14, 26], [14, 27], [15, 18], [15, 20], [15, 28], [16, 17], [16, 23], [17, 18], [17, 28], [18, 22], [19, 25], [19, 26], [19, 28], [20, 24], [20, 27], [20, 29], [21, 23], [21, 25], [21, 29], [22, 24], [22, 26], [23, 25], [23, 26], [23, 27], [24, 26], [24, 28], [27, 29]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l2-s0/solution/solve.sh b/tasks/construct-mc-max-independent-set-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d338909ae920dff8338b766681ba115e8dab882e --- /dev/null +++ b/tasks/construct-mc-max-independent-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' +{"independent_set": [4, 8, 10, 14, 16, 18, 20, 25, 28]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l2-s0/tests/check.py b/tasks/construct-mc-max-independent-set-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l2-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-l2-s0/tests/instance.json b/tasks/construct-mc-max-independent-set-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e6cc9c78a1ca27576863b865540480e55b72a243 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 30, "k": 9, "edges": [[0, 8], [0, 9], [0, 13], [0, 19], [0, 26], [0, 27], [1, 2], [1, 4], [1, 10], [1, 11], [1, 14], [1, 17], [1, 23], [2, 3], [2, 10], [2, 12], [2, 16], [2, 23], [2, 28], [2, 29], [3, 6], [3, 8], [3, 27], [3, 29], [4, 7], [4, 12], [4, 19], [4, 21], [4, 22], [4, 23], [5, 7], [5, 16], [5, 17], [5, 19], [5, 20], [5, 21], [5, 23], [6, 7], [6, 11], [6, 15], [6, 24], [6, 26], [7, 14], [7, 16], [7, 19], [7, 20], [7, 21], [8, 21], [8, 24], [8, 27], [9, 15], [9, 17], [9, 19], [9, 20], [9, 22], [9, 28], [9, 29], [10, 15], [10, 27], [11, 12], [11, 15], [11, 22], [11, 25], [12, 16], [12, 17], [12, 18], [12, 20], [12, 22], [13, 15], [13, 17], [13, 18], [13, 20], [13, 22], [13, 24], [13, 28], [13, 29], [14, 21], [14, 26], [14, 27], [15, 18], [15, 20], [15, 28], [16, 17], [16, 23], [17, 18], [17, 28], [18, 22], [19, 25], [19, 26], [19, 28], [20, 24], [20, 27], [20, 29], [21, 23], [21, 25], [21, 29], [22, 24], [22, 26], [23, 25], [23, 26], [23, 27], [24, 26], [24, 28], [27, 29]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l2-s0/tests/run.py b/tasks/construct-mc-max-independent-set-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-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-mc-max-independent-set-l2-s0/tests/test.sh b/tasks/construct-mc-max-independent-set-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-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-mc-max-independent-set-l2-s7/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-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-mc-max-independent-set-l2-s7/environment/instance.json b/tasks/construct-mc-max-independent-set-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..83ced27ba66d0586232e005c4671d7a091a86e7a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 30, "k": 9, "edges": [[0, 1], [0, 3], [0, 7], [0, 9], [0, 13], [0, 15], [0, 17], [0, 21], [0, 23], [0, 26], [1, 6], [1, 7], [1, 8], [1, 19], [1, 26], [1, 28], [2, 6], [2, 7], [2, 12], [2, 15], [2, 17], [2, 27], [2, 28], [2, 29], [3, 7], [3, 11], [3, 12], [3, 14], [3, 15], [3, 20], [3, 24], [3, 27], [3, 28], [4, 8], [4, 15], [4, 18], [4, 19], [4, 23], [5, 6], [5, 14], [5, 21], [5, 28], [6, 7], [6, 16], [6, 17], [6, 18], [6, 26], [6, 28], [7, 11], [7, 27], [8, 17], [8, 26], [8, 29], [9, 12], [9, 14], [9, 15], [9, 21], [9, 23], [9, 27], [9, 29], [10, 16], [10, 18], [10, 19], [10, 26], [10, 28], [11, 14], [11, 28], [12, 13], [12, 14], [12, 17], [12, 18], [12, 19], [12, 22], [12, 25], [12, 26], [12, 28], [13, 15], [13, 18], [13, 21], [13, 29], [14, 16], [14, 26], [15, 18], [15, 19], [15, 22], [15, 24], [15, 26], [15, 27], [16, 26], [17, 18], [17, 24], [17, 27], [17, 29], [18, 21], [18, 24], [19, 27], [19, 28], [20, 21], [20, 28], [20, 29], [21, 25], [21, 29], [22, 24], [22, 25], [22, 29], [23, 27], [23, 28], [24, 26], [25, 27], [25, 29], [26, 27], [26, 28]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l2-s7/solution/solve.sh b/tasks/construct-mc-max-independent-set-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9e832e14d9a8aedddacffe1491ca8029d5e5c8d2 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l2-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"independent_set": [1, 2, 10, 13, 14, 20, 23, 24, 25]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l2-s7/tests/check.py b/tasks/construct-mc-max-independent-set-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l2-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-l2-s7/tests/instance.json b/tasks/construct-mc-max-independent-set-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..83ced27ba66d0586232e005c4671d7a091a86e7a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 30, "k": 9, "edges": [[0, 1], [0, 3], [0, 7], [0, 9], [0, 13], [0, 15], [0, 17], [0, 21], [0, 23], [0, 26], [1, 6], [1, 7], [1, 8], [1, 19], [1, 26], [1, 28], [2, 6], [2, 7], [2, 12], [2, 15], [2, 17], [2, 27], [2, 28], [2, 29], [3, 7], [3, 11], [3, 12], [3, 14], [3, 15], [3, 20], [3, 24], [3, 27], [3, 28], [4, 8], [4, 15], [4, 18], [4, 19], [4, 23], [5, 6], [5, 14], [5, 21], [5, 28], [6, 7], [6, 16], [6, 17], [6, 18], [6, 26], [6, 28], [7, 11], [7, 27], [8, 17], [8, 26], [8, 29], [9, 12], [9, 14], [9, 15], [9, 21], [9, 23], [9, 27], [9, 29], [10, 16], [10, 18], [10, 19], [10, 26], [10, 28], [11, 14], [11, 28], [12, 13], [12, 14], [12, 17], [12, 18], [12, 19], [12, 22], [12, 25], [12, 26], [12, 28], [13, 15], [13, 18], [13, 21], [13, 29], [14, 16], [14, 26], [15, 18], [15, 19], [15, 22], [15, 24], [15, 26], [15, 27], [16, 26], [17, 18], [17, 24], [17, 27], [17, 29], [18, 21], [18, 24], [19, 27], [19, 28], [20, 21], [20, 28], [20, 29], [21, 25], [21, 29], [22, 24], [22, 25], [22, 29], [23, 27], [23, 28], [24, 26], [25, 27], [25, 29], [26, 27], [26, 28]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l2-s7/tests/run.py b/tasks/construct-mc-max-independent-set-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l2-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-max-independent-set-l2-s7/tests/test.sh b/tasks/construct-mc-max-independent-set-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l2-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-max-independent-set-l2-s9/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-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-mc-max-independent-set-l2-s9/environment/instance.json b/tasks/construct-mc-max-independent-set-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1447135d16d2fe072f0c8b548ff31375764a319f --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 30, "k": 9, "edges": [[0, 4], [0, 10], [0, 12], [0, 20], [1, 7], [1, 12], [1, 18], [1, 19], [1, 22], [1, 24], [1, 26], [1, 28], [2, 3], [2, 6], [2, 15], [2, 20], [2, 22], [2, 24], [2, 25], [2, 29], [3, 5], [3, 6], [3, 7], [3, 9], [3, 22], [4, 6], [4, 8], [4, 9], [4, 16], [4, 18], [4, 21], [4, 23], [4, 24], [4, 25], [4, 27], [5, 11], [5, 12], [5, 17], [5, 19], [5, 21], [5, 27], [5, 29], [6, 12], [6, 13], [6, 16], [6, 21], [6, 22], [7, 11], [7, 20], [7, 21], [7, 23], [7, 25], [7, 27], [8, 13], [8, 23], [8, 24], [8, 27], [9, 11], [9, 12], [9, 14], [9, 16], [9, 22], [9, 26], [9, 29], [10, 11], [10, 19], [10, 21], [10, 23], [10, 25], [11, 13], [11, 14], [11, 16], [11, 19], [11, 28], [12, 14], [12, 15], [12, 19], [12, 20], [12, 27], [12, 29], [13, 15], [13, 18], [13, 20], [14, 17], [14, 19], [15, 16], [15, 20], [15, 25], [15, 29], [16, 18], [16, 19], [16, 24], [16, 26], [17, 23], [17, 27], [18, 19], [18, 24], [18, 25], [18, 28], [19, 20], [19, 21], [19, 24], [19, 25], [19, 29], [20, 22], [20, 29], [21, 25], [21, 27], [22, 26], [23, 24], [23, 25], [23, 28], [24, 25], [24, 29], [25, 29]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l2-s9/solution/solve.sh b/tasks/construct-mc-max-independent-set-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..381b371543074b98c636cff52a08d1e8a9ba3eb4 --- /dev/null +++ b/tasks/construct-mc-max-independent-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' +{"independent_set": [0, 1, 3, 13, 14, 16, 21, 23, 29]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l2-s9/tests/check.py b/tasks/construct-mc-max-independent-set-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l2-s9/tests/check.py @@ -0,0 +1,18 @@ +"""Independent set of size >= k in a given graph (MathConstraint max_independent_set, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"set has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) in E: + raise Invalid(f"vertices {u} and {v} are adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-independent-set-l2-s9/tests/instance.json b/tasks/construct-mc-max-independent-set-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1447135d16d2fe072f0c8b548ff31375764a319f --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 30, "k": 9, "edges": [[0, 4], [0, 10], [0, 12], [0, 20], [1, 7], [1, 12], [1, 18], [1, 19], [1, 22], [1, 24], [1, 26], [1, 28], [2, 3], [2, 6], [2, 15], [2, 20], [2, 22], [2, 24], [2, 25], [2, 29], [3, 5], [3, 6], [3, 7], [3, 9], [3, 22], [4, 6], [4, 8], [4, 9], [4, 16], [4, 18], [4, 21], [4, 23], [4, 24], [4, 25], [4, 27], [5, 11], [5, 12], [5, 17], [5, 19], [5, 21], [5, 27], [5, 29], [6, 12], [6, 13], [6, 16], [6, 21], [6, 22], [7, 11], [7, 20], [7, 21], [7, 23], [7, 25], [7, 27], [8, 13], [8, 23], [8, 24], [8, 27], [9, 11], [9, 12], [9, 14], [9, 16], [9, 22], [9, 26], [9, 29], [10, 11], [10, 19], [10, 21], [10, 23], [10, 25], [11, 13], [11, 14], [11, 16], [11, 19], [11, 28], [12, 14], [12, 15], [12, 19], [12, 20], [12, 27], [12, 29], [13, 15], [13, 18], [13, 20], [14, 17], [14, 19], [15, 16], [15, 20], [15, 25], [15, 29], [16, 18], [16, 19], [16, 24], [16, 26], [17, 23], [17, 27], [18, 19], [18, 24], [18, 25], [18, 28], [19, 20], [19, 21], [19, 24], [19, 25], [19, 29], [20, 22], [20, 29], [21, 25], [21, 27], [22, 26], [23, 24], [23, 25], [23, 28], [24, 25], [24, 29], [25, 29]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l2-s9/tests/run.py b/tasks/construct-mc-max-independent-set-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-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-mc-max-independent-set-l2-s9/tests/test.sh b/tasks/construct-mc-max-independent-set-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-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-mc-max-independent-set-l6-s1/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-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-mc-max-independent-set-l6-s1/environment/instance.json b/tasks/construct-mc-max-independent-set-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5421e4270e50b60b830d32d677bd083c43048595 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 140, "k": 18, "edges": [[0, 12], [0, 13], [0, 18], [0, 19], [0, 20], [0, 25], [0, 26], [0, 27], [0, 31], [0, 34], [0, 35], [0, 37], [0, 38], [0, 49], [0, 53], [0, 54], [0, 56], [0, 59], [0, 60], [0, 63], [0, 68], [0, 71], [0, 73], [0, 75], [0, 78], [0, 80], [0, 81], [0, 84], [0, 85], [0, 87], [0, 88], [0, 93], [0, 95], [0, 98], [0, 99], [0, 101], [0, 104], [0, 108], [0, 112], [0, 113], [0, 123], [0, 126], [0, 127], [0, 133], [1, 5], [1, 7], [1, 9], [1, 16], [1, 20], [1, 21], [1, 24], [1, 25], [1, 31], [1, 32], [1, 33], [1, 34], [1, 37], [1, 38], [1, 40], [1, 42], [1, 43], [1, 45], [1, 47], [1, 49], [1, 50], [1, 51], [1, 52], [1, 55], [1, 59], [1, 64], [1, 80], [1, 82], [1, 87], [1, 88], [1, 92], [1, 102], [1, 104], [1, 113], [1, 117], [1, 118], [1, 122], [1, 123], [1, 128], [1, 135], [2, 5], [2, 6], [2, 9], [2, 12], [2, 15], [2, 19], [2, 20], [2, 22], [2, 25], [2, 29], [2, 30], [2, 38], [2, 40], [2, 49], [2, 56], [2, 70], [2, 76], [2, 77], [2, 79], [2, 80], [2, 89], [2, 90], [2, 92], [2, 94], [2, 95], [2, 98], [2, 105], [2, 107], [2, 112], [2, 113], [2, 128], [2, 130], [2, 137], [2, 138], [3, 4], [3, 12], [3, 13], [3, 16], [3, 17], [3, 20], [3, 23], [3, 27], [3, 32], [3, 34], [3, 36], [3, 37], [3, 49], [3, 51], [3, 57], [3, 58], [3, 61], [3, 63], [3, 64], [3, 69], [3, 72], [3, 77], [3, 84], [3, 88], [3, 90], [3, 97], [3, 116], [3, 120], [3, 124], [3, 129], [3, 130], [3, 131], [3, 136], [3, 137], [3, 139], [4, 5], [4, 7], [4, 14], [4, 16], [4, 19], [4, 21], [4, 23], [4, 29], [4, 32], [4, 33], [4, 36], [4, 38], [4, 45], [4, 51], [4, 57], [4, 58], [4, 59], [4, 62], [4, 63], [4, 66], [4, 68], [4, 71], [4, 74], [4, 78], [4, 83], [4, 84], [4, 89], [4, 102], [4, 103], [4, 105], [4, 107], [4, 111], [4, 113], [4, 116], [4, 117], [4, 132], [4, 135], [4, 136], [5, 11], [5, 13], [5, 15], [5, 18], [5, 19], [5, 26], [5, 28], [5, 30], [5, 36], [5, 41], [5, 43], [5, 44], [5, 45], [5, 51], [5, 52], [5, 54], [5, 58], [5, 60], [5, 62], [5, 68], [5, 69], [5, 71], [5, 82], [5, 84], [5, 85], [5, 86], [5, 91], [5, 99], [5, 102], [5, 107], [5, 108], [5, 112], [5, 121], [5, 127], [5, 129], [5, 130], [5, 133], [5, 134], [5, 135], [5, 138], [5, 139], [6, 7], [6, 10], [6, 11], [6, 12], [6, 15], [6, 17], [6, 18], [6, 21], [6, 22], [6, 36], [6, 38], [6, 39], [6, 44], [6, 48], [6, 49], [6, 50], [6, 52], [6, 54], [6, 55], [6, 57], [6, 60], [6, 66], [6, 67], [6, 70], [6, 73], [6, 76], [6, 79], [6, 80], [6, 84], [6, 90], [6, 91], [6, 96], [6, 103], [6, 107], [6, 108], [6, 111], [6, 114], [6, 115], [6, 117], [6, 119], [6, 121], [6, 122], [6, 129], [6, 130], [6, 137], [6, 138], [6, 139], [7, 13], [7, 17], [7, 18], [7, 19], [7, 35], [7, 36], [7, 38], [7, 40], [7, 44], [7, 51], [7, 52], [7, 56], [7, 59], [7, 61], [7, 62], [7, 72], [7, 75], [7, 76], [7, 79], [7, 80], [7, 83], [7, 87], [7, 88], [7, 93], [7, 95], [7, 97], [7, 98], [7, 103], [7, 104], [7, 118], [7, 120], [7, 123], [7, 128], [7, 134], [8, 12], [8, 13], [8, 15], [8, 19], [8, 21], [8, 25], [8, 28], [8, 29], [8, 30], [8, 34], [8, 36], [8, 47], [8, 52], [8, 56], [8, 59], [8, 62], [8, 63], [8, 75], [8, 83], [8, 86], [8, 87], [8, 88], [8, 90], [8, 91], [8, 98], [8, 100], [8, 101], [8, 122], [8, 123], [8, 128], [8, 129], [8, 135], [9, 15], [9, 22], [9, 23], [9, 29], [9, 30], [9, 32], [9, 36], [9, 38], [9, 40], [9, 46], [9, 50], [9, 51], [9, 53], [9, 61], [9, 63], [9, 65], [9, 66], [9, 69], [9, 73], [9, 76], [9, 80], [9, 82], [9, 84], [9, 86], [9, 88], [9, 89], [9, 90], [9, 91], [9, 92], [9, 93], [9, 94], [9, 102], [9, 103], [9, 109], [9, 115], [9, 119], [9, 123], [9, 125], [9, 127], [9, 131], [9, 136], [9, 138], [9, 139], [10, 18], [10, 20], [10, 23], [10, 27], [10, 33], [10, 36], [10, 40], [10, 41], [10, 42], [10, 43], [10, 44], [10, 48], [10, 50], [10, 56], [10, 57], [10, 58], [10, 66], [10, 68], [10, 70], [10, 76], [10, 81], [10, 84], [10, 85], [10, 86], [10, 95], [10, 96], [10, 99], [10, 101], [10, 102], [10, 103], [10, 104], [10, 106], [10, 108], [10, 112], [10, 119], [10, 121], [10, 122], [10, 126], [10, 127], [10, 132], [10, 135], [10, 138], [10, 139], [11, 12], [11, 13], [11, 14], [11, 17], [11, 24], [11, 25], [11, 30], [11, 35], [11, 46], [11, 47], [11, 49], [11, 53], [11, 54], [11, 55], [11, 57], [11, 59], [11, 60], [11, 62], [11, 65], [11, 66], [11, 69], [11, 71], [11, 74], [11, 88], [11, 93], [11, 94], [11, 96], [11, 97], [11, 100], [11, 102], [11, 103], [11, 104], [11, 109], [11, 111], [11, 114], [11, 116], [11, 117], [11, 118], [11, 122], [11, 125], [11, 126], [11, 129], [11, 131], [11, 134], [11, 135], [11, 138], [12, 14], [12, 16], [12, 19], [12, 25], [12, 26], [12, 32], [12, 38], [12, 42], [12, 48], [12, 49], [12, 50], [12, 51], [12, 53], [12, 55], [12, 57], [12, 58], [12, 59], [12, 64], [12, 65], [12, 70], [12, 78], [12, 81], [12, 83], [12, 86], [12, 87], [12, 90], [12, 91], [12, 94], [12, 104], [12, 105], [12, 106], [12, 107], [12, 108], [12, 112], [12, 113], [12, 118], [12, 120], [12, 122], [12, 128], [12, 129], [12, 130], [12, 134], [12, 139], [13, 18], [13, 19], [13, 23], [13, 33], [13, 34], [13, 37], [13, 42], [13, 46], [13, 49], [13, 53], [13, 56], [13, 64], [13, 65], [13, 66], [13, 68], [13, 69], [13, 70], [13, 73], [13, 82], [13, 83], [13, 86], [13, 87], [13, 91], [13, 94], [13, 106], [13, 108], [13, 109], [13, 113], [13, 114], [13, 117], [13, 120], [13, 123], [13, 127], [13, 138], [14, 15], [14, 20], [14, 23], [14, 25], [14, 28], [14, 35], [14, 39], [14, 44], [14, 50], [14, 53], [14, 56], [14, 57], [14, 60], [14, 62], [14, 69], [14, 70], [14, 71], [14, 74], [14, 76], [14, 77], [14, 79], [14, 81], [14, 83], [14, 88], [14, 89], [14, 90], [14, 92], [14, 93], [14, 101], [14, 102], [14, 113], [14, 117], [14, 121], [14, 122], [14, 124], [14, 125], [14, 129], [14, 132], [14, 133], [15, 17], [15, 18], [15, 19], [15, 20], [15, 23], [15, 25], [15, 34], [15, 36], [15, 42], [15, 43], [15, 44], [15, 50], [15, 52], [15, 54], [15, 55], [15, 56], [15, 60], [15, 69], [15, 74], [15, 77], [15, 84], [15, 86], [15, 87], [15, 88], [15, 90], [15, 93], [15, 95], [15, 97], [15, 98], [15, 100], [15, 102], [15, 111], [15, 113], [15, 114], [15, 118], [15, 120], [15, 121], [15, 122], [15, 123], [15, 126], [15, 129], [15, 132], [15, 135], [16, 22], [16, 27], [16, 29], [16, 32], [16, 40], [16, 52], [16, 55], [16, 57], [16, 68], [16, 71], [16, 72], [16, 75], [16, 77], [16, 82], [16, 84], [16, 86], [16, 88], [16, 89], [16, 95], [16, 102], [16, 110], [16, 111], [16, 113], [16, 117], [16, 121], [16, 122], [16, 124], [16, 126], [16, 128], [16, 132], [16, 136], [17, 19], [17, 23], [17, 27], [17, 32], [17, 33], [17, 34], [17, 37], [17, 45], [17, 48], [17, 50], [17, 51], [17, 54], [17, 55], [17, 64], [17, 67], [17, 68], [17, 71], [17, 74], [17, 75], [17, 77], [17, 78], [17, 81], [17, 86], [17, 88], [17, 89], [17, 94], [17, 99], [17, 100], [17, 101], [17, 104], [17, 108], [17, 113], [17, 114], [17, 115], [17, 116], [17, 119], [17, 124], [17, 139], [18, 21], [18, 23], [18, 25], [18, 28], [18, 29], [18, 31], [18, 33], [18, 38], [18, 42], [18, 43], [18, 45], [18, 47], [18, 50], [18, 53], [18, 57], [18, 59], [18, 60], [18, 61], [18, 63], [18, 69], [18, 79], [18, 85], [18, 87], [18, 88], [18, 89], [18, 92], [18, 94], [18, 96], [18, 105], [18, 109], [18, 110], [18, 115], [18, 117], [18, 119], [18, 120], [18, 121], [18, 131], [18, 133], [18, 134], [18, 138], [18, 139], [19, 22], [19, 23], [19, 24], [19, 26], [19, 27], [19, 28], [19, 30], [19, 32], [19, 33], [19, 35], [19, 36], [19, 37], [19, 39], [19, 47], [19, 51], [19, 54], [19, 62], [19, 69], [19, 71], [19, 73], [19, 85], [19, 86], [19, 89], [19, 90], [19, 98], [19, 105], [19, 110], [19, 111], [19, 112], [19, 116], [19, 126], [19, 131], [19, 133], [20, 21], [20, 24], [20, 25], [20, 26], [20, 28], [20, 29], [20, 31], [20, 34], [20, 36], [20, 38], [20, 39], [20, 41], [20, 44], [20, 51], [20, 58], [20, 59], [20, 60], [20, 62], [20, 72], [20, 73], [20, 79], [20, 80], [20, 82], [20, 83], [20, 84], [20, 86], [20, 89], [20, 90], [20, 95], [20, 101], [20, 113], [20, 116], [20, 117], [20, 121], [20, 126], [20, 127], [20, 132], [21, 24], [21, 26], [21, 27], [21, 34], [21, 52], [21, 55], [21, 59], [21, 65], [21, 72], [21, 74], [21, 76], [21, 81], [21, 84], [21, 94], [21, 103], [21, 105], [21, 109], [21, 111], [21, 112], [21, 113], [21, 114], [21, 129], [21, 131], [21, 134], [21, 137], [21, 139], [22, 32], [22, 36], [22, 54], [22, 56], [22, 58], [22, 59], [22, 63], [22, 64], [22, 68], [22, 71], [22, 76], [22, 78], [22, 83], [22, 85], [22, 92], [22, 94], [22, 96], [22, 99], [22, 101], [22, 107], [22, 108], [22, 110], [22, 117], [22, 118], [22, 132], [22, 133], [22, 134], [22, 137], [23, 24], [23, 29], [23, 43], [23, 47], [23, 49], [23, 50], [23, 56], [23, 59], [23, 63], [23, 64], [23, 70], [23, 78], [23, 80], [23, 84], [23, 87], [23, 88], [23, 93], [23, 94], [23, 98], [23, 101], [23, 107], [23, 110], [23, 112], [23, 116], [23, 120], [23, 121], [23, 122], [23, 130], [23, 132], [23, 136], [24, 28], [24, 32], [24, 33], [24, 37], [24, 40], [24, 44], [24, 46], [24, 47], [24, 48], [24, 52], [24, 54], [24, 55], [24, 66], [24, 68], [24, 76], [24, 77], [24, 78], [24, 79], [24, 80], [24, 91], [24, 97], [24, 100], [24, 103], [24, 113], [24, 116], [24, 120], [24, 122], [24, 123], [24, 126], [24, 135], [25, 29], [25, 31], [25, 34], [25, 41], [25, 46], [25, 48], [25, 49], [25, 50], [25, 51], [25, 52], [25, 54], [25, 62], [25, 70], [25, 73], [25, 75], [25, 78], [25, 81], [25, 82], [25, 83], [25, 85], [25, 88], [25, 89], [25, 93], [25, 96], [25, 98], [25, 103], [25, 109], [25, 111], [25, 112], [25, 113], [25, 125], [25, 128], [26, 34], [26, 35], [26, 36], [26, 38], [26, 44], [26, 50], [26, 51], [26, 58], [26, 60], [26, 62], [26, 64], [26, 65], [26, 66], [26, 67], [26, 79], [26, 88], [26, 93], [26, 98], [26, 105], [26, 109], [26, 110], [26, 115], [26, 117], [26, 118], [26, 122], [26, 123], [26, 126], [26, 128], [26, 129], [26, 131], [26, 132], [26, 133], [26, 137], [26, 138], [27, 29], [27, 31], [27, 32], [27, 33], [27, 34], [27, 38], [27, 39], [27, 44], [27, 47], [27, 49], [27, 51], [27, 53], [27, 55], [27, 62], [27, 65], [27, 67], [27, 69], [27, 75], [27, 77], [27, 78], [27, 79], [27, 80], [27, 84], [27, 88], [27, 96], [27, 99], [27, 100], [27, 103], [27, 105], [27, 107], [27, 115], [27, 120], [27, 123], [27, 124], [27, 128], [27, 134], [27, 136], [27, 137], [28, 29], [28, 34], [28, 37], [28, 38], [28, 42], [28, 46], [28, 47], [28, 49], [28, 53], [28, 57], [28, 60], [28, 61], [28, 62], [28, 64], [28, 65], [28, 66], [28, 71], [28, 74], [28, 76], [28, 82], [28, 83], [28, 90], [28, 91], [28, 93], [28, 100], [28, 101], [28, 102], [28, 105], [28, 111], [28, 113], [28, 115], [28, 118], [28, 119], [28, 121], [28, 128], [28, 136], [28, 137], [29, 32], [29, 38], [29, 43], [29, 44], [29, 47], [29, 48], [29, 51], [29, 52], [29, 53], [29, 54], [29, 55], [29, 56], [29, 59], [29, 61], [29, 62], [29, 64], [29, 66], [29, 68], [29, 69], [29, 70], [29, 71], [29, 74], [29, 79], [29, 80], [29, 81], [29, 84], [29, 90], [29, 91], [29, 92], [29, 93], [29, 95], [29, 101], [29, 103], [29, 105], [29, 106], [29, 111], [29, 113], [29, 114], [29, 115], [29, 120], [29, 125], [29, 130], [29, 133], [29, 135], [29, 139], [30, 34], [30, 35], [30, 36], [30, 38], [30, 39], [30, 43], [30, 47], [30, 51], [30, 53], [30, 58], [30, 60], [30, 61], [30, 62], [30, 63], [30, 70], [30, 73], [30, 90], [30, 95], [30, 99], [30, 100], [30, 101], [30, 104], [30, 110], [30, 113], [30, 121], [30, 127], [30, 129], [30, 131], [30, 134], [30, 138], [31, 32], [31, 35], [31, 36], [31, 40], [31, 41], [31, 59], [31, 61], [31, 62], [31, 63], [31, 64], [31, 66], [31, 68], [31, 71], [31, 73], [31, 76], [31, 82], [31, 85], [31, 87], [31, 88], [31, 89], [31, 104], [31, 106], [31, 112], [31, 113], [31, 114], [31, 122], [31, 126], [31, 127], [31, 128], [31, 129], [31, 130], [31, 133], [31, 135], [32, 35], [32, 37], [32, 45], [32, 46], [32, 50], [32, 54], [32, 55], [32, 57], [32, 58], [32, 59], [32, 60], [32, 64], [32, 65], [32, 69], [32, 70], [32, 73], [32, 76], [32, 78], [32, 84], [32, 89], [32, 98], [32, 100], [32, 102], [32, 106], [32, 107], [32, 108], [32, 110], [32, 111], [32, 113], [32, 115], [32, 116], [32, 118], [32, 121], [32, 122], [32, 127], [32, 128], [32, 136], [32, 137], [33, 36], [33, 37], [33, 40], [33, 41], [33, 42], [33, 44], [33, 49], [33, 50], [33, 56], [33, 63], [33, 65], [33, 67], [33, 72], [33, 77], [33, 79], [33, 80], [33, 81], [33, 88], [33, 92], [33, 95], [33, 99], [33, 103], [33, 104], [33, 105], [33, 106], [33, 116], [33, 117], [33, 119], [33, 121], [33, 124], [33, 125], [33, 126], [33, 128], [33, 131], [33, 133], [34, 35], [34, 40], [34, 41], [34, 42], [34, 44], [34, 52], [34, 60], [34, 61], [34, 62], [34, 63], [34, 65], [34, 67], [34, 71], [34, 92], [34, 93], [34, 102], [34, 105], [34, 107], [34, 108], [34, 115], [34, 131], [34, 133], [34, 136], [35, 37], [35, 43], [35, 44], [35, 45], [35, 47], [35, 49], [35, 53], [35, 58], [35, 59], [35, 62], [35, 63], [35, 66], [35, 71], [35, 74], [35, 79], [35, 81], [35, 83], [35, 89], [35, 91], [35, 94], [35, 97], [35, 98], [35, 102], [35, 103], [35, 105], [35, 107], [35, 108], [35, 110], [35, 112], [35, 114], [35, 118], [35, 119], [35, 131], [35, 133], [36, 37], [36, 38], [36, 40], [36, 42], [36, 43], [36, 46], [36, 48], [36, 51], [36, 54], [36, 55], [36, 59], [36, 63], [36, 65], [36, 67], [36, 68], [36, 69], [36, 74], [36, 75], [36, 76], [36, 80], [36, 93], [36, 94], [36, 97], [36, 100], [36, 102], [36, 113], [36, 116], [36, 118], [36, 123], [36, 126], [36, 127], [36, 128], [36, 130], [36, 134], [36, 136], [36, 137], [36, 138], [36, 139], [37, 38], [37, 39], [37, 40], [37, 42], [37, 44], [37, 47], [37, 49], [37, 53], [37, 54], [37, 63], [37, 68], [37, 70], [37, 75], [37, 81], [37, 86], [37, 91], [37, 92], [37, 93], [37, 94], [37, 99], [37, 101], [37, 104], [37, 109], [37, 112], [37, 117], [37, 120], [37, 124], [37, 128], [37, 134], [37, 136], [38, 40], [38, 42], [38, 51], [38, 54], [38, 57], [38, 58], [38, 59], [38, 60], [38, 61], [38, 62], [38, 65], [38, 67], [38, 68], [38, 72], [38, 74], [38, 77], [38, 79], [38, 80], [38, 82], [38, 84], [38, 89], [38, 90], [38, 91], [38, 92], [38, 98], [38, 104], [38, 106], [38, 107], [38, 110], [38, 113], [38, 122], [38, 125], [38, 128], [38, 133], [38, 137], [39, 42], [39, 43], [39, 47], [39, 49], [39, 50], [39, 51], [39, 52], [39, 55], [39, 56], [39, 63], [39, 65], [39, 66], [39, 70], [39, 72], [39, 74], [39, 76], [39, 79], [39, 85], [39, 87], [39, 92], [39, 97], [39, 103], [39, 106], [39, 110], [39, 113], [39, 114], [39, 116], [39, 119], [39, 124], [39, 129], [39, 130], [39, 132], [39, 133], [40, 41], [40, 43], [40, 46], [40, 47], [40, 49], [40, 55], [40, 58], [40, 61], [40, 62], [40, 67], [40, 72], [40, 78], [40, 81], [40, 82], [40, 84], [40, 92], [40, 99], [40, 102], [40, 105], [40, 110], [40, 112], [40, 115], [40, 117], [40, 120], [40, 126], [40, 127], [40, 128], [40, 129], [40, 130], [40, 131], [40, 135], [40, 138], [41, 43], [41, 46], [41, 50], [41, 51], [41, 53], [41, 55], [41, 56], [41, 57], [41, 58], [41, 65], [41, 76], [41, 78], [41, 79], [41, 80], [41, 86], [41, 89], [41, 95], [41, 96], [41, 103], [41, 105], [41, 108], [41, 115], [41, 116], [41, 120], [41, 122], [41, 125], [41, 130], [41, 132], [42, 43], [42, 55], [42, 57], [42, 66], [42, 69], [42, 73], [42, 75], [42, 76], [42, 85], [42, 87], [42, 92], [42, 93], [42, 96], [42, 101], [42, 102], [42, 108], [42, 110], [42, 113], [42, 114], [42, 116], [42, 119], [42, 121], [42, 125], [42, 126], [42, 133], [42, 137], [43, 55], [43, 56], [43, 59], [43, 62], [43, 63], [43, 66], [43, 73], [43, 74], [43, 77], [43, 78], [43, 84], [43, 86], [43, 87], [43, 89], [43, 91], [43, 93], [43, 95], [43, 97], [43, 98], [43, 100], [43, 101], [43, 102], [43, 105], [43, 107], [43, 109], [43, 112], [43, 118], [43, 125], [43, 129], [43, 130], [43, 131], [43, 132], [43, 137], [44, 48], [44, 50], [44, 53], [44, 54], [44, 56], [44, 65], [44, 66], [44, 70], [44, 71], [44, 72], [44, 75], [44, 84], [44, 85], [44, 91], [44, 93], [44, 103], [44, 104], [44, 108], [44, 110], [44, 111], [44, 119], [44, 123], [44, 124], [44, 127], [44, 131], [44, 135], [44, 137], [44, 138], [44, 139], [45, 47], [45, 48], [45, 54], [45, 55], [45, 56], [45, 62], [45, 63], [45, 66], [45, 68], [45, 70], [45, 71], [45, 79], [45, 84], [45, 90], [45, 93], [45, 102], [45, 104], [45, 105], [45, 108], [45, 119], [45, 123], [45, 124], [45, 125], [45, 128], [45, 129], [45, 130], [45, 131], [45, 132], [45, 133], [45, 139], [46, 47], [46, 49], [46, 53], [46, 55], [46, 57], [46, 58], [46, 66], [46, 67], [46, 71], [46, 73], [46, 74], [46, 76], [46, 77], [46, 91], [46, 93], [46, 95], [46, 98], [46, 99], [46, 104], [46, 107], [46, 109], [46, 111], [46, 114], [46, 119], [46, 122], [46, 126], [46, 131], [46, 132], [46, 136], [46, 139], [47, 55], [47, 61], [47, 67], [47, 68], [47, 69], [47, 72], [47, 74], [47, 75], [47, 77], [47, 81], [47, 82], [47, 88], [47, 89], [47, 94], [47, 95], [47, 97], [47, 103], [47, 104], [47, 105], [47, 106], [47, 108], [47, 109], [47, 112], [47, 123], [47, 127], [47, 129], [47, 130], [47, 138], [48, 49], [48, 50], [48, 52], [48, 56], [48, 58], [48, 68], [48, 76], [48, 79], [48, 80], [48, 85], [48, 93], [48, 95], [48, 103], [48, 108], [48, 110], [48, 114], [48, 117], [48, 119], [48, 124], [48, 125], [48, 132], [49, 54], [49, 58], [49, 60], [49, 65], [49, 69], [49, 70], [49, 75], [49, 80], [49, 81], [49, 84], [49, 92], [49, 93], [49, 95], [49, 97], [49, 101], [49, 103], [49, 104], [49, 107], [49, 109], [49, 110], [49, 112], [49, 122], [49, 123], [49, 127], [49, 128], [49, 131], [49, 134], [49, 136], [50, 51], [50, 52], [50, 54], [50, 55], [50, 57], [50, 59], [50, 65], [50, 72], [50, 77], [50, 81], [50, 88], [50, 89], [50, 90], [50, 91], [50, 92], [50, 95], [50, 96], [50, 99], [50, 100], [50, 102], [50, 103], [50, 105], [50, 110], [50, 111], [50, 113], [50, 114], [50, 119], [50, 122], [50, 123], [50, 124], [50, 126], [50, 127], [50, 132], [50, 133], [50, 139], [51, 54], [51, 57], [51, 58], [51, 60], [51, 61], [51, 66], [51, 70], [51, 71], [51, 72], [51, 73], [51, 74], [51, 81], [51, 83], [51, 85], [51, 86], [51, 97], [51, 101], [51, 102], [51, 103], [51, 105], [51, 109], [51, 110], [51, 113], [51, 121], [51, 122], [51, 123], [51, 124], [51, 133], [51, 136], [52, 53], [52, 65], [52, 67], [52, 72], [52, 73], [52, 81], [52, 84], [52, 86], [52, 88], [52, 89], [52, 91], [52, 95], [52, 100], [52, 112], [52, 113], [52, 115], [52, 116], [52, 122], [52, 127], [52, 130], [53, 56], [53, 60], [53, 63], [53, 66], [53, 70], [53, 72], [53, 73], [53, 83], [53, 87], [53, 88], [53, 89], [53, 94], [53, 96], [53, 97], [53, 125], [53, 126], [53, 129], [53, 133], [53, 136], [53, 137], [54, 59], [54, 61], [54, 64], [54, 74], [54, 77], [54, 79], [54, 80], [54, 81], [54, 96], [54, 98], [54, 101], [54, 102], [54, 103], [54, 105], [54, 106], [54, 107], [54, 109], [54, 115], [54, 117], [54, 119], [54, 123], [54, 126], [54, 127], [54, 128], [54, 130], [54, 131], [55, 56], [55, 61], [55, 63], [55, 64], [55, 65], [55, 68], [55, 73], [55, 78], [55, 79], [55, 81], [55, 83], [55, 89], [55, 90], [55, 91], [55, 103], [55, 105], [55, 107], [55, 110], [55, 114], [55, 118], [55, 123], [55, 124], [55, 128], [55, 139], [56, 60], [56, 68], [56, 70], [56, 71], [56, 72], [56, 73], [56, 82], [56, 86], [56, 87], [56, 88], [56, 91], [56, 92], [56, 96], [56, 99], [56, 105], [56, 106], [56, 107], [56, 115], [56, 117], [56, 118], [56, 124], [56, 127], [56, 129], [56, 132], [57, 62], [57, 63], [57, 64], [57, 66], [57, 71], [57, 72], [57, 75], [57, 81], [57, 87], [57, 89], [57, 90], [57, 96], [57, 103], [57, 107], [57, 110], [57, 113], [57, 115], [57, 118], [57, 121], [57, 123], [57, 125], [57, 129], [57, 130], [57, 136], [58, 60], [58, 67], [58, 70], [58, 71], [58, 74], [58, 84], [58, 87], [58, 88], [58, 92], [58, 93], [58, 94], [58, 97], [58, 100], [58, 103], [58, 106], [58, 107], [58, 108], [58, 109], [58, 115], [58, 122], [58, 125], [58, 127], [58, 128], [58, 130], [59, 67], [59, 68], [59, 69], [59, 70], [59, 71], [59, 73], [59, 74], [59, 75], [59, 77], [59, 78], [59, 80], [59, 88], [59, 89], [59, 93], [59, 94], [59, 96], [59, 104], [59, 105], [59, 107], [59, 110], [59, 113], [59, 116], [59, 120], [59, 124], [59, 128], [59, 130], [59, 133], [60, 64], [60, 76], [60, 77], [60, 80], [60, 81], [60, 87], [60, 90], [60, 100], [60, 102], [60, 105], [60, 106], [60, 107], [60, 108], [60, 111], [60, 113], [60, 134], [60, 136], [61, 62], [61, 65], [61, 71], [61, 76], [61, 86], [61, 92], [61, 94], [61, 95], [61, 96], [61, 105], [61, 108], [61, 111], [61, 121], [61, 123], [61, 128], [61, 133], [61, 138], [62, 63], [62, 68], [62, 69], [62, 70], [62, 79], [62, 84], [62, 85], [62, 87], [62, 92], [62, 94], [62, 95], [62, 98], [62, 101], [62, 103], [62, 104], [62, 106], [62, 109], [62, 110], [62, 119], [62, 120], [62, 124], [62, 126], [62, 129], [62, 130], [62, 136], [63, 64], [63, 66], [63, 70], [63, 72], [63, 75], [63, 89], [63, 93], [63, 102], [63, 106], [63, 112], [63, 114], [63, 118], [63, 119], [63, 121], [63, 122], [63, 123], [63, 130], [63, 132], [63, 133], [63, 137], [64, 67], [64, 72], [64, 73], [64, 78], [64, 82], [64, 92], [64, 93], [64, 94], [64, 98], [64, 100], [64, 101], [64, 104], [64, 105], [64, 107], [64, 109], [64, 117], [64, 118], [64, 124], [64, 125], [64, 128], [64, 131], [64, 136], [65, 70], [65, 72], [65, 75], [65, 77], [65, 78], [65, 80], [65, 82], [65, 83], [65, 86], [65, 90], [65, 94], [65, 96], [65, 102], [65, 105], [65, 111], [65, 112], [65, 113], [65, 115], [65, 117], [65, 118], [65, 120], [65, 131], [65, 134], [65, 137], [66, 74], [66, 79], [66, 85], [66, 87], [66, 88], [66, 99], [66, 100], [66, 110], [66, 112], [66, 117], [66, 120], [66, 124], [66, 131], [66, 133], [66, 137], [66, 138], [66, 139], [67, 72], [67, 74], [67, 77], [67, 79], [67, 81], [67, 82], [67, 86], [67, 88], [67, 89], [67, 92], [67, 94], [67, 96], [67, 98], [67, 100], [67, 101], [67, 103], [67, 106], [67, 110], [67, 111], [67, 115], [67, 117], [67, 125], [67, 126], [67, 132], [67, 133], [67, 136], [67, 138], [68, 71], [68, 75], [68, 76], [68, 89], [68, 92], [68, 93], [68, 94], [68, 95], [68, 97], [68, 102], [68, 103], [68, 106], [68, 115], [68, 117], [68, 118], [68, 123], [68, 130], [68, 132], [68, 137], [68, 139], [69, 72], [69, 74], [69, 75], [69, 77], [69, 79], [69, 80], [69, 85], [69, 86], [69, 88], [69, 91], [69, 92], [69, 93], [69, 96], [69, 99], [69, 106], [69, 107], [69, 108], [69, 110], [69, 111], [69, 119], [69, 121], [69, 122], [69, 136], [69, 139], [70, 72], [70, 73], [70, 74], [70, 76], [70, 77], [70, 81], [70, 84], [70, 86], [70, 89], [70, 94], [70, 99], [70, 107], [70, 109], [70, 110], [70, 112], [70, 120], [70, 127], [70, 129], [70, 132], [70, 134], [70, 138], [71, 74], [71, 75], [71, 78], [71, 80], [71, 81], [71, 83], [71, 88], [71, 89], [71, 90], [71, 93], [71, 98], [71, 99], [71, 100], [71, 104], [71, 106], [71, 108], [71, 109], [71, 110], [71, 116], [71, 119], [71, 121], [71, 123], [71, 124], [71, 128], [71, 131], [71, 133], [71, 134], [71, 135], [71, 137], [72, 82], [72, 84], [72, 88], [72, 89], [72, 92], [72, 95], [72, 99], [72, 100], [72, 102], [72, 104], [72, 107], [72, 111], [72, 117], [72, 118], [72, 121], [72, 123], [72, 124], [72, 129], [72, 132], [73, 75], [73, 79], [73, 82], [73, 86], [73, 107], [73, 112], [73, 115], [73, 116], [73, 117], [73, 118], [73, 120], [73, 121], [73, 123], [73, 124], [73, 128], [73, 130], [73, 133], [73, 134], [74, 78], [74, 83], [74, 84], [74, 85], [74, 90], [74, 94], [74, 96], [74, 101], [74, 104], [74, 105], [74, 108], [74, 109], [74, 119], [74, 122], [74, 124], [74, 125], [74, 128], [74, 134], [74, 136], [74, 137], [74, 138], [75, 77], [75, 78], [75, 81], [75, 82], [75, 93], [75, 94], [75, 95], [75, 96], [75, 106], [75, 117], [75, 121], [75, 126], [75, 127], [75, 135], [76, 83], [76, 84], [76, 85], [76, 89], [76, 91], [76, 97], [76, 98], [76, 101], [76, 109], [76, 110], [76, 111], [76, 115], [76, 117], [76, 119], [76, 120], [76, 124], [76, 130], [76, 131], [76, 137], [76, 138], [77, 81], [77, 82], [77, 84], [77, 85], [77, 92], [77, 98], [77, 100], [77, 104], [77, 105], [77, 107], [77, 108], [77, 110], [77, 114], [77, 116], [77, 117], [77, 118], [77, 126], [77, 127], [77, 132], [77, 135], [77, 136], [78, 81], [78, 83], [78, 89], [78, 93], [78, 94], [78, 97], [78, 102], [78, 104], [78, 112], [78, 115], [78, 116], [78, 122], [78, 124], [78, 128], [78, 130], [78, 136], [78, 137], [78, 138], [79, 86], [79, 94], [79, 95], [79, 104], [79, 106], [79, 107], [79, 113], [79, 114], [79, 116], [79, 126], [79, 128], [79, 136], [80, 83], [80, 84], [80, 87], [80, 90], [80, 93], [80, 95], [80, 100], [80, 106], [80, 107], [80, 110], [80, 111], [80, 112], [80, 118], [80, 120], [80, 121], [80, 125], [80, 130], [80, 134], [80, 135], [80, 136], [81, 90], [81, 93], [81, 95], [81, 100], [81, 101], [81, 103], [81, 104], [81, 115], [81, 116], [81, 120], [81, 123], [81, 127], [81, 128], [82, 90], [82, 94], [82, 95], [82, 97], [82, 99], [82, 102], [82, 107], [82, 108], [82, 111], [82, 112], [82, 115], [82, 124], [82, 132], [82, 133], [83, 84], [83, 88], [83, 90], [83, 91], [83, 100], [83, 102], [83, 106], [83, 107], [83, 108], [83, 114], [83, 123], [83, 125], [83, 127], [83, 129], [83, 131], [83, 138], [84, 89], [84, 91], [84, 92], [84, 99], [84, 101], [84, 107], [84, 113], [84, 120], [84, 123], [84, 124], [84, 126], [84, 127], [84, 128], [84, 133], [84, 137], [84, 138], [84, 139], [85, 96], [85, 97], [85, 101], [85, 104], [85, 105], [85, 109], [85, 115], [85, 116], [85, 118], [85, 119], [85, 126], [85, 132], [86, 89], [86, 91], [86, 93], [86, 99], [86, 100], [86, 107], [86, 108], [86, 112], [86, 114], [86, 122], [86, 124], [86, 125], [86, 127], [86, 132], [86, 137], [86, 138], [87, 88], [87, 89], [87, 90], [87, 91], [87, 93], [87, 94], [87, 98], [87, 102], [87, 105], [87, 109], [87, 113], [87, 114], [87, 117], [87, 119], [87, 122], [87, 124], [87, 125], [87, 126], [87, 131], [88, 91], [88, 93], [88, 94], [88, 95], [88, 96], [88, 97], [88, 103], [88, 112], [88, 114], [88, 119], [88, 121], [88, 122], [88, 123], [88, 126], [88, 136], [88, 138], [89, 92], [89, 93], [89, 96], [89, 101], [89, 110], [89, 114], [89, 115], [89, 117], [89, 118], [89, 121], [89, 125], [89, 129], [89, 133], [89, 134], [89, 139], [90, 92], [90, 96], [90, 102], [90, 103], [90, 104], [90, 105], [90, 108], [90, 113], [90, 116], [90, 117], [90, 124], [90, 127], [90, 128], [90, 131], [90, 133], [90, 134], [90, 136], [90, 138], [91, 92], [91, 94], [91, 95], [91, 96], [91, 98], [91, 99], [91, 102], [91, 103], [91, 104], [91, 107], [91, 110], [91, 113], [91, 114], [91, 117], [91, 118], [91, 120], [91, 123], [91, 128], [91, 135], [91, 139], [92, 97], [92, 99], [92, 102], [92, 107], [92, 110], [92, 115], [92, 116], [92, 118], [92, 121], [92, 122], [92, 126], [92, 131], [92, 134], [92, 136], [93, 95], [93, 97], [93, 99], [93, 104], [93, 107], [93, 111], [93, 113], [93, 115], [93, 118], [93, 121], [93, 122], [93, 127], [93, 128], [93, 129], [93, 133], [93, 136], [93, 137], [94, 105], [94, 106], [94, 109], [94, 110], [94, 111], [94, 120], [94, 122], [94, 128], [94, 131], [94, 132], [94, 133], [94, 134], [94, 137], [94, 139], [95, 102], [95, 104], [95, 106], [95, 108], [95, 117], [95, 118], [95, 122], [95, 127], [95, 131], [95, 134], [95, 135], [96, 100], [96, 101], [96, 102], [96, 104], [96, 105], [96, 106], [96, 110], [96, 123], [96, 124], [96, 126], [96, 134], [96, 139], [97, 98], [97, 101], [97, 103], [97, 105], [97, 106], [97, 107], [97, 109], [97, 116], [97, 118], [97, 119], [97, 121], [97, 124], [97, 139], [98, 108], [98, 109], [98, 111], [98, 112], [98, 115], [98, 121], [98, 124], [98, 129], [98, 130], [98, 139], [99, 107], [99, 108], [99, 111], [99, 112], [99, 113], [99, 114], [99, 115], [99, 118], [99, 119], [99, 120], [99, 122], [99, 126], [99, 129], [99, 133], [99, 135], [99, 136], [100, 101], [100, 102], [100, 105], [100, 106], [100, 107], [100, 110], [100, 116], [100, 120], [100, 129], [100, 133], [100, 134], [100, 135], [100, 136], [100, 139], [101, 102], [101, 111], [101, 114], [101, 117], [101, 118], [101, 119], [101, 124], [101, 131], [101, 133], [101, 134], [101, 138], [102, 105], [102, 112], [102, 115], [102, 121], [102, 122], [102, 126], [102, 127], [102, 134], [102, 136], [103, 104], [103, 107], [103, 111], [103, 116], [103, 118], [103, 119], [103, 125], [103, 131], [103, 135], [103, 137], [103, 139], [104, 110], [104, 111], [104, 116], [104, 117], [104, 118], [104, 127], [104, 128], [104, 129], [104, 133], [104, 134], [104, 135], [104, 138], [105, 107], [105, 111], [105, 114], [105, 119], [105, 120], [105, 121], [105, 124], [105, 125], [105, 126], [105, 127], [105, 128], [105, 130], [105, 137], [105, 139], [106, 109], [106, 110], [106, 116], [106, 118], [106, 119], [106, 121], [106, 122], [106, 125], [106, 127], [106, 132], [106, 138], [107, 109], [107, 111], [107, 115], [107, 118], [107, 126], [107, 127], [107, 128], [107, 129], [107, 131], [107, 135], [107, 138], [108, 112], [108, 119], [108, 120], [108, 121], [108, 125], [108, 130], [108, 134], [108, 138], [108, 139], [109, 116], [109, 117], [109, 118], [109, 130], [109, 136], [109, 138], [110, 111], [110, 118], [110, 122], [110, 123], [110, 127], [110, 134], [110, 135], [110, 137], [111, 121], [111, 122], [111, 133], [111, 134], [111, 136], [111, 138], [112, 115], [112, 116], [112, 117], [112, 118], [112, 119], [112, 122], [112, 125], [112, 126], [112, 134], [112, 136], [112, 139], [113, 114], [113, 115], [113, 117], [113, 122], [113, 128], [113, 129], [113, 138], [113, 139], [114, 115], [114, 116], [114, 117], [114, 122], [114, 125], [114, 130], [114, 137], [115, 129], [115, 131], [115, 132], [115, 139], [116, 118], [116, 125], [116, 126], [116, 131], [116, 134], [116, 138], [116, 139], [117, 121], [117, 135], [117, 139], [118, 120], [118, 136], [119, 120], [119, 121], [119, 124], [119, 127], [119, 135], [120, 124], [120, 132], [121, 126], [121, 127], [121, 128], [121, 137], [121, 139], [122, 125], [122, 127], [122, 130], [122, 133], [122, 135], [122, 139], [123, 125], [123, 127], [123, 129], [123, 132], [123, 137], [124, 125], [124, 126], [124, 135], [124, 137], [124, 139], [125, 126], [125, 133], [125, 137], [126, 127], [126, 128], [126, 130], [126, 136], [127, 130], [127, 135], [127, 137], [127, 138], [127, 139], [128, 129], [128, 135], [128, 138], [129, 132], [129, 134], [129, 135], [129, 139], [130, 136], [130, 138], [131, 134], [131, 135], [132, 133], [132, 135], [132, 138], [133, 136], [133, 139], [134, 137], [134, 139], [135, 136]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l6-s1/solution/solve.sh b/tasks/construct-mc-max-independent-set-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9064de67e1e7f6082cac09e89ba873be470d2eac --- /dev/null +++ b/tasks/construct-mc-max-independent-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' +{"independent_set": [1, 2, 4, 8, 27, 41, 60, 61, 72, 73, 93, 109, 110, 114, 119, 126, 131, 139]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l6-s1/tests/check.py b/tasks/construct-mc-max-independent-set-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l6-s1/tests/check.py @@ -0,0 +1,18 @@ +"""Independent set of size >= k in a given graph (MathConstraint max_independent_set, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"set has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) in E: + raise Invalid(f"vertices {u} and {v} are adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-independent-set-l6-s1/tests/instance.json b/tasks/construct-mc-max-independent-set-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5421e4270e50b60b830d32d677bd083c43048595 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 140, "k": 18, "edges": [[0, 12], [0, 13], [0, 18], [0, 19], [0, 20], [0, 25], [0, 26], [0, 27], [0, 31], [0, 34], [0, 35], [0, 37], [0, 38], [0, 49], [0, 53], [0, 54], [0, 56], [0, 59], [0, 60], [0, 63], [0, 68], [0, 71], [0, 73], [0, 75], [0, 78], [0, 80], [0, 81], [0, 84], [0, 85], [0, 87], [0, 88], [0, 93], [0, 95], [0, 98], [0, 99], [0, 101], [0, 104], [0, 108], [0, 112], [0, 113], [0, 123], [0, 126], [0, 127], [0, 133], [1, 5], [1, 7], [1, 9], [1, 16], [1, 20], [1, 21], [1, 24], [1, 25], [1, 31], [1, 32], [1, 33], [1, 34], [1, 37], [1, 38], [1, 40], [1, 42], [1, 43], [1, 45], [1, 47], [1, 49], [1, 50], [1, 51], [1, 52], [1, 55], [1, 59], [1, 64], [1, 80], [1, 82], [1, 87], [1, 88], [1, 92], [1, 102], [1, 104], [1, 113], [1, 117], [1, 118], [1, 122], [1, 123], [1, 128], [1, 135], [2, 5], [2, 6], [2, 9], [2, 12], [2, 15], [2, 19], [2, 20], [2, 22], [2, 25], [2, 29], [2, 30], [2, 38], [2, 40], [2, 49], [2, 56], [2, 70], [2, 76], [2, 77], [2, 79], [2, 80], [2, 89], [2, 90], [2, 92], [2, 94], [2, 95], [2, 98], [2, 105], [2, 107], [2, 112], [2, 113], [2, 128], [2, 130], [2, 137], [2, 138], [3, 4], [3, 12], [3, 13], [3, 16], [3, 17], [3, 20], [3, 23], [3, 27], [3, 32], [3, 34], [3, 36], [3, 37], [3, 49], [3, 51], [3, 57], [3, 58], [3, 61], [3, 63], [3, 64], [3, 69], [3, 72], [3, 77], [3, 84], [3, 88], [3, 90], [3, 97], [3, 116], [3, 120], [3, 124], [3, 129], [3, 130], [3, 131], [3, 136], [3, 137], [3, 139], [4, 5], [4, 7], [4, 14], [4, 16], [4, 19], [4, 21], [4, 23], [4, 29], [4, 32], [4, 33], [4, 36], [4, 38], [4, 45], [4, 51], [4, 57], [4, 58], [4, 59], [4, 62], [4, 63], [4, 66], [4, 68], [4, 71], [4, 74], [4, 78], [4, 83], [4, 84], [4, 89], [4, 102], [4, 103], [4, 105], [4, 107], [4, 111], [4, 113], [4, 116], [4, 117], [4, 132], [4, 135], [4, 136], [5, 11], [5, 13], [5, 15], [5, 18], [5, 19], [5, 26], [5, 28], [5, 30], [5, 36], [5, 41], [5, 43], [5, 44], [5, 45], [5, 51], [5, 52], [5, 54], [5, 58], [5, 60], [5, 62], [5, 68], [5, 69], [5, 71], [5, 82], [5, 84], [5, 85], [5, 86], [5, 91], [5, 99], [5, 102], [5, 107], [5, 108], [5, 112], [5, 121], [5, 127], [5, 129], [5, 130], [5, 133], [5, 134], [5, 135], [5, 138], [5, 139], [6, 7], [6, 10], [6, 11], [6, 12], [6, 15], [6, 17], [6, 18], [6, 21], [6, 22], [6, 36], [6, 38], [6, 39], [6, 44], [6, 48], [6, 49], [6, 50], [6, 52], [6, 54], [6, 55], [6, 57], [6, 60], [6, 66], [6, 67], [6, 70], [6, 73], [6, 76], [6, 79], [6, 80], [6, 84], [6, 90], [6, 91], [6, 96], [6, 103], [6, 107], [6, 108], [6, 111], [6, 114], [6, 115], [6, 117], [6, 119], [6, 121], [6, 122], [6, 129], [6, 130], [6, 137], [6, 138], [6, 139], [7, 13], [7, 17], [7, 18], [7, 19], [7, 35], [7, 36], [7, 38], [7, 40], [7, 44], [7, 51], [7, 52], [7, 56], [7, 59], [7, 61], [7, 62], [7, 72], [7, 75], [7, 76], [7, 79], [7, 80], [7, 83], [7, 87], [7, 88], [7, 93], [7, 95], [7, 97], [7, 98], [7, 103], [7, 104], [7, 118], [7, 120], [7, 123], [7, 128], [7, 134], [8, 12], [8, 13], [8, 15], [8, 19], [8, 21], [8, 25], [8, 28], [8, 29], [8, 30], [8, 34], [8, 36], [8, 47], [8, 52], [8, 56], [8, 59], [8, 62], [8, 63], [8, 75], [8, 83], [8, 86], [8, 87], [8, 88], [8, 90], [8, 91], [8, 98], [8, 100], [8, 101], [8, 122], [8, 123], [8, 128], [8, 129], [8, 135], [9, 15], [9, 22], [9, 23], [9, 29], [9, 30], [9, 32], [9, 36], [9, 38], [9, 40], [9, 46], [9, 50], [9, 51], [9, 53], [9, 61], [9, 63], [9, 65], [9, 66], [9, 69], [9, 73], [9, 76], [9, 80], [9, 82], [9, 84], [9, 86], [9, 88], [9, 89], [9, 90], [9, 91], [9, 92], [9, 93], [9, 94], [9, 102], [9, 103], [9, 109], [9, 115], [9, 119], [9, 123], [9, 125], [9, 127], [9, 131], [9, 136], [9, 138], [9, 139], [10, 18], [10, 20], [10, 23], [10, 27], [10, 33], [10, 36], [10, 40], [10, 41], [10, 42], [10, 43], [10, 44], [10, 48], [10, 50], [10, 56], [10, 57], [10, 58], [10, 66], [10, 68], [10, 70], [10, 76], [10, 81], [10, 84], [10, 85], [10, 86], [10, 95], [10, 96], [10, 99], [10, 101], [10, 102], [10, 103], [10, 104], [10, 106], [10, 108], [10, 112], [10, 119], [10, 121], [10, 122], [10, 126], [10, 127], [10, 132], [10, 135], [10, 138], [10, 139], [11, 12], [11, 13], [11, 14], [11, 17], [11, 24], [11, 25], [11, 30], [11, 35], [11, 46], [11, 47], [11, 49], [11, 53], [11, 54], [11, 55], [11, 57], [11, 59], [11, 60], [11, 62], [11, 65], [11, 66], [11, 69], [11, 71], [11, 74], [11, 88], [11, 93], [11, 94], [11, 96], [11, 97], [11, 100], [11, 102], [11, 103], [11, 104], [11, 109], [11, 111], [11, 114], [11, 116], [11, 117], [11, 118], [11, 122], [11, 125], [11, 126], [11, 129], [11, 131], [11, 134], [11, 135], [11, 138], [12, 14], [12, 16], [12, 19], [12, 25], [12, 26], [12, 32], [12, 38], [12, 42], [12, 48], [12, 49], [12, 50], [12, 51], [12, 53], [12, 55], [12, 57], [12, 58], [12, 59], [12, 64], [12, 65], [12, 70], [12, 78], [12, 81], [12, 83], [12, 86], [12, 87], [12, 90], [12, 91], [12, 94], [12, 104], [12, 105], [12, 106], [12, 107], [12, 108], [12, 112], [12, 113], [12, 118], [12, 120], [12, 122], [12, 128], [12, 129], [12, 130], [12, 134], [12, 139], [13, 18], [13, 19], [13, 23], [13, 33], [13, 34], [13, 37], [13, 42], [13, 46], [13, 49], [13, 53], [13, 56], [13, 64], [13, 65], [13, 66], [13, 68], [13, 69], [13, 70], [13, 73], [13, 82], [13, 83], [13, 86], [13, 87], [13, 91], [13, 94], [13, 106], [13, 108], [13, 109], [13, 113], [13, 114], [13, 117], [13, 120], [13, 123], [13, 127], [13, 138], [14, 15], [14, 20], [14, 23], [14, 25], [14, 28], [14, 35], [14, 39], [14, 44], [14, 50], [14, 53], [14, 56], [14, 57], [14, 60], [14, 62], [14, 69], [14, 70], [14, 71], [14, 74], [14, 76], [14, 77], [14, 79], [14, 81], [14, 83], [14, 88], [14, 89], [14, 90], [14, 92], [14, 93], [14, 101], [14, 102], [14, 113], [14, 117], [14, 121], [14, 122], [14, 124], [14, 125], [14, 129], [14, 132], [14, 133], [15, 17], [15, 18], [15, 19], [15, 20], [15, 23], [15, 25], [15, 34], [15, 36], [15, 42], [15, 43], [15, 44], [15, 50], [15, 52], [15, 54], [15, 55], [15, 56], [15, 60], [15, 69], [15, 74], [15, 77], [15, 84], [15, 86], [15, 87], [15, 88], [15, 90], [15, 93], [15, 95], [15, 97], [15, 98], [15, 100], [15, 102], [15, 111], [15, 113], [15, 114], [15, 118], [15, 120], [15, 121], [15, 122], [15, 123], [15, 126], [15, 129], [15, 132], [15, 135], [16, 22], [16, 27], [16, 29], [16, 32], [16, 40], [16, 52], [16, 55], [16, 57], [16, 68], [16, 71], [16, 72], [16, 75], [16, 77], [16, 82], [16, 84], [16, 86], [16, 88], [16, 89], [16, 95], [16, 102], [16, 110], [16, 111], [16, 113], [16, 117], [16, 121], [16, 122], [16, 124], [16, 126], [16, 128], [16, 132], [16, 136], [17, 19], [17, 23], [17, 27], [17, 32], [17, 33], [17, 34], [17, 37], [17, 45], [17, 48], [17, 50], [17, 51], [17, 54], [17, 55], [17, 64], [17, 67], [17, 68], [17, 71], [17, 74], [17, 75], [17, 77], [17, 78], [17, 81], [17, 86], [17, 88], [17, 89], [17, 94], [17, 99], [17, 100], [17, 101], [17, 104], [17, 108], [17, 113], [17, 114], [17, 115], [17, 116], [17, 119], [17, 124], [17, 139], [18, 21], [18, 23], [18, 25], [18, 28], [18, 29], [18, 31], [18, 33], [18, 38], [18, 42], [18, 43], [18, 45], [18, 47], [18, 50], [18, 53], [18, 57], [18, 59], [18, 60], [18, 61], [18, 63], [18, 69], [18, 79], [18, 85], [18, 87], [18, 88], [18, 89], [18, 92], [18, 94], [18, 96], [18, 105], [18, 109], [18, 110], [18, 115], [18, 117], [18, 119], [18, 120], [18, 121], [18, 131], [18, 133], [18, 134], [18, 138], [18, 139], [19, 22], [19, 23], [19, 24], [19, 26], [19, 27], [19, 28], [19, 30], [19, 32], [19, 33], [19, 35], [19, 36], [19, 37], [19, 39], [19, 47], [19, 51], [19, 54], [19, 62], [19, 69], [19, 71], [19, 73], [19, 85], [19, 86], [19, 89], [19, 90], [19, 98], [19, 105], [19, 110], [19, 111], [19, 112], [19, 116], [19, 126], [19, 131], [19, 133], [20, 21], [20, 24], [20, 25], [20, 26], [20, 28], [20, 29], [20, 31], [20, 34], [20, 36], [20, 38], [20, 39], [20, 41], [20, 44], [20, 51], [20, 58], [20, 59], [20, 60], [20, 62], [20, 72], [20, 73], [20, 79], [20, 80], [20, 82], [20, 83], [20, 84], [20, 86], [20, 89], [20, 90], [20, 95], [20, 101], [20, 113], [20, 116], [20, 117], [20, 121], [20, 126], [20, 127], [20, 132], [21, 24], [21, 26], [21, 27], [21, 34], [21, 52], [21, 55], [21, 59], [21, 65], [21, 72], [21, 74], [21, 76], [21, 81], [21, 84], [21, 94], [21, 103], [21, 105], [21, 109], [21, 111], [21, 112], [21, 113], [21, 114], [21, 129], [21, 131], [21, 134], [21, 137], [21, 139], [22, 32], [22, 36], [22, 54], [22, 56], [22, 58], [22, 59], [22, 63], [22, 64], [22, 68], [22, 71], [22, 76], [22, 78], [22, 83], [22, 85], [22, 92], [22, 94], [22, 96], [22, 99], [22, 101], [22, 107], [22, 108], [22, 110], [22, 117], [22, 118], [22, 132], [22, 133], [22, 134], [22, 137], [23, 24], [23, 29], [23, 43], [23, 47], [23, 49], [23, 50], [23, 56], [23, 59], [23, 63], [23, 64], [23, 70], [23, 78], [23, 80], [23, 84], [23, 87], [23, 88], [23, 93], [23, 94], [23, 98], [23, 101], [23, 107], [23, 110], [23, 112], [23, 116], [23, 120], [23, 121], [23, 122], [23, 130], [23, 132], [23, 136], [24, 28], [24, 32], [24, 33], [24, 37], [24, 40], [24, 44], [24, 46], [24, 47], [24, 48], [24, 52], [24, 54], [24, 55], [24, 66], [24, 68], [24, 76], [24, 77], [24, 78], [24, 79], [24, 80], [24, 91], [24, 97], [24, 100], [24, 103], [24, 113], [24, 116], [24, 120], [24, 122], [24, 123], [24, 126], [24, 135], [25, 29], [25, 31], [25, 34], [25, 41], [25, 46], [25, 48], [25, 49], [25, 50], [25, 51], [25, 52], [25, 54], [25, 62], [25, 70], [25, 73], [25, 75], [25, 78], [25, 81], [25, 82], [25, 83], [25, 85], [25, 88], [25, 89], [25, 93], [25, 96], [25, 98], [25, 103], [25, 109], [25, 111], [25, 112], [25, 113], [25, 125], [25, 128], [26, 34], [26, 35], [26, 36], [26, 38], [26, 44], [26, 50], [26, 51], [26, 58], [26, 60], [26, 62], [26, 64], [26, 65], [26, 66], [26, 67], [26, 79], [26, 88], [26, 93], [26, 98], [26, 105], [26, 109], [26, 110], [26, 115], [26, 117], [26, 118], [26, 122], [26, 123], [26, 126], [26, 128], [26, 129], [26, 131], [26, 132], [26, 133], [26, 137], [26, 138], [27, 29], [27, 31], [27, 32], [27, 33], [27, 34], [27, 38], [27, 39], [27, 44], [27, 47], [27, 49], [27, 51], [27, 53], [27, 55], [27, 62], [27, 65], [27, 67], [27, 69], [27, 75], [27, 77], [27, 78], [27, 79], [27, 80], [27, 84], [27, 88], [27, 96], [27, 99], [27, 100], [27, 103], [27, 105], [27, 107], [27, 115], [27, 120], [27, 123], [27, 124], [27, 128], [27, 134], [27, 136], [27, 137], [28, 29], [28, 34], [28, 37], [28, 38], [28, 42], [28, 46], [28, 47], [28, 49], [28, 53], [28, 57], [28, 60], [28, 61], [28, 62], [28, 64], [28, 65], [28, 66], [28, 71], [28, 74], [28, 76], [28, 82], [28, 83], [28, 90], [28, 91], [28, 93], [28, 100], [28, 101], [28, 102], [28, 105], [28, 111], [28, 113], [28, 115], [28, 118], [28, 119], [28, 121], [28, 128], [28, 136], [28, 137], [29, 32], [29, 38], [29, 43], [29, 44], [29, 47], [29, 48], [29, 51], [29, 52], [29, 53], [29, 54], [29, 55], [29, 56], [29, 59], [29, 61], [29, 62], [29, 64], [29, 66], [29, 68], [29, 69], [29, 70], [29, 71], [29, 74], [29, 79], [29, 80], [29, 81], [29, 84], [29, 90], [29, 91], [29, 92], [29, 93], [29, 95], [29, 101], [29, 103], [29, 105], [29, 106], [29, 111], [29, 113], [29, 114], [29, 115], [29, 120], [29, 125], [29, 130], [29, 133], [29, 135], [29, 139], [30, 34], [30, 35], [30, 36], [30, 38], [30, 39], [30, 43], [30, 47], [30, 51], [30, 53], [30, 58], [30, 60], [30, 61], [30, 62], [30, 63], [30, 70], [30, 73], [30, 90], [30, 95], [30, 99], [30, 100], [30, 101], [30, 104], [30, 110], [30, 113], [30, 121], [30, 127], [30, 129], [30, 131], [30, 134], [30, 138], [31, 32], [31, 35], [31, 36], [31, 40], [31, 41], [31, 59], [31, 61], [31, 62], [31, 63], [31, 64], [31, 66], [31, 68], [31, 71], [31, 73], [31, 76], [31, 82], [31, 85], [31, 87], [31, 88], [31, 89], [31, 104], [31, 106], [31, 112], [31, 113], [31, 114], [31, 122], [31, 126], [31, 127], [31, 128], [31, 129], [31, 130], [31, 133], [31, 135], [32, 35], [32, 37], [32, 45], [32, 46], [32, 50], [32, 54], [32, 55], [32, 57], [32, 58], [32, 59], [32, 60], [32, 64], [32, 65], [32, 69], [32, 70], [32, 73], [32, 76], [32, 78], [32, 84], [32, 89], [32, 98], [32, 100], [32, 102], [32, 106], [32, 107], [32, 108], [32, 110], [32, 111], [32, 113], [32, 115], [32, 116], [32, 118], [32, 121], [32, 122], [32, 127], [32, 128], [32, 136], [32, 137], [33, 36], [33, 37], [33, 40], [33, 41], [33, 42], [33, 44], [33, 49], [33, 50], [33, 56], [33, 63], [33, 65], [33, 67], [33, 72], [33, 77], [33, 79], [33, 80], [33, 81], [33, 88], [33, 92], [33, 95], [33, 99], [33, 103], [33, 104], [33, 105], [33, 106], [33, 116], [33, 117], [33, 119], [33, 121], [33, 124], [33, 125], [33, 126], [33, 128], [33, 131], [33, 133], [34, 35], [34, 40], [34, 41], [34, 42], [34, 44], [34, 52], [34, 60], [34, 61], [34, 62], [34, 63], [34, 65], [34, 67], [34, 71], [34, 92], [34, 93], [34, 102], [34, 105], [34, 107], [34, 108], [34, 115], [34, 131], [34, 133], [34, 136], [35, 37], [35, 43], [35, 44], [35, 45], [35, 47], [35, 49], [35, 53], [35, 58], [35, 59], [35, 62], [35, 63], [35, 66], [35, 71], [35, 74], [35, 79], [35, 81], [35, 83], [35, 89], [35, 91], [35, 94], [35, 97], [35, 98], [35, 102], [35, 103], [35, 105], [35, 107], [35, 108], [35, 110], [35, 112], [35, 114], [35, 118], [35, 119], [35, 131], [35, 133], [36, 37], [36, 38], [36, 40], [36, 42], [36, 43], [36, 46], [36, 48], [36, 51], [36, 54], [36, 55], [36, 59], [36, 63], [36, 65], [36, 67], [36, 68], [36, 69], [36, 74], [36, 75], [36, 76], [36, 80], [36, 93], [36, 94], [36, 97], [36, 100], [36, 102], [36, 113], [36, 116], [36, 118], [36, 123], [36, 126], [36, 127], [36, 128], [36, 130], [36, 134], [36, 136], [36, 137], [36, 138], [36, 139], [37, 38], [37, 39], [37, 40], [37, 42], [37, 44], [37, 47], [37, 49], [37, 53], [37, 54], [37, 63], [37, 68], [37, 70], [37, 75], [37, 81], [37, 86], [37, 91], [37, 92], [37, 93], [37, 94], [37, 99], [37, 101], [37, 104], [37, 109], [37, 112], [37, 117], [37, 120], [37, 124], [37, 128], [37, 134], [37, 136], [38, 40], [38, 42], [38, 51], [38, 54], [38, 57], [38, 58], [38, 59], [38, 60], [38, 61], [38, 62], [38, 65], [38, 67], [38, 68], [38, 72], [38, 74], [38, 77], [38, 79], [38, 80], [38, 82], [38, 84], [38, 89], [38, 90], [38, 91], [38, 92], [38, 98], [38, 104], [38, 106], [38, 107], [38, 110], [38, 113], [38, 122], [38, 125], [38, 128], [38, 133], [38, 137], [39, 42], [39, 43], [39, 47], [39, 49], [39, 50], [39, 51], [39, 52], [39, 55], [39, 56], [39, 63], [39, 65], [39, 66], [39, 70], [39, 72], [39, 74], [39, 76], [39, 79], [39, 85], [39, 87], [39, 92], [39, 97], [39, 103], [39, 106], [39, 110], [39, 113], [39, 114], [39, 116], [39, 119], [39, 124], [39, 129], [39, 130], [39, 132], [39, 133], [40, 41], [40, 43], [40, 46], [40, 47], [40, 49], [40, 55], [40, 58], [40, 61], [40, 62], [40, 67], [40, 72], [40, 78], [40, 81], [40, 82], [40, 84], [40, 92], [40, 99], [40, 102], [40, 105], [40, 110], [40, 112], [40, 115], [40, 117], [40, 120], [40, 126], [40, 127], [40, 128], [40, 129], [40, 130], [40, 131], [40, 135], [40, 138], [41, 43], [41, 46], [41, 50], [41, 51], [41, 53], [41, 55], [41, 56], [41, 57], [41, 58], [41, 65], [41, 76], [41, 78], [41, 79], [41, 80], [41, 86], [41, 89], [41, 95], [41, 96], [41, 103], [41, 105], [41, 108], [41, 115], [41, 116], [41, 120], [41, 122], [41, 125], [41, 130], [41, 132], [42, 43], [42, 55], [42, 57], [42, 66], [42, 69], [42, 73], [42, 75], [42, 76], [42, 85], [42, 87], [42, 92], [42, 93], [42, 96], [42, 101], [42, 102], [42, 108], [42, 110], [42, 113], [42, 114], [42, 116], [42, 119], [42, 121], [42, 125], [42, 126], [42, 133], [42, 137], [43, 55], [43, 56], [43, 59], [43, 62], [43, 63], [43, 66], [43, 73], [43, 74], [43, 77], [43, 78], [43, 84], [43, 86], [43, 87], [43, 89], [43, 91], [43, 93], [43, 95], [43, 97], [43, 98], [43, 100], [43, 101], [43, 102], [43, 105], [43, 107], [43, 109], [43, 112], [43, 118], [43, 125], [43, 129], [43, 130], [43, 131], [43, 132], [43, 137], [44, 48], [44, 50], [44, 53], [44, 54], [44, 56], [44, 65], [44, 66], [44, 70], [44, 71], [44, 72], [44, 75], [44, 84], [44, 85], [44, 91], [44, 93], [44, 103], [44, 104], [44, 108], [44, 110], [44, 111], [44, 119], [44, 123], [44, 124], [44, 127], [44, 131], [44, 135], [44, 137], [44, 138], [44, 139], [45, 47], [45, 48], [45, 54], [45, 55], [45, 56], [45, 62], [45, 63], [45, 66], [45, 68], [45, 70], [45, 71], [45, 79], [45, 84], [45, 90], [45, 93], [45, 102], [45, 104], [45, 105], [45, 108], [45, 119], [45, 123], [45, 124], [45, 125], [45, 128], [45, 129], [45, 130], [45, 131], [45, 132], [45, 133], [45, 139], [46, 47], [46, 49], [46, 53], [46, 55], [46, 57], [46, 58], [46, 66], [46, 67], [46, 71], [46, 73], [46, 74], [46, 76], [46, 77], [46, 91], [46, 93], [46, 95], [46, 98], [46, 99], [46, 104], [46, 107], [46, 109], [46, 111], [46, 114], [46, 119], [46, 122], [46, 126], [46, 131], [46, 132], [46, 136], [46, 139], [47, 55], [47, 61], [47, 67], [47, 68], [47, 69], [47, 72], [47, 74], [47, 75], [47, 77], [47, 81], [47, 82], [47, 88], [47, 89], [47, 94], [47, 95], [47, 97], [47, 103], [47, 104], [47, 105], [47, 106], [47, 108], [47, 109], [47, 112], [47, 123], [47, 127], [47, 129], [47, 130], [47, 138], [48, 49], [48, 50], [48, 52], [48, 56], [48, 58], [48, 68], [48, 76], [48, 79], [48, 80], [48, 85], [48, 93], [48, 95], [48, 103], [48, 108], [48, 110], [48, 114], [48, 117], [48, 119], [48, 124], [48, 125], [48, 132], [49, 54], [49, 58], [49, 60], [49, 65], [49, 69], [49, 70], [49, 75], [49, 80], [49, 81], [49, 84], [49, 92], [49, 93], [49, 95], [49, 97], [49, 101], [49, 103], [49, 104], [49, 107], [49, 109], [49, 110], [49, 112], [49, 122], [49, 123], [49, 127], [49, 128], [49, 131], [49, 134], [49, 136], [50, 51], [50, 52], [50, 54], [50, 55], [50, 57], [50, 59], [50, 65], [50, 72], [50, 77], [50, 81], [50, 88], [50, 89], [50, 90], [50, 91], [50, 92], [50, 95], [50, 96], [50, 99], [50, 100], [50, 102], [50, 103], [50, 105], [50, 110], [50, 111], [50, 113], [50, 114], [50, 119], [50, 122], [50, 123], [50, 124], [50, 126], [50, 127], [50, 132], [50, 133], [50, 139], [51, 54], [51, 57], [51, 58], [51, 60], [51, 61], [51, 66], [51, 70], [51, 71], [51, 72], [51, 73], [51, 74], [51, 81], [51, 83], [51, 85], [51, 86], [51, 97], [51, 101], [51, 102], [51, 103], [51, 105], [51, 109], [51, 110], [51, 113], [51, 121], [51, 122], [51, 123], [51, 124], [51, 133], [51, 136], [52, 53], [52, 65], [52, 67], [52, 72], [52, 73], [52, 81], [52, 84], [52, 86], [52, 88], [52, 89], [52, 91], [52, 95], [52, 100], [52, 112], [52, 113], [52, 115], [52, 116], [52, 122], [52, 127], [52, 130], [53, 56], [53, 60], [53, 63], [53, 66], [53, 70], [53, 72], [53, 73], [53, 83], [53, 87], [53, 88], [53, 89], [53, 94], [53, 96], [53, 97], [53, 125], [53, 126], [53, 129], [53, 133], [53, 136], [53, 137], [54, 59], [54, 61], [54, 64], [54, 74], [54, 77], [54, 79], [54, 80], [54, 81], [54, 96], [54, 98], [54, 101], [54, 102], [54, 103], [54, 105], [54, 106], [54, 107], [54, 109], [54, 115], [54, 117], [54, 119], [54, 123], [54, 126], [54, 127], [54, 128], [54, 130], [54, 131], [55, 56], [55, 61], [55, 63], [55, 64], [55, 65], [55, 68], [55, 73], [55, 78], [55, 79], [55, 81], [55, 83], [55, 89], [55, 90], [55, 91], [55, 103], [55, 105], [55, 107], [55, 110], [55, 114], [55, 118], [55, 123], [55, 124], [55, 128], [55, 139], [56, 60], [56, 68], [56, 70], [56, 71], [56, 72], [56, 73], [56, 82], [56, 86], [56, 87], [56, 88], [56, 91], [56, 92], [56, 96], [56, 99], [56, 105], [56, 106], [56, 107], [56, 115], [56, 117], [56, 118], [56, 124], [56, 127], [56, 129], [56, 132], [57, 62], [57, 63], [57, 64], [57, 66], [57, 71], [57, 72], [57, 75], [57, 81], [57, 87], [57, 89], [57, 90], [57, 96], [57, 103], [57, 107], [57, 110], [57, 113], [57, 115], [57, 118], [57, 121], [57, 123], [57, 125], [57, 129], [57, 130], [57, 136], [58, 60], [58, 67], [58, 70], [58, 71], [58, 74], [58, 84], [58, 87], [58, 88], [58, 92], [58, 93], [58, 94], [58, 97], [58, 100], [58, 103], [58, 106], [58, 107], [58, 108], [58, 109], [58, 115], [58, 122], [58, 125], [58, 127], [58, 128], [58, 130], [59, 67], [59, 68], [59, 69], [59, 70], [59, 71], [59, 73], [59, 74], [59, 75], [59, 77], [59, 78], [59, 80], [59, 88], [59, 89], [59, 93], [59, 94], [59, 96], [59, 104], [59, 105], [59, 107], [59, 110], [59, 113], [59, 116], [59, 120], [59, 124], [59, 128], [59, 130], [59, 133], [60, 64], [60, 76], [60, 77], [60, 80], [60, 81], [60, 87], [60, 90], [60, 100], [60, 102], [60, 105], [60, 106], [60, 107], [60, 108], [60, 111], [60, 113], [60, 134], [60, 136], [61, 62], [61, 65], [61, 71], [61, 76], [61, 86], [61, 92], [61, 94], [61, 95], [61, 96], [61, 105], [61, 108], [61, 111], [61, 121], [61, 123], [61, 128], [61, 133], [61, 138], [62, 63], [62, 68], [62, 69], [62, 70], [62, 79], [62, 84], [62, 85], [62, 87], [62, 92], [62, 94], [62, 95], [62, 98], [62, 101], [62, 103], [62, 104], [62, 106], [62, 109], [62, 110], [62, 119], [62, 120], [62, 124], [62, 126], [62, 129], [62, 130], [62, 136], [63, 64], [63, 66], [63, 70], [63, 72], [63, 75], [63, 89], [63, 93], [63, 102], [63, 106], [63, 112], [63, 114], [63, 118], [63, 119], [63, 121], [63, 122], [63, 123], [63, 130], [63, 132], [63, 133], [63, 137], [64, 67], [64, 72], [64, 73], [64, 78], [64, 82], [64, 92], [64, 93], [64, 94], [64, 98], [64, 100], [64, 101], [64, 104], [64, 105], [64, 107], [64, 109], [64, 117], [64, 118], [64, 124], [64, 125], [64, 128], [64, 131], [64, 136], [65, 70], [65, 72], [65, 75], [65, 77], [65, 78], [65, 80], [65, 82], [65, 83], [65, 86], [65, 90], [65, 94], [65, 96], [65, 102], [65, 105], [65, 111], [65, 112], [65, 113], [65, 115], [65, 117], [65, 118], [65, 120], [65, 131], [65, 134], [65, 137], [66, 74], [66, 79], [66, 85], [66, 87], [66, 88], [66, 99], [66, 100], [66, 110], [66, 112], [66, 117], [66, 120], [66, 124], [66, 131], [66, 133], [66, 137], [66, 138], [66, 139], [67, 72], [67, 74], [67, 77], [67, 79], [67, 81], [67, 82], [67, 86], [67, 88], [67, 89], [67, 92], [67, 94], [67, 96], [67, 98], [67, 100], [67, 101], [67, 103], [67, 106], [67, 110], [67, 111], [67, 115], [67, 117], [67, 125], [67, 126], [67, 132], [67, 133], [67, 136], [67, 138], [68, 71], [68, 75], [68, 76], [68, 89], [68, 92], [68, 93], [68, 94], [68, 95], [68, 97], [68, 102], [68, 103], [68, 106], [68, 115], [68, 117], [68, 118], [68, 123], [68, 130], [68, 132], [68, 137], [68, 139], [69, 72], [69, 74], [69, 75], [69, 77], [69, 79], [69, 80], [69, 85], [69, 86], [69, 88], [69, 91], [69, 92], [69, 93], [69, 96], [69, 99], [69, 106], [69, 107], [69, 108], [69, 110], [69, 111], [69, 119], [69, 121], [69, 122], [69, 136], [69, 139], [70, 72], [70, 73], [70, 74], [70, 76], [70, 77], [70, 81], [70, 84], [70, 86], [70, 89], [70, 94], [70, 99], [70, 107], [70, 109], [70, 110], [70, 112], [70, 120], [70, 127], [70, 129], [70, 132], [70, 134], [70, 138], [71, 74], [71, 75], [71, 78], [71, 80], [71, 81], [71, 83], [71, 88], [71, 89], [71, 90], [71, 93], [71, 98], [71, 99], [71, 100], [71, 104], [71, 106], [71, 108], [71, 109], [71, 110], [71, 116], [71, 119], [71, 121], [71, 123], [71, 124], [71, 128], [71, 131], [71, 133], [71, 134], [71, 135], [71, 137], [72, 82], [72, 84], [72, 88], [72, 89], [72, 92], [72, 95], [72, 99], [72, 100], [72, 102], [72, 104], [72, 107], [72, 111], [72, 117], [72, 118], [72, 121], [72, 123], [72, 124], [72, 129], [72, 132], [73, 75], [73, 79], [73, 82], [73, 86], [73, 107], [73, 112], [73, 115], [73, 116], [73, 117], [73, 118], [73, 120], [73, 121], [73, 123], [73, 124], [73, 128], [73, 130], [73, 133], [73, 134], [74, 78], [74, 83], [74, 84], [74, 85], [74, 90], [74, 94], [74, 96], [74, 101], [74, 104], [74, 105], [74, 108], [74, 109], [74, 119], [74, 122], [74, 124], [74, 125], [74, 128], [74, 134], [74, 136], [74, 137], [74, 138], [75, 77], [75, 78], [75, 81], [75, 82], [75, 93], [75, 94], [75, 95], [75, 96], [75, 106], [75, 117], [75, 121], [75, 126], [75, 127], [75, 135], [76, 83], [76, 84], [76, 85], [76, 89], [76, 91], [76, 97], [76, 98], [76, 101], [76, 109], [76, 110], [76, 111], [76, 115], [76, 117], [76, 119], [76, 120], [76, 124], [76, 130], [76, 131], [76, 137], [76, 138], [77, 81], [77, 82], [77, 84], [77, 85], [77, 92], [77, 98], [77, 100], [77, 104], [77, 105], [77, 107], [77, 108], [77, 110], [77, 114], [77, 116], [77, 117], [77, 118], [77, 126], [77, 127], [77, 132], [77, 135], [77, 136], [78, 81], [78, 83], [78, 89], [78, 93], [78, 94], [78, 97], [78, 102], [78, 104], [78, 112], [78, 115], [78, 116], [78, 122], [78, 124], [78, 128], [78, 130], [78, 136], [78, 137], [78, 138], [79, 86], [79, 94], [79, 95], [79, 104], [79, 106], [79, 107], [79, 113], [79, 114], [79, 116], [79, 126], [79, 128], [79, 136], [80, 83], [80, 84], [80, 87], [80, 90], [80, 93], [80, 95], [80, 100], [80, 106], [80, 107], [80, 110], [80, 111], [80, 112], [80, 118], [80, 120], [80, 121], [80, 125], [80, 130], [80, 134], [80, 135], [80, 136], [81, 90], [81, 93], [81, 95], [81, 100], [81, 101], [81, 103], [81, 104], [81, 115], [81, 116], [81, 120], [81, 123], [81, 127], [81, 128], [82, 90], [82, 94], [82, 95], [82, 97], [82, 99], [82, 102], [82, 107], [82, 108], [82, 111], [82, 112], [82, 115], [82, 124], [82, 132], [82, 133], [83, 84], [83, 88], [83, 90], [83, 91], [83, 100], [83, 102], [83, 106], [83, 107], [83, 108], [83, 114], [83, 123], [83, 125], [83, 127], [83, 129], [83, 131], [83, 138], [84, 89], [84, 91], [84, 92], [84, 99], [84, 101], [84, 107], [84, 113], [84, 120], [84, 123], [84, 124], [84, 126], [84, 127], [84, 128], [84, 133], [84, 137], [84, 138], [84, 139], [85, 96], [85, 97], [85, 101], [85, 104], [85, 105], [85, 109], [85, 115], [85, 116], [85, 118], [85, 119], [85, 126], [85, 132], [86, 89], [86, 91], [86, 93], [86, 99], [86, 100], [86, 107], [86, 108], [86, 112], [86, 114], [86, 122], [86, 124], [86, 125], [86, 127], [86, 132], [86, 137], [86, 138], [87, 88], [87, 89], [87, 90], [87, 91], [87, 93], [87, 94], [87, 98], [87, 102], [87, 105], [87, 109], [87, 113], [87, 114], [87, 117], [87, 119], [87, 122], [87, 124], [87, 125], [87, 126], [87, 131], [88, 91], [88, 93], [88, 94], [88, 95], [88, 96], [88, 97], [88, 103], [88, 112], [88, 114], [88, 119], [88, 121], [88, 122], [88, 123], [88, 126], [88, 136], [88, 138], [89, 92], [89, 93], [89, 96], [89, 101], [89, 110], [89, 114], [89, 115], [89, 117], [89, 118], [89, 121], [89, 125], [89, 129], [89, 133], [89, 134], [89, 139], [90, 92], [90, 96], [90, 102], [90, 103], [90, 104], [90, 105], [90, 108], [90, 113], [90, 116], [90, 117], [90, 124], [90, 127], [90, 128], [90, 131], [90, 133], [90, 134], [90, 136], [90, 138], [91, 92], [91, 94], [91, 95], [91, 96], [91, 98], [91, 99], [91, 102], [91, 103], [91, 104], [91, 107], [91, 110], [91, 113], [91, 114], [91, 117], [91, 118], [91, 120], [91, 123], [91, 128], [91, 135], [91, 139], [92, 97], [92, 99], [92, 102], [92, 107], [92, 110], [92, 115], [92, 116], [92, 118], [92, 121], [92, 122], [92, 126], [92, 131], [92, 134], [92, 136], [93, 95], [93, 97], [93, 99], [93, 104], [93, 107], [93, 111], [93, 113], [93, 115], [93, 118], [93, 121], [93, 122], [93, 127], [93, 128], [93, 129], [93, 133], [93, 136], [93, 137], [94, 105], [94, 106], [94, 109], [94, 110], [94, 111], [94, 120], [94, 122], [94, 128], [94, 131], [94, 132], [94, 133], [94, 134], [94, 137], [94, 139], [95, 102], [95, 104], [95, 106], [95, 108], [95, 117], [95, 118], [95, 122], [95, 127], [95, 131], [95, 134], [95, 135], [96, 100], [96, 101], [96, 102], [96, 104], [96, 105], [96, 106], [96, 110], [96, 123], [96, 124], [96, 126], [96, 134], [96, 139], [97, 98], [97, 101], [97, 103], [97, 105], [97, 106], [97, 107], [97, 109], [97, 116], [97, 118], [97, 119], [97, 121], [97, 124], [97, 139], [98, 108], [98, 109], [98, 111], [98, 112], [98, 115], [98, 121], [98, 124], [98, 129], [98, 130], [98, 139], [99, 107], [99, 108], [99, 111], [99, 112], [99, 113], [99, 114], [99, 115], [99, 118], [99, 119], [99, 120], [99, 122], [99, 126], [99, 129], [99, 133], [99, 135], [99, 136], [100, 101], [100, 102], [100, 105], [100, 106], [100, 107], [100, 110], [100, 116], [100, 120], [100, 129], [100, 133], [100, 134], [100, 135], [100, 136], [100, 139], [101, 102], [101, 111], [101, 114], [101, 117], [101, 118], [101, 119], [101, 124], [101, 131], [101, 133], [101, 134], [101, 138], [102, 105], [102, 112], [102, 115], [102, 121], [102, 122], [102, 126], [102, 127], [102, 134], [102, 136], [103, 104], [103, 107], [103, 111], [103, 116], [103, 118], [103, 119], [103, 125], [103, 131], [103, 135], [103, 137], [103, 139], [104, 110], [104, 111], [104, 116], [104, 117], [104, 118], [104, 127], [104, 128], [104, 129], [104, 133], [104, 134], [104, 135], [104, 138], [105, 107], [105, 111], [105, 114], [105, 119], [105, 120], [105, 121], [105, 124], [105, 125], [105, 126], [105, 127], [105, 128], [105, 130], [105, 137], [105, 139], [106, 109], [106, 110], [106, 116], [106, 118], [106, 119], [106, 121], [106, 122], [106, 125], [106, 127], [106, 132], [106, 138], [107, 109], [107, 111], [107, 115], [107, 118], [107, 126], [107, 127], [107, 128], [107, 129], [107, 131], [107, 135], [107, 138], [108, 112], [108, 119], [108, 120], [108, 121], [108, 125], [108, 130], [108, 134], [108, 138], [108, 139], [109, 116], [109, 117], [109, 118], [109, 130], [109, 136], [109, 138], [110, 111], [110, 118], [110, 122], [110, 123], [110, 127], [110, 134], [110, 135], [110, 137], [111, 121], [111, 122], [111, 133], [111, 134], [111, 136], [111, 138], [112, 115], [112, 116], [112, 117], [112, 118], [112, 119], [112, 122], [112, 125], [112, 126], [112, 134], [112, 136], [112, 139], [113, 114], [113, 115], [113, 117], [113, 122], [113, 128], [113, 129], [113, 138], [113, 139], [114, 115], [114, 116], [114, 117], [114, 122], [114, 125], [114, 130], [114, 137], [115, 129], [115, 131], [115, 132], [115, 139], [116, 118], [116, 125], [116, 126], [116, 131], [116, 134], [116, 138], [116, 139], [117, 121], [117, 135], [117, 139], [118, 120], [118, 136], [119, 120], [119, 121], [119, 124], [119, 127], [119, 135], [120, 124], [120, 132], [121, 126], [121, 127], [121, 128], [121, 137], [121, 139], [122, 125], [122, 127], [122, 130], [122, 133], [122, 135], [122, 139], [123, 125], [123, 127], [123, 129], [123, 132], [123, 137], [124, 125], [124, 126], [124, 135], [124, 137], [124, 139], [125, 126], [125, 133], [125, 137], [126, 127], [126, 128], [126, 130], [126, 136], [127, 130], [127, 135], [127, 137], [127, 138], [127, 139], [128, 129], [128, 135], [128, 138], [129, 132], [129, 134], [129, 135], [129, 139], [130, 136], [130, 138], [131, 134], [131, 135], [132, 133], [132, 135], [132, 138], [133, 136], [133, 139], [134, 137], [134, 139], [135, 136]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l6-s1/tests/run.py b/tasks/construct-mc-max-independent-set-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-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-mc-max-independent-set-l6-s1/tests/test.sh b/tasks/construct-mc-max-independent-set-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-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-mc-max-independent-set-l6-s6/environment/Dockerfile b/tasks/construct-mc-max-independent-set-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-max-independent-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-mc-max-independent-set-l6-s6/environment/instance.json b/tasks/construct-mc-max-independent-set-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c0a6f42cc4829773190d5f751b14ed50e1d27f2e --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 140, "k": 18, "edges": [[0, 1], [0, 3], [0, 8], [0, 13], [0, 14], [0, 19], [0, 20], [0, 23], [0, 25], [0, 34], [0, 36], [0, 42], [0, 49], [0, 51], [0, 52], [0, 54], [0, 57], [0, 62], [0, 65], [0, 69], [0, 70], [0, 71], [0, 73], [0, 78], [0, 80], [0, 82], [0, 83], [0, 85], [0, 86], [0, 94], [0, 98], [0, 102], [0, 110], [0, 114], [0, 116], [0, 124], [0, 127], [0, 129], [0, 130], [0, 134], [0, 136], [1, 12], [1, 15], [1, 25], [1, 39], [1, 41], [1, 51], [1, 55], [1, 61], [1, 69], [1, 71], [1, 73], [1, 74], [1, 77], [1, 78], [1, 85], [1, 87], [1, 93], [1, 100], [1, 102], [1, 103], [1, 113], [1, 116], [1, 119], [1, 122], [1, 125], [1, 127], [2, 4], [2, 5], [2, 6], [2, 7], [2, 11], [2, 13], [2, 15], [2, 16], [2, 17], [2, 22], [2, 23], [2, 30], [2, 34], [2, 36], [2, 40], [2, 43], [2, 44], [2, 52], [2, 53], [2, 56], [2, 58], [2, 66], [2, 70], [2, 75], [2, 76], [2, 77], [2, 80], [2, 83], [2, 84], [2, 93], [2, 105], [2, 106], [2, 112], [2, 113], [2, 115], [2, 119], [2, 133], [2, 135], [2, 137], [2, 138], [3, 8], [3, 11], [3, 12], [3, 13], [3, 17], [3, 26], [3, 28], [3, 29], [3, 33], [3, 36], [3, 37], [3, 40], [3, 47], [3, 56], [3, 60], [3, 61], [3, 77], [3, 78], [3, 83], [3, 84], [3, 87], [3, 88], [3, 89], [3, 95], [3, 97], [3, 102], [3, 106], [3, 114], [3, 125], [3, 133], [3, 137], [3, 139], [4, 6], [4, 13], [4, 16], [4, 19], [4, 25], [4, 26], [4, 28], [4, 33], [4, 35], [4, 39], [4, 40], [4, 41], [4, 42], [4, 44], [4, 48], [4, 49], [4, 52], [4, 68], [4, 71], [4, 78], [4, 81], [4, 91], [4, 94], [4, 95], [4, 97], [4, 100], [4, 101], [4, 103], [4, 104], [4, 107], [4, 108], [4, 115], [4, 117], [4, 122], [4, 123], [4, 124], [4, 125], [4, 129], [5, 9], [5, 15], [5, 17], [5, 20], [5, 22], [5, 27], [5, 30], [5, 32], [5, 39], [5, 43], [5, 45], [5, 46], [5, 50], [5, 54], [5, 56], [5, 57], [5, 61], [5, 65], [5, 75], [5, 78], [5, 79], [5, 80], [5, 82], [5, 83], [5, 84], [5, 95], [5, 96], [5, 97], [5, 99], [5, 102], [5, 104], [5, 108], [5, 111], [5, 116], [5, 117], [5, 120], [5, 123], [5, 130], [5, 131], [5, 132], [5, 135], [5, 137], [6, 7], [6, 10], [6, 12], [6, 21], [6, 33], [6, 37], [6, 42], [6, 47], [6, 50], [6, 52], [6, 53], [6, 54], [6, 57], [6, 59], [6, 60], [6, 63], [6, 64], [6, 71], [6, 77], [6, 78], [6, 80], [6, 81], [6, 82], [6, 84], [6, 85], [6, 86], [6, 87], [6, 96], [6, 98], [6, 102], [6, 104], [6, 108], [6, 109], [6, 110], [6, 112], [6, 114], [6, 118], [6, 127], [6, 129], [6, 131], [6, 132], [6, 135], [6, 137], [7, 21], [7, 23], [7, 28], [7, 30], [7, 32], [7, 34], [7, 35], [7, 42], [7, 43], [7, 54], [7, 59], [7, 62], [7, 70], [7, 72], [7, 73], [7, 74], [7, 78], [7, 79], [7, 87], [7, 99], [7, 100], [7, 104], [7, 105], [7, 107], [7, 108], [7, 113], [7, 116], [7, 123], [7, 124], [7, 125], [7, 128], [7, 129], [7, 134], [7, 135], [7, 138], [7, 139], [8, 14], [8, 16], [8, 21], [8, 24], [8, 25], [8, 29], [8, 31], [8, 33], [8, 34], [8, 36], [8, 37], [8, 40], [8, 48], [8, 54], [8, 58], [8, 65], [8, 66], [8, 69], [8, 70], [8, 73], [8, 78], [8, 79], [8, 80], [8, 81], [8, 82], [8, 84], [8, 87], [8, 90], [8, 97], [8, 105], [8, 106], [8, 115], [8, 117], [8, 118], [8, 122], [8, 126], [8, 127], [8, 128], [8, 129], [8, 131], [8, 137], [9, 11], [9, 13], [9, 15], [9, 19], [9, 20], [9, 21], [9, 23], [9, 25], [9, 31], [9, 39], [9, 40], [9, 41], [9, 47], [9, 55], [9, 58], [9, 62], [9, 64], [9, 67], [9, 70], [9, 77], [9, 80], [9, 82], [9, 91], [9, 92], [9, 95], [9, 98], [9, 99], [9, 100], [9, 103], [9, 106], [9, 108], [9, 114], [9, 118], [9, 123], [9, 124], [9, 137], [9, 139], [10, 14], [10, 16], [10, 17], [10, 18], [10, 21], [10, 24], [10, 25], [10, 30], [10, 32], [10, 35], [10, 36], [10, 38], [10, 39], [10, 43], [10, 48], [10, 49], [10, 50], [10, 55], [10, 56], [10, 58], [10, 70], [10, 73], [10, 75], [10, 81], [10, 84], [10, 88], [10, 97], [10, 104], [10, 105], [10, 106], [10, 113], [10, 119], [10, 121], [10, 124], [10, 125], [10, 128], [10, 130], [11, 12], [11, 13], [11, 17], [11, 24], [11, 31], [11, 43], [11, 49], [11, 50], [11, 54], [11, 60], [11, 65], [11, 68], [11, 70], [11, 71], [11, 72], [11, 75], [11, 76], [11, 77], [11, 78], [11, 87], [11, 89], [11, 91], [11, 92], [11, 96], [11, 102], [11, 104], [11, 106], [11, 113], [11, 114], [11, 117], [11, 121], [11, 123], [11, 124], [11, 125], [11, 128], [11, 129], [11, 132], [11, 135], [11, 138], [12, 17], [12, 21], [12, 24], [12, 25], [12, 28], [12, 40], [12, 42], [12, 45], [12, 48], [12, 49], [12, 56], [12, 58], [12, 60], [12, 64], [12, 67], [12, 71], [12, 77], [12, 78], [12, 84], [12, 88], [12, 90], [12, 94], [12, 98], [12, 99], [12, 100], [12, 104], [12, 107], [12, 109], [12, 113], [12, 114], [12, 116], [12, 118], [12, 120], [12, 125], [12, 128], [12, 129], [12, 130], [12, 133], [12, 136], [12, 137], [12, 139], [13, 16], [13, 23], [13, 25], [13, 30], [13, 33], [13, 39], [13, 59], [13, 62], [13, 63], [13, 65], [13, 69], [13, 72], [13, 85], [13, 98], [13, 101], [13, 106], [13, 107], [13, 112], [13, 113], [13, 119], [13, 121], [13, 125], [13, 127], [13, 129], [13, 130], [13, 135], [13, 138], [14, 17], [14, 20], [14, 26], [14, 27], [14, 28], [14, 31], [14, 35], [14, 38], [14, 42], [14, 43], [14, 49], [14, 54], [14, 55], [14, 57], [14, 65], [14, 66], [14, 67], [14, 68], [14, 71], [14, 76], [14, 77], [14, 81], [14, 86], [14, 88], [14, 92], [14, 95], [14, 99], [14, 102], [14, 103], [14, 106], [14, 110], [14, 113], [14, 124], [14, 131], [14, 132], [14, 134], [14, 136], [15, 16], [15, 23], [15, 24], [15, 25], [15, 30], [15, 31], [15, 37], [15, 38], [15, 41], [15, 42], [15, 44], [15, 47], [15, 56], [15, 57], [15, 59], [15, 62], [15, 63], [15, 64], [15, 68], [15, 79], [15, 82], [15, 85], [15, 86], [15, 91], [15, 93], [15, 94], [15, 106], [15, 110], [15, 113], [15, 114], [15, 122], [15, 125], [15, 127], [15, 128], [15, 129], [15, 131], [15, 135], [15, 136], [16, 22], [16, 28], [16, 37], [16, 41], [16, 43], [16, 47], [16, 54], [16, 58], [16, 60], [16, 63], [16, 64], [16, 65], [16, 69], [16, 77], [16, 79], [16, 80], [16, 88], [16, 94], [16, 99], [16, 102], [16, 106], [16, 109], [16, 110], [16, 117], [16, 121], [16, 124], [16, 128], [16, 130], [16, 138], [17, 18], [17, 27], [17, 29], [17, 33], [17, 39], [17, 40], [17, 41], [17, 47], [17, 49], [17, 52], [17, 54], [17, 56], [17, 58], [17, 60], [17, 63], [17, 64], [17, 65], [17, 67], [17, 68], [17, 73], [17, 75], [17, 78], [17, 79], [17, 80], [17, 85], [17, 88], [17, 89], [17, 94], [17, 98], [17, 104], [17, 105], [17, 106], [17, 107], [17, 115], [17, 116], [17, 118], [17, 119], [17, 123], [17, 127], [17, 131], [17, 134], [17, 135], [18, 20], [18, 24], [18, 26], [18, 29], [18, 31], [18, 32], [18, 41], [18, 42], [18, 48], [18, 49], [18, 54], [18, 57], [18, 60], [18, 62], [18, 70], [18, 72], [18, 83], [18, 84], [18, 85], [18, 88], [18, 97], [18, 99], [18, 101], [18, 102], [18, 103], [18, 104], [18, 106], [18, 108], [18, 109], [18, 114], [18, 115], [18, 117], [18, 126], [18, 135], [19, 23], [19, 24], [19, 32], [19, 36], [19, 39], [19, 41], [19, 42], [19, 44], [19, 49], [19, 50], [19, 51], [19, 53], [19, 55], [19, 56], [19, 59], [19, 60], [19, 62], [19, 63], [19, 64], [19, 66], [19, 67], [19, 69], [19, 73], [19, 88], [19, 95], [19, 96], [19, 101], [19, 102], [19, 103], [19, 105], [19, 108], [19, 109], [19, 112], [19, 128], [19, 130], [19, 135], [19, 138], [19, 139], [20, 21], [20, 25], [20, 37], [20, 38], [20, 42], [20, 46], [20, 49], [20, 57], [20, 62], [20, 68], [20, 70], [20, 72], [20, 77], [20, 81], [20, 84], [20, 85], [20, 89], [20, 90], [20, 92], [20, 94], [20, 95], [20, 96], [20, 98], [20, 99], [20, 102], [20, 104], [20, 105], [20, 106], [20, 107], [20, 109], [20, 110], [20, 114], [20, 115], [20, 117], [20, 119], [20, 120], [20, 121], [20, 122], [20, 124], [20, 128], [20, 130], [20, 131], [20, 132], [20, 137], [21, 25], [21, 28], [21, 29], [21, 35], [21, 39], [21, 48], [21, 52], [21, 56], [21, 58], [21, 62], [21, 66], [21, 67], [21, 68], [21, 76], [21, 88], [21, 90], [21, 93], [21, 100], [21, 101], [21, 103], [21, 106], [21, 108], [21, 110], [21, 111], [21, 113], [21, 117], [21, 121], [21, 128], [21, 130], [21, 133], [21, 135], [21, 137], [22, 28], [22, 31], [22, 35], [22, 40], [22, 43], [22, 52], [22, 55], [22, 58], [22, 59], [22, 68], [22, 71], [22, 73], [22, 74], [22, 78], [22, 85], [22, 88], [22, 90], [22, 93], [22, 105], [22, 117], [22, 119], [22, 122], [22, 123], [22, 125], [22, 130], [22, 133], [22, 137], [22, 138], [23, 24], [23, 26], [23, 29], [23, 32], [23, 34], [23, 46], [23, 47], [23, 49], [23, 50], [23, 52], [23, 53], [23, 54], [23, 61], [23, 67], [23, 69], [23, 75], [23, 76], [23, 82], [23, 84], [23, 96], [23, 99], [23, 105], [23, 107], [23, 108], [23, 113], [23, 116], [23, 117], [23, 118], [23, 119], [23, 120], [23, 121], [23, 122], [23, 126], [23, 128], [23, 131], [23, 134], [23, 136], [23, 137], [23, 139], [24, 30], [24, 40], [24, 44], [24, 46], [24, 47], [24, 52], [24, 53], [24, 54], [24, 58], [24, 61], [24, 62], [24, 67], [24, 71], [24, 77], [24, 79], [24, 81], [24, 82], [24, 83], [24, 85], [24, 89], [24, 93], [24, 101], [24, 104], [24, 105], [24, 109], [24, 112], [24, 113], [24, 115], [24, 116], [24, 121], [24, 126], [24, 129], [24, 130], [24, 132], [24, 135], [24, 138], [24, 139], [25, 26], [25, 27], [25, 29], [25, 30], [25, 38], [25, 45], [25, 46], [25, 49], [25, 50], [25, 55], [25, 61], [25, 62], [25, 70], [25, 75], [25, 79], [25, 88], [25, 93], [25, 100], [25, 101], [25, 105], [25, 109], [25, 110], [25, 111], [25, 128], [25, 129], [25, 134], [25, 135], [25, 138], [26, 32], [26, 34], [26, 42], [26, 45], [26, 49], [26, 58], [26, 59], [26, 60], [26, 62], [26, 63], [26, 64], [26, 73], [26, 74], [26, 78], [26, 79], [26, 80], [26, 84], [26, 89], [26, 96], [26, 97], [26, 102], [26, 103], [26, 104], [26, 108], [26, 110], [26, 111], [26, 112], [26, 115], [26, 116], [26, 119], [26, 120], [26, 126], [26, 127], [26, 128], [26, 130], [26, 138], [27, 33], [27, 34], [27, 39], [27, 47], [27, 52], [27, 55], [27, 56], [27, 60], [27, 61], [27, 63], [27, 67], [27, 68], [27, 71], [27, 72], [27, 74], [27, 78], [27, 84], [27, 85], [27, 86], [27, 89], [27, 100], [27, 105], [27, 106], [27, 110], [27, 116], [27, 117], [27, 120], [27, 121], [27, 126], [27, 127], [27, 129], [27, 131], [27, 132], [28, 29], [28, 31], [28, 33], [28, 37], [28, 40], [28, 48], [28, 52], [28, 53], [28, 54], [28, 57], [28, 60], [28, 62], [28, 70], [28, 71], [28, 76], [28, 80], [28, 86], [28, 88], [28, 90], [28, 95], [28, 97], [28, 107], [28, 109], [28, 113], [28, 116], [28, 117], [28, 123], [28, 124], [28, 128], [28, 130], [28, 134], [28, 139], [29, 32], [29, 35], [29, 38], [29, 39], [29, 48], [29, 50], [29, 51], [29, 58], [29, 59], [29, 60], [29, 66], [29, 69], [29, 71], [29, 73], [29, 79], [29, 85], [29, 86], [29, 92], [29, 98], [29, 100], [29, 103], [29, 106], [29, 108], [29, 110], [29, 114], [29, 117], [29, 121], [29, 124], [29, 125], [29, 130], [29, 135], [29, 136], [30, 33], [30, 37], [30, 39], [30, 41], [30, 42], [30, 49], [30, 50], [30, 55], [30, 63], [30, 64], [30, 65], [30, 74], [30, 79], [30, 80], [30, 81], [30, 85], [30, 90], [30, 91], [30, 98], [30, 100], [30, 101], [30, 102], [30, 103], [30, 108], [30, 110], [30, 113], [30, 114], [30, 115], [30, 122], [30, 129], [30, 131], [30, 133], [30, 136], [30, 137], [30, 139], [31, 34], [31, 35], [31, 37], [31, 41], [31, 42], [31, 44], [31, 46], [31, 51], [31, 59], [31, 61], [31, 66], [31, 67], [31, 69], [31, 73], [31, 77], [31, 80], [31, 88], [31, 92], [31, 95], [31, 98], [31, 100], [31, 101], [31, 106], [31, 110], [31, 112], [31, 113], [31, 114], [31, 116], [31, 118], [31, 122], [31, 124], [31, 129], [31, 131], [31, 138], [31, 139], [32, 34], [32, 36], [32, 40], [32, 41], [32, 43], [32, 56], [32, 57], [32, 58], [32, 59], [32, 65], [32, 66], [32, 73], [32, 74], [32, 75], [32, 79], [32, 81], [32, 82], [32, 85], [32, 89], [32, 92], [32, 93], [32, 94], [32, 95], [32, 97], [32, 100], [32, 102], [32, 103], [32, 104], [32, 105], [32, 113], [32, 120], [32, 121], [32, 124], [32, 129], [32, 131], [32, 134], [32, 135], [32, 136], [32, 138], [32, 139], [33, 37], [33, 45], [33, 48], [33, 50], [33, 56], [33, 57], [33, 58], [33, 59], [33, 63], [33, 65], [33, 69], [33, 71], [33, 75], [33, 76], [33, 79], [33, 80], [33, 82], [33, 88], [33, 90], [33, 91], [33, 93], [33, 96], [33, 100], [33, 102], [33, 106], [33, 111], [33, 115], [33, 117], [33, 120], [33, 124], [33, 125], [33, 128], [33, 129], [33, 131], [33, 135], [33, 137], [33, 138], [33, 139], [34, 49], [34, 50], [34, 52], [34, 56], [34, 58], [34, 61], [34, 64], [34, 65], [34, 67], [34, 69], [34, 72], [34, 73], [34, 76], [34, 88], [34, 89], [34, 91], [34, 95], [34, 96], [34, 104], [34, 105], [34, 107], [34, 108], [34, 112], [34, 113], [34, 114], [34, 116], [34, 117], [34, 120], [34, 121], [34, 122], [34, 125], [34, 129], [34, 131], [34, 132], [34, 133], [34, 136], [35, 37], [35, 40], [35, 43], [35, 51], [35, 53], [35, 57], [35, 61], [35, 66], [35, 67], [35, 70], [35, 72], [35, 76], [35, 79], [35, 81], [35, 84], [35, 85], [35, 90], [35, 93], [35, 98], [35, 101], [35, 102], [35, 103], [35, 107], [35, 109], [35, 113], [35, 115], [35, 126], [35, 127], [35, 129], [35, 132], [35, 133], [35, 136], [36, 40], [36, 42], [36, 43], [36, 51], [36, 52], [36, 54], [36, 55], [36, 61], [36, 68], [36, 71], [36, 72], [36, 74], [36, 77], [36, 79], [36, 84], [36, 85], [36, 92], [36, 93], [36, 94], [36, 96], [36, 98], [36, 100], [36, 101], [36, 102], [36, 114], [36, 123], [36, 126], [36, 127], [36, 128], [36, 129], [36, 130], [36, 133], [36, 134], [36, 136], [37, 38], [37, 52], [37, 55], [37, 57], [37, 60], [37, 63], [37, 72], [37, 75], [37, 76], [37, 77], [37, 84], [37, 91], [37, 93], [37, 95], [37, 98], [37, 100], [37, 103], [37, 104], [37, 109], [37, 112], [37, 114], [37, 122], [37, 132], [37, 133], [37, 134], [37, 135], [37, 137], [38, 53], [38, 56], [38, 60], [38, 62], [38, 63], [38, 68], [38, 76], [38, 77], [38, 86], [38, 89], [38, 95], [38, 96], [38, 97], [38, 98], [38, 101], [38, 102], [38, 104], [38, 109], [38, 110], [38, 112], [38, 113], [38, 114], [38, 116], [38, 117], [38, 127], [38, 128], [38, 134], [38, 135], [39, 40], [39, 43], [39, 45], [39, 46], [39, 48], [39, 52], [39, 55], [39, 58], [39, 62], [39, 66], [39, 67], [39, 70], [39, 76], [39, 81], [39, 87], [39, 88], [39, 95], [39, 96], [39, 99], [39, 109], [39, 114], [39, 116], [39, 123], [39, 124], [39, 126], [39, 128], [39, 130], [39, 132], [39, 137], [40, 44], [40, 46], [40, 53], [40, 55], [40, 58], [40, 69], [40, 79], [40, 80], [40, 92], [40, 95], [40, 98], [40, 105], [40, 109], [40, 111], [40, 112], [40, 113], [40, 114], [40, 117], [40, 119], [40, 120], [40, 121], [40, 125], [40, 127], [40, 133], [40, 136], [41, 42], [41, 43], [41, 48], [41, 55], [41, 57], [41, 58], [41, 63], [41, 65], [41, 66], [41, 69], [41, 71], [41, 72], [41, 74], [41, 75], [41, 79], [41, 80], [41, 83], [41, 84], [41, 87], [41, 90], [41, 98], [41, 105], [41, 106], [41, 109], [41, 111], [41, 118], [41, 129], [41, 130], [42, 52], [42, 53], [42, 59], [42, 63], [42, 64], [42, 69], [42, 73], [42, 75], [42, 77], [42, 81], [42, 82], [42, 90], [42, 92], [42, 95], [42, 97], [42, 104], [42, 113], [42, 114], [42, 118], [42, 119], [42, 126], [42, 129], [42, 130], [42, 134], [42, 137], [43, 44], [43, 46], [43, 48], [43, 50], [43, 53], [43, 55], [43, 57], [43, 60], [43, 63], [43, 64], [43, 65], [43, 70], [43, 73], [43, 80], [43, 82], [43, 86], [43, 87], [43, 90], [43, 99], [43, 101], [43, 106], [43, 107], [43, 115], [43, 118], [43, 122], [43, 130], [43, 135], [43, 137], [44, 55], [44, 56], [44, 58], [44, 63], [44, 65], [44, 66], [44, 67], [44, 68], [44, 84], [44, 86], [44, 90], [44, 96], [44, 97], [44, 103], [44, 104], [44, 109], [44, 110], [44, 119], [44, 121], [44, 130], [45, 49], [45, 53], [45, 55], [45, 61], [45, 63], [45, 64], [45, 65], [45, 72], [45, 74], [45, 76], [45, 77], [45, 80], [45, 84], [45, 86], [45, 90], [45, 99], [45, 103], [45, 104], [45, 112], [45, 117], [45, 121], [45, 122], [45, 123], [45, 131], [45, 133], [45, 135], [45, 137], [46, 50], [46, 53], [46, 54], [46, 57], [46, 58], [46, 63], [46, 68], [46, 74], [46, 76], [46, 81], [46, 82], [46, 84], [46, 86], [46, 92], [46, 96], [46, 97], [46, 102], [46, 105], [46, 112], [46, 114], [46, 118], [46, 125], [46, 133], [46, 134], [46, 135], [46, 137], [47, 53], [47, 56], [47, 58], [47, 60], [47, 61], [47, 81], [47, 85], [47, 88], [47, 89], [47, 91], [47, 96], [47, 99], [47, 100], [47, 102], [47, 104], [47, 108], [47, 109], [47, 111], [47, 112], [47, 115], [47, 116], [47, 125], [47, 127], [47, 133], [47, 134], [47, 138], [48, 56], [48, 58], [48, 59], [48, 77], [48, 79], [48, 85], [48, 87], [48, 88], [48, 96], [48, 97], [48, 113], [48, 116], [48, 122], [48, 126], [48, 129], [48, 138], [48, 139], [49, 50], [49, 53], [49, 55], [49, 57], [49, 64], [49, 65], [49, 67], [49, 70], [49, 72], [49, 75], [49, 83], [49, 84], [49, 87], [49, 88], [49, 93], [49, 94], [49, 97], [49, 102], [49, 117], [49, 118], [49, 120], [49, 124], [49, 125], [49, 126], [49, 131], [49, 135], [49, 136], [50, 52], [50, 55], [50, 57], [50, 58], [50, 59], [50, 64], [50, 68], [50, 75], [50, 76], [50, 81], [50, 86], [50, 87], [50, 88], [50, 92], [50, 93], [50, 94], [50, 102], [50, 103], [50, 106], [50, 118], [50, 119], [50, 121], [50, 129], [50, 130], [50, 131], [50, 135], [51, 69], [51, 74], [51, 77], [51, 83], [51, 90], [51, 91], [51, 93], [51, 95], [51, 98], [51, 99], [51, 103], [51, 106], [51, 113], [51, 117], [51, 121], [51, 125], [51, 127], [51, 128], [51, 130], [51, 131], [51, 132], [51, 137], [52, 54], [52, 55], [52, 56], [52, 59], [52, 70], [52, 79], [52, 89], [52, 91], [52, 95], [52, 96], [52, 97], [52, 101], [52, 103], [52, 104], [52, 120], [52, 121], [52, 127], [52, 130], [52, 132], [52, 133], [52, 136], [52, 138], [53, 54], [53, 55], [53, 56], [53, 57], [53, 59], [53, 60], [53, 61], [53, 62], [53, 64], [53, 65], [53, 66], [53, 71], [53, 73], [53, 76], [53, 78], [53, 80], [53, 83], [53, 86], [53, 92], [53, 96], [53, 99], [53, 101], [53, 107], [53, 108], [53, 110], [53, 121], [53, 124], [53, 126], [53, 129], [53, 132], [53, 133], [53, 134], [53, 135], [54, 66], [54, 67], [54, 73], [54, 74], [54, 82], [54, 85], [54, 86], [54, 87], [54, 89], [54, 90], [54, 91], [54, 94], [54, 98], [54, 99], [54, 100], [54, 109], [54, 112], [54, 113], [54, 115], [54, 118], [54, 119], [54, 122], [54, 126], [54, 127], [54, 132], [54, 137], [55, 56], [55, 57], [55, 58], [55, 60], [55, 67], [55, 71], [55, 74], [55, 77], [55, 79], [55, 80], [55, 82], [55, 94], [55, 96], [55, 105], [55, 106], [55, 108], [55, 117], [55, 121], [55, 124], [55, 125], [55, 128], [55, 129], [55, 130], [55, 131], [56, 57], [56, 58], [56, 61], [56, 66], [56, 71], [56, 75], [56, 85], [56, 87], [56, 93], [56, 96], [56, 97], [56, 99], [56, 103], [56, 106], [56, 108], [56, 109], [56, 113], [56, 114], [56, 115], [56, 117], [56, 118], [56, 119], [56, 120], [56, 122], [56, 125], [56, 128], [56, 130], [56, 131], [56, 132], [56, 133], [56, 139], [57, 60], [57, 61], [57, 66], [57, 67], [57, 69], [57, 72], [57, 74], [57, 80], [57, 84], [57, 87], [57, 88], [57, 94], [57, 95], [57, 98], [57, 99], [57, 104], [57, 105], [57, 106], [57, 109], [57, 111], [57, 113], [57, 114], [57, 116], [57, 118], [57, 122], [57, 123], [57, 128], [57, 130], [57, 135], [57, 136], [57, 137], [58, 60], [58, 66], [58, 67], [58, 68], [58, 71], [58, 73], [58, 74], [58, 78], [58, 79], [58, 80], [58, 83], [58, 87], [58, 88], [58, 99], [58, 109], [58, 110], [58, 122], [58, 124], [58, 132], [59, 73], [59, 76], [59, 78], [59, 79], [59, 80], [59, 91], [59, 95], [59, 96], [59, 98], [59, 100], [59, 101], [59, 103], [59, 104], [59, 107], [59, 111], [59, 114], [59, 118], [59, 123], [59, 129], [59, 131], [59, 134], [60, 69], [60, 73], [60, 76], [60, 81], [60, 82], [60, 91], [60, 94], [60, 96], [60, 97], [60, 100], [60, 103], [60, 122], [60, 126], [60, 128], [60, 134], [60, 136], [61, 64], [61, 66], [61, 69], [61, 73], [61, 75], [61, 81], [61, 82], [61, 83], [61, 84], [61, 90], [61, 92], [61, 96], [61, 97], [61, 102], [61, 104], [61, 105], [61, 114], [61, 124], [61, 127], [61, 128], [61, 129], [61, 130], [61, 134], [61, 135], [61, 139], [62, 63], [62, 67], [62, 71], [62, 74], [62, 76], [62, 79], [62, 84], [62, 89], [62, 91], [62, 92], [62, 96], [62, 97], [62, 100], [62, 106], [62, 110], [62, 113], [62, 117], [62, 118], [62, 124], [62, 125], [62, 131], [62, 133], [62, 138], [63, 64], [63, 65], [63, 72], [63, 75], [63, 77], [63, 80], [63, 83], [63, 88], [63, 89], [63, 92], [63, 97], [63, 98], [63, 104], [63, 106], [63, 107], [63, 110], [63, 115], [63, 116], [63, 117], [63, 122], [63, 123], [63, 128], [63, 135], [64, 65], [64, 74], [64, 75], [64, 77], [64, 79], [64, 80], [64, 81], [64, 83], [64, 88], [64, 91], [64, 93], [64, 96], [64, 98], [64, 99], [64, 100], [64, 106], [64, 107], [64, 108], [64, 109], [64, 112], [64, 113], [64, 115], [64, 118], [64, 120], [64, 121], [64, 131], [64, 133], [64, 136], [64, 138], [65, 69], [65, 71], [65, 78], [65, 83], [65, 84], [65, 87], [65, 90], [65, 93], [65, 98], [65, 99], [65, 100], [65, 103], [65, 106], [65, 112], [65, 116], [65, 118], [65, 127], [65, 128], [65, 132], [66, 70], [66, 71], [66, 77], [66, 78], [66, 81], [66, 85], [66, 88], [66, 90], [66, 98], [66, 99], [66, 102], [66, 108], [66, 109], [66, 116], [66, 117], [66, 126], [66, 127], [66, 130], [66, 132], [66, 135], [66, 136], [66, 137], [67, 69], [67, 76], [67, 84], [67, 85], [67, 90], [67, 93], [67, 98], [67, 110], [67, 115], [67, 121], [67, 129], [67, 131], [67, 135], [68, 71], [68, 73], [68, 74], [68, 75], [68, 76], [68, 79], [68, 82], [68, 83], [68, 84], [68, 85], [68, 87], [68, 88], [68, 90], [68, 97], [68, 100], [68, 108], [68, 114], [68, 116], [68, 117], [68, 119], [68, 120], [68, 121], [68, 125], [68, 126], [68, 129], [69, 70], [69, 71], [69, 73], [69, 74], [69, 78], [69, 79], [69, 81], [69, 82], [69, 84], [69, 85], [69, 86], [69, 90], [69, 93], [69, 98], [69, 99], [69, 106], [69, 115], [69, 125], [69, 127], [69, 132], [69, 133], [69, 134], [69, 136], [69, 138], [70, 76], [70, 87], [70, 93], [70, 94], [70, 95], [70, 97], [70, 98], [70, 101], [70, 108], [70, 113], [70, 120], [70, 124], [70, 125], [70, 128], [70, 129], [70, 130], [70, 133], [70, 135], [70, 136], [70, 137], [70, 139], [71, 74], [71, 76], [71, 83], [71, 86], [71, 87], [71, 90], [71, 96], [71, 97], [71, 105], [71, 113], [71, 115], [71, 116], [71, 121], [71, 126], [71, 130], [71, 137], [71, 138], [71, 139], [72, 80], [72, 85], [72, 86], [72, 95], [72, 96], [72, 98], [72, 102], [72, 103], [72, 109], [72, 113], [72, 114], [72, 119], [72, 122], [72, 124], [72, 125], [72, 126], [72, 127], [72, 128], [72, 129], [72, 134], [73, 74], [73, 87], [73, 92], [73, 99], [73, 100], [73, 103], [73, 104], [73, 106], [73, 107], [73, 108], [73, 111], [73, 113], [73, 115], [73, 117], [73, 121], [73, 129], [73, 131], [73, 134], [73, 137], [74, 77], [74, 81], [74, 89], [74, 98], [74, 100], [74, 103], [74, 104], [74, 111], [74, 117], [74, 120], [74, 123], [74, 130], [74, 133], [74, 135], [74, 137], [75, 79], [75, 80], [75, 85], [75, 90], [75, 94], [75, 95], [75, 107], [75, 111], [75, 114], [75, 116], [75, 120], [75, 123], [75, 124], [75, 126], [75, 128], [75, 132], [75, 134], [75, 136], [75, 138], [75, 139], [76, 78], [76, 83], [76, 84], [76, 85], [76, 87], [76, 88], [76, 92], [76, 93], [76, 94], [76, 97], [76, 100], [76, 102], [76, 106], [76, 107], [76, 108], [76, 111], [76, 114], [76, 115], [76, 116], [76, 117], [76, 122], [76, 126], [76, 133], [76, 135], [76, 139], [77, 78], [77, 80], [77, 81], [77, 84], [77, 87], [77, 88], [77, 89], [77, 92], [77, 94], [77, 98], [77, 99], [77, 103], [77, 105], [77, 107], [77, 111], [77, 114], [77, 115], [77, 116], [77, 117], [77, 126], [77, 129], [77, 131], [77, 132], [77, 134], [77, 138], [78, 84], [78, 86], [78, 88], [78, 98], [78, 99], [78, 101], [78, 102], [78, 105], [78, 110], [78, 114], [78, 115], [78, 116], [78, 117], [78, 118], [78, 121], [78, 122], [78, 124], [78, 127], [78, 129], [78, 132], [78, 135], [78, 138], [79, 80], [79, 84], [79, 92], [79, 93], [79, 96], [79, 100], [79, 108], [79, 111], [79, 112], [79, 113], [79, 118], [79, 119], [79, 123], [79, 126], [79, 127], [79, 128], [79, 129], [79, 130], [79, 133], [79, 135], [79, 137], [79, 139], [80, 82], [80, 89], [80, 90], [80, 91], [80, 92], [80, 93], [80, 94], [80, 102], [80, 105], [80, 109], [80, 114], [80, 115], [80, 118], [80, 119], [80, 121], [80, 122], [80, 123], [80, 126], [80, 128], [80, 130], [80, 134], [80, 136], [80, 139], [81, 89], [81, 91], [81, 92], [81, 93], [81, 95], [81, 106], [81, 110], [81, 112], [81, 114], [81, 119], [81, 120], [81, 121], [81, 127], [81, 128], [82, 91], [82, 103], [82, 105], [82, 106], [82, 107], [82, 109], [82, 114], [82, 123], [82, 125], [82, 126], [82, 134], [82, 138], [83, 86], [83, 87], [83, 93], [83, 94], [83, 99], [83, 101], [83, 103], [83, 112], [83, 116], [83, 117], [83, 119], [83, 130], [83, 132], [83, 136], [84, 86], [84, 87], [84, 88], [84, 89], [84, 90], [84, 91], [84, 92], [84, 95], [84, 96], [84, 107], [84, 109], [84, 115], [84, 116], [84, 119], [84, 120], [84, 124], [84, 129], [84, 132], [84, 135], [84, 138], [85, 87], [85, 95], [85, 98], [85, 103], [85, 104], [85, 106], [85, 110], [85, 112], [85, 113], [85, 114], [85, 117], [85, 123], [85, 124], [85, 130], [85, 135], [86, 97], [86, 101], [86, 103], [86, 104], [86, 105], [86, 107], [86, 109], [86, 110], [86, 114], [86, 115], [86, 118], [86, 121], [86, 123], [86, 133], [86, 139], [87, 88], [87, 91], [87, 93], [87, 94], [87, 95], [87, 98], [87, 100], [87, 101], [87, 110], [87, 111], [87, 112], [87, 113], [87, 117], [87, 121], [87, 122], [87, 123], [87, 125], [87, 128], [87, 134], [87, 139], [88, 92], [88, 94], [88, 95], [88, 100], [88, 109], [88, 111], [88, 114], [88, 116], [88, 119], [88, 122], [88, 124], [88, 125], [88, 128], [88, 130], [89, 90], [89, 99], [89, 102], [89, 103], [89, 106], [89, 109], [89, 110], [89, 113], [89, 114], [89, 117], [89, 119], [89, 120], [89, 125], [89, 126], [89, 127], [89, 132], [90, 92], [90, 95], [90, 96], [90, 97], [90, 100], [90, 101], [90, 102], [90, 106], [90, 111], [90, 112], [90, 115], [90, 116], [90, 117], [90, 124], [90, 125], [90, 126], [90, 127], [90, 130], [90, 133], [90, 134], [90, 135], [90, 138], [91, 94], [91, 95], [91, 114], [91, 115], [91, 118], [91, 124], [91, 125], [91, 127], [91, 128], [91, 135], [91, 137], [92, 94], [92, 104], [92, 110], [92, 114], [92, 121], [92, 122], [92, 129], [92, 134], [92, 135], [92, 139], [93, 95], [93, 101], [93, 102], [93, 121], [93, 122], [93, 129], [93, 133], [93, 137], [93, 139], [94, 97], [94, 99], [94, 101], [94, 104], [94, 107], [94, 113], [94, 116], [94, 117], [94, 126], [94, 128], [94, 132], [94, 135], [94, 139], [95, 101], [95, 102], [95, 104], [95, 106], [95, 109], [95, 111], [95, 115], [95, 116], [95, 118], [95, 121], [95, 124], [95, 127], [95, 130], [95, 132], [95, 136], [95, 137], [95, 138], [95, 139], [96, 97], [96, 110], [96, 114], [96, 117], [96, 120], [96, 125], [96, 127], [96, 129], [96, 133], [97, 98], [97, 101], [97, 104], [97, 105], [97, 109], [97, 110], [97, 114], [97, 115], [97, 120], [97, 121], [97, 123], [97, 128], [97, 129], [97, 132], [97, 137], [97, 138], [98, 117], [98, 118], [98, 119], [98, 123], [98, 127], [98, 131], [98, 139], [99, 101], [99, 105], [99, 107], [99, 111], [99, 114], [99, 126], [99, 129], [99, 130], [99, 136], [100, 102], [100, 112], [100, 124], [100, 126], [100, 130], [100, 134], [100, 138], [101, 103], [101, 105], [101, 106], [101, 115], [101, 116], [101, 117], [101, 119], [101, 125], [101, 126], [101, 127], [101, 129], [101, 130], [101, 133], [101, 136], [101, 139], [102, 109], [102, 110], [102, 113], [102, 122], [102, 124], [103, 106], [103, 107], [103, 108], [103, 109], [103, 112], [103, 126], [103, 128], [103, 129], [103, 135], [103, 136], [104, 106], [104, 115], [104, 117], [104, 129], [105, 116], [105, 120], [105, 127], [105, 128], [105, 130], [105, 131], [105, 135], [105, 139], [106, 110], [106, 111], [106, 116], [106, 135], [106, 137], [106, 138], [107, 114], [107, 117], [107, 118], [107, 122], [107, 125], [107, 128], [107, 134], [107, 135], [107, 138], [108, 109], [108, 112], [108, 113], [108, 116], [108, 121], [108, 127], [108, 128], [108, 133], [109, 110], [109, 115], [109, 118], [109, 120], [109, 122], [109, 125], [109, 127], [109, 128], [109, 130], [109, 136], [110, 112], [110, 116], [110, 121], [110, 123], [110, 128], [110, 129], [110, 137], [110, 139], [111, 116], [111, 117], [111, 121], [111, 122], [111, 123], [111, 126], [111, 127], [111, 129], [111, 130], [111, 131], [111, 133], [111, 138], [112, 115], [112, 116], [112, 117], [112, 119], [112, 121], [112, 123], [112, 129], [112, 131], [112, 132], [112, 136], [112, 138], [113, 115], [113, 116], [113, 118], [113, 124], [114, 118], [114, 121], [114, 127], [114, 128], [114, 129], [114, 135], [114, 136], [115, 122], [115, 124], [115, 125], [115, 131], [115, 132], [115, 133], [115, 134], [115, 135], [115, 136], [115, 138], [116, 118], [116, 121], [116, 122], [116, 128], [116, 129], [116, 130], [116, 132], [116, 133], [116, 135], [117, 124], [117, 131], [117, 132], [117, 133], [117, 135], [117, 137], [118, 123], [118, 124], [118, 125], [118, 128], [118, 129], [119, 122], [119, 124], [119, 130], [119, 134], [119, 136], [119, 137], [119, 139], [120, 121], [120, 125], [120, 129], [120, 130], [120, 137], [121, 122], [121, 129], [121, 132], [121, 133], [121, 134], [121, 136], [122, 124], [122, 128], [122, 129], [122, 132], [122, 133], [122, 137], [122, 138], [123, 131], [123, 132], [123, 135], [123, 136], [123, 137], [123, 138], [123, 139], [124, 126], [124, 129], [124, 135], [124, 138], [124, 139], [125, 131], [125, 135], [125, 136], [126, 129], [126, 134], [126, 138], [127, 133], [127, 134], [127, 135], [128, 131], [128, 132], [129, 138], [129, 139], [130, 132], [130, 136], [132, 134], [132, 135], [133, 138], [134, 136], [134, 139], [136, 137]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l6-s6/solution/solve.sh b/tasks/construct-mc-max-independent-set-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..88f57b6c6d171146d7c803c34b19439e13bbd12a --- /dev/null +++ b/tasks/construct-mc-max-independent-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' +{"independent_set": [3, 16, 42, 44, 45, 46, 48, 71, 91, 93, 98, 100, 107, 108, 111, 120, 132, 136]} +RLMATH_EOF diff --git a/tasks/construct-mc-max-independent-set-l6-s6/tests/check.py b/tasks/construct-mc-max-independent-set-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..adce413e8578d996549583b990e4ff559f38ed41 --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l6-s6/tests/check.py @@ -0,0 +1,18 @@ +"""Independent set of size >= k in a given graph (MathConstraint max_independent_set, CC-BY-4.0).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) < k: + raise Invalid(f"set has {len(S)} vertices, need at least {k}") + E = {(u, v) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(S), 2): + if (u, v) in E: + raise Invalid(f"vertices {u} and {v} are adjacent") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-max-independent-set-l6-s6/tests/instance.json b/tasks/construct-mc-max-independent-set-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c0a6f42cc4829773190d5f751b14ed50e1d27f2e --- /dev/null +++ b/tasks/construct-mc-max-independent-set-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 140, "k": 18, "edges": [[0, 1], [0, 3], [0, 8], [0, 13], [0, 14], [0, 19], [0, 20], [0, 23], [0, 25], [0, 34], [0, 36], [0, 42], [0, 49], [0, 51], [0, 52], [0, 54], [0, 57], [0, 62], [0, 65], [0, 69], [0, 70], [0, 71], [0, 73], [0, 78], [0, 80], [0, 82], [0, 83], [0, 85], [0, 86], [0, 94], [0, 98], [0, 102], [0, 110], [0, 114], [0, 116], [0, 124], [0, 127], [0, 129], [0, 130], [0, 134], [0, 136], [1, 12], [1, 15], [1, 25], [1, 39], [1, 41], [1, 51], [1, 55], [1, 61], [1, 69], [1, 71], [1, 73], [1, 74], [1, 77], [1, 78], [1, 85], [1, 87], [1, 93], [1, 100], [1, 102], [1, 103], [1, 113], [1, 116], [1, 119], [1, 122], [1, 125], [1, 127], [2, 4], [2, 5], [2, 6], [2, 7], [2, 11], [2, 13], [2, 15], [2, 16], [2, 17], [2, 22], [2, 23], [2, 30], [2, 34], [2, 36], [2, 40], [2, 43], [2, 44], [2, 52], [2, 53], [2, 56], [2, 58], [2, 66], [2, 70], [2, 75], [2, 76], [2, 77], [2, 80], [2, 83], [2, 84], [2, 93], [2, 105], [2, 106], [2, 112], [2, 113], [2, 115], [2, 119], [2, 133], [2, 135], [2, 137], [2, 138], [3, 8], [3, 11], [3, 12], [3, 13], [3, 17], [3, 26], [3, 28], [3, 29], [3, 33], [3, 36], [3, 37], [3, 40], [3, 47], [3, 56], [3, 60], [3, 61], [3, 77], [3, 78], [3, 83], [3, 84], [3, 87], [3, 88], [3, 89], [3, 95], [3, 97], [3, 102], [3, 106], [3, 114], [3, 125], [3, 133], [3, 137], [3, 139], [4, 6], [4, 13], [4, 16], [4, 19], [4, 25], [4, 26], [4, 28], [4, 33], [4, 35], [4, 39], [4, 40], [4, 41], [4, 42], [4, 44], [4, 48], [4, 49], [4, 52], [4, 68], [4, 71], [4, 78], [4, 81], [4, 91], [4, 94], [4, 95], [4, 97], [4, 100], [4, 101], [4, 103], [4, 104], [4, 107], [4, 108], [4, 115], [4, 117], [4, 122], [4, 123], [4, 124], [4, 125], [4, 129], [5, 9], [5, 15], [5, 17], [5, 20], [5, 22], [5, 27], [5, 30], [5, 32], [5, 39], [5, 43], [5, 45], [5, 46], [5, 50], [5, 54], [5, 56], [5, 57], [5, 61], [5, 65], [5, 75], [5, 78], [5, 79], [5, 80], [5, 82], [5, 83], [5, 84], [5, 95], [5, 96], [5, 97], [5, 99], [5, 102], [5, 104], [5, 108], [5, 111], [5, 116], [5, 117], [5, 120], [5, 123], [5, 130], [5, 131], [5, 132], [5, 135], [5, 137], [6, 7], [6, 10], [6, 12], [6, 21], [6, 33], [6, 37], [6, 42], [6, 47], [6, 50], [6, 52], [6, 53], [6, 54], [6, 57], [6, 59], [6, 60], [6, 63], [6, 64], [6, 71], [6, 77], [6, 78], [6, 80], [6, 81], [6, 82], [6, 84], [6, 85], [6, 86], [6, 87], [6, 96], [6, 98], [6, 102], [6, 104], [6, 108], [6, 109], [6, 110], [6, 112], [6, 114], [6, 118], [6, 127], [6, 129], [6, 131], [6, 132], [6, 135], [6, 137], [7, 21], [7, 23], [7, 28], [7, 30], [7, 32], [7, 34], [7, 35], [7, 42], [7, 43], [7, 54], [7, 59], [7, 62], [7, 70], [7, 72], [7, 73], [7, 74], [7, 78], [7, 79], [7, 87], [7, 99], [7, 100], [7, 104], [7, 105], [7, 107], [7, 108], [7, 113], [7, 116], [7, 123], [7, 124], [7, 125], [7, 128], [7, 129], [7, 134], [7, 135], [7, 138], [7, 139], [8, 14], [8, 16], [8, 21], [8, 24], [8, 25], [8, 29], [8, 31], [8, 33], [8, 34], [8, 36], [8, 37], [8, 40], [8, 48], [8, 54], [8, 58], [8, 65], [8, 66], [8, 69], [8, 70], [8, 73], [8, 78], [8, 79], [8, 80], [8, 81], [8, 82], [8, 84], [8, 87], [8, 90], [8, 97], [8, 105], [8, 106], [8, 115], [8, 117], [8, 118], [8, 122], [8, 126], [8, 127], [8, 128], [8, 129], [8, 131], [8, 137], [9, 11], [9, 13], [9, 15], [9, 19], [9, 20], [9, 21], [9, 23], [9, 25], [9, 31], [9, 39], [9, 40], [9, 41], [9, 47], [9, 55], [9, 58], [9, 62], [9, 64], [9, 67], [9, 70], [9, 77], [9, 80], [9, 82], [9, 91], [9, 92], [9, 95], [9, 98], [9, 99], [9, 100], [9, 103], [9, 106], [9, 108], [9, 114], [9, 118], [9, 123], [9, 124], [9, 137], [9, 139], [10, 14], [10, 16], [10, 17], [10, 18], [10, 21], [10, 24], [10, 25], [10, 30], [10, 32], [10, 35], [10, 36], [10, 38], [10, 39], [10, 43], [10, 48], [10, 49], [10, 50], [10, 55], [10, 56], [10, 58], [10, 70], [10, 73], [10, 75], [10, 81], [10, 84], [10, 88], [10, 97], [10, 104], [10, 105], [10, 106], [10, 113], [10, 119], [10, 121], [10, 124], [10, 125], [10, 128], [10, 130], [11, 12], [11, 13], [11, 17], [11, 24], [11, 31], [11, 43], [11, 49], [11, 50], [11, 54], [11, 60], [11, 65], [11, 68], [11, 70], [11, 71], [11, 72], [11, 75], [11, 76], [11, 77], [11, 78], [11, 87], [11, 89], [11, 91], [11, 92], [11, 96], [11, 102], [11, 104], [11, 106], [11, 113], [11, 114], [11, 117], [11, 121], [11, 123], [11, 124], [11, 125], [11, 128], [11, 129], [11, 132], [11, 135], [11, 138], [12, 17], [12, 21], [12, 24], [12, 25], [12, 28], [12, 40], [12, 42], [12, 45], [12, 48], [12, 49], [12, 56], [12, 58], [12, 60], [12, 64], [12, 67], [12, 71], [12, 77], [12, 78], [12, 84], [12, 88], [12, 90], [12, 94], [12, 98], [12, 99], [12, 100], [12, 104], [12, 107], [12, 109], [12, 113], [12, 114], [12, 116], [12, 118], [12, 120], [12, 125], [12, 128], [12, 129], [12, 130], [12, 133], [12, 136], [12, 137], [12, 139], [13, 16], [13, 23], [13, 25], [13, 30], [13, 33], [13, 39], [13, 59], [13, 62], [13, 63], [13, 65], [13, 69], [13, 72], [13, 85], [13, 98], [13, 101], [13, 106], [13, 107], [13, 112], [13, 113], [13, 119], [13, 121], [13, 125], [13, 127], [13, 129], [13, 130], [13, 135], [13, 138], [14, 17], [14, 20], [14, 26], [14, 27], [14, 28], [14, 31], [14, 35], [14, 38], [14, 42], [14, 43], [14, 49], [14, 54], [14, 55], [14, 57], [14, 65], [14, 66], [14, 67], [14, 68], [14, 71], [14, 76], [14, 77], [14, 81], [14, 86], [14, 88], [14, 92], [14, 95], [14, 99], [14, 102], [14, 103], [14, 106], [14, 110], [14, 113], [14, 124], [14, 131], [14, 132], [14, 134], [14, 136], [15, 16], [15, 23], [15, 24], [15, 25], [15, 30], [15, 31], [15, 37], [15, 38], [15, 41], [15, 42], [15, 44], [15, 47], [15, 56], [15, 57], [15, 59], [15, 62], [15, 63], [15, 64], [15, 68], [15, 79], [15, 82], [15, 85], [15, 86], [15, 91], [15, 93], [15, 94], [15, 106], [15, 110], [15, 113], [15, 114], [15, 122], [15, 125], [15, 127], [15, 128], [15, 129], [15, 131], [15, 135], [15, 136], [16, 22], [16, 28], [16, 37], [16, 41], [16, 43], [16, 47], [16, 54], [16, 58], [16, 60], [16, 63], [16, 64], [16, 65], [16, 69], [16, 77], [16, 79], [16, 80], [16, 88], [16, 94], [16, 99], [16, 102], [16, 106], [16, 109], [16, 110], [16, 117], [16, 121], [16, 124], [16, 128], [16, 130], [16, 138], [17, 18], [17, 27], [17, 29], [17, 33], [17, 39], [17, 40], [17, 41], [17, 47], [17, 49], [17, 52], [17, 54], [17, 56], [17, 58], [17, 60], [17, 63], [17, 64], [17, 65], [17, 67], [17, 68], [17, 73], [17, 75], [17, 78], [17, 79], [17, 80], [17, 85], [17, 88], [17, 89], [17, 94], [17, 98], [17, 104], [17, 105], [17, 106], [17, 107], [17, 115], [17, 116], [17, 118], [17, 119], [17, 123], [17, 127], [17, 131], [17, 134], [17, 135], [18, 20], [18, 24], [18, 26], [18, 29], [18, 31], [18, 32], [18, 41], [18, 42], [18, 48], [18, 49], [18, 54], [18, 57], [18, 60], [18, 62], [18, 70], [18, 72], [18, 83], [18, 84], [18, 85], [18, 88], [18, 97], [18, 99], [18, 101], [18, 102], [18, 103], [18, 104], [18, 106], [18, 108], [18, 109], [18, 114], [18, 115], [18, 117], [18, 126], [18, 135], [19, 23], [19, 24], [19, 32], [19, 36], [19, 39], [19, 41], [19, 42], [19, 44], [19, 49], [19, 50], [19, 51], [19, 53], [19, 55], [19, 56], [19, 59], [19, 60], [19, 62], [19, 63], [19, 64], [19, 66], [19, 67], [19, 69], [19, 73], [19, 88], [19, 95], [19, 96], [19, 101], [19, 102], [19, 103], [19, 105], [19, 108], [19, 109], [19, 112], [19, 128], [19, 130], [19, 135], [19, 138], [19, 139], [20, 21], [20, 25], [20, 37], [20, 38], [20, 42], [20, 46], [20, 49], [20, 57], [20, 62], [20, 68], [20, 70], [20, 72], [20, 77], [20, 81], [20, 84], [20, 85], [20, 89], [20, 90], [20, 92], [20, 94], [20, 95], [20, 96], [20, 98], [20, 99], [20, 102], [20, 104], [20, 105], [20, 106], [20, 107], [20, 109], [20, 110], [20, 114], [20, 115], [20, 117], [20, 119], [20, 120], [20, 121], [20, 122], [20, 124], [20, 128], [20, 130], [20, 131], [20, 132], [20, 137], [21, 25], [21, 28], [21, 29], [21, 35], [21, 39], [21, 48], [21, 52], [21, 56], [21, 58], [21, 62], [21, 66], [21, 67], [21, 68], [21, 76], [21, 88], [21, 90], [21, 93], [21, 100], [21, 101], [21, 103], [21, 106], [21, 108], [21, 110], [21, 111], [21, 113], [21, 117], [21, 121], [21, 128], [21, 130], [21, 133], [21, 135], [21, 137], [22, 28], [22, 31], [22, 35], [22, 40], [22, 43], [22, 52], [22, 55], [22, 58], [22, 59], [22, 68], [22, 71], [22, 73], [22, 74], [22, 78], [22, 85], [22, 88], [22, 90], [22, 93], [22, 105], [22, 117], [22, 119], [22, 122], [22, 123], [22, 125], [22, 130], [22, 133], [22, 137], [22, 138], [23, 24], [23, 26], [23, 29], [23, 32], [23, 34], [23, 46], [23, 47], [23, 49], [23, 50], [23, 52], [23, 53], [23, 54], [23, 61], [23, 67], [23, 69], [23, 75], [23, 76], [23, 82], [23, 84], [23, 96], [23, 99], [23, 105], [23, 107], [23, 108], [23, 113], [23, 116], [23, 117], [23, 118], [23, 119], [23, 120], [23, 121], [23, 122], [23, 126], [23, 128], [23, 131], [23, 134], [23, 136], [23, 137], [23, 139], [24, 30], [24, 40], [24, 44], [24, 46], [24, 47], [24, 52], [24, 53], [24, 54], [24, 58], [24, 61], [24, 62], [24, 67], [24, 71], [24, 77], [24, 79], [24, 81], [24, 82], [24, 83], [24, 85], [24, 89], [24, 93], [24, 101], [24, 104], [24, 105], [24, 109], [24, 112], [24, 113], [24, 115], [24, 116], [24, 121], [24, 126], [24, 129], [24, 130], [24, 132], [24, 135], [24, 138], [24, 139], [25, 26], [25, 27], [25, 29], [25, 30], [25, 38], [25, 45], [25, 46], [25, 49], [25, 50], [25, 55], [25, 61], [25, 62], [25, 70], [25, 75], [25, 79], [25, 88], [25, 93], [25, 100], [25, 101], [25, 105], [25, 109], [25, 110], [25, 111], [25, 128], [25, 129], [25, 134], [25, 135], [25, 138], [26, 32], [26, 34], [26, 42], [26, 45], [26, 49], [26, 58], [26, 59], [26, 60], [26, 62], [26, 63], [26, 64], [26, 73], [26, 74], [26, 78], [26, 79], [26, 80], [26, 84], [26, 89], [26, 96], [26, 97], [26, 102], [26, 103], [26, 104], [26, 108], [26, 110], [26, 111], [26, 112], [26, 115], [26, 116], [26, 119], [26, 120], [26, 126], [26, 127], [26, 128], [26, 130], [26, 138], [27, 33], [27, 34], [27, 39], [27, 47], [27, 52], [27, 55], [27, 56], [27, 60], [27, 61], [27, 63], [27, 67], [27, 68], [27, 71], [27, 72], [27, 74], [27, 78], [27, 84], [27, 85], [27, 86], [27, 89], [27, 100], [27, 105], [27, 106], [27, 110], [27, 116], [27, 117], [27, 120], [27, 121], [27, 126], [27, 127], [27, 129], [27, 131], [27, 132], [28, 29], [28, 31], [28, 33], [28, 37], [28, 40], [28, 48], [28, 52], [28, 53], [28, 54], [28, 57], [28, 60], [28, 62], [28, 70], [28, 71], [28, 76], [28, 80], [28, 86], [28, 88], [28, 90], [28, 95], [28, 97], [28, 107], [28, 109], [28, 113], [28, 116], [28, 117], [28, 123], [28, 124], [28, 128], [28, 130], [28, 134], [28, 139], [29, 32], [29, 35], [29, 38], [29, 39], [29, 48], [29, 50], [29, 51], [29, 58], [29, 59], [29, 60], [29, 66], [29, 69], [29, 71], [29, 73], [29, 79], [29, 85], [29, 86], [29, 92], [29, 98], [29, 100], [29, 103], [29, 106], [29, 108], [29, 110], [29, 114], [29, 117], [29, 121], [29, 124], [29, 125], [29, 130], [29, 135], [29, 136], [30, 33], [30, 37], [30, 39], [30, 41], [30, 42], [30, 49], [30, 50], [30, 55], [30, 63], [30, 64], [30, 65], [30, 74], [30, 79], [30, 80], [30, 81], [30, 85], [30, 90], [30, 91], [30, 98], [30, 100], [30, 101], [30, 102], [30, 103], [30, 108], [30, 110], [30, 113], [30, 114], [30, 115], [30, 122], [30, 129], [30, 131], [30, 133], [30, 136], [30, 137], [30, 139], [31, 34], [31, 35], [31, 37], [31, 41], [31, 42], [31, 44], [31, 46], [31, 51], [31, 59], [31, 61], [31, 66], [31, 67], [31, 69], [31, 73], [31, 77], [31, 80], [31, 88], [31, 92], [31, 95], [31, 98], [31, 100], [31, 101], [31, 106], [31, 110], [31, 112], [31, 113], [31, 114], [31, 116], [31, 118], [31, 122], [31, 124], [31, 129], [31, 131], [31, 138], [31, 139], [32, 34], [32, 36], [32, 40], [32, 41], [32, 43], [32, 56], [32, 57], [32, 58], [32, 59], [32, 65], [32, 66], [32, 73], [32, 74], [32, 75], [32, 79], [32, 81], [32, 82], [32, 85], [32, 89], [32, 92], [32, 93], [32, 94], [32, 95], [32, 97], [32, 100], [32, 102], [32, 103], [32, 104], [32, 105], [32, 113], [32, 120], [32, 121], [32, 124], [32, 129], [32, 131], [32, 134], [32, 135], [32, 136], [32, 138], [32, 139], [33, 37], [33, 45], [33, 48], [33, 50], [33, 56], [33, 57], [33, 58], [33, 59], [33, 63], [33, 65], [33, 69], [33, 71], [33, 75], [33, 76], [33, 79], [33, 80], [33, 82], [33, 88], [33, 90], [33, 91], [33, 93], [33, 96], [33, 100], [33, 102], [33, 106], [33, 111], [33, 115], [33, 117], [33, 120], [33, 124], [33, 125], [33, 128], [33, 129], [33, 131], [33, 135], [33, 137], [33, 138], [33, 139], [34, 49], [34, 50], [34, 52], [34, 56], [34, 58], [34, 61], [34, 64], [34, 65], [34, 67], [34, 69], [34, 72], [34, 73], [34, 76], [34, 88], [34, 89], [34, 91], [34, 95], [34, 96], [34, 104], [34, 105], [34, 107], [34, 108], [34, 112], [34, 113], [34, 114], [34, 116], [34, 117], [34, 120], [34, 121], [34, 122], [34, 125], [34, 129], [34, 131], [34, 132], [34, 133], [34, 136], [35, 37], [35, 40], [35, 43], [35, 51], [35, 53], [35, 57], [35, 61], [35, 66], [35, 67], [35, 70], [35, 72], [35, 76], [35, 79], [35, 81], [35, 84], [35, 85], [35, 90], [35, 93], [35, 98], [35, 101], [35, 102], [35, 103], [35, 107], [35, 109], [35, 113], [35, 115], [35, 126], [35, 127], [35, 129], [35, 132], [35, 133], [35, 136], [36, 40], [36, 42], [36, 43], [36, 51], [36, 52], [36, 54], [36, 55], [36, 61], [36, 68], [36, 71], [36, 72], [36, 74], [36, 77], [36, 79], [36, 84], [36, 85], [36, 92], [36, 93], [36, 94], [36, 96], [36, 98], [36, 100], [36, 101], [36, 102], [36, 114], [36, 123], [36, 126], [36, 127], [36, 128], [36, 129], [36, 130], [36, 133], [36, 134], [36, 136], [37, 38], [37, 52], [37, 55], [37, 57], [37, 60], [37, 63], [37, 72], [37, 75], [37, 76], [37, 77], [37, 84], [37, 91], [37, 93], [37, 95], [37, 98], [37, 100], [37, 103], [37, 104], [37, 109], [37, 112], [37, 114], [37, 122], [37, 132], [37, 133], [37, 134], [37, 135], [37, 137], [38, 53], [38, 56], [38, 60], [38, 62], [38, 63], [38, 68], [38, 76], [38, 77], [38, 86], [38, 89], [38, 95], [38, 96], [38, 97], [38, 98], [38, 101], [38, 102], [38, 104], [38, 109], [38, 110], [38, 112], [38, 113], [38, 114], [38, 116], [38, 117], [38, 127], [38, 128], [38, 134], [38, 135], [39, 40], [39, 43], [39, 45], [39, 46], [39, 48], [39, 52], [39, 55], [39, 58], [39, 62], [39, 66], [39, 67], [39, 70], [39, 76], [39, 81], [39, 87], [39, 88], [39, 95], [39, 96], [39, 99], [39, 109], [39, 114], [39, 116], [39, 123], [39, 124], [39, 126], [39, 128], [39, 130], [39, 132], [39, 137], [40, 44], [40, 46], [40, 53], [40, 55], [40, 58], [40, 69], [40, 79], [40, 80], [40, 92], [40, 95], [40, 98], [40, 105], [40, 109], [40, 111], [40, 112], [40, 113], [40, 114], [40, 117], [40, 119], [40, 120], [40, 121], [40, 125], [40, 127], [40, 133], [40, 136], [41, 42], [41, 43], [41, 48], [41, 55], [41, 57], [41, 58], [41, 63], [41, 65], [41, 66], [41, 69], [41, 71], [41, 72], [41, 74], [41, 75], [41, 79], [41, 80], [41, 83], [41, 84], [41, 87], [41, 90], [41, 98], [41, 105], [41, 106], [41, 109], [41, 111], [41, 118], [41, 129], [41, 130], [42, 52], [42, 53], [42, 59], [42, 63], [42, 64], [42, 69], [42, 73], [42, 75], [42, 77], [42, 81], [42, 82], [42, 90], [42, 92], [42, 95], [42, 97], [42, 104], [42, 113], [42, 114], [42, 118], [42, 119], [42, 126], [42, 129], [42, 130], [42, 134], [42, 137], [43, 44], [43, 46], [43, 48], [43, 50], [43, 53], [43, 55], [43, 57], [43, 60], [43, 63], [43, 64], [43, 65], [43, 70], [43, 73], [43, 80], [43, 82], [43, 86], [43, 87], [43, 90], [43, 99], [43, 101], [43, 106], [43, 107], [43, 115], [43, 118], [43, 122], [43, 130], [43, 135], [43, 137], [44, 55], [44, 56], [44, 58], [44, 63], [44, 65], [44, 66], [44, 67], [44, 68], [44, 84], [44, 86], [44, 90], [44, 96], [44, 97], [44, 103], [44, 104], [44, 109], [44, 110], [44, 119], [44, 121], [44, 130], [45, 49], [45, 53], [45, 55], [45, 61], [45, 63], [45, 64], [45, 65], [45, 72], [45, 74], [45, 76], [45, 77], [45, 80], [45, 84], [45, 86], [45, 90], [45, 99], [45, 103], [45, 104], [45, 112], [45, 117], [45, 121], [45, 122], [45, 123], [45, 131], [45, 133], [45, 135], [45, 137], [46, 50], [46, 53], [46, 54], [46, 57], [46, 58], [46, 63], [46, 68], [46, 74], [46, 76], [46, 81], [46, 82], [46, 84], [46, 86], [46, 92], [46, 96], [46, 97], [46, 102], [46, 105], [46, 112], [46, 114], [46, 118], [46, 125], [46, 133], [46, 134], [46, 135], [46, 137], [47, 53], [47, 56], [47, 58], [47, 60], [47, 61], [47, 81], [47, 85], [47, 88], [47, 89], [47, 91], [47, 96], [47, 99], [47, 100], [47, 102], [47, 104], [47, 108], [47, 109], [47, 111], [47, 112], [47, 115], [47, 116], [47, 125], [47, 127], [47, 133], [47, 134], [47, 138], [48, 56], [48, 58], [48, 59], [48, 77], [48, 79], [48, 85], [48, 87], [48, 88], [48, 96], [48, 97], [48, 113], [48, 116], [48, 122], [48, 126], [48, 129], [48, 138], [48, 139], [49, 50], [49, 53], [49, 55], [49, 57], [49, 64], [49, 65], [49, 67], [49, 70], [49, 72], [49, 75], [49, 83], [49, 84], [49, 87], [49, 88], [49, 93], [49, 94], [49, 97], [49, 102], [49, 117], [49, 118], [49, 120], [49, 124], [49, 125], [49, 126], [49, 131], [49, 135], [49, 136], [50, 52], [50, 55], [50, 57], [50, 58], [50, 59], [50, 64], [50, 68], [50, 75], [50, 76], [50, 81], [50, 86], [50, 87], [50, 88], [50, 92], [50, 93], [50, 94], [50, 102], [50, 103], [50, 106], [50, 118], [50, 119], [50, 121], [50, 129], [50, 130], [50, 131], [50, 135], [51, 69], [51, 74], [51, 77], [51, 83], [51, 90], [51, 91], [51, 93], [51, 95], [51, 98], [51, 99], [51, 103], [51, 106], [51, 113], [51, 117], [51, 121], [51, 125], [51, 127], [51, 128], [51, 130], [51, 131], [51, 132], [51, 137], [52, 54], [52, 55], [52, 56], [52, 59], [52, 70], [52, 79], [52, 89], [52, 91], [52, 95], [52, 96], [52, 97], [52, 101], [52, 103], [52, 104], [52, 120], [52, 121], [52, 127], [52, 130], [52, 132], [52, 133], [52, 136], [52, 138], [53, 54], [53, 55], [53, 56], [53, 57], [53, 59], [53, 60], [53, 61], [53, 62], [53, 64], [53, 65], [53, 66], [53, 71], [53, 73], [53, 76], [53, 78], [53, 80], [53, 83], [53, 86], [53, 92], [53, 96], [53, 99], [53, 101], [53, 107], [53, 108], [53, 110], [53, 121], [53, 124], [53, 126], [53, 129], [53, 132], [53, 133], [53, 134], [53, 135], [54, 66], [54, 67], [54, 73], [54, 74], [54, 82], [54, 85], [54, 86], [54, 87], [54, 89], [54, 90], [54, 91], [54, 94], [54, 98], [54, 99], [54, 100], [54, 109], [54, 112], [54, 113], [54, 115], [54, 118], [54, 119], [54, 122], [54, 126], [54, 127], [54, 132], [54, 137], [55, 56], [55, 57], [55, 58], [55, 60], [55, 67], [55, 71], [55, 74], [55, 77], [55, 79], [55, 80], [55, 82], [55, 94], [55, 96], [55, 105], [55, 106], [55, 108], [55, 117], [55, 121], [55, 124], [55, 125], [55, 128], [55, 129], [55, 130], [55, 131], [56, 57], [56, 58], [56, 61], [56, 66], [56, 71], [56, 75], [56, 85], [56, 87], [56, 93], [56, 96], [56, 97], [56, 99], [56, 103], [56, 106], [56, 108], [56, 109], [56, 113], [56, 114], [56, 115], [56, 117], [56, 118], [56, 119], [56, 120], [56, 122], [56, 125], [56, 128], [56, 130], [56, 131], [56, 132], [56, 133], [56, 139], [57, 60], [57, 61], [57, 66], [57, 67], [57, 69], [57, 72], [57, 74], [57, 80], [57, 84], [57, 87], [57, 88], [57, 94], [57, 95], [57, 98], [57, 99], [57, 104], [57, 105], [57, 106], [57, 109], [57, 111], [57, 113], [57, 114], [57, 116], [57, 118], [57, 122], [57, 123], [57, 128], [57, 130], [57, 135], [57, 136], [57, 137], [58, 60], [58, 66], [58, 67], [58, 68], [58, 71], [58, 73], [58, 74], [58, 78], [58, 79], [58, 80], [58, 83], [58, 87], [58, 88], [58, 99], [58, 109], [58, 110], [58, 122], [58, 124], [58, 132], [59, 73], [59, 76], [59, 78], [59, 79], [59, 80], [59, 91], [59, 95], [59, 96], [59, 98], [59, 100], [59, 101], [59, 103], [59, 104], [59, 107], [59, 111], [59, 114], [59, 118], [59, 123], [59, 129], [59, 131], [59, 134], [60, 69], [60, 73], [60, 76], [60, 81], [60, 82], [60, 91], [60, 94], [60, 96], [60, 97], [60, 100], [60, 103], [60, 122], [60, 126], [60, 128], [60, 134], [60, 136], [61, 64], [61, 66], [61, 69], [61, 73], [61, 75], [61, 81], [61, 82], [61, 83], [61, 84], [61, 90], [61, 92], [61, 96], [61, 97], [61, 102], [61, 104], [61, 105], [61, 114], [61, 124], [61, 127], [61, 128], [61, 129], [61, 130], [61, 134], [61, 135], [61, 139], [62, 63], [62, 67], [62, 71], [62, 74], [62, 76], [62, 79], [62, 84], [62, 89], [62, 91], [62, 92], [62, 96], [62, 97], [62, 100], [62, 106], [62, 110], [62, 113], [62, 117], [62, 118], [62, 124], [62, 125], [62, 131], [62, 133], [62, 138], [63, 64], [63, 65], [63, 72], [63, 75], [63, 77], [63, 80], [63, 83], [63, 88], [63, 89], [63, 92], [63, 97], [63, 98], [63, 104], [63, 106], [63, 107], [63, 110], [63, 115], [63, 116], [63, 117], [63, 122], [63, 123], [63, 128], [63, 135], [64, 65], [64, 74], [64, 75], [64, 77], [64, 79], [64, 80], [64, 81], [64, 83], [64, 88], [64, 91], [64, 93], [64, 96], [64, 98], [64, 99], [64, 100], [64, 106], [64, 107], [64, 108], [64, 109], [64, 112], [64, 113], [64, 115], [64, 118], [64, 120], [64, 121], [64, 131], [64, 133], [64, 136], [64, 138], [65, 69], [65, 71], [65, 78], [65, 83], [65, 84], [65, 87], [65, 90], [65, 93], [65, 98], [65, 99], [65, 100], [65, 103], [65, 106], [65, 112], [65, 116], [65, 118], [65, 127], [65, 128], [65, 132], [66, 70], [66, 71], [66, 77], [66, 78], [66, 81], [66, 85], [66, 88], [66, 90], [66, 98], [66, 99], [66, 102], [66, 108], [66, 109], [66, 116], [66, 117], [66, 126], [66, 127], [66, 130], [66, 132], [66, 135], [66, 136], [66, 137], [67, 69], [67, 76], [67, 84], [67, 85], [67, 90], [67, 93], [67, 98], [67, 110], [67, 115], [67, 121], [67, 129], [67, 131], [67, 135], [68, 71], [68, 73], [68, 74], [68, 75], [68, 76], [68, 79], [68, 82], [68, 83], [68, 84], [68, 85], [68, 87], [68, 88], [68, 90], [68, 97], [68, 100], [68, 108], [68, 114], [68, 116], [68, 117], [68, 119], [68, 120], [68, 121], [68, 125], [68, 126], [68, 129], [69, 70], [69, 71], [69, 73], [69, 74], [69, 78], [69, 79], [69, 81], [69, 82], [69, 84], [69, 85], [69, 86], [69, 90], [69, 93], [69, 98], [69, 99], [69, 106], [69, 115], [69, 125], [69, 127], [69, 132], [69, 133], [69, 134], [69, 136], [69, 138], [70, 76], [70, 87], [70, 93], [70, 94], [70, 95], [70, 97], [70, 98], [70, 101], [70, 108], [70, 113], [70, 120], [70, 124], [70, 125], [70, 128], [70, 129], [70, 130], [70, 133], [70, 135], [70, 136], [70, 137], [70, 139], [71, 74], [71, 76], [71, 83], [71, 86], [71, 87], [71, 90], [71, 96], [71, 97], [71, 105], [71, 113], [71, 115], [71, 116], [71, 121], [71, 126], [71, 130], [71, 137], [71, 138], [71, 139], [72, 80], [72, 85], [72, 86], [72, 95], [72, 96], [72, 98], [72, 102], [72, 103], [72, 109], [72, 113], [72, 114], [72, 119], [72, 122], [72, 124], [72, 125], [72, 126], [72, 127], [72, 128], [72, 129], [72, 134], [73, 74], [73, 87], [73, 92], [73, 99], [73, 100], [73, 103], [73, 104], [73, 106], [73, 107], [73, 108], [73, 111], [73, 113], [73, 115], [73, 117], [73, 121], [73, 129], [73, 131], [73, 134], [73, 137], [74, 77], [74, 81], [74, 89], [74, 98], [74, 100], [74, 103], [74, 104], [74, 111], [74, 117], [74, 120], [74, 123], [74, 130], [74, 133], [74, 135], [74, 137], [75, 79], [75, 80], [75, 85], [75, 90], [75, 94], [75, 95], [75, 107], [75, 111], [75, 114], [75, 116], [75, 120], [75, 123], [75, 124], [75, 126], [75, 128], [75, 132], [75, 134], [75, 136], [75, 138], [75, 139], [76, 78], [76, 83], [76, 84], [76, 85], [76, 87], [76, 88], [76, 92], [76, 93], [76, 94], [76, 97], [76, 100], [76, 102], [76, 106], [76, 107], [76, 108], [76, 111], [76, 114], [76, 115], [76, 116], [76, 117], [76, 122], [76, 126], [76, 133], [76, 135], [76, 139], [77, 78], [77, 80], [77, 81], [77, 84], [77, 87], [77, 88], [77, 89], [77, 92], [77, 94], [77, 98], [77, 99], [77, 103], [77, 105], [77, 107], [77, 111], [77, 114], [77, 115], [77, 116], [77, 117], [77, 126], [77, 129], [77, 131], [77, 132], [77, 134], [77, 138], [78, 84], [78, 86], [78, 88], [78, 98], [78, 99], [78, 101], [78, 102], [78, 105], [78, 110], [78, 114], [78, 115], [78, 116], [78, 117], [78, 118], [78, 121], [78, 122], [78, 124], [78, 127], [78, 129], [78, 132], [78, 135], [78, 138], [79, 80], [79, 84], [79, 92], [79, 93], [79, 96], [79, 100], [79, 108], [79, 111], [79, 112], [79, 113], [79, 118], [79, 119], [79, 123], [79, 126], [79, 127], [79, 128], [79, 129], [79, 130], [79, 133], [79, 135], [79, 137], [79, 139], [80, 82], [80, 89], [80, 90], [80, 91], [80, 92], [80, 93], [80, 94], [80, 102], [80, 105], [80, 109], [80, 114], [80, 115], [80, 118], [80, 119], [80, 121], [80, 122], [80, 123], [80, 126], [80, 128], [80, 130], [80, 134], [80, 136], [80, 139], [81, 89], [81, 91], [81, 92], [81, 93], [81, 95], [81, 106], [81, 110], [81, 112], [81, 114], [81, 119], [81, 120], [81, 121], [81, 127], [81, 128], [82, 91], [82, 103], [82, 105], [82, 106], [82, 107], [82, 109], [82, 114], [82, 123], [82, 125], [82, 126], [82, 134], [82, 138], [83, 86], [83, 87], [83, 93], [83, 94], [83, 99], [83, 101], [83, 103], [83, 112], [83, 116], [83, 117], [83, 119], [83, 130], [83, 132], [83, 136], [84, 86], [84, 87], [84, 88], [84, 89], [84, 90], [84, 91], [84, 92], [84, 95], [84, 96], [84, 107], [84, 109], [84, 115], [84, 116], [84, 119], [84, 120], [84, 124], [84, 129], [84, 132], [84, 135], [84, 138], [85, 87], [85, 95], [85, 98], [85, 103], [85, 104], [85, 106], [85, 110], [85, 112], [85, 113], [85, 114], [85, 117], [85, 123], [85, 124], [85, 130], [85, 135], [86, 97], [86, 101], [86, 103], [86, 104], [86, 105], [86, 107], [86, 109], [86, 110], [86, 114], [86, 115], [86, 118], [86, 121], [86, 123], [86, 133], [86, 139], [87, 88], [87, 91], [87, 93], [87, 94], [87, 95], [87, 98], [87, 100], [87, 101], [87, 110], [87, 111], [87, 112], [87, 113], [87, 117], [87, 121], [87, 122], [87, 123], [87, 125], [87, 128], [87, 134], [87, 139], [88, 92], [88, 94], [88, 95], [88, 100], [88, 109], [88, 111], [88, 114], [88, 116], [88, 119], [88, 122], [88, 124], [88, 125], [88, 128], [88, 130], [89, 90], [89, 99], [89, 102], [89, 103], [89, 106], [89, 109], [89, 110], [89, 113], [89, 114], [89, 117], [89, 119], [89, 120], [89, 125], [89, 126], [89, 127], [89, 132], [90, 92], [90, 95], [90, 96], [90, 97], [90, 100], [90, 101], [90, 102], [90, 106], [90, 111], [90, 112], [90, 115], [90, 116], [90, 117], [90, 124], [90, 125], [90, 126], [90, 127], [90, 130], [90, 133], [90, 134], [90, 135], [90, 138], [91, 94], [91, 95], [91, 114], [91, 115], [91, 118], [91, 124], [91, 125], [91, 127], [91, 128], [91, 135], [91, 137], [92, 94], [92, 104], [92, 110], [92, 114], [92, 121], [92, 122], [92, 129], [92, 134], [92, 135], [92, 139], [93, 95], [93, 101], [93, 102], [93, 121], [93, 122], [93, 129], [93, 133], [93, 137], [93, 139], [94, 97], [94, 99], [94, 101], [94, 104], [94, 107], [94, 113], [94, 116], [94, 117], [94, 126], [94, 128], [94, 132], [94, 135], [94, 139], [95, 101], [95, 102], [95, 104], [95, 106], [95, 109], [95, 111], [95, 115], [95, 116], [95, 118], [95, 121], [95, 124], [95, 127], [95, 130], [95, 132], [95, 136], [95, 137], [95, 138], [95, 139], [96, 97], [96, 110], [96, 114], [96, 117], [96, 120], [96, 125], [96, 127], [96, 129], [96, 133], [97, 98], [97, 101], [97, 104], [97, 105], [97, 109], [97, 110], [97, 114], [97, 115], [97, 120], [97, 121], [97, 123], [97, 128], [97, 129], [97, 132], [97, 137], [97, 138], [98, 117], [98, 118], [98, 119], [98, 123], [98, 127], [98, 131], [98, 139], [99, 101], [99, 105], [99, 107], [99, 111], [99, 114], [99, 126], [99, 129], [99, 130], [99, 136], [100, 102], [100, 112], [100, 124], [100, 126], [100, 130], [100, 134], [100, 138], [101, 103], [101, 105], [101, 106], [101, 115], [101, 116], [101, 117], [101, 119], [101, 125], [101, 126], [101, 127], [101, 129], [101, 130], [101, 133], [101, 136], [101, 139], [102, 109], [102, 110], [102, 113], [102, 122], [102, 124], [103, 106], [103, 107], [103, 108], [103, 109], [103, 112], [103, 126], [103, 128], [103, 129], [103, 135], [103, 136], [104, 106], [104, 115], [104, 117], [104, 129], [105, 116], [105, 120], [105, 127], [105, 128], [105, 130], [105, 131], [105, 135], [105, 139], [106, 110], [106, 111], [106, 116], [106, 135], [106, 137], [106, 138], [107, 114], [107, 117], [107, 118], [107, 122], [107, 125], [107, 128], [107, 134], [107, 135], [107, 138], [108, 109], [108, 112], [108, 113], [108, 116], [108, 121], [108, 127], [108, 128], [108, 133], [109, 110], [109, 115], [109, 118], [109, 120], [109, 122], [109, 125], [109, 127], [109, 128], [109, 130], [109, 136], [110, 112], [110, 116], [110, 121], [110, 123], [110, 128], [110, 129], [110, 137], [110, 139], [111, 116], [111, 117], [111, 121], [111, 122], [111, 123], [111, 126], [111, 127], [111, 129], [111, 130], [111, 131], [111, 133], [111, 138], [112, 115], [112, 116], [112, 117], [112, 119], [112, 121], [112, 123], [112, 129], [112, 131], [112, 132], [112, 136], [112, 138], [113, 115], [113, 116], [113, 118], [113, 124], [114, 118], [114, 121], [114, 127], [114, 128], [114, 129], [114, 135], [114, 136], [115, 122], [115, 124], [115, 125], [115, 131], [115, 132], [115, 133], [115, 134], [115, 135], [115, 136], [115, 138], [116, 118], [116, 121], [116, 122], [116, 128], [116, 129], [116, 130], [116, 132], [116, 133], [116, 135], [117, 124], [117, 131], [117, 132], [117, 133], [117, 135], [117, 137], [118, 123], [118, 124], [118, 125], [118, 128], [118, 129], [119, 122], [119, 124], [119, 130], [119, 134], [119, 136], [119, 137], [119, 139], [120, 121], [120, 125], [120, 129], [120, 130], [120, 137], [121, 122], [121, 129], [121, 132], [121, 133], [121, 134], [121, 136], [122, 124], [122, 128], [122, 129], [122, 132], [122, 133], [122, 137], [122, 138], [123, 131], [123, 132], [123, 135], [123, 136], [123, 137], [123, 138], [123, 139], [124, 126], [124, 129], [124, 135], [124, 138], [124, 139], [125, 131], [125, 135], [125, 136], [126, 129], [126, 134], [126, 138], [127, 133], [127, 134], [127, 135], [128, 131], [128, 132], [129, 138], [129, 139], [130, 132], [130, 136], [132, 134], [132, 135], [133, 138], [134, 136], [134, 139], [136, 137]], "family": "mc_max_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-max-independent-set-l6-s6/tests/run.py b/tasks/construct-mc-max-independent-set-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-max-independent-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-mc-max-independent-set-l6-s6/tests/test.sh b/tasks/construct-mc-max-independent-set-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-max-independent-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-mc-ortholatin-l5-s2/environment/Dockerfile b/tasks/construct-mc-ortholatin-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ortholatin-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-ortholatin-l5-s2/environment/instance.json b/tasks/construct-mc-ortholatin-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b5e8f2baa033790894413306adf1ccb9ce754af1 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 21, "family": "mc_ortholatin", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ortholatin-l5-s2/solution/solve.sh b/tasks/construct-mc-ortholatin-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6680612b01172bbb204d090a18548c84ff96a910 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l5-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"X": [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]], "Y": [[0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 0], [3, 5, 7, 9, 11, 13, 15, 17, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1], [4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 0, 2], [5, 7, 9, 11, 13, 15, 17, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3], [6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 0, 2, 4], [7, 9, 11, 13, 15, 17, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5], [8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 0, 2, 4, 6], [9, 11, 13, 15, 17, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7], [10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 0, 2, 4, 6, 8], [11, 13, 15, 17, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9], [12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 0, 2, 4, 6, 8, 10], [13, 15, 17, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11], [14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 0, 2, 4, 6, 8, 10, 12], [15, 17, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13], [16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 0, 2, 4, 6, 8, 10, 12, 14], [17, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15], [18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16], [19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17], [20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18]]} +RLMATH_EOF diff --git a/tasks/construct-mc-ortholatin-l5-s2/tests/check.py b/tasks/construct-mc-ortholatin-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a5418a59fae1c86318eee903e90d75b36d8a3306 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l5-s2/tests/check.py @@ -0,0 +1,25 @@ +"""Pair of orthogonal Latin squares of order n (MathConstraint ortholatin, CC-BY-4.0).""" +from run import Invalid, int_list + + +def _square(v, n, name): + if not isinstance(v, list) or len(v) != n: + raise Invalid(f"{name} must be a list of {n} rows") + S = [int_list(r, n, 0, n - 1, f"{name} row") for r in v] + full = list(range(n)) + for i in range(n): + if sorted(S[i]) != full: + raise Invalid(f"{name}: row {i} is not a permutation of 0..{n - 1}") + if sorted(S[r][i] for r in range(n)) != full: + raise Invalid(f"{name}: column {i} is not a permutation of 0..{n - 1}") + return S + + +def check(inst, ans): + n = inst["n"] + X = _square(ans.get("X"), n, "X") + Y = _square(ans.get("Y"), n, "Y") + pairs = {(X[i][j], Y[i][j]) for i in range(n) for j in range(n)} + if len(pairs) != n * n: + raise Invalid("X and Y are not orthogonal (some ordered pair repeats)") + return None, {} diff --git a/tasks/construct-mc-ortholatin-l5-s2/tests/instance.json b/tasks/construct-mc-ortholatin-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b5e8f2baa033790894413306adf1ccb9ce754af1 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 21, "family": "mc_ortholatin", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ortholatin-l5-s2/tests/run.py b/tasks/construct-mc-ortholatin-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ortholatin-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-ortholatin-l5-s2/tests/test.sh b/tasks/construct-mc-ortholatin-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l5-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-clique-coloring-l2-s1/environment/Dockerfile b/tasks/construct-mc-pysms-clique-coloring-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l2-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-clique-coloring-l2-s1/environment/instance.json b/tasks/construct-mc-pysms-clique-coloring-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a25ceed9b3e730b86836c83b1617613cdcaab040 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 13, "required_edges": [[1, 3], [2, 7], [3, 11], [3, 10], [0, 12], [2, 10], [2, 4], [1, 11]], "max_chromatic_number": 5, "max_clique": 5, "min_degree": 4, "family": "mc_pysms_clique_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-clique-coloring-l2-s1/solution/solve.sh b/tasks/construct-mc-pysms-clique-coloring-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2823c567ac672047f51d39cb6bfc8432f774ac87 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l2-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"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], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12]], "coloring": [0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-clique-coloring-l2-s1/tests/check.py b/tasks/construct-mc-pysms-clique-coloring-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-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-clique-coloring-l2-s1/tests/instance.json b/tasks/construct-mc-pysms-clique-coloring-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a25ceed9b3e730b86836c83b1617613cdcaab040 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 13, "required_edges": [[1, 3], [2, 7], [3, 11], [3, 10], [0, 12], [2, 10], [2, 4], [1, 11]], "max_chromatic_number": 5, "max_clique": 5, "min_degree": 4, "family": "mc_pysms_clique_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-clique-coloring-l2-s1/tests/run.py b/tasks/construct-mc-pysms-clique-coloring-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l2-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-clique-coloring-l2-s1/tests/test.sh b/tasks/construct-mc-pysms-clique-coloring-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l2-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-graph-builder-l3-s0/environment/Dockerfile b/tasks/construct-mc-pysms-graph-builder-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l3-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-graph-builder-l3-s0/environment/instance.json b/tasks/construct-mc-pysms-graph-builder-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fc9c35a78e8a83ed2030026008121b04d7cf6661 --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 13, "required_edges": [], "max_degree": 2, "min_degree": 2, "max_chromatic_number": 4, "min_chromatic_number": 2, "min_edges": 9, "max_edges": 14, "family": "mc_pysms_graph_builder", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-graph-builder-l3-s0/solution/solve.sh b/tasks/construct-mc-pysms-graph-builder-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..40da84f6d7cce5de88d0e418870de6970b9eb8f1 --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l3-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 11], [0, 12], [1, 10], [1, 12], [2, 8], [2, 9], [3, 7], [3, 9], [4, 5], [4, 6], [5, 6], [7, 8], [10, 11]], "coloring": [0, 0, 0, 0, 0, 1, 2, 1, 2, 1, 1, 2, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-graph-builder-l3-s0/tests/check.py b/tasks/construct-mc-pysms-graph-builder-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l3-s0/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-graph-builder-l3-s0/tests/instance.json b/tasks/construct-mc-pysms-graph-builder-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fc9c35a78e8a83ed2030026008121b04d7cf6661 --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 13, "required_edges": [], "max_degree": 2, "min_degree": 2, "max_chromatic_number": 4, "min_chromatic_number": 2, "min_edges": 9, "max_edges": 14, "family": "mc_pysms_graph_builder", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-graph-builder-l3-s0/tests/run.py b/tasks/construct-mc-pysms-graph-builder-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l3-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-graph-builder-l3-s0/tests/test.sh b/tasks/construct-mc-pysms-graph-builder-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-graph-builder-l3-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-independent-connectivity-l2-s1/environment/Dockerfile b/tasks/construct-mc-pysms-independent-connectivity-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-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-independent-connectivity-l2-s1/environment/instance.json b/tasks/construct-mc-pysms-independent-connectivity-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..786a45b14fedb940b9d2360623bbcad22cddfe60 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 10, "required_edges": [[0, 3], [3, 8], [2, 9], [0, 5], [0, 4], [1, 7], [1, 4], [1, 6], [4, 8]], "max_independent_set": 6, "min_connectivity": 2, "family": "mc_pysms_independent_connectivity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-independent-connectivity-l2-s1/solution/solve.sh b/tasks/construct-mc-pysms-independent-connectivity-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2dfbd8e10be3814720762c87be2212bdd75316c7 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-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], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-independent-connectivity-l2-s1/tests/check.py b/tasks/construct-mc-pysms-independent-connectivity-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-independent-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-independent-connectivity-l2-s1/tests/instance.json b/tasks/construct-mc-pysms-independent-connectivity-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..786a45b14fedb940b9d2360623bbcad22cddfe60 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 10, "required_edges": [[0, 3], [3, 8], [2, 9], [0, 5], [0, 4], [1, 7], [1, 4], [1, 6], [4, 8]], "max_independent_set": 6, "min_connectivity": 2, "family": "mc_pysms_independent_connectivity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-independent-connectivity-l2-s1/tests/run.py b/tasks/construct-mc-pysms-independent-connectivity-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-independent-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-independent-connectivity-l2-s1/tests/test.sh b/tasks/construct-mc-pysms-independent-connectivity-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-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-connectivity-l5-s1/environment/Dockerfile b/tasks/construct-mc-pysms-min-connectivity-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-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-min-connectivity-l5-s1/environment/instance.json b/tasks/construct-mc-pysms-min-connectivity-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b574bb83942367014c15ea19551204c4f00ba5b7 --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 16, "required_edges": [[1, 10], [4, 10], [7, 10], [1, 6], [5, 13], [3, 6], [0, 6], [0, 15], [9, 13], [3, 12], [2, 7], [4, 14], [1, 12], [8, 13], [11, 14], [5, 12], [4, 12], [5, 14], [0, 4], [6, 7], [8, 9], [9, 12], [2, 8], [10, 14]], "min_connectivity": 5, "family": "mc_pysms_min_connectivity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-connectivity-l5-s1/solution/solve.sh b/tasks/construct-mc-pysms-min-connectivity-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4b8141dfb1b77c83fdaab714902ed360207c54d0 --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-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, 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-connectivity-l5-s1/tests/check.py b/tasks/construct-mc-pysms-min-connectivity-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-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-min-connectivity-l5-s1/tests/instance.json b/tasks/construct-mc-pysms-min-connectivity-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b574bb83942367014c15ea19551204c4f00ba5b7 --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 16, "required_edges": [[1, 10], [4, 10], [7, 10], [1, 6], [5, 13], [3, 6], [0, 6], [0, 15], [9, 13], [3, 12], [2, 7], [4, 14], [1, 12], [8, 13], [11, 14], [5, 12], [4, 12], [5, 14], [0, 4], [6, 7], [8, 9], [9, 12], [2, 8], [10, 14]], "min_connectivity": 5, "family": "mc_pysms_min_connectivity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-connectivity-l5-s1/tests/run.py b/tasks/construct-mc-pysms-min-connectivity-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-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-min-connectivity-l5-s1/tests/test.sh b/tasks/construct-mc-pysms-min-connectivity-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-min-connectivity-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-min-degree-l3-s2/environment/Dockerfile b/tasks/construct-mc-pysms-min-degree-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l3-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-min-degree-l3-s2/environment/instance.json b/tasks/construct-mc-pysms-min-degree-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..52ebd2da9e805963f841b5d52ed8ffba48152aee --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 11, "required_edges": [], "min_degree": 3, "family": "mc_pysms_min_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-degree-l3-s2/solution/solve.sh b/tasks/construct-mc-pysms-min-degree-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..24220ce9a34ebb047de09ce7f88464235e6a9a4b --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l3-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 7], [6, 8], [6, 9], [6, 10], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [9, 10]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-min-degree-l3-s2/tests/check.py b/tasks/construct-mc-pysms-min-degree-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l3-s2/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-min-degree-l3-s2/tests/instance.json b/tasks/construct-mc-pysms-min-degree-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..52ebd2da9e805963f841b5d52ed8ffba48152aee --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 11, "required_edges": [], "min_degree": 3, "family": "mc_pysms_min_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-degree-l3-s2/tests/run.py b/tasks/construct-mc-pysms-min-degree-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l3-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-min-degree-l3-s2/tests/test.sh b/tasks/construct-mc-pysms-min-degree-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l3-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-min-girth-l2-s0/environment/Dockerfile b/tasks/construct-mc-pysms-min-girth-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-min-girth-l2-s0/environment/instance.json b/tasks/construct-mc-pysms-min-girth-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f77b61cb5ce442850745f4a2e2ce75fc212a76d2 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 9, "required_edges": [], "min_girth": 3, "family": "mc_pysms_min_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-girth-l2-s0/solution/solve.sh b/tasks/construct-mc-pysms-min-girth-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..266b10696d549d81ec1db10a95e1067a0f575ccd --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l2-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [4, 5], [4, 6], [4, 7], [4, 8], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-min-girth-l2-s0/tests/check.py b/tasks/construct-mc-pysms-min-girth-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l2-s0/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-min-girth-l2-s0/tests/instance.json b/tasks/construct-mc-pysms-min-girth-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f77b61cb5ce442850745f4a2e2ce75fc212a76d2 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 9, "required_edges": [], "min_girth": 3, "family": "mc_pysms_min_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-girth-l2-s0/tests/run.py b/tasks/construct-mc-pysms-min-girth-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-min-girth-l2-s0/tests/test.sh b/tasks/construct-mc-pysms-min-girth-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-min-girth-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/environment/Dockerfile b/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/environment/instance.json b/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fb7910a880c715a8848b10eb9f7a4b90585a4784 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 18, "required_edges": [], "max_edges": 40, "min_edges": 34, "family": "mc_pysms_num_edges_bounds", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/solution/solve.sh b/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..77a0fd18ced8c3f06d38d7c14851defa75f8c82d --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [1, 2], [1, 3], [1, 4], [1, 5], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [2, 5], [2, 6], [2, 17], [3, 4], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/tests/check.py b/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/tests/instance.json b/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fb7910a880c715a8848b10eb9f7a4b90585a4784 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 18, "required_edges": [], "max_edges": 40, "min_edges": 34, "family": "mc_pysms_num_edges_bounds", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/tests/run.py b/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/tests/test.sh b/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-num-edges-bounds-l4-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-ramsey-l2-s0/environment/Dockerfile b/tasks/construct-mc-ramsey-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-ramsey-l2-s0/environment/instance.json b/tasks/construct-mc-ramsey-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f57be2ad11c22a7d971dbb74f10522b4b70ae566 --- /dev/null +++ b/tasks/construct-mc-ramsey-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 13, "r": 6, "s": 3, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l2-s0/solution/solve.sh b/tasks/construct-mc-ramsey-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b51044195ed50590bf06670a6f4d8bebdd189f65 --- /dev/null +++ b/tasks/construct-mc-ramsey-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' +{"colors": [1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-ramsey-l2-s0/tests/check.py b/tasks/construct-mc-ramsey-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l2-s0/tests/check.py @@ -0,0 +1,31 @@ +"""Two-colouring of the edges of K_n with no colour-0 K_r and no colour-1 K_s (MathConstraint ramsey, +CC-BY-4.0). Adapted from pilot/grader.py check_ramsey; adds the optional fixed edge colours.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, r, s = inst["n"], inst["r"], inst["s"] + edges = list(itertools.combinations(range(n), 2)) + col = int_list(ans.get("colors"), len(edges), 0, 1, "colors") + for name, i, v in inst.get("fixed", []): + if col[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + c = {e: col[i] for i, e in enumerate(edges)} + for k, colour in ((r, 0), (s, 1)): + adj = {v: {u for u in range(n) if u != v and c[(min(u, v), max(u, v))] == colour} for v in range(n)} + + def grow(size, cand): + if size == k: + return True + if size + len(cand) < k: + return False + for v in sorted(cand): + if grow(size + 1, {u for u in cand if u > v} & adj[v]): + return True + return False + + if grow(0, set(range(n))): + raise Invalid(f"monochromatic K_{k} in colour {colour}") + return None, {} diff --git a/tasks/construct-mc-ramsey-l2-s0/tests/instance.json b/tasks/construct-mc-ramsey-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f57be2ad11c22a7d971dbb74f10522b4b70ae566 --- /dev/null +++ b/tasks/construct-mc-ramsey-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 13, "r": 6, "s": 3, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l2-s0/tests/run.py b/tasks/construct-mc-ramsey-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-ramsey-l2-s0/tests/test.sh b/tasks/construct-mc-ramsey-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-ramsey-l2-s7/environment/Dockerfile b/tasks/construct-mc-ramsey-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-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-mc-ramsey-l2-s7/environment/instance.json b/tasks/construct-mc-ramsey-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..25e862fb8abe75fac486d2ca7b979b2bf5c3a5f1 --- /dev/null +++ b/tasks/construct-mc-ramsey-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 10, "r": 5, "s": 3, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l2-s7/solution/solve.sh b/tasks/construct-mc-ramsey-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6136e06fcac86ee8e770feb58301aad579977cff --- /dev/null +++ b/tasks/construct-mc-ramsey-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' +{"colors": [0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-ramsey-l2-s7/tests/check.py b/tasks/construct-mc-ramsey-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l2-s7/tests/check.py @@ -0,0 +1,31 @@ +"""Two-colouring of the edges of K_n with no colour-0 K_r and no colour-1 K_s (MathConstraint ramsey, +CC-BY-4.0). Adapted from pilot/grader.py check_ramsey; adds the optional fixed edge colours.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, r, s = inst["n"], inst["r"], inst["s"] + edges = list(itertools.combinations(range(n), 2)) + col = int_list(ans.get("colors"), len(edges), 0, 1, "colors") + for name, i, v in inst.get("fixed", []): + if col[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + c = {e: col[i] for i, e in enumerate(edges)} + for k, colour in ((r, 0), (s, 1)): + adj = {v: {u for u in range(n) if u != v and c[(min(u, v), max(u, v))] == colour} for v in range(n)} + + def grow(size, cand): + if size == k: + return True + if size + len(cand) < k: + return False + for v in sorted(cand): + if grow(size + 1, {u for u in cand if u > v} & adj[v]): + return True + return False + + if grow(0, set(range(n))): + raise Invalid(f"monochromatic K_{k} in colour {colour}") + return None, {} diff --git a/tasks/construct-mc-ramsey-l2-s7/tests/instance.json b/tasks/construct-mc-ramsey-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..25e862fb8abe75fac486d2ca7b979b2bf5c3a5f1 --- /dev/null +++ b/tasks/construct-mc-ramsey-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 10, "r": 5, "s": 3, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l2-s7/tests/run.py b/tasks/construct-mc-ramsey-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-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-mc-ramsey-l2-s7/tests/test.sh b/tasks/construct-mc-ramsey-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-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-mc-ramsey-l6-s1/environment/Dockerfile b/tasks/construct-mc-ramsey-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-l6-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-ramsey-l6-s1/environment/instance.json b/tasks/construct-mc-ramsey-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bf97641f00578c42c66231b0587a159d73cd6fe0 --- /dev/null +++ b/tasks/construct-mc-ramsey-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 37, "r": 5, "s": 5, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l6-s1/solution/solve.sh b/tasks/construct-mc-ramsey-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a8f835cd336e44fc77e85b1d0113c6dbdbb8c26f --- /dev/null +++ b/tasks/construct-mc-ramsey-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' +{"colors": [0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-ramsey-l6-s1/tests/check.py b/tasks/construct-mc-ramsey-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l6-s1/tests/check.py @@ -0,0 +1,31 @@ +"""Two-colouring of the edges of K_n with no colour-0 K_r and no colour-1 K_s (MathConstraint ramsey, +CC-BY-4.0). Adapted from pilot/grader.py check_ramsey; adds the optional fixed edge colours.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, r, s = inst["n"], inst["r"], inst["s"] + edges = list(itertools.combinations(range(n), 2)) + col = int_list(ans.get("colors"), len(edges), 0, 1, "colors") + for name, i, v in inst.get("fixed", []): + if col[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + c = {e: col[i] for i, e in enumerate(edges)} + for k, colour in ((r, 0), (s, 1)): + adj = {v: {u for u in range(n) if u != v and c[(min(u, v), max(u, v))] == colour} for v in range(n)} + + def grow(size, cand): + if size == k: + return True + if size + len(cand) < k: + return False + for v in sorted(cand): + if grow(size + 1, {u for u in cand if u > v} & adj[v]): + return True + return False + + if grow(0, set(range(n))): + raise Invalid(f"monochromatic K_{k} in colour {colour}") + return None, {} diff --git a/tasks/construct-mc-ramsey-l6-s1/tests/instance.json b/tasks/construct-mc-ramsey-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bf97641f00578c42c66231b0587a159d73cd6fe0 --- /dev/null +++ b/tasks/construct-mc-ramsey-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 37, "r": 5, "s": 5, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l6-s1/tests/run.py b/tasks/construct-mc-ramsey-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-l6-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-ramsey-l6-s1/tests/test.sh b/tasks/construct-mc-ramsey-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-l6-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-social-golfers-l3-s3/environment/Dockerfile b/tasks/construct-mc-social-golfers-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-social-golfers-l3-s3/environment/instance.json b/tasks/construct-mc-social-golfers-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b9aee2f83429e5407625342198b7611af8ffce12 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"n_groups": 9, "group_size": 4, "n_weeks": 6, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l3-s3/solution/solve.sh b/tasks/construct-mc-social-golfers-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cd0501e03a51a593d2dcf62bd169753948221267 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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' +{"schedule": [[0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8], [8, 5, 3, 4, 7, 6, 0, 1, 8, 7, 1, 0, 8, 2, 0, 3, 6, 5, 2, 1, 7, 2, 0, 4, 7, 6, 2, 1, 8, 4, 5, 3, 6, 3, 4, 5], [1, 2, 0, 4, 7, 0, 5, 2, 2, 1, 0, 8, 4, 1, 3, 2, 8, 7, 5, 6, 5, 6, 7, 3, 3, 6, 4, 8, 0, 7, 1, 8, 3, 4, 6, 5], [2, 1, 3, 0, 2, 0, 6, 5, 6, 4, 8, 3, 8, 7, 5, 4, 2, 3, 1, 0, 0, 2, 1, 3, 8, 4, 5, 7, 7, 6, 8, 1, 6, 7, 5, 4], [0, 1, 2, 3, 1, 0, 2, 3, 4, 2, 1, 0, 2, 1, 4, 0, 3, 4, 5, 6, 4, 7, 3, 8, 5, 8, 6, 7, 5, 7, 8, 6, 6, 8, 5, 7], [0, 1, 2, 3, 2, 1, 0, 4, 2, 1, 0, 3, 4, 3, 1, 5, 5, 0, 2, 6, 5, 4, 8, 7, 6, 3, 7, 8, 7, 6, 8, 4, 8, 6, 5, 7]]} +RLMATH_EOF diff --git a/tasks/construct-mc-social-golfers-l3-s3/tests/check.py b/tasks/construct-mc-social-golfers-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..73977815b7b6094a8491075b6dc2ae1293e44930 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l3-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-l3-s3/tests/instance.json b/tasks/construct-mc-social-golfers-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b9aee2f83429e5407625342198b7611af8ffce12 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"n_groups": 9, "group_size": 4, "n_weeks": 6, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l3-s3/tests/run.py b/tasks/construct-mc-social-golfers-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-social-golfers-l3-s3/tests/test.sh b/tasks/construct-mc-social-golfers-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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-vertex-cover-l3-s2/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l3-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-vertex-cover-l3-s2/environment/instance.json b/tasks/construct-mc-vertex-cover-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..896e2e07d64e386bd8fa00c1b3e38fe949dd28b2 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 45, "k": 30, "edges": [[0, 13], [0, 18], [0, 29], [0, 31], [0, 32], [0, 38], [1, 4], [1, 5], [1, 6], [1, 9], [1, 11], [1, 12], [1, 16], [1, 24], [1, 26], [1, 27], [1, 42], [2, 3], [2, 4], [2, 16], [2, 24], [2, 26], [2, 33], [2, 41], [3, 15], [3, 16], [3, 18], [3, 25], [3, 31], [3, 33], [3, 35], [3, 38], [3, 42], [4, 25], [4, 26], [4, 32], [4, 40], [5, 6], [5, 15], [5, 26], [5, 36], [5, 39], [5, 40], [5, 42], [6, 8], [6, 13], [6, 16], [6, 24], [6, 29], [6, 31], [6, 41], [6, 42], [7, 9], [7, 25], [7, 33], [7, 34], [7, 39], [7, 41], [8, 17], [8, 23], [8, 26], [9, 11], [9, 14], [9, 37], [9, 38], [9, 39], [9, 43], [10, 14], [10, 19], [10, 32], [11, 19], [11, 37], [12, 18], [12, 22], [12, 26], [12, 29], [12, 36], [12, 38], [12, 39], [12, 43], [13, 21], [13, 27], [13, 29], [13, 34], [13, 38], [15, 18], [15, 19], [15, 24], [15, 26], [15, 34], [15, 35], [15, 40], [15, 44], [17, 25], [17, 33], [17, 43], [18, 21], [18, 24], [18, 29], [18, 33], [18, 38], [18, 39], [19, 27], [20, 31], [20, 33], [20, 39], [20, 44], [21, 39], [21, 44], [22, 28], [22, 32], [22, 37], [22, 41], [23, 26], [23, 27], [23, 30], [23, 33], [23, 36], [23, 41], [23, 42], [24, 30], [24, 44], [25, 31], [25, 33], [25, 35], [25, 40], [25, 44], [26, 28], [26, 31], [26, 38], [27, 28], [27, 29], [27, 31], [27, 34], [27, 41], [28, 31], [29, 35], [29, 37], [29, 43], [30, 32], [30, 37], [30, 38], [30, 39], [31, 32], [31, 33], [31, 36], [31, 37], [33, 35], [33, 37], [33, 38], [33, 42], [34, 37], [34, 39], [35, 40], [35, 42], [36, 40], [36, 42], [37, 40], [38, 40], [38, 42], [38, 43], [38, 44], [39, 43], [40, 41]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l3-s2/solution/solve.sh b/tasks/construct-mc-vertex-cover-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..20be0e26426f5ca1743fbb9df9dc8d953139d8b5 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [0, 1, 2, 3, 6, 9, 12, 14, 15, 17, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 32, 33, 34, 36, 37, 38, 39, 40, 41, 42]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l3-s2/tests/check.py b/tasks/construct-mc-vertex-cover-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l3-s2/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l3-s2/tests/instance.json b/tasks/construct-mc-vertex-cover-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..896e2e07d64e386bd8fa00c1b3e38fe949dd28b2 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 45, "k": 30, "edges": [[0, 13], [0, 18], [0, 29], [0, 31], [0, 32], [0, 38], [1, 4], [1, 5], [1, 6], [1, 9], [1, 11], [1, 12], [1, 16], [1, 24], [1, 26], [1, 27], [1, 42], [2, 3], [2, 4], [2, 16], [2, 24], [2, 26], [2, 33], [2, 41], [3, 15], [3, 16], [3, 18], [3, 25], [3, 31], [3, 33], [3, 35], [3, 38], [3, 42], [4, 25], [4, 26], [4, 32], [4, 40], [5, 6], [5, 15], [5, 26], [5, 36], [5, 39], [5, 40], [5, 42], [6, 8], [6, 13], [6, 16], [6, 24], [6, 29], [6, 31], [6, 41], [6, 42], [7, 9], [7, 25], [7, 33], [7, 34], [7, 39], [7, 41], [8, 17], [8, 23], [8, 26], [9, 11], [9, 14], [9, 37], [9, 38], [9, 39], [9, 43], [10, 14], [10, 19], [10, 32], [11, 19], [11, 37], [12, 18], [12, 22], [12, 26], [12, 29], [12, 36], [12, 38], [12, 39], [12, 43], [13, 21], [13, 27], [13, 29], [13, 34], [13, 38], [15, 18], [15, 19], [15, 24], [15, 26], [15, 34], [15, 35], [15, 40], [15, 44], [17, 25], [17, 33], [17, 43], [18, 21], [18, 24], [18, 29], [18, 33], [18, 38], [18, 39], [19, 27], [20, 31], [20, 33], [20, 39], [20, 44], [21, 39], [21, 44], [22, 28], [22, 32], [22, 37], [22, 41], [23, 26], [23, 27], [23, 30], [23, 33], [23, 36], [23, 41], [23, 42], [24, 30], [24, 44], [25, 31], [25, 33], [25, 35], [25, 40], [25, 44], [26, 28], [26, 31], [26, 38], [27, 28], [27, 29], [27, 31], [27, 34], [27, 41], [28, 31], [29, 35], [29, 37], [29, 43], [30, 32], [30, 37], [30, 38], [30, 39], [31, 32], [31, 33], [31, 36], [31, 37], [33, 35], [33, 37], [33, 38], [33, 42], [34, 37], [34, 39], [35, 40], [35, 42], [36, 40], [36, 42], [37, 40], [38, 40], [38, 42], [38, 43], [38, 44], [39, 43], [40, 41]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l3-s2/tests/run.py b/tasks/construct-mc-vertex-cover-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l3-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-vertex-cover-l3-s2/tests/test.sh b/tasks/construct-mc-vertex-cover-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l3-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-vertex-cover-l3-s5/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l3-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l3-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-vertex-cover-l3-s5/environment/instance.json b/tasks/construct-mc-vertex-cover-l3-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..65195b4a5cb9ea0c8ddecbc22736b5d399e3f165 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l3-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 45, "k": 30, "edges": [[0, 12], [0, 17], [0, 19], [0, 43], [1, 5], [1, 10], [1, 12], [1, 19], [1, 20], [1, 21], [1, 24], [1, 28], [1, 30], [1, 39], [1, 40], [1, 43], [2, 10], [2, 12], [2, 14], [2, 17], [2, 18], [2, 25], [2, 30], [2, 36], [2, 37], [2, 40], [3, 18], [3, 22], [3, 32], [3, 35], [3, 39], [3, 43], [4, 14], [4, 15], [4, 17], [4, 24], [4, 27], [4, 33], [4, 41], [4, 43], [5, 9], [5, 18], [5, 34], [5, 35], [5, 39], [5, 42], [6, 7], [6, 19], [6, 23], [6, 24], [6, 25], [6, 40], [7, 16], [7, 18], [7, 19], [7, 20], [7, 29], [7, 30], [7, 32], [7, 33], [7, 42], [8, 32], [8, 33], [9, 16], [9, 17], [9, 26], [9, 27], [9, 33], [9, 36], [10, 27], [10, 34], [10, 35], [11, 13], [11, 24], [11, 26], [11, 27], [11, 34], [11, 40], [11, 44], [12, 18], [12, 22], [12, 24], [12, 26], [12, 28], [12, 35], [12, 39], [12, 41], [13, 15], [13, 18], [13, 27], [13, 29], [13, 35], [13, 39], [13, 40], [14, 16], [14, 17], [14, 21], [14, 22], [14, 28], [14, 37], [14, 39], [14, 44], [15, 26], [15, 27], [15, 29], [15, 32], [15, 35], [15, 36], [15, 41], [16, 23], [16, 33], [16, 37], [17, 22], [17, 27], [17, 29], [17, 40], [17, 43], [17, 44], [18, 25], [18, 28], [18, 29], [18, 35], [18, 37], [19, 21], [19, 27], [19, 29], [19, 37], [19, 41], [19, 43], [20, 29], [20, 30], [20, 35], [21, 42], [21, 44], [22, 34], [22, 40], [22, 43], [23, 27], [23, 30], [23, 34], [23, 41], [24, 25], [24, 26], [24, 38], [24, 42], [25, 41], [25, 42], [26, 27], [26, 32], [26, 33], [26, 41], [26, 42], [26, 43], [27, 28], [27, 30], [27, 34], [27, 42], [28, 30], [28, 34], [29, 35], [29, 36], [29, 42], [30, 32], [31, 33], [31, 34], [31, 35], [31, 38], [31, 41], [32, 36], [32, 37], [32, 42], [33, 35], [33, 37], [33, 39], [33, 43], [34, 39], [34, 42], [34, 43], [35, 36], [35, 38], [36, 38], [38, 40], [38, 43], [39, 40], [39, 41], [40, 41], [42, 44], [43, 44]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l3-s5/solution/solve.sh b/tasks/construct-mc-vertex-cover-l3-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..410cab4d4acc4b06886257eab368260dac115d1b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l3-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"cover": [1, 2, 3, 6, 7, 9, 11, 12, 14, 15, 16, 17, 18, 19, 24, 27, 29, 30, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 44]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l3-s5/tests/check.py b/tasks/construct-mc-vertex-cover-l3-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l3-s5/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l3-s5/tests/instance.json b/tasks/construct-mc-vertex-cover-l3-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..65195b4a5cb9ea0c8ddecbc22736b5d399e3f165 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l3-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 45, "k": 30, "edges": [[0, 12], [0, 17], [0, 19], [0, 43], [1, 5], [1, 10], [1, 12], [1, 19], [1, 20], [1, 21], [1, 24], [1, 28], [1, 30], [1, 39], [1, 40], [1, 43], [2, 10], [2, 12], [2, 14], [2, 17], [2, 18], [2, 25], [2, 30], [2, 36], [2, 37], [2, 40], [3, 18], [3, 22], [3, 32], [3, 35], [3, 39], [3, 43], [4, 14], [4, 15], [4, 17], [4, 24], [4, 27], [4, 33], [4, 41], [4, 43], [5, 9], [5, 18], [5, 34], [5, 35], [5, 39], [5, 42], [6, 7], [6, 19], [6, 23], [6, 24], [6, 25], [6, 40], [7, 16], [7, 18], [7, 19], [7, 20], [7, 29], [7, 30], [7, 32], [7, 33], [7, 42], [8, 32], [8, 33], [9, 16], [9, 17], [9, 26], [9, 27], [9, 33], [9, 36], [10, 27], [10, 34], [10, 35], [11, 13], [11, 24], [11, 26], [11, 27], [11, 34], [11, 40], [11, 44], [12, 18], [12, 22], [12, 24], [12, 26], [12, 28], [12, 35], [12, 39], [12, 41], [13, 15], [13, 18], [13, 27], [13, 29], [13, 35], [13, 39], [13, 40], [14, 16], [14, 17], [14, 21], [14, 22], [14, 28], [14, 37], [14, 39], [14, 44], [15, 26], [15, 27], [15, 29], [15, 32], [15, 35], [15, 36], [15, 41], [16, 23], [16, 33], [16, 37], [17, 22], [17, 27], [17, 29], [17, 40], [17, 43], [17, 44], [18, 25], [18, 28], [18, 29], [18, 35], [18, 37], [19, 21], [19, 27], [19, 29], [19, 37], [19, 41], [19, 43], [20, 29], [20, 30], [20, 35], [21, 42], [21, 44], [22, 34], [22, 40], [22, 43], [23, 27], [23, 30], [23, 34], [23, 41], [24, 25], [24, 26], [24, 38], [24, 42], [25, 41], [25, 42], [26, 27], [26, 32], [26, 33], [26, 41], [26, 42], [26, 43], [27, 28], [27, 30], [27, 34], [27, 42], [28, 30], [28, 34], [29, 35], [29, 36], [29, 42], [30, 32], [31, 33], [31, 34], [31, 35], [31, 38], [31, 41], [32, 36], [32, 37], [32, 42], [33, 35], [33, 37], [33, 39], [33, 43], [34, 39], [34, 42], [34, 43], [35, 36], [35, 38], [36, 38], [38, 40], [38, 43], [39, 40], [39, 41], [40, 41], [42, 44], [43, 44]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l3-s5/tests/run.py b/tasks/construct-mc-vertex-cover-l3-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l3-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-vertex-cover-l3-s5/tests/test.sh b/tasks/construct-mc-vertex-cover-l3-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l3-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-3col-l6-s3/environment/Dockerfile b/tasks/construct-nppc-3col-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-3col-l6-s3/environment/instance.json b/tasks/construct-nppc-3col-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0913e77e2bc20e5cec0bbd8dc3d85bbcb4faaedc --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 120, "edges": [[0, 11], [0, 16], [0, 20], [0, 68], [0, 85], [0, 118], [1, 19], [1, 30], [1, 33], [1, 40], [1, 45], [1, 53], [1, 64], [1, 70], [1, 81], [1, 93], [1, 103], [1, 105], [1, 117], [2, 16], [2, 27], [2, 33], [2, 45], [2, 47], [2, 64], [2, 71], [2, 87], [2, 99], [2, 119], [3, 8], [3, 9], [3, 14], [3, 63], [3, 68], [3, 69], [3, 75], [3, 83], [3, 116], [4, 12], [4, 33], [4, 75], [4, 78], [4, 99], [4, 110], [5, 10], [5, 59], [5, 79], [5, 90], [5, 98], [5, 117], [6, 9], [6, 25], [6, 28], [6, 36], [6, 38], [6, 72], [6, 84], [6, 86], [6, 94], [6, 99], [6, 108], [6, 112], [7, 30], [7, 37], [7, 52], [7, 57], [7, 58], [7, 77], [7, 85], [7, 86], [7, 115], [8, 11], [8, 23], [8, 26], [8, 35], [8, 44], [8, 61], [8, 68], [8, 81], [8, 90], [8, 91], [8, 92], [8, 93], [8, 98], [8, 102], [9, 20], [9, 29], [9, 73], [9, 91], [9, 95], [9, 112], [9, 117], [9, 119], [10, 19], [10, 24], [10, 26], [10, 29], [10, 36], [10, 45], [10, 47], [10, 64], [10, 67], [11, 15], [11, 31], [11, 38], [11, 72], [11, 74], [11, 79], [11, 82], [11, 111], [12, 18], [12, 23], [12, 30], [12, 39], [12, 44], [12, 45], [12, 55], [12, 58], [12, 69], [12, 70], [12, 97], [12, 118], [13, 15], [13, 16], [13, 55], [13, 59], [13, 69], [14, 21], [14, 29], [14, 36], [14, 93], [14, 98], [14, 113], [14, 116], [15, 48], [15, 85], [16, 24], [16, 42], [16, 45], [16, 81], [16, 91], [16, 100], [16, 107], [17, 18], [17, 19], [17, 33], [17, 52], [17, 56], [17, 59], [17, 66], [17, 67], [17, 77], [17, 100], [17, 115], [18, 60], [18, 67], [18, 90], [18, 111], [18, 118], [19, 20], [19, 58], [19, 72], [19, 99], [20, 24], [20, 66], [20, 73], [20, 76], [20, 96], [20, 107], [21, 31], [21, 68], [21, 70], [22, 67], [22, 102], [22, 104], [22, 115], [22, 116], [22, 118], [23, 49], [23, 59], [23, 61], [23, 71], [23, 83], [23, 89], [23, 101], [23, 113], [24, 43], [24, 49], [24, 111], [25, 27], [25, 73], [25, 75], [25, 95], [25, 112], [25, 115], [26, 31], [26, 38], [26, 70], [26, 72], [27, 62], [27, 67], [27, 79], [27, 106], [27, 118], [28, 32], [28, 37], [28, 45], [28, 50], [28, 53], [28, 67], [28, 108], [29, 61], [29, 70], [29, 116], [30, 43], [30, 45], [30, 64], [30, 65], [30, 81], [30, 90], [30, 93], [30, 102], [31, 55], [31, 63], [31, 65], [31, 79], [31, 81], [31, 84], [31, 96], [31, 106], [31, 109], [31, 115], [32, 33], [32, 47], [32, 60], [32, 68], [32, 116], [33, 46], [33, 51], [33, 74], [33, 80], [33, 101], [34, 35], [34, 42], [34, 44], [34, 54], [34, 75], [34, 94], [34, 119], [35, 39], [35, 55], [35, 62], [35, 83], [35, 97], [35, 98], [36, 45], [36, 53], [36, 55], [36, 83], [36, 86], [36, 100], [37, 53], [37, 98], [38, 54], [38, 55], [38, 62], [38, 79], [38, 81], [38, 85], [38, 97], [38, 105], [40, 46], [40, 64], [40, 85], [40, 92], [40, 101], [41, 66], [41, 67], [41, 73], [41, 83], [41, 93], [41, 98], [41, 103], [41, 118], [42, 49], [42, 71], [42, 74], [42, 80], [43, 45], [43, 48], [43, 82], [43, 85], [43, 103], [44, 52], [44, 74], [44, 88], [45, 60], [45, 78], [45, 83], [45, 86], [46, 51], [46, 54], [46, 56], [46, 57], [46, 62], [46, 67], [46, 81], [47, 74], [47, 75], [47, 82], [47, 99], [47, 108], [48, 57], [48, 64], [48, 67], [48, 91], [48, 95], [48, 99], [48, 110], [49, 58], [49, 65], [49, 69], [49, 70], [49, 77], [49, 82], [49, 90], [49, 96], [50, 119], [51, 64], [51, 67], [51, 97], [51, 106], [51, 112], [51, 117], [52, 57], [52, 96], [52, 114], [52, 115], [53, 58], [53, 75], [53, 78], [53, 79], [53, 99], [53, 100], [53, 102], [54, 80], [54, 84], [55, 57], [55, 78], [55, 104], [55, 110], [55, 115], [55, 119], [56, 68], [56, 76], [56, 101], [57, 59], [57, 62], [57, 78], [57, 82], [58, 67], [58, 87], [58, 96], [58, 106], [58, 109], [58, 117], [59, 101], [59, 102], [59, 106], [59, 109], [59, 112], [59, 117], [60, 62], [60, 83], [60, 85], [60, 103], [60, 108], [60, 115], [61, 62], [61, 66], [61, 83], [62, 67], [62, 94], [62, 101], [62, 104], [62, 114], [63, 97], [63, 104], [63, 109], [64, 84], [65, 76], [65, 79], [65, 99], [65, 100], [65, 116], [66, 76], [66, 83], [66, 89], [66, 94], [66, 101], [66, 104], [66, 113], [67, 72], [67, 75], [67, 78], [67, 99], [67, 100], [68, 84], [68, 86], [68, 93], [68, 98], [68, 105], [69, 87], [69, 91], [69, 92], [69, 95], [69, 118], [69, 119], [71, 90], [71, 96], [71, 108], [72, 85], [72, 98], [73, 88], [73, 100], [74, 96], [74, 97], [74, 109], [74, 119], [75, 79], [76, 94], [76, 96], [76, 101], [76, 112], [76, 119], [77, 101], [77, 108], [77, 110], [78, 98], [78, 103], [78, 107], [79, 97], [79, 106], [79, 116], [80, 81], [80, 97], [80, 106], [80, 108], [81, 103], [81, 110], [81, 113], [82, 101], [83, 91], [83, 94], [83, 101], [83, 111], [83, 116], [83, 118], [84, 87], [84, 89], [85, 99], [86, 99], [86, 117], [87, 88], [87, 97], [87, 98], [88, 94], [89, 92], [89, 95], [89, 98], [90, 101], [90, 110], [91, 104], [93, 107], [93, 110], [93, 116], [94, 109], [94, 118], [95, 99], [95, 110], [97, 104], [97, 114], [98, 107], [98, 116], [101, 106], [101, 108], [104, 106], [105, 110], [105, 116], [106, 119], [107, 111], [107, 112], [107, 118], [108, 112], [108, 119], [109, 113], [110, 115], [111, 118], [112, 118], [113, 118]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l6-s3/solution/solve.sh b/tasks/construct-nppc-3col-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ea650d0b3e1e5b9ffc828304e0dd96a1f24ec134 --- /dev/null +++ b/tasks/construct-nppc-3col-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' +{"coloring": [1, 0, 1, 2, 1, 0, 2, 0, 1, 1, 1, 2, 0, 2, 1, 0, 0, 0, 1, 2, 0, 2, 1, 2, 2, 1, 2, 0, 0, 2, 1, 0, 1, 2, 1, 0, 0, 1, 0, 1, 1, 0, 2, 0, 2, 2, 0, 2, 1, 0, 1, 1, 1, 2, 2, 1, 2, 2, 1, 1, 0, 0, 1, 1, 2, 2, 2, 2, 0, 1, 1, 0, 0, 2, 1, 0, 1, 2, 0, 1, 0, 2, 1, 1, 1, 2, 1, 0, 1, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 0, 1, 0, 0, 1, 0, 1, 2, 1, 1, 2, 0, 0, 0, 0, 0, 2, 0, 2, 2, 0]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l6-s3/tests/check.py b/tasks/construct-nppc-3col-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s3/tests/check.py @@ -0,0 +1,12 @@ +"""Proper 3-colouring of a given graph. Accepts any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["num_nodes"] + # upstream NPPC verifier skips the range/length check, so an all-distinct colouring passed it + c = int_list(ans.get("coloring"), n, 0, 2, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-nppc-3col-l6-s3/tests/instance.json b/tasks/construct-nppc-3col-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0913e77e2bc20e5cec0bbd8dc3d85bbcb4faaedc --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 120, "edges": [[0, 11], [0, 16], [0, 20], [0, 68], [0, 85], [0, 118], [1, 19], [1, 30], [1, 33], [1, 40], [1, 45], [1, 53], [1, 64], [1, 70], [1, 81], [1, 93], [1, 103], [1, 105], [1, 117], [2, 16], [2, 27], [2, 33], [2, 45], [2, 47], [2, 64], [2, 71], [2, 87], [2, 99], [2, 119], [3, 8], [3, 9], [3, 14], [3, 63], [3, 68], [3, 69], [3, 75], [3, 83], [3, 116], [4, 12], [4, 33], [4, 75], [4, 78], [4, 99], [4, 110], [5, 10], [5, 59], [5, 79], [5, 90], [5, 98], [5, 117], [6, 9], [6, 25], [6, 28], [6, 36], [6, 38], [6, 72], [6, 84], [6, 86], [6, 94], [6, 99], [6, 108], [6, 112], [7, 30], [7, 37], [7, 52], [7, 57], [7, 58], [7, 77], [7, 85], [7, 86], [7, 115], [8, 11], [8, 23], [8, 26], [8, 35], [8, 44], [8, 61], [8, 68], [8, 81], [8, 90], [8, 91], [8, 92], [8, 93], [8, 98], [8, 102], [9, 20], [9, 29], [9, 73], [9, 91], [9, 95], [9, 112], [9, 117], [9, 119], [10, 19], [10, 24], [10, 26], [10, 29], [10, 36], [10, 45], [10, 47], [10, 64], [10, 67], [11, 15], [11, 31], [11, 38], [11, 72], [11, 74], [11, 79], [11, 82], [11, 111], [12, 18], [12, 23], [12, 30], [12, 39], [12, 44], [12, 45], [12, 55], [12, 58], [12, 69], [12, 70], [12, 97], [12, 118], [13, 15], [13, 16], [13, 55], [13, 59], [13, 69], [14, 21], [14, 29], [14, 36], [14, 93], [14, 98], [14, 113], [14, 116], [15, 48], [15, 85], [16, 24], [16, 42], [16, 45], [16, 81], [16, 91], [16, 100], [16, 107], [17, 18], [17, 19], [17, 33], [17, 52], [17, 56], [17, 59], [17, 66], [17, 67], [17, 77], [17, 100], [17, 115], [18, 60], [18, 67], [18, 90], [18, 111], [18, 118], [19, 20], [19, 58], [19, 72], [19, 99], [20, 24], [20, 66], [20, 73], [20, 76], [20, 96], [20, 107], [21, 31], [21, 68], [21, 70], [22, 67], [22, 102], [22, 104], [22, 115], [22, 116], [22, 118], [23, 49], [23, 59], [23, 61], [23, 71], [23, 83], [23, 89], [23, 101], [23, 113], [24, 43], [24, 49], [24, 111], [25, 27], [25, 73], [25, 75], [25, 95], [25, 112], [25, 115], [26, 31], [26, 38], [26, 70], [26, 72], [27, 62], [27, 67], [27, 79], [27, 106], [27, 118], [28, 32], [28, 37], [28, 45], [28, 50], [28, 53], [28, 67], [28, 108], [29, 61], [29, 70], [29, 116], [30, 43], [30, 45], [30, 64], [30, 65], [30, 81], [30, 90], [30, 93], [30, 102], [31, 55], [31, 63], [31, 65], [31, 79], [31, 81], [31, 84], [31, 96], [31, 106], [31, 109], [31, 115], [32, 33], [32, 47], [32, 60], [32, 68], [32, 116], [33, 46], [33, 51], [33, 74], [33, 80], [33, 101], [34, 35], [34, 42], [34, 44], [34, 54], [34, 75], [34, 94], [34, 119], [35, 39], [35, 55], [35, 62], [35, 83], [35, 97], [35, 98], [36, 45], [36, 53], [36, 55], [36, 83], [36, 86], [36, 100], [37, 53], [37, 98], [38, 54], [38, 55], [38, 62], [38, 79], [38, 81], [38, 85], [38, 97], [38, 105], [40, 46], [40, 64], [40, 85], [40, 92], [40, 101], [41, 66], [41, 67], [41, 73], [41, 83], [41, 93], [41, 98], [41, 103], [41, 118], [42, 49], [42, 71], [42, 74], [42, 80], [43, 45], [43, 48], [43, 82], [43, 85], [43, 103], [44, 52], [44, 74], [44, 88], [45, 60], [45, 78], [45, 83], [45, 86], [46, 51], [46, 54], [46, 56], [46, 57], [46, 62], [46, 67], [46, 81], [47, 74], [47, 75], [47, 82], [47, 99], [47, 108], [48, 57], [48, 64], [48, 67], [48, 91], [48, 95], [48, 99], [48, 110], [49, 58], [49, 65], [49, 69], [49, 70], [49, 77], [49, 82], [49, 90], [49, 96], [50, 119], [51, 64], [51, 67], [51, 97], [51, 106], [51, 112], [51, 117], [52, 57], [52, 96], [52, 114], [52, 115], [53, 58], [53, 75], [53, 78], [53, 79], [53, 99], [53, 100], [53, 102], [54, 80], [54, 84], [55, 57], [55, 78], [55, 104], [55, 110], [55, 115], [55, 119], [56, 68], [56, 76], [56, 101], [57, 59], [57, 62], [57, 78], [57, 82], [58, 67], [58, 87], [58, 96], [58, 106], [58, 109], [58, 117], [59, 101], [59, 102], [59, 106], [59, 109], [59, 112], [59, 117], [60, 62], [60, 83], [60, 85], [60, 103], [60, 108], [60, 115], [61, 62], [61, 66], [61, 83], [62, 67], [62, 94], [62, 101], [62, 104], [62, 114], [63, 97], [63, 104], [63, 109], [64, 84], [65, 76], [65, 79], [65, 99], [65, 100], [65, 116], [66, 76], [66, 83], [66, 89], [66, 94], [66, 101], [66, 104], [66, 113], [67, 72], [67, 75], [67, 78], [67, 99], [67, 100], [68, 84], [68, 86], [68, 93], [68, 98], [68, 105], [69, 87], [69, 91], [69, 92], [69, 95], [69, 118], [69, 119], [71, 90], [71, 96], [71, 108], [72, 85], [72, 98], [73, 88], [73, 100], [74, 96], [74, 97], [74, 109], [74, 119], [75, 79], [76, 94], [76, 96], [76, 101], [76, 112], [76, 119], [77, 101], [77, 108], [77, 110], [78, 98], [78, 103], [78, 107], [79, 97], [79, 106], [79, 116], [80, 81], [80, 97], [80, 106], [80, 108], [81, 103], [81, 110], [81, 113], [82, 101], [83, 91], [83, 94], [83, 101], [83, 111], [83, 116], [83, 118], [84, 87], [84, 89], [85, 99], [86, 99], [86, 117], [87, 88], [87, 97], [87, 98], [88, 94], [89, 92], [89, 95], [89, 98], [90, 101], [90, 110], [91, 104], [93, 107], [93, 110], [93, 116], [94, 109], [94, 118], [95, 99], [95, 110], [97, 104], [97, 114], [98, 107], [98, 116], [101, 106], [101, 108], [104, 106], [105, 110], [105, 116], [106, 119], [107, 111], [107, 112], [107, 118], [108, 112], [108, 119], [109, 113], [110, 115], [111, 118], [112, 118], [113, 118]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l6-s3/tests/run.py b/tasks/construct-nppc-3col-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-3col-l6-s3/tests/test.sh b/tasks/construct-nppc-3col-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-3col-l6-s4/environment/Dockerfile b/tasks/construct-nppc-3col-l6-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-3col-l6-s4/environment/instance.json b/tasks/construct-nppc-3col-l6-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d84b179f69cd15cf995cfdb186c7a9b77dedd445 --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s4/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 120, "edges": [[0, 19], [0, 34], [0, 51], [0, 53], [0, 60], [0, 73], [0, 97], [0, 109], [1, 2], [1, 7], [1, 30], [1, 39], [1, 53], [1, 54], [1, 76], [1, 88], [1, 111], [1, 118], [2, 6], [2, 16], [2, 35], [2, 73], [2, 86], [2, 92], [2, 95], [3, 28], [3, 86], [3, 98], [3, 112], [4, 78], [4, 83], [4, 91], [4, 92], [5, 6], [5, 12], [5, 35], [5, 40], [5, 47], [5, 56], [5, 66], [5, 72], [5, 85], [5, 103], [5, 114], [5, 115], [6, 7], [6, 23], [6, 32], [6, 44], [6, 49], [6, 93], [6, 104], [6, 110], [7, 20], [7, 24], [7, 26], [7, 28], [7, 81], [7, 90], [7, 110], [7, 112], [8, 26], [8, 39], [8, 51], [8, 52], [8, 65], [8, 68], [8, 70], [8, 75], [8, 87], [8, 97], [9, 13], [9, 21], [9, 33], [9, 69], [9, 103], [9, 114], [10, 12], [10, 52], [10, 53], [10, 66], [10, 86], [10, 95], [10, 101], [11, 12], [11, 29], [11, 37], [11, 43], [11, 47], [11, 52], [11, 68], [11, 70], [11, 87], [11, 88], [11, 113], [12, 20], [12, 29], [12, 30], [12, 43], [12, 44], [12, 74], [12, 118], [13, 20], [13, 26], [13, 37], [13, 38], [13, 39], [13, 57], [13, 67], [13, 76], [13, 97], [13, 104], [14, 77], [14, 81], [14, 87], [14, 119], [15, 16], [15, 37], [15, 59], [15, 83], [15, 101], [15, 115], [16, 29], [16, 55], [16, 81], [16, 92], [16, 97], [16, 104], [16, 116], [17, 38], [17, 49], [17, 62], [17, 68], [17, 75], [17, 88], [17, 116], [18, 45], [18, 47], [18, 58], [18, 62], [18, 63], [18, 64], [18, 81], [18, 84], [18, 100], [18, 109], [19, 30], [19, 45], [19, 47], [19, 59], [19, 64], [19, 78], [19, 81], [19, 83], [19, 102], [19, 105], [19, 118], [20, 35], [20, 61], [20, 81], [20, 88], [20, 89], [20, 91], [20, 106], [20, 109], [20, 115], [21, 26], [21, 67], [21, 69], [21, 72], [21, 101], [21, 104], [21, 117], [22, 24], [22, 28], [22, 30], [22, 52], [22, 54], [23, 25], [23, 45], [23, 71], [23, 74], [23, 81], [23, 83], [23, 92], [23, 99], [23, 106], [24, 37], [24, 48], [24, 56], [24, 82], [24, 112], [24, 114], [25, 27], [25, 38], [25, 54], [25, 57], [25, 87], [25, 88], [25, 89], [25, 93], [25, 107], [26, 36], [26, 68], [26, 78], [26, 79], [26, 113], [27, 49], [27, 70], [27, 78], [27, 95], [28, 29], [28, 78], [28, 81], [28, 82], [28, 100], [29, 38], [29, 41], [29, 67], [29, 70], [29, 94], [29, 101], [29, 104], [30, 32], [30, 56], [30, 58], [30, 61], [30, 64], [30, 72], [30, 73], [30, 81], [30, 99], [30, 114], [31, 42], [31, 52], [31, 93], [31, 111], [32, 33], [32, 45], [32, 50], [32, 90], [32, 97], [32, 111], [33, 52], [33, 61], [33, 72], [33, 79], [33, 86], [33, 91], [33, 100], [34, 36], [34, 89], [34, 92], [34, 103], [35, 81], [35, 104], [35, 107], [36, 39], [36, 64], [36, 67], [36, 86], [36, 99], [37, 38], [37, 84], [37, 90], [37, 92], [37, 97], [37, 104], [37, 108], [37, 114], [38, 40], [38, 53], [38, 106], [38, 108], [38, 117], [39, 60], [39, 64], [39, 77], [39, 89], [39, 119], [40, 44], [40, 61], [40, 80], [40, 105], [40, 112], [40, 114], [41, 61], [41, 79], [41, 99], [41, 101], [42, 56], [42, 61], [42, 103], [42, 106], [42, 108], [43, 53], [43, 59], [43, 82], [43, 83], [43, 88], [43, 89], [43, 109], [44, 64], [44, 75], [44, 76], [44, 103], [44, 108], [44, 112], [44, 119], [45, 52], [45, 73], [45, 77], [45, 80], [45, 116], [45, 118], [46, 49], [46, 51], [46, 57], [46, 59], [46, 67], [46, 73], [46, 90], [46, 97], [47, 53], [47, 57], [47, 74], [47, 105], [48, 55], [48, 65], [48, 83], [48, 96], [48, 100], [48, 109], [49, 65], [49, 67], [49, 69], [50, 80], [50, 105], [51, 53], [51, 62], [51, 72], [51, 84], [51, 91], [51, 100], [51, 112], [51, 113], [51, 117], [52, 66], [52, 85], [52, 107], [53, 69], [53, 71], [53, 91], [53, 95], [53, 97], [53, 112], [54, 65], [54, 69], [54, 84], [54, 118], [55, 58], [55, 60], [55, 66], [55, 82], [55, 109], [55, 115], [56, 69], [56, 87], [57, 82], [57, 101], [57, 102], [57, 114], [57, 117], [58, 80], [58, 84], [58, 98], [59, 61], [59, 63], [59, 64], [59, 79], [59, 92], [59, 99], [59, 109], [60, 114], [60, 119], [61, 82], [61, 88], [61, 104], [61, 105], [62, 95], [62, 99], [62, 105], [62, 118], [63, 69], [63, 74], [63, 87], [63, 88], [63, 96], [63, 98], [63, 104], [63, 105], [63, 110], [64, 65], [64, 73], [64, 79], [64, 80], [64, 90], [64, 96], [65, 108], [65, 119], [66, 90], [66, 117], [67, 68], [67, 85], [67, 95], [67, 99], [67, 102], [68, 80], [68, 97], [68, 107], [69, 73], [69, 78], [69, 81], [69, 94], [70, 95], [70, 106], [70, 111], [70, 119], [71, 79], [71, 82], [71, 86], [71, 99], [71, 102], [71, 109], [71, 112], [71, 117], [72, 98], [73, 81], [73, 92], [73, 112], [73, 113], [74, 77], [74, 91], [74, 101], [75, 90], [75, 112], [76, 111], [77, 80], [78, 79], [78, 87], [78, 90], [78, 93], [79, 110], [79, 114], [80, 81], [80, 101], [81, 90], [82, 103], [83, 108], [83, 114], [83, 117], [84, 87], [84, 88], [84, 98], [85, 104], [85, 111], [86, 96], [87, 104], [87, 116], [88, 104], [88, 112], [89, 102], [89, 108], [89, 119], [91, 98], [92, 94], [92, 109], [93, 116], [94, 95], [96, 118], [96, 119], [97, 112], [98, 100], [98, 106], [101, 110], [102, 107], [103, 109], [103, 111], [104, 108], [105, 109], [105, 114], [105, 115], [105, 117], [106, 107], [108, 116], [111, 115], [111, 117], [116, 117], [116, 119], [117, 119]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l6-s4/solution/solve.sh b/tasks/construct-nppc-3col-l6-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fe5cd98204e54a89dff9b034554dba9b7b722cc0 --- /dev/null +++ b/tasks/construct-nppc-3col-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' +{"coloring": [1, 1, 0, 2, 2, 0, 1, 2, 1, 2, 0, 0, 2, 1, 0, 1, 2, 1, 0, 2, 0, 1, 1, 2, 0, 1, 0, 0, 0, 1, 0, 1, 2, 0, 0, 2, 2, 2, 0, 0, 2, 0, 0, 1, 0, 1, 1, 1, 1, 2, 1, 0, 2, 2, 2, 0, 1, 0, 2, 0, 2, 1, 2, 1, 1, 0, 1, 0, 2, 0, 2, 0, 2, 2, 0, 2, 2, 2, 1, 2, 0, 1, 2, 0, 1, 1, 1, 2, 2, 2, 0, 1, 1, 2, 2, 1, 2, 0, 0, 1, 2, 2, 1, 1, 0, 0, 1, 0, 1, 2, 0, 0, 1, 1, 1, 2, 0, 2, 0, 1]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l6-s4/tests/check.py b/tasks/construct-nppc-3col-l6-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s4/tests/check.py @@ -0,0 +1,12 @@ +"""Proper 3-colouring of a given graph. Accepts any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["num_nodes"] + # upstream NPPC verifier skips the range/length check, so an all-distinct colouring passed it + c = int_list(ans.get("coloring"), n, 0, 2, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-nppc-3col-l6-s4/tests/instance.json b/tasks/construct-nppc-3col-l6-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d84b179f69cd15cf995cfdb186c7a9b77dedd445 --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s4/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 120, "edges": [[0, 19], [0, 34], [0, 51], [0, 53], [0, 60], [0, 73], [0, 97], [0, 109], [1, 2], [1, 7], [1, 30], [1, 39], [1, 53], [1, 54], [1, 76], [1, 88], [1, 111], [1, 118], [2, 6], [2, 16], [2, 35], [2, 73], [2, 86], [2, 92], [2, 95], [3, 28], [3, 86], [3, 98], [3, 112], [4, 78], [4, 83], [4, 91], [4, 92], [5, 6], [5, 12], [5, 35], [5, 40], [5, 47], [5, 56], [5, 66], [5, 72], [5, 85], [5, 103], [5, 114], [5, 115], [6, 7], [6, 23], [6, 32], [6, 44], [6, 49], [6, 93], [6, 104], [6, 110], [7, 20], [7, 24], [7, 26], [7, 28], [7, 81], [7, 90], [7, 110], [7, 112], [8, 26], [8, 39], [8, 51], [8, 52], [8, 65], [8, 68], [8, 70], [8, 75], [8, 87], [8, 97], [9, 13], [9, 21], [9, 33], [9, 69], [9, 103], [9, 114], [10, 12], [10, 52], [10, 53], [10, 66], [10, 86], [10, 95], [10, 101], [11, 12], [11, 29], [11, 37], [11, 43], [11, 47], [11, 52], [11, 68], [11, 70], [11, 87], [11, 88], [11, 113], [12, 20], [12, 29], [12, 30], [12, 43], [12, 44], [12, 74], [12, 118], [13, 20], [13, 26], [13, 37], [13, 38], [13, 39], [13, 57], [13, 67], [13, 76], [13, 97], [13, 104], [14, 77], [14, 81], [14, 87], [14, 119], [15, 16], [15, 37], [15, 59], [15, 83], [15, 101], [15, 115], [16, 29], [16, 55], [16, 81], [16, 92], [16, 97], [16, 104], [16, 116], [17, 38], [17, 49], [17, 62], [17, 68], [17, 75], [17, 88], [17, 116], [18, 45], [18, 47], [18, 58], [18, 62], [18, 63], [18, 64], [18, 81], [18, 84], [18, 100], [18, 109], [19, 30], [19, 45], [19, 47], [19, 59], [19, 64], [19, 78], [19, 81], [19, 83], [19, 102], [19, 105], [19, 118], [20, 35], [20, 61], [20, 81], [20, 88], [20, 89], [20, 91], [20, 106], [20, 109], [20, 115], [21, 26], [21, 67], [21, 69], [21, 72], [21, 101], [21, 104], [21, 117], [22, 24], [22, 28], [22, 30], [22, 52], [22, 54], [23, 25], [23, 45], [23, 71], [23, 74], [23, 81], [23, 83], [23, 92], [23, 99], [23, 106], [24, 37], [24, 48], [24, 56], [24, 82], [24, 112], [24, 114], [25, 27], [25, 38], [25, 54], [25, 57], [25, 87], [25, 88], [25, 89], [25, 93], [25, 107], [26, 36], [26, 68], [26, 78], [26, 79], [26, 113], [27, 49], [27, 70], [27, 78], [27, 95], [28, 29], [28, 78], [28, 81], [28, 82], [28, 100], [29, 38], [29, 41], [29, 67], [29, 70], [29, 94], [29, 101], [29, 104], [30, 32], [30, 56], [30, 58], [30, 61], [30, 64], [30, 72], [30, 73], [30, 81], [30, 99], [30, 114], [31, 42], [31, 52], [31, 93], [31, 111], [32, 33], [32, 45], [32, 50], [32, 90], [32, 97], [32, 111], [33, 52], [33, 61], [33, 72], [33, 79], [33, 86], [33, 91], [33, 100], [34, 36], [34, 89], [34, 92], [34, 103], [35, 81], [35, 104], [35, 107], [36, 39], [36, 64], [36, 67], [36, 86], [36, 99], [37, 38], [37, 84], [37, 90], [37, 92], [37, 97], [37, 104], [37, 108], [37, 114], [38, 40], [38, 53], [38, 106], [38, 108], [38, 117], [39, 60], [39, 64], [39, 77], [39, 89], [39, 119], [40, 44], [40, 61], [40, 80], [40, 105], [40, 112], [40, 114], [41, 61], [41, 79], [41, 99], [41, 101], [42, 56], [42, 61], [42, 103], [42, 106], [42, 108], [43, 53], [43, 59], [43, 82], [43, 83], [43, 88], [43, 89], [43, 109], [44, 64], [44, 75], [44, 76], [44, 103], [44, 108], [44, 112], [44, 119], [45, 52], [45, 73], [45, 77], [45, 80], [45, 116], [45, 118], [46, 49], [46, 51], [46, 57], [46, 59], [46, 67], [46, 73], [46, 90], [46, 97], [47, 53], [47, 57], [47, 74], [47, 105], [48, 55], [48, 65], [48, 83], [48, 96], [48, 100], [48, 109], [49, 65], [49, 67], [49, 69], [50, 80], [50, 105], [51, 53], [51, 62], [51, 72], [51, 84], [51, 91], [51, 100], [51, 112], [51, 113], [51, 117], [52, 66], [52, 85], [52, 107], [53, 69], [53, 71], [53, 91], [53, 95], [53, 97], [53, 112], [54, 65], [54, 69], [54, 84], [54, 118], [55, 58], [55, 60], [55, 66], [55, 82], [55, 109], [55, 115], [56, 69], [56, 87], [57, 82], [57, 101], [57, 102], [57, 114], [57, 117], [58, 80], [58, 84], [58, 98], [59, 61], [59, 63], [59, 64], [59, 79], [59, 92], [59, 99], [59, 109], [60, 114], [60, 119], [61, 82], [61, 88], [61, 104], [61, 105], [62, 95], [62, 99], [62, 105], [62, 118], [63, 69], [63, 74], [63, 87], [63, 88], [63, 96], [63, 98], [63, 104], [63, 105], [63, 110], [64, 65], [64, 73], [64, 79], [64, 80], [64, 90], [64, 96], [65, 108], [65, 119], [66, 90], [66, 117], [67, 68], [67, 85], [67, 95], [67, 99], [67, 102], [68, 80], [68, 97], [68, 107], [69, 73], [69, 78], [69, 81], [69, 94], [70, 95], [70, 106], [70, 111], [70, 119], [71, 79], [71, 82], [71, 86], [71, 99], [71, 102], [71, 109], [71, 112], [71, 117], [72, 98], [73, 81], [73, 92], [73, 112], [73, 113], [74, 77], [74, 91], [74, 101], [75, 90], [75, 112], [76, 111], [77, 80], [78, 79], [78, 87], [78, 90], [78, 93], [79, 110], [79, 114], [80, 81], [80, 101], [81, 90], [82, 103], [83, 108], [83, 114], [83, 117], [84, 87], [84, 88], [84, 98], [85, 104], [85, 111], [86, 96], [87, 104], [87, 116], [88, 104], [88, 112], [89, 102], [89, 108], [89, 119], [91, 98], [92, 94], [92, 109], [93, 116], [94, 95], [96, 118], [96, 119], [97, 112], [98, 100], [98, 106], [101, 110], [102, 107], [103, 109], [103, 111], [104, 108], [105, 109], [105, 114], [105, 115], [105, 117], [106, 107], [108, 116], [111, 115], [111, 117], [116, 117], [116, 119], [117, 119]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l6-s4/tests/run.py b/tasks/construct-nppc-3col-l6-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-3col-l6-s4/tests/test.sh b/tasks/construct-nppc-3col-l6-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-l6-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-bandwidth-l1-s1/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-bandwidth-l1-s1/environment/instance.json b/tasks/construct-nppc-bandwidth-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5f745661ddf7ca3c8f0611aafbeb22dcaf578b82 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 6, "bandwidth": 3, "edges": [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l1-s1/solution/solve.sh b/tasks/construct-nppc-bandwidth-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cefe8c07e284668c5ead54349298f9a451e49e3b --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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' +{"layout": [0, 3, 5, 2, 1, 4]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l1-s1/tests/check.py b/tasks/construct-nppc-bandwidth-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s1/tests/check.py @@ -0,0 +1,14 @@ +"""Bandwidth <= b: layout must be a permutation of 0..n-1 with |p[u]-p[v]| <= b on every edge.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, b = inst["num_nodes"], inst["bandwidth"] + # upstream NPPC verifier compares sorted(layout) to range(n), which also accepts floats/bools + p = int_list(ans.get("layout"), n, 0, n - 1, "layout") + if len(set(p)) != n: + raise Invalid("layout is not a permutation of 0..n-1") + for u, v in inst["edges"]: + if abs(p[u] - p[v]) > b: + raise Invalid(f"edge ({u},{v}) has stretch {abs(p[u] - p[v])} > {b}") + return None, {} diff --git a/tasks/construct-nppc-bandwidth-l1-s1/tests/instance.json b/tasks/construct-nppc-bandwidth-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5f745661ddf7ca3c8f0611aafbeb22dcaf578b82 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 6, "bandwidth": 3, "edges": [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l1-s1/tests/run.py b/tasks/construct-nppc-bandwidth-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-bandwidth-l1-s1/tests/test.sh b/tasks/construct-nppc-bandwidth-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-bandwidth-l1-s6/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-bandwidth-l1-s6/environment/instance.json b/tasks/construct-nppc-bandwidth-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c1d8d8859b465be88b2db7cca42e838cb445e83a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 6, "bandwidth": 3, "edges": [[0, 2], [1, 2], [2, 3], [3, 5], [4, 5]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l1-s6/solution/solve.sh b/tasks/construct-nppc-bandwidth-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..67ddbdc5490501bfac66131ced447e5f01e1740f --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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' +{"layout": [0, 4, 2, 5, 1, 3]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l1-s6/tests/check.py b/tasks/construct-nppc-bandwidth-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-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-l1-s6/tests/instance.json b/tasks/construct-nppc-bandwidth-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c1d8d8859b465be88b2db7cca42e838cb445e83a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 6, "bandwidth": 3, "edges": [[0, 2], [1, 2], [2, 3], [3, 5], [4, 5]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l1-s6/tests/run.py b/tasks/construct-nppc-bandwidth-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-bandwidth-l1-s6/tests/test.sh b/tasks/construct-nppc-bandwidth-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-bandwidth-l1-s8/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-bandwidth-l1-s8/environment/instance.json b/tasks/construct-nppc-bandwidth-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5f745661ddf7ca3c8f0611aafbeb22dcaf578b82 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 6, "bandwidth": 3, "edges": [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l1-s8/solution/solve.sh b/tasks/construct-nppc-bandwidth-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ca85c92c9d34cd04004701d48ae0019affe68dac --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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' +{"layout": [4, 5, 2, 3, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l1-s8/tests/check.py b/tasks/construct-nppc-bandwidth-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s8/tests/check.py @@ -0,0 +1,14 @@ +"""Bandwidth <= b: layout must be a permutation of 0..n-1 with |p[u]-p[v]| <= b on every edge.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, b = inst["num_nodes"], inst["bandwidth"] + # upstream NPPC verifier compares sorted(layout) to range(n), which also accepts floats/bools + p = int_list(ans.get("layout"), n, 0, n - 1, "layout") + if len(set(p)) != n: + raise Invalid("layout is not a permutation of 0..n-1") + for u, v in inst["edges"]: + if abs(p[u] - p[v]) > b: + raise Invalid(f"edge ({u},{v}) has stretch {abs(p[u] - p[v])} > {b}") + return None, {} diff --git a/tasks/construct-nppc-bandwidth-l1-s8/tests/instance.json b/tasks/construct-nppc-bandwidth-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5f745661ddf7ca3c8f0611aafbeb22dcaf578b82 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 6, "bandwidth": 3, "edges": [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l1-s8/tests/run.py b/tasks/construct-nppc-bandwidth-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-bandwidth-l1-s8/tests/test.sh b/tasks/construct-nppc-bandwidth-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l1-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-bandwidth-l5-s7/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l5-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-bandwidth-l5-s7/environment/instance.json b/tasks/construct-nppc-bandwidth-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..adcb39d27f8c5607213d20540a0e89c0eea69ecc --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "bandwidth": 4, "edges": [[0, 7], [0, 8], [0, 10], [0, 17], [0, 27], [0, 35], [1, 4], [1, 6], [1, 15], [1, 26], [1, 28], [1, 31], [1, 32], [2, 8], [2, 27], [3, 5], [3, 9], [3, 14], [3, 20], [3, 21], [4, 15], [4, 25], [4, 26], [4, 37], [5, 9], [5, 12], [5, 14], [5, 39], [6, 15], [6, 18], [7, 10], [7, 16], [7, 27], [7, 30], [7, 33], [8, 10], [8, 17], [8, 27], [8, 35], [9, 12], [9, 14], [9, 39], [10, 11], [10, 24], [10, 33], [11, 24], [11, 27], [11, 30], [11, 33], [12, 13], [12, 20], [12, 39], [13, 14], [13, 19], [13, 23], [13, 36], [13, 38], [14, 20], [15, 18], [15, 31], [16, 18], [16, 30], [16, 33], [16, 34], [17, 27], [17, 35], [18, 22], [18, 31], [18, 34], [19, 20], [19, 23], [19, 37], [19, 38], [20, 21], [20, 38], [21, 23], [22, 24], [22, 34], [23, 36], [23, 37], [23, 38], [24, 30], [24, 33], [25, 26], [25, 28], [25, 36], [25, 37], [25, 38], [26, 28], [26, 29], [26, 32], [26, 37], [27, 35], [28, 29], [28, 32], [29, 36], [30, 33], [31, 32], [31, 34], [33, 34], [36, 37], [37, 38]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l5-s7/solution/solve.sh b/tasks/construct-nppc-bandwidth-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3efccac334722261ce24a15e9a553cd49e75b8f5 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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' +{"layout": [34, 19, 39, 3, 16, 2, 22, 31, 36, 1, 33, 32, 4, 8, 5, 20, 27, 37, 24, 11, 7, 6, 25, 9, 29, 14, 17, 35, 18, 15, 28, 23, 21, 30, 26, 38, 12, 13, 10, 0]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l5-s7/tests/check.py b/tasks/construct-nppc-bandwidth-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l5-s7/tests/check.py @@ -0,0 +1,14 @@ +"""Bandwidth <= b: layout must be a permutation of 0..n-1 with |p[u]-p[v]| <= b on every edge.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, b = inst["num_nodes"], inst["bandwidth"] + # upstream NPPC verifier compares sorted(layout) to range(n), which also accepts floats/bools + p = int_list(ans.get("layout"), n, 0, n - 1, "layout") + if len(set(p)) != n: + raise Invalid("layout is not a permutation of 0..n-1") + for u, v in inst["edges"]: + if abs(p[u] - p[v]) > b: + raise Invalid(f"edge ({u},{v}) has stretch {abs(p[u] - p[v])} > {b}") + return None, {} diff --git a/tasks/construct-nppc-bandwidth-l5-s7/tests/instance.json b/tasks/construct-nppc-bandwidth-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..adcb39d27f8c5607213d20540a0e89c0eea69ecc --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "bandwidth": 4, "edges": [[0, 7], [0, 8], [0, 10], [0, 17], [0, 27], [0, 35], [1, 4], [1, 6], [1, 15], [1, 26], [1, 28], [1, 31], [1, 32], [2, 8], [2, 27], [3, 5], [3, 9], [3, 14], [3, 20], [3, 21], [4, 15], [4, 25], [4, 26], [4, 37], [5, 9], [5, 12], [5, 14], [5, 39], [6, 15], [6, 18], [7, 10], [7, 16], [7, 27], [7, 30], [7, 33], [8, 10], [8, 17], [8, 27], [8, 35], [9, 12], [9, 14], [9, 39], [10, 11], [10, 24], [10, 33], [11, 24], [11, 27], [11, 30], [11, 33], [12, 13], [12, 20], [12, 39], [13, 14], [13, 19], [13, 23], [13, 36], [13, 38], [14, 20], [15, 18], [15, 31], [16, 18], [16, 30], [16, 33], [16, 34], [17, 27], [17, 35], [18, 22], [18, 31], [18, 34], [19, 20], [19, 23], [19, 37], [19, 38], [20, 21], [20, 38], [21, 23], [22, 24], [22, 34], [23, 36], [23, 37], [23, 38], [24, 30], [24, 33], [25, 26], [25, 28], [25, 36], [25, 37], [25, 38], [26, 28], [26, 29], [26, 32], [26, 37], [27, 35], [28, 29], [28, 32], [29, 36], [30, 33], [31, 32], [31, 34], [33, 34], [36, 37], [37, 38]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l5-s7/tests/run.py b/tasks/construct-nppc-bandwidth-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l5-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-bandwidth-l5-s7/tests/test.sh b/tasks/construct-nppc-bandwidth-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l5-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-bandwidth-l5-s9/environment/Dockerfile b/tasks/construct-nppc-bandwidth-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l5-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-bandwidth-l5-s9/environment/instance.json b/tasks/construct-nppc-bandwidth-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e478dc7e29ff8b90d99e716d0bf96c24239c5dbb --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "bandwidth": 4, "edges": [[0, 2], [0, 9], [0, 26], [0, 30], [1, 7], [1, 14], [1, 37], [1, 38], [1, 39], [2, 7], [2, 9], [2, 13], [2, 26], [2, 28], [2, 30], [3, 4], [3, 16], [3, 19], [3, 21], [3, 34], [4, 16], [4, 19], [4, 23], [4, 31], [4, 34], [5, 6], [5, 24], [6, 20], [6, 22], [7, 13], [7, 38], [8, 10], [8, 18], [8, 19], [8, 21], [9, 26], [9, 27], [9, 28], [9, 30], [9, 36], [10, 11], [10, 14], [10, 17], [10, 18], [10, 35], [10, 39], [11, 14], [11, 15], [11, 17], [11, 18], [12, 16], [12, 23], [12, 25], [12, 33], [13, 30], [13, 32], [13, 38], [13, 39], [14, 17], [14, 35], [14, 39], [15, 17], [15, 18], [15, 21], [15, 31], [16, 23], [16, 25], [16, 31], [16, 33], [16, 34], [17, 18], [17, 37], [18, 19], [19, 21], [19, 31], [20, 22], [20, 24], [21, 31], [22, 24], [22, 27], [22, 28], [22, 29], [23, 25], [23, 33], [23, 34], [24, 27], [24, 29], [24, 36], [25, 33], [25, 34], [26, 27], [26, 28], [26, 30], [26, 36], [27, 28], [27, 29], [27, 36], [28, 29], [28, 30], [28, 36], [29, 36], [30, 38], [31, 34], [32, 35], [32, 39], [33, 34], [35, 37], [35, 38], [35, 39], [37, 39], [38, 39]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l5-s9/solution/solve.sh b/tasks/construct-nppc-bandwidth-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c9a370a626779fd5b025c87e9bb54d05b77f2321 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-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' +{"layout": [26, 21, 28, 8, 6, 38, 37, 25, 12, 30, 16, 15, 0, 24, 18, 11, 4, 14, 13, 10, 39, 9, 35, 3, 36, 1, 29, 32, 31, 34, 27, 7, 22, 2, 5, 19, 33, 17, 23, 20]} +RLMATH_EOF diff --git a/tasks/construct-nppc-bandwidth-l5-s9/tests/check.py b/tasks/construct-nppc-bandwidth-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0f847cded257e6c404063dfafde33fa44163afa2 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l5-s9/tests/check.py @@ -0,0 +1,14 @@ +"""Bandwidth <= b: layout must be a permutation of 0..n-1 with |p[u]-p[v]| <= b on every edge.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, b = inst["num_nodes"], inst["bandwidth"] + # upstream NPPC verifier compares sorted(layout) to range(n), which also accepts floats/bools + p = int_list(ans.get("layout"), n, 0, n - 1, "layout") + if len(set(p)) != n: + raise Invalid("layout is not a permutation of 0..n-1") + for u, v in inst["edges"]: + if abs(p[u] - p[v]) > b: + raise Invalid(f"edge ({u},{v}) has stretch {abs(p[u] - p[v])} > {b}") + return None, {} diff --git a/tasks/construct-nppc-bandwidth-l5-s9/tests/instance.json b/tasks/construct-nppc-bandwidth-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e478dc7e29ff8b90d99e716d0bf96c24239c5dbb --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "bandwidth": 4, "edges": [[0, 2], [0, 9], [0, 26], [0, 30], [1, 7], [1, 14], [1, 37], [1, 38], [1, 39], [2, 7], [2, 9], [2, 13], [2, 26], [2, 28], [2, 30], [3, 4], [3, 16], [3, 19], [3, 21], [3, 34], [4, 16], [4, 19], [4, 23], [4, 31], [4, 34], [5, 6], [5, 24], [6, 20], [6, 22], [7, 13], [7, 38], [8, 10], [8, 18], [8, 19], [8, 21], [9, 26], [9, 27], [9, 28], [9, 30], [9, 36], [10, 11], [10, 14], [10, 17], [10, 18], [10, 35], [10, 39], [11, 14], [11, 15], [11, 17], [11, 18], [12, 16], [12, 23], [12, 25], [12, 33], [13, 30], [13, 32], [13, 38], [13, 39], [14, 17], [14, 35], [14, 39], [15, 17], [15, 18], [15, 21], [15, 31], [16, 23], [16, 25], [16, 31], [16, 33], [16, 34], [17, 18], [17, 37], [18, 19], [19, 21], [19, 31], [20, 22], [20, 24], [21, 31], [22, 24], [22, 27], [22, 28], [22, 29], [23, 25], [23, 33], [23, 34], [24, 27], [24, 29], [24, 36], [25, 33], [25, 34], [26, 27], [26, 28], [26, 30], [26, 36], [27, 28], [27, 29], [27, 36], [28, 29], [28, 30], [28, 36], [29, 36], [30, 38], [31, 34], [32, 35], [32, 39], [33, 34], [35, 37], [35, 38], [35, 39], [37, 39], [38, 39]], "family": "nppc_bandwidth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-bandwidth-l5-s9/tests/run.py b/tasks/construct-nppc-bandwidth-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l5-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-bandwidth-l5-s9/tests/test.sh b/tasks/construct-nppc-bandwidth-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-bandwidth-l5-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-clique-l4-s0/environment/Dockerfile b/tasks/construct-nppc-clique-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-l4-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-clique-l4-s0/environment/instance.json b/tasks/construct-nppc-clique-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..55041fe9b86268c1db84003bc7fd9c171858cc51 --- /dev/null +++ b/tasks/construct-nppc-clique-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 1], [0, 4], [0, 5], [0, 6], [0, 8], [0, 9], [0, 11], [0, 12], [0, 14], [0, 16], [0, 17], [0, 18], [0, 19], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [1, 3], [1, 4], [1, 6], [1, 8], [1, 10], [1, 12], [1, 16], [1, 18], [1, 25], [1, 27], [1, 28], [2, 4], [2, 6], [2, 7], [2, 8], [2, 12], [2, 14], [2, 18], [2, 20], [2, 22], [2, 24], [2, 29], [3, 4], [3, 6], [3, 11], [3, 14], [3, 16], [3, 17], [3, 18], [3, 24], [3, 27], [3, 28], [4, 5], [4, 8], [4, 9], [4, 10], [4, 11], [4, 14], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 28], [4, 29], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 14], [5, 15], [5, 16], [5, 17], [5, 19], [5, 20], [5, 21], [5, 25], [5, 28], [6, 7], [6, 9], [6, 11], [6, 13], [6, 14], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 28], [7, 10], [7, 12], [7, 19], [7, 20], [7, 22], [7, 23], [7, 25], [7, 26], [7, 27], [7, 29], [8, 11], [8, 16], [8, 17], [8, 22], [8, 23], [8, 24], [8, 27], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 29], [10, 11], [10, 12], [10, 14], [10, 15], [10, 17], [10, 18], [10, 20], [10, 22], [10, 24], [10, 27], [10, 28], [11, 12], [11, 13], [11, 14], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [12, 13], [12, 18], [12, 19], [12, 21], [13, 14], [13, 15], [13, 16], [13, 17], [13, 19], [13, 20], [13, 24], [13, 26], [13, 27], [13, 28], [13, 29], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [15, 18], [15, 22], [15, 23], [15, 25], [15, 26], [15, 28], [16, 17], [16, 18], [16, 19], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [17, 18], [17, 19], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 28], [18, 19], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [20, 23], [20, 26], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [23, 24], [23, 25], [23, 26], [23, 27], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [25, 26], [25, 29], [26, 29], [27, 28], [27, 29]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l4-s0/solution/solve.sh b/tasks/construct-nppc-clique-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cd255e077a975b7e95042ae540fa901ee4eb6f04 --- /dev/null +++ b/tasks/construct-nppc-clique-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' +{"clique": [0, 4, 9, 11, 14, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l4-s0/tests/check.py b/tasks/construct-nppc-clique-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l4-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-l4-s0/tests/instance.json b/tasks/construct-nppc-clique-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..55041fe9b86268c1db84003bc7fd9c171858cc51 --- /dev/null +++ b/tasks/construct-nppc-clique-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 1], [0, 4], [0, 5], [0, 6], [0, 8], [0, 9], [0, 11], [0, 12], [0, 14], [0, 16], [0, 17], [0, 18], [0, 19], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [1, 3], [1, 4], [1, 6], [1, 8], [1, 10], [1, 12], [1, 16], [1, 18], [1, 25], [1, 27], [1, 28], [2, 4], [2, 6], [2, 7], [2, 8], [2, 12], [2, 14], [2, 18], [2, 20], [2, 22], [2, 24], [2, 29], [3, 4], [3, 6], [3, 11], [3, 14], [3, 16], [3, 17], [3, 18], [3, 24], [3, 27], [3, 28], [4, 5], [4, 8], [4, 9], [4, 10], [4, 11], [4, 14], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 28], [4, 29], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 14], [5, 15], [5, 16], [5, 17], [5, 19], [5, 20], [5, 21], [5, 25], [5, 28], [6, 7], [6, 9], [6, 11], [6, 13], [6, 14], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 28], [7, 10], [7, 12], [7, 19], [7, 20], [7, 22], [7, 23], [7, 25], [7, 26], [7, 27], [7, 29], [8, 11], [8, 16], [8, 17], [8, 22], [8, 23], [8, 24], [8, 27], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 29], [10, 11], [10, 12], [10, 14], [10, 15], [10, 17], [10, 18], [10, 20], [10, 22], [10, 24], [10, 27], [10, 28], [11, 12], [11, 13], [11, 14], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [12, 13], [12, 18], [12, 19], [12, 21], [13, 14], [13, 15], [13, 16], [13, 17], [13, 19], [13, 20], [13, 24], [13, 26], [13, 27], [13, 28], [13, 29], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [15, 18], [15, 22], [15, 23], [15, 25], [15, 26], [15, 28], [16, 17], [16, 18], [16, 19], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [17, 18], [17, 19], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 28], [18, 19], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [20, 23], [20, 26], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [21, 27], [21, 28], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [23, 24], [23, 25], [23, 26], [23, 27], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [25, 26], [25, 29], [26, 29], [27, 28], [27, 29]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l4-s0/tests/run.py b/tasks/construct-nppc-clique-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-l4-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-clique-l4-s0/tests/test.sh b/tasks/construct-nppc-clique-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-l4-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-clique-l4-s7/environment/Dockerfile b/tasks/construct-nppc-clique-l4-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-l4-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-clique-l4-s7/environment/instance.json b/tasks/construct-nppc-clique-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b21db118d1699dc8eac785e633e7422ecd448faf --- /dev/null +++ b/tasks/construct-nppc-clique-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 2], [0, 3], [0, 4], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 15], [0, 16], [0, 17], [0, 19], [0, 20], [0, 23], [0, 27], [0, 28], [0, 29], [1, 3], [1, 4], [1, 10], [1, 12], [1, 13], [1, 14], [1, 15], [1, 17], [1, 18], [1, 19], [1, 20], [1, 23], [1, 26], [1, 28], [1, 29], [2, 4], [2, 5], [2, 6], [2, 8], [2, 9], [2, 12], [2, 14], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 27], [2, 28], [3, 4], [3, 6], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 14], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 23], [3, 24], [3, 25], [3, 27], [3, 28], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 15], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 23], [4, 27], [4, 28], [4, 29], [5, 7], [5, 8], [5, 9], [5, 13], [5, 14], [5, 16], [5, 21], [5, 24], [5, 25], [5, 28], [5, 29], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 21], [6, 23], [6, 24], [6, 27], [6, 28], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 25], [7, 26], [7, 28], [8, 9], [8, 10], [8, 11], [8, 12], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 23], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [9, 10], [9, 11], [9, 12], [9, 13], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 23], [9, 26], [9, 27], [9, 28], [9, 29], [10, 11], [10, 12], [10, 13], [10, 16], [10, 17], [10, 19], [10, 20], [10, 21], [10, 23], [10, 26], [10, 27], [10, 28], [10, 29], [11, 12], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 22], [11, 23], [11, 24], [11, 27], [11, 28], [12, 14], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 22], [12, 23], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [13, 14], [13, 16], [13, 17], [13, 21], [13, 23], [13, 25], [13, 26], [13, 27], [13, 28], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 21], [14, 26], [14, 28], [14, 29], [15, 18], [15, 21], [15, 23], [15, 27], [15, 28], [16, 22], [16, 26], [16, 27], [16, 28], [17, 18], [17, 19], [17, 20], [17, 22], [17, 23], [17, 25], [17, 26], [17, 27], [17, 28], [18, 24], [19, 20], [19, 22], [19, 23], [19, 24], [19, 25], [19, 27], [19, 28], [20, 23], [20, 27], [20, 28], [21, 22], [21, 27], [21, 29], [22, 24], [22, 25], [22, 26], [22, 27], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [24, 25], [24, 26], [24, 28], [25, 28], [25, 29], [26, 27], [26, 28], [27, 28], [27, 29]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l4-s7/solution/solve.sh b/tasks/construct-nppc-clique-l4-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3e6b66290be3d37108b2664e1b8f9cc87ecab49d --- /dev/null +++ b/tasks/construct-nppc-clique-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' +{"clique": [0, 3, 4, 6, 8, 9, 10, 11, 12, 17, 19, 20, 23, 27, 28]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l4-s7/tests/check.py b/tasks/construct-nppc-clique-l4-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l4-s7/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l4-s7/tests/instance.json b/tasks/construct-nppc-clique-l4-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b21db118d1699dc8eac785e633e7422ecd448faf --- /dev/null +++ b/tasks/construct-nppc-clique-l4-s7/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 2], [0, 3], [0, 4], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 15], [0, 16], [0, 17], [0, 19], [0, 20], [0, 23], [0, 27], [0, 28], [0, 29], [1, 3], [1, 4], [1, 10], [1, 12], [1, 13], [1, 14], [1, 15], [1, 17], [1, 18], [1, 19], [1, 20], [1, 23], [1, 26], [1, 28], [1, 29], [2, 4], [2, 5], [2, 6], [2, 8], [2, 9], [2, 12], [2, 14], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 27], [2, 28], [3, 4], [3, 6], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 14], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 23], [3, 24], [3, 25], [3, 27], [3, 28], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 15], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 23], [4, 27], [4, 28], [4, 29], [5, 7], [5, 8], [5, 9], [5, 13], [5, 14], [5, 16], [5, 21], [5, 24], [5, 25], [5, 28], [5, 29], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 21], [6, 23], [6, 24], [6, 27], [6, 28], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 25], [7, 26], [7, 28], [8, 9], [8, 10], [8, 11], [8, 12], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 23], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [9, 10], [9, 11], [9, 12], [9, 13], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 23], [9, 26], [9, 27], [9, 28], [9, 29], [10, 11], [10, 12], [10, 13], [10, 16], [10, 17], [10, 19], [10, 20], [10, 21], [10, 23], [10, 26], [10, 27], [10, 28], [10, 29], [11, 12], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 22], [11, 23], [11, 24], [11, 27], [11, 28], [12, 14], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 22], [12, 23], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [13, 14], [13, 16], [13, 17], [13, 21], [13, 23], [13, 25], [13, 26], [13, 27], [13, 28], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 21], [14, 26], [14, 28], [14, 29], [15, 18], [15, 21], [15, 23], [15, 27], [15, 28], [16, 22], [16, 26], [16, 27], [16, 28], [17, 18], [17, 19], [17, 20], [17, 22], [17, 23], [17, 25], [17, 26], [17, 27], [17, 28], [18, 24], [19, 20], [19, 22], [19, 23], [19, 24], [19, 25], [19, 27], [19, 28], [20, 23], [20, 27], [20, 28], [21, 22], [21, 27], [21, 29], [22, 24], [22, 25], [22, 26], [22, 27], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [24, 25], [24, 26], [24, 28], [25, 28], [25, 29], [26, 27], [26, 28], [27, 28], [27, 29]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l4-s7/tests/run.py b/tasks/construct-nppc-clique-l4-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-l4-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-clique-l4-s7/tests/test.sh b/tasks/construct-nppc-clique-l4-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-l4-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-clique-l4-s9/environment/Dockerfile b/tasks/construct-nppc-clique-l4-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-l4-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-clique-l4-s9/environment/instance.json b/tasks/construct-nppc-clique-l4-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0c79d439b6b900f1b126f7199308623e2f84cf49 --- /dev/null +++ b/tasks/construct-nppc-clique-l4-s9/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 2], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 12], [0, 13], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 23], [0, 25], [0, 26], [0, 27], [0, 29], [1, 3], [1, 4], [1, 5], [1, 6], [1, 8], [1, 9], [1, 11], [1, 14], [1, 16], [1, 17], [1, 20], [1, 24], [1, 26], [1, 28], [1, 29], [2, 6], [2, 7], [2, 8], [2, 9], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 18], [2, 19], [2, 20], [2, 22], [2, 24], [2, 26], [2, 29], [3, 6], [3, 8], [3, 9], [3, 11], [3, 12], [3, 14], [3, 15], [3, 16], [3, 17], [3, 22], [3, 26], [3, 28], [4, 5], [4, 6], [4, 7], [4, 8], [4, 11], [4, 12], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 26], [4, 27], [4, 28], [4, 29], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 12], [5, 13], [5, 15], [5, 16], [5, 17], [5, 19], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 29], [6, 7], [6, 11], [6, 12], [6, 13], [6, 16], [6, 17], [6, 18], [6, 19], [6, 21], [6, 23], [6, 24], [6, 26], [6, 27], [6, 28], [6, 29], [7, 8], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 16], [7, 17], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [8, 9], [8, 10], [8, 12], [8, 15], [8, 17], [8, 21], [8, 23], [8, 24], [8, 26], [8, 27], [8, 28], [9, 10], [9, 11], [9, 12], [9, 13], [9, 16], [9, 19], [9, 21], [9, 22], [9, 23], [9, 25], [9, 27], [10, 11], [10, 12], [10, 14], [10, 15], [10, 18], [10, 21], [10, 22], [10, 24], [10, 28], [10, 29], [11, 12], [11, 13], [11, 14], [11, 17], [11, 18], [11, 20], [11, 22], [11, 23], [11, 24], [11, 25], [11, 27], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 19], [12, 20], [12, 21], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 29], [13, 14], [13, 15], [13, 16], [13, 17], [13, 19], [13, 21], [13, 22], [13, 23], [13, 24], [13, 26], [13, 27], [13, 28], [13, 29], [14, 17], [14, 18], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 27], [14, 28], [15, 16], [15, 23], [15, 26], [15, 27], [15, 28], [15, 29], [16, 17], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 25], [16, 26], [16, 27], [16, 29], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 25], [17, 26], [17, 27], [17, 29], [18, 19], [18, 24], [18, 26], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 26], [19, 27], [19, 28], [19, 29], [20, 22], [20, 23], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [21, 23], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [22, 24], [22, 25], [22, 27], [22, 28], [23, 26], [23, 27], [23, 29], [24, 25], [24, 26], [24, 28], [25, 26], [25, 27], [25, 28], [25, 29], [26, 27], [26, 28], [26, 29], [27, 28], [27, 29], [28, 29]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l4-s9/solution/solve.sh b/tasks/construct-nppc-clique-l4-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d808dde2e3f85b712b68fbc42ce0a9583829c90c --- /dev/null +++ b/tasks/construct-nppc-clique-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' +{"clique": [0, 4, 5, 6, 7, 12, 13, 16, 17, 19, 21, 23, 26, 27, 29]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l4-s9/tests/check.py b/tasks/construct-nppc-clique-l4-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l4-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-l4-s9/tests/instance.json b/tasks/construct-nppc-clique-l4-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0c79d439b6b900f1b126f7199308623e2f84cf49 --- /dev/null +++ b/tasks/construct-nppc-clique-l4-s9/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 2], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 12], [0, 13], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 23], [0, 25], [0, 26], [0, 27], [0, 29], [1, 3], [1, 4], [1, 5], [1, 6], [1, 8], [1, 9], [1, 11], [1, 14], [1, 16], [1, 17], [1, 20], [1, 24], [1, 26], [1, 28], [1, 29], [2, 6], [2, 7], [2, 8], [2, 9], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 18], [2, 19], [2, 20], [2, 22], [2, 24], [2, 26], [2, 29], [3, 6], [3, 8], [3, 9], [3, 11], [3, 12], [3, 14], [3, 15], [3, 16], [3, 17], [3, 22], [3, 26], [3, 28], [4, 5], [4, 6], [4, 7], [4, 8], [4, 11], [4, 12], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 26], [4, 27], [4, 28], [4, 29], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 12], [5, 13], [5, 15], [5, 16], [5, 17], [5, 19], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 29], [6, 7], [6, 11], [6, 12], [6, 13], [6, 16], [6, 17], [6, 18], [6, 19], [6, 21], [6, 23], [6, 24], [6, 26], [6, 27], [6, 28], [6, 29], [7, 8], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 16], [7, 17], [7, 18], [7, 19], [7, 20], [7, 21], [7, 22], [7, 23], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [8, 9], [8, 10], [8, 12], [8, 15], [8, 17], [8, 21], [8, 23], [8, 24], [8, 26], [8, 27], [8, 28], [9, 10], [9, 11], [9, 12], [9, 13], [9, 16], [9, 19], [9, 21], [9, 22], [9, 23], [9, 25], [9, 27], [10, 11], [10, 12], [10, 14], [10, 15], [10, 18], [10, 21], [10, 22], [10, 24], [10, 28], [10, 29], [11, 12], [11, 13], [11, 14], [11, 17], [11, 18], [11, 20], [11, 22], [11, 23], [11, 24], [11, 25], [11, 27], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 19], [12, 20], [12, 21], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 29], [13, 14], [13, 15], [13, 16], [13, 17], [13, 19], [13, 21], [13, 22], [13, 23], [13, 24], [13, 26], [13, 27], [13, 28], [13, 29], [14, 17], [14, 18], [14, 20], [14, 21], [14, 22], [14, 23], [14, 24], [14, 27], [14, 28], [15, 16], [15, 23], [15, 26], [15, 27], [15, 28], [15, 29], [16, 17], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 25], [16, 26], [16, 27], [16, 29], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 25], [17, 26], [17, 27], [17, 29], [18, 19], [18, 24], [18, 26], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 26], [19, 27], [19, 28], [19, 29], [20, 22], [20, 23], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [21, 23], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [22, 24], [22, 25], [22, 27], [22, 28], [23, 26], [23, 27], [23, 29], [24, 25], [24, 26], [24, 28], [25, 26], [25, 27], [25, 28], [25, 29], [26, 27], [26, 28], [26, 29], [27, 28], [27, 29], [28, 29]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l4-s9/tests/run.py b/tasks/construct-nppc-clique-l4-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-l4-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-clique-l4-s9/tests/test.sh b/tasks/construct-nppc-clique-l4-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-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-nppc-dominating-set-l1-s8/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l1-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-dominating-set-l1-s8/environment/instance.json b/tasks/construct-nppc-dominating-set-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5d973c397cff4e8bdd26b3a6144f5814e774c75e --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "k": 5, "edges": [[0, 6], [0, 8], [0, 9], [1, 2], [1, 3], [1, 7], [2, 3], [2, 6], [2, 8], [3, 6], [3, 8], [3, 9], [4, 6], [6, 7], [7, 8]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l1-s8/solution/solve.sh b/tasks/construct-nppc-dominating-set-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..08e833f7a50c14f2438e1173be08fc170a508467 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [0, 3, 4, 5, 7]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l1-s8/tests/check.py b/tasks/construct-nppc-dominating-set-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l1-s8/tests/check.py @@ -0,0 +1,23 @@ +"""Dominating set of size <= k. Accepts any valid dominating set.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier has no type/range checks (out-of-range labels and floats are silently used) + d = int_list(ans.get("dominating_set"), None, 0, n - 1, "dominating_set") + if len(set(d)) != len(d): + raise Invalid("dominating_set contains duplicates") + if not d or len(d) > k: + raise Invalid(f"dominating_set must have 1..{k} vertices, got {len(d)}") + dom = set(d) + s = set(d) + for u, v in inst["edges"]: + if u in s: + dom.add(v) + if v in s: + dom.add(u) + if len(dom) != n: + miss = min(set(range(n)) - dom) + raise Invalid(f"vertex {miss} is not dominated") + return None, {"size": len(d)} diff --git a/tasks/construct-nppc-dominating-set-l1-s8/tests/instance.json b/tasks/construct-nppc-dominating-set-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5d973c397cff4e8bdd26b3a6144f5814e774c75e --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "k": 5, "edges": [[0, 6], [0, 8], [0, 9], [1, 2], [1, 3], [1, 7], [2, 3], [2, 6], [2, 8], [3, 6], [3, 8], [3, 9], [4, 6], [6, 7], [7, 8]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l1-s8/tests/run.py b/tasks/construct-nppc-dominating-set-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l1-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-dominating-set-l1-s8/tests/test.sh b/tasks/construct-nppc-dominating-set-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l1-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-dominating-set-l5-s0/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-dominating-set-l5-s0/environment/instance.json b/tasks/construct-nppc-dominating-set-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..09ab6fbb1441243c9c71b878b4927953e81166f5 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 180, "k": 15, "edges": [[0, 5], [0, 8], [0, 16], [0, 17], [0, 33], [0, 39], [0, 43], [0, 61], [0, 66], [0, 69], [0, 74], [0, 77], [0, 79], [0, 85], [0, 89], [0, 93], [0, 94], [0, 102], [0, 112], [0, 128], [0, 129], [0, 132], [0, 137], [0, 138], [0, 143], [0, 144], [0, 147], [0, 156], [0, 157], [0, 158], [0, 161], [0, 164], [0, 166], [0, 178], [1, 5], [1, 7], [1, 16], [1, 22], [1, 38], [1, 46], [1, 48], [1, 60], [1, 66], [1, 68], [1, 75], [1, 78], [1, 81], [1, 101], [1, 112], [1, 139], [1, 145], [1, 150], [1, 155], [1, 160], [1, 162], [1, 166], [1, 167], [1, 172], [1, 177], [2, 6], [2, 8], [2, 13], [2, 14], [2, 18], [2, 27], [2, 29], [2, 33], [2, 34], [2, 36], [2, 44], [2, 55], [2, 62], [2, 63], [2, 65], [2, 66], [2, 67], [2, 69], [2, 74], [2, 75], [2, 80], [2, 81], [2, 90], [2, 93], [2, 95], [2, 100], [2, 115], [2, 118], [2, 119], [2, 131], [2, 136], [2, 140], [2, 145], [2, 153], [2, 157], [2, 159], [2, 160], [2, 161], [2, 164], [2, 170], [3, 4], [3, 5], [3, 11], [3, 16], [3, 19], [3, 21], [3, 23], [3, 24], [3, 35], [3, 39], [3, 45], [3, 53], [3, 58], [3, 64], [3, 69], [3, 71], [3, 73], [3, 76], [3, 77], [3, 82], [3, 85], [3, 86], [3, 93], [3, 94], [3, 97], [3, 104], [3, 106], [3, 110], [3, 115], [3, 122], [3, 129], [3, 132], [3, 137], [3, 150], [3, 153], [3, 166], [3, 173], [3, 174], [3, 179], [4, 9], [4, 11], [4, 13], [4, 17], [4, 22], [4, 24], [4, 27], [4, 30], [4, 32], [4, 34], [4, 35], [4, 37], [4, 41], [4, 54], [4, 59], [4, 71], [4, 76], [4, 85], [4, 88], [4, 89], [4, 93], [4, 98], [4, 100], [4, 103], [4, 106], [4, 107], [4, 108], [4, 113], [4, 115], [4, 128], [4, 136], [4, 137], [4, 147], [4, 158], [4, 162], [4, 171], [4, 174], [5, 6], [5, 8], [5, 10], [5, 20], [5, 38], [5, 40], [5, 42], [5, 47], [5, 53], [5, 57], [5, 58], [5, 64], [5, 81], [5, 83], [5, 84], [5, 94], [5, 100], [5, 110], [5, 112], [5, 116], [5, 123], [5, 131], [5, 142], [5, 146], [5, 153], [5, 157], [5, 162], [5, 178], [6, 20], [6, 30], [6, 34], [6, 36], [6, 37], [6, 44], [6, 48], [6, 60], [6, 75], [6, 79], [6, 80], [6, 81], [6, 82], [6, 91], [6, 95], [6, 103], [6, 108], [6, 109], [6, 120], [6, 124], [6, 126], [6, 134], [6, 138], [6, 140], [6, 142], [6, 147], [6, 150], [6, 159], [6, 165], [7, 8], [7, 15], [7, 16], [7, 18], [7, 19], [7, 21], [7, 22], [7, 25], [7, 32], [7, 35], [7, 46], [7, 54], [7, 55], [7, 65], [7, 66], [7, 91], [7, 95], [7, 97], [7, 98], [7, 101], [7, 104], [7, 106], [7, 118], [7, 120], [7, 124], [7, 125], [7, 128], [7, 129], [7, 134], [7, 135], [7, 138], [7, 140], [7, 141], [7, 148], [7, 151], [7, 155], [7, 160], [7, 165], [7, 169], [8, 11], [8, 16], [8, 29], [8, 32], [8, 39], [8, 44], [8, 45], [8, 53], [8, 72], [8, 73], [8, 88], [8, 97], [8, 100], [8, 102], [8, 107], [8, 110], [8, 115], [8, 120], [8, 122], [8, 124], [8, 127], [8, 128], [8, 129], [8, 134], [8, 135], [8, 142], [8, 144], [8, 149], [8, 150], [8, 155], [8, 163], [8, 167], [8, 169], [8, 170], [8, 172], [8, 176], [8, 178], [9, 10], [9, 14], [9, 16], [9, 25], [9, 28], [9, 29], [9, 31], [9, 36], [9, 49], [9, 54], [9, 56], [9, 62], [9, 85], [9, 87], [9, 96], [9, 99], [9, 101], [9, 114], [9, 118], [9, 119], [9, 122], [9, 125], [9, 131], [9, 133], [9, 137], [9, 139], [9, 143], [9, 152], [9, 157], [9, 163], [9, 164], [9, 174], [9, 175], [9, 179], [10, 12], [10, 24], [10, 28], [10, 34], [10, 42], [10, 49], [10, 54], [10, 56], [10, 58], [10, 64], [10, 66], [10, 81], [10, 88], [10, 97], [10, 98], [10, 102], [10, 104], [10, 105], [10, 107], [10, 112], [10, 115], [10, 124], [10, 125], [10, 130], [10, 135], [10, 141], [10, 144], [10, 145], [10, 147], [10, 151], [10, 158], [10, 159], [10, 165], [10, 166], [10, 172], [10, 173], [11, 13], [11, 18], [11, 19], [11, 21], [11, 22], [11, 26], [11, 31], [11, 33], [11, 35], [11, 39], [11, 40], [11, 43], [11, 47], [11, 48], [11, 50], [11, 53], [11, 55], [11, 58], [11, 60], [11, 62], [11, 67], [11, 69], [11, 71], [11, 89], [11, 95], [11, 102], [11, 108], [11, 109], [11, 112], [11, 118], [11, 119], [11, 122], [11, 126], [11, 133], [11, 135], [11, 137], [11, 138], [11, 144], [11, 146], [11, 147], [11, 152], [11, 154], [11, 160], [11, 166], [11, 167], [11, 169], [11, 171], [11, 172], [11, 176], [11, 178], [12, 22], [12, 25], [12, 32], [12, 35], [12, 36], [12, 49], [12, 51], [12, 52], [12, 55], [12, 60], [12, 66], [12, 74], [12, 78], [12, 79], [12, 87], [12, 89], [12, 90], [12, 92], [12, 97], [12, 99], [12, 108], [12, 110], [12, 111], [12, 114], [12, 122], [12, 124], [12, 126], [12, 135], [12, 138], [12, 143], [12, 145], [12, 152], [12, 157], [12, 161], [12, 162], [12, 171], [12, 174], [12, 176], [12, 177], [12, 178], [13, 19], [13, 20], [13, 22], [13, 29], [13, 32], [13, 36], [13, 40], [13, 44], [13, 46], [13, 48], [13, 56], [13, 60], [13, 62], [13, 68], [13, 69], [13, 71], [13, 72], [13, 80], [13, 81], [13, 82], [13, 84], [13, 88], [13, 103], [13, 107], [13, 108], [13, 114], [13, 115], [13, 119], [13, 124], [13, 125], [13, 135], [13, 140], [13, 147], [13, 149], [13, 150], [13, 162], [13, 163], [13, 165], [13, 170], [13, 171], [13, 175], [13, 176], [13, 178], [13, 179], [14, 16], [14, 22], [14, 26], [14, 31], [14, 40], [14, 43], [14, 44], [14, 46], [14, 50], [14, 55], [14, 56], [14, 68], [14, 73], [14, 79], [14, 83], [14, 85], [14, 87], [14, 88], [14, 90], [14, 92], [14, 93], [14, 99], [14, 100], [14, 103], [14, 110], [14, 111], [14, 113], [14, 119], [14, 121], [14, 125], [14, 132], [14, 133], [14, 134], [14, 139], [14, 144], [14, 145], [14, 148], [14, 149], [14, 165], [14, 166], [14, 168], [14, 169], [14, 170], [14, 177], [15, 19], [15, 24], [15, 26], [15, 29], [15, 31], [15, 38], [15, 40], [15, 41], [15, 43], [15, 46], [15, 51], [15, 53], [15, 55], [15, 58], [15, 59], [15, 64], [15, 66], [15, 72], [15, 77], [15, 86], [15, 88], [15, 91], [15, 96], [15, 99], [15, 100], [15, 101], [15, 106], [15, 108], [15, 113], [15, 128], [15, 138], [15, 155], [15, 157], [15, 162], [15, 179], [16, 25], [16, 28], [16, 30], [16, 37], [16, 43], [16, 47], [16, 49], [16, 66], [16, 69], [16, 73], [16, 81], [16, 84], [16, 97], [16, 105], [16, 113], [16, 116], [16, 121], [16, 125], [16, 131], [16, 134], [16, 138], [16, 148], [16, 151], [16, 161], [16, 162], [16, 165], [16, 169], [16, 175], [16, 179], [17, 27], [17, 38], [17, 48], [17, 53], [17, 64], [17, 69], [17, 72], [17, 79], [17, 80], [17, 82], [17, 87], [17, 95], [17, 96], [17, 99], [17, 100], [17, 104], [17, 107], [17, 109], [17, 114], [17, 115], [17, 119], [17, 120], [17, 125], [17, 130], [17, 131], [17, 136], [17, 147], [17, 152], [17, 153], [17, 161], [17, 162], [17, 164], [17, 166], [17, 170], [17, 174], [17, 177], [17, 178], [18, 21], [18, 25], [18, 26], [18, 52], [18, 54], [18, 74], [18, 77], [18, 79], [18, 80], [18, 89], [18, 118], [18, 125], [18, 129], [18, 132], [18, 136], [18, 144], [18, 145], [18, 149], [18, 150], [18, 157], [18, 160], [18, 162], [18, 168], [18, 171], [18, 172], [18, 173], [18, 176], [19, 29], [19, 30], [19, 36], [19, 38], [19, 40], [19, 44], [19, 55], [19, 57], [19, 63], [19, 64], [19, 66], [19, 69], [19, 79], [19, 80], [19, 81], [19, 85], [19, 86], [19, 111], [19, 118], [19, 121], [19, 127], [19, 136], [19, 141], [19, 147], [19, 149], [19, 166], [19, 170], [19, 172], [19, 175], [19, 176], [20, 24], [20, 26], [20, 28], [20, 40], [20, 50], [20, 51], [20, 53], [20, 54], [20, 57], [20, 65], [20, 68], [20, 70], [20, 72], [20, 77], [20, 80], [20, 96], [20, 110], [20, 118], [20, 129], [20, 130], [20, 131], [20, 137], [20, 145], [20, 147], [20, 148], [20, 154], [20, 155], [20, 165], [20, 168], [20, 169], [21, 23], [21, 29], [21, 31], [21, 33], [21, 43], [21, 59], [21, 61], [21, 66], [21, 68], [21, 69], [21, 72], [21, 73], [21, 83], [21, 88], [21, 94], [21, 101], [21, 102], [21, 106], [21, 109], [21, 116], [21, 120], [21, 126], [21, 131], [21, 152], [21, 153], [21, 161], [21, 163], [21, 169], [21, 170], [21, 173], [21, 175], [22, 25], [22, 26], [22, 28], [22, 34], [22, 35], [22, 44], [22, 53], [22, 58], [22, 60], [22, 62], [22, 63], [22, 76], [22, 79], [22, 83], [22, 92], [22, 93], [22, 96], [22, 98], [22, 99], [22, 106], [22, 108], [22, 113], [22, 116], [22, 118], [22, 119], [22, 122], [22, 123], [22, 126], [22, 128], [22, 131], [22, 137], [22, 140], [22, 141], [22, 153], [22, 157], [22, 159], [22, 161], [22, 163], [22, 165], [22, 175], [23, 25], [23, 27], [23, 36], [23, 43], [23, 44], [23, 47], [23, 55], [23, 58], [23, 63], [23, 64], [23, 66], [23, 84], [23, 90], [23, 103], [23, 105], [23, 107], [23, 109], [23, 111], [23, 115], [23, 118], [23, 124], [23, 127], [23, 128], [23, 135], [23, 139], [23, 140], [23, 141], [23, 149], [23, 150], [23, 153], [23, 154], [23, 156], [23, 158], [23, 165], [23, 168], [23, 171], [24, 27], [24, 31], [24, 39], [24, 40], [24, 42], [24, 49], [24, 50], [24, 61], [24, 64], [24, 66], [24, 73], [24, 77], [24, 84], [24, 96], [24, 98], [24, 105], [24, 109], [24, 111], [24, 115], [24, 118], [24, 122], [24, 128], [24, 134], [24, 139], [24, 144], [24, 155], [24, 156], [24, 161], [24, 165], [24, 168], [24, 169], [24, 171], [24, 174], [24, 177], [24, 178], [25, 28], [25, 33], [25, 39], [25, 41], [25, 45], [25, 63], [25, 69], [25, 71], [25, 74], [25, 76], [25, 80], [25, 90], [25, 91], [25, 95], [25, 103], [25, 104], [25, 107], [25, 110], [25, 115], [25, 124], [25, 126], [25, 130], [25, 135], [25, 143], [25, 146], [25, 147], [25, 151], [25, 154], [25, 155], [25, 157], [25, 160], [25, 162], [25, 176], [25, 177], [26, 36], [26, 37], [26, 47], [26, 64], [26, 71], [26, 73], [26, 75], [26, 87], [26, 91], [26, 94], [26, 96], [26, 98], [26, 100], [26, 107], [26, 108], [26, 111], [26, 112], [26, 115], [26, 122], [26, 124], [26, 138], [26, 139], [26, 140], [26, 141], [26, 146], [26, 148], [26, 155], [26, 159], [26, 161], [26, 162], [26, 168], [26, 175], [26, 179], [27, 34], [27, 38], [27, 40], [27, 41], [27, 47], [27, 48], [27, 62], [27, 64], [27, 72], [27, 78], [27, 83], [27, 85], [27, 94], [27, 97], [27, 101], [27, 111], [27, 113], [27, 116], [27, 127], [27, 132], [27, 135], [27, 143], [27, 152], [27, 156], [27, 157], [27, 162], [27, 177], [27, 178], [28, 29], [28, 31], [28, 34], [28, 41], [28, 42], [28, 62], [28, 65], [28, 66], [28, 67], [28, 68], [28, 76], [28, 77], [28, 83], [28, 87], [28, 104], [28, 107], [28, 113], [28, 115], [28, 124], [28, 125], [28, 128], [28, 130], [28, 134], [28, 136], [28, 145], [28, 151], [28, 157], [28, 167], [28, 173], [28, 179], [29, 30], [29, 34], [29, 36], [29, 37], [29, 39], [29, 52], [29, 54], [29, 59], [29, 62], [29, 74], [29, 75], [29, 88], [29, 97], [29, 101], [29, 120], [29, 121], [29, 124], [29, 126], [29, 127], [29, 133], [29, 135], [29, 146], [29, 152], [29, 153], [29, 162], [29, 164], [29, 165], [29, 167], [29, 168], [29, 171], [29, 172], [29, 178], [30, 31], [30, 32], [30, 33], [30, 48], [30, 57], [30, 86], [30, 93], [30, 95], [30, 98], [30, 111], [30, 127], [30, 132], [30, 136], [30, 149], [30, 152], [30, 153], [30, 155], [30, 158], [30, 162], [30, 175], [30, 176], [30, 178], [31, 32], [31, 39], [31, 42], [31, 45], [31, 51], [31, 62], [31, 68], [31, 79], [31, 80], [31, 88], [31, 100], [31, 104], [31, 105], [31, 111], [31, 114], [31, 124], [31, 131], [31, 133], [31, 134], [31, 143], [31, 147], [31, 151], [31, 153], [31, 154], [31, 162], [31, 175], [31, 176], [32, 41], [32, 46], [32, 47], [32, 51], [32, 53], [32, 57], [32, 61], [32, 66], [32, 71], [32, 79], [32, 89], [32, 92], [32, 99], [32, 102], [32, 103], [32, 119], [32, 120], [32, 126], [32, 137], [32, 141], [32, 143], [32, 144], [32, 147], [32, 149], [32, 154], [32, 157], [32, 158], [32, 160], [32, 161], [32, 167], [32, 168], [32, 169], [32, 174], [33, 39], [33, 51], [33, 54], [33, 57], [33, 62], [33, 66], [33, 73], [33, 75], [33, 93], [33, 100], [33, 107], [33, 117], [33, 118], [33, 125], [33, 127], [33, 128], [33, 132], [33, 135], [33, 136], [33, 141], [33, 150], [33, 158], [33, 160], [33, 166], [33, 169], [33, 172], [33, 176], [34, 39], [34, 54], [34, 64], [34, 67], [34, 72], [34, 73], [34, 87], [34, 88], [34, 90], [34, 95], [34, 100], [34, 102], [34, 105], [34, 116], [34, 117], [34, 118], [34, 123], [34, 129], [34, 136], [34, 140], [34, 145], [34, 148], [34, 152], [34, 158], [34, 162], [34, 167], [34, 175], [34, 176], [34, 178], [35, 36], [35, 37], [35, 45], [35, 46], [35, 52], [35, 53], [35, 58], [35, 59], [35, 63], [35, 64], [35, 65], [35, 75], [35, 78], [35, 88], [35, 89], [35, 91], [35, 100], [35, 110], [35, 112], [35, 114], [35, 118], [35, 119], [35, 128], [35, 129], [35, 143], [35, 146], [35, 147], [35, 150], [35, 154], [35, 155], [35, 162], [35, 163], [35, 173], [35, 179], [36, 38], [36, 43], [36, 52], [36, 53], [36, 54], [36, 55], [36, 56], [36, 59], [36, 61], [36, 64], [36, 70], [36, 71], [36, 75], [36, 79], [36, 84], [36, 86], [36, 87], [36, 89], [36, 93], [36, 95], [36, 96], [36, 99], [36, 101], [36, 104], [36, 109], [36, 118], [36, 121], [36, 122], [36, 135], [36, 137], [36, 139], [36, 143], [36, 149], [36, 150], [36, 160], [36, 161], [36, 169], [36, 172], [36, 175], [36, 177], [36, 178], [36, 179], [37, 39], [37, 46], [37, 48], [37, 51], [37, 75], [37, 78], [37, 79], [37, 90], [37, 91], [37, 92], [37, 95], [37, 100], [37, 107], [37, 111], [37, 115], [37, 116], [37, 118], [37, 120], [37, 123], [37, 124], [37, 127], [37, 128], [37, 132], [37, 134], [37, 144], [37, 158], [37, 159], [37, 165], [38, 42], [38, 46], [38, 48], [38, 51], [38, 52], [38, 59], [38, 62], [38, 63], [38, 68], [38, 71], [38, 72], [38, 80], [38, 84], [38, 86], [38, 87], [38, 93], [38, 98], [38, 100], [38, 101], [38, 104], [38, 108], [38, 112], [38, 113], [38, 116], [38, 120], [38, 135], [38, 158], [38, 159], [38, 161], [38, 165], [38, 170], [38, 172], [38, 175], [38, 176], [38, 179], [39, 47], [39, 50], [39, 55], [39, 66], [39, 69], [39, 74], [39, 77], [39, 84], [39, 91], [39, 92], [39, 98], [39, 102], [39, 107], [39, 117], [39, 123], [39, 124], [39, 126], [39, 128], [39, 130], [39, 131], [39, 142], [39, 144], [39, 153], [39, 166], [39, 173], [40, 45], [40, 48], [40, 49], [40, 50], [40, 67], [40, 69], [40, 70], [40, 73], [40, 78], [40, 96], [40, 101], [40, 115], [40, 121], [40, 123], [40, 126], [40, 127], [40, 143], [40, 145], [40, 154], [40, 158], [40, 159], [40, 166], [41, 50], [41, 55], [41, 56], [41, 58], [41, 64], [41, 83], [41, 84], [41, 86], [41, 87], [41, 89], [41, 92], [41, 93], [41, 94], [41, 98], [41, 99], [41, 101], [41, 113], [41, 118], [41, 133], [41, 137], [41, 151], [41, 153], [41, 154], [41, 157], [41, 166], [41, 169], [41, 174], [42, 48], [42, 51], [42, 54], [42, 58], [42, 59], [42, 60], [42, 66], [42, 69], [42, 70], [42, 74], [42, 75], [42, 76], [42, 79], [42, 88], [42, 89], [42, 91], [42, 95], [42, 105], [42, 123], [42, 129], [42, 132], [42, 133], [42, 145], [42, 163], [42, 164], [42, 166], [42, 177], [42, 178], [43, 49], [43, 58], [43, 75], [43, 85], [43, 93], [43, 96], [43, 106], [43, 114], [43, 119], [43, 122], [43, 128], [43, 132], [43, 139], [43, 140], [43, 156], [43, 158], [43, 159], [43, 162], [43, 163], [43, 165], [43, 166], [44, 58], [44, 66], [44, 70], [44, 78], [44, 88], [44, 104], [44, 106], [44, 113], [44, 117], [44, 120], [44, 121], [44, 124], [44, 130], [44, 135], [44, 137], [44, 138], [44, 152], [44, 158], [44, 159], [44, 160], [44, 165], [44, 167], [44, 172], [44, 176], [45, 48], [45, 51], [45, 61], [45, 69], [45, 70], [45, 74], [45, 76], [45, 82], [45, 84], [45, 86], [45, 88], [45, 91], [45, 100], [45, 108], [45, 118], [45, 119], [45, 124], [45, 127], [45, 129], [45, 134], [45, 146], [45, 148], [45, 149], [45, 150], [45, 156], [45, 162], [45, 166], [45, 169], [45, 172], [45, 175], [45, 176], [46, 48], [46, 54], [46, 58], [46, 59], [46, 63], [46, 64], [46, 65], [46, 66], [46, 72], [46, 74], [46, 80], [46, 81], [46, 90], [46, 94], [46, 95], [46, 104], [46, 105], [46, 124], [46, 128], [46, 132], [46, 133], [46, 140], [46, 152], [46, 156], [46, 159], [46, 160], [46, 163], [46, 164], [46, 169], [46, 171], [46, 173], [46, 174], [46, 178], [47, 52], [47, 67], [47, 69], [47, 71], [47, 75], [47, 79], [47, 87], [47, 91], [47, 93], [47, 102], [47, 103], [47, 106], [47, 108], [47, 114], [47, 121], [47, 122], [47, 126], [47, 128], [47, 136], [47, 137], [47, 143], [47, 151], [47, 154], [47, 155], [47, 157], [47, 164], [47, 170], [47, 171], [47, 172], [47, 177], [47, 178], [48, 51], [48, 57], [48, 61], [48, 65], [48, 66], [48, 68], [48, 72], [48, 73], [48, 74], [48, 76], [48, 79], [48, 82], [48, 84], [48, 88], [48, 91], [48, 93], [48, 100], [48, 102], [48, 103], [48, 106], [48, 115], [48, 120], [48, 124], [48, 132], [48, 142], [48, 144], [48, 148], [48, 150], [48, 152], [48, 163], [48, 168], [48, 170], [49, 52], [49, 53], [49, 56], [49, 60], [49, 64], [49, 77], [49, 79], [49, 83], [49, 86], [49, 88], [49, 96], [49, 98], [49, 100], [49, 111], [49, 116], [49, 118], [49, 121], [49, 128], [49, 130], [49, 137], [49, 141], [49, 155], [49, 164], [49, 176], [50, 53], [50, 62], [50, 65], [50, 66], [50, 68], [50, 72], [50, 73], [50, 76], [50, 79], [50, 86], [50, 88], [50, 91], [50, 92], [50, 93], [50, 101], [50, 102], [50, 104], [50, 105], [50, 110], [50, 115], [50, 120], [50, 126], [50, 136], [50, 143], [50, 146], [50, 147], [50, 151], [50, 163], [50, 164], [50, 165], [50, 166], [50, 172], [51, 57], [51, 67], [51, 69], [51, 82], [51, 98], [51, 100], [51, 102], [51, 108], [51, 109], [51, 110], [51, 112], [51, 113], [51, 114], [51, 116], [51, 123], [51, 127], [51, 145], [51, 153], [51, 157], [51, 161], [51, 165], [51, 171], [51, 176], [51, 179], [52, 55], [52, 67], [52, 70], [52, 71], [52, 84], [52, 91], [52, 111], [52, 119], [52, 121], [52, 124], [52, 125], [52, 130], [52, 136], [52, 141], [52, 150], [52, 161], [52, 162], [52, 177], [52, 178], [53, 56], [53, 58], [53, 61], [53, 66], [53, 79], [53, 84], [53, 87], [53, 88], [53, 92], [53, 95], [53, 96], [53, 98], [53, 102], [53, 105], [53, 109], [53, 110], [53, 111], [53, 114], [53, 115], [53, 122], [53, 123], [53, 128], [53, 129], [53, 130], [53, 133], [53, 137], [53, 144], [53, 153], [53, 160], [53, 164], [53, 166], [53, 168], [53, 170], [53, 175], [54, 56], [54, 62], [54, 66], [54, 67], [54, 72], [54, 78], [54, 79], [54, 82], [54, 85], [54, 86], [54, 90], [54, 93], [54, 101], [54, 108], [54, 111], [54, 120], [54, 127], [54, 134], [54, 137], [54, 140], [54, 145], [54, 159], [54, 160], [54, 163], [54, 165], [54, 169], [54, 172], [55, 64], [55, 65], [55, 66], [55, 74], [55, 77], [55, 79], [55, 85], [55, 89], [55, 98], [55, 99], [55, 111], [55, 117], [55, 118], [55, 119], [55, 121], [55, 124], [55, 127], [55, 131], [55, 132], [55, 133], [55, 134], [55, 137], [55, 140], [55, 141], [55, 142], [55, 148], [55, 151], [55, 174], [55, 178], [56, 57], [56, 68], [56, 72], [56, 81], [56, 82], [56, 83], [56, 84], [56, 96], [56, 103], [56, 107], [56, 109], [56, 110], [56, 116], [56, 118], [56, 124], [56, 127], [56, 151], [56, 155], [56, 156], [56, 159], [56, 163], [56, 167], [56, 170], [56, 172], [56, 177], [57, 62], [57, 79], [57, 87], [57, 88], [57, 90], [57, 92], [57, 93], [57, 97], [57, 102], [57, 112], [57, 113], [57, 116], [57, 117], [57, 120], [57, 130], [57, 135], [57, 136], [57, 139], [57, 146], [57, 147], [57, 148], [57, 149], [57, 150], [57, 158], [58, 60], [58, 72], [58, 83], [58, 85], [58, 86], [58, 88], [58, 89], [58, 95], [58, 99], [58, 101], [58, 107], [58, 108], [58, 111], [58, 112], [58, 115], [58, 119], [58, 123], [58, 125], [58, 136], [58, 141], [58, 154], [58, 159], [58, 170], [58, 177], [59, 60], [59, 67], [59, 80], [59, 81], [59, 83], [59, 89], [59, 93], [59, 101], [59, 103], [59, 104], [59, 111], [59, 112], [59, 128], [59, 132], [59, 136], [59, 141], [59, 143], [59, 145], [59, 148], [59, 153], [59, 156], [59, 163], [59, 176], [60, 62], [60, 82], [60, 83], [60, 85], [60, 91], [60, 94], [60, 98], [60, 99], [60, 114], [60, 116], [60, 128], [60, 132], [60, 133], [60, 134], [60, 139], [60, 144], [60, 146], [60, 147], [60, 153], [60, 157], [60, 161], [60, 165], [60, 169], [60, 174], [61, 68], [61, 71], [61, 77], [61, 87], [61, 92], [61, 93], [61, 115], [61, 116], [61, 119], [61, 129], [61, 131], [61, 151], [61, 178], [62, 64], [62, 74], [62, 76], [62, 77], [62, 81], [62, 82], [62, 86], [62, 88], [62, 90], [62, 98], [62, 100], [62, 105], [62, 107], [62, 108], [62, 113], [62, 114], [62, 119], [62, 121], [62, 128], [62, 138], [62, 142], [62, 145], [62, 155], [62, 158], [62, 168], [62, 171], [62, 172], [62, 174], [62, 179], [63, 65], [63, 71], [63, 81], [63, 83], [63, 87], [63, 88], [63, 91], [63, 92], [63, 102], [63, 104], [63, 107], [63, 108], [63, 114], [63, 118], [63, 123], [63, 125], [63, 126], [63, 127], [63, 131], [63, 133], [63, 140], [63, 142], [63, 143], [63, 144], [63, 145], [63, 149], [63, 163], [63, 165], [63, 170], [63, 174], [63, 176], [63, 177], [64, 65], [64, 68], [64, 69], [64, 70], [64, 72], [64, 86], [64, 90], [64, 97], [64, 99], [64, 101], [64, 104], [64, 118], [64, 123], [64, 124], [64, 126], [64, 138], [64, 139], [64, 151], [64, 152], [64, 154], [64, 160], [64, 161], [64, 163], [64, 168], [64, 169], [64, 174], [65, 75], [65, 78], [65, 79], [65, 87], [65, 88], [65, 100], [65, 105], [65, 116], [65, 118], [65, 125], [65, 126], [65, 135], [65, 137], [65, 138], [65, 141], [65, 146], [65, 147], [65, 152], [65, 154], [65, 159], [65, 161], [65, 162], [65, 169], [65, 174], [66, 67], [66, 68], [66, 75], [66, 79], [66, 81], [66, 82], [66, 84], [66, 94], [66, 96], [66, 98], [66, 102], [66, 111], [66, 112], [66, 114], [66, 116], [66, 117], [66, 125], [66, 126], [66, 130], [66, 131], [66, 133], [66, 134], [66, 138], [66, 141], [66, 144], [66, 145], [66, 154], [66, 157], [66, 159], [66, 163], [66, 164], [66, 171], [66, 172], [67, 70], [67, 71], [67, 77], [67, 83], [67, 84], [67, 86], [67, 89], [67, 94], [67, 97], [67, 98], [67, 101], [67, 106], [67, 108], [67, 117], [67, 135], [67, 147], [67, 155], [67, 157], [67, 161], [67, 169], [67, 177], [68, 70], [68, 72], [68, 73], [68, 78], [68, 80], [68, 87], [68, 88], [68, 89], [68, 94], [68, 95], [68, 97], [68, 99], [68, 106], [68, 108], [68, 118], [68, 123], [68, 126], [68, 130], [68, 135], [68, 136], [68, 138], [68, 140], [68, 142], [68, 153], [68, 158], [68, 159], [69, 72], [69, 73], [69, 81], [69, 83], [69, 88], [69, 98], [69, 99], [69, 110], [69, 118], [69, 122], [69, 128], [69, 130], [69, 131], [69, 134], [69, 147], [69, 155], [69, 159], [69, 165], [69, 167], [69, 169], [69, 173], [70, 71], [70, 73], [70, 81], [70, 82], [70, 85], [70, 89], [70, 103], [70, 106], [70, 110], [70, 118], [70, 124], [70, 136], [70, 139], [70, 140], [70, 143], [70, 144], [70, 145], [70, 168], [70, 171], [70, 173], [70, 175], [71, 86], [71, 91], [71, 97], [71, 112], [71, 113], [71, 117], [71, 121], [71, 123], [71, 130], [71, 136], [71, 142], [71, 143], [71, 152], [71, 154], [71, 156], [71, 163], [71, 171], [72, 81], [72, 84], [72, 85], [72, 86], [72, 89], [72, 91], [72, 92], [72, 100], [72, 101], [72, 107], [72, 110], [72, 115], [72, 120], [72, 121], [72, 125], [72, 127], [72, 129], [72, 131], [72, 133], [72, 135], [72, 136], [72, 139], [72, 145], [72, 146], [72, 147], [72, 149], [72, 150], [72, 163], [72, 164], [72, 165], [72, 169], [72, 175], [73, 76], [73, 79], [73, 81], [73, 84], [73, 88], [73, 92], [73, 96], [73, 97], [73, 102], [73, 103], [73, 106], [73, 110], [73, 111], [73, 118], [73, 119], [73, 129], [73, 134], [73, 137], [73, 138], [73, 139], [73, 140], [73, 143], [73, 144], [73, 151], [73, 155], [73, 162], [73, 163], [73, 164], [73, 167], [73, 168], [73, 169], [73, 173], [73, 175], [74, 77], [74, 87], [74, 91], [74, 95], [74, 104], [74, 107], [74, 111], [74, 116], [74, 117], [74, 130], [74, 131], [74, 140], [74, 142], [74, 144], [74, 153], [74, 155], [74, 157], [74, 158], [74, 160], [74, 167], [74, 168], [74, 170], [75, 76], [75, 79], [75, 87], [75, 89], [75, 90], [75, 93], [75, 97], [75, 100], [75, 105], [75, 112], [75, 115], [75, 124], [75, 137], [75, 141], [75, 144], [75, 146], [75, 149], [75, 150], [75, 154], [75, 169], [75, 176], [75, 177], [76, 89], [76, 92], [76, 94], [76, 97], [76, 98], [76, 101], [76, 103], [76, 107], [76, 108], [76, 110], [76, 127], [76, 130], [76, 136], [76, 141], [76, 149], [76, 158], [76, 178], [77, 107], [77, 114], [77, 117], [77, 122], [77, 144], [77, 149], [77, 158], [77, 164], [77, 165], [77, 174], [78, 85], [78, 93], [78, 95], [78, 109], [78, 113], [78, 116], [78, 117], [78, 120], [78, 124], [78, 125], [78, 134], [78, 137], [78, 146], [78, 147], [78, 151], [78, 153], [78, 154], [78, 156], [78, 157], [78, 161], [78, 165], [79, 83], [79, 92], [79, 94], [79, 97], [79, 101], [79, 103], [79, 107], [79, 113], [79, 116], [79, 117], [79, 119], [79, 132], [79, 135], [79, 139], [79, 143], [79, 159], [79, 160], [79, 171], [79, 175], [80, 88], [80, 94], [80, 95], [80, 105], [80, 108], [80, 114], [80, 118], [80, 119], [80, 124], [80, 127], [80, 131], [80, 134], [80, 146], [80, 147], [80, 148], [80, 150], [80, 163], [80, 168], [80, 169], [80, 174], [80, 175], [80, 177], [81, 83], [81, 86], [81, 92], [81, 94], [81, 102], [81, 103], [81, 104], [81, 105], [81, 107], [81, 113], [81, 115], [81, 132], [81, 134], [81, 138], [81, 142], [81, 147], [81, 151], [81, 153], [81, 154], [81, 155], [81, 163], [81, 164], [82, 85], [82, 88], [82, 95], [82, 100], [82, 102], [82, 103], [82, 104], [82, 115], [82, 118], [82, 124], [82, 131], [82, 138], [82, 143], [82, 144], [82, 148], [82, 163], [82, 172], [82, 174], [82, 175], [82, 177], [82, 178], [83, 85], [83, 87], [83, 91], [83, 93], [83, 99], [83, 102], [83, 115], [83, 118], [83, 125], [83, 139], [83, 145], [83, 152], [83, 153], [83, 154], [83, 155], [83, 156], [83, 164], [83, 166], [83, 177], [84, 88], [84, 89], [84, 100], [84, 106], [84, 115], [84, 119], [84, 122], [84, 135], [84, 151], [84, 154], [84, 167], [84, 169], [84, 173], [84, 174], [84, 177], [85, 90], [85, 94], [85, 95], [85, 98], [85, 99], [85, 108], [85, 112], [85, 113], [85, 117], [85, 126], [85, 131], [85, 134], [85, 135], [85, 151], [85, 163], [85, 178], [86, 93], [86, 105], [86, 111], [86, 121], [86, 128], [86, 145], [86, 146], [86, 148], [86, 149], [86, 153], [86, 158], [86, 161], [86, 162], [86, 177], [87, 90], [87, 92], [87, 99], [87, 102], [87, 104], [87, 107], [87, 110], [87, 114], [87, 119], [87, 136], [87, 140], [87, 141], [87, 152], [87, 156], [87, 159], [87, 164], [87, 165], [87, 171], [87, 175], [87, 177], [88, 94], [88, 96], [88, 111], [88, 116], [88, 118], [88, 119], [88, 123], [88, 125], [88, 138], [88, 139], [88, 140], [88, 142], [88, 145], [88, 146], [88, 153], [88, 174], [89, 91], [89, 92], [89, 100], [89, 101], [89, 117], [89, 124], [89, 125], [89, 132], [89, 139], [89, 140], [89, 141], [89, 143], [89, 150], [89, 159], [89, 167], [89, 174], [90, 98], [90, 100], [90, 103], [90, 109], [90, 120], [90, 123], [90, 129], [90, 130], [90, 139], [90, 141], [90, 143], [90, 145], [90, 147], [90, 150], [90, 155], [90, 156], [90, 159], [90, 162], [90, 169], [90, 171], [90, 179], [91, 94], [91, 101], [91, 104], [91, 106], [91, 108], [91, 112], [91, 115], [91, 116], [91, 118], [91, 127], [91, 128], [91, 129], [91, 130], [91, 133], [91, 135], [91, 139], [91, 140], [91, 148], [91, 157], [91, 173], [92, 97], [92, 100], [92, 105], [92, 113], [92, 119], [92, 120], [92, 132], [92, 138], [92, 140], [92, 152], [92, 157], [92, 158], [92, 165], [92, 166], [92, 172], [92, 178], [93, 95], [93, 104], [93, 114], [93, 116], [93, 122], [93, 127], [93, 129], [93, 130], [93, 133], [93, 137], [93, 138], [93, 140], [93, 143], [93, 150], [93, 151], [93, 164], [93, 169], [93, 176], [94, 96], [94, 97], [94, 98], [94, 101], [94, 105], [94, 112], [94, 120], [94, 123], [94, 125], [94, 129], [94, 132], [94, 134], [94, 139], [94, 141], [94, 145], [94, 150], [94, 157], [94, 159], [94, 168], [94, 176], [94, 177], [95, 98], [95, 109], [95, 113], [95, 124], [95, 125], [95, 135], [95, 137], [95, 144], [95, 154], [95, 156], [95, 165], [95, 167], [95, 169], [95, 179], [96, 105], [96, 106], [96, 108], [96, 117], [96, 123], [96, 130], [96, 147], [96, 153], [96, 154], [96, 161], [96, 162], [96, 174], [96, 176], [96, 179], [97, 100], [97, 101], [97, 102], [97, 113], [97, 115], [97, 125], [97, 127], [97, 128], [97, 129], [97, 132], [97, 141], [97, 143], [97, 149], [97, 156], [97, 157], [97, 163], [97, 169], [97, 175], [97, 176], [98, 100], [98, 103], [98, 105], [98, 106], [98, 107], [98, 118], [98, 127], [98, 138], [98, 145], [98, 149], [98, 153], [98, 155], [98, 159], [98, 164], [98, 174], [99, 103], [99, 106], [99, 110], [99, 121], [99, 122], [99, 123], [99, 125], [99, 132], [99, 134], [99, 139], [99, 147], [99, 153], [99, 157], [99, 159], [99, 161], [99, 170], [99, 171], [100, 101], [100, 102], [100, 107], [100, 114], [100, 116], [100, 119], [100, 123], [100, 129], [100, 132], [100, 135], [100, 142], [100, 146], [100, 148], [100, 149], [100, 153], [100, 167], [100, 169], [100, 170], [100, 171], [100, 173], [101, 110], [101, 113], [101, 116], [101, 141], [101, 142], [101, 145], [101, 152], [101, 162], [101, 163], [101, 165], [101, 170], [101, 172], [101, 173], [101, 179], [102, 105], [102, 110], [102, 113], [102, 119], [102, 122], [102, 128], [102, 134], [102, 146], [102, 150], [102, 154], [102, 177], [103, 119], [103, 124], [103, 127], [103, 131], [103, 134], [103, 136], [103, 139], [103, 145], [103, 146], [103, 152], [103, 162], [103, 179], [104, 108], [104, 109], [104, 113], [104, 118], [104, 120], [104, 127], [104, 131], [104, 133], [104, 136], [104, 145], [104, 153], [104, 158], [104, 164], [104, 167], [104, 169], [104, 171], [104, 179], [105, 111], [105, 118], [105, 131], [105, 132], [105, 135], [105, 137], [105, 146], [105, 151], [105, 159], [105, 164], [105, 167], [105, 168], [105, 173], [105, 176], [105, 179], [106, 114], [106, 117], [106, 127], [106, 128], [106, 132], [106, 137], [106, 144], [106, 145], [106, 150], [106, 151], [106, 154], [106, 159], [106, 165], [106, 175], [107, 108], [107, 109], [107, 112], [107, 124], [107, 129], [107, 133], [107, 140], [107, 150], [107, 165], [107, 170], [107, 174], [107, 176], [107, 179], [108, 116], [108, 117], [108, 118], [108, 129], [108, 134], [108, 135], [108, 139], [108, 146], [108, 148], [108, 150], [108, 163], [108, 166], [108, 169], [108, 170], [109, 112], [109, 120], [109, 125], [109, 130], [109, 131], [109, 134], [109, 136], [109, 138], [109, 143], [109, 145], [109, 152], [109, 158], [109, 169], [109, 171], [109, 174], [109, 175], [110, 111], [110, 112], [110, 113], [110, 130], [110, 134], [110, 140], [110, 141], [110, 142], [110, 144], [110, 146], [110, 147], [110, 156], [110, 157], [110, 158], [110, 161], [110, 164], [110, 166], [110, 169], [110, 178], [111, 118], [111, 131], [111, 134], [111, 135], [111, 146], [111, 149], [111, 155], [111, 161], [111, 169], [111, 174], [112, 113], [112, 118], [112, 120], [112, 121], [112, 154], [112, 155], [112, 157], [112, 161], [112, 169], [112, 170], [113, 120], [113, 122], [113, 124], [113, 126], [113, 132], [113, 136], [113, 139], [113, 143], [113, 144], [113, 145], [113, 147], [113, 149], [113, 152], [113, 163], [113, 164], [113, 165], [113, 171], [113, 172], [114, 116], [114, 123], [114, 131], [114, 134], [114, 136], [114, 140], [114, 146], [114, 147], [114, 148], [114, 150], [114, 151], [114, 159], [114, 161], [114, 163], [114, 166], [114, 168], [114, 170], [114, 173], [114, 174], [115, 117], [115, 118], [115, 119], [115, 126], [115, 129], [115, 132], [115, 139], [115, 143], [115, 146], [115, 147], [115, 150], [115, 157], [115, 164], [115, 171], [115, 172], [115, 174], [115, 179], [116, 131], [116, 133], [116, 139], [116, 147], [116, 150], [116, 159], [116, 162], [116, 172], [116, 174], [116, 178], [117, 119], [117, 131], [117, 136], [117, 139], [117, 144], [117, 156], [117, 157], [117, 163], [117, 166], [117, 168], [117, 169], [117, 174], [117, 175], [117, 176], [117, 178], [118, 119], [118, 120], [118, 123], [118, 125], [118, 127], [118, 128], [118, 132], [118, 141], [118, 145], [118, 147], [118, 149], [118, 153], [118, 154], [118, 156], [118, 158], [118, 161], [118, 164], [118, 174], [119, 128], [119, 130], [119, 136], [119, 143], [119, 147], [119, 148], [119, 159], [119, 161], [119, 162], [119, 166], [119, 169], [120, 137], [120, 138], [120, 141], [120, 144], [120, 149], [120, 151], [120, 165], [120, 179], [121, 126], [121, 130], [121, 139], [121, 145], [121, 149], [121, 151], [121, 156], [121, 158], [121, 161], [121, 164], [121, 169], [121, 173], [121, 176], [122, 124], [122, 127], [122, 129], [122, 130], [122, 131], [122, 144], [122, 153], [122, 158], [122, 164], [122, 178], [123, 124], [123, 134], [123, 136], [123, 141], [123, 142], [123, 143], [123, 149], [123, 152], [123, 160], [123, 164], [123, 166], [123, 175], [123, 177], [123, 179], [124, 141], [124, 143], [124, 151], [124, 157], [124, 162], [124, 164], [124, 170], [125, 126], [125, 128], [125, 131], [125, 136], [125, 146], [125, 153], [125, 165], [125, 171], [126, 127], [126, 128], [126, 141], [126, 142], [126, 148], [126, 158], [126, 160], [126, 164], [126, 168], [126, 169], [126, 171], [127, 139], [127, 145], [127, 153], [127, 156], [127, 158], [127, 162], [127, 164], [127, 167], [127, 168], [127, 174], [127, 176], [128, 139], [128, 145], [128, 153], [128, 161], [128, 168], [128, 177], [129, 132], [129, 135], [129, 140], [129, 148], [129, 149], [129, 166], [129, 172], [129, 174], [129, 175], [129, 177], [129, 178], [130, 133], [130, 137], [130, 159], [130, 166], [130, 167], [130, 168], [130, 171], [130, 179], [131, 133], [131, 136], [131, 143], [131, 157], [131, 162], [131, 163], [131, 172], [131, 173], [131, 179], [132, 134], [132, 135], [132, 136], [132, 141], [132, 142], [132, 149], [132, 153], [132, 154], [132, 155], [132, 157], [132, 159], [132, 164], [132, 165], [132, 178], [132, 179], [133, 134], [133, 139], [133, 143], [133, 144], [133, 146], [133, 154], [133, 165], [133, 166], [133, 171], [133, 175], [133, 177], [133, 178], [134, 140], [134, 152], [134, 153], [134, 164], [134, 167], [134, 169], [135, 140], [135, 143], [135, 153], [135, 155], [135, 156], [135, 160], [135, 164], [135, 167], [136, 142], [136, 145], [136, 148], [136, 151], [136, 153], [136, 154], [136, 160], [136, 162], [136, 173], [137, 149], [137, 152], [137, 156], [137, 163], [137, 167], [137, 176], [137, 177], [138, 140], [138, 143], [138, 150], [138, 152], [138, 155], [138, 168], [138, 170], [139, 140], [139, 146], [139, 149], [139, 150], [139, 153], [139, 156], [139, 162], [140, 150], [140, 165], [140, 172], [140, 173], [140, 174], [141, 145], [141, 147], [141, 155], [141, 160], [141, 162], [141, 175], [142, 144], [142, 145], [142, 148], [142, 153], [142, 154], [142, 165], [142, 170], [143, 146], [143, 151], [143, 156], [143, 157], [143, 163], [143, 165], [143, 166], [143, 170], [143, 173], [144, 149], [144, 152], [144, 161], [144, 164], [144, 166], [144, 170], [144, 174], [144, 178], [145, 147], [145, 151], [145, 152], [145, 153], [145, 156], [145, 158], [145, 163], [145, 164], [145, 168], [145, 171], [145, 174], [145, 175], [145, 177], [146, 148], [146, 161], [146, 164], [146, 166], [146, 167], [146, 172], [147, 169], [147, 174], [147, 175], [147, 176], [147, 178], [147, 179], [148, 156], [148, 158], [148, 166], [148, 168], [148, 172], [148, 173], [148, 177], [149, 150], [149, 152], [149, 161], [149, 176], [150, 151], [150, 155], [150, 156], [150, 159], [150, 161], [150, 167], [150, 176], [150, 178], [150, 179], [151, 155], [151, 164], [151, 165], [151, 170], [151, 172], [151, 175], [152, 159], [152, 168], [152, 170], [152, 172], [152, 175], [153, 155], [153, 164], [153, 166], [153, 173], [153, 174], [154, 157], [154, 161], [154, 171], [154, 174], [155, 158], [155, 164], [155, 167], [155, 168], [155, 175], [156, 158], [156, 159], [156, 165], [156, 169], [156, 170], [156, 176], [156, 178], [156, 179], [157, 158], [157, 169], [157, 170], [157, 179], [158, 162], [158, 164], [158, 168], [158, 171], [158, 174], [158, 177], [159, 166], [159, 170], [159, 174], [160, 162], [160, 163], [160, 166], [161, 166], [161, 170], [161, 172], [162, 177], [162, 178], [163, 169], [163, 172], [163, 179], [164, 174], [165, 169], [165, 171], [166, 167], [167, 168], [167, 170], [170, 173], [170, 174], [170, 177], [171, 172], [171, 178], [172, 173], [172, 175], [173, 176], [174, 175], [175, 179], [176, 179], [178, 179]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l5-s0/solution/solve.sh b/tasks/construct-nppc-dominating-set-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9ff6e5bb842f028d487a6d3fee6e57babec009ec --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [3, 36, 62, 66, 67, 68, 72, 93, 100, 118, 124, 140, 145, 169, 178]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l5-s0/tests/check.py b/tasks/construct-nppc-dominating-set-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-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-l5-s0/tests/instance.json b/tasks/construct-nppc-dominating-set-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..09ab6fbb1441243c9c71b878b4927953e81166f5 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 180, "k": 15, "edges": [[0, 5], [0, 8], [0, 16], [0, 17], [0, 33], [0, 39], [0, 43], [0, 61], [0, 66], [0, 69], [0, 74], [0, 77], [0, 79], [0, 85], [0, 89], [0, 93], [0, 94], [0, 102], [0, 112], [0, 128], [0, 129], [0, 132], [0, 137], [0, 138], [0, 143], [0, 144], [0, 147], [0, 156], [0, 157], [0, 158], [0, 161], [0, 164], [0, 166], [0, 178], [1, 5], [1, 7], [1, 16], [1, 22], [1, 38], [1, 46], [1, 48], [1, 60], [1, 66], [1, 68], [1, 75], [1, 78], [1, 81], [1, 101], [1, 112], [1, 139], [1, 145], [1, 150], [1, 155], [1, 160], [1, 162], [1, 166], [1, 167], [1, 172], [1, 177], [2, 6], [2, 8], [2, 13], [2, 14], [2, 18], [2, 27], [2, 29], [2, 33], [2, 34], [2, 36], [2, 44], [2, 55], [2, 62], [2, 63], [2, 65], [2, 66], [2, 67], [2, 69], [2, 74], [2, 75], [2, 80], [2, 81], [2, 90], [2, 93], [2, 95], [2, 100], [2, 115], [2, 118], [2, 119], [2, 131], [2, 136], [2, 140], [2, 145], [2, 153], [2, 157], [2, 159], [2, 160], [2, 161], [2, 164], [2, 170], [3, 4], [3, 5], [3, 11], [3, 16], [3, 19], [3, 21], [3, 23], [3, 24], [3, 35], [3, 39], [3, 45], [3, 53], [3, 58], [3, 64], [3, 69], [3, 71], [3, 73], [3, 76], [3, 77], [3, 82], [3, 85], [3, 86], [3, 93], [3, 94], [3, 97], [3, 104], [3, 106], [3, 110], [3, 115], [3, 122], [3, 129], [3, 132], [3, 137], [3, 150], [3, 153], [3, 166], [3, 173], [3, 174], [3, 179], [4, 9], [4, 11], [4, 13], [4, 17], [4, 22], [4, 24], [4, 27], [4, 30], [4, 32], [4, 34], [4, 35], [4, 37], [4, 41], [4, 54], [4, 59], [4, 71], [4, 76], [4, 85], [4, 88], [4, 89], [4, 93], [4, 98], [4, 100], [4, 103], [4, 106], [4, 107], [4, 108], [4, 113], [4, 115], [4, 128], [4, 136], [4, 137], [4, 147], [4, 158], [4, 162], [4, 171], [4, 174], [5, 6], [5, 8], [5, 10], [5, 20], [5, 38], [5, 40], [5, 42], [5, 47], [5, 53], [5, 57], [5, 58], [5, 64], [5, 81], [5, 83], [5, 84], [5, 94], [5, 100], [5, 110], [5, 112], [5, 116], [5, 123], [5, 131], [5, 142], [5, 146], [5, 153], [5, 157], [5, 162], [5, 178], [6, 20], [6, 30], [6, 34], [6, 36], [6, 37], [6, 44], [6, 48], [6, 60], [6, 75], [6, 79], [6, 80], [6, 81], [6, 82], [6, 91], [6, 95], [6, 103], [6, 108], [6, 109], [6, 120], [6, 124], [6, 126], [6, 134], [6, 138], [6, 140], [6, 142], [6, 147], [6, 150], [6, 159], [6, 165], [7, 8], [7, 15], [7, 16], [7, 18], [7, 19], [7, 21], [7, 22], [7, 25], [7, 32], [7, 35], [7, 46], [7, 54], [7, 55], [7, 65], [7, 66], [7, 91], [7, 95], [7, 97], [7, 98], [7, 101], [7, 104], [7, 106], [7, 118], [7, 120], [7, 124], [7, 125], [7, 128], [7, 129], [7, 134], [7, 135], [7, 138], [7, 140], [7, 141], [7, 148], [7, 151], [7, 155], [7, 160], [7, 165], [7, 169], [8, 11], [8, 16], [8, 29], [8, 32], [8, 39], [8, 44], [8, 45], [8, 53], [8, 72], [8, 73], [8, 88], [8, 97], [8, 100], [8, 102], [8, 107], [8, 110], [8, 115], [8, 120], [8, 122], [8, 124], [8, 127], [8, 128], [8, 129], [8, 134], [8, 135], [8, 142], [8, 144], [8, 149], [8, 150], [8, 155], [8, 163], [8, 167], [8, 169], [8, 170], [8, 172], [8, 176], [8, 178], [9, 10], [9, 14], [9, 16], [9, 25], [9, 28], [9, 29], [9, 31], [9, 36], [9, 49], [9, 54], [9, 56], [9, 62], [9, 85], [9, 87], [9, 96], [9, 99], [9, 101], [9, 114], [9, 118], [9, 119], [9, 122], [9, 125], [9, 131], [9, 133], [9, 137], [9, 139], [9, 143], [9, 152], [9, 157], [9, 163], [9, 164], [9, 174], [9, 175], [9, 179], [10, 12], [10, 24], [10, 28], [10, 34], [10, 42], [10, 49], [10, 54], [10, 56], [10, 58], [10, 64], [10, 66], [10, 81], [10, 88], [10, 97], [10, 98], [10, 102], [10, 104], [10, 105], [10, 107], [10, 112], [10, 115], [10, 124], [10, 125], [10, 130], [10, 135], [10, 141], [10, 144], [10, 145], [10, 147], [10, 151], [10, 158], [10, 159], [10, 165], [10, 166], [10, 172], [10, 173], [11, 13], [11, 18], [11, 19], [11, 21], [11, 22], [11, 26], [11, 31], [11, 33], [11, 35], [11, 39], [11, 40], [11, 43], [11, 47], [11, 48], [11, 50], [11, 53], [11, 55], [11, 58], [11, 60], [11, 62], [11, 67], [11, 69], [11, 71], [11, 89], [11, 95], [11, 102], [11, 108], [11, 109], [11, 112], [11, 118], [11, 119], [11, 122], [11, 126], [11, 133], [11, 135], [11, 137], [11, 138], [11, 144], [11, 146], [11, 147], [11, 152], [11, 154], [11, 160], [11, 166], [11, 167], [11, 169], [11, 171], [11, 172], [11, 176], [11, 178], [12, 22], [12, 25], [12, 32], [12, 35], [12, 36], [12, 49], [12, 51], [12, 52], [12, 55], [12, 60], [12, 66], [12, 74], [12, 78], [12, 79], [12, 87], [12, 89], [12, 90], [12, 92], [12, 97], [12, 99], [12, 108], [12, 110], [12, 111], [12, 114], [12, 122], [12, 124], [12, 126], [12, 135], [12, 138], [12, 143], [12, 145], [12, 152], [12, 157], [12, 161], [12, 162], [12, 171], [12, 174], [12, 176], [12, 177], [12, 178], [13, 19], [13, 20], [13, 22], [13, 29], [13, 32], [13, 36], [13, 40], [13, 44], [13, 46], [13, 48], [13, 56], [13, 60], [13, 62], [13, 68], [13, 69], [13, 71], [13, 72], [13, 80], [13, 81], [13, 82], [13, 84], [13, 88], [13, 103], [13, 107], [13, 108], [13, 114], [13, 115], [13, 119], [13, 124], [13, 125], [13, 135], [13, 140], [13, 147], [13, 149], [13, 150], [13, 162], [13, 163], [13, 165], [13, 170], [13, 171], [13, 175], [13, 176], [13, 178], [13, 179], [14, 16], [14, 22], [14, 26], [14, 31], [14, 40], [14, 43], [14, 44], [14, 46], [14, 50], [14, 55], [14, 56], [14, 68], [14, 73], [14, 79], [14, 83], [14, 85], [14, 87], [14, 88], [14, 90], [14, 92], [14, 93], [14, 99], [14, 100], [14, 103], [14, 110], [14, 111], [14, 113], [14, 119], [14, 121], [14, 125], [14, 132], [14, 133], [14, 134], [14, 139], [14, 144], [14, 145], [14, 148], [14, 149], [14, 165], [14, 166], [14, 168], [14, 169], [14, 170], [14, 177], [15, 19], [15, 24], [15, 26], [15, 29], [15, 31], [15, 38], [15, 40], [15, 41], [15, 43], [15, 46], [15, 51], [15, 53], [15, 55], [15, 58], [15, 59], [15, 64], [15, 66], [15, 72], [15, 77], [15, 86], [15, 88], [15, 91], [15, 96], [15, 99], [15, 100], [15, 101], [15, 106], [15, 108], [15, 113], [15, 128], [15, 138], [15, 155], [15, 157], [15, 162], [15, 179], [16, 25], [16, 28], [16, 30], [16, 37], [16, 43], [16, 47], [16, 49], [16, 66], [16, 69], [16, 73], [16, 81], [16, 84], [16, 97], [16, 105], [16, 113], [16, 116], [16, 121], [16, 125], [16, 131], [16, 134], [16, 138], [16, 148], [16, 151], [16, 161], [16, 162], [16, 165], [16, 169], [16, 175], [16, 179], [17, 27], [17, 38], [17, 48], [17, 53], [17, 64], [17, 69], [17, 72], [17, 79], [17, 80], [17, 82], [17, 87], [17, 95], [17, 96], [17, 99], [17, 100], [17, 104], [17, 107], [17, 109], [17, 114], [17, 115], [17, 119], [17, 120], [17, 125], [17, 130], [17, 131], [17, 136], [17, 147], [17, 152], [17, 153], [17, 161], [17, 162], [17, 164], [17, 166], [17, 170], [17, 174], [17, 177], [17, 178], [18, 21], [18, 25], [18, 26], [18, 52], [18, 54], [18, 74], [18, 77], [18, 79], [18, 80], [18, 89], [18, 118], [18, 125], [18, 129], [18, 132], [18, 136], [18, 144], [18, 145], [18, 149], [18, 150], [18, 157], [18, 160], [18, 162], [18, 168], [18, 171], [18, 172], [18, 173], [18, 176], [19, 29], [19, 30], [19, 36], [19, 38], [19, 40], [19, 44], [19, 55], [19, 57], [19, 63], [19, 64], [19, 66], [19, 69], [19, 79], [19, 80], [19, 81], [19, 85], [19, 86], [19, 111], [19, 118], [19, 121], [19, 127], [19, 136], [19, 141], [19, 147], [19, 149], [19, 166], [19, 170], [19, 172], [19, 175], [19, 176], [20, 24], [20, 26], [20, 28], [20, 40], [20, 50], [20, 51], [20, 53], [20, 54], [20, 57], [20, 65], [20, 68], [20, 70], [20, 72], [20, 77], [20, 80], [20, 96], [20, 110], [20, 118], [20, 129], [20, 130], [20, 131], [20, 137], [20, 145], [20, 147], [20, 148], [20, 154], [20, 155], [20, 165], [20, 168], [20, 169], [21, 23], [21, 29], [21, 31], [21, 33], [21, 43], [21, 59], [21, 61], [21, 66], [21, 68], [21, 69], [21, 72], [21, 73], [21, 83], [21, 88], [21, 94], [21, 101], [21, 102], [21, 106], [21, 109], [21, 116], [21, 120], [21, 126], [21, 131], [21, 152], [21, 153], [21, 161], [21, 163], [21, 169], [21, 170], [21, 173], [21, 175], [22, 25], [22, 26], [22, 28], [22, 34], [22, 35], [22, 44], [22, 53], [22, 58], [22, 60], [22, 62], [22, 63], [22, 76], [22, 79], [22, 83], [22, 92], [22, 93], [22, 96], [22, 98], [22, 99], [22, 106], [22, 108], [22, 113], [22, 116], [22, 118], [22, 119], [22, 122], [22, 123], [22, 126], [22, 128], [22, 131], [22, 137], [22, 140], [22, 141], [22, 153], [22, 157], [22, 159], [22, 161], [22, 163], [22, 165], [22, 175], [23, 25], [23, 27], [23, 36], [23, 43], [23, 44], [23, 47], [23, 55], [23, 58], [23, 63], [23, 64], [23, 66], [23, 84], [23, 90], [23, 103], [23, 105], [23, 107], [23, 109], [23, 111], [23, 115], [23, 118], [23, 124], [23, 127], [23, 128], [23, 135], [23, 139], [23, 140], [23, 141], [23, 149], [23, 150], [23, 153], [23, 154], [23, 156], [23, 158], [23, 165], [23, 168], [23, 171], [24, 27], [24, 31], [24, 39], [24, 40], [24, 42], [24, 49], [24, 50], [24, 61], [24, 64], [24, 66], [24, 73], [24, 77], [24, 84], [24, 96], [24, 98], [24, 105], [24, 109], [24, 111], [24, 115], [24, 118], [24, 122], [24, 128], [24, 134], [24, 139], [24, 144], [24, 155], [24, 156], [24, 161], [24, 165], [24, 168], [24, 169], [24, 171], [24, 174], [24, 177], [24, 178], [25, 28], [25, 33], [25, 39], [25, 41], [25, 45], [25, 63], [25, 69], [25, 71], [25, 74], [25, 76], [25, 80], [25, 90], [25, 91], [25, 95], [25, 103], [25, 104], [25, 107], [25, 110], [25, 115], [25, 124], [25, 126], [25, 130], [25, 135], [25, 143], [25, 146], [25, 147], [25, 151], [25, 154], [25, 155], [25, 157], [25, 160], [25, 162], [25, 176], [25, 177], [26, 36], [26, 37], [26, 47], [26, 64], [26, 71], [26, 73], [26, 75], [26, 87], [26, 91], [26, 94], [26, 96], [26, 98], [26, 100], [26, 107], [26, 108], [26, 111], [26, 112], [26, 115], [26, 122], [26, 124], [26, 138], [26, 139], [26, 140], [26, 141], [26, 146], [26, 148], [26, 155], [26, 159], [26, 161], [26, 162], [26, 168], [26, 175], [26, 179], [27, 34], [27, 38], [27, 40], [27, 41], [27, 47], [27, 48], [27, 62], [27, 64], [27, 72], [27, 78], [27, 83], [27, 85], [27, 94], [27, 97], [27, 101], [27, 111], [27, 113], [27, 116], [27, 127], [27, 132], [27, 135], [27, 143], [27, 152], [27, 156], [27, 157], [27, 162], [27, 177], [27, 178], [28, 29], [28, 31], [28, 34], [28, 41], [28, 42], [28, 62], [28, 65], [28, 66], [28, 67], [28, 68], [28, 76], [28, 77], [28, 83], [28, 87], [28, 104], [28, 107], [28, 113], [28, 115], [28, 124], [28, 125], [28, 128], [28, 130], [28, 134], [28, 136], [28, 145], [28, 151], [28, 157], [28, 167], [28, 173], [28, 179], [29, 30], [29, 34], [29, 36], [29, 37], [29, 39], [29, 52], [29, 54], [29, 59], [29, 62], [29, 74], [29, 75], [29, 88], [29, 97], [29, 101], [29, 120], [29, 121], [29, 124], [29, 126], [29, 127], [29, 133], [29, 135], [29, 146], [29, 152], [29, 153], [29, 162], [29, 164], [29, 165], [29, 167], [29, 168], [29, 171], [29, 172], [29, 178], [30, 31], [30, 32], [30, 33], [30, 48], [30, 57], [30, 86], [30, 93], [30, 95], [30, 98], [30, 111], [30, 127], [30, 132], [30, 136], [30, 149], [30, 152], [30, 153], [30, 155], [30, 158], [30, 162], [30, 175], [30, 176], [30, 178], [31, 32], [31, 39], [31, 42], [31, 45], [31, 51], [31, 62], [31, 68], [31, 79], [31, 80], [31, 88], [31, 100], [31, 104], [31, 105], [31, 111], [31, 114], [31, 124], [31, 131], [31, 133], [31, 134], [31, 143], [31, 147], [31, 151], [31, 153], [31, 154], [31, 162], [31, 175], [31, 176], [32, 41], [32, 46], [32, 47], [32, 51], [32, 53], [32, 57], [32, 61], [32, 66], [32, 71], [32, 79], [32, 89], [32, 92], [32, 99], [32, 102], [32, 103], [32, 119], [32, 120], [32, 126], [32, 137], [32, 141], [32, 143], [32, 144], [32, 147], [32, 149], [32, 154], [32, 157], [32, 158], [32, 160], [32, 161], [32, 167], [32, 168], [32, 169], [32, 174], [33, 39], [33, 51], [33, 54], [33, 57], [33, 62], [33, 66], [33, 73], [33, 75], [33, 93], [33, 100], [33, 107], [33, 117], [33, 118], [33, 125], [33, 127], [33, 128], [33, 132], [33, 135], [33, 136], [33, 141], [33, 150], [33, 158], [33, 160], [33, 166], [33, 169], [33, 172], [33, 176], [34, 39], [34, 54], [34, 64], [34, 67], [34, 72], [34, 73], [34, 87], [34, 88], [34, 90], [34, 95], [34, 100], [34, 102], [34, 105], [34, 116], [34, 117], [34, 118], [34, 123], [34, 129], [34, 136], [34, 140], [34, 145], [34, 148], [34, 152], [34, 158], [34, 162], [34, 167], [34, 175], [34, 176], [34, 178], [35, 36], [35, 37], [35, 45], [35, 46], [35, 52], [35, 53], [35, 58], [35, 59], [35, 63], [35, 64], [35, 65], [35, 75], [35, 78], [35, 88], [35, 89], [35, 91], [35, 100], [35, 110], [35, 112], [35, 114], [35, 118], [35, 119], [35, 128], [35, 129], [35, 143], [35, 146], [35, 147], [35, 150], [35, 154], [35, 155], [35, 162], [35, 163], [35, 173], [35, 179], [36, 38], [36, 43], [36, 52], [36, 53], [36, 54], [36, 55], [36, 56], [36, 59], [36, 61], [36, 64], [36, 70], [36, 71], [36, 75], [36, 79], [36, 84], [36, 86], [36, 87], [36, 89], [36, 93], [36, 95], [36, 96], [36, 99], [36, 101], [36, 104], [36, 109], [36, 118], [36, 121], [36, 122], [36, 135], [36, 137], [36, 139], [36, 143], [36, 149], [36, 150], [36, 160], [36, 161], [36, 169], [36, 172], [36, 175], [36, 177], [36, 178], [36, 179], [37, 39], [37, 46], [37, 48], [37, 51], [37, 75], [37, 78], [37, 79], [37, 90], [37, 91], [37, 92], [37, 95], [37, 100], [37, 107], [37, 111], [37, 115], [37, 116], [37, 118], [37, 120], [37, 123], [37, 124], [37, 127], [37, 128], [37, 132], [37, 134], [37, 144], [37, 158], [37, 159], [37, 165], [38, 42], [38, 46], [38, 48], [38, 51], [38, 52], [38, 59], [38, 62], [38, 63], [38, 68], [38, 71], [38, 72], [38, 80], [38, 84], [38, 86], [38, 87], [38, 93], [38, 98], [38, 100], [38, 101], [38, 104], [38, 108], [38, 112], [38, 113], [38, 116], [38, 120], [38, 135], [38, 158], [38, 159], [38, 161], [38, 165], [38, 170], [38, 172], [38, 175], [38, 176], [38, 179], [39, 47], [39, 50], [39, 55], [39, 66], [39, 69], [39, 74], [39, 77], [39, 84], [39, 91], [39, 92], [39, 98], [39, 102], [39, 107], [39, 117], [39, 123], [39, 124], [39, 126], [39, 128], [39, 130], [39, 131], [39, 142], [39, 144], [39, 153], [39, 166], [39, 173], [40, 45], [40, 48], [40, 49], [40, 50], [40, 67], [40, 69], [40, 70], [40, 73], [40, 78], [40, 96], [40, 101], [40, 115], [40, 121], [40, 123], [40, 126], [40, 127], [40, 143], [40, 145], [40, 154], [40, 158], [40, 159], [40, 166], [41, 50], [41, 55], [41, 56], [41, 58], [41, 64], [41, 83], [41, 84], [41, 86], [41, 87], [41, 89], [41, 92], [41, 93], [41, 94], [41, 98], [41, 99], [41, 101], [41, 113], [41, 118], [41, 133], [41, 137], [41, 151], [41, 153], [41, 154], [41, 157], [41, 166], [41, 169], [41, 174], [42, 48], [42, 51], [42, 54], [42, 58], [42, 59], [42, 60], [42, 66], [42, 69], [42, 70], [42, 74], [42, 75], [42, 76], [42, 79], [42, 88], [42, 89], [42, 91], [42, 95], [42, 105], [42, 123], [42, 129], [42, 132], [42, 133], [42, 145], [42, 163], [42, 164], [42, 166], [42, 177], [42, 178], [43, 49], [43, 58], [43, 75], [43, 85], [43, 93], [43, 96], [43, 106], [43, 114], [43, 119], [43, 122], [43, 128], [43, 132], [43, 139], [43, 140], [43, 156], [43, 158], [43, 159], [43, 162], [43, 163], [43, 165], [43, 166], [44, 58], [44, 66], [44, 70], [44, 78], [44, 88], [44, 104], [44, 106], [44, 113], [44, 117], [44, 120], [44, 121], [44, 124], [44, 130], [44, 135], [44, 137], [44, 138], [44, 152], [44, 158], [44, 159], [44, 160], [44, 165], [44, 167], [44, 172], [44, 176], [45, 48], [45, 51], [45, 61], [45, 69], [45, 70], [45, 74], [45, 76], [45, 82], [45, 84], [45, 86], [45, 88], [45, 91], [45, 100], [45, 108], [45, 118], [45, 119], [45, 124], [45, 127], [45, 129], [45, 134], [45, 146], [45, 148], [45, 149], [45, 150], [45, 156], [45, 162], [45, 166], [45, 169], [45, 172], [45, 175], [45, 176], [46, 48], [46, 54], [46, 58], [46, 59], [46, 63], [46, 64], [46, 65], [46, 66], [46, 72], [46, 74], [46, 80], [46, 81], [46, 90], [46, 94], [46, 95], [46, 104], [46, 105], [46, 124], [46, 128], [46, 132], [46, 133], [46, 140], [46, 152], [46, 156], [46, 159], [46, 160], [46, 163], [46, 164], [46, 169], [46, 171], [46, 173], [46, 174], [46, 178], [47, 52], [47, 67], [47, 69], [47, 71], [47, 75], [47, 79], [47, 87], [47, 91], [47, 93], [47, 102], [47, 103], [47, 106], [47, 108], [47, 114], [47, 121], [47, 122], [47, 126], [47, 128], [47, 136], [47, 137], [47, 143], [47, 151], [47, 154], [47, 155], [47, 157], [47, 164], [47, 170], [47, 171], [47, 172], [47, 177], [47, 178], [48, 51], [48, 57], [48, 61], [48, 65], [48, 66], [48, 68], [48, 72], [48, 73], [48, 74], [48, 76], [48, 79], [48, 82], [48, 84], [48, 88], [48, 91], [48, 93], [48, 100], [48, 102], [48, 103], [48, 106], [48, 115], [48, 120], [48, 124], [48, 132], [48, 142], [48, 144], [48, 148], [48, 150], [48, 152], [48, 163], [48, 168], [48, 170], [49, 52], [49, 53], [49, 56], [49, 60], [49, 64], [49, 77], [49, 79], [49, 83], [49, 86], [49, 88], [49, 96], [49, 98], [49, 100], [49, 111], [49, 116], [49, 118], [49, 121], [49, 128], [49, 130], [49, 137], [49, 141], [49, 155], [49, 164], [49, 176], [50, 53], [50, 62], [50, 65], [50, 66], [50, 68], [50, 72], [50, 73], [50, 76], [50, 79], [50, 86], [50, 88], [50, 91], [50, 92], [50, 93], [50, 101], [50, 102], [50, 104], [50, 105], [50, 110], [50, 115], [50, 120], [50, 126], [50, 136], [50, 143], [50, 146], [50, 147], [50, 151], [50, 163], [50, 164], [50, 165], [50, 166], [50, 172], [51, 57], [51, 67], [51, 69], [51, 82], [51, 98], [51, 100], [51, 102], [51, 108], [51, 109], [51, 110], [51, 112], [51, 113], [51, 114], [51, 116], [51, 123], [51, 127], [51, 145], [51, 153], [51, 157], [51, 161], [51, 165], [51, 171], [51, 176], [51, 179], [52, 55], [52, 67], [52, 70], [52, 71], [52, 84], [52, 91], [52, 111], [52, 119], [52, 121], [52, 124], [52, 125], [52, 130], [52, 136], [52, 141], [52, 150], [52, 161], [52, 162], [52, 177], [52, 178], [53, 56], [53, 58], [53, 61], [53, 66], [53, 79], [53, 84], [53, 87], [53, 88], [53, 92], [53, 95], [53, 96], [53, 98], [53, 102], [53, 105], [53, 109], [53, 110], [53, 111], [53, 114], [53, 115], [53, 122], [53, 123], [53, 128], [53, 129], [53, 130], [53, 133], [53, 137], [53, 144], [53, 153], [53, 160], [53, 164], [53, 166], [53, 168], [53, 170], [53, 175], [54, 56], [54, 62], [54, 66], [54, 67], [54, 72], [54, 78], [54, 79], [54, 82], [54, 85], [54, 86], [54, 90], [54, 93], [54, 101], [54, 108], [54, 111], [54, 120], [54, 127], [54, 134], [54, 137], [54, 140], [54, 145], [54, 159], [54, 160], [54, 163], [54, 165], [54, 169], [54, 172], [55, 64], [55, 65], [55, 66], [55, 74], [55, 77], [55, 79], [55, 85], [55, 89], [55, 98], [55, 99], [55, 111], [55, 117], [55, 118], [55, 119], [55, 121], [55, 124], [55, 127], [55, 131], [55, 132], [55, 133], [55, 134], [55, 137], [55, 140], [55, 141], [55, 142], [55, 148], [55, 151], [55, 174], [55, 178], [56, 57], [56, 68], [56, 72], [56, 81], [56, 82], [56, 83], [56, 84], [56, 96], [56, 103], [56, 107], [56, 109], [56, 110], [56, 116], [56, 118], [56, 124], [56, 127], [56, 151], [56, 155], [56, 156], [56, 159], [56, 163], [56, 167], [56, 170], [56, 172], [56, 177], [57, 62], [57, 79], [57, 87], [57, 88], [57, 90], [57, 92], [57, 93], [57, 97], [57, 102], [57, 112], [57, 113], [57, 116], [57, 117], [57, 120], [57, 130], [57, 135], [57, 136], [57, 139], [57, 146], [57, 147], [57, 148], [57, 149], [57, 150], [57, 158], [58, 60], [58, 72], [58, 83], [58, 85], [58, 86], [58, 88], [58, 89], [58, 95], [58, 99], [58, 101], [58, 107], [58, 108], [58, 111], [58, 112], [58, 115], [58, 119], [58, 123], [58, 125], [58, 136], [58, 141], [58, 154], [58, 159], [58, 170], [58, 177], [59, 60], [59, 67], [59, 80], [59, 81], [59, 83], [59, 89], [59, 93], [59, 101], [59, 103], [59, 104], [59, 111], [59, 112], [59, 128], [59, 132], [59, 136], [59, 141], [59, 143], [59, 145], [59, 148], [59, 153], [59, 156], [59, 163], [59, 176], [60, 62], [60, 82], [60, 83], [60, 85], [60, 91], [60, 94], [60, 98], [60, 99], [60, 114], [60, 116], [60, 128], [60, 132], [60, 133], [60, 134], [60, 139], [60, 144], [60, 146], [60, 147], [60, 153], [60, 157], [60, 161], [60, 165], [60, 169], [60, 174], [61, 68], [61, 71], [61, 77], [61, 87], [61, 92], [61, 93], [61, 115], [61, 116], [61, 119], [61, 129], [61, 131], [61, 151], [61, 178], [62, 64], [62, 74], [62, 76], [62, 77], [62, 81], [62, 82], [62, 86], [62, 88], [62, 90], [62, 98], [62, 100], [62, 105], [62, 107], [62, 108], [62, 113], [62, 114], [62, 119], [62, 121], [62, 128], [62, 138], [62, 142], [62, 145], [62, 155], [62, 158], [62, 168], [62, 171], [62, 172], [62, 174], [62, 179], [63, 65], [63, 71], [63, 81], [63, 83], [63, 87], [63, 88], [63, 91], [63, 92], [63, 102], [63, 104], [63, 107], [63, 108], [63, 114], [63, 118], [63, 123], [63, 125], [63, 126], [63, 127], [63, 131], [63, 133], [63, 140], [63, 142], [63, 143], [63, 144], [63, 145], [63, 149], [63, 163], [63, 165], [63, 170], [63, 174], [63, 176], [63, 177], [64, 65], [64, 68], [64, 69], [64, 70], [64, 72], [64, 86], [64, 90], [64, 97], [64, 99], [64, 101], [64, 104], [64, 118], [64, 123], [64, 124], [64, 126], [64, 138], [64, 139], [64, 151], [64, 152], [64, 154], [64, 160], [64, 161], [64, 163], [64, 168], [64, 169], [64, 174], [65, 75], [65, 78], [65, 79], [65, 87], [65, 88], [65, 100], [65, 105], [65, 116], [65, 118], [65, 125], [65, 126], [65, 135], [65, 137], [65, 138], [65, 141], [65, 146], [65, 147], [65, 152], [65, 154], [65, 159], [65, 161], [65, 162], [65, 169], [65, 174], [66, 67], [66, 68], [66, 75], [66, 79], [66, 81], [66, 82], [66, 84], [66, 94], [66, 96], [66, 98], [66, 102], [66, 111], [66, 112], [66, 114], [66, 116], [66, 117], [66, 125], [66, 126], [66, 130], [66, 131], [66, 133], [66, 134], [66, 138], [66, 141], [66, 144], [66, 145], [66, 154], [66, 157], [66, 159], [66, 163], [66, 164], [66, 171], [66, 172], [67, 70], [67, 71], [67, 77], [67, 83], [67, 84], [67, 86], [67, 89], [67, 94], [67, 97], [67, 98], [67, 101], [67, 106], [67, 108], [67, 117], [67, 135], [67, 147], [67, 155], [67, 157], [67, 161], [67, 169], [67, 177], [68, 70], [68, 72], [68, 73], [68, 78], [68, 80], [68, 87], [68, 88], [68, 89], [68, 94], [68, 95], [68, 97], [68, 99], [68, 106], [68, 108], [68, 118], [68, 123], [68, 126], [68, 130], [68, 135], [68, 136], [68, 138], [68, 140], [68, 142], [68, 153], [68, 158], [68, 159], [69, 72], [69, 73], [69, 81], [69, 83], [69, 88], [69, 98], [69, 99], [69, 110], [69, 118], [69, 122], [69, 128], [69, 130], [69, 131], [69, 134], [69, 147], [69, 155], [69, 159], [69, 165], [69, 167], [69, 169], [69, 173], [70, 71], [70, 73], [70, 81], [70, 82], [70, 85], [70, 89], [70, 103], [70, 106], [70, 110], [70, 118], [70, 124], [70, 136], [70, 139], [70, 140], [70, 143], [70, 144], [70, 145], [70, 168], [70, 171], [70, 173], [70, 175], [71, 86], [71, 91], [71, 97], [71, 112], [71, 113], [71, 117], [71, 121], [71, 123], [71, 130], [71, 136], [71, 142], [71, 143], [71, 152], [71, 154], [71, 156], [71, 163], [71, 171], [72, 81], [72, 84], [72, 85], [72, 86], [72, 89], [72, 91], [72, 92], [72, 100], [72, 101], [72, 107], [72, 110], [72, 115], [72, 120], [72, 121], [72, 125], [72, 127], [72, 129], [72, 131], [72, 133], [72, 135], [72, 136], [72, 139], [72, 145], [72, 146], [72, 147], [72, 149], [72, 150], [72, 163], [72, 164], [72, 165], [72, 169], [72, 175], [73, 76], [73, 79], [73, 81], [73, 84], [73, 88], [73, 92], [73, 96], [73, 97], [73, 102], [73, 103], [73, 106], [73, 110], [73, 111], [73, 118], [73, 119], [73, 129], [73, 134], [73, 137], [73, 138], [73, 139], [73, 140], [73, 143], [73, 144], [73, 151], [73, 155], [73, 162], [73, 163], [73, 164], [73, 167], [73, 168], [73, 169], [73, 173], [73, 175], [74, 77], [74, 87], [74, 91], [74, 95], [74, 104], [74, 107], [74, 111], [74, 116], [74, 117], [74, 130], [74, 131], [74, 140], [74, 142], [74, 144], [74, 153], [74, 155], [74, 157], [74, 158], [74, 160], [74, 167], [74, 168], [74, 170], [75, 76], [75, 79], [75, 87], [75, 89], [75, 90], [75, 93], [75, 97], [75, 100], [75, 105], [75, 112], [75, 115], [75, 124], [75, 137], [75, 141], [75, 144], [75, 146], [75, 149], [75, 150], [75, 154], [75, 169], [75, 176], [75, 177], [76, 89], [76, 92], [76, 94], [76, 97], [76, 98], [76, 101], [76, 103], [76, 107], [76, 108], [76, 110], [76, 127], [76, 130], [76, 136], [76, 141], [76, 149], [76, 158], [76, 178], [77, 107], [77, 114], [77, 117], [77, 122], [77, 144], [77, 149], [77, 158], [77, 164], [77, 165], [77, 174], [78, 85], [78, 93], [78, 95], [78, 109], [78, 113], [78, 116], [78, 117], [78, 120], [78, 124], [78, 125], [78, 134], [78, 137], [78, 146], [78, 147], [78, 151], [78, 153], [78, 154], [78, 156], [78, 157], [78, 161], [78, 165], [79, 83], [79, 92], [79, 94], [79, 97], [79, 101], [79, 103], [79, 107], [79, 113], [79, 116], [79, 117], [79, 119], [79, 132], [79, 135], [79, 139], [79, 143], [79, 159], [79, 160], [79, 171], [79, 175], [80, 88], [80, 94], [80, 95], [80, 105], [80, 108], [80, 114], [80, 118], [80, 119], [80, 124], [80, 127], [80, 131], [80, 134], [80, 146], [80, 147], [80, 148], [80, 150], [80, 163], [80, 168], [80, 169], [80, 174], [80, 175], [80, 177], [81, 83], [81, 86], [81, 92], [81, 94], [81, 102], [81, 103], [81, 104], [81, 105], [81, 107], [81, 113], [81, 115], [81, 132], [81, 134], [81, 138], [81, 142], [81, 147], [81, 151], [81, 153], [81, 154], [81, 155], [81, 163], [81, 164], [82, 85], [82, 88], [82, 95], [82, 100], [82, 102], [82, 103], [82, 104], [82, 115], [82, 118], [82, 124], [82, 131], [82, 138], [82, 143], [82, 144], [82, 148], [82, 163], [82, 172], [82, 174], [82, 175], [82, 177], [82, 178], [83, 85], [83, 87], [83, 91], [83, 93], [83, 99], [83, 102], [83, 115], [83, 118], [83, 125], [83, 139], [83, 145], [83, 152], [83, 153], [83, 154], [83, 155], [83, 156], [83, 164], [83, 166], [83, 177], [84, 88], [84, 89], [84, 100], [84, 106], [84, 115], [84, 119], [84, 122], [84, 135], [84, 151], [84, 154], [84, 167], [84, 169], [84, 173], [84, 174], [84, 177], [85, 90], [85, 94], [85, 95], [85, 98], [85, 99], [85, 108], [85, 112], [85, 113], [85, 117], [85, 126], [85, 131], [85, 134], [85, 135], [85, 151], [85, 163], [85, 178], [86, 93], [86, 105], [86, 111], [86, 121], [86, 128], [86, 145], [86, 146], [86, 148], [86, 149], [86, 153], [86, 158], [86, 161], [86, 162], [86, 177], [87, 90], [87, 92], [87, 99], [87, 102], [87, 104], [87, 107], [87, 110], [87, 114], [87, 119], [87, 136], [87, 140], [87, 141], [87, 152], [87, 156], [87, 159], [87, 164], [87, 165], [87, 171], [87, 175], [87, 177], [88, 94], [88, 96], [88, 111], [88, 116], [88, 118], [88, 119], [88, 123], [88, 125], [88, 138], [88, 139], [88, 140], [88, 142], [88, 145], [88, 146], [88, 153], [88, 174], [89, 91], [89, 92], [89, 100], [89, 101], [89, 117], [89, 124], [89, 125], [89, 132], [89, 139], [89, 140], [89, 141], [89, 143], [89, 150], [89, 159], [89, 167], [89, 174], [90, 98], [90, 100], [90, 103], [90, 109], [90, 120], [90, 123], [90, 129], [90, 130], [90, 139], [90, 141], [90, 143], [90, 145], [90, 147], [90, 150], [90, 155], [90, 156], [90, 159], [90, 162], [90, 169], [90, 171], [90, 179], [91, 94], [91, 101], [91, 104], [91, 106], [91, 108], [91, 112], [91, 115], [91, 116], [91, 118], [91, 127], [91, 128], [91, 129], [91, 130], [91, 133], [91, 135], [91, 139], [91, 140], [91, 148], [91, 157], [91, 173], [92, 97], [92, 100], [92, 105], [92, 113], [92, 119], [92, 120], [92, 132], [92, 138], [92, 140], [92, 152], [92, 157], [92, 158], [92, 165], [92, 166], [92, 172], [92, 178], [93, 95], [93, 104], [93, 114], [93, 116], [93, 122], [93, 127], [93, 129], [93, 130], [93, 133], [93, 137], [93, 138], [93, 140], [93, 143], [93, 150], [93, 151], [93, 164], [93, 169], [93, 176], [94, 96], [94, 97], [94, 98], [94, 101], [94, 105], [94, 112], [94, 120], [94, 123], [94, 125], [94, 129], [94, 132], [94, 134], [94, 139], [94, 141], [94, 145], [94, 150], [94, 157], [94, 159], [94, 168], [94, 176], [94, 177], [95, 98], [95, 109], [95, 113], [95, 124], [95, 125], [95, 135], [95, 137], [95, 144], [95, 154], [95, 156], [95, 165], [95, 167], [95, 169], [95, 179], [96, 105], [96, 106], [96, 108], [96, 117], [96, 123], [96, 130], [96, 147], [96, 153], [96, 154], [96, 161], [96, 162], [96, 174], [96, 176], [96, 179], [97, 100], [97, 101], [97, 102], [97, 113], [97, 115], [97, 125], [97, 127], [97, 128], [97, 129], [97, 132], [97, 141], [97, 143], [97, 149], [97, 156], [97, 157], [97, 163], [97, 169], [97, 175], [97, 176], [98, 100], [98, 103], [98, 105], [98, 106], [98, 107], [98, 118], [98, 127], [98, 138], [98, 145], [98, 149], [98, 153], [98, 155], [98, 159], [98, 164], [98, 174], [99, 103], [99, 106], [99, 110], [99, 121], [99, 122], [99, 123], [99, 125], [99, 132], [99, 134], [99, 139], [99, 147], [99, 153], [99, 157], [99, 159], [99, 161], [99, 170], [99, 171], [100, 101], [100, 102], [100, 107], [100, 114], [100, 116], [100, 119], [100, 123], [100, 129], [100, 132], [100, 135], [100, 142], [100, 146], [100, 148], [100, 149], [100, 153], [100, 167], [100, 169], [100, 170], [100, 171], [100, 173], [101, 110], [101, 113], [101, 116], [101, 141], [101, 142], [101, 145], [101, 152], [101, 162], [101, 163], [101, 165], [101, 170], [101, 172], [101, 173], [101, 179], [102, 105], [102, 110], [102, 113], [102, 119], [102, 122], [102, 128], [102, 134], [102, 146], [102, 150], [102, 154], [102, 177], [103, 119], [103, 124], [103, 127], [103, 131], [103, 134], [103, 136], [103, 139], [103, 145], [103, 146], [103, 152], [103, 162], [103, 179], [104, 108], [104, 109], [104, 113], [104, 118], [104, 120], [104, 127], [104, 131], [104, 133], [104, 136], [104, 145], [104, 153], [104, 158], [104, 164], [104, 167], [104, 169], [104, 171], [104, 179], [105, 111], [105, 118], [105, 131], [105, 132], [105, 135], [105, 137], [105, 146], [105, 151], [105, 159], [105, 164], [105, 167], [105, 168], [105, 173], [105, 176], [105, 179], [106, 114], [106, 117], [106, 127], [106, 128], [106, 132], [106, 137], [106, 144], [106, 145], [106, 150], [106, 151], [106, 154], [106, 159], [106, 165], [106, 175], [107, 108], [107, 109], [107, 112], [107, 124], [107, 129], [107, 133], [107, 140], [107, 150], [107, 165], [107, 170], [107, 174], [107, 176], [107, 179], [108, 116], [108, 117], [108, 118], [108, 129], [108, 134], [108, 135], [108, 139], [108, 146], [108, 148], [108, 150], [108, 163], [108, 166], [108, 169], [108, 170], [109, 112], [109, 120], [109, 125], [109, 130], [109, 131], [109, 134], [109, 136], [109, 138], [109, 143], [109, 145], [109, 152], [109, 158], [109, 169], [109, 171], [109, 174], [109, 175], [110, 111], [110, 112], [110, 113], [110, 130], [110, 134], [110, 140], [110, 141], [110, 142], [110, 144], [110, 146], [110, 147], [110, 156], [110, 157], [110, 158], [110, 161], [110, 164], [110, 166], [110, 169], [110, 178], [111, 118], [111, 131], [111, 134], [111, 135], [111, 146], [111, 149], [111, 155], [111, 161], [111, 169], [111, 174], [112, 113], [112, 118], [112, 120], [112, 121], [112, 154], [112, 155], [112, 157], [112, 161], [112, 169], [112, 170], [113, 120], [113, 122], [113, 124], [113, 126], [113, 132], [113, 136], [113, 139], [113, 143], [113, 144], [113, 145], [113, 147], [113, 149], [113, 152], [113, 163], [113, 164], [113, 165], [113, 171], [113, 172], [114, 116], [114, 123], [114, 131], [114, 134], [114, 136], [114, 140], [114, 146], [114, 147], [114, 148], [114, 150], [114, 151], [114, 159], [114, 161], [114, 163], [114, 166], [114, 168], [114, 170], [114, 173], [114, 174], [115, 117], [115, 118], [115, 119], [115, 126], [115, 129], [115, 132], [115, 139], [115, 143], [115, 146], [115, 147], [115, 150], [115, 157], [115, 164], [115, 171], [115, 172], [115, 174], [115, 179], [116, 131], [116, 133], [116, 139], [116, 147], [116, 150], [116, 159], [116, 162], [116, 172], [116, 174], [116, 178], [117, 119], [117, 131], [117, 136], [117, 139], [117, 144], [117, 156], [117, 157], [117, 163], [117, 166], [117, 168], [117, 169], [117, 174], [117, 175], [117, 176], [117, 178], [118, 119], [118, 120], [118, 123], [118, 125], [118, 127], [118, 128], [118, 132], [118, 141], [118, 145], [118, 147], [118, 149], [118, 153], [118, 154], [118, 156], [118, 158], [118, 161], [118, 164], [118, 174], [119, 128], [119, 130], [119, 136], [119, 143], [119, 147], [119, 148], [119, 159], [119, 161], [119, 162], [119, 166], [119, 169], [120, 137], [120, 138], [120, 141], [120, 144], [120, 149], [120, 151], [120, 165], [120, 179], [121, 126], [121, 130], [121, 139], [121, 145], [121, 149], [121, 151], [121, 156], [121, 158], [121, 161], [121, 164], [121, 169], [121, 173], [121, 176], [122, 124], [122, 127], [122, 129], [122, 130], [122, 131], [122, 144], [122, 153], [122, 158], [122, 164], [122, 178], [123, 124], [123, 134], [123, 136], [123, 141], [123, 142], [123, 143], [123, 149], [123, 152], [123, 160], [123, 164], [123, 166], [123, 175], [123, 177], [123, 179], [124, 141], [124, 143], [124, 151], [124, 157], [124, 162], [124, 164], [124, 170], [125, 126], [125, 128], [125, 131], [125, 136], [125, 146], [125, 153], [125, 165], [125, 171], [126, 127], [126, 128], [126, 141], [126, 142], [126, 148], [126, 158], [126, 160], [126, 164], [126, 168], [126, 169], [126, 171], [127, 139], [127, 145], [127, 153], [127, 156], [127, 158], [127, 162], [127, 164], [127, 167], [127, 168], [127, 174], [127, 176], [128, 139], [128, 145], [128, 153], [128, 161], [128, 168], [128, 177], [129, 132], [129, 135], [129, 140], [129, 148], [129, 149], [129, 166], [129, 172], [129, 174], [129, 175], [129, 177], [129, 178], [130, 133], [130, 137], [130, 159], [130, 166], [130, 167], [130, 168], [130, 171], [130, 179], [131, 133], [131, 136], [131, 143], [131, 157], [131, 162], [131, 163], [131, 172], [131, 173], [131, 179], [132, 134], [132, 135], [132, 136], [132, 141], [132, 142], [132, 149], [132, 153], [132, 154], [132, 155], [132, 157], [132, 159], [132, 164], [132, 165], [132, 178], [132, 179], [133, 134], [133, 139], [133, 143], [133, 144], [133, 146], [133, 154], [133, 165], [133, 166], [133, 171], [133, 175], [133, 177], [133, 178], [134, 140], [134, 152], [134, 153], [134, 164], [134, 167], [134, 169], [135, 140], [135, 143], [135, 153], [135, 155], [135, 156], [135, 160], [135, 164], [135, 167], [136, 142], [136, 145], [136, 148], [136, 151], [136, 153], [136, 154], [136, 160], [136, 162], [136, 173], [137, 149], [137, 152], [137, 156], [137, 163], [137, 167], [137, 176], [137, 177], [138, 140], [138, 143], [138, 150], [138, 152], [138, 155], [138, 168], [138, 170], [139, 140], [139, 146], [139, 149], [139, 150], [139, 153], [139, 156], [139, 162], [140, 150], [140, 165], [140, 172], [140, 173], [140, 174], [141, 145], [141, 147], [141, 155], [141, 160], [141, 162], [141, 175], [142, 144], [142, 145], [142, 148], [142, 153], [142, 154], [142, 165], [142, 170], [143, 146], [143, 151], [143, 156], [143, 157], [143, 163], [143, 165], [143, 166], [143, 170], [143, 173], [144, 149], [144, 152], [144, 161], [144, 164], [144, 166], [144, 170], [144, 174], [144, 178], [145, 147], [145, 151], [145, 152], [145, 153], [145, 156], [145, 158], [145, 163], [145, 164], [145, 168], [145, 171], [145, 174], [145, 175], [145, 177], [146, 148], [146, 161], [146, 164], [146, 166], [146, 167], [146, 172], [147, 169], [147, 174], [147, 175], [147, 176], [147, 178], [147, 179], [148, 156], [148, 158], [148, 166], [148, 168], [148, 172], [148, 173], [148, 177], [149, 150], [149, 152], [149, 161], [149, 176], [150, 151], [150, 155], [150, 156], [150, 159], [150, 161], [150, 167], [150, 176], [150, 178], [150, 179], [151, 155], [151, 164], [151, 165], [151, 170], [151, 172], [151, 175], [152, 159], [152, 168], [152, 170], [152, 172], [152, 175], [153, 155], [153, 164], [153, 166], [153, 173], [153, 174], [154, 157], [154, 161], [154, 171], [154, 174], [155, 158], [155, 164], [155, 167], [155, 168], [155, 175], [156, 158], [156, 159], [156, 165], [156, 169], [156, 170], [156, 176], [156, 178], [156, 179], [157, 158], [157, 169], [157, 170], [157, 179], [158, 162], [158, 164], [158, 168], [158, 171], [158, 174], [158, 177], [159, 166], [159, 170], [159, 174], [160, 162], [160, 163], [160, 166], [161, 166], [161, 170], [161, 172], [162, 177], [162, 178], [163, 169], [163, 172], [163, 179], [164, 174], [165, 169], [165, 171], [166, 167], [167, 168], [167, 170], [170, 173], [170, 174], [170, 177], [171, 172], [171, 178], [172, 173], [172, 175], [173, 176], [174, 175], [175, 179], [176, 179], [178, 179]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l5-s0/tests/run.py b/tasks/construct-nppc-dominating-set-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-dominating-set-l5-s0/tests/test.sh b/tasks/construct-nppc-dominating-set-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-dominating-set-l5-s7/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-dominating-set-l5-s7/environment/instance.json b/tasks/construct-nppc-dominating-set-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ab0109abe26f6c312b2192fda1bd48d103776633 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 180, "k": 15, "edges": [[0, 8], [0, 20], [0, 27], [0, 31], [0, 35], [0, 42], [0, 43], [0, 55], [0, 56], [0, 57], [0, 58], [0, 66], [0, 71], [0, 73], [0, 76], [0, 99], [0, 100], [0, 108], [0, 118], [0, 121], [0, 124], [0, 126], [0, 136], [0, 137], [0, 140], [0, 146], [0, 147], [0, 148], [0, 155], [0, 156], [0, 163], [0, 177], [1, 2], [1, 7], [1, 13], [1, 16], [1, 20], [1, 24], [1, 25], [1, 28], [1, 37], [1, 39], [1, 44], [1, 46], [1, 51], [1, 52], [1, 54], [1, 55], [1, 63], [1, 64], [1, 67], [1, 68], [1, 73], [1, 79], [1, 90], [1, 96], [1, 101], [1, 103], [1, 105], [1, 106], [1, 108], [1, 110], [1, 116], [1, 121], [1, 125], [1, 130], [1, 134], [1, 135], [1, 137], [1, 141], [1, 145], [1, 149], [1, 159], [1, 164], [1, 166], [1, 170], [2, 3], [2, 6], [2, 7], [2, 10], [2, 13], [2, 18], [2, 21], [2, 27], [2, 28], [2, 29], [2, 32], [2, 36], [2, 37], [2, 44], [2, 45], [2, 49], [2, 51], [2, 52], [2, 54], [2, 55], [2, 56], [2, 58], [2, 59], [2, 60], [2, 61], [2, 64], [2, 66], [2, 67], [2, 71], [2, 72], [2, 80], [2, 88], [2, 92], [2, 96], [2, 97], [2, 113], [2, 118], [2, 120], [2, 125], [2, 129], [2, 135], [2, 147], [2, 150], [2, 151], [2, 154], [2, 162], [2, 163], [2, 167], [2, 168], [2, 170], [2, 179], [3, 4], [3, 8], [3, 10], [3, 11], [3, 17], [3, 21], [3, 25], [3, 30], [3, 31], [3, 39], [3, 42], [3, 44], [3, 51], [3, 54], [3, 62], [3, 69], [3, 75], [3, 77], [3, 81], [3, 86], [3, 89], [3, 91], [3, 92], [3, 97], [3, 107], [3, 111], [3, 123], [3, 125], [3, 127], [3, 131], [3, 147], [3, 158], [3, 161], [4, 7], [4, 9], [4, 10], [4, 18], [4, 22], [4, 24], [4, 25], [4, 26], [4, 32], [4, 43], [4, 53], [4, 57], [4, 59], [4, 71], [4, 74], [4, 77], [4, 81], [4, 86], [4, 95], [4, 99], [4, 106], [4, 107], [4, 108], [4, 112], [4, 113], [4, 117], [4, 122], [4, 129], [4, 134], [4, 149], [4, 150], [4, 155], [4, 163], [4, 164], [4, 169], [4, 171], [4, 178], [4, 179], [5, 6], [5, 8], [5, 13], [5, 16], [5, 43], [5, 48], [5, 51], [5, 53], [5, 69], [5, 78], [5, 89], [5, 94], [5, 96], [5, 101], [5, 104], [5, 110], [5, 112], [5, 114], [5, 117], [5, 119], [5, 122], [5, 127], [5, 136], [5, 144], [5, 157], [5, 167], [5, 172], [5, 173], [5, 174], [5, 177], [5, 179], [6, 7], [6, 10], [6, 11], [6, 14], [6, 24], [6, 31], [6, 39], [6, 40], [6, 47], [6, 52], [6, 56], [6, 63], [6, 69], [6, 70], [6, 72], [6, 73], [6, 76], [6, 79], [6, 88], [6, 94], [6, 101], [6, 104], [6, 107], [6, 108], [6, 112], [6, 160], [6, 162], [6, 165], [6, 167], [6, 177], [6, 179], [7, 10], [7, 12], [7, 14], [7, 30], [7, 39], [7, 45], [7, 47], [7, 59], [7, 62], [7, 65], [7, 70], [7, 77], [7, 79], [7, 84], [7, 87], [7, 94], [7, 101], [7, 107], [7, 112], [7, 116], [7, 119], [7, 121], [7, 123], [7, 130], [7, 131], [7, 135], [7, 138], [7, 142], [7, 149], [7, 153], [7, 158], [7, 159], [7, 164], [8, 20], [8, 25], [8, 30], [8, 31], [8, 37], [8, 40], [8, 45], [8, 58], [8, 64], [8, 68], [8, 71], [8, 76], [8, 78], [8, 84], [8, 87], [8, 96], [8, 97], [8, 99], [8, 101], [8, 110], [8, 116], [8, 117], [8, 119], [8, 124], [8, 134], [8, 136], [8, 147], [8, 151], [8, 155], [8, 162], [8, 176], [9, 12], [9, 16], [9, 18], [9, 24], [9, 27], [9, 28], [9, 32], [9, 33], [9, 40], [9, 48], [9, 49], [9, 54], [9, 74], [9, 94], [9, 103], [9, 106], [9, 110], [9, 111], [9, 115], [9, 120], [9, 125], [9, 133], [9, 136], [9, 137], [9, 138], [9, 142], [9, 143], [9, 145], [9, 146], [9, 162], [9, 165], [9, 166], [9, 174], [10, 11], [10, 25], [10, 31], [10, 35], [10, 36], [10, 40], [10, 42], [10, 48], [10, 49], [10, 55], [10, 56], [10, 59], [10, 60], [10, 75], [10, 76], [10, 83], [10, 85], [10, 86], [10, 92], [10, 98], [10, 104], [10, 108], [10, 112], [10, 116], [10, 127], [10, 132], [10, 134], [10, 141], [10, 145], [10, 147], [10, 149], [10, 151], [10, 155], [10, 171], [10, 174], [11, 19], [11, 27], [11, 42], [11, 43], [11, 50], [11, 56], [11, 57], [11, 63], [11, 64], [11, 70], [11, 74], [11, 81], [11, 82], [11, 99], [11, 105], [11, 109], [11, 116], [11, 117], [11, 122], [11, 124], [11, 129], [11, 135], [11, 139], [11, 140], [11, 142], [11, 144], [11, 145], [11, 150], [11, 151], [11, 153], [11, 155], [11, 162], [11, 164], [11, 166], [11, 171], [11, 173], [11, 178], [12, 26], [12, 29], [12, 32], [12, 36], [12, 40], [12, 41], [12, 44], [12, 49], [12, 51], [12, 54], [12, 55], [12, 65], [12, 66], [12, 69], [12, 70], [12, 75], [12, 78], [12, 83], [12, 88], [12, 90], [12, 94], [12, 103], [12, 104], [12, 121], [12, 122], [12, 124], [12, 128], [12, 136], [12, 139], [12, 143], [12, 145], [12, 152], [12, 159], [12, 160], [12, 161], [12, 162], [12, 171], [12, 179], [13, 26], [13, 29], [13, 33], [13, 43], [13, 55], [13, 59], [13, 65], [13, 69], [13, 72], [13, 74], [13, 79], [13, 99], [13, 104], [13, 112], [13, 114], [13, 119], [13, 121], [13, 124], [13, 126], [13, 130], [13, 142], [13, 145], [13, 149], [13, 153], [13, 155], [13, 156], [13, 159], [13, 160], [13, 171], [14, 20], [14, 23], [14, 31], [14, 32], [14, 37], [14, 40], [14, 41], [14, 43], [14, 45], [14, 47], [14, 53], [14, 60], [14, 63], [14, 64], [14, 68], [14, 72], [14, 74], [14, 77], [14, 80], [14, 100], [14, 108], [14, 110], [14, 111], [14, 125], [14, 131], [14, 134], [14, 144], [14, 145], [14, 153], [14, 159], [14, 160], [14, 163], [14, 176], [14, 179], [15, 19], [15, 21], [15, 24], [15, 30], [15, 32], [15, 37], [15, 45], [15, 60], [15, 64], [15, 70], [15, 75], [15, 76], [15, 77], [15, 79], [15, 80], [15, 82], [15, 86], [15, 92], [15, 96], [15, 102], [15, 115], [15, 117], [15, 118], [15, 120], [15, 130], [15, 131], [15, 133], [15, 135], [15, 143], [15, 145], [15, 146], [15, 147], [15, 151], [15, 159], [15, 166], [16, 18], [16, 23], [16, 37], [16, 38], [16, 45], [16, 49], [16, 51], [16, 63], [16, 67], [16, 68], [16, 74], [16, 76], [16, 83], [16, 84], [16, 86], [16, 97], [16, 100], [16, 101], [16, 102], [16, 105], [16, 106], [16, 111], [16, 118], [16, 142], [16, 144], [16, 149], [16, 151], [16, 152], [16, 153], [16, 155], [16, 164], [16, 170], [16, 172], [16, 174], [16, 179], [17, 19], [17, 29], [17, 63], [17, 74], [17, 75], [17, 76], [17, 80], [17, 81], [17, 94], [17, 97], [17, 98], [17, 103], [17, 106], [17, 111], [17, 113], [17, 116], [17, 122], [17, 123], [17, 127], [17, 144], [17, 147], [17, 149], [17, 167], [17, 170], [18, 19], [18, 23], [18, 25], [18, 27], [18, 29], [18, 32], [18, 38], [18, 51], [18, 54], [18, 57], [18, 70], [18, 85], [18, 88], [18, 95], [18, 101], [18, 103], [18, 104], [18, 109], [18, 110], [18, 124], [18, 129], [18, 132], [18, 134], [18, 136], [18, 138], [18, 141], [18, 143], [18, 145], [18, 150], [18, 156], [18, 160], [18, 161], [18, 164], [18, 165], [18, 168], [18, 169], [18, 171], [18, 172], [19, 25], [19, 28], [19, 29], [19, 32], [19, 38], [19, 39], [19, 44], [19, 54], [19, 55], [19, 57], [19, 69], [19, 73], [19, 74], [19, 75], [19, 86], [19, 87], [19, 88], [19, 89], [19, 90], [19, 93], [19, 97], [19, 99], [19, 104], [19, 111], [19, 113], [19, 114], [19, 115], [19, 121], [19, 135], [19, 138], [19, 140], [19, 144], [19, 146], [19, 148], [19, 157], [19, 165], [19, 173], [19, 175], [19, 178], [20, 24], [20, 29], [20, 37], [20, 43], [20, 46], [20, 48], [20, 57], [20, 60], [20, 62], [20, 64], [20, 73], [20, 78], [20, 83], [20, 85], [20, 87], [20, 89], [20, 92], [20, 93], [20, 102], [20, 104], [20, 111], [20, 117], [20, 120], [20, 126], [20, 128], [20, 136], [20, 137], [20, 138], [20, 141], [20, 143], [20, 145], [20, 146], [20, 147], [20, 152], [20, 155], [20, 156], [20, 159], [20, 173], [20, 176], [21, 22], [21, 27], [21, 29], [21, 42], [21, 50], [21, 56], [21, 63], [21, 65], [21, 66], [21, 71], [21, 74], [21, 75], [21, 81], [21, 93], [21, 94], [21, 107], [21, 113], [21, 126], [21, 136], [21, 148], [21, 163], [22, 34], [22, 35], [22, 38], [22, 39], [22, 40], [22, 44], [22, 53], [22, 55], [22, 56], [22, 57], [22, 58], [22, 61], [22, 68], [22, 81], [22, 84], [22, 88], [22, 94], [22, 96], [22, 99], [22, 100], [22, 104], [22, 105], [22, 106], [22, 108], [22, 112], [22, 115], [22, 122], [22, 131], [22, 137], [22, 142], [22, 144], [22, 148], [22, 151], [22, 168], [22, 169], [22, 170], [22, 173], [23, 34], [23, 39], [23, 47], [23, 48], [23, 52], [23, 54], [23, 59], [23, 63], [23, 77], [23, 80], [23, 83], [23, 93], [23, 96], [23, 102], [23, 116], [23, 117], [23, 119], [23, 128], [23, 133], [23, 138], [23, 139], [23, 141], [23, 166], [23, 174], [24, 26], [24, 29], [24, 30], [24, 34], [24, 37], [24, 47], [24, 50], [24, 54], [24, 76], [24, 78], [24, 81], [24, 88], [24, 89], [24, 100], [24, 112], [24, 113], [24, 122], [24, 126], [24, 129], [24, 131], [24, 136], [24, 141], [24, 142], [24, 147], [24, 159], [24, 163], [24, 168], [24, 169], [24, 173], [24, 177], [24, 178], [25, 26], [25, 29], [25, 40], [25, 46], [25, 48], [25, 54], [25, 58], [25, 59], [25, 60], [25, 61], [25, 65], [25, 71], [25, 85], [25, 90], [25, 105], [25, 110], [25, 119], [25, 120], [25, 122], [25, 129], [25, 132], [25, 135], [25, 148], [25, 156], [25, 162], [25, 165], [25, 166], [25, 168], [25, 175], [25, 176], [26, 33], [26, 37], [26, 40], [26, 41], [26, 44], [26, 45], [26, 46], [26, 62], [26, 68], [26, 75], [26, 80], [26, 86], [26, 89], [26, 101], [26, 103], [26, 104], [26, 109], [26, 111], [26, 115], [26, 118], [26, 120], [26, 125], [26, 133], [26, 134], [26, 137], [26, 149], [26, 152], [26, 156], [26, 157], [26, 168], [26, 171], [26, 173], [27, 44], [27, 46], [27, 51], [27, 62], [27, 72], [27, 78], [27, 86], [27, 92], [27, 95], [27, 101], [27, 103], [27, 105], [27, 116], [27, 118], [27, 121], [27, 123], [27, 131], [27, 133], [27, 137], [27, 138], [27, 139], [27, 140], [27, 142], [27, 146], [27, 151], [27, 152], [27, 166], [27, 169], [27, 171], [27, 176], [27, 178], [28, 33], [28, 34], [28, 46], [28, 53], [28, 54], [28, 58], [28, 59], [28, 83], [28, 84], [28, 89], [28, 92], [28, 98], [28, 105], [28, 112], [28, 131], [28, 139], [28, 140], [28, 143], [28, 146], [28, 151], [28, 157], [28, 163], [28, 174], [28, 179], [29, 43], [29, 44], [29, 52], [29, 55], [29, 59], [29, 61], [29, 62], [29, 63], [29, 64], [29, 74], [29, 78], [29, 87], [29, 106], [29, 112], [29, 113], [29, 116], [29, 125], [29, 126], [29, 130], [29, 132], [29, 133], [29, 137], [29, 138], [29, 167], [29, 171], [29, 173], [30, 36], [30, 37], [30, 43], [30, 48], [30, 49], [30, 67], [30, 69], [30, 71], [30, 72], [30, 76], [30, 80], [30, 89], [30, 92], [30, 98], [30, 108], [30, 110], [30, 119], [30, 120], [30, 122], [30, 139], [30, 148], [30, 149], [30, 150], [30, 154], [30, 157], [30, 166], [30, 174], [31, 34], [31, 37], [31, 40], [31, 45], [31, 52], [31, 55], [31, 59], [31, 66], [31, 70], [31, 75], [31, 78], [31, 81], [31, 83], [31, 90], [31, 93], [31, 97], [31, 98], [31, 100], [31, 101], [31, 103], [31, 110], [31, 111], [31, 116], [31, 117], [31, 125], [31, 126], [31, 131], [31, 135], [31, 137], [31, 138], [31, 139], [31, 146], [31, 148], [31, 150], [31, 153], [31, 155], [31, 156], [31, 159], [31, 171], [31, 174], [31, 175], [32, 34], [32, 37], [32, 38], [32, 39], [32, 40], [32, 58], [32, 63], [32, 71], [32, 72], [32, 77], [32, 78], [32, 80], [32, 81], [32, 87], [32, 88], [32, 89], [32, 94], [32, 100], [32, 108], [32, 113], [32, 157], [32, 158], [32, 171], [32, 172], [32, 175], [32, 176], [33, 47], [33, 48], [33, 50], [33, 51], [33, 58], [33, 60], [33, 72], [33, 77], [33, 85], [33, 93], [33, 110], [33, 116], [33, 118], [33, 129], [33, 130], [33, 149], [33, 157], [33, 163], [33, 165], [33, 169], [33, 171], [33, 177], [33, 179], [34, 41], [34, 53], [34, 54], [34, 55], [34, 56], [34, 57], [34, 58], [34, 63], [34, 66], [34, 69], [34, 75], [34, 77], [34, 85], [34, 90], [34, 103], [34, 104], [34, 108], [34, 111], [34, 114], [34, 121], [34, 122], [34, 123], [34, 140], [34, 147], [34, 148], [34, 149], [34, 154], [34, 157], [34, 161], [34, 163], [34, 166], [34, 170], [35, 37], [35, 38], [35, 40], [35, 42], [35, 43], [35, 46], [35, 50], [35, 55], [35, 56], [35, 57], [35, 68], [35, 69], [35, 72], [35, 73], [35, 80], [35, 84], [35, 86], [35, 100], [35, 103], [35, 114], [35, 115], [35, 117], [35, 124], [35, 142], [35, 150], [35, 155], [35, 156], [35, 157], [35, 158], [35, 163], [35, 164], [35, 179], [36, 37], [36, 43], [36, 44], [36, 51], [36, 53], [36, 57], [36, 59], [36, 64], [36, 70], [36, 84], [36, 85], [36, 91], [36, 95], [36, 96], [36, 98], [36, 103], [36, 106], [36, 113], [36, 116], [36, 120], [36, 121], [36, 126], [36, 127], [36, 130], [36, 133], [36, 140], [36, 148], [36, 156], [36, 157], [36, 170], [36, 172], [36, 178], [37, 38], [37, 47], [37, 52], [37, 60], [37, 62], [37, 65], [37, 72], [37, 81], [37, 82], [37, 83], [37, 87], [37, 91], [37, 97], [37, 98], [37, 99], [37, 101], [37, 114], [37, 123], [37, 125], [37, 132], [37, 133], [37, 138], [37, 139], [37, 141], [37, 143], [37, 144], [37, 147], [37, 150], [37, 151], [37, 154], [37, 156], [37, 160], [37, 169], [37, 174], [37, 177], [37, 179], [38, 47], [38, 50], [38, 57], [38, 59], [38, 64], [38, 100], [38, 101], [38, 104], [38, 109], [38, 113], [38, 117], [38, 124], [38, 125], [38, 128], [38, 131], [38, 137], [38, 141], [38, 146], [38, 148], [38, 149], [38, 165], [38, 166], [38, 167], [38, 170], [38, 176], [39, 40], [39, 41], [39, 50], [39, 63], [39, 78], [39, 81], [39, 83], [39, 84], [39, 85], [39, 86], [39, 90], [39, 96], [39, 97], [39, 99], [39, 105], [39, 109], [39, 113], [39, 133], [39, 136], [39, 142], [39, 144], [39, 149], [39, 150], [39, 155], [39, 156], [39, 158], [39, 168], [39, 175], [40, 48], [40, 49], [40, 79], [40, 82], [40, 96], [40, 102], [40, 107], [40, 109], [40, 114], [40, 116], [40, 117], [40, 118], [40, 124], [40, 128], [40, 134], [40, 137], [40, 138], [40, 140], [40, 144], [40, 148], [40, 149], [40, 152], [40, 154], [40, 160], [40, 162], [40, 170], [40, 175], [40, 177], [41, 44], [41, 45], [41, 47], [41, 51], [41, 56], [41, 68], [41, 70], [41, 74], [41, 82], [41, 86], [41, 97], [41, 99], [41, 104], [41, 129], [41, 133], [41, 135], [41, 136], [41, 137], [41, 150], [41, 158], [41, 165], [41, 174], [42, 43], [42, 48], [42, 52], [42, 59], [42, 66], [42, 70], [42, 88], [42, 89], [42, 97], [42, 98], [42, 100], [42, 104], [42, 109], [42, 130], [42, 139], [42, 154], [42, 155], [42, 157], [42, 165], [42, 174], [43, 53], [43, 58], [43, 60], [43, 61], [43, 62], [43, 64], [43, 74], [43, 75], [43, 87], [43, 109], [43, 111], [43, 124], [43, 126], [43, 138], [43, 139], [43, 140], [43, 143], [43, 148], [43, 152], [43, 153], [43, 163], [43, 164], [43, 167], [43, 168], [43, 179], [44, 46], [44, 48], [44, 51], [44, 56], [44, 63], [44, 71], [44, 84], [44, 85], [44, 96], [44, 97], [44, 100], [44, 103], [44, 116], [44, 120], [44, 121], [44, 128], [44, 133], [44, 134], [44, 135], [44, 136], [44, 138], [44, 143], [44, 145], [44, 162], [44, 163], [44, 166], [44, 171], [44, 172], [44, 173], [45, 51], [45, 52], [45, 53], [45, 55], [45, 62], [45, 64], [45, 68], [45, 75], [45, 95], [45, 97], [45, 101], [45, 105], [45, 108], [45, 115], [45, 116], [45, 122], [45, 126], [45, 130], [45, 133], [45, 135], [45, 139], [45, 149], [45, 156], [45, 160], [45, 165], [45, 171], [45, 175], [46, 49], [46, 55], [46, 56], [46, 62], [46, 69], [46, 84], [46, 87], [46, 88], [46, 89], [46, 95], [46, 101], [46, 103], [46, 106], [46, 111], [46, 112], [46, 116], [46, 117], [46, 144], [46, 148], [46, 149], [46, 152], [46, 157], [46, 160], [46, 161], [46, 168], [46, 175], [46, 177], [47, 49], [47, 55], [47, 57], [47, 61], [47, 64], [47, 66], [47, 70], [47, 71], [47, 79], [47, 81], [47, 88], [47, 94], [47, 95], [47, 100], [47, 101], [47, 103], [47, 106], [47, 109], [47, 110], [47, 111], [47, 114], [47, 115], [47, 120], [47, 122], [47, 125], [47, 127], [47, 131], [47, 132], [47, 133], [47, 136], [47, 146], [47, 154], [47, 158], [47, 159], [47, 165], [47, 166], [47, 172], [47, 175], [47, 177], [48, 49], [48, 51], [48, 52], [48, 59], [48, 62], [48, 69], [48, 72], [48, 73], [48, 77], [48, 80], [48, 84], [48, 87], [48, 88], [48, 98], [48, 100], [48, 101], [48, 102], [48, 104], [48, 106], [48, 124], [48, 130], [48, 133], [48, 138], [48, 144], [48, 158], [48, 160], [48, 161], [48, 162], [48, 179], [49, 62], [49, 67], [49, 74], [49, 85], [49, 90], [49, 98], [49, 103], [49, 122], [49, 123], [49, 124], [49, 128], [49, 136], [49, 138], [49, 139], [49, 141], [49, 144], [49, 145], [49, 147], [49, 158], [49, 167], [49, 169], [49, 173], [49, 175], [49, 178], [50, 53], [50, 57], [50, 60], [50, 67], [50, 71], [50, 73], [50, 76], [50, 80], [50, 82], [50, 87], [50, 97], [50, 98], [50, 101], [50, 103], [50, 104], [50, 106], [50, 113], [50, 117], [50, 120], [50, 130], [50, 131], [50, 136], [50, 137], [50, 140], [50, 144], [50, 148], [50, 151], [50, 152], [50, 155], [50, 161], [50, 164], [50, 172], [50, 174], [50, 179], [51, 54], [51, 56], [51, 63], [51, 66], [51, 68], [51, 72], [51, 73], [51, 76], [51, 78], [51, 84], [51, 88], [51, 89], [51, 93], [51, 103], [51, 107], [51, 112], [51, 120], [51, 122], [51, 126], [51, 129], [51, 131], [51, 134], [51, 145], [51, 150], [51, 164], [51, 165], [51, 174], [52, 56], [52, 59], [52, 60], [52, 63], [52, 72], [52, 73], [52, 76], [52, 80], [52, 81], [52, 91], [52, 92], [52, 93], [52, 95], [52, 110], [52, 121], [52, 122], [52, 125], [52, 133], [52, 135], [52, 136], [52, 137], [52, 138], [52, 142], [52, 143], [52, 146], [52, 149], [52, 154], [52, 159], [52, 170], [52, 172], [52, 179], [53, 64], [53, 68], [53, 72], [53, 78], [53, 79], [53, 90], [53, 92], [53, 97], [53, 99], [53, 108], [53, 116], [53, 136], [53, 139], [53, 140], [53, 143], [53, 148], [53, 164], [53, 168], [53, 170], [53, 171], [53, 172], [53, 175], [53, 176], [53, 177], [54, 58], [54, 59], [54, 68], [54, 69], [54, 71], [54, 73], [54, 75], [54, 78], [54, 80], [54, 83], [54, 84], [54, 85], [54, 86], [54, 88], [54, 96], [54, 100], [54, 107], [54, 117], [54, 120], [54, 138], [54, 142], [54, 143], [54, 146], [54, 154], [54, 158], [54, 159], [54, 160], [54, 167], [54, 172], [54, 175], [54, 176], [54, 177], [55, 70], [55, 72], [55, 85], [55, 87], [55, 94], [55, 100], [55, 101], [55, 102], [55, 103], [55, 117], [55, 118], [55, 127], [55, 128], [55, 129], [55, 132], [55, 135], [55, 136], [55, 138], [55, 140], [55, 143], [55, 147], [55, 148], [55, 152], [55, 163], [55, 168], [55, 169], [55, 170], [55, 177], [55, 179], [56, 60], [56, 61], [56, 65], [56, 69], [56, 70], [56, 77], [56, 81], [56, 82], [56, 95], [56, 96], [56, 109], [56, 110], [56, 111], [56, 113], [56, 118], [56, 127], [56, 129], [56, 141], [56, 152], [56, 161], [56, 168], [56, 177], [57, 70], [57, 81], [57, 86], [57, 90], [57, 103], [57, 110], [57, 115], [57, 120], [57, 122], [57, 123], [57, 130], [57, 134], [57, 157], [57, 158], [57, 167], [57, 169], [57, 175], [57, 178], [58, 65], [58, 67], [58, 97], [58, 100], [58, 103], [58, 111], [58, 113], [58, 117], [58, 118], [58, 119], [58, 120], [58, 124], [58, 126], [58, 128], [58, 130], [58, 131], [58, 133], [58, 138], [58, 139], [58, 141], [58, 160], [58, 164], [58, 166], [58, 168], [58, 169], [58, 172], [58, 177], [58, 179], [59, 62], [59, 63], [59, 76], [59, 79], [59, 81], [59, 95], [59, 98], [59, 99], [59, 104], [59, 109], [59, 117], [59, 118], [59, 129], [59, 130], [59, 133], [59, 134], [59, 138], [59, 143], [59, 145], [59, 147], [59, 148], [59, 152], [59, 155], [59, 156], [59, 157], [59, 161], [59, 163], [59, 166], [59, 175], [59, 176], [60, 64], [60, 69], [60, 70], [60, 73], [60, 81], [60, 100], [60, 108], [60, 110], [60, 111], [60, 114], [60, 137], [60, 145], [60, 147], [60, 149], [60, 150], [60, 158], [60, 159], [60, 177], [61, 67], [61, 78], [61, 80], [61, 92], [61, 95], [61, 97], [61, 106], [61, 107], [61, 113], [61, 119], [61, 130], [61, 142], [61, 146], [61, 147], [61, 148], [61, 149], [61, 166], [61, 174], [61, 175], [62, 66], [62, 69], [62, 80], [62, 86], [62, 94], [62, 95], [62, 105], [62, 115], [62, 117], [62, 124], [62, 134], [62, 138], [62, 156], [62, 163], [62, 165], [62, 173], [62, 175], [62, 176], [63, 68], [63, 82], [63, 89], [63, 93], [63, 96], [63, 99], [63, 106], [63, 107], [63, 123], [63, 124], [63, 131], [63, 136], [63, 139], [63, 140], [63, 146], [63, 150], [63, 153], [63, 166], [63, 175], [64, 73], [64, 81], [64, 82], [64, 86], [64, 96], [64, 97], [64, 100], [64, 101], [64, 113], [64, 116], [64, 118], [64, 123], [64, 132], [64, 134], [64, 148], [64, 150], [64, 153], [64, 154], [64, 160], [64, 174], [65, 70], [65, 82], [65, 83], [65, 86], [65, 96], [65, 100], [65, 101], [65, 105], [65, 107], [65, 120], [65, 137], [65, 141], [65, 145], [65, 148], [65, 150], [65, 151], [65, 153], [65, 154], [65, 162], [65, 164], [65, 165], [65, 169], [65, 178], [66, 67], [66, 70], [66, 84], [66, 86], [66, 90], [66, 97], [66, 103], [66, 105], [66, 113], [66, 114], [66, 116], [66, 117], [66, 121], [66, 143], [66, 148], [66, 150], [66, 154], [66, 156], [66, 160], [66, 162], [66, 165], [66, 179], [67, 68], [67, 79], [67, 84], [67, 89], [67, 95], [67, 97], [67, 104], [67, 106], [67, 113], [67, 118], [67, 125], [67, 127], [67, 130], [67, 132], [67, 138], [67, 145], [67, 154], [67, 155], [67, 156], [67, 164], [67, 171], [67, 178], [68, 72], [68, 78], [68, 81], [68, 84], [68, 87], [68, 91], [68, 98], [68, 100], [68, 102], [68, 116], [68, 121], [68, 123], [68, 126], [68, 130], [68, 134], [68, 135], [68, 136], [68, 137], [68, 139], [68, 142], [68, 144], [68, 150], [68, 155], [68, 158], [68, 174], [68, 177], [69, 70], [69, 74], [69, 82], [69, 84], [69, 90], [69, 94], [69, 99], [69, 101], [69, 104], [69, 109], [69, 110], [69, 111], [69, 113], [69, 124], [69, 125], [69, 126], [69, 128], [69, 133], [69, 136], [69, 142], [69, 143], [69, 147], [69, 149], [69, 151], [69, 158], [69, 160], [69, 163], [69, 165], [69, 177], [70, 72], [70, 73], [70, 83], [70, 87], [70, 91], [70, 92], [70, 94], [70, 98], [70, 101], [70, 103], [70, 107], [70, 114], [70, 126], [70, 129], [70, 139], [70, 141], [70, 142], [70, 150], [70, 151], [70, 155], [70, 156], [70, 158], [70, 163], [70, 164], [70, 171], [70, 172], [70, 174], [70, 175], [71, 79], [71, 81], [71, 85], [71, 86], [71, 89], [71, 96], [71, 98], [71, 105], [71, 112], [71, 124], [71, 132], [71, 136], [71, 138], [71, 139], [71, 141], [71, 147], [71, 152], [71, 153], [71, 159], [71, 166], [71, 171], [72, 74], [72, 77], [72, 86], [72, 92], [72, 93], [72, 104], [72, 109], [72, 110], [72, 114], [72, 121], [72, 125], [72, 127], [72, 134], [72, 137], [72, 146], [72, 149], [72, 158], [72, 159], [72, 171], [72, 172], [73, 76], [73, 82], [73, 84], [73, 85], [73, 89], [73, 96], [73, 99], [73, 100], [73, 101], [73, 104], [73, 116], [73, 124], [73, 133], [73, 134], [73, 138], [73, 139], [73, 159], [73, 163], [73, 164], [73, 170], [73, 172], [73, 174], [73, 175], [73, 178], [74, 77], [74, 79], [74, 85], [74, 99], [74, 103], [74, 105], [74, 114], [74, 117], [74, 120], [74, 123], [74, 129], [74, 132], [74, 136], [74, 139], [74, 147], [74, 151], [74, 152], [74, 161], [74, 173], [74, 175], [74, 178], [75, 79], [75, 92], [75, 93], [75, 99], [75, 127], [75, 128], [75, 140], [75, 153], [75, 154], [75, 155], [75, 159], [75, 163], [75, 164], [75, 175], [75, 179], [76, 78], [76, 83], [76, 88], [76, 89], [76, 90], [76, 91], [76, 102], [76, 109], [76, 110], [76, 113], [76, 117], [76, 119], [76, 131], [76, 141], [76, 146], [76, 152], [76, 153], [76, 156], [76, 172], [76, 173], [76, 175], [76, 178], [77, 78], [77, 95], [77, 100], [77, 103], [77, 111], [77, 112], [77, 129], [77, 131], [77, 139], [77, 140], [77, 141], [77, 145], [77, 147], [77, 150], [77, 153], [77, 154], [77, 155], [77, 163], [77, 164], [77, 169], [77, 170], [77, 179], [78, 85], [78, 93], [78, 95], [78, 103], [78, 104], [78, 107], [78, 111], [78, 113], [78, 119], [78, 123], [78, 124], [78, 125], [78, 133], [78, 143], [78, 157], [78, 160], [78, 162], [78, 175], [79, 81], [79, 84], [79, 87], [79, 89], [79, 102], [79, 105], [79, 111], [79, 116], [79, 121], [79, 122], [79, 125], [79, 131], [79, 132], [79, 141], [79, 154], [79, 157], [79, 166], [79, 176], [80, 82], [80, 90], [80, 101], [80, 108], [80, 109], [80, 114], [80, 119], [80, 122], [80, 129], [80, 133], [80, 134], [80, 135], [80, 140], [80, 141], [80, 150], [80, 154], [80, 162], [80, 165], [80, 166], [80, 167], [80, 168], [80, 173], [80, 174], [80, 179], [81, 85], [81, 89], [81, 95], [81, 96], [81, 97], [81, 98], [81, 126], [81, 131], [81, 134], [81, 136], [81, 144], [81, 145], [81, 148], [81, 150], [81, 151], [81, 153], [81, 156], [81, 170], [82, 94], [82, 101], [82, 107], [82, 108], [82, 111], [82, 120], [82, 121], [82, 125], [82, 142], [82, 161], [82, 165], [82, 167], [82, 170], [82, 175], [82, 176], [83, 84], [83, 90], [83, 95], [83, 97], [83, 100], [83, 108], [83, 111], [83, 120], [83, 125], [83, 128], [83, 135], [83, 136], [83, 141], [83, 143], [83, 145], [83, 147], [83, 155], [83, 156], [83, 160], [83, 161], [83, 169], [83, 170], [83, 173], [83, 174], [83, 177], [83, 178], [83, 179], [84, 87], [84, 90], [84, 91], [84, 93], [84, 108], [84, 109], [84, 112], [84, 117], [84, 126], [84, 128], [84, 130], [84, 145], [84, 150], [84, 151], [84, 155], [84, 156], [84, 158], [84, 161], [84, 162], [84, 163], [84, 166], [84, 178], [85, 86], [85, 87], [85, 95], [85, 98], [85, 100], [85, 105], [85, 108], [85, 118], [85, 122], [85, 127], [85, 135], [85, 146], [85, 159], [85, 161], [85, 163], [85, 165], [86, 88], [86, 95], [86, 97], [86, 100], [86, 105], [86, 110], [86, 115], [86, 116], [86, 123], [86, 130], [86, 132], [86, 134], [86, 145], [86, 148], [86, 149], [86, 150], [86, 162], [86, 171], [86, 176], [86, 177], [87, 89], [87, 92], [87, 93], [87, 100], [87, 104], [87, 110], [87, 134], [87, 143], [87, 149], [87, 153], [87, 154], [87, 156], [87, 160], [87, 163], [87, 170], [88, 92], [88, 102], [88, 104], [88, 105], [88, 116], [88, 117], [88, 136], [88, 139], [88, 141], [88, 142], [88, 144], [88, 146], [88, 151], [88, 152], [88, 158], [88, 163], [88, 166], [88, 168], [88, 175], [88, 176], [88, 177], [89, 90], [89, 91], [89, 92], [89, 101], [89, 104], [89, 113], [89, 116], [89, 119], [89, 120], [89, 124], [89, 125], [89, 129], [89, 131], [89, 138], [89, 140], [89, 144], [89, 147], [89, 156], [89, 157], [89, 159], [89, 162], [89, 163], [89, 165], [89, 167], [89, 175], [90, 92], [90, 97], [90, 98], [90, 100], [90, 104], [90, 106], [90, 115], [90, 118], [90, 120], [90, 122], [90, 124], [90, 127], [90, 134], [90, 143], [90, 145], [90, 156], [90, 161], [90, 165], [90, 167], [90, 177], [90, 178], [91, 92], [91, 98], [91, 101], [91, 112], [91, 113], [91, 117], [91, 118], [91, 121], [91, 129], [91, 131], [91, 138], [91, 139], [91, 142], [91, 145], [91, 148], [91, 149], [91, 163], [91, 164], [91, 166], [91, 168], [91, 175], [92, 94], [92, 99], [92, 107], [92, 109], [92, 111], [92, 112], [92, 115], [92, 117], [92, 119], [92, 121], [92, 122], [92, 127], [92, 128], [92, 129], [92, 139], [92, 142], [92, 147], [92, 148], [92, 153], [92, 154], [92, 160], [92, 165], [92, 167], [93, 103], [93, 106], [93, 107], [93, 116], [93, 119], [93, 122], [93, 139], [93, 147], [93, 148], [93, 154], [93, 155], [93, 156], [93, 159], [93, 160], [93, 167], [93, 168], [93, 172], [93, 178], [94, 103], [94, 110], [94, 120], [94, 127], [94, 130], [94, 132], [94, 138], [94, 141], [94, 143], [94, 146], [94, 147], [94, 153], [94, 156], [94, 158], [94, 164], [94, 170], [94, 174], [95, 108], [95, 118], [95, 119], [95, 125], [95, 132], [95, 134], [95, 136], [95, 139], [95, 142], [95, 144], [95, 146], [95, 148], [95, 150], [95, 151], [95, 154], [95, 157], [95, 158], [95, 161], [95, 162], [95, 164], [95, 168], [95, 171], [95, 173], [96, 100], [96, 101], [96, 103], [96, 108], [96, 116], [96, 118], [96, 120], [96, 126], [96, 129], [96, 136], [96, 141], [96, 148], [96, 151], [96, 154], [96, 160], [96, 166], [96, 170], [97, 100], [97, 103], [97, 110], [97, 111], [97, 125], [97, 128], [97, 133], [97, 154], [97, 157], [97, 161], [97, 163], [97, 173], [97, 176], [98, 99], [98, 108], [98, 110], [98, 117], [98, 120], [98, 123], [98, 124], [98, 125], [98, 129], [98, 136], [98, 138], [98, 143], [98, 144], [98, 157], [98, 159], [98, 161], [98, 168], [99, 102], [99, 103], [99, 107], [99, 111], [99, 126], [99, 139], [99, 140], [99, 142], [99, 148], [99, 151], [99, 157], [99, 158], [99, 177], [99, 178], [100, 107], [100, 121], [100, 125], [100, 137], [100, 138], [100, 146], [100, 148], [100, 155], [100, 161], [100, 163], [100, 165], [100, 170], [100, 178], [100, 179], [101, 103], [101, 107], [101, 115], [101, 116], [101, 121], [101, 130], [101, 131], [101, 133], [101, 141], [101, 143], [101, 148], [101, 149], [101, 154], [101, 155], [101, 160], [101, 162], [101, 165], [101, 174], [101, 177], [101, 178], [102, 103], [102, 121], [102, 122], [102, 130], [102, 133], [102, 138], [102, 145], [102, 146], [102, 148], [102, 149], [102, 151], [102, 153], [102, 159], [102, 160], [103, 107], [103, 112], [103, 121], [103, 123], [103, 127], [103, 131], [103, 132], [103, 133], [103, 135], [103, 139], [103, 142], [103, 143], [103, 144], [103, 146], [103, 152], [103, 153], [103, 155], [103, 160], [103, 176], [104, 105], [104, 109], [104, 124], [104, 126], [104, 134], [104, 142], [104, 144], [104, 145], [104, 146], [104, 147], [104, 148], [104, 150], [104, 152], [104, 165], [104, 171], [104, 177], [105, 108], [105, 132], [105, 136], [105, 140], [105, 155], [105, 156], [105, 162], [105, 164], [105, 171], [105, 173], [105, 175], [105, 177], [106, 110], [106, 112], [106, 122], [106, 124], [106, 126], [106, 127], [106, 128], [106, 136], [106, 138], [106, 143], [106, 147], [106, 150], [106, 173], [106, 178], [107, 108], [107, 111], [107, 113], [107, 116], [107, 118], [107, 128], [107, 129], [107, 136], [107, 138], [107, 152], [107, 157], [107, 158], [107, 162], [107, 169], [107, 179], [108, 109], [108, 110], [108, 117], [108, 120], [108, 122], [108, 124], [108, 133], [108, 136], [108, 140], [108, 143], [108, 147], [108, 148], [108, 159], [108, 165], [108, 166], [108, 173], [108, 179], [109, 120], [109, 127], [109, 129], [109, 144], [109, 145], [109, 146], [109, 156], [109, 159], [109, 160], [109, 164], [109, 165], [109, 167], [109, 169], [109, 171], [109, 176], [109, 177], [110, 111], [110, 119], [110, 127], [110, 135], [110, 138], [110, 139], [110, 141], [110, 153], [110, 166], [110, 169], [111, 113], [111, 118], [111, 122], [111, 123], [111, 125], [111, 129], [111, 130], [111, 132], [111, 134], [111, 151], [111, 165], [111, 167], [111, 170], [111, 177], [112, 116], [112, 122], [112, 134], [112, 135], [112, 136], [112, 140], [112, 149], [112, 151], [112, 154], [112, 156], [112, 173], [112, 178], [112, 179], [113, 114], [113, 133], [113, 145], [113, 149], [113, 156], [113, 173], [113, 179], [114, 121], [114, 123], [114, 127], [114, 133], [114, 137], [114, 138], [114, 143], [114, 144], [114, 147], [114, 159], [114, 162], [114, 167], [114, 171], [114, 177], [115, 132], [115, 133], [115, 134], [115, 138], [115, 146], [115, 148], [115, 156], [115, 157], [115, 159], [115, 161], [115, 167], [115, 168], [115, 172], [115, 175], [115, 177], [116, 121], [116, 133], [116, 138], [116, 142], [116, 148], [116, 150], [116, 155], [116, 167], [116, 174], [117, 120], [117, 132], [117, 135], [117, 138], [117, 140], [117, 147], [117, 150], [117, 152], [117, 159], [117, 160], [117, 161], [117, 163], [117, 164], [117, 169], [117, 178], [118, 119], [118, 125], [118, 127], [118, 128], [118, 136], [118, 147], [118, 149], [118, 159], [118, 167], [118, 173], [118, 174], [119, 126], [119, 128], [119, 136], [119, 137], [119, 146], [119, 147], [119, 153], [119, 160], [119, 174], [119, 175], [119, 176], [119, 178], [120, 122], [120, 123], [120, 128], [120, 131], [120, 133], [120, 134], [120, 136], [120, 137], [120, 144], [120, 147], [120, 158], [120, 162], [120, 165], [120, 166], [120, 179], [121, 127], [121, 134], [121, 136], [121, 140], [121, 143], [121, 144], [121, 145], [121, 147], [121, 150], [121, 164], [121, 174], [121, 175], [121, 178], [122, 129], [122, 132], [122, 135], [122, 139], [122, 151], [122, 152], [122, 155], [122, 170], [122, 178], [123, 135], [123, 140], [123, 141], [123, 143], [123, 145], [123, 148], [123, 153], [123, 154], [123, 155], [123, 157], [123, 165], [124, 130], [124, 132], [124, 139], [124, 142], [124, 143], [124, 146], [124, 148], [124, 152], [124, 155], [124, 158], [124, 169], [124, 170], [124, 176], [125, 128], [125, 130], [125, 131], [125, 135], [125, 141], [125, 148], [125, 164], [125, 169], [125, 172], [125, 177], [126, 128], [126, 129], [126, 132], [126, 133], [126, 139], [126, 142], [126, 146], [126, 148], [126, 151], [126, 154], [126, 159], [126, 161], [126, 162], [126, 170], [126, 172], [126, 174], [126, 177], [127, 139], [127, 141], [127, 144], [127, 145], [127, 153], [127, 154], [127, 155], [127, 157], [127, 160], [127, 175], [127, 179], [128, 129], [128, 150], [128, 152], [128, 156], [128, 161], [128, 165], [128, 170], [128, 172], [128, 178], [129, 138], [129, 141], [129, 143], [129, 146], [129, 151], [129, 163], [129, 166], [129, 174], [129, 177], [130, 142], [130, 143], [130, 146], [130, 147], [130, 149], [130, 155], [130, 158], [130, 159], [130, 161], [130, 163], [130, 169], [130, 175], [131, 132], [131, 137], [131, 146], [131, 148], [131, 153], [131, 155], [131, 156], [131, 159], [131, 160], [131, 168], [131, 170], [131, 171], [132, 141], [132, 142], [132, 148], [132, 151], [132, 169], [132, 171], [132, 172], [132, 173], [132, 176], [133, 134], [133, 139], [133, 146], [133, 148], [133, 149], [133, 150], [133, 162], [133, 175], [133, 177], [134, 145], [134, 146], [134, 149], [134, 152], [134, 157], [134, 159], [134, 161], [134, 168], [134, 169], [134, 173], [134, 176], [135, 138], [135, 143], [135, 146], [135, 157], [135, 166], [135, 176], [136, 138], [136, 139], [136, 152], [136, 161], [136, 164], [136, 168], [136, 169], [136, 170], [136, 173], [136, 175], [136, 177], [137, 148], [137, 158], [137, 165], [138, 141], [138, 143], [138, 153], [138, 158], [138, 174], [138, 178], [138, 179], [139, 144], [139, 152], [139, 155], [139, 158], [139, 160], [139, 164], [139, 168], [139, 170], [139, 171], [139, 173], [139, 175], [139, 178], [140, 142], [140, 144], [140, 148], [140, 157], [140, 166], [140, 167], [140, 173], [140, 177], [141, 143], [141, 147], [141, 154], [141, 156], [141, 161], [141, 168], [141, 172], [141, 174], [142, 143], [142, 148], [142, 151], [142, 152], [142, 155], [142, 158], [142, 159], [142, 161], [142, 170], [142, 171], [142, 174], [142, 175], [142, 177], [143, 145], [143, 147], [143, 148], [143, 150], [143, 155], [143, 159], [143, 161], [143, 168], [144, 151], [144, 152], [144, 159], [144, 162], [144, 169], [144, 173], [145, 147], [145, 169], [145, 171], [145, 172], [145, 179], [146, 148], [146, 150], [146, 151], [146, 153], [146, 157], [146, 161], [146, 172], [146, 174], [146, 175], [147, 148], [147, 154], [147, 162], [147, 165], [147, 171], [148, 154], [148, 155], [148, 160], [148, 161], [148, 167], [148, 171], [148, 172], [148, 176], [149, 152], [149, 161], [149, 163], [149, 168], [149, 169], [149, 177], [150, 154], [150, 156], [150, 160], [150, 161], [150, 164], [150, 175], [151, 153], [151, 160], [151, 161], [151, 167], [151, 173], [151, 174], [151, 176], [152, 156], [152, 158], [152, 162], [152, 163], [152, 166], [152, 168], [152, 169], [152, 170], [152, 177], [153, 156], [153, 164], [153, 166], [153, 167], [153, 168], [153, 172], [153, 177], [154, 159], [154, 173], [154, 175], [155, 160], [155, 161], [155, 171], [155, 174], [155, 175], [156, 157], [156, 158], [156, 166], [156, 171], [157, 158], [157, 161], [157, 163], [157, 168], [157, 169], [158, 159], [158, 162], [158, 166], [158, 167], [158, 169], [158, 174], [159, 165], [159, 170], [159, 171], [159, 175], [159, 176], [160, 165], [160, 168], [160, 173], [160, 178], [160, 179], [161, 163], [161, 165], [161, 167], [161, 168], [161, 177], [162, 163], [162, 172], [162, 173], [163, 166], [163, 171], [163, 178], [164, 178], [164, 179], [165, 167], [165, 168], [165, 170], [165, 174], [166, 169], [166, 170], [167, 178], [168, 171], [168, 175], [168, 177], [169, 176], [170, 171], [171, 175], [171, 177], [173, 176], [173, 177], [173, 178], [178, 179]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l5-s7/solution/solve.sh b/tasks/construct-nppc-dominating-set-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4ebb46442cc9968a6bdfabdf9c75a0776a1113f8 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [1, 29, 34, 37, 45, 84, 89, 134, 136, 138, 139, 146, 148, 165, 177]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l5-s7/tests/check.py b/tasks/construct-nppc-dominating-set-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s7/tests/check.py @@ -0,0 +1,23 @@ +"""Dominating set of size <= k. Accepts any valid dominating set.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier has no type/range checks (out-of-range labels and floats are silently used) + d = int_list(ans.get("dominating_set"), None, 0, n - 1, "dominating_set") + if len(set(d)) != len(d): + raise Invalid("dominating_set contains duplicates") + if not d or len(d) > k: + raise Invalid(f"dominating_set must have 1..{k} vertices, got {len(d)}") + dom = set(d) + s = set(d) + for u, v in inst["edges"]: + if u in s: + dom.add(v) + if v in s: + dom.add(u) + if len(dom) != n: + miss = min(set(range(n)) - dom) + raise Invalid(f"vertex {miss} is not dominated") + return None, {"size": len(d)} diff --git a/tasks/construct-nppc-dominating-set-l5-s7/tests/instance.json b/tasks/construct-nppc-dominating-set-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ab0109abe26f6c312b2192fda1bd48d103776633 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 180, "k": 15, "edges": [[0, 8], [0, 20], [0, 27], [0, 31], [0, 35], [0, 42], [0, 43], [0, 55], [0, 56], [0, 57], [0, 58], [0, 66], [0, 71], [0, 73], [0, 76], [0, 99], [0, 100], [0, 108], [0, 118], [0, 121], [0, 124], [0, 126], [0, 136], [0, 137], [0, 140], [0, 146], [0, 147], [0, 148], [0, 155], [0, 156], [0, 163], [0, 177], [1, 2], [1, 7], [1, 13], [1, 16], [1, 20], [1, 24], [1, 25], [1, 28], [1, 37], [1, 39], [1, 44], [1, 46], [1, 51], [1, 52], [1, 54], [1, 55], [1, 63], [1, 64], [1, 67], [1, 68], [1, 73], [1, 79], [1, 90], [1, 96], [1, 101], [1, 103], [1, 105], [1, 106], [1, 108], [1, 110], [1, 116], [1, 121], [1, 125], [1, 130], [1, 134], [1, 135], [1, 137], [1, 141], [1, 145], [1, 149], [1, 159], [1, 164], [1, 166], [1, 170], [2, 3], [2, 6], [2, 7], [2, 10], [2, 13], [2, 18], [2, 21], [2, 27], [2, 28], [2, 29], [2, 32], [2, 36], [2, 37], [2, 44], [2, 45], [2, 49], [2, 51], [2, 52], [2, 54], [2, 55], [2, 56], [2, 58], [2, 59], [2, 60], [2, 61], [2, 64], [2, 66], [2, 67], [2, 71], [2, 72], [2, 80], [2, 88], [2, 92], [2, 96], [2, 97], [2, 113], [2, 118], [2, 120], [2, 125], [2, 129], [2, 135], [2, 147], [2, 150], [2, 151], [2, 154], [2, 162], [2, 163], [2, 167], [2, 168], [2, 170], [2, 179], [3, 4], [3, 8], [3, 10], [3, 11], [3, 17], [3, 21], [3, 25], [3, 30], [3, 31], [3, 39], [3, 42], [3, 44], [3, 51], [3, 54], [3, 62], [3, 69], [3, 75], [3, 77], [3, 81], [3, 86], [3, 89], [3, 91], [3, 92], [3, 97], [3, 107], [3, 111], [3, 123], [3, 125], [3, 127], [3, 131], [3, 147], [3, 158], [3, 161], [4, 7], [4, 9], [4, 10], [4, 18], [4, 22], [4, 24], [4, 25], [4, 26], [4, 32], [4, 43], [4, 53], [4, 57], [4, 59], [4, 71], [4, 74], [4, 77], [4, 81], [4, 86], [4, 95], [4, 99], [4, 106], [4, 107], [4, 108], [4, 112], [4, 113], [4, 117], [4, 122], [4, 129], [4, 134], [4, 149], [4, 150], [4, 155], [4, 163], [4, 164], [4, 169], [4, 171], [4, 178], [4, 179], [5, 6], [5, 8], [5, 13], [5, 16], [5, 43], [5, 48], [5, 51], [5, 53], [5, 69], [5, 78], [5, 89], [5, 94], [5, 96], [5, 101], [5, 104], [5, 110], [5, 112], [5, 114], [5, 117], [5, 119], [5, 122], [5, 127], [5, 136], [5, 144], [5, 157], [5, 167], [5, 172], [5, 173], [5, 174], [5, 177], [5, 179], [6, 7], [6, 10], [6, 11], [6, 14], [6, 24], [6, 31], [6, 39], [6, 40], [6, 47], [6, 52], [6, 56], [6, 63], [6, 69], [6, 70], [6, 72], [6, 73], [6, 76], [6, 79], [6, 88], [6, 94], [6, 101], [6, 104], [6, 107], [6, 108], [6, 112], [6, 160], [6, 162], [6, 165], [6, 167], [6, 177], [6, 179], [7, 10], [7, 12], [7, 14], [7, 30], [7, 39], [7, 45], [7, 47], [7, 59], [7, 62], [7, 65], [7, 70], [7, 77], [7, 79], [7, 84], [7, 87], [7, 94], [7, 101], [7, 107], [7, 112], [7, 116], [7, 119], [7, 121], [7, 123], [7, 130], [7, 131], [7, 135], [7, 138], [7, 142], [7, 149], [7, 153], [7, 158], [7, 159], [7, 164], [8, 20], [8, 25], [8, 30], [8, 31], [8, 37], [8, 40], [8, 45], [8, 58], [8, 64], [8, 68], [8, 71], [8, 76], [8, 78], [8, 84], [8, 87], [8, 96], [8, 97], [8, 99], [8, 101], [8, 110], [8, 116], [8, 117], [8, 119], [8, 124], [8, 134], [8, 136], [8, 147], [8, 151], [8, 155], [8, 162], [8, 176], [9, 12], [9, 16], [9, 18], [9, 24], [9, 27], [9, 28], [9, 32], [9, 33], [9, 40], [9, 48], [9, 49], [9, 54], [9, 74], [9, 94], [9, 103], [9, 106], [9, 110], [9, 111], [9, 115], [9, 120], [9, 125], [9, 133], [9, 136], [9, 137], [9, 138], [9, 142], [9, 143], [9, 145], [9, 146], [9, 162], [9, 165], [9, 166], [9, 174], [10, 11], [10, 25], [10, 31], [10, 35], [10, 36], [10, 40], [10, 42], [10, 48], [10, 49], [10, 55], [10, 56], [10, 59], [10, 60], [10, 75], [10, 76], [10, 83], [10, 85], [10, 86], [10, 92], [10, 98], [10, 104], [10, 108], [10, 112], [10, 116], [10, 127], [10, 132], [10, 134], [10, 141], [10, 145], [10, 147], [10, 149], [10, 151], [10, 155], [10, 171], [10, 174], [11, 19], [11, 27], [11, 42], [11, 43], [11, 50], [11, 56], [11, 57], [11, 63], [11, 64], [11, 70], [11, 74], [11, 81], [11, 82], [11, 99], [11, 105], [11, 109], [11, 116], [11, 117], [11, 122], [11, 124], [11, 129], [11, 135], [11, 139], [11, 140], [11, 142], [11, 144], [11, 145], [11, 150], [11, 151], [11, 153], [11, 155], [11, 162], [11, 164], [11, 166], [11, 171], [11, 173], [11, 178], [12, 26], [12, 29], [12, 32], [12, 36], [12, 40], [12, 41], [12, 44], [12, 49], [12, 51], [12, 54], [12, 55], [12, 65], [12, 66], [12, 69], [12, 70], [12, 75], [12, 78], [12, 83], [12, 88], [12, 90], [12, 94], [12, 103], [12, 104], [12, 121], [12, 122], [12, 124], [12, 128], [12, 136], [12, 139], [12, 143], [12, 145], [12, 152], [12, 159], [12, 160], [12, 161], [12, 162], [12, 171], [12, 179], [13, 26], [13, 29], [13, 33], [13, 43], [13, 55], [13, 59], [13, 65], [13, 69], [13, 72], [13, 74], [13, 79], [13, 99], [13, 104], [13, 112], [13, 114], [13, 119], [13, 121], [13, 124], [13, 126], [13, 130], [13, 142], [13, 145], [13, 149], [13, 153], [13, 155], [13, 156], [13, 159], [13, 160], [13, 171], [14, 20], [14, 23], [14, 31], [14, 32], [14, 37], [14, 40], [14, 41], [14, 43], [14, 45], [14, 47], [14, 53], [14, 60], [14, 63], [14, 64], [14, 68], [14, 72], [14, 74], [14, 77], [14, 80], [14, 100], [14, 108], [14, 110], [14, 111], [14, 125], [14, 131], [14, 134], [14, 144], [14, 145], [14, 153], [14, 159], [14, 160], [14, 163], [14, 176], [14, 179], [15, 19], [15, 21], [15, 24], [15, 30], [15, 32], [15, 37], [15, 45], [15, 60], [15, 64], [15, 70], [15, 75], [15, 76], [15, 77], [15, 79], [15, 80], [15, 82], [15, 86], [15, 92], [15, 96], [15, 102], [15, 115], [15, 117], [15, 118], [15, 120], [15, 130], [15, 131], [15, 133], [15, 135], [15, 143], [15, 145], [15, 146], [15, 147], [15, 151], [15, 159], [15, 166], [16, 18], [16, 23], [16, 37], [16, 38], [16, 45], [16, 49], [16, 51], [16, 63], [16, 67], [16, 68], [16, 74], [16, 76], [16, 83], [16, 84], [16, 86], [16, 97], [16, 100], [16, 101], [16, 102], [16, 105], [16, 106], [16, 111], [16, 118], [16, 142], [16, 144], [16, 149], [16, 151], [16, 152], [16, 153], [16, 155], [16, 164], [16, 170], [16, 172], [16, 174], [16, 179], [17, 19], [17, 29], [17, 63], [17, 74], [17, 75], [17, 76], [17, 80], [17, 81], [17, 94], [17, 97], [17, 98], [17, 103], [17, 106], [17, 111], [17, 113], [17, 116], [17, 122], [17, 123], [17, 127], [17, 144], [17, 147], [17, 149], [17, 167], [17, 170], [18, 19], [18, 23], [18, 25], [18, 27], [18, 29], [18, 32], [18, 38], [18, 51], [18, 54], [18, 57], [18, 70], [18, 85], [18, 88], [18, 95], [18, 101], [18, 103], [18, 104], [18, 109], [18, 110], [18, 124], [18, 129], [18, 132], [18, 134], [18, 136], [18, 138], [18, 141], [18, 143], [18, 145], [18, 150], [18, 156], [18, 160], [18, 161], [18, 164], [18, 165], [18, 168], [18, 169], [18, 171], [18, 172], [19, 25], [19, 28], [19, 29], [19, 32], [19, 38], [19, 39], [19, 44], [19, 54], [19, 55], [19, 57], [19, 69], [19, 73], [19, 74], [19, 75], [19, 86], [19, 87], [19, 88], [19, 89], [19, 90], [19, 93], [19, 97], [19, 99], [19, 104], [19, 111], [19, 113], [19, 114], [19, 115], [19, 121], [19, 135], [19, 138], [19, 140], [19, 144], [19, 146], [19, 148], [19, 157], [19, 165], [19, 173], [19, 175], [19, 178], [20, 24], [20, 29], [20, 37], [20, 43], [20, 46], [20, 48], [20, 57], [20, 60], [20, 62], [20, 64], [20, 73], [20, 78], [20, 83], [20, 85], [20, 87], [20, 89], [20, 92], [20, 93], [20, 102], [20, 104], [20, 111], [20, 117], [20, 120], [20, 126], [20, 128], [20, 136], [20, 137], [20, 138], [20, 141], [20, 143], [20, 145], [20, 146], [20, 147], [20, 152], [20, 155], [20, 156], [20, 159], [20, 173], [20, 176], [21, 22], [21, 27], [21, 29], [21, 42], [21, 50], [21, 56], [21, 63], [21, 65], [21, 66], [21, 71], [21, 74], [21, 75], [21, 81], [21, 93], [21, 94], [21, 107], [21, 113], [21, 126], [21, 136], [21, 148], [21, 163], [22, 34], [22, 35], [22, 38], [22, 39], [22, 40], [22, 44], [22, 53], [22, 55], [22, 56], [22, 57], [22, 58], [22, 61], [22, 68], [22, 81], [22, 84], [22, 88], [22, 94], [22, 96], [22, 99], [22, 100], [22, 104], [22, 105], [22, 106], [22, 108], [22, 112], [22, 115], [22, 122], [22, 131], [22, 137], [22, 142], [22, 144], [22, 148], [22, 151], [22, 168], [22, 169], [22, 170], [22, 173], [23, 34], [23, 39], [23, 47], [23, 48], [23, 52], [23, 54], [23, 59], [23, 63], [23, 77], [23, 80], [23, 83], [23, 93], [23, 96], [23, 102], [23, 116], [23, 117], [23, 119], [23, 128], [23, 133], [23, 138], [23, 139], [23, 141], [23, 166], [23, 174], [24, 26], [24, 29], [24, 30], [24, 34], [24, 37], [24, 47], [24, 50], [24, 54], [24, 76], [24, 78], [24, 81], [24, 88], [24, 89], [24, 100], [24, 112], [24, 113], [24, 122], [24, 126], [24, 129], [24, 131], [24, 136], [24, 141], [24, 142], [24, 147], [24, 159], [24, 163], [24, 168], [24, 169], [24, 173], [24, 177], [24, 178], [25, 26], [25, 29], [25, 40], [25, 46], [25, 48], [25, 54], [25, 58], [25, 59], [25, 60], [25, 61], [25, 65], [25, 71], [25, 85], [25, 90], [25, 105], [25, 110], [25, 119], [25, 120], [25, 122], [25, 129], [25, 132], [25, 135], [25, 148], [25, 156], [25, 162], [25, 165], [25, 166], [25, 168], [25, 175], [25, 176], [26, 33], [26, 37], [26, 40], [26, 41], [26, 44], [26, 45], [26, 46], [26, 62], [26, 68], [26, 75], [26, 80], [26, 86], [26, 89], [26, 101], [26, 103], [26, 104], [26, 109], [26, 111], [26, 115], [26, 118], [26, 120], [26, 125], [26, 133], [26, 134], [26, 137], [26, 149], [26, 152], [26, 156], [26, 157], [26, 168], [26, 171], [26, 173], [27, 44], [27, 46], [27, 51], [27, 62], [27, 72], [27, 78], [27, 86], [27, 92], [27, 95], [27, 101], [27, 103], [27, 105], [27, 116], [27, 118], [27, 121], [27, 123], [27, 131], [27, 133], [27, 137], [27, 138], [27, 139], [27, 140], [27, 142], [27, 146], [27, 151], [27, 152], [27, 166], [27, 169], [27, 171], [27, 176], [27, 178], [28, 33], [28, 34], [28, 46], [28, 53], [28, 54], [28, 58], [28, 59], [28, 83], [28, 84], [28, 89], [28, 92], [28, 98], [28, 105], [28, 112], [28, 131], [28, 139], [28, 140], [28, 143], [28, 146], [28, 151], [28, 157], [28, 163], [28, 174], [28, 179], [29, 43], [29, 44], [29, 52], [29, 55], [29, 59], [29, 61], [29, 62], [29, 63], [29, 64], [29, 74], [29, 78], [29, 87], [29, 106], [29, 112], [29, 113], [29, 116], [29, 125], [29, 126], [29, 130], [29, 132], [29, 133], [29, 137], [29, 138], [29, 167], [29, 171], [29, 173], [30, 36], [30, 37], [30, 43], [30, 48], [30, 49], [30, 67], [30, 69], [30, 71], [30, 72], [30, 76], [30, 80], [30, 89], [30, 92], [30, 98], [30, 108], [30, 110], [30, 119], [30, 120], [30, 122], [30, 139], [30, 148], [30, 149], [30, 150], [30, 154], [30, 157], [30, 166], [30, 174], [31, 34], [31, 37], [31, 40], [31, 45], [31, 52], [31, 55], [31, 59], [31, 66], [31, 70], [31, 75], [31, 78], [31, 81], [31, 83], [31, 90], [31, 93], [31, 97], [31, 98], [31, 100], [31, 101], [31, 103], [31, 110], [31, 111], [31, 116], [31, 117], [31, 125], [31, 126], [31, 131], [31, 135], [31, 137], [31, 138], [31, 139], [31, 146], [31, 148], [31, 150], [31, 153], [31, 155], [31, 156], [31, 159], [31, 171], [31, 174], [31, 175], [32, 34], [32, 37], [32, 38], [32, 39], [32, 40], [32, 58], [32, 63], [32, 71], [32, 72], [32, 77], [32, 78], [32, 80], [32, 81], [32, 87], [32, 88], [32, 89], [32, 94], [32, 100], [32, 108], [32, 113], [32, 157], [32, 158], [32, 171], [32, 172], [32, 175], [32, 176], [33, 47], [33, 48], [33, 50], [33, 51], [33, 58], [33, 60], [33, 72], [33, 77], [33, 85], [33, 93], [33, 110], [33, 116], [33, 118], [33, 129], [33, 130], [33, 149], [33, 157], [33, 163], [33, 165], [33, 169], [33, 171], [33, 177], [33, 179], [34, 41], [34, 53], [34, 54], [34, 55], [34, 56], [34, 57], [34, 58], [34, 63], [34, 66], [34, 69], [34, 75], [34, 77], [34, 85], [34, 90], [34, 103], [34, 104], [34, 108], [34, 111], [34, 114], [34, 121], [34, 122], [34, 123], [34, 140], [34, 147], [34, 148], [34, 149], [34, 154], [34, 157], [34, 161], [34, 163], [34, 166], [34, 170], [35, 37], [35, 38], [35, 40], [35, 42], [35, 43], [35, 46], [35, 50], [35, 55], [35, 56], [35, 57], [35, 68], [35, 69], [35, 72], [35, 73], [35, 80], [35, 84], [35, 86], [35, 100], [35, 103], [35, 114], [35, 115], [35, 117], [35, 124], [35, 142], [35, 150], [35, 155], [35, 156], [35, 157], [35, 158], [35, 163], [35, 164], [35, 179], [36, 37], [36, 43], [36, 44], [36, 51], [36, 53], [36, 57], [36, 59], [36, 64], [36, 70], [36, 84], [36, 85], [36, 91], [36, 95], [36, 96], [36, 98], [36, 103], [36, 106], [36, 113], [36, 116], [36, 120], [36, 121], [36, 126], [36, 127], [36, 130], [36, 133], [36, 140], [36, 148], [36, 156], [36, 157], [36, 170], [36, 172], [36, 178], [37, 38], [37, 47], [37, 52], [37, 60], [37, 62], [37, 65], [37, 72], [37, 81], [37, 82], [37, 83], [37, 87], [37, 91], [37, 97], [37, 98], [37, 99], [37, 101], [37, 114], [37, 123], [37, 125], [37, 132], [37, 133], [37, 138], [37, 139], [37, 141], [37, 143], [37, 144], [37, 147], [37, 150], [37, 151], [37, 154], [37, 156], [37, 160], [37, 169], [37, 174], [37, 177], [37, 179], [38, 47], [38, 50], [38, 57], [38, 59], [38, 64], [38, 100], [38, 101], [38, 104], [38, 109], [38, 113], [38, 117], [38, 124], [38, 125], [38, 128], [38, 131], [38, 137], [38, 141], [38, 146], [38, 148], [38, 149], [38, 165], [38, 166], [38, 167], [38, 170], [38, 176], [39, 40], [39, 41], [39, 50], [39, 63], [39, 78], [39, 81], [39, 83], [39, 84], [39, 85], [39, 86], [39, 90], [39, 96], [39, 97], [39, 99], [39, 105], [39, 109], [39, 113], [39, 133], [39, 136], [39, 142], [39, 144], [39, 149], [39, 150], [39, 155], [39, 156], [39, 158], [39, 168], [39, 175], [40, 48], [40, 49], [40, 79], [40, 82], [40, 96], [40, 102], [40, 107], [40, 109], [40, 114], [40, 116], [40, 117], [40, 118], [40, 124], [40, 128], [40, 134], [40, 137], [40, 138], [40, 140], [40, 144], [40, 148], [40, 149], [40, 152], [40, 154], [40, 160], [40, 162], [40, 170], [40, 175], [40, 177], [41, 44], [41, 45], [41, 47], [41, 51], [41, 56], [41, 68], [41, 70], [41, 74], [41, 82], [41, 86], [41, 97], [41, 99], [41, 104], [41, 129], [41, 133], [41, 135], [41, 136], [41, 137], [41, 150], [41, 158], [41, 165], [41, 174], [42, 43], [42, 48], [42, 52], [42, 59], [42, 66], [42, 70], [42, 88], [42, 89], [42, 97], [42, 98], [42, 100], [42, 104], [42, 109], [42, 130], [42, 139], [42, 154], [42, 155], [42, 157], [42, 165], [42, 174], [43, 53], [43, 58], [43, 60], [43, 61], [43, 62], [43, 64], [43, 74], [43, 75], [43, 87], [43, 109], [43, 111], [43, 124], [43, 126], [43, 138], [43, 139], [43, 140], [43, 143], [43, 148], [43, 152], [43, 153], [43, 163], [43, 164], [43, 167], [43, 168], [43, 179], [44, 46], [44, 48], [44, 51], [44, 56], [44, 63], [44, 71], [44, 84], [44, 85], [44, 96], [44, 97], [44, 100], [44, 103], [44, 116], [44, 120], [44, 121], [44, 128], [44, 133], [44, 134], [44, 135], [44, 136], [44, 138], [44, 143], [44, 145], [44, 162], [44, 163], [44, 166], [44, 171], [44, 172], [44, 173], [45, 51], [45, 52], [45, 53], [45, 55], [45, 62], [45, 64], [45, 68], [45, 75], [45, 95], [45, 97], [45, 101], [45, 105], [45, 108], [45, 115], [45, 116], [45, 122], [45, 126], [45, 130], [45, 133], [45, 135], [45, 139], [45, 149], [45, 156], [45, 160], [45, 165], [45, 171], [45, 175], [46, 49], [46, 55], [46, 56], [46, 62], [46, 69], [46, 84], [46, 87], [46, 88], [46, 89], [46, 95], [46, 101], [46, 103], [46, 106], [46, 111], [46, 112], [46, 116], [46, 117], [46, 144], [46, 148], [46, 149], [46, 152], [46, 157], [46, 160], [46, 161], [46, 168], [46, 175], [46, 177], [47, 49], [47, 55], [47, 57], [47, 61], [47, 64], [47, 66], [47, 70], [47, 71], [47, 79], [47, 81], [47, 88], [47, 94], [47, 95], [47, 100], [47, 101], [47, 103], [47, 106], [47, 109], [47, 110], [47, 111], [47, 114], [47, 115], [47, 120], [47, 122], [47, 125], [47, 127], [47, 131], [47, 132], [47, 133], [47, 136], [47, 146], [47, 154], [47, 158], [47, 159], [47, 165], [47, 166], [47, 172], [47, 175], [47, 177], [48, 49], [48, 51], [48, 52], [48, 59], [48, 62], [48, 69], [48, 72], [48, 73], [48, 77], [48, 80], [48, 84], [48, 87], [48, 88], [48, 98], [48, 100], [48, 101], [48, 102], [48, 104], [48, 106], [48, 124], [48, 130], [48, 133], [48, 138], [48, 144], [48, 158], [48, 160], [48, 161], [48, 162], [48, 179], [49, 62], [49, 67], [49, 74], [49, 85], [49, 90], [49, 98], [49, 103], [49, 122], [49, 123], [49, 124], [49, 128], [49, 136], [49, 138], [49, 139], [49, 141], [49, 144], [49, 145], [49, 147], [49, 158], [49, 167], [49, 169], [49, 173], [49, 175], [49, 178], [50, 53], [50, 57], [50, 60], [50, 67], [50, 71], [50, 73], [50, 76], [50, 80], [50, 82], [50, 87], [50, 97], [50, 98], [50, 101], [50, 103], [50, 104], [50, 106], [50, 113], [50, 117], [50, 120], [50, 130], [50, 131], [50, 136], [50, 137], [50, 140], [50, 144], [50, 148], [50, 151], [50, 152], [50, 155], [50, 161], [50, 164], [50, 172], [50, 174], [50, 179], [51, 54], [51, 56], [51, 63], [51, 66], [51, 68], [51, 72], [51, 73], [51, 76], [51, 78], [51, 84], [51, 88], [51, 89], [51, 93], [51, 103], [51, 107], [51, 112], [51, 120], [51, 122], [51, 126], [51, 129], [51, 131], [51, 134], [51, 145], [51, 150], [51, 164], [51, 165], [51, 174], [52, 56], [52, 59], [52, 60], [52, 63], [52, 72], [52, 73], [52, 76], [52, 80], [52, 81], [52, 91], [52, 92], [52, 93], [52, 95], [52, 110], [52, 121], [52, 122], [52, 125], [52, 133], [52, 135], [52, 136], [52, 137], [52, 138], [52, 142], [52, 143], [52, 146], [52, 149], [52, 154], [52, 159], [52, 170], [52, 172], [52, 179], [53, 64], [53, 68], [53, 72], [53, 78], [53, 79], [53, 90], [53, 92], [53, 97], [53, 99], [53, 108], [53, 116], [53, 136], [53, 139], [53, 140], [53, 143], [53, 148], [53, 164], [53, 168], [53, 170], [53, 171], [53, 172], [53, 175], [53, 176], [53, 177], [54, 58], [54, 59], [54, 68], [54, 69], [54, 71], [54, 73], [54, 75], [54, 78], [54, 80], [54, 83], [54, 84], [54, 85], [54, 86], [54, 88], [54, 96], [54, 100], [54, 107], [54, 117], [54, 120], [54, 138], [54, 142], [54, 143], [54, 146], [54, 154], [54, 158], [54, 159], [54, 160], [54, 167], [54, 172], [54, 175], [54, 176], [54, 177], [55, 70], [55, 72], [55, 85], [55, 87], [55, 94], [55, 100], [55, 101], [55, 102], [55, 103], [55, 117], [55, 118], [55, 127], [55, 128], [55, 129], [55, 132], [55, 135], [55, 136], [55, 138], [55, 140], [55, 143], [55, 147], [55, 148], [55, 152], [55, 163], [55, 168], [55, 169], [55, 170], [55, 177], [55, 179], [56, 60], [56, 61], [56, 65], [56, 69], [56, 70], [56, 77], [56, 81], [56, 82], [56, 95], [56, 96], [56, 109], [56, 110], [56, 111], [56, 113], [56, 118], [56, 127], [56, 129], [56, 141], [56, 152], [56, 161], [56, 168], [56, 177], [57, 70], [57, 81], [57, 86], [57, 90], [57, 103], [57, 110], [57, 115], [57, 120], [57, 122], [57, 123], [57, 130], [57, 134], [57, 157], [57, 158], [57, 167], [57, 169], [57, 175], [57, 178], [58, 65], [58, 67], [58, 97], [58, 100], [58, 103], [58, 111], [58, 113], [58, 117], [58, 118], [58, 119], [58, 120], [58, 124], [58, 126], [58, 128], [58, 130], [58, 131], [58, 133], [58, 138], [58, 139], [58, 141], [58, 160], [58, 164], [58, 166], [58, 168], [58, 169], [58, 172], [58, 177], [58, 179], [59, 62], [59, 63], [59, 76], [59, 79], [59, 81], [59, 95], [59, 98], [59, 99], [59, 104], [59, 109], [59, 117], [59, 118], [59, 129], [59, 130], [59, 133], [59, 134], [59, 138], [59, 143], [59, 145], [59, 147], [59, 148], [59, 152], [59, 155], [59, 156], [59, 157], [59, 161], [59, 163], [59, 166], [59, 175], [59, 176], [60, 64], [60, 69], [60, 70], [60, 73], [60, 81], [60, 100], [60, 108], [60, 110], [60, 111], [60, 114], [60, 137], [60, 145], [60, 147], [60, 149], [60, 150], [60, 158], [60, 159], [60, 177], [61, 67], [61, 78], [61, 80], [61, 92], [61, 95], [61, 97], [61, 106], [61, 107], [61, 113], [61, 119], [61, 130], [61, 142], [61, 146], [61, 147], [61, 148], [61, 149], [61, 166], [61, 174], [61, 175], [62, 66], [62, 69], [62, 80], [62, 86], [62, 94], [62, 95], [62, 105], [62, 115], [62, 117], [62, 124], [62, 134], [62, 138], [62, 156], [62, 163], [62, 165], [62, 173], [62, 175], [62, 176], [63, 68], [63, 82], [63, 89], [63, 93], [63, 96], [63, 99], [63, 106], [63, 107], [63, 123], [63, 124], [63, 131], [63, 136], [63, 139], [63, 140], [63, 146], [63, 150], [63, 153], [63, 166], [63, 175], [64, 73], [64, 81], [64, 82], [64, 86], [64, 96], [64, 97], [64, 100], [64, 101], [64, 113], [64, 116], [64, 118], [64, 123], [64, 132], [64, 134], [64, 148], [64, 150], [64, 153], [64, 154], [64, 160], [64, 174], [65, 70], [65, 82], [65, 83], [65, 86], [65, 96], [65, 100], [65, 101], [65, 105], [65, 107], [65, 120], [65, 137], [65, 141], [65, 145], [65, 148], [65, 150], [65, 151], [65, 153], [65, 154], [65, 162], [65, 164], [65, 165], [65, 169], [65, 178], [66, 67], [66, 70], [66, 84], [66, 86], [66, 90], [66, 97], [66, 103], [66, 105], [66, 113], [66, 114], [66, 116], [66, 117], [66, 121], [66, 143], [66, 148], [66, 150], [66, 154], [66, 156], [66, 160], [66, 162], [66, 165], [66, 179], [67, 68], [67, 79], [67, 84], [67, 89], [67, 95], [67, 97], [67, 104], [67, 106], [67, 113], [67, 118], [67, 125], [67, 127], [67, 130], [67, 132], [67, 138], [67, 145], [67, 154], [67, 155], [67, 156], [67, 164], [67, 171], [67, 178], [68, 72], [68, 78], [68, 81], [68, 84], [68, 87], [68, 91], [68, 98], [68, 100], [68, 102], [68, 116], [68, 121], [68, 123], [68, 126], [68, 130], [68, 134], [68, 135], [68, 136], [68, 137], [68, 139], [68, 142], [68, 144], [68, 150], [68, 155], [68, 158], [68, 174], [68, 177], [69, 70], [69, 74], [69, 82], [69, 84], [69, 90], [69, 94], [69, 99], [69, 101], [69, 104], [69, 109], [69, 110], [69, 111], [69, 113], [69, 124], [69, 125], [69, 126], [69, 128], [69, 133], [69, 136], [69, 142], [69, 143], [69, 147], [69, 149], [69, 151], [69, 158], [69, 160], [69, 163], [69, 165], [69, 177], [70, 72], [70, 73], [70, 83], [70, 87], [70, 91], [70, 92], [70, 94], [70, 98], [70, 101], [70, 103], [70, 107], [70, 114], [70, 126], [70, 129], [70, 139], [70, 141], [70, 142], [70, 150], [70, 151], [70, 155], [70, 156], [70, 158], [70, 163], [70, 164], [70, 171], [70, 172], [70, 174], [70, 175], [71, 79], [71, 81], [71, 85], [71, 86], [71, 89], [71, 96], [71, 98], [71, 105], [71, 112], [71, 124], [71, 132], [71, 136], [71, 138], [71, 139], [71, 141], [71, 147], [71, 152], [71, 153], [71, 159], [71, 166], [71, 171], [72, 74], [72, 77], [72, 86], [72, 92], [72, 93], [72, 104], [72, 109], [72, 110], [72, 114], [72, 121], [72, 125], [72, 127], [72, 134], [72, 137], [72, 146], [72, 149], [72, 158], [72, 159], [72, 171], [72, 172], [73, 76], [73, 82], [73, 84], [73, 85], [73, 89], [73, 96], [73, 99], [73, 100], [73, 101], [73, 104], [73, 116], [73, 124], [73, 133], [73, 134], [73, 138], [73, 139], [73, 159], [73, 163], [73, 164], [73, 170], [73, 172], [73, 174], [73, 175], [73, 178], [74, 77], [74, 79], [74, 85], [74, 99], [74, 103], [74, 105], [74, 114], [74, 117], [74, 120], [74, 123], [74, 129], [74, 132], [74, 136], [74, 139], [74, 147], [74, 151], [74, 152], [74, 161], [74, 173], [74, 175], [74, 178], [75, 79], [75, 92], [75, 93], [75, 99], [75, 127], [75, 128], [75, 140], [75, 153], [75, 154], [75, 155], [75, 159], [75, 163], [75, 164], [75, 175], [75, 179], [76, 78], [76, 83], [76, 88], [76, 89], [76, 90], [76, 91], [76, 102], [76, 109], [76, 110], [76, 113], [76, 117], [76, 119], [76, 131], [76, 141], [76, 146], [76, 152], [76, 153], [76, 156], [76, 172], [76, 173], [76, 175], [76, 178], [77, 78], [77, 95], [77, 100], [77, 103], [77, 111], [77, 112], [77, 129], [77, 131], [77, 139], [77, 140], [77, 141], [77, 145], [77, 147], [77, 150], [77, 153], [77, 154], [77, 155], [77, 163], [77, 164], [77, 169], [77, 170], [77, 179], [78, 85], [78, 93], [78, 95], [78, 103], [78, 104], [78, 107], [78, 111], [78, 113], [78, 119], [78, 123], [78, 124], [78, 125], [78, 133], [78, 143], [78, 157], [78, 160], [78, 162], [78, 175], [79, 81], [79, 84], [79, 87], [79, 89], [79, 102], [79, 105], [79, 111], [79, 116], [79, 121], [79, 122], [79, 125], [79, 131], [79, 132], [79, 141], [79, 154], [79, 157], [79, 166], [79, 176], [80, 82], [80, 90], [80, 101], [80, 108], [80, 109], [80, 114], [80, 119], [80, 122], [80, 129], [80, 133], [80, 134], [80, 135], [80, 140], [80, 141], [80, 150], [80, 154], [80, 162], [80, 165], [80, 166], [80, 167], [80, 168], [80, 173], [80, 174], [80, 179], [81, 85], [81, 89], [81, 95], [81, 96], [81, 97], [81, 98], [81, 126], [81, 131], [81, 134], [81, 136], [81, 144], [81, 145], [81, 148], [81, 150], [81, 151], [81, 153], [81, 156], [81, 170], [82, 94], [82, 101], [82, 107], [82, 108], [82, 111], [82, 120], [82, 121], [82, 125], [82, 142], [82, 161], [82, 165], [82, 167], [82, 170], [82, 175], [82, 176], [83, 84], [83, 90], [83, 95], [83, 97], [83, 100], [83, 108], [83, 111], [83, 120], [83, 125], [83, 128], [83, 135], [83, 136], [83, 141], [83, 143], [83, 145], [83, 147], [83, 155], [83, 156], [83, 160], [83, 161], [83, 169], [83, 170], [83, 173], [83, 174], [83, 177], [83, 178], [83, 179], [84, 87], [84, 90], [84, 91], [84, 93], [84, 108], [84, 109], [84, 112], [84, 117], [84, 126], [84, 128], [84, 130], [84, 145], [84, 150], [84, 151], [84, 155], [84, 156], [84, 158], [84, 161], [84, 162], [84, 163], [84, 166], [84, 178], [85, 86], [85, 87], [85, 95], [85, 98], [85, 100], [85, 105], [85, 108], [85, 118], [85, 122], [85, 127], [85, 135], [85, 146], [85, 159], [85, 161], [85, 163], [85, 165], [86, 88], [86, 95], [86, 97], [86, 100], [86, 105], [86, 110], [86, 115], [86, 116], [86, 123], [86, 130], [86, 132], [86, 134], [86, 145], [86, 148], [86, 149], [86, 150], [86, 162], [86, 171], [86, 176], [86, 177], [87, 89], [87, 92], [87, 93], [87, 100], [87, 104], [87, 110], [87, 134], [87, 143], [87, 149], [87, 153], [87, 154], [87, 156], [87, 160], [87, 163], [87, 170], [88, 92], [88, 102], [88, 104], [88, 105], [88, 116], [88, 117], [88, 136], [88, 139], [88, 141], [88, 142], [88, 144], [88, 146], [88, 151], [88, 152], [88, 158], [88, 163], [88, 166], [88, 168], [88, 175], [88, 176], [88, 177], [89, 90], [89, 91], [89, 92], [89, 101], [89, 104], [89, 113], [89, 116], [89, 119], [89, 120], [89, 124], [89, 125], [89, 129], [89, 131], [89, 138], [89, 140], [89, 144], [89, 147], [89, 156], [89, 157], [89, 159], [89, 162], [89, 163], [89, 165], [89, 167], [89, 175], [90, 92], [90, 97], [90, 98], [90, 100], [90, 104], [90, 106], [90, 115], [90, 118], [90, 120], [90, 122], [90, 124], [90, 127], [90, 134], [90, 143], [90, 145], [90, 156], [90, 161], [90, 165], [90, 167], [90, 177], [90, 178], [91, 92], [91, 98], [91, 101], [91, 112], [91, 113], [91, 117], [91, 118], [91, 121], [91, 129], [91, 131], [91, 138], [91, 139], [91, 142], [91, 145], [91, 148], [91, 149], [91, 163], [91, 164], [91, 166], [91, 168], [91, 175], [92, 94], [92, 99], [92, 107], [92, 109], [92, 111], [92, 112], [92, 115], [92, 117], [92, 119], [92, 121], [92, 122], [92, 127], [92, 128], [92, 129], [92, 139], [92, 142], [92, 147], [92, 148], [92, 153], [92, 154], [92, 160], [92, 165], [92, 167], [93, 103], [93, 106], [93, 107], [93, 116], [93, 119], [93, 122], [93, 139], [93, 147], [93, 148], [93, 154], [93, 155], [93, 156], [93, 159], [93, 160], [93, 167], [93, 168], [93, 172], [93, 178], [94, 103], [94, 110], [94, 120], [94, 127], [94, 130], [94, 132], [94, 138], [94, 141], [94, 143], [94, 146], [94, 147], [94, 153], [94, 156], [94, 158], [94, 164], [94, 170], [94, 174], [95, 108], [95, 118], [95, 119], [95, 125], [95, 132], [95, 134], [95, 136], [95, 139], [95, 142], [95, 144], [95, 146], [95, 148], [95, 150], [95, 151], [95, 154], [95, 157], [95, 158], [95, 161], [95, 162], [95, 164], [95, 168], [95, 171], [95, 173], [96, 100], [96, 101], [96, 103], [96, 108], [96, 116], [96, 118], [96, 120], [96, 126], [96, 129], [96, 136], [96, 141], [96, 148], [96, 151], [96, 154], [96, 160], [96, 166], [96, 170], [97, 100], [97, 103], [97, 110], [97, 111], [97, 125], [97, 128], [97, 133], [97, 154], [97, 157], [97, 161], [97, 163], [97, 173], [97, 176], [98, 99], [98, 108], [98, 110], [98, 117], [98, 120], [98, 123], [98, 124], [98, 125], [98, 129], [98, 136], [98, 138], [98, 143], [98, 144], [98, 157], [98, 159], [98, 161], [98, 168], [99, 102], [99, 103], [99, 107], [99, 111], [99, 126], [99, 139], [99, 140], [99, 142], [99, 148], [99, 151], [99, 157], [99, 158], [99, 177], [99, 178], [100, 107], [100, 121], [100, 125], [100, 137], [100, 138], [100, 146], [100, 148], [100, 155], [100, 161], [100, 163], [100, 165], [100, 170], [100, 178], [100, 179], [101, 103], [101, 107], [101, 115], [101, 116], [101, 121], [101, 130], [101, 131], [101, 133], [101, 141], [101, 143], [101, 148], [101, 149], [101, 154], [101, 155], [101, 160], [101, 162], [101, 165], [101, 174], [101, 177], [101, 178], [102, 103], [102, 121], [102, 122], [102, 130], [102, 133], [102, 138], [102, 145], [102, 146], [102, 148], [102, 149], [102, 151], [102, 153], [102, 159], [102, 160], [103, 107], [103, 112], [103, 121], [103, 123], [103, 127], [103, 131], [103, 132], [103, 133], [103, 135], [103, 139], [103, 142], [103, 143], [103, 144], [103, 146], [103, 152], [103, 153], [103, 155], [103, 160], [103, 176], [104, 105], [104, 109], [104, 124], [104, 126], [104, 134], [104, 142], [104, 144], [104, 145], [104, 146], [104, 147], [104, 148], [104, 150], [104, 152], [104, 165], [104, 171], [104, 177], [105, 108], [105, 132], [105, 136], [105, 140], [105, 155], [105, 156], [105, 162], [105, 164], [105, 171], [105, 173], [105, 175], [105, 177], [106, 110], [106, 112], [106, 122], [106, 124], [106, 126], [106, 127], [106, 128], [106, 136], [106, 138], [106, 143], [106, 147], [106, 150], [106, 173], [106, 178], [107, 108], [107, 111], [107, 113], [107, 116], [107, 118], [107, 128], [107, 129], [107, 136], [107, 138], [107, 152], [107, 157], [107, 158], [107, 162], [107, 169], [107, 179], [108, 109], [108, 110], [108, 117], [108, 120], [108, 122], [108, 124], [108, 133], [108, 136], [108, 140], [108, 143], [108, 147], [108, 148], [108, 159], [108, 165], [108, 166], [108, 173], [108, 179], [109, 120], [109, 127], [109, 129], [109, 144], [109, 145], [109, 146], [109, 156], [109, 159], [109, 160], [109, 164], [109, 165], [109, 167], [109, 169], [109, 171], [109, 176], [109, 177], [110, 111], [110, 119], [110, 127], [110, 135], [110, 138], [110, 139], [110, 141], [110, 153], [110, 166], [110, 169], [111, 113], [111, 118], [111, 122], [111, 123], [111, 125], [111, 129], [111, 130], [111, 132], [111, 134], [111, 151], [111, 165], [111, 167], [111, 170], [111, 177], [112, 116], [112, 122], [112, 134], [112, 135], [112, 136], [112, 140], [112, 149], [112, 151], [112, 154], [112, 156], [112, 173], [112, 178], [112, 179], [113, 114], [113, 133], [113, 145], [113, 149], [113, 156], [113, 173], [113, 179], [114, 121], [114, 123], [114, 127], [114, 133], [114, 137], [114, 138], [114, 143], [114, 144], [114, 147], [114, 159], [114, 162], [114, 167], [114, 171], [114, 177], [115, 132], [115, 133], [115, 134], [115, 138], [115, 146], [115, 148], [115, 156], [115, 157], [115, 159], [115, 161], [115, 167], [115, 168], [115, 172], [115, 175], [115, 177], [116, 121], [116, 133], [116, 138], [116, 142], [116, 148], [116, 150], [116, 155], [116, 167], [116, 174], [117, 120], [117, 132], [117, 135], [117, 138], [117, 140], [117, 147], [117, 150], [117, 152], [117, 159], [117, 160], [117, 161], [117, 163], [117, 164], [117, 169], [117, 178], [118, 119], [118, 125], [118, 127], [118, 128], [118, 136], [118, 147], [118, 149], [118, 159], [118, 167], [118, 173], [118, 174], [119, 126], [119, 128], [119, 136], [119, 137], [119, 146], [119, 147], [119, 153], [119, 160], [119, 174], [119, 175], [119, 176], [119, 178], [120, 122], [120, 123], [120, 128], [120, 131], [120, 133], [120, 134], [120, 136], [120, 137], [120, 144], [120, 147], [120, 158], [120, 162], [120, 165], [120, 166], [120, 179], [121, 127], [121, 134], [121, 136], [121, 140], [121, 143], [121, 144], [121, 145], [121, 147], [121, 150], [121, 164], [121, 174], [121, 175], [121, 178], [122, 129], [122, 132], [122, 135], [122, 139], [122, 151], [122, 152], [122, 155], [122, 170], [122, 178], [123, 135], [123, 140], [123, 141], [123, 143], [123, 145], [123, 148], [123, 153], [123, 154], [123, 155], [123, 157], [123, 165], [124, 130], [124, 132], [124, 139], [124, 142], [124, 143], [124, 146], [124, 148], [124, 152], [124, 155], [124, 158], [124, 169], [124, 170], [124, 176], [125, 128], [125, 130], [125, 131], [125, 135], [125, 141], [125, 148], [125, 164], [125, 169], [125, 172], [125, 177], [126, 128], [126, 129], [126, 132], [126, 133], [126, 139], [126, 142], [126, 146], [126, 148], [126, 151], [126, 154], [126, 159], [126, 161], [126, 162], [126, 170], [126, 172], [126, 174], [126, 177], [127, 139], [127, 141], [127, 144], [127, 145], [127, 153], [127, 154], [127, 155], [127, 157], [127, 160], [127, 175], [127, 179], [128, 129], [128, 150], [128, 152], [128, 156], [128, 161], [128, 165], [128, 170], [128, 172], [128, 178], [129, 138], [129, 141], [129, 143], [129, 146], [129, 151], [129, 163], [129, 166], [129, 174], [129, 177], [130, 142], [130, 143], [130, 146], [130, 147], [130, 149], [130, 155], [130, 158], [130, 159], [130, 161], [130, 163], [130, 169], [130, 175], [131, 132], [131, 137], [131, 146], [131, 148], [131, 153], [131, 155], [131, 156], [131, 159], [131, 160], [131, 168], [131, 170], [131, 171], [132, 141], [132, 142], [132, 148], [132, 151], [132, 169], [132, 171], [132, 172], [132, 173], [132, 176], [133, 134], [133, 139], [133, 146], [133, 148], [133, 149], [133, 150], [133, 162], [133, 175], [133, 177], [134, 145], [134, 146], [134, 149], [134, 152], [134, 157], [134, 159], [134, 161], [134, 168], [134, 169], [134, 173], [134, 176], [135, 138], [135, 143], [135, 146], [135, 157], [135, 166], [135, 176], [136, 138], [136, 139], [136, 152], [136, 161], [136, 164], [136, 168], [136, 169], [136, 170], [136, 173], [136, 175], [136, 177], [137, 148], [137, 158], [137, 165], [138, 141], [138, 143], [138, 153], [138, 158], [138, 174], [138, 178], [138, 179], [139, 144], [139, 152], [139, 155], [139, 158], [139, 160], [139, 164], [139, 168], [139, 170], [139, 171], [139, 173], [139, 175], [139, 178], [140, 142], [140, 144], [140, 148], [140, 157], [140, 166], [140, 167], [140, 173], [140, 177], [141, 143], [141, 147], [141, 154], [141, 156], [141, 161], [141, 168], [141, 172], [141, 174], [142, 143], [142, 148], [142, 151], [142, 152], [142, 155], [142, 158], [142, 159], [142, 161], [142, 170], [142, 171], [142, 174], [142, 175], [142, 177], [143, 145], [143, 147], [143, 148], [143, 150], [143, 155], [143, 159], [143, 161], [143, 168], [144, 151], [144, 152], [144, 159], [144, 162], [144, 169], [144, 173], [145, 147], [145, 169], [145, 171], [145, 172], [145, 179], [146, 148], [146, 150], [146, 151], [146, 153], [146, 157], [146, 161], [146, 172], [146, 174], [146, 175], [147, 148], [147, 154], [147, 162], [147, 165], [147, 171], [148, 154], [148, 155], [148, 160], [148, 161], [148, 167], [148, 171], [148, 172], [148, 176], [149, 152], [149, 161], [149, 163], [149, 168], [149, 169], [149, 177], [150, 154], [150, 156], [150, 160], [150, 161], [150, 164], [150, 175], [151, 153], [151, 160], [151, 161], [151, 167], [151, 173], [151, 174], [151, 176], [152, 156], [152, 158], [152, 162], [152, 163], [152, 166], [152, 168], [152, 169], [152, 170], [152, 177], [153, 156], [153, 164], [153, 166], [153, 167], [153, 168], [153, 172], [153, 177], [154, 159], [154, 173], [154, 175], [155, 160], [155, 161], [155, 171], [155, 174], [155, 175], [156, 157], [156, 158], [156, 166], [156, 171], [157, 158], [157, 161], [157, 163], [157, 168], [157, 169], [158, 159], [158, 162], [158, 166], [158, 167], [158, 169], [158, 174], [159, 165], [159, 170], [159, 171], [159, 175], [159, 176], [160, 165], [160, 168], [160, 173], [160, 178], [160, 179], [161, 163], [161, 165], [161, 167], [161, 168], [161, 177], [162, 163], [162, 172], [162, 173], [163, 166], [163, 171], [163, 178], [164, 178], [164, 179], [165, 167], [165, 168], [165, 170], [165, 174], [166, 169], [166, 170], [167, 178], [168, 171], [168, 175], [168, 177], [169, 176], [170, 171], [171, 175], [171, 177], [173, 176], [173, 177], [173, 178], [178, 179]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l5-s7/tests/run.py b/tasks/construct-nppc-dominating-set-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-dominating-set-l5-s7/tests/test.sh b/tasks/construct-nppc-dominating-set-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l5-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-independent-set-l1-s1/environment/Dockerfile b/tasks/construct-nppc-independent-set-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-independent-set-l1-s1/environment/instance.json b/tasks/construct-nppc-independent-set-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d2198fb5369f02af11e9c3987e35bfac0e0ef87e --- /dev/null +++ b/tasks/construct-nppc-independent-set-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "k": 4, "edges": [[0, 4], [0, 7], [1, 4], [1, 6], [1, 7], [2, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 6], [5, 7], [6, 7]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l1-s1/solution/solve.sh b/tasks/construct-nppc-independent-set-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c08bc7912eaa7c1d4102cf74c49a3bc09cce7e8a --- /dev/null +++ b/tasks/construct-nppc-independent-set-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' +{"independent_set": [0, 1, 3, 5]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l1-s1/tests/check.py b/tasks/construct-nppc-independent-set-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l1-s1/tests/check.py @@ -0,0 +1,19 @@ +"""Independent set of size >= k. Accepts any valid independent set.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + s = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + # upstream NPPC verifier checks len(list) >= size but only tests pairs u < v, so [v]*k passed + if len(set(s)) != len(s): + raise Invalid("independent_set contains duplicates") + if len(s) < k: + raise Invalid(f"independent_set has {len(s)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(s), 2): + if (u, v) in es: + raise Invalid(f"edge between {u} and {v}") + return None, {"size": len(s)} diff --git a/tasks/construct-nppc-independent-set-l1-s1/tests/instance.json b/tasks/construct-nppc-independent-set-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d2198fb5369f02af11e9c3987e35bfac0e0ef87e --- /dev/null +++ b/tasks/construct-nppc-independent-set-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "k": 4, "edges": [[0, 4], [0, 7], [1, 4], [1, 6], [1, 7], [2, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 6], [5, 7], [6, 7]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l1-s1/tests/run.py b/tasks/construct-nppc-independent-set-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-independent-set-l1-s1/tests/test.sh b/tasks/construct-nppc-independent-set-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-independent-set-l1-s8/environment/Dockerfile b/tasks/construct-nppc-independent-set-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l1-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-independent-set-l1-s8/environment/instance.json b/tasks/construct-nppc-independent-set-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..83ce0dca2151cc9166454cd21c54f7a76697eb5e --- /dev/null +++ b/tasks/construct-nppc-independent-set-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "k": 4, "edges": [[0, 2], [0, 3], [0, 6], [1, 2], [1, 3], [1, 6], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [4, 6], [5, 7]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l1-s8/solution/solve.sh b/tasks/construct-nppc-independent-set-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..184e89725379a8d862d0e8123424c4aa4cb84521 --- /dev/null +++ b/tasks/construct-nppc-independent-set-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' +{"independent_set": [0, 1, 4, 7]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l1-s8/tests/check.py b/tasks/construct-nppc-independent-set-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l1-s8/tests/check.py @@ -0,0 +1,19 @@ +"""Independent set of size >= k. Accepts any valid independent set.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + s = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + # upstream NPPC verifier checks len(list) >= size but only tests pairs u < v, so [v]*k passed + if len(set(s)) != len(s): + raise Invalid("independent_set contains duplicates") + if len(s) < k: + raise Invalid(f"independent_set has {len(s)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(s), 2): + if (u, v) in es: + raise Invalid(f"edge between {u} and {v}") + return None, {"size": len(s)} diff --git a/tasks/construct-nppc-independent-set-l1-s8/tests/instance.json b/tasks/construct-nppc-independent-set-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..83ce0dca2151cc9166454cd21c54f7a76697eb5e --- /dev/null +++ b/tasks/construct-nppc-independent-set-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 8, "k": 4, "edges": [[0, 2], [0, 3], [0, 6], [1, 2], [1, 3], [1, 6], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [4, 6], [5, 7]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l1-s8/tests/run.py b/tasks/construct-nppc-independent-set-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l1-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-independent-set-l1-s8/tests/test.sh b/tasks/construct-nppc-independent-set-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l1-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-independent-set-l5-s0/environment/Dockerfile b/tasks/construct-nppc-independent-set-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-independent-set-l5-s0/environment/instance.json b/tasks/construct-nppc-independent-set-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..43530ef64f3ef75e812ae3b132690833e7f8809a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 48, "k": 24, "edges": [[0, 3], [0, 10], [0, 12], [0, 15], [0, 17], [0, 28], [0, 36], [0, 42], [0, 43], [1, 2], [1, 4], [1, 8], [1, 9], [1, 10], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 22], [1, 28], [1, 34], [1, 38], [1, 42], [1, 43], [1, 47], [2, 4], [2, 5], [2, 7], [2, 9], [2, 10], [2, 11], [2, 13], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 23], [2, 24], [2, 25], [2, 28], [2, 30], [2, 34], [2, 36], [2, 37], [2, 39], [2, 40], [2, 42], [2, 45], [3, 5], [3, 6], [3, 7], [3, 8], [3, 11], [3, 13], [3, 14], [3, 15], [3, 16], [3, 18], [3, 20], [3, 21], [3, 25], [3, 29], [3, 30], [3, 33], [3, 37], [3, 39], [3, 40], [3, 44], [3, 45], [4, 5], [4, 6], [4, 9], [4, 11], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 23], [4, 25], [4, 28], [4, 29], [4, 30], [4, 33], [4, 34], [4, 35], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 43], [4, 45], [5, 10], [5, 15], [5, 16], [5, 17], [5, 19], [5, 22], [5, 23], [5, 34], [5, 36], [5, 43], [5, 47], [6, 8], [6, 15], [6, 16], [6, 18], [6, 19], [6, 22], [6, 28], [6, 34], [6, 38], [6, 42], [6, 43], [7, 8], [7, 9], [7, 17], [7, 19], [7, 23], [7, 27], [7, 28], [7, 34], [7, 38], [7, 43], [8, 13], [8, 15], [8, 16], [8, 17], [8, 19], [8, 20], [8, 24], [8, 25], [8, 28], [8, 29], [8, 31], [8, 33], [8, 34], [8, 35], [8, 39], [8, 40], [8, 42], [8, 43], [8, 45], [9, 10], [9, 11], [9, 15], [9, 17], [9, 21], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 37], [9, 39], [9, 40], [9, 42], [9, 43], [9, 44], [9, 46], [9, 47], [10, 12], [10, 13], [10, 14], [10, 18], [10, 19], [10, 25], [10, 26], [10, 27], [10, 33], [10, 35], [10, 36], [10, 37], [10, 38], [10, 39], [10, 41], [10, 46], [11, 12], [11, 17], [11, 32], [11, 36], [11, 38], [12, 13], [12, 15], [12, 17], [12, 19], [12, 20], [12, 23], [12, 25], [12, 29], [12, 30], [12, 33], [12, 36], [12, 37], [12, 41], [12, 43], [12, 44], [12, 45], [12, 46], [13, 15], [13, 18], [13, 19], [13, 27], [13, 32], [13, 36], [13, 40], [13, 42], [13, 47], [14, 15], [14, 17], [14, 18], [14, 19], [14, 22], [14, 23], [14, 28], [14, 34], [14, 38], [14, 40], [15, 17], [15, 18], [15, 19], [15, 21], [15, 22], [15, 23], [15, 29], [15, 32], [15, 35], [15, 36], [15, 37], [15, 40], [15, 44], [15, 45], [15, 47], [16, 18], [16, 20], [16, 21], [16, 25], [16, 30], [16, 31], [16, 35], [16, 37], [16, 40], [16, 41], [16, 42], [16, 43], [16, 44], [16, 45], [16, 46], [16, 47], [17, 18], [17, 19], [17, 21], [17, 23], [17, 26], [17, 30], [17, 32], [17, 34], [17, 39], [17, 42], [17, 44], [17, 45], [18, 19], [18, 22], [18, 23], [18, 29], [18, 30], [18, 31], [18, 32], [18, 33], [18, 36], [18, 40], [18, 41], [18, 44], [18, 45], [18, 47], [19, 20], [19, 21], [19, 22], [19, 23], [19, 26], [19, 28], [19, 30], [19, 32], [19, 33], [19, 34], [19, 37], [19, 42], [19, 43], [19, 44], [19, 45], [19, 46], [20, 22], [20, 27], [20, 32], [20, 47], [21, 27], [21, 34], [21, 42], [21, 43], [22, 24], [22, 25], [22, 26], [22, 35], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 43], [22, 44], [22, 46], [22, 47], [23, 27], [23, 29], [23, 30], [23, 31], [23, 32], [23, 35], [23, 36], [23, 37], [23, 39], [23, 41], [23, 42], [23, 43], [23, 44], [23, 47], [24, 32], [24, 34], [24, 36], [24, 38], [25, 27], [25, 32], [25, 36], [25, 42], [26, 27], [26, 42], [26, 43], [27, 29], [27, 30], [27, 31], [27, 33], [27, 35], [27, 39], [27, 43], [27, 44], [27, 46], [27, 47], [28, 29], [28, 30], [28, 32], [28, 34], [28, 36], [28, 37], [28, 38], [28, 40], [28, 41], [28, 42], [28, 44], [29, 32], [29, 40], [29, 43], [30, 36], [30, 42], [31, 36], [31, 38], [31, 43], [31, 47], [32, 33], [32, 34], [32, 37], [32, 38], [32, 39], [32, 41], [32, 43], [32, 45], [32, 47], [33, 36], [33, 38], [33, 40], [33, 42], [33, 43], [33, 47], [34, 39], [34, 40], [34, 42], [34, 46], [35, 38], [35, 40], [35, 42], [35, 47], [36, 38], [36, 40], [36, 42], [36, 43], [36, 44], [36, 46], [37, 42], [37, 47], [38, 40], [38, 42], [38, 43], [38, 44], [38, 45], [38, 46], [40, 41], [40, 45], [40, 46], [40, 47], [41, 43], [41, 47], [42, 45], [42, 46], [43, 44], [43, 45], [43, 46]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l5-s0/solution/solve.sh b/tasks/construct-nppc-independent-set-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f7ee1e2da3713713518784cb4d9a788f397c43a7 --- /dev/null +++ b/tasks/construct-nppc-independent-set-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' +{"independent_set": [0, 1, 5, 6, 7, 11, 13, 14, 20, 21, 24, 25, 26, 29, 30, 31, 33, 35, 37, 39, 41, 44, 45, 46]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l5-s0/tests/check.py b/tasks/construct-nppc-independent-set-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s0/tests/check.py @@ -0,0 +1,19 @@ +"""Independent set of size >= k. Accepts any valid independent set.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + s = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + # upstream NPPC verifier checks len(list) >= size but only tests pairs u < v, so [v]*k passed + if len(set(s)) != len(s): + raise Invalid("independent_set contains duplicates") + if len(s) < k: + raise Invalid(f"independent_set has {len(s)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(s), 2): + if (u, v) in es: + raise Invalid(f"edge between {u} and {v}") + return None, {"size": len(s)} diff --git a/tasks/construct-nppc-independent-set-l5-s0/tests/instance.json b/tasks/construct-nppc-independent-set-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..43530ef64f3ef75e812ae3b132690833e7f8809a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 48, "k": 24, "edges": [[0, 3], [0, 10], [0, 12], [0, 15], [0, 17], [0, 28], [0, 36], [0, 42], [0, 43], [1, 2], [1, 4], [1, 8], [1, 9], [1, 10], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 22], [1, 28], [1, 34], [1, 38], [1, 42], [1, 43], [1, 47], [2, 4], [2, 5], [2, 7], [2, 9], [2, 10], [2, 11], [2, 13], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 23], [2, 24], [2, 25], [2, 28], [2, 30], [2, 34], [2, 36], [2, 37], [2, 39], [2, 40], [2, 42], [2, 45], [3, 5], [3, 6], [3, 7], [3, 8], [3, 11], [3, 13], [3, 14], [3, 15], [3, 16], [3, 18], [3, 20], [3, 21], [3, 25], [3, 29], [3, 30], [3, 33], [3, 37], [3, 39], [3, 40], [3, 44], [3, 45], [4, 5], [4, 6], [4, 9], [4, 11], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 23], [4, 25], [4, 28], [4, 29], [4, 30], [4, 33], [4, 34], [4, 35], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 43], [4, 45], [5, 10], [5, 15], [5, 16], [5, 17], [5, 19], [5, 22], [5, 23], [5, 34], [5, 36], [5, 43], [5, 47], [6, 8], [6, 15], [6, 16], [6, 18], [6, 19], [6, 22], [6, 28], [6, 34], [6, 38], [6, 42], [6, 43], [7, 8], [7, 9], [7, 17], [7, 19], [7, 23], [7, 27], [7, 28], [7, 34], [7, 38], [7, 43], [8, 13], [8, 15], [8, 16], [8, 17], [8, 19], [8, 20], [8, 24], [8, 25], [8, 28], [8, 29], [8, 31], [8, 33], [8, 34], [8, 35], [8, 39], [8, 40], [8, 42], [8, 43], [8, 45], [9, 10], [9, 11], [9, 15], [9, 17], [9, 21], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 37], [9, 39], [9, 40], [9, 42], [9, 43], [9, 44], [9, 46], [9, 47], [10, 12], [10, 13], [10, 14], [10, 18], [10, 19], [10, 25], [10, 26], [10, 27], [10, 33], [10, 35], [10, 36], [10, 37], [10, 38], [10, 39], [10, 41], [10, 46], [11, 12], [11, 17], [11, 32], [11, 36], [11, 38], [12, 13], [12, 15], [12, 17], [12, 19], [12, 20], [12, 23], [12, 25], [12, 29], [12, 30], [12, 33], [12, 36], [12, 37], [12, 41], [12, 43], [12, 44], [12, 45], [12, 46], [13, 15], [13, 18], [13, 19], [13, 27], [13, 32], [13, 36], [13, 40], [13, 42], [13, 47], [14, 15], [14, 17], [14, 18], [14, 19], [14, 22], [14, 23], [14, 28], [14, 34], [14, 38], [14, 40], [15, 17], [15, 18], [15, 19], [15, 21], [15, 22], [15, 23], [15, 29], [15, 32], [15, 35], [15, 36], [15, 37], [15, 40], [15, 44], [15, 45], [15, 47], [16, 18], [16, 20], [16, 21], [16, 25], [16, 30], [16, 31], [16, 35], [16, 37], [16, 40], [16, 41], [16, 42], [16, 43], [16, 44], [16, 45], [16, 46], [16, 47], [17, 18], [17, 19], [17, 21], [17, 23], [17, 26], [17, 30], [17, 32], [17, 34], [17, 39], [17, 42], [17, 44], [17, 45], [18, 19], [18, 22], [18, 23], [18, 29], [18, 30], [18, 31], [18, 32], [18, 33], [18, 36], [18, 40], [18, 41], [18, 44], [18, 45], [18, 47], [19, 20], [19, 21], [19, 22], [19, 23], [19, 26], [19, 28], [19, 30], [19, 32], [19, 33], [19, 34], [19, 37], [19, 42], [19, 43], [19, 44], [19, 45], [19, 46], [20, 22], [20, 27], [20, 32], [20, 47], [21, 27], [21, 34], [21, 42], [21, 43], [22, 24], [22, 25], [22, 26], [22, 35], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 43], [22, 44], [22, 46], [22, 47], [23, 27], [23, 29], [23, 30], [23, 31], [23, 32], [23, 35], [23, 36], [23, 37], [23, 39], [23, 41], [23, 42], [23, 43], [23, 44], [23, 47], [24, 32], [24, 34], [24, 36], [24, 38], [25, 27], [25, 32], [25, 36], [25, 42], [26, 27], [26, 42], [26, 43], [27, 29], [27, 30], [27, 31], [27, 33], [27, 35], [27, 39], [27, 43], [27, 44], [27, 46], [27, 47], [28, 29], [28, 30], [28, 32], [28, 34], [28, 36], [28, 37], [28, 38], [28, 40], [28, 41], [28, 42], [28, 44], [29, 32], [29, 40], [29, 43], [30, 36], [30, 42], [31, 36], [31, 38], [31, 43], [31, 47], [32, 33], [32, 34], [32, 37], [32, 38], [32, 39], [32, 41], [32, 43], [32, 45], [32, 47], [33, 36], [33, 38], [33, 40], [33, 42], [33, 43], [33, 47], [34, 39], [34, 40], [34, 42], [34, 46], [35, 38], [35, 40], [35, 42], [35, 47], [36, 38], [36, 40], [36, 42], [36, 43], [36, 44], [36, 46], [37, 42], [37, 47], [38, 40], [38, 42], [38, 43], [38, 44], [38, 45], [38, 46], [40, 41], [40, 45], [40, 46], [40, 47], [41, 43], [41, 47], [42, 45], [42, 46], [43, 44], [43, 45], [43, 46]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l5-s0/tests/run.py b/tasks/construct-nppc-independent-set-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-independent-set-l5-s0/tests/test.sh b/tasks/construct-nppc-independent-set-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-independent-set-l5-s7/environment/Dockerfile b/tasks/construct-nppc-independent-set-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-independent-set-l5-s7/environment/instance.json b/tasks/construct-nppc-independent-set-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a7e393c9991469e8cd90112ec10f589bc62b5fca --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 48, "k": 24, "edges": [[0, 1], [0, 4], [0, 6], [0, 7], [0, 9], [0, 11], [0, 15], [0, 17], [0, 19], [0, 21], [0, 25], [0, 26], [0, 28], [0, 29], [0, 30], [0, 32], [0, 33], [0, 34], [0, 37], [0, 40], [1, 9], [1, 12], [1, 16], [1, 17], [1, 24], [1, 25], [1, 27], [1, 33], [1, 36], [1, 38], [1, 39], [1, 40], [1, 44], [1, 47], [2, 4], [2, 5], [2, 6], [2, 9], [2, 16], [2, 18], [2, 19], [2, 25], [2, 38], [2, 40], [2, 45], [3, 4], [3, 5], [3, 8], [3, 17], [3, 25], [3, 27], [3, 38], [3, 39], [3, 45], [4, 6], [4, 7], [4, 8], [4, 9], [4, 11], [4, 12], [4, 13], [4, 16], [4, 20], [4, 21], [4, 29], [4, 30], [4, 31], [4, 34], [4, 36], [4, 37], [4, 42], [4, 43], [4, 44], [4, 46], [5, 6], [5, 8], [5, 10], [5, 11], [5, 13], [5, 16], [5, 17], [5, 18], [5, 20], [5, 21], [5, 22], [5, 23], [5, 29], [5, 36], [5, 37], [5, 39], [5, 41], [5, 42], [5, 43], [5, 44], [5, 45], [5, 47], [6, 7], [6, 9], [6, 11], [6, 12], [6, 14], [6, 17], [6, 25], [6, 26], [6, 28], [6, 32], [6, 35], [6, 36], [6, 37], [6, 41], [6, 45], [6, 46], [7, 8], [7, 11], [7, 16], [7, 18], [7, 19], [7, 24], [7, 33], [7, 38], [7, 40], [7, 47], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 17], [8, 18], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 31], [8, 34], [8, 35], [8, 36], [8, 37], [8, 38], [8, 39], [8, 41], [8, 42], [8, 43], [8, 45], [8, 46], [9, 11], [9, 13], [9, 14], [9, 19], [9, 20], [9, 21], [9, 25], [9, 26], [9, 27], [9, 28], [9, 30], [9, 31], [9, 32], [9, 36], [9, 37], [9, 40], [9, 46], [10, 12], [10, 16], [10, 18], [10, 33], [10, 36], [10, 38], [10, 39], [10, 44], [10, 45], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 20], [11, 21], [11, 23], [11, 25], [11, 26], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 42], [11, 45], [11, 46], [12, 15], [12, 16], [12, 19], [12, 21], [12, 24], [12, 28], [12, 30], [12, 31], [12, 34], [12, 35], [12, 36], [12, 37], [12, 40], [12, 42], [12, 43], [12, 44], [12, 47], [13, 16], [13, 17], [13, 24], [13, 25], [13, 27], [13, 33], [13, 38], [13, 40], [13, 45], [13, 46], [14, 17], [14, 18], [14, 24], [14, 27], [14, 38], [14, 39], [15, 16], [15, 17], [15, 24], [15, 36], [15, 38], [15, 39], [15, 44], [15, 45], [15, 47], [16, 20], [16, 21], [16, 22], [16, 24], [16, 26], [16, 28], [16, 29], [16, 30], [16, 32], [16, 33], [16, 34], [16, 36], [16, 42], [16, 43], [16, 44], [16, 46], [17, 22], [17, 23], [17, 26], [17, 31], [17, 32], [17, 33], [17, 34], [17, 36], [17, 37], [17, 38], [17, 40], [17, 41], [17, 47], [18, 20], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 32], [18, 34], [18, 36], [18, 39], [18, 41], [18, 45], [18, 47], [19, 20], [19, 22], [19, 24], [19, 25], [19, 27], [19, 30], [19, 31], [19, 32], [19, 34], [19, 36], [19, 37], [19, 38], [19, 39], [19, 41], [19, 43], [19, 44], [19, 45], [19, 46], [19, 47], [20, 24], [20, 33], [20, 36], [20, 44], [20, 45], [20, 46], [20, 47], [21, 25], [21, 36], [21, 38], [21, 40], [21, 45], [21, 46], [21, 47], [22, 25], [22, 27], [22, 39], [22, 44], [22, 45], [23, 25], [23, 27], [23, 33], [23, 36], [23, 38], [23, 40], [23, 44], [23, 47], [24, 25], [24, 28], [24, 29], [24, 31], [24, 33], [24, 34], [24, 35], [24, 39], [24, 40], [24, 41], [24, 42], [24, 43], [24, 45], [25, 26], [25, 28], [25, 30], [25, 33], [25, 34], [25, 35], [25, 36], [25, 38], [25, 41], [25, 44], [25, 45], [26, 33], [26, 36], [26, 38], [26, 40], [26, 46], [26, 47], [27, 32], [27, 33], [27, 34], [27, 36], [27, 38], [27, 40], [27, 41], [27, 43], [28, 33], [28, 36], [28, 38], [29, 38], [29, 39], [29, 40], [29, 45], [29, 47], [30, 33], [30, 36], [30, 39], [30, 40], [31, 36], [31, 38], [31, 40], [31, 46], [32, 36], [32, 40], [32, 46], [33, 34], [33, 36], [33, 37], [33, 39], [33, 40], [33, 42], [33, 43], [33, 46], [33, 47], [34, 36], [34, 44], [34, 47], [35, 36], [35, 40], [35, 47], [36, 37], [36, 38], [36, 39], [36, 46], [37, 39], [38, 40], [38, 42], [38, 44], [38, 47], [39, 42], [39, 43], [39, 45], [39, 47], [40, 45], [40, 46], [41, 44], [41, 45], [41, 46], [41, 47], [42, 44], [43, 44], [43, 47], [44, 46], [44, 47], [45, 47]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l5-s7/solution/solve.sh b/tasks/construct-nppc-independent-set-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3aa3935730e9ba4f1df00c691acb1022b5ea2027 --- /dev/null +++ b/tasks/construct-nppc-independent-set-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' +{"independent_set": [1, 2, 3, 7, 10, 13, 14, 15, 20, 21, 22, 23, 26, 28, 29, 30, 31, 32, 34, 35, 37, 41, 42, 43]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l5-s7/tests/check.py b/tasks/construct-nppc-independent-set-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s7/tests/check.py @@ -0,0 +1,19 @@ +"""Independent set of size >= k. Accepts any valid independent set.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + s = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + # upstream NPPC verifier checks len(list) >= size but only tests pairs u < v, so [v]*k passed + if len(set(s)) != len(s): + raise Invalid("independent_set contains duplicates") + if len(s) < k: + raise Invalid(f"independent_set has {len(s)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(s), 2): + if (u, v) in es: + raise Invalid(f"edge between {u} and {v}") + return None, {"size": len(s)} diff --git a/tasks/construct-nppc-independent-set-l5-s7/tests/instance.json b/tasks/construct-nppc-independent-set-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a7e393c9991469e8cd90112ec10f589bc62b5fca --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 48, "k": 24, "edges": [[0, 1], [0, 4], [0, 6], [0, 7], [0, 9], [0, 11], [0, 15], [0, 17], [0, 19], [0, 21], [0, 25], [0, 26], [0, 28], [0, 29], [0, 30], [0, 32], [0, 33], [0, 34], [0, 37], [0, 40], [1, 9], [1, 12], [1, 16], [1, 17], [1, 24], [1, 25], [1, 27], [1, 33], [1, 36], [1, 38], [1, 39], [1, 40], [1, 44], [1, 47], [2, 4], [2, 5], [2, 6], [2, 9], [2, 16], [2, 18], [2, 19], [2, 25], [2, 38], [2, 40], [2, 45], [3, 4], [3, 5], [3, 8], [3, 17], [3, 25], [3, 27], [3, 38], [3, 39], [3, 45], [4, 6], [4, 7], [4, 8], [4, 9], [4, 11], [4, 12], [4, 13], [4, 16], [4, 20], [4, 21], [4, 29], [4, 30], [4, 31], [4, 34], [4, 36], [4, 37], [4, 42], [4, 43], [4, 44], [4, 46], [5, 6], [5, 8], [5, 10], [5, 11], [5, 13], [5, 16], [5, 17], [5, 18], [5, 20], [5, 21], [5, 22], [5, 23], [5, 29], [5, 36], [5, 37], [5, 39], [5, 41], [5, 42], [5, 43], [5, 44], [5, 45], [5, 47], [6, 7], [6, 9], [6, 11], [6, 12], [6, 14], [6, 17], [6, 25], [6, 26], [6, 28], [6, 32], [6, 35], [6, 36], [6, 37], [6, 41], [6, 45], [6, 46], [7, 8], [7, 11], [7, 16], [7, 18], [7, 19], [7, 24], [7, 33], [7, 38], [7, 40], [7, 47], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 17], [8, 18], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 31], [8, 34], [8, 35], [8, 36], [8, 37], [8, 38], [8, 39], [8, 41], [8, 42], [8, 43], [8, 45], [8, 46], [9, 11], [9, 13], [9, 14], [9, 19], [9, 20], [9, 21], [9, 25], [9, 26], [9, 27], [9, 28], [9, 30], [9, 31], [9, 32], [9, 36], [9, 37], [9, 40], [9, 46], [10, 12], [10, 16], [10, 18], [10, 33], [10, 36], [10, 38], [10, 39], [10, 44], [10, 45], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [11, 20], [11, 21], [11, 23], [11, 25], [11, 26], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 42], [11, 45], [11, 46], [12, 15], [12, 16], [12, 19], [12, 21], [12, 24], [12, 28], [12, 30], [12, 31], [12, 34], [12, 35], [12, 36], [12, 37], [12, 40], [12, 42], [12, 43], [12, 44], [12, 47], [13, 16], [13, 17], [13, 24], [13, 25], [13, 27], [13, 33], [13, 38], [13, 40], [13, 45], [13, 46], [14, 17], [14, 18], [14, 24], [14, 27], [14, 38], [14, 39], [15, 16], [15, 17], [15, 24], [15, 36], [15, 38], [15, 39], [15, 44], [15, 45], [15, 47], [16, 20], [16, 21], [16, 22], [16, 24], [16, 26], [16, 28], [16, 29], [16, 30], [16, 32], [16, 33], [16, 34], [16, 36], [16, 42], [16, 43], [16, 44], [16, 46], [17, 22], [17, 23], [17, 26], [17, 31], [17, 32], [17, 33], [17, 34], [17, 36], [17, 37], [17, 38], [17, 40], [17, 41], [17, 47], [18, 20], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 32], [18, 34], [18, 36], [18, 39], [18, 41], [18, 45], [18, 47], [19, 20], [19, 22], [19, 24], [19, 25], [19, 27], [19, 30], [19, 31], [19, 32], [19, 34], [19, 36], [19, 37], [19, 38], [19, 39], [19, 41], [19, 43], [19, 44], [19, 45], [19, 46], [19, 47], [20, 24], [20, 33], [20, 36], [20, 44], [20, 45], [20, 46], [20, 47], [21, 25], [21, 36], [21, 38], [21, 40], [21, 45], [21, 46], [21, 47], [22, 25], [22, 27], [22, 39], [22, 44], [22, 45], [23, 25], [23, 27], [23, 33], [23, 36], [23, 38], [23, 40], [23, 44], [23, 47], [24, 25], [24, 28], [24, 29], [24, 31], [24, 33], [24, 34], [24, 35], [24, 39], [24, 40], [24, 41], [24, 42], [24, 43], [24, 45], [25, 26], [25, 28], [25, 30], [25, 33], [25, 34], [25, 35], [25, 36], [25, 38], [25, 41], [25, 44], [25, 45], [26, 33], [26, 36], [26, 38], [26, 40], [26, 46], [26, 47], [27, 32], [27, 33], [27, 34], [27, 36], [27, 38], [27, 40], [27, 41], [27, 43], [28, 33], [28, 36], [28, 38], [29, 38], [29, 39], [29, 40], [29, 45], [29, 47], [30, 33], [30, 36], [30, 39], [30, 40], [31, 36], [31, 38], [31, 40], [31, 46], [32, 36], [32, 40], [32, 46], [33, 34], [33, 36], [33, 37], [33, 39], [33, 40], [33, 42], [33, 43], [33, 46], [33, 47], [34, 36], [34, 44], [34, 47], [35, 36], [35, 40], [35, 47], [36, 37], [36, 38], [36, 39], [36, 46], [37, 39], [38, 40], [38, 42], [38, 44], [38, 47], [39, 42], [39, 43], [39, 45], [39, 47], [40, 45], [40, 46], [41, 44], [41, 45], [41, 46], [41, 47], [42, 44], [43, 44], [43, 47], [44, 46], [44, 47], [45, 47]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l5-s7/tests/run.py b/tasks/construct-nppc-independent-set-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-independent-set-l5-s7/tests/test.sh b/tasks/construct-nppc-independent-set-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-independent-set-l5-s9/environment/Dockerfile b/tasks/construct-nppc-independent-set-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-independent-set-l5-s9/environment/instance.json b/tasks/construct-nppc-independent-set-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6f2e7b8ae18aa0c734a56184709707f02cf246c8 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 48, "k": 24, "edges": [[0, 1], [0, 2], [0, 7], [0, 8], [0, 11], [0, 14], [0, 15], [0, 16], [0, 19], [0, 21], [0, 23], [0, 27], [0, 30], [0, 31], [0, 33], [0, 36], [0, 43], [0, 46], [1, 4], [1, 6], [1, 7], [1, 9], [1, 11], [1, 12], [1, 13], [1, 15], [1, 16], [1, 18], [1, 19], [1, 21], [1, 23], [1, 24], [1, 27], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 45], [1, 47], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 13], [2, 14], [2, 16], [2, 17], [2, 22], [2, 24], [2, 26], [2, 27], [2, 29], [2, 30], [2, 32], [2, 35], [2, 36], [2, 39], [2, 41], [2, 43], [2, 46], [3, 5], [3, 7], [3, 14], [3, 15], [3, 16], [3, 23], [3, 27], [3, 30], [3, 33], [3, 36], [3, 40], [4, 5], [4, 7], [4, 8], [4, 11], [4, 14], [4, 15], [4, 20], [4, 21], [4, 35], [4, 40], [4, 46], [5, 6], [5, 7], [5, 10], [5, 11], [5, 12], [5, 14], [5, 15], [5, 19], [5, 20], [5, 22], [5, 26], [5, 27], [5, 28], [5, 33], [5, 35], [5, 38], [5, 43], [5, 44], [5, 46], [5, 47], [6, 7], [6, 8], [6, 9], [6, 12], [6, 14], [6, 15], [6, 21], [6, 23], [6, 26], [6, 27], [6, 28], [6, 32], [6, 35], [6, 37], [6, 38], [6, 39], [6, 41], [6, 42], [6, 43], [6, 45], [6, 47], [7, 8], [7, 11], [7, 12], [7, 13], [7, 17], [7, 19], [7, 21], [7, 22], [7, 25], [7, 26], [7, 27], [7, 30], [7, 32], [7, 33], [7, 34], [7, 35], [7, 36], [7, 38], [7, 39], [7, 46], [7, 47], [8, 9], [8, 10], [8, 11], [8, 12], [8, 14], [8, 18], [8, 20], [8, 21], [8, 22], [8, 23], [8, 28], [8, 39], [8, 40], [8, 43], [9, 15], [9, 23], [9, 27], [9, 31], [9, 36], [9, 40], [9, 46], [9, 47], [10, 11], [10, 14], [10, 21], [10, 30], [10, 33], [10, 35], [10, 36], [10, 40], [10, 43], [11, 12], [11, 13], [11, 15], [11, 19], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 25], [11, 29], [11, 30], [11, 33], [11, 34], [11, 35], [11, 36], [11, 42], [11, 44], [11, 45], [11, 47], [12, 15], [12, 19], [12, 21], [12, 23], [12, 30], [12, 31], [12, 33], [12, 36], [12, 40], [13, 14], [13, 16], [13, 19], [13, 20], [13, 21], [13, 27], [13, 30], [13, 31], [13, 36], [13, 46], [13, 47], [14, 15], [14, 17], [14, 18], [14, 19], [14, 23], [14, 25], [14, 27], [14, 28], [14, 32], [14, 36], [14, 37], [14, 38], [14, 41], [14, 42], [14, 43], [14, 45], [15, 17], [15, 26], [15, 27], [15, 28], [15, 29], [15, 34], [15, 36], [15, 40], [15, 41], [15, 43], [15, 46], [16, 17], [16, 19], [16, 20], [16, 22], [16, 23], [16, 24], [16, 26], [16, 30], [16, 32], [16, 33], [16, 35], [16, 38], [16, 40], [16, 41], [16, 43], [16, 44], [16, 45], [17, 19], [17, 20], [17, 30], [17, 31], [17, 35], [17, 43], [18, 23], [18, 31], [18, 33], [18, 36], [18, 43], [19, 25], [19, 27], [19, 29], [19, 30], [19, 31], [19, 32], [19, 35], [19, 36], [19, 37], [19, 38], [19, 41], [19, 42], [20, 21], [20, 22], [20, 26], [20, 28], [20, 31], [20, 36], [20, 37], [20, 38], [20, 39], [20, 43], [20, 44], [20, 45], [20, 46], [21, 29], [21, 31], [21, 33], [21, 34], [21, 38], [21, 44], [21, 45], [22, 23], [22, 27], [22, 30], [22, 31], [22, 33], [22, 40], [22, 43], [22, 47], [23, 25], [23, 28], [23, 31], [23, 33], [23, 34], [23, 35], [23, 37], [23, 40], [23, 42], [23, 44], [23, 47], [24, 27], [24, 30], [24, 31], [24, 33], [24, 40], [24, 43], [24, 46], [24, 47], [25, 31], [25, 33], [25, 35], [25, 40], [25, 43], [25, 47], [26, 30], [26, 33], [26, 36], [26, 40], [26, 43], [26, 46], [26, 47], [27, 28], [27, 29], [27, 30], [27, 31], [27, 34], [27, 36], [27, 38], [27, 40], [27, 44], [27, 46], [27, 47], [28, 33], [28, 36], [28, 43], [28, 46], [29, 30], [29, 31], [29, 33], [29, 35], [29, 36], [30, 31], [30, 34], [30, 36], [30, 38], [30, 39], [30, 40], [30, 42], [30, 46], [30, 47], [31, 32], [31, 33], [31, 35], [31, 37], [31, 38], [31, 39], [31, 40], [31, 42], [31, 43], [31, 44], [31, 45], [31, 47], [32, 40], [32, 46], [32, 47], [33, 35], [33, 37], [33, 38], [33, 39], [33, 41], [33, 42], [33, 43], [33, 44], [33, 45], [34, 36], [34, 46], [35, 39], [35, 40], [35, 44], [35, 47], [36, 37], [36, 38], [36, 39], [36, 41], [36, 42], [36, 43], [36, 45], [36, 47], [37, 43], [38, 43], [40, 42], [40, 44], [40, 45], [40, 46], [40, 47], [41, 46], [41, 47], [42, 43], [42, 46], [43, 44], [43, 46], [43, 47], [45, 46], [45, 47], [46, 47]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l5-s9/solution/solve.sh b/tasks/construct-nppc-independent-set-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fd132e887e2470c6ba3a2538615e2a1f73962c3a --- /dev/null +++ b/tasks/construct-nppc-independent-set-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' +{"independent_set": [0, 3, 4, 9, 10, 12, 13, 17, 18, 22, 24, 25, 26, 28, 29, 32, 34, 37, 38, 39, 41, 42, 44, 45]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l5-s9/tests/check.py b/tasks/construct-nppc-independent-set-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s9/tests/check.py @@ -0,0 +1,19 @@ +"""Independent set of size >= k. Accepts any valid independent set.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + s = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + # upstream NPPC verifier checks len(list) >= size but only tests pairs u < v, so [v]*k passed + if len(set(s)) != len(s): + raise Invalid("independent_set contains duplicates") + if len(s) < k: + raise Invalid(f"independent_set has {len(s)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(s), 2): + if (u, v) in es: + raise Invalid(f"edge between {u} and {v}") + return None, {"size": len(s)} diff --git a/tasks/construct-nppc-independent-set-l5-s9/tests/instance.json b/tasks/construct-nppc-independent-set-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6f2e7b8ae18aa0c734a56184709707f02cf246c8 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 48, "k": 24, "edges": [[0, 1], [0, 2], [0, 7], [0, 8], [0, 11], [0, 14], [0, 15], [0, 16], [0, 19], [0, 21], [0, 23], [0, 27], [0, 30], [0, 31], [0, 33], [0, 36], [0, 43], [0, 46], [1, 4], [1, 6], [1, 7], [1, 9], [1, 11], [1, 12], [1, 13], [1, 15], [1, 16], [1, 18], [1, 19], [1, 21], [1, 23], [1, 24], [1, 27], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 45], [1, 47], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 13], [2, 14], [2, 16], [2, 17], [2, 22], [2, 24], [2, 26], [2, 27], [2, 29], [2, 30], [2, 32], [2, 35], [2, 36], [2, 39], [2, 41], [2, 43], [2, 46], [3, 5], [3, 7], [3, 14], [3, 15], [3, 16], [3, 23], [3, 27], [3, 30], [3, 33], [3, 36], [3, 40], [4, 5], [4, 7], [4, 8], [4, 11], [4, 14], [4, 15], [4, 20], [4, 21], [4, 35], [4, 40], [4, 46], [5, 6], [5, 7], [5, 10], [5, 11], [5, 12], [5, 14], [5, 15], [5, 19], [5, 20], [5, 22], [5, 26], [5, 27], [5, 28], [5, 33], [5, 35], [5, 38], [5, 43], [5, 44], [5, 46], [5, 47], [6, 7], [6, 8], [6, 9], [6, 12], [6, 14], [6, 15], [6, 21], [6, 23], [6, 26], [6, 27], [6, 28], [6, 32], [6, 35], [6, 37], [6, 38], [6, 39], [6, 41], [6, 42], [6, 43], [6, 45], [6, 47], [7, 8], [7, 11], [7, 12], [7, 13], [7, 17], [7, 19], [7, 21], [7, 22], [7, 25], [7, 26], [7, 27], [7, 30], [7, 32], [7, 33], [7, 34], [7, 35], [7, 36], [7, 38], [7, 39], [7, 46], [7, 47], [8, 9], [8, 10], [8, 11], [8, 12], [8, 14], [8, 18], [8, 20], [8, 21], [8, 22], [8, 23], [8, 28], [8, 39], [8, 40], [8, 43], [9, 15], [9, 23], [9, 27], [9, 31], [9, 36], [9, 40], [9, 46], [9, 47], [10, 11], [10, 14], [10, 21], [10, 30], [10, 33], [10, 35], [10, 36], [10, 40], [10, 43], [11, 12], [11, 13], [11, 15], [11, 19], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 25], [11, 29], [11, 30], [11, 33], [11, 34], [11, 35], [11, 36], [11, 42], [11, 44], [11, 45], [11, 47], [12, 15], [12, 19], [12, 21], [12, 23], [12, 30], [12, 31], [12, 33], [12, 36], [12, 40], [13, 14], [13, 16], [13, 19], [13, 20], [13, 21], [13, 27], [13, 30], [13, 31], [13, 36], [13, 46], [13, 47], [14, 15], [14, 17], [14, 18], [14, 19], [14, 23], [14, 25], [14, 27], [14, 28], [14, 32], [14, 36], [14, 37], [14, 38], [14, 41], [14, 42], [14, 43], [14, 45], [15, 17], [15, 26], [15, 27], [15, 28], [15, 29], [15, 34], [15, 36], [15, 40], [15, 41], [15, 43], [15, 46], [16, 17], [16, 19], [16, 20], [16, 22], [16, 23], [16, 24], [16, 26], [16, 30], [16, 32], [16, 33], [16, 35], [16, 38], [16, 40], [16, 41], [16, 43], [16, 44], [16, 45], [17, 19], [17, 20], [17, 30], [17, 31], [17, 35], [17, 43], [18, 23], [18, 31], [18, 33], [18, 36], [18, 43], [19, 25], [19, 27], [19, 29], [19, 30], [19, 31], [19, 32], [19, 35], [19, 36], [19, 37], [19, 38], [19, 41], [19, 42], [20, 21], [20, 22], [20, 26], [20, 28], [20, 31], [20, 36], [20, 37], [20, 38], [20, 39], [20, 43], [20, 44], [20, 45], [20, 46], [21, 29], [21, 31], [21, 33], [21, 34], [21, 38], [21, 44], [21, 45], [22, 23], [22, 27], [22, 30], [22, 31], [22, 33], [22, 40], [22, 43], [22, 47], [23, 25], [23, 28], [23, 31], [23, 33], [23, 34], [23, 35], [23, 37], [23, 40], [23, 42], [23, 44], [23, 47], [24, 27], [24, 30], [24, 31], [24, 33], [24, 40], [24, 43], [24, 46], [24, 47], [25, 31], [25, 33], [25, 35], [25, 40], [25, 43], [25, 47], [26, 30], [26, 33], [26, 36], [26, 40], [26, 43], [26, 46], [26, 47], [27, 28], [27, 29], [27, 30], [27, 31], [27, 34], [27, 36], [27, 38], [27, 40], [27, 44], [27, 46], [27, 47], [28, 33], [28, 36], [28, 43], [28, 46], [29, 30], [29, 31], [29, 33], [29, 35], [29, 36], [30, 31], [30, 34], [30, 36], [30, 38], [30, 39], [30, 40], [30, 42], [30, 46], [30, 47], [31, 32], [31, 33], [31, 35], [31, 37], [31, 38], [31, 39], [31, 40], [31, 42], [31, 43], [31, 44], [31, 45], [31, 47], [32, 40], [32, 46], [32, 47], [33, 35], [33, 37], [33, 38], [33, 39], [33, 41], [33, 42], [33, 43], [33, 44], [33, 45], [34, 36], [34, 46], [35, 39], [35, 40], [35, 44], [35, 47], [36, 37], [36, 38], [36, 39], [36, 41], [36, 42], [36, 43], [36, 45], [36, 47], [37, 43], [38, 43], [40, 42], [40, 44], [40, 45], [40, 46], [40, 47], [41, 46], [41, 47], [42, 43], [42, 46], [43, 44], [43, 46], [43, 47], [45, 46], [45, 47], [46, 47]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l5-s9/tests/run.py b/tasks/construct-nppc-independent-set-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-independent-set-l5-s9/tests/test.sh b/tasks/construct-nppc-independent-set-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l5-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quad-diophantine-l4-s1/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quad-diophantine-l4-s1/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3fb416b84bbe311cadc1d6ec8bdd9bbf0ca6478c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"a": 76740, "b": 92097, "c": 1667145434612901, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l4-s1/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..96f02f668acec65ea6b575ee5dbb0b37efd82969 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 147392, "y": 161253} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l4-s1/tests/check.py b/tasks/construct-nppc-quad-diophantine-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s1/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l4-s1/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3fb416b84bbe311cadc1d6ec8bdd9bbf0ca6478c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"a": 76740, "b": 92097, "c": 1667145434612901, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l4-s1/tests/run.py b/tasks/construct-nppc-quad-diophantine-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quad-diophantine-l4-s1/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quad-diophantine-l4-s6/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quad-diophantine-l4-s6/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a0e2d5ddf40bad55c3b2dbe67c6d10b7dd8bfec8 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"a": 99724, "b": 66616, "c": 58211444847164, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l4-s6/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f71f91b4fb3491be616d5d0a56e4298f7e39e451 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 24159, "y": 102170} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l4-s6/tests/check.py b/tasks/construct-nppc-quad-diophantine-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s6/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l4-s6/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a0e2d5ddf40bad55c3b2dbe67c6d10b7dd8bfec8 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"a": 99724, "b": 66616, "c": 58211444847164, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l4-s6/tests/run.py b/tasks/construct-nppc-quad-diophantine-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quad-diophantine-l4-s6/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quad-diophantine-l4-s8/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quad-diophantine-l4-s8/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e5118a780155d54df3815a4aa18b34477b91641c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"a": 157334, "b": 37155, "c": 2190872876984834, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l4-s8/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7dc32f0c1c429df5bf6a6842566d911b2a212d0d --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 118004, "y": 154358} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l4-s8/tests/check.py b/tasks/construct-nppc-quad-diophantine-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-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-l4-s8/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e5118a780155d54df3815a4aa18b34477b91641c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"a": 157334, "b": 37155, "c": 2190872876984834, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l4-s8/tests/run.py b/tasks/construct-nppc-quad-diophantine-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quad-diophantine-l4-s8/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l4-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quadratic-congruence-l4-s1/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l4-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quadratic-congruence-l4-s1/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bdfbf42db2e75118c7ea2acd771625c36bba58de --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"a": 981576, "b": 2211006, "c": 3939792, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l4-s1/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f534c877c9ae2f8503ce659a8e8af69900010768 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 1909356} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l4-s1/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l4-s1/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l4-s1/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bdfbf42db2e75118c7ea2acd771625c36bba58de --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"a": 981576, "b": 2211006, "c": 3939792, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l4-s1/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quadratic-congruence-l4-s1/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l4-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quadratic-congruence-l4-s6/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l4-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-quadratic-congruence-l4-s6/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6a0f352f6ddab9c711e1b60d66c76e1fa772f647 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"a": 261980, "b": 1591873, "c": 3076071, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l4-s6/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..eea6ec7f0f1ebaa119498385a4e1df47a587c9cb --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l4-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": 1197632} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l4-s6/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l4-s6/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l4-s6/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6a0f352f6ddab9c711e1b60d66c76e1fa772f647 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"a": 261980, "b": 1591873, "c": 3076071, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l4-s6/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l4-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-quadratic-congruence-l4-s6/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l4-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-vertex-cover-l2-s2/environment/Dockerfile b/tasks/construct-nppc-vertex-cover-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l2-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-vertex-cover-l2-s2/environment/instance.json b/tasks/construct-nppc-vertex-cover-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..24acc9685b8cfa6112f19e1f0e2bb511e7cadb52 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 16, "k": 5, "edges": [[0, 7], [0, 12], [1, 2], [1, 12], [1, 13], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 9], [2, 10], [2, 11], [2, 14], [2, 15], [3, 7], [3, 13], [5, 7], [5, 14], [6, 13], [6, 14], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [8, 12], [8, 13], [8, 14], [9, 12], [9, 13], [9, 14], [10, 12], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 15], [14, 15]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l2-s2/solution/solve.sh b/tasks/construct-nppc-vertex-cover-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9b83ffede1c81e0a60314db4e0b68de4d45fb1e9 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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' +{"cover": [2, 7, 12, 13, 14]} +RLMATH_EOF diff --git a/tasks/construct-nppc-vertex-cover-l2-s2/tests/check.py b/tasks/construct-nppc-vertex-cover-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d8ed740cc660c4837d941a8d70ea394c3bc9f69e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l2-s2/tests/check.py @@ -0,0 +1,18 @@ +"""Vertex cover of size <= k. Accepts any valid cover.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier converts to a set without type checks (floats/bools slip through and + # duplicates are silently merged); here entries must be distinct ints in range + c = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(c)) != len(c): + raise Invalid("cover contains duplicates") + if len(c) > k: + raise Invalid(f"cover has {len(c)} > {k} vertices") + s = set(c) + for u, v in inst["edges"]: + if u not in s and v not in s: + raise Invalid(f"edge ({u},{v}) not covered") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-vertex-cover-l2-s2/tests/instance.json b/tasks/construct-nppc-vertex-cover-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..24acc9685b8cfa6112f19e1f0e2bb511e7cadb52 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 16, "k": 5, "edges": [[0, 7], [0, 12], [1, 2], [1, 12], [1, 13], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 9], [2, 10], [2, 11], [2, 14], [2, 15], [3, 7], [3, 13], [5, 7], [5, 14], [6, 13], [6, 14], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [8, 12], [8, 13], [8, 14], [9, 12], [9, 13], [9, 14], [10, 12], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 15], [14, 15]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l2-s2/tests/run.py b/tasks/construct-nppc-vertex-cover-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l2-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-vertex-cover-l2-s2/tests/test.sh b/tasks/construct-nppc-vertex-cover-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l2-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-vertex-cover-l2-s5/environment/Dockerfile b/tasks/construct-nppc-vertex-cover-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l2-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-vertex-cover-l2-s5/environment/instance.json b/tasks/construct-nppc-vertex-cover-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c856d06e83f93d0c186fabc907a122434609e1b8 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 16, "k": 5, "edges": [[0, 2], [0, 7], [0, 12], [1, 2], [1, 7], [1, 12], [2, 4], [2, 5], [2, 7], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [3, 5], [3, 7], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [4, 10], [4, 12], [5, 10], [5, 12], [6, 7], [6, 10], [6, 12], [7, 8], [7, 9], [7, 11], [7, 12], [7, 13], [7, 14], [9, 10], [9, 12], [10, 12], [10, 13], [10, 15], [12, 13], [12, 15]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l2-s5/solution/solve.sh b/tasks/construct-nppc-vertex-cover-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a86193add677368e9414a95bdf2e26bff831bb0a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l2-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"cover": [2, 3, 7, 10, 12]} +RLMATH_EOF diff --git a/tasks/construct-nppc-vertex-cover-l2-s5/tests/check.py b/tasks/construct-nppc-vertex-cover-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d8ed740cc660c4837d941a8d70ea394c3bc9f69e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l2-s5/tests/check.py @@ -0,0 +1,18 @@ +"""Vertex cover of size <= k. Accepts any valid cover.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier converts to a set without type checks (floats/bools slip through and + # duplicates are silently merged); here entries must be distinct ints in range + c = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(c)) != len(c): + raise Invalid("cover contains duplicates") + if len(c) > k: + raise Invalid(f"cover has {len(c)} > {k} vertices") + s = set(c) + for u, v in inst["edges"]: + if u not in s and v not in s: + raise Invalid(f"edge ({u},{v}) not covered") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-vertex-cover-l2-s5/tests/instance.json b/tasks/construct-nppc-vertex-cover-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c856d06e83f93d0c186fabc907a122434609e1b8 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 16, "k": 5, "edges": [[0, 2], [0, 7], [0, 12], [1, 2], [1, 7], [1, 12], [2, 4], [2, 5], [2, 7], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [3, 5], [3, 7], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [4, 10], [4, 12], [5, 10], [5, 12], [6, 7], [6, 10], [6, 12], [7, 8], [7, 9], [7, 11], [7, 12], [7, 13], [7, 14], [9, 10], [9, 12], [10, 12], [10, 13], [10, 15], [12, 13], [12, 15]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l2-s5/tests/run.py b/tasks/construct-nppc-vertex-cover-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l2-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-vertex-cover-l2-s5/tests/test.sh b/tasks/construct-nppc-vertex-cover-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l2-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-vertex-cover-l6-s4/environment/Dockerfile b/tasks/construct-nppc-vertex-cover-l6-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l6-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-vertex-cover-l6-s4/environment/instance.json b/tasks/construct-nppc-vertex-cover-l6-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0864ab45a7def62a853d41e6f1d52f8c8aa820d3 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l6-s4/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 160, "k": 64, "edges": [[0, 38], [0, 51], [0, 81], [0, 121], [0, 133], [0, 139], [1, 6], [1, 11], [1, 14], [1, 15], [1, 18], [1, 19], [1, 23], [1, 29], [1, 30], [1, 33], [1, 39], [1, 40], [1, 47], [1, 57], [1, 60], [1, 62], [1, 68], [1, 69], [1, 72], [1, 79], [1, 87], [1, 97], [1, 108], [1, 110], [1, 121], [1, 123], [1, 128], [1, 131], [1, 133], [1, 139], [1, 141], [1, 145], [1, 150], [1, 153], [2, 14], [2, 29], [2, 62], [2, 98], [2, 126], [2, 155], [2, 157], [3, 5], [3, 11], [3, 15], [3, 24], [3, 25], [3, 26], [3, 30], [3, 34], [3, 36], [3, 38], [3, 49], [3, 52], [3, 53], [3, 55], [3, 57], [3, 71], [3, 82], [3, 83], [3, 86], [3, 88], [3, 90], [3, 91], [3, 93], [3, 116], [3, 120], [3, 121], [3, 125], [3, 126], [3, 131], [3, 133], [3, 139], [3, 142], [3, 149], [4, 8], [4, 9], [4, 18], [4, 21], [4, 24], [4, 44], [4, 47], [4, 82], [4, 93], [4, 129], [4, 150], [5, 30], [5, 38], [5, 43], [5, 62], [5, 89], [5, 137], [5, 144], [6, 14], [6, 28], [6, 30], [6, 34], [6, 39], [6, 44], [6, 46], [6, 58], [6, 77], [6, 78], [6, 80], [6, 81], [6, 82], [6, 84], [6, 90], [6, 93], [6, 94], [6, 96], [6, 109], [6, 115], [6, 118], [6, 131], [6, 132], [6, 133], [6, 137], [6, 142], [6, 159], [7, 8], [7, 30], [7, 47], [7, 100], [7, 119], [7, 137], [7, 148], [7, 157], [8, 10], [8, 12], [8, 13], [8, 18], [8, 19], [8, 23], [8, 24], [8, 32], [8, 38], [8, 39], [8, 44], [8, 53], [8, 57], [8, 62], [8, 73], [8, 74], [8, 76], [8, 92], [8, 100], [8, 103], [8, 104], [8, 110], [8, 113], [8, 115], [8, 123], [8, 124], [8, 137], [8, 139], [8, 146], [8, 148], [8, 155], [9, 11], [9, 12], [9, 14], [9, 15], [9, 20], [9, 23], [9, 24], [9, 25], [9, 28], [9, 29], [9, 34], [9, 44], [9, 55], [9, 56], [9, 59], [9, 62], [9, 66], [9, 82], [9, 83], [9, 85], [9, 90], [9, 95], [9, 99], [9, 104], [9, 105], [9, 110], [9, 115], [9, 118], [9, 120], [9, 121], [9, 123], [9, 124], [9, 125], [9, 126], [9, 129], [9, 133], [9, 135], [9, 140], [9, 144], [9, 147], [9, 149], [9, 150], [10, 38], [10, 40], [10, 47], [10, 53], [10, 58], [10, 81], [10, 93], [10, 100], [10, 113], [10, 119], [10, 120], [10, 126], [10, 139], [10, 148], [10, 157], [11, 18], [11, 56], [11, 119], [11, 123], [11, 133], [11, 142], [11, 150], [12, 26], [12, 55], [12, 57], [12, 58], [12, 62], [12, 80], [12, 95], [12, 109], [12, 119], [12, 120], [12, 123], [12, 148], [12, 150], [12, 157], [13, 55], [13, 62], [13, 121], [13, 123], [13, 139], [13, 157], [14, 15], [14, 29], [14, 30], [14, 31], [14, 34], [14, 36], [14, 37], [14, 46], [14, 52], [14, 53], [14, 54], [14, 57], [14, 64], [14, 66], [14, 74], [14, 76], [14, 82], [14, 86], [14, 88], [14, 89], [14, 93], [14, 95], [14, 98], [14, 99], [14, 102], [14, 108], [14, 109], [14, 114], [14, 119], [14, 120], [14, 146], [14, 147], [14, 150], [14, 155], [15, 19], [15, 21], [15, 28], [15, 29], [15, 30], [15, 32], [15, 34], [15, 39], [15, 40], [15, 46], [15, 47], [15, 48], [15, 49], [15, 51], [15, 52], [15, 53], [15, 58], [15, 59], [15, 65], [15, 66], [15, 72], [15, 73], [15, 87], [15, 88], [15, 97], [15, 101], [15, 103], [15, 105], [15, 110], [15, 113], [15, 120], [15, 122], [15, 128], [15, 133], [15, 137], [15, 139], [15, 144], [15, 148], [15, 151], [15, 156], [15, 157], [15, 158], [16, 21], [16, 47], [16, 51], [16, 57], [16, 113], [16, 126], [16, 150], [16, 157], [17, 24], [17, 43], [17, 51], [17, 120], [17, 121], [18, 20], [18, 22], [18, 33], [18, 35], [18, 39], [18, 44], [18, 45], [18, 49], [18, 56], [18, 59], [18, 61], [18, 62], [18, 64], [18, 67], [18, 75], [18, 78], [18, 81], [18, 83], [18, 85], [18, 89], [18, 94], [18, 98], [18, 100], [18, 108], [18, 110], [18, 133], [18, 135], [18, 137], [18, 139], [18, 143], [18, 145], [18, 155], [18, 157], [19, 38], [19, 49], [19, 51], [19, 53], [19, 54], [19, 57], [19, 60], [19, 61], [19, 67], [19, 69], [19, 74], [19, 79], [19, 81], [19, 82], [19, 89], [19, 100], [19, 104], [19, 105], [19, 108], [19, 112], [19, 115], [19, 119], [19, 124], [19, 125], [19, 126], [19, 130], [19, 133], [19, 137], [19, 139], [19, 140], [19, 146], [19, 153], [19, 154], [19, 159], [20, 28], [20, 44], [20, 46], [20, 48], [20, 51], [20, 53], [20, 57], [20, 58], [20, 59], [20, 63], [20, 85], [20, 89], [20, 93], [20, 95], [20, 99], [20, 107], [20, 111], [20, 113], [20, 115], [20, 116], [20, 124], [20, 133], [20, 136], [20, 142], [20, 151], [20, 155], [21, 23], [21, 28], [21, 31], [21, 32], [21, 51], [21, 55], [21, 56], [21, 64], [21, 66], [21, 72], [21, 75], [21, 78], [21, 86], [21, 87], [21, 88], [21, 93], [21, 104], [21, 109], [21, 114], [21, 115], [21, 119], [21, 137], [21, 139], [21, 145], [21, 148], [21, 149], [21, 155], [21, 158], [22, 33], [22, 53], [22, 64], [22, 98], [22, 123], [22, 139], [22, 142], [22, 144], [23, 24], [23, 29], [23, 34], [23, 40], [23, 44], [23, 53], [23, 55], [23, 60], [23, 62], [23, 68], [23, 70], [23, 82], [23, 95], [23, 109], [23, 115], [23, 120], [23, 123], [23, 126], [23, 140], [23, 143], [23, 146], [23, 148], [23, 149], [23, 151], [24, 27], [24, 30], [24, 38], [24, 43], [24, 46], [24, 51], [24, 54], [24, 66], [24, 68], [24, 76], [24, 77], [24, 80], [24, 81], [24, 100], [24, 102], [24, 105], [24, 108], [24, 109], [24, 110], [24, 111], [24, 114], [24, 118], [24, 119], [24, 122], [24, 123], [24, 129], [24, 141], [24, 152], [24, 158], [25, 30], [25, 47], [25, 50], [25, 100], [25, 126], [25, 133], [25, 139], [25, 144], [25, 155], [25, 158], [26, 29], [26, 30], [26, 47], [26, 48], [26, 57], [26, 58], [26, 61], [26, 68], [26, 76], [26, 82], [26, 89], [26, 90], [26, 95], [26, 97], [26, 101], [26, 102], [26, 105], [26, 106], [26, 109], [26, 110], [26, 111], [26, 113], [26, 115], [26, 121], [26, 133], [26, 134], [26, 136], [26, 137], [26, 139], [26, 142], [26, 148], [26, 158], [27, 29], [27, 54], [27, 55], [27, 58], [27, 62], [27, 88], [27, 137], [27, 145], [28, 33], [28, 38], [28, 44], [28, 58], [28, 116], [28, 121], [28, 123], [28, 126], [28, 129], [29, 30], [29, 33], [29, 37], [29, 46], [29, 51], [29, 52], [29, 54], [29, 59], [29, 61], [29, 73], [29, 77], [29, 80], [29, 81], [29, 82], [29, 84], [29, 88], [29, 89], [29, 93], [29, 100], [29, 105], [29, 109], [29, 119], [29, 123], [29, 139], [29, 143], [29, 145], [29, 146], [29, 148], [29, 150], [29, 157], [30, 37], [30, 40], [30, 48], [30, 62], [30, 65], [30, 67], [30, 68], [30, 69], [30, 80], [30, 87], [30, 88], [30, 94], [30, 98], [30, 103], [30, 108], [30, 109], [30, 112], [30, 121], [30, 126], [30, 139], [30, 144], [30, 146], [30, 148], [30, 152], [31, 40], [31, 43], [31, 82], [31, 115], [31, 126], [31, 148], [31, 157], [32, 51], [32, 62], [32, 64], [32, 98], [32, 109], [32, 110], [32, 126], [33, 35], [33, 37], [33, 38], [33, 49], [33, 59], [33, 60], [33, 69], [33, 70], [33, 71], [33, 75], [33, 79], [33, 80], [33, 81], [33, 89], [33, 92], [33, 93], [33, 105], [33, 111], [33, 119], [33, 124], [33, 128], [33, 129], [33, 133], [33, 134], [33, 139], [33, 149], [33, 150], [34, 38], [34, 40], [34, 47], [34, 55], [34, 89], [34, 126], [35, 43], [35, 54], [35, 56], [35, 58], [35, 69], [35, 80], [35, 98], [35, 100], [35, 109], [35, 123], [35, 137], [36, 40], [36, 54], [36, 56], [36, 62], [36, 121], [36, 139], [37, 47], [37, 56], [37, 58], [37, 95], [37, 115], [37, 137], [37, 150], [37, 157], [38, 40], [38, 41], [38, 43], [38, 47], [38, 53], [38, 56], [38, 62], [38, 64], [38, 66], [38, 67], [38, 72], [38, 77], [38, 80], [38, 82], [38, 85], [38, 87], [38, 90], [38, 95], [38, 96], [38, 101], [38, 103], [38, 110], [38, 118], [38, 119], [38, 120], [38, 121], [38, 123], [38, 124], [38, 145], [38, 150], [38, 151], [38, 156], [39, 40], [39, 53], [39, 58], [39, 69], [39, 81], [39, 82], [39, 100], [39, 123], [39, 142], [40, 44], [40, 47], [40, 51], [40, 54], [40, 56], [40, 58], [40, 62], [40, 75], [40, 83], [40, 92], [40, 93], [40, 94], [40, 95], [40, 106], [40, 115], [40, 119], [40, 123], [40, 129], [40, 143], [40, 150], [40, 157], [41, 43], [41, 51], [41, 62], [41, 89], [41, 95], [41, 98], [41, 113], [41, 121], [41, 144], [41, 157], [42, 43], [42, 54], [42, 81], [42, 98], [42, 109], [42, 123], [42, 145], [43, 58], [43, 62], [43, 78], [43, 81], [43, 91], [43, 109], [43, 114], [43, 121], [43, 123], [43, 131], [43, 133], [43, 140], [43, 154], [43, 158], [44, 55], [44, 57], [44, 59], [44, 60], [44, 64], [44, 74], [44, 76], [44, 81], [44, 82], [44, 87], [44, 95], [44, 97], [44, 102], [44, 103], [44, 110], [44, 116], [44, 120], [44, 125], [44, 138], [44, 139], [44, 146], [44, 147], [44, 148], [44, 154], [44, 157], [44, 158], [45, 53], [45, 56], [45, 88], [45, 95], [45, 98], [45, 100], [45, 123], [45, 126], [45, 133], [45, 148], [45, 150], [45, 158], [46, 56], [46, 64], [46, 88], [46, 123], [46, 148], [47, 55], [47, 56], [47, 57], [47, 58], [47, 62], [47, 75], [47, 93], [47, 94], [47, 98], [47, 102], [47, 103], [47, 110], [47, 126], [47, 128], [47, 134], [47, 138], [47, 141], [47, 144], [47, 148], [47, 157], [48, 53], [48, 58], [48, 95], [48, 121], [48, 126], [48, 133], [48, 148], [49, 110], [49, 115], [49, 123], [49, 133], [49, 142], [49, 150], [50, 61], [50, 63], [50, 66], [50, 73], [50, 74], [50, 80], [50, 93], [50, 96], [50, 97], [50, 122], [50, 124], [50, 137], [50, 138], [50, 139], [50, 141], [50, 148], [50, 157], [50, 158], [51, 55], [51, 56], [51, 57], [51, 60], [51, 61], [51, 62], [51, 63], [51, 64], [51, 65], [51, 69], [51, 78], [51, 80], [51, 95], [51, 101], [51, 105], [51, 108], [51, 114], [51, 116], [51, 118], [51, 128], [51, 129], [51, 131], [51, 144], [51, 151], [51, 153], [52, 55], [52, 57], [52, 88], [52, 110], [52, 119], [52, 126], [52, 145], [52, 150], [52, 157], [53, 54], [53, 55], [53, 58], [53, 63], [53, 72], [53, 73], [53, 84], [53, 86], [53, 88], [53, 93], [53, 95], [53, 96], [53, 103], [53, 109], [53, 110], [53, 121], [53, 133], [53, 134], [53, 148], [53, 150], [53, 159], [54, 57], [54, 68], [54, 76], [54, 82], [54, 85], [54, 86], [54, 90], [54, 95], [54, 108], [54, 109], [54, 110], [54, 114], [54, 122], [54, 151], [54, 158], [55, 63], [55, 71], [55, 73], [55, 81], [55, 88], [55, 89], [55, 94], [55, 99], [55, 108], [55, 115], [55, 116], [55, 118], [55, 119], [55, 129], [55, 135], [55, 136], [55, 152], [56, 57], [56, 60], [56, 61], [56, 69], [56, 88], [56, 95], [56, 99], [56, 100], [56, 101], [56, 102], [56, 107], [56, 120], [56, 126], [56, 127], [56, 128], [56, 129], [56, 130], [56, 139], [56, 140], [56, 142], [56, 146], [56, 152], [56, 156], [57, 61], [57, 64], [57, 65], [57, 67], [57, 69], [57, 80], [57, 81], [57, 88], [57, 92], [57, 98], [57, 109], [57, 115], [57, 117], [57, 119], [57, 120], [57, 123], [57, 137], [57, 142], [57, 144], [57, 149], [57, 150], [57, 156], [58, 59], [58, 62], [58, 70], [58, 71], [58, 73], [58, 78], [58, 80], [58, 82], [58, 95], [58, 98], [58, 103], [58, 109], [58, 113], [58, 114], [58, 115], [58, 116], [58, 122], [58, 140], [58, 141], [58, 142], [58, 147], [58, 154], [58, 157], [59, 109], [59, 110], [59, 113], [59, 119], [59, 142], [60, 109], [60, 110], [60, 113], [60, 115], [60, 120], [60, 137], [60, 144], [60, 145], [61, 98], [61, 100], [61, 115], [61, 158], [62, 65], [62, 69], [62, 77], [62, 79], [62, 80], [62, 96], [62, 97], [62, 103], [62, 110], [62, 115], [62, 117], [62, 126], [62, 130], [62, 133], [62, 136], [62, 138], [62, 143], [63, 81], [63, 95], [63, 98], [63, 100], [63, 142], [63, 150], [64, 68], [64, 69], [64, 71], [64, 73], [64, 77], [64, 87], [64, 95], [64, 97], [64, 113], [64, 115], [64, 117], [64, 118], [64, 120], [64, 124], [64, 131], [64, 134], [64, 143], [64, 144], [64, 145], [64, 148], [64, 150], [64, 155], [65, 95], [65, 109], [65, 126], [65, 144], [65, 148], [66, 88], [66, 98], [66, 116], [66, 123], [66, 145], [66, 158], [67, 80], [67, 139], [68, 89], [68, 98], [68, 100], [68, 119], [68, 139], [68, 155], [69, 72], [69, 78], [69, 79], [69, 82], [69, 84], [69, 87], [69, 90], [69, 96], [69, 98], [69, 102], [69, 105], [69, 112], [69, 114], [69, 115], [69, 119], [69, 121], [69, 123], [69, 124], [69, 126], [69, 131], [69, 132], [69, 144], [69, 145], [69, 148], [69, 155], [69, 156], [69, 158], [70, 80], [70, 110], [70, 126], [70, 129], [70, 155], [71, 95], [71, 98], [71, 110], [71, 120], [71, 142], [71, 158], [72, 89], [72, 93], [72, 113], [72, 116], [72, 119], [72, 120], [72, 142], [73, 82], [73, 88], [73, 98], [73, 123], [73, 133], [73, 142], [73, 150], [74, 82], [74, 100], [74, 109], [74, 113], [74, 119], [74, 137], [74, 144], [75, 80], [75, 100], [75, 109], [75, 120], [75, 123], [75, 126], [75, 139], [76, 109], [76, 110], [76, 113], [76, 121], [76, 142], [76, 144], [76, 145], [77, 81], [77, 82], [77, 88], [77, 89], [77, 93], [77, 129], [77, 133], [77, 139], [77, 144], [77, 150], [78, 93], [78, 110], [78, 113], [78, 116], [78, 120], [78, 133], [78, 137], [79, 150], [79, 157], [80, 81], [80, 98], [80, 101], [80, 106], [80, 109], [80, 116], [80, 125], [80, 126], [80, 139], [80, 140], [80, 149], [80, 151], [80, 154], [80, 158], [81, 87], [81, 88], [81, 100], [81, 106], [81, 109], [81, 113], [81, 114], [81, 116], [81, 118], [81, 119], [81, 120], [81, 126], [81, 127], [81, 128], [81, 130], [81, 132], [81, 133], [81, 140], [81, 143], [81, 152], [81, 155], [81, 156], [82, 85], [82, 86], [82, 92], [82, 99], [82, 113], [82, 124], [82, 128], [82, 139], [82, 142], [82, 147], [82, 152], [82, 157], [82, 159], [83, 88], [83, 89], [83, 100], [83, 139], [83, 144], [83, 148], [83, 157], [84, 95], [84, 98], [84, 100], [84, 116], [84, 129], [84, 142], [84, 148], [85, 93], [85, 148], [85, 155], [85, 158], [86, 129], [86, 139], [86, 150], [87, 98], [87, 110], [87, 116], [87, 148], [87, 158], [88, 100], [88, 108], [88, 113], [88, 116], [88, 132], [88, 136], [88, 139], [88, 146], [88, 149], [88, 152], [88, 155], [89, 91], [89, 96], [89, 101], [89, 104], [89, 105], [89, 110], [89, 111], [89, 117], [89, 120], [89, 123], [89, 136], [89, 142], [89, 151], [89, 152], [89, 153], [89, 156], [89, 157], [90, 93], [90, 133], [90, 139], [90, 155], [91, 93], [91, 95], [91, 100], [91, 113], [91, 133], [91, 158], [92, 139], [92, 144], [93, 95], [93, 97], [93, 98], [93, 100], [93, 105], [93, 107], [93, 109], [93, 120], [93, 126], [93, 128], [93, 134], [93, 150], [93, 153], [94, 95], [94, 109], [94, 129], [94, 144], [94, 155], [95, 100], [95, 109], [95, 112], [95, 113], [95, 114], [95, 118], [95, 132], [95, 133], [95, 136], [95, 148], [95, 149], [95, 154], [95, 155], [95, 156], [95, 157], [95, 158], [95, 159], [96, 116], [96, 119], [96, 120], [96, 123], [96, 148], [97, 109], [97, 120], [97, 121], [97, 150], [97, 155], [98, 99], [98, 100], [98, 113], [98, 119], [98, 120], [98, 123], [98, 127], [98, 133], [98, 134], [98, 139], [98, 142], [98, 144], [98, 146], [98, 147], [98, 148], [98, 152], [99, 113], [99, 126], [99, 145], [100, 106], [100, 119], [100, 120], [100, 123], [100, 133], [100, 134], [100, 136], [100, 139], [100, 143], [100, 146], [101, 119], [101, 121], [101, 137], [101, 150], [102, 110], [102, 113], [102, 120], [103, 123], [103, 145], [104, 113], [104, 120], [104, 123], [104, 137], [105, 148], [106, 115], [106, 137], [106, 142], [107, 110], [107, 121], [107, 126], [108, 121], [108, 123], [108, 142], [108, 155], [109, 120], [109, 124], [109, 134], [109, 146], [109, 148], [109, 150], [110, 117], [110, 119], [110, 123], [110, 130], [110, 136], [110, 137], [110, 140], [110, 145], [110, 151], [110, 153], [110, 154], [110, 158], [111, 126], [111, 155], [111, 158], [112, 119], [112, 121], [112, 129], [112, 133], [112, 139], [112, 157], [113, 125], [113, 134], [113, 136], [113, 148], [113, 154], [113, 156], [114, 116], [114, 139], [114, 145], [114, 158], [115, 118], [115, 119], [115, 129], [115, 132], [115, 134], [115, 137], [115, 138], [115, 140], [115, 141], [115, 148], [115, 150], [115, 153], [115, 156], [116, 117], [116, 118], [116, 128], [116, 133], [116, 138], [116, 140], [116, 143], [116, 150], [116, 152], [117, 121], [117, 123], [117, 137], [117, 144], [118, 119], [118, 120], [118, 123], [119, 124], [119, 126], [119, 135], [119, 137], [119, 139], [119, 144], [119, 145], [119, 150], [119, 157], [119, 158], [119, 159], [120, 121], [120, 125], [120, 129], [120, 130], [120, 139], [120, 141], [120, 157], [120, 159], [121, 125], [121, 137], [121, 147], [121, 148], [122, 129], [122, 148], [122, 158], [123, 137], [123, 141], [123, 142], [123, 149], [124, 126], [124, 145], [126, 130], [126, 138], [126, 139], [126, 143], [126, 144], [126, 150], [126, 151], [126, 154], [126, 157], [127, 148], [127, 155], [128, 129], [128, 150], [128, 158], [129, 131], [129, 134], [129, 142], [129, 145], [129, 148], [129, 157], [130, 148], [131, 148], [132, 133], [132, 144], [132, 148], [132, 158], [133, 157], [133, 159], [135, 139], [135, 142], [135, 155], [136, 144], [136, 148], [137, 144], [137, 148], [137, 154], [137, 159], [138, 158], [139, 156], [139, 157], [139, 159], [141, 145], [142, 143], [142, 147], [144, 152], [145, 150], [145, 157], [145, 158], [146, 150], [146, 158], [149, 157], [150, 153], [151, 157], [154, 157], [155, 159], [156, 157]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l6-s4/solution/solve.sh b/tasks/construct-nppc-vertex-cover-l6-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..53628d1b980ba654b9d3084585e9eee905fe3229 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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' +{"cover": [1, 3, 6, 8, 9, 14, 15, 18, 19, 20, 21, 23, 24, 26, 29, 30, 33, 38, 40, 43, 44, 47, 50, 51, 53, 54, 55, 56, 57, 58, 62, 64, 69, 80, 81, 82, 88, 89, 93, 95, 98, 100, 109, 110, 113, 115, 116, 119, 120, 121, 123, 126, 129, 133, 137, 139, 142, 144, 145, 148, 150, 155, 157, 158]} +RLMATH_EOF diff --git a/tasks/construct-nppc-vertex-cover-l6-s4/tests/check.py b/tasks/construct-nppc-vertex-cover-l6-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d8ed740cc660c4837d941a8d70ea394c3bc9f69e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l6-s4/tests/check.py @@ -0,0 +1,18 @@ +"""Vertex cover of size <= k. Accepts any valid cover.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier converts to a set without type checks (floats/bools slip through and + # duplicates are silently merged); here entries must be distinct ints in range + c = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(c)) != len(c): + raise Invalid("cover contains duplicates") + if len(c) > k: + raise Invalid(f"cover has {len(c)} > {k} vertices") + s = set(c) + for u, v in inst["edges"]: + if u not in s and v not in s: + raise Invalid(f"edge ({u},{v}) not covered") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-vertex-cover-l6-s4/tests/instance.json b/tasks/construct-nppc-vertex-cover-l6-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0864ab45a7def62a853d41e6f1d52f8c8aa820d3 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l6-s4/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 160, "k": 64, "edges": [[0, 38], [0, 51], [0, 81], [0, 121], [0, 133], [0, 139], [1, 6], [1, 11], [1, 14], [1, 15], [1, 18], [1, 19], [1, 23], [1, 29], [1, 30], [1, 33], [1, 39], [1, 40], [1, 47], [1, 57], [1, 60], [1, 62], [1, 68], [1, 69], [1, 72], [1, 79], [1, 87], [1, 97], [1, 108], [1, 110], [1, 121], [1, 123], [1, 128], [1, 131], [1, 133], [1, 139], [1, 141], [1, 145], [1, 150], [1, 153], [2, 14], [2, 29], [2, 62], [2, 98], [2, 126], [2, 155], [2, 157], [3, 5], [3, 11], [3, 15], [3, 24], [3, 25], [3, 26], [3, 30], [3, 34], [3, 36], [3, 38], [3, 49], [3, 52], [3, 53], [3, 55], [3, 57], [3, 71], [3, 82], [3, 83], [3, 86], [3, 88], [3, 90], [3, 91], [3, 93], [3, 116], [3, 120], [3, 121], [3, 125], [3, 126], [3, 131], [3, 133], [3, 139], [3, 142], [3, 149], [4, 8], [4, 9], [4, 18], [4, 21], [4, 24], [4, 44], [4, 47], [4, 82], [4, 93], [4, 129], [4, 150], [5, 30], [5, 38], [5, 43], [5, 62], [5, 89], [5, 137], [5, 144], [6, 14], [6, 28], [6, 30], [6, 34], [6, 39], [6, 44], [6, 46], [6, 58], [6, 77], [6, 78], [6, 80], [6, 81], [6, 82], [6, 84], [6, 90], [6, 93], [6, 94], [6, 96], [6, 109], [6, 115], [6, 118], [6, 131], [6, 132], [6, 133], [6, 137], [6, 142], [6, 159], [7, 8], [7, 30], [7, 47], [7, 100], [7, 119], [7, 137], [7, 148], [7, 157], [8, 10], [8, 12], [8, 13], [8, 18], [8, 19], [8, 23], [8, 24], [8, 32], [8, 38], [8, 39], [8, 44], [8, 53], [8, 57], [8, 62], [8, 73], [8, 74], [8, 76], [8, 92], [8, 100], [8, 103], [8, 104], [8, 110], [8, 113], [8, 115], [8, 123], [8, 124], [8, 137], [8, 139], [8, 146], [8, 148], [8, 155], [9, 11], [9, 12], [9, 14], [9, 15], [9, 20], [9, 23], [9, 24], [9, 25], [9, 28], [9, 29], [9, 34], [9, 44], [9, 55], [9, 56], [9, 59], [9, 62], [9, 66], [9, 82], [9, 83], [9, 85], [9, 90], [9, 95], [9, 99], [9, 104], [9, 105], [9, 110], [9, 115], [9, 118], [9, 120], [9, 121], [9, 123], [9, 124], [9, 125], [9, 126], [9, 129], [9, 133], [9, 135], [9, 140], [9, 144], [9, 147], [9, 149], [9, 150], [10, 38], [10, 40], [10, 47], [10, 53], [10, 58], [10, 81], [10, 93], [10, 100], [10, 113], [10, 119], [10, 120], [10, 126], [10, 139], [10, 148], [10, 157], [11, 18], [11, 56], [11, 119], [11, 123], [11, 133], [11, 142], [11, 150], [12, 26], [12, 55], [12, 57], [12, 58], [12, 62], [12, 80], [12, 95], [12, 109], [12, 119], [12, 120], [12, 123], [12, 148], [12, 150], [12, 157], [13, 55], [13, 62], [13, 121], [13, 123], [13, 139], [13, 157], [14, 15], [14, 29], [14, 30], [14, 31], [14, 34], [14, 36], [14, 37], [14, 46], [14, 52], [14, 53], [14, 54], [14, 57], [14, 64], [14, 66], [14, 74], [14, 76], [14, 82], [14, 86], [14, 88], [14, 89], [14, 93], [14, 95], [14, 98], [14, 99], [14, 102], [14, 108], [14, 109], [14, 114], [14, 119], [14, 120], [14, 146], [14, 147], [14, 150], [14, 155], [15, 19], [15, 21], [15, 28], [15, 29], [15, 30], [15, 32], [15, 34], [15, 39], [15, 40], [15, 46], [15, 47], [15, 48], [15, 49], [15, 51], [15, 52], [15, 53], [15, 58], [15, 59], [15, 65], [15, 66], [15, 72], [15, 73], [15, 87], [15, 88], [15, 97], [15, 101], [15, 103], [15, 105], [15, 110], [15, 113], [15, 120], [15, 122], [15, 128], [15, 133], [15, 137], [15, 139], [15, 144], [15, 148], [15, 151], [15, 156], [15, 157], [15, 158], [16, 21], [16, 47], [16, 51], [16, 57], [16, 113], [16, 126], [16, 150], [16, 157], [17, 24], [17, 43], [17, 51], [17, 120], [17, 121], [18, 20], [18, 22], [18, 33], [18, 35], [18, 39], [18, 44], [18, 45], [18, 49], [18, 56], [18, 59], [18, 61], [18, 62], [18, 64], [18, 67], [18, 75], [18, 78], [18, 81], [18, 83], [18, 85], [18, 89], [18, 94], [18, 98], [18, 100], [18, 108], [18, 110], [18, 133], [18, 135], [18, 137], [18, 139], [18, 143], [18, 145], [18, 155], [18, 157], [19, 38], [19, 49], [19, 51], [19, 53], [19, 54], [19, 57], [19, 60], [19, 61], [19, 67], [19, 69], [19, 74], [19, 79], [19, 81], [19, 82], [19, 89], [19, 100], [19, 104], [19, 105], [19, 108], [19, 112], [19, 115], [19, 119], [19, 124], [19, 125], [19, 126], [19, 130], [19, 133], [19, 137], [19, 139], [19, 140], [19, 146], [19, 153], [19, 154], [19, 159], [20, 28], [20, 44], [20, 46], [20, 48], [20, 51], [20, 53], [20, 57], [20, 58], [20, 59], [20, 63], [20, 85], [20, 89], [20, 93], [20, 95], [20, 99], [20, 107], [20, 111], [20, 113], [20, 115], [20, 116], [20, 124], [20, 133], [20, 136], [20, 142], [20, 151], [20, 155], [21, 23], [21, 28], [21, 31], [21, 32], [21, 51], [21, 55], [21, 56], [21, 64], [21, 66], [21, 72], [21, 75], [21, 78], [21, 86], [21, 87], [21, 88], [21, 93], [21, 104], [21, 109], [21, 114], [21, 115], [21, 119], [21, 137], [21, 139], [21, 145], [21, 148], [21, 149], [21, 155], [21, 158], [22, 33], [22, 53], [22, 64], [22, 98], [22, 123], [22, 139], [22, 142], [22, 144], [23, 24], [23, 29], [23, 34], [23, 40], [23, 44], [23, 53], [23, 55], [23, 60], [23, 62], [23, 68], [23, 70], [23, 82], [23, 95], [23, 109], [23, 115], [23, 120], [23, 123], [23, 126], [23, 140], [23, 143], [23, 146], [23, 148], [23, 149], [23, 151], [24, 27], [24, 30], [24, 38], [24, 43], [24, 46], [24, 51], [24, 54], [24, 66], [24, 68], [24, 76], [24, 77], [24, 80], [24, 81], [24, 100], [24, 102], [24, 105], [24, 108], [24, 109], [24, 110], [24, 111], [24, 114], [24, 118], [24, 119], [24, 122], [24, 123], [24, 129], [24, 141], [24, 152], [24, 158], [25, 30], [25, 47], [25, 50], [25, 100], [25, 126], [25, 133], [25, 139], [25, 144], [25, 155], [25, 158], [26, 29], [26, 30], [26, 47], [26, 48], [26, 57], [26, 58], [26, 61], [26, 68], [26, 76], [26, 82], [26, 89], [26, 90], [26, 95], [26, 97], [26, 101], [26, 102], [26, 105], [26, 106], [26, 109], [26, 110], [26, 111], [26, 113], [26, 115], [26, 121], [26, 133], [26, 134], [26, 136], [26, 137], [26, 139], [26, 142], [26, 148], [26, 158], [27, 29], [27, 54], [27, 55], [27, 58], [27, 62], [27, 88], [27, 137], [27, 145], [28, 33], [28, 38], [28, 44], [28, 58], [28, 116], [28, 121], [28, 123], [28, 126], [28, 129], [29, 30], [29, 33], [29, 37], [29, 46], [29, 51], [29, 52], [29, 54], [29, 59], [29, 61], [29, 73], [29, 77], [29, 80], [29, 81], [29, 82], [29, 84], [29, 88], [29, 89], [29, 93], [29, 100], [29, 105], [29, 109], [29, 119], [29, 123], [29, 139], [29, 143], [29, 145], [29, 146], [29, 148], [29, 150], [29, 157], [30, 37], [30, 40], [30, 48], [30, 62], [30, 65], [30, 67], [30, 68], [30, 69], [30, 80], [30, 87], [30, 88], [30, 94], [30, 98], [30, 103], [30, 108], [30, 109], [30, 112], [30, 121], [30, 126], [30, 139], [30, 144], [30, 146], [30, 148], [30, 152], [31, 40], [31, 43], [31, 82], [31, 115], [31, 126], [31, 148], [31, 157], [32, 51], [32, 62], [32, 64], [32, 98], [32, 109], [32, 110], [32, 126], [33, 35], [33, 37], [33, 38], [33, 49], [33, 59], [33, 60], [33, 69], [33, 70], [33, 71], [33, 75], [33, 79], [33, 80], [33, 81], [33, 89], [33, 92], [33, 93], [33, 105], [33, 111], [33, 119], [33, 124], [33, 128], [33, 129], [33, 133], [33, 134], [33, 139], [33, 149], [33, 150], [34, 38], [34, 40], [34, 47], [34, 55], [34, 89], [34, 126], [35, 43], [35, 54], [35, 56], [35, 58], [35, 69], [35, 80], [35, 98], [35, 100], [35, 109], [35, 123], [35, 137], [36, 40], [36, 54], [36, 56], [36, 62], [36, 121], [36, 139], [37, 47], [37, 56], [37, 58], [37, 95], [37, 115], [37, 137], [37, 150], [37, 157], [38, 40], [38, 41], [38, 43], [38, 47], [38, 53], [38, 56], [38, 62], [38, 64], [38, 66], [38, 67], [38, 72], [38, 77], [38, 80], [38, 82], [38, 85], [38, 87], [38, 90], [38, 95], [38, 96], [38, 101], [38, 103], [38, 110], [38, 118], [38, 119], [38, 120], [38, 121], [38, 123], [38, 124], [38, 145], [38, 150], [38, 151], [38, 156], [39, 40], [39, 53], [39, 58], [39, 69], [39, 81], [39, 82], [39, 100], [39, 123], [39, 142], [40, 44], [40, 47], [40, 51], [40, 54], [40, 56], [40, 58], [40, 62], [40, 75], [40, 83], [40, 92], [40, 93], [40, 94], [40, 95], [40, 106], [40, 115], [40, 119], [40, 123], [40, 129], [40, 143], [40, 150], [40, 157], [41, 43], [41, 51], [41, 62], [41, 89], [41, 95], [41, 98], [41, 113], [41, 121], [41, 144], [41, 157], [42, 43], [42, 54], [42, 81], [42, 98], [42, 109], [42, 123], [42, 145], [43, 58], [43, 62], [43, 78], [43, 81], [43, 91], [43, 109], [43, 114], [43, 121], [43, 123], [43, 131], [43, 133], [43, 140], [43, 154], [43, 158], [44, 55], [44, 57], [44, 59], [44, 60], [44, 64], [44, 74], [44, 76], [44, 81], [44, 82], [44, 87], [44, 95], [44, 97], [44, 102], [44, 103], [44, 110], [44, 116], [44, 120], [44, 125], [44, 138], [44, 139], [44, 146], [44, 147], [44, 148], [44, 154], [44, 157], [44, 158], [45, 53], [45, 56], [45, 88], [45, 95], [45, 98], [45, 100], [45, 123], [45, 126], [45, 133], [45, 148], [45, 150], [45, 158], [46, 56], [46, 64], [46, 88], [46, 123], [46, 148], [47, 55], [47, 56], [47, 57], [47, 58], [47, 62], [47, 75], [47, 93], [47, 94], [47, 98], [47, 102], [47, 103], [47, 110], [47, 126], [47, 128], [47, 134], [47, 138], [47, 141], [47, 144], [47, 148], [47, 157], [48, 53], [48, 58], [48, 95], [48, 121], [48, 126], [48, 133], [48, 148], [49, 110], [49, 115], [49, 123], [49, 133], [49, 142], [49, 150], [50, 61], [50, 63], [50, 66], [50, 73], [50, 74], [50, 80], [50, 93], [50, 96], [50, 97], [50, 122], [50, 124], [50, 137], [50, 138], [50, 139], [50, 141], [50, 148], [50, 157], [50, 158], [51, 55], [51, 56], [51, 57], [51, 60], [51, 61], [51, 62], [51, 63], [51, 64], [51, 65], [51, 69], [51, 78], [51, 80], [51, 95], [51, 101], [51, 105], [51, 108], [51, 114], [51, 116], [51, 118], [51, 128], [51, 129], [51, 131], [51, 144], [51, 151], [51, 153], [52, 55], [52, 57], [52, 88], [52, 110], [52, 119], [52, 126], [52, 145], [52, 150], [52, 157], [53, 54], [53, 55], [53, 58], [53, 63], [53, 72], [53, 73], [53, 84], [53, 86], [53, 88], [53, 93], [53, 95], [53, 96], [53, 103], [53, 109], [53, 110], [53, 121], [53, 133], [53, 134], [53, 148], [53, 150], [53, 159], [54, 57], [54, 68], [54, 76], [54, 82], [54, 85], [54, 86], [54, 90], [54, 95], [54, 108], [54, 109], [54, 110], [54, 114], [54, 122], [54, 151], [54, 158], [55, 63], [55, 71], [55, 73], [55, 81], [55, 88], [55, 89], [55, 94], [55, 99], [55, 108], [55, 115], [55, 116], [55, 118], [55, 119], [55, 129], [55, 135], [55, 136], [55, 152], [56, 57], [56, 60], [56, 61], [56, 69], [56, 88], [56, 95], [56, 99], [56, 100], [56, 101], [56, 102], [56, 107], [56, 120], [56, 126], [56, 127], [56, 128], [56, 129], [56, 130], [56, 139], [56, 140], [56, 142], [56, 146], [56, 152], [56, 156], [57, 61], [57, 64], [57, 65], [57, 67], [57, 69], [57, 80], [57, 81], [57, 88], [57, 92], [57, 98], [57, 109], [57, 115], [57, 117], [57, 119], [57, 120], [57, 123], [57, 137], [57, 142], [57, 144], [57, 149], [57, 150], [57, 156], [58, 59], [58, 62], [58, 70], [58, 71], [58, 73], [58, 78], [58, 80], [58, 82], [58, 95], [58, 98], [58, 103], [58, 109], [58, 113], [58, 114], [58, 115], [58, 116], [58, 122], [58, 140], [58, 141], [58, 142], [58, 147], [58, 154], [58, 157], [59, 109], [59, 110], [59, 113], [59, 119], [59, 142], [60, 109], [60, 110], [60, 113], [60, 115], [60, 120], [60, 137], [60, 144], [60, 145], [61, 98], [61, 100], [61, 115], [61, 158], [62, 65], [62, 69], [62, 77], [62, 79], [62, 80], [62, 96], [62, 97], [62, 103], [62, 110], [62, 115], [62, 117], [62, 126], [62, 130], [62, 133], [62, 136], [62, 138], [62, 143], [63, 81], [63, 95], [63, 98], [63, 100], [63, 142], [63, 150], [64, 68], [64, 69], [64, 71], [64, 73], [64, 77], [64, 87], [64, 95], [64, 97], [64, 113], [64, 115], [64, 117], [64, 118], [64, 120], [64, 124], [64, 131], [64, 134], [64, 143], [64, 144], [64, 145], [64, 148], [64, 150], [64, 155], [65, 95], [65, 109], [65, 126], [65, 144], [65, 148], [66, 88], [66, 98], [66, 116], [66, 123], [66, 145], [66, 158], [67, 80], [67, 139], [68, 89], [68, 98], [68, 100], [68, 119], [68, 139], [68, 155], [69, 72], [69, 78], [69, 79], [69, 82], [69, 84], [69, 87], [69, 90], [69, 96], [69, 98], [69, 102], [69, 105], [69, 112], [69, 114], [69, 115], [69, 119], [69, 121], [69, 123], [69, 124], [69, 126], [69, 131], [69, 132], [69, 144], [69, 145], [69, 148], [69, 155], [69, 156], [69, 158], [70, 80], [70, 110], [70, 126], [70, 129], [70, 155], [71, 95], [71, 98], [71, 110], [71, 120], [71, 142], [71, 158], [72, 89], [72, 93], [72, 113], [72, 116], [72, 119], [72, 120], [72, 142], [73, 82], [73, 88], [73, 98], [73, 123], [73, 133], [73, 142], [73, 150], [74, 82], [74, 100], [74, 109], [74, 113], [74, 119], [74, 137], [74, 144], [75, 80], [75, 100], [75, 109], [75, 120], [75, 123], [75, 126], [75, 139], [76, 109], [76, 110], [76, 113], [76, 121], [76, 142], [76, 144], [76, 145], [77, 81], [77, 82], [77, 88], [77, 89], [77, 93], [77, 129], [77, 133], [77, 139], [77, 144], [77, 150], [78, 93], [78, 110], [78, 113], [78, 116], [78, 120], [78, 133], [78, 137], [79, 150], [79, 157], [80, 81], [80, 98], [80, 101], [80, 106], [80, 109], [80, 116], [80, 125], [80, 126], [80, 139], [80, 140], [80, 149], [80, 151], [80, 154], [80, 158], [81, 87], [81, 88], [81, 100], [81, 106], [81, 109], [81, 113], [81, 114], [81, 116], [81, 118], [81, 119], [81, 120], [81, 126], [81, 127], [81, 128], [81, 130], [81, 132], [81, 133], [81, 140], [81, 143], [81, 152], [81, 155], [81, 156], [82, 85], [82, 86], [82, 92], [82, 99], [82, 113], [82, 124], [82, 128], [82, 139], [82, 142], [82, 147], [82, 152], [82, 157], [82, 159], [83, 88], [83, 89], [83, 100], [83, 139], [83, 144], [83, 148], [83, 157], [84, 95], [84, 98], [84, 100], [84, 116], [84, 129], [84, 142], [84, 148], [85, 93], [85, 148], [85, 155], [85, 158], [86, 129], [86, 139], [86, 150], [87, 98], [87, 110], [87, 116], [87, 148], [87, 158], [88, 100], [88, 108], [88, 113], [88, 116], [88, 132], [88, 136], [88, 139], [88, 146], [88, 149], [88, 152], [88, 155], [89, 91], [89, 96], [89, 101], [89, 104], [89, 105], [89, 110], [89, 111], [89, 117], [89, 120], [89, 123], [89, 136], [89, 142], [89, 151], [89, 152], [89, 153], [89, 156], [89, 157], [90, 93], [90, 133], [90, 139], [90, 155], [91, 93], [91, 95], [91, 100], [91, 113], [91, 133], [91, 158], [92, 139], [92, 144], [93, 95], [93, 97], [93, 98], [93, 100], [93, 105], [93, 107], [93, 109], [93, 120], [93, 126], [93, 128], [93, 134], [93, 150], [93, 153], [94, 95], [94, 109], [94, 129], [94, 144], [94, 155], [95, 100], [95, 109], [95, 112], [95, 113], [95, 114], [95, 118], [95, 132], [95, 133], [95, 136], [95, 148], [95, 149], [95, 154], [95, 155], [95, 156], [95, 157], [95, 158], [95, 159], [96, 116], [96, 119], [96, 120], [96, 123], [96, 148], [97, 109], [97, 120], [97, 121], [97, 150], [97, 155], [98, 99], [98, 100], [98, 113], [98, 119], [98, 120], [98, 123], [98, 127], [98, 133], [98, 134], [98, 139], [98, 142], [98, 144], [98, 146], [98, 147], [98, 148], [98, 152], [99, 113], [99, 126], [99, 145], [100, 106], [100, 119], [100, 120], [100, 123], [100, 133], [100, 134], [100, 136], [100, 139], [100, 143], [100, 146], [101, 119], [101, 121], [101, 137], [101, 150], [102, 110], [102, 113], [102, 120], [103, 123], [103, 145], [104, 113], [104, 120], [104, 123], [104, 137], [105, 148], [106, 115], [106, 137], [106, 142], [107, 110], [107, 121], [107, 126], [108, 121], [108, 123], [108, 142], [108, 155], [109, 120], [109, 124], [109, 134], [109, 146], [109, 148], [109, 150], [110, 117], [110, 119], [110, 123], [110, 130], [110, 136], [110, 137], [110, 140], [110, 145], [110, 151], [110, 153], [110, 154], [110, 158], [111, 126], [111, 155], [111, 158], [112, 119], [112, 121], [112, 129], [112, 133], [112, 139], [112, 157], [113, 125], [113, 134], [113, 136], [113, 148], [113, 154], [113, 156], [114, 116], [114, 139], [114, 145], [114, 158], [115, 118], [115, 119], [115, 129], [115, 132], [115, 134], [115, 137], [115, 138], [115, 140], [115, 141], [115, 148], [115, 150], [115, 153], [115, 156], [116, 117], [116, 118], [116, 128], [116, 133], [116, 138], [116, 140], [116, 143], [116, 150], [116, 152], [117, 121], [117, 123], [117, 137], [117, 144], [118, 119], [118, 120], [118, 123], [119, 124], [119, 126], [119, 135], [119, 137], [119, 139], [119, 144], [119, 145], [119, 150], [119, 157], [119, 158], [119, 159], [120, 121], [120, 125], [120, 129], [120, 130], [120, 139], [120, 141], [120, 157], [120, 159], [121, 125], [121, 137], [121, 147], [121, 148], [122, 129], [122, 148], [122, 158], [123, 137], [123, 141], [123, 142], [123, 149], [124, 126], [124, 145], [126, 130], [126, 138], [126, 139], [126, 143], [126, 144], [126, 150], [126, 151], [126, 154], [126, 157], [127, 148], [127, 155], [128, 129], [128, 150], [128, 158], [129, 131], [129, 134], [129, 142], [129, 145], [129, 148], [129, 157], [130, 148], [131, 148], [132, 133], [132, 144], [132, 148], [132, 158], [133, 157], [133, 159], [135, 139], [135, 142], [135, 155], [136, 144], [136, 148], [137, 144], [137, 148], [137, 154], [137, 159], [138, 158], [139, 156], [139, 157], [139, 159], [141, 145], [142, 143], [142, 147], [144, 152], [145, 150], [145, 157], [145, 158], [146, 150], [146, 158], [149, 157], [150, 153], [151, 157], [154, 157], [155, 159], [156, 157]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l6-s4/tests/run.py b/tasks/construct-nppc-vertex-cover-l6-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l6-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-vertex-cover-l6-s4/tests/test.sh b/tasks/construct-nppc-vertex-cover-l6-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-rg-graph-color-l4-s1/environment/Dockerfile b/tasks/construct-rg-graph-color-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-graph-color-l4-s1/environment/instance.json b/tasks/construct-rg-graph-color-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3e7074b3877fe04c0964c413887c0d1e6af36223 --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_vertices": 20, "num_colors": 3, "edges": [[0, 7], [0, 8], [0, 17], [0, 19], [2, 8], [3, 4], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 16], [4, 12], [4, 17], [5, 6], [5, 12], [6, 7], [6, 18], [7, 10], [8, 14], [10, 13], [10, 19], [12, 15], [13, 19], [15, 16], [17, 18]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l4-s1/solution/solve.sh b/tasks/construct-rg-graph-color-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..43a0c0c13fd5f72a17a7b7bd37ffd295f8e2ae37 --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [1, 1, 1, 1, 2, 1, 2, 3, 2, 2, 2, 2, 3, 1, 1, 1, 2, 3, 1, 3]} +RLMATH_EOF diff --git a/tasks/construct-rg-graph-color-l4-s1/tests/check.py b/tasks/construct-rg-graph-color-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e9328912405d1c894970c90415be62bf9556ed36 --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s1/tests/check.py @@ -0,0 +1,13 @@ +"""Proper colouring with colours 1..k (Reasoning Gym graph_color, Apache-2.0). Any valid colouring. +Upstream note: its verifier checks `color in allowed_colors`, so True (== 1) and 1.0 were accepted as +colours, and extra keys were ignored. Here colours must be ints in 1..k, one per vertex.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_vertices"], inst["num_colors"] + c = int_list(ans.get("coloring"), n, 1, k, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"adjacent vertices {u} and {v} share colour {c[u]}") + return None, {} diff --git a/tasks/construct-rg-graph-color-l4-s1/tests/instance.json b/tasks/construct-rg-graph-color-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3e7074b3877fe04c0964c413887c0d1e6af36223 --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"num_vertices": 20, "num_colors": 3, "edges": [[0, 7], [0, 8], [0, 17], [0, 19], [2, 8], [3, 4], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 16], [4, 12], [4, 17], [5, 6], [5, 12], [6, 7], [6, 18], [7, 10], [8, 14], [10, 13], [10, 19], [12, 15], [13, 19], [15, 16], [17, 18]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l4-s1/tests/run.py b/tasks/construct-rg-graph-color-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-graph-color-l4-s1/tests/test.sh b/tasks/construct-rg-graph-color-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-graph-color-l4-s6/environment/Dockerfile b/tasks/construct-rg-graph-color-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-graph-color-l4-s6/environment/instance.json b/tasks/construct-rg-graph-color-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6773766425109de3a43c9af778c76ec0e3cd77dc --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"num_vertices": 20, "num_colors": 3, "edges": [[0, 1], [0, 4], [0, 7], [0, 8], [0, 16], [1, 7], [1, 17], [2, 10], [2, 13], [2, 16], [2, 17], [3, 5], [3, 8], [3, 19], [4, 17], [4, 19], [5, 7], [5, 14], [5, 17], [6, 8], [7, 8], [7, 9], [7, 10], [7, 11], [8, 9], [8, 13], [8, 15], [9, 13], [9, 16], [10, 13], [10, 15], [10, 18], [11, 12], [11, 13], [11, 17], [12, 13], [13, 16], [14, 17], [16, 17], [18, 19]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l4-s6/solution/solve.sh b/tasks/construct-rg-graph-color-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4903b455c6dc20be4a4c88ae6630e29b9699c5a3 --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [1, 2, 1, 1, 2, 2, 1, 3, 2, 1, 2, 1, 2, 3, 1, 1, 2, 3, 1, 3]} +RLMATH_EOF diff --git a/tasks/construct-rg-graph-color-l4-s6/tests/check.py b/tasks/construct-rg-graph-color-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e9328912405d1c894970c90415be62bf9556ed36 --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-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-l4-s6/tests/instance.json b/tasks/construct-rg-graph-color-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6773766425109de3a43c9af778c76ec0e3cd77dc --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"num_vertices": 20, "num_colors": 3, "edges": [[0, 1], [0, 4], [0, 7], [0, 8], [0, 16], [1, 7], [1, 17], [2, 10], [2, 13], [2, 16], [2, 17], [3, 5], [3, 8], [3, 19], [4, 17], [4, 19], [5, 7], [5, 14], [5, 17], [6, 8], [7, 8], [7, 9], [7, 10], [7, 11], [8, 9], [8, 13], [8, 15], [9, 13], [9, 16], [10, 13], [10, 15], [10, 18], [11, 12], [11, 13], [11, 17], [12, 13], [13, 16], [14, 17], [16, 17], [18, 19]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l4-s6/tests/run.py b/tasks/construct-rg-graph-color-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-graph-color-l4-s6/tests/test.sh b/tasks/construct-rg-graph-color-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-graph-color-l4-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-intermediate-integration-l3-s2/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l3-s2/environment/instance.json b/tasks/construct-rg-intermediate-integration-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a2ae96a0683aa8f65836e6b3199e9fa1c64db63c --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-6*sin(2*x - 2)*cos(2*x - 2)**4", "problem_type": "trigonometric", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l3-s2/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6b07fbc44d73cb7ce26ae3189e9cec7439eba254 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "3*cos(2*x - 2)**5/5 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l3-s2/tests/check.py b/tasks/construct-rg-intermediate-integration-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l3-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-l3-s2/tests/instance.json b/tasks/construct-rg-intermediate-integration-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a2ae96a0683aa8f65836e6b3199e9fa1c64db63c --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-6*sin(2*x - 2)*cos(2*x - 2)**4", "problem_type": "trigonometric", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l3-s2/tests/run.py b/tasks/construct-rg-intermediate-integration-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l3-s2/tests/test.sh b/tasks/construct-rg-intermediate-integration-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l3-s5/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l3-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l3-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-intermediate-integration-l3-s5/environment/instance.json b/tasks/construct-rg-intermediate-integration-l3-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f64debdb6be4ff54c33ef55089f0bb8f9e91f6c6 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l3-s5/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "8*sin(8*x + 3)**2*cos(8*x + 3)", "problem_type": "trigonometric", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l3-s5/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l3-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c1f0be8b05fe19bec5167d3a5a8522b40cd7ce58 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l3-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"antiderivative": "sin(8*x + 3)**3/3 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l3-s5/tests/check.py b/tasks/construct-rg-intermediate-integration-l3-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l3-s5/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-intermediate-integration-l3-s5/tests/instance.json b/tasks/construct-rg-intermediate-integration-l3-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f64debdb6be4ff54c33ef55089f0bb8f9e91f6c6 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l3-s5/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "8*sin(8*x + 3)**2*cos(8*x + 3)", "problem_type": "trigonometric", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l3-s5/tests/run.py b/tasks/construct-rg-intermediate-integration-l3-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l3-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-intermediate-integration-l3-s5/tests/test.sh b/tasks/construct-rg-intermediate-integration-l3-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l3-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-simple-integration-l4-s0/environment/Dockerfile b/tasks/construct-rg-simple-integration-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l4-s0/environment/instance.json b/tasks/construct-rg-simple-integration-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eea1f16091379f400c7cf095f2e61064241a49d7 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "40*X**9/3 + 108*X**5/5 - 30*X**4 + 6*X", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l4-s0/solution/solve.sh b/tasks/construct-rg-simple-integration-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..61180dad244a37b7d43b1d71d699ff319033012d --- /dev/null +++ b/tasks/construct-rg-simple-integration-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' +{"antiderivative": "4*X**10/3 + 18*X**6/5 - 6*X**5 + 3*X**2 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l4-s0/tests/check.py b/tasks/construct-rg-simple-integration-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l4-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-l4-s0/tests/instance.json b/tasks/construct-rg-simple-integration-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eea1f16091379f400c7cf095f2e61064241a49d7 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "40*X**9/3 + 108*X**5/5 - 30*X**4 + 6*X", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l4-s0/tests/run.py b/tasks/construct-rg-simple-integration-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l4-s0/tests/test.sh b/tasks/construct-rg-simple-integration-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l4-s7/environment/instance.json b/tasks/construct-rg-simple-integration-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..08001f34f7d6f4f17df17614a3564fcba6589e07 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "45*x**8/2 - 8*x**7 - 28*x**6 - 5*x**4/3 - 18*x", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l1-s1/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l1-s1/environment/instance.json b/tasks/construct-rlve-antiderivative-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ce37c34e179fed39a7d6db117a61b32723165900 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "64*x**3", "max_ops": 28, "max_len": 540, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l1-s1/solution/solve.sh b/tasks/construct-rlve-antiderivative-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1c91b510664a67639537fe9511ef2956a7f764e8 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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' +{"F": "16*x**4"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l1-s1/tests/check.py b/tasks/construct-rlve-antiderivative-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l1-s1/tests/check.py @@ -0,0 +1,107 @@ +"""Antiderivative check. The answer string is tokenised against a whitelist (x, integers, + - * / ** ( ) and a few +elementary functions) before sympy parses it, so no Python eval of untrusted text and no `integrate`/`Integral`.""" +import re +import signal + +import sympy +from sympy.parsing.sympy_parser import auto_number, parse_expr + +from run import Invalid + +x = sympy.Symbol("x") +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "exp": sympy.exp, "log": sympy.log, + "sqrt": sympy.sqrt, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "E": sympy.E, "pi": sympy.pi, "x": x} +TOK = re.compile(r"\s*(?:(\d+)|([A-Za-z]+)|(\*\*|[-+*/()]))") +NPTS = 40 + + +def safe_parse(s, max_len): + if not isinstance(s, str) or not s.strip(): + raise Invalid("F must be a non-empty string") + if len(s) > max_len: + raise Invalid("expression too long") + pos = 0 + while pos < len(s): + m = TOK.match(s, pos) + if not m or m.end() == pos: + if s[pos:].strip() == "": + break + raise Invalid(f"illegal character near position {pos}") + if m.group(1) and len(m.group(1)) > 12: + raise Invalid("integer literal too long") + if m.group(2) and m.group(2) not in FUNCS: + raise Invalid(f"unknown name {m.group(2)!r}") + pos = m.end() + try: + e = parse_expr(s, local_dict=dict(FUNCS), global_dict={"__builtins__": {}, "Integer": sympy.Integer}, + transformations=(auto_number,)) + except Invalid: + raise + except Exception as ex: + raise Invalid(f"cannot parse F: {type(ex).__name__}") + if not isinstance(e, sympy.Expr): + raise Invalid("F is not an expression") + if e.free_symbols - {x}: + raise Invalid("F may only contain the variable x") + return e + + +def _val(e, pt): + v = e.evalf(40, subs={x: pt}) + if not v.is_number or v.has(sympy.zoo, sympy.nan, sympy.oo, -sympy.oo): + return None + return v + + +class _Timeout(Exception): + pass + + +def _alarm(*_): + raise _Timeout() + + +def check(inst, ans): + old = None + try: + old = signal.signal(signal.SIGALRM, _alarm) + signal.alarm(40) + except ValueError: # not in main thread + old = None + try: + return _check(inst, ans) + except _Timeout: + raise Invalid("evaluation timed out") + except RecursionError: + raise Invalid("expression too deep") + finally: + if old is not None: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + + +def _check(inst, ans): + F = safe_parse(ans.get("F"), inst["max_len"]) + if sympy.count_ops(F) > inst["max_ops"]: + raise Invalid("expression too complex") + if any(isinstance(a, sympy.Rational) and max(abs(a.p), abs(a.q)) > 10 ** 12 for a in F.atoms(sympy.Rational)): + raise Invalid("numeric constants too large") + D = sympy.diff(F, x) + f = sympy.sympify(inst["f_prime"]) # trusted instance data + ok = 0 + for k in range(NPTS): + pt = sympy.Rational(2 * k + 1, NPTS // 2 * 2) * 2 - 2 + sympy.Rational(1, 997) + vf = _val(f, pt) + if vf is None: + continue + vd = _val(D, pt) + if vd is None: + continue + err = sympy.Abs(vd - vf).evalf(40) + if err > sympy.Float("1e-20", 40) * (1 + sympy.Abs(vf).evalf(40)): + raise Invalid(f"F'(x) != f(x) at x = {float(pt):.4f}") + ok += 1 + if ok < NPTS // 4: + raise Invalid("F' could not be compared with f on enough test points") + return None, {"points_checked": ok} diff --git a/tasks/construct-rlve-antiderivative-l1-s1/tests/instance.json b/tasks/construct-rlve-antiderivative-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ce37c34e179fed39a7d6db117a61b32723165900 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "64*x**3", "max_ops": 28, "max_len": 540, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l1-s1/tests/run.py b/tasks/construct-rlve-antiderivative-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l1-s1/tests/test.sh b/tasks/construct-rlve-antiderivative-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l1-s6/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l1-s6/environment/instance.json b/tasks/construct-rlve-antiderivative-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f9f166613c52160f44139eb2f9fbba6e1705cfd5 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "cos(x)*cos(sin(x))", "max_ops": 28, "max_len": 620, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l1-s6/solution/solve.sh b/tasks/construct-rlve-antiderivative-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cc986980dfc341c71f3b5f497ca472e48a127fb4 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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' +{"F": "sin(sin(x))"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l1-s6/tests/check.py b/tasks/construct-rlve-antiderivative-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l1-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-l1-s6/tests/instance.json b/tasks/construct-rlve-antiderivative-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f9f166613c52160f44139eb2f9fbba6e1705cfd5 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "cos(x)*cos(sin(x))", "max_ops": 28, "max_len": 620, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l1-s6/tests/run.py b/tasks/construct-rlve-antiderivative-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l1-s6/tests/test.sh b/tasks/construct-rlve-antiderivative-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l5-s9/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l5-s9/environment/instance.json b/tasks/construct-rlve-antiderivative-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bed753d864cca11843f5e056900275eb171aba56 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "log(x)*sin(x)*sin(2*x)/cos(x)**2 + 2*log(x)*cos(2*x)/cos(x) + sin(2*x)/(x*cos(x))", "max_ops": 48, "max_len": 920, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l5-s9/solution/solve.sh b/tasks/construct-rlve-antiderivative-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cd8f71566025c78d014985b53110fb77eb806ce7 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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' +{"F": "log(x)*sin(2*x)/cos(x) + 1"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l5-s9/tests/check.py b/tasks/construct-rlve-antiderivative-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l5-s9/tests/check.py @@ -0,0 +1,107 @@ +"""Antiderivative check. The answer string is tokenised against a whitelist (x, integers, + - * / ** ( ) and a few +elementary functions) before sympy parses it, so no Python eval of untrusted text and no `integrate`/`Integral`.""" +import re +import signal + +import sympy +from sympy.parsing.sympy_parser import auto_number, parse_expr + +from run import Invalid + +x = sympy.Symbol("x") +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "exp": sympy.exp, "log": sympy.log, + "sqrt": sympy.sqrt, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "E": sympy.E, "pi": sympy.pi, "x": x} +TOK = re.compile(r"\s*(?:(\d+)|([A-Za-z]+)|(\*\*|[-+*/()]))") +NPTS = 40 + + +def safe_parse(s, max_len): + if not isinstance(s, str) or not s.strip(): + raise Invalid("F must be a non-empty string") + if len(s) > max_len: + raise Invalid("expression too long") + pos = 0 + while pos < len(s): + m = TOK.match(s, pos) + if not m or m.end() == pos: + if s[pos:].strip() == "": + break + raise Invalid(f"illegal character near position {pos}") + if m.group(1) and len(m.group(1)) > 12: + raise Invalid("integer literal too long") + if m.group(2) and m.group(2) not in FUNCS: + raise Invalid(f"unknown name {m.group(2)!r}") + pos = m.end() + try: + e = parse_expr(s, local_dict=dict(FUNCS), global_dict={"__builtins__": {}, "Integer": sympy.Integer}, + transformations=(auto_number,)) + except Invalid: + raise + except Exception as ex: + raise Invalid(f"cannot parse F: {type(ex).__name__}") + if not isinstance(e, sympy.Expr): + raise Invalid("F is not an expression") + if e.free_symbols - {x}: + raise Invalid("F may only contain the variable x") + return e + + +def _val(e, pt): + v = e.evalf(40, subs={x: pt}) + if not v.is_number or v.has(sympy.zoo, sympy.nan, sympy.oo, -sympy.oo): + return None + return v + + +class _Timeout(Exception): + pass + + +def _alarm(*_): + raise _Timeout() + + +def check(inst, ans): + old = None + try: + old = signal.signal(signal.SIGALRM, _alarm) + signal.alarm(40) + except ValueError: # not in main thread + old = None + try: + return _check(inst, ans) + except _Timeout: + raise Invalid("evaluation timed out") + except RecursionError: + raise Invalid("expression too deep") + finally: + if old is not None: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + + +def _check(inst, ans): + F = safe_parse(ans.get("F"), inst["max_len"]) + if sympy.count_ops(F) > inst["max_ops"]: + raise Invalid("expression too complex") + if any(isinstance(a, sympy.Rational) and max(abs(a.p), abs(a.q)) > 10 ** 12 for a in F.atoms(sympy.Rational)): + raise Invalid("numeric constants too large") + D = sympy.diff(F, x) + f = sympy.sympify(inst["f_prime"]) # trusted instance data + ok = 0 + for k in range(NPTS): + pt = sympy.Rational(2 * k + 1, NPTS // 2 * 2) * 2 - 2 + sympy.Rational(1, 997) + vf = _val(f, pt) + if vf is None: + continue + vd = _val(D, pt) + if vd is None: + continue + err = sympy.Abs(vd - vf).evalf(40) + if err > sympy.Float("1e-20", 40) * (1 + sympy.Abs(vf).evalf(40)): + raise Invalid(f"F'(x) != f(x) at x = {float(pt):.4f}") + ok += 1 + if ok < NPTS // 4: + raise Invalid("F' could not be compared with f on enough test points") + return None, {"points_checked": ok} diff --git a/tasks/construct-rlve-antiderivative-l5-s9/tests/instance.json b/tasks/construct-rlve-antiderivative-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bed753d864cca11843f5e056900275eb171aba56 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "log(x)*sin(x)*sin(2*x)/cos(x)**2 + 2*log(x)*cos(2*x)/cos(x) + sin(2*x)/(x*cos(x))", "max_ops": 48, "max_len": 920, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l5-s9/tests/run.py b/tasks/construct-rlve-antiderivative-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l5-s9/tests/test.sh b/tasks/construct-rlve-antiderivative-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-bezout-identity-l4-s3/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l4-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l4-s3/environment/instance.json b/tasks/construct-rlve-bezout-identity-l4-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2e616d678d97367e94678002389ed26888563e34 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l4-s3/environment/instance.json @@ -0,0 +1 @@ +{"A": [272, -588, 234, -202, 1586, -1768, 1696, -694], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l4-s3/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l4-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..52271fd6448895d76e035909c9c3af73f04ee3fe --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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": [3886, 1798, 1, 0, 0, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l4-s3/tests/check.py b/tasks/construct-rlve-bezout-identity-l4-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l4-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-l4-s3/tests/instance.json b/tasks/construct-rlve-bezout-identity-l4-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2e616d678d97367e94678002389ed26888563e34 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l4-s3/tests/instance.json @@ -0,0 +1 @@ +{"A": [272, -588, 234, -202, 1586, -1768, 1696, -694], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l4-s3/tests/run.py b/tasks/construct-rlve-bezout-identity-l4-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l4-s3/tests/test.sh b/tasks/construct-rlve-bezout-identity-l4-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l4-s4/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l4-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l4-s4/environment/instance.json b/tasks/construct-rlve-bezout-identity-l4-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cd4682bc22a1c5c5b2579edd610f5557fa3bf019 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l4-s4/environment/instance.json @@ -0,0 +1 @@ +{"A": [1046, 1569, -1046, 1046, -1046, -523, 450, 1569], "target": 1, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l4-s4/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l4-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..eab5be1531a14da7f8ea29d58ad1abda2686037e --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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, 0, 0, 0, 0, -37, -43, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l4-s4/tests/check.py b/tasks/construct-rlve-bezout-identity-l4-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l4-s4/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + X = int_list(ans.get("X"), len(A), name="X") + S = sum(a * x for a, x in zip(A, X)) + if S != inst["target"]: + raise Invalid(f"S = {S}, required {inst['target']}") + return None, {} diff --git a/tasks/construct-rlve-bezout-identity-l4-s4/tests/instance.json b/tasks/construct-rlve-bezout-identity-l4-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cd4682bc22a1c5c5b2579edd610f5557fa3bf019 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l4-s4/tests/instance.json @@ -0,0 +1 @@ +{"A": [1046, 1569, -1046, 1046, -1046, -523, 450, 1569], "target": 1, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l4-s4/tests/run.py b/tasks/construct-rlve-bezout-identity-l4-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l4-s4/tests/test.sh b/tasks/construct-rlve-bezout-identity-l4-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-construct-hack-interval-l3-s1/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l3-s1/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b7d0e0f9631d45ba25c6508dd32029b4bd0a937c --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"mod": 777790, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l3-s1/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..12ba0415c11c5c1f4113ed94d2b44b721afaa3a3 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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' +{"L": 27, "R": 39934} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l3-s1/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l3-s1/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l3-s1/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b7d0e0f9631d45ba25c6508dd32029b4bd0a937c --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"mod": 777790, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l3-s1/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l3-s1/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l3-s6/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l3-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l3-s6/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fe753311a8805298f4c33ac98ad390d52f44695f --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"mod": 674503, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l3-s6/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4bf2567d4832fc9130aa0214625ffd4bdc6b70cd --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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' +{"L": 52, "R": 35632} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l3-s6/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l3-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-l3-s6/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fe753311a8805298f4c33ac98ad390d52f44695f --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"mod": 674503, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l3-s6/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l3-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l3-s6/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l3-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l3-s8/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l3-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l3-s8/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l3-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..850596950e2b5ff0cfa2e28221c28b03387a83fa --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l3-s8/environment/instance.json @@ -0,0 +1 @@ +{"mod": 840967, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l3-s8/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l3-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..63da6dacf6f6c503734d04462e2609b85dfd170c --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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' +{"L": 3, "R": 43324} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l3-s8/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l3-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l3-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-l3-s8/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l3-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..850596950e2b5ff0cfa2e28221c28b03387a83fa --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l3-s8/tests/instance.json @@ -0,0 +1 @@ +{"mod": 840967, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l3-s8/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l3-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-construct-hack-interval-l3-s8/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l3-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-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-crt-l3-s0/environment/Dockerfile b/tasks/construct-rlve-crt-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l3-s0/environment/instance.json b/tasks/construct-rlve-crt-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..84b6ba2b454018e5ad32640c4e0b93ec8d27ea87 --- /dev/null +++ b/tasks/construct-rlve-crt-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"moduli": [755, 2493, 378, 1607], "residues": [8, 2045, 2, 1324], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l3-s0/solution/solve.sh b/tasks/construct-rlve-crt-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8c9d400de5ab175b4830b4a5a88f23b3e4560554 --- /dev/null +++ b/tasks/construct-rlve-crt-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' +{"x": 4538} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l3-s0/tests/check.py b/tasks/construct-rlve-crt-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l3-s0/tests/check.py @@ -0,0 +1,11 @@ +from run import Invalid, as_int + + +def check(inst, ans): + x = as_int(ans.get("x"), "x", lo=0) + if x.bit_length() > 20000: + raise Invalid("x is unreasonably large") + for a, b in zip(inst["residues"], inst["moduli"]): + if x % b != a: + raise Invalid(f"x mod {b} = {x % b}, need {a}") + return None, {} diff --git a/tasks/construct-rlve-crt-l3-s0/tests/instance.json b/tasks/construct-rlve-crt-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..84b6ba2b454018e5ad32640c4e0b93ec8d27ea87 --- /dev/null +++ b/tasks/construct-rlve-crt-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [755, 2493, 378, 1607], "residues": [8, 2045, 2, 1324], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l3-s0/tests/run.py b/tasks/construct-rlve-crt-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l3-s0/tests/test.sh b/tasks/construct-rlve-crt-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l3-s7/environment/Dockerfile b/tasks/construct-rlve-crt-l3-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l3-s7/environment/instance.json b/tasks/construct-rlve-crt-l3-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c82594b5daa5f83b0807e48c491f1d06742d9699 --- /dev/null +++ b/tasks/construct-rlve-crt-l3-s7/environment/instance.json @@ -0,0 +1 @@ +{"moduli": [1028, 646, 1592, 1829], "residues": [901, 637, 337, 100], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l3-s7/solution/solve.sh b/tasks/construct-rlve-crt-l3-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e0a8aba4b3aa2dc66bc928ed257976e0b51881b9 --- /dev/null +++ b/tasks/construct-rlve-crt-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' +{"x": 1929} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l3-s7/tests/check.py b/tasks/construct-rlve-crt-l3-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l3-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-l3-s7/tests/instance.json b/tasks/construct-rlve-crt-l3-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c82594b5daa5f83b0807e48c491f1d06742d9699 --- /dev/null +++ b/tasks/construct-rlve-crt-l3-s7/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [1028, 646, 1592, 1829], "residues": [901, 637, 337, 100], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l3-s7/tests/run.py b/tasks/construct-rlve-crt-l3-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l3-s7/tests/test.sh b/tasks/construct-rlve-crt-l3-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-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-distinct-subset-sum-permutation-l2-s0/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..26c078dbe85ac979447e85d0c953e0ebaa180e69 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"A": [12, 0, 13, 11, 2, 3, 4], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..da637b46ef22327402a82eda11d438371ed5a7d3 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"B": [13, 2, 0, 12, 3, 4, 11]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-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-l2-s0/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..26c078dbe85ac979447e85d0c953e0ebaa180e69 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"A": [12, 0, 13, 11, 2, 3, 4], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b50e657e937b2bf1b30d9dec6f126e5139630d11 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"A": [5, 10, 0, 12, 2, 4, 8], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5e873a36910432eafb42a461162d47d4ef3aaa5f --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"B": [8, 12, 2, 0, 4, 5, 10]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/tests/check.py @@ -0,0 +1,22 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + n = len(A) + B = int_list(ans.get("B"), n, name="B") + if Counter(B) != Counter(A): + raise Invalid("B is not a permutation of A") + d = [a - b for a, b in zip(A, B)] + # count subsets (including empty and full) with sum 0; the empty and full sets always qualify + ways = Counter({0: 1}) + for x in d: + nxt = Counter(ways) + for s, c in ways.items(): + nxt[s + x] += c + ways = nxt + if ways[0] != 2: + raise Invalid(f"{ways[0] - 2} non-empty proper subsets have equal sums in A and B") + return None, {} diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b50e657e937b2bf1b30d9dec6f126e5139630d11 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"A": [5, 10, 0, 12, 2, 4, 8], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l2-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l6-s8/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-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-distinct-subset-sum-permutation-l6-s8/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4d5dc7087404ee889effe9e7854866ed4a380ef5 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"A": [1, 9, 16, 43, 12, 0, 25, 8, 7, 5, 10, 34, 38, 39, 13, 24, 19, 42, 6, 14, 27, 37], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l6-s8/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cf1b1e8619e11651e9bc14d96e1fba58edc66f63 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-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' +{"B": [5, 10, 19, 0, 13, 1, 27, 9, 8, 6, 12, 37, 39, 42, 14, 25, 24, 43, 7, 16, 34, 38]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l6-s8/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l6-s8/tests/check.py @@ -0,0 +1,22 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + n = len(A) + B = int_list(ans.get("B"), n, name="B") + if Counter(B) != Counter(A): + raise Invalid("B is not a permutation of A") + d = [a - b for a, b in zip(A, B)] + # count subsets (including empty and full) with sum 0; the empty and full sets always qualify + ways = Counter({0: 1}) + for x in d: + nxt = Counter(ways) + for s, c in ways.items(): + nxt[s + x] += c + ways = nxt + if ways[0] != 2: + raise Invalid(f"{ways[0] - 2} non-empty proper subsets have equal sums in A and B") + return None, {} diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l6-s8/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4d5dc7087404ee889effe9e7854866ed4a380ef5 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"A": [1, 9, 16, 43, 12, 0, 25, 8, 7, 5, 10, 34, 38, 39, 13, 24, 19, 42, 6, 14, 27, 37], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l6-s8/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-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-distinct-subset-sum-permutation-l6-s8/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-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-even-degree-partition-l3-s9/environment/Dockerfile b/tasks/construct-rlve-even-degree-partition-l3-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l3-s9/environment/instance.json b/tasks/construct-rlve-even-degree-partition-l3-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3b96b6a9cdf28e22f257812261c2448fb9f40145 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l3-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 7], [0, 8], [0, 9], [0, 11], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 4], [3, 6], [3, 7], [3, 8], [3, 10], [4, 5], [4, 9], [4, 11], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [6, 7], [6, 8], [6, 9], [6, 10], [7, 8], [7, 9], [7, 10], [7, 11], [8, 10], [8, 11], [9, 11], [10, 11]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l3-s9/solution/solve.sh b/tasks/construct-rlve-even-degree-partition-l3-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..13f9fb9d31c2f25aad1cdeafb2f775ca5f651436 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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' +{"groups": [2, 2, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-even-degree-partition-l3-s9/tests/check.py b/tasks/construct-rlve-even-degree-partition-l3-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c7f0f71ea6d10264ececcc933b97a4a0e6eaf8e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l3-s9/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + g = int_list(ans.get("groups"), n, 1, 2, "groups") + deg = [0] * n + for u, v in inst["edges"]: + if g[u] == g[v]: + deg[u] += 1 + deg[v] += 1 + for v in range(n): + if deg[v] % 2: + raise Invalid(f"vertex {v} has {deg[v]} same-group neighbours") + return None, {} diff --git a/tasks/construct-rlve-even-degree-partition-l3-s9/tests/instance.json b/tasks/construct-rlve-even-degree-partition-l3-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3b96b6a9cdf28e22f257812261c2448fb9f40145 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l3-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 7], [0, 8], [0, 9], [0, 11], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 4], [3, 6], [3, 7], [3, 8], [3, 10], [4, 5], [4, 9], [4, 11], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [6, 7], [6, 8], [6, 9], [6, 10], [7, 8], [7, 9], [7, 10], [7, 11], [8, 10], [8, 11], [9, 11], [10, 11]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l3-s9/tests/run.py b/tasks/construct-rlve-even-degree-partition-l3-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l3-s9/tests/test.sh b/tasks/construct-rlve-even-degree-partition-l3-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-graph-isomorphism-l5-s3/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l5-s3/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..827055b9bed49204bfabd2e9ed659c7d3d01c0d6 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 26, "edges1": [[7, 11], [4, 22], [8, 17], [6, 24], [7, 21], [20, 25], [7, 15], [14, 21], [1, 17], [12, 15], [8, 15], [7, 10], [11, 12], [18, 25], [23, 24], [11, 23], [7, 23], [3, 15], [0, 10], [2, 8], [5, 25], [12, 25], [1, 11], [1, 13], [9, 25], [10, 20], [9, 20], [5, 10], [7, 12], [13, 15], [15, 23], [10, 24], [6, 23], [7, 17], [1, 6], [4, 12], [12, 22], [19, 21], [17, 22], [1, 5], [8, 25], [3, 9], [4, 23], [16, 24], [10, 15], [2, 4], [6, 8], [1, 24]], "edges2": [[6, 15], [6, 16], [0, 22], [7, 23], [5, 18], [18, 19], [16, 18], [12, 20], [6, 14], [12, 24], [8, 25], [10, 11], [0, 11], [18, 25], [9, 20], [15, 18], [2, 3], [13, 22], [5, 16], [14, 17], [5, 13], [16, 20], [5, 11], [11, 25], [1, 3], [1, 5], [6, 9], [0, 14], [11, 16], [12, 19], [16, 23], [5, 6], [11, 17], [12, 17], [2, 9], [1, 20], [19, 25], [21, 23], [12, 25], [4, 14], [15, 16], [1, 19], [2, 18], [12, 15], [1, 14], [5, 24], [2, 6], [14, 22]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l5-s3/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..03f51a187a7ea4e731fed571ffbedc48730f356c --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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' +{"p": [10, 12, 3, 13, 2, 17, 19, 16, 1, 22, 11, 15, 6, 24, 21, 5, 8, 20, 4, 7, 0, 23, 9, 18, 25, 14]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l5-s3/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l5-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-l5-s3/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..827055b9bed49204bfabd2e9ed659c7d3d01c0d6 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 26, "edges1": [[7, 11], [4, 22], [8, 17], [6, 24], [7, 21], [20, 25], [7, 15], [14, 21], [1, 17], [12, 15], [8, 15], [7, 10], [11, 12], [18, 25], [23, 24], [11, 23], [7, 23], [3, 15], [0, 10], [2, 8], [5, 25], [12, 25], [1, 11], [1, 13], [9, 25], [10, 20], [9, 20], [5, 10], [7, 12], [13, 15], [15, 23], [10, 24], [6, 23], [7, 17], [1, 6], [4, 12], [12, 22], [19, 21], [17, 22], [1, 5], [8, 25], [3, 9], [4, 23], [16, 24], [10, 15], [2, 4], [6, 8], [1, 24]], "edges2": [[6, 15], [6, 16], [0, 22], [7, 23], [5, 18], [18, 19], [16, 18], [12, 20], [6, 14], [12, 24], [8, 25], [10, 11], [0, 11], [18, 25], [9, 20], [15, 18], [2, 3], [13, 22], [5, 16], [14, 17], [5, 13], [16, 20], [5, 11], [11, 25], [1, 3], [1, 5], [6, 9], [0, 14], [11, 16], [12, 19], [16, 23], [5, 6], [11, 17], [12, 17], [2, 9], [1, 20], [19, 25], [21, 23], [12, 25], [4, 14], [15, 16], [1, 19], [2, 18], [12, 15], [1, 14], [5, 24], [2, 6], [14, 22]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l5-s3/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l5-s3/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l5-s4/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l5-s4/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c4d1396095f3b644138ea7a89cd4a4116696ebf0 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 26, "edges1": [[18, 19], [20, 23], [11, 23], [4, 14], [15, 17], [24, 25], [10, 19], [17, 22], [14, 23], [12, 21], [5, 8], [0, 24], [10, 20], [11, 13], [3, 20], [3, 22], [0, 3], [0, 17], [15, 20], [20, 22], [2, 9], [20, 21], [0, 8], [5, 10], [12, 20], [9, 16], [3, 17], [0, 10], [17, 19], [12, 24], [8, 12], [3, 14], [0, 9], [1, 5], [4, 22], [11, 20], [1, 2], [13, 21], [2, 19], [17, 21], [11, 21], [18, 20], [21, 24], [3, 6], [10, 13], [14, 17], [6, 15], [3, 5], [15, 25], [9, 17], [14, 21], [13, 19], [4, 5], [5, 18], [10, 22], [0, 12], [7, 19], [19, 22], [18, 24], [9, 20], [1, 15], [2, 18], [14, 16], [17, 25], [8, 13], [8, 22], [9, 15], [10, 11], [17, 20], [10, 18], [2, 13], [1, 24], [7, 20], [7, 23], [7, 18], [8, 15], [13, 24], [14, 24], [12, 19], [14, 15], [6, 12], [6, 10], [2, 16], [4, 18], [1, 17], [14, 22], [7, 25], [19, 25], [14, 19], [10, 12], [19, 24], [2, 11], [0, 2], [0, 7], [6, 22], [16, 21], [2, 24], [9, 22], [16, 23], [9, 24], [0, 5], [4, 6], [2, 3], [19, 23], [1, 22], [0, 15], [5, 11], [1, 14], [1, 19], [0, 20], [1, 20], [5, 19], [15, 19]], "edges2": [[7, 13], [10, 17], [9, 17], [10, 14], [9, 18], [7, 12], [5, 8], [7, 14], [18, 22], [6, 12], [15, 25], [6, 21], [11, 19], [0, 9], [18, 21], [8, 20], [8, 18], [12, 25], [3, 8], [19, 22], [12, 23], [7, 18], [0, 6], [9, 20], [4, 18], [17, 18], [2, 23], [9, 13], [16, 20], [2, 25], [0, 11], [4, 10], [13, 15], [4, 7], [12, 14], [4, 20], [10, 15], [0, 16], [16, 22], [13, 22], [9, 23], [4, 9], [2, 11], [13, 24], [4, 13], [8, 25], [4, 24], [12, 21], [10, 12], [3, 22], [9, 14], [0, 10], [13, 16], [1, 21], [4, 6], [6, 10], [7, 17], [1, 7], [12, 20], [11, 18], [6, 8], [21, 25], [21, 23], [10, 13], [14, 16], [2, 12], [1, 15], [2, 24], [10, 24], [3, 18], [13, 18], [5, 24], [6, 22], [6, 14], [15, 20], [1, 24], [8, 21], [3, 17], [11, 20], [15, 24], [1, 5], [14, 24], [11, 21], [6, 23], [9, 11], [18, 24], [18, 20], [21, 24], [10, 18], [0, 13], [6, 24], [19, 21], [4, 25], [18, 25], [9, 12], [5, 13], [18, 23], [3, 6], [5, 25], [19, 25], [0, 19], [6, 19], [0, 23], [14, 20], [3, 12], [2, 7], [8, 9], [6, 7], [6, 15], [1, 23], [7, 10], [12, 15], [19, 20]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l5-s4/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..66fef4244ed5a04cc7e9fe57ab8d90da47f6296f --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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' +{"p": [12, 4, 20, 15, 5, 25, 1, 3, 2, 14, 21, 19, 23, 11, 13, 7, 16, 10, 8, 18, 6, 0, 24, 22, 9, 17]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l5-s4/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l5-s4/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("p"), n, 0, n - 1, "p") + if len(set(p)) != n: + raise Invalid("p is not a permutation") + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + img = {(min(p[u], p[v]), max(p[u], p[v])) for u, v in inst["edges1"]} + if img != e2: + raise Invalid(f"{len(img - e2)} edges of G1 are not mapped onto edges of G2") + return None, {} diff --git a/tasks/construct-rlve-graph-isomorphism-l5-s4/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c4d1396095f3b644138ea7a89cd4a4116696ebf0 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 26, "edges1": [[18, 19], [20, 23], [11, 23], [4, 14], [15, 17], [24, 25], [10, 19], [17, 22], [14, 23], [12, 21], [5, 8], [0, 24], [10, 20], [11, 13], [3, 20], [3, 22], [0, 3], [0, 17], [15, 20], [20, 22], [2, 9], [20, 21], [0, 8], [5, 10], [12, 20], [9, 16], [3, 17], [0, 10], [17, 19], [12, 24], [8, 12], [3, 14], [0, 9], [1, 5], [4, 22], [11, 20], [1, 2], [13, 21], [2, 19], [17, 21], [11, 21], [18, 20], [21, 24], [3, 6], [10, 13], [14, 17], [6, 15], [3, 5], [15, 25], [9, 17], [14, 21], [13, 19], [4, 5], [5, 18], [10, 22], [0, 12], [7, 19], [19, 22], [18, 24], [9, 20], [1, 15], [2, 18], [14, 16], [17, 25], [8, 13], [8, 22], [9, 15], [10, 11], [17, 20], [10, 18], [2, 13], [1, 24], [7, 20], [7, 23], [7, 18], [8, 15], [13, 24], [14, 24], [12, 19], [14, 15], [6, 12], [6, 10], [2, 16], [4, 18], [1, 17], [14, 22], [7, 25], [19, 25], [14, 19], [10, 12], [19, 24], [2, 11], [0, 2], [0, 7], [6, 22], [16, 21], [2, 24], [9, 22], [16, 23], [9, 24], [0, 5], [4, 6], [2, 3], [19, 23], [1, 22], [0, 15], [5, 11], [1, 14], [1, 19], [0, 20], [1, 20], [5, 19], [15, 19]], "edges2": [[7, 13], [10, 17], [9, 17], [10, 14], [9, 18], [7, 12], [5, 8], [7, 14], [18, 22], [6, 12], [15, 25], [6, 21], [11, 19], [0, 9], [18, 21], [8, 20], [8, 18], [12, 25], [3, 8], [19, 22], [12, 23], [7, 18], [0, 6], [9, 20], [4, 18], [17, 18], [2, 23], [9, 13], [16, 20], [2, 25], [0, 11], [4, 10], [13, 15], [4, 7], [12, 14], [4, 20], [10, 15], [0, 16], [16, 22], [13, 22], [9, 23], [4, 9], [2, 11], [13, 24], [4, 13], [8, 25], [4, 24], [12, 21], [10, 12], [3, 22], [9, 14], [0, 10], [13, 16], [1, 21], [4, 6], [6, 10], [7, 17], [1, 7], [12, 20], [11, 18], [6, 8], [21, 25], [21, 23], [10, 13], [14, 16], [2, 12], [1, 15], [2, 24], [10, 24], [3, 18], [13, 18], [5, 24], [6, 22], [6, 14], [15, 20], [1, 24], [8, 21], [3, 17], [11, 20], [15, 24], [1, 5], [14, 24], [11, 21], [6, 23], [9, 11], [18, 24], [18, 20], [21, 24], [10, 18], [0, 13], [6, 24], [19, 21], [4, 25], [18, 25], [9, 12], [5, 13], [18, 23], [3, 6], [5, 25], [19, 25], [0, 19], [6, 19], [0, 23], [14, 20], [3, 12], [2, 7], [8, 9], [6, 7], [6, 15], [1, 23], [7, 10], [12, 15], [19, 20]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l5-s4/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l5-s4/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-grid-parity-construction-l5-s3/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l5-s3/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f122e65f5d2a7196f18662938a3cd2a8aaeebbf8 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["1111000100000", "1100100100000", "0001110010000"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l5-s3/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c018fd49779c50559761b14536d38a6289d109d5 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["0110011000000", "0110100000000", "0010001100000"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l5-s3/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l5-s3/tests/check.py @@ -0,0 +1,22 @@ +from run import Invalid + + +def check(inst, ans): + P = inst["parity"] + N, M = len(P), len(P[0]) + G = ans.get("grid") + if not isinstance(G, list) or len(G) != N: + raise Invalid(f"grid must be a list of {N} strings") + for r in G: + if not isinstance(r, str) or len(r) != M or set(r) - {"0", "1"}: + raise Invalid(f"each row must be a string of {M} characters '0'/'1'") + for i in range(N): + for j in range(M): + v = int(G[i][j]) + for di, dj in ((-1, 0), (1, 0), (0, -1), (0, 1)): + a, b = i + di, j + dj + if 0 <= a < N and 0 <= b < M: + v ^= int(G[a][b]) + if v != int(P[i][j]): + raise Invalid(f"parity mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-grid-parity-construction-l5-s3/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f122e65f5d2a7196f18662938a3cd2a8aaeebbf8 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["1111000100000", "1100100100000", "0001110010000"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l5-s3/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l5-s3/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l5-s4/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l5-s4/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cb4a53dbe04ff7edbf0e03987bf05d3257406b2f --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["01101001101001", "00110010001011"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l5-s4/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c4cf8ff481954e595979dfcebcc5426036f0a674 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["01101001100111", "11100111110011"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l5-s4/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l5-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-l5-s4/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cb4a53dbe04ff7edbf0e03987bf05d3257406b2f --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["01101001101001", "00110010001011"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l5-s4/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l5-s4/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-imp-party-l2-s3/environment/Dockerfile b/tasks/construct-rlve-imp-party-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l2-s3/environment/instance.json b/tasks/construct-rlve-imp-party-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cecebed38dc972a568251cfd12f865c8bd5bb8d5 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 5, "edges": [[1, 2], [1, 4], [1, 6], [1, 7], [1, 8], [1, 9], [1, 11], [1, 12], [1, 14], [2, 4], [2, 6], [2, 7], [2, 8], [2, 9], [2, 11], [2, 12], [2, 14], [4, 6], [4, 7], [4, 8], [4, 9], [4, 11], [4, 12], [4, 14], [6, 7], [6, 8], [6, 9], [6, 11], [6, 12], [6, 14], [7, 8], [7, 9], [7, 11], [7, 12], [7, 14], [8, 9], [8, 11], [8, 12], [8, 14], [9, 11], [9, 12], [9, 14], [11, 12], [11, 14], [12, 14]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l2-s3/solution/solve.sh b/tasks/construct-rlve-imp-party-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ddf4ad925751366466f30d15b0bc35ae2dda87ca --- /dev/null +++ b/tasks/construct-rlve-imp-party-l2-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [2, 4, 8, 11, 12]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l2-s3/tests/check.py b/tasks/construct-rlve-imp-party-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l2-s3/tests/check.py @@ -0,0 +1,14 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + c = int_list(ans.get("clique"), n, 0, 3 * n - 1, "clique") + if len(set(c)) != n: + raise Invalid("vertices must be distinct") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(n): + for j in range(i + 1, n): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-imp-party-l2-s3/tests/instance.json b/tasks/construct-rlve-imp-party-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cecebed38dc972a568251cfd12f865c8bd5bb8d5 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 5, "edges": [[1, 2], [1, 4], [1, 6], [1, 7], [1, 8], [1, 9], [1, 11], [1, 12], [1, 14], [2, 4], [2, 6], [2, 7], [2, 8], [2, 9], [2, 11], [2, 12], [2, 14], [4, 6], [4, 7], [4, 8], [4, 9], [4, 11], [4, 12], [4, 14], [6, 7], [6, 8], [6, 9], [6, 11], [6, 12], [6, 14], [7, 8], [7, 9], [7, 11], [7, 12], [7, 14], [8, 9], [8, 11], [8, 12], [8, 14], [9, 11], [9, 12], [9, 14], [11, 12], [11, 14], [12, 14]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l2-s3/tests/run.py b/tasks/construct-rlve-imp-party-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l2-s3/tests/test.sh b/tasks/construct-rlve-imp-party-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l2-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-imp-party-l2-s4/environment/Dockerfile b/tasks/construct-rlve-imp-party-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l2-s4/environment/instance.json b/tasks/construct-rlve-imp-party-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4b1f6c1255ec74757b91dd867bc27da36c0d3938 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 5, "edges": [[0, 1], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 10], [0, 11], [0, 13], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [2, 3], [2, 5], [2, 6], [2, 7], [2, 8], [2, 11], [2, 13], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [5, 6], [5, 7], [5, 8], [5, 10], [5, 11], [5, 13], [5, 14], [6, 7], [6, 8], [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, 13], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [11, 14], [12, 13], [13, 14]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l2-s4/solution/solve.sh b/tasks/construct-rlve-imp-party-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..28945402eb455d7a3918c1867b2b461b63b5340d --- /dev/null +++ b/tasks/construct-rlve-imp-party-l2-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [1, 3, 4, 8, 11]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l2-s4/tests/check.py b/tasks/construct-rlve-imp-party-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l2-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-l2-s4/tests/instance.json b/tasks/construct-rlve-imp-party-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4b1f6c1255ec74757b91dd867bc27da36c0d3938 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 5, "edges": [[0, 1], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 10], [0, 11], [0, 13], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [2, 3], [2, 5], [2, 6], [2, 7], [2, 8], [2, 11], [2, 13], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [5, 6], [5, 7], [5, 8], [5, 10], [5, 11], [5, 13], [5, 14], [6, 7], [6, 8], [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, 13], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [11, 14], [12, 13], [13, 14]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l2-s4/tests/run.py b/tasks/construct-rlve-imp-party-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l2-s4/tests/test.sh b/tasks/construct-rlve-imp-party-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l6-s2/environment/Dockerfile b/tasks/construct-rlve-imp-party-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l6-s2/environment/instance.json b/tasks/construct-rlve-imp-party-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e129c30a80b83a737018e539d7645f955f43c508 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 25, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29], [0, 31], [0, 32], [0, 33], [0, 34], [0, 35], [0, 37], [0, 38], [0, 39], [0, 40], [0, 41], [0, 42], [0, 43], [0, 44], [0, 45], [0, 46], [0, 47], [0, 49], [0, 50], [0, 51], [0, 52], [0, 53], [0, 54], [0, 55], [0, 56], [0, 57], [0, 58], [0, 59], [0, 60], [0, 61], [0, 62], [0, 63], [0, 65], [0, 66], [0, 67], [0, 68], [0, 69], [0, 70], [0, 71], [0, 72], [0, 73], [0, 74], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 9], [1, 10], [1, 11], [1, 12], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 20], [1, 21], [1, 22], [1, 23], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 42], [1, 44], [1, 45], [1, 46], [1, 47], [1, 48], [1, 49], [1, 50], [1, 51], [1, 52], [1, 53], [1, 54], [1, 55], [1, 56], [1, 57], [1, 58], [1, 59], [1, 60], [1, 61], [1, 62], [1, 63], [1, 64], [1, 65], [1, 66], [1, 67], [1, 68], [1, 69], [1, 71], [1, 72], [1, 73], [1, 74], [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, 16], [2, 17], [2, 18], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 26], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 33], [2, 34], [2, 35], [2, 38], [2, 39], [2, 40], [2, 41], [2, 42], [2, 43], [2, 45], [2, 46], [2, 47], [2, 48], [2, 49], [2, 50], [2, 51], [2, 52], [2, 53], [2, 54], [2, 56], [2, 57], [2, 58], [2, 59], [2, 60], [2, 61], [2, 62], [2, 63], [2, 65], [2, 66], [2, 67], [2, 68], [2, 69], [2, 70], [2, 71], [2, 73], [2, 74], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [3, 40], [3, 41], [3, 42], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 51], [3, 52], [3, 53], [3, 54], [3, 56], [3, 57], [3, 58], [3, 59], [3, 60], [3, 61], [3, 62], [3, 63], [3, 64], [3, 65], [3, 66], [3, 67], [3, 68], [3, 69], [3, 70], [3, 71], [3, 72], [3, 73], [3, 74], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 21], [4, 22], [4, 23], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 42], [4, 43], [4, 45], [4, 46], [4, 47], [4, 48], [4, 49], [4, 50], [4, 51], [4, 52], [4, 53], [4, 54], [4, 55], [4, 56], [4, 57], [4, 58], [4, 59], [4, 60], [4, 61], [4, 62], [4, 63], [4, 64], [4, 65], [4, 66], [4, 67], [4, 68], [4, 69], [4, 70], [4, 71], [4, 72], [4, 73], [4, 74], [5, 6], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 28], [5, 29], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [5, 37], [5, 38], [5, 39], [5, 40], [5, 41], [5, 42], [5, 43], [5, 44], [5, 45], [5, 47], [5, 48], [5, 49], [5, 50], [5, 51], [5, 52], [5, 53], [5, 54], [5, 55], [5, 56], [5, 57], [5, 58], [5, 59], [5, 60], [5, 61], [5, 62], [5, 63], [5, 64], [5, 65], [5, 66], [5, 67], [5, 68], [5, 69], [5, 70], [5, 71], [5, 72], [5, 73], [5, 74], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 28], [6, 29], [6, 31], [6, 32], [6, 33], [6, 34], [6, 35], [6, 37], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 44], [6, 45], [6, 46], [6, 47], [6, 48], [6, 49], [6, 50], [6, 51], [6, 52], [6, 53], [6, 54], [6, 55], [6, 56], [6, 57], [6, 58], [6, 59], [6, 60], [6, 61], [6, 62], [6, 64], [6, 65], [6, 66], [6, 67], [6, 68], [6, 69], [6, 70], [6, 71], [6, 72], [6, 73], [6, 74], [7, 10], [7, 11], [7, 14], [7, 17], [7, 21], [7, 31], [7, 33], [7, 34], [7, 35], [7, 38], [7, 39], [7, 42], [7, 45], [7, 47], [7, 49], [7, 52], [7, 53], [7, 54], [7, 57], [7, 58], [7, 59], [7, 60], [7, 65], [7, 67], [7, 68], [7, 71], [7, 74], [8, 9], [8, 10], [8, 14], [8, 16], [8, 17], [8, 21], [8, 22], [8, 26], [8, 27], [8, 29], [8, 31], [8, 33], [8, 34], [8, 35], [8, 38], [8, 40], [8, 42], [8, 45], [8, 47], [8, 49], [8, 50], [8, 51], [8, 52], [8, 53], [8, 54], [8, 56], [8, 58], [8, 61], [8, 67], [8, 68], [8, 71], [8, 73], [8, 74], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 35], [9, 36], [9, 37], [9, 38], [9, 39], [9, 40], [9, 41], [9, 42], [9, 44], [9, 45], [9, 46], [9, 47], [9, 48], [9, 49], [9, 50], [9, 51], [9, 52], [9, 53], [9, 54], [9, 55], [9, 56], [9, 57], [9, 58], [9, 59], [9, 60], [9, 61], [9, 62], [9, 64], [9, 65], [9, 66], [9, 67], [9, 68], [9, 69], [9, 70], [9, 71], [9, 73], [9, 74], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 25], [10, 26], [10, 27], [10, 28], [10, 29], [10, 30], [10, 31], [10, 32], [10, 33], [10, 34], [10, 35], [10, 36], [10, 37], [10, 38], [10, 39], [10, 40], [10, 41], [10, 42], [10, 43], [10, 44], [10, 45], [10, 46], [10, 47], [10, 48], [10, 49], [10, 50], [10, 51], [10, 52], [10, 53], [10, 54], [10, 55], [10, 56], [10, 57], [10, 58], [10, 59], [10, 60], [10, 61], [10, 63], [10, 64], [10, 65], [10, 66], [10, 67], [10, 68], [10, 69], [10, 70], [10, 71], [10, 73], [10, 74], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 34], [11, 35], [11, 36], [11, 37], [11, 38], [11, 39], [11, 40], [11, 41], [11, 42], [11, 43], [11, 44], [11, 45], [11, 46], [11, 47], [11, 49], [11, 50], [11, 51], [11, 52], [11, 53], [11, 54], [11, 55], [11, 56], [11, 57], [11, 58], [11, 59], [11, 60], [11, 61], [11, 62], [11, 63], [11, 64], [11, 65], [11, 66], [11, 67], [11, 68], [11, 69], [11, 71], [11, 72], [11, 73], [11, 74], [12, 14], [12, 16], [12, 17], [12, 21], [12, 22], [12, 26], [12, 27], [12, 28], [12, 33], [12, 34], [12, 35], [12, 41], [12, 45], [12, 47], [12, 49], [12, 50], [12, 53], [12, 54], [12, 56], [12, 57], [12, 58], [12, 60], [12, 61], [12, 65], [12, 66], [12, 67], [12, 68], [12, 74], [13, 14], [13, 16], [13, 17], [13, 21], [13, 22], [13, 23], [13, 26], [13, 27], [13, 28], [13, 29], [13, 31], [13, 33], [13, 34], [13, 35], [13, 38], [13, 39], [13, 40], [13, 41], [13, 42], [13, 45], [13, 47], [13, 49], [13, 50], [13, 51], [13, 52], [13, 53], [13, 54], [13, 56], [13, 57], [13, 58], [13, 60], [13, 65], [13, 66], [13, 67], [13, 68], [13, 71], [13, 73], [13, 74], [14, 15], [14, 16], [14, 17], [14, 18], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [14, 36], [14, 37], [14, 38], [14, 39], [14, 40], [14, 41], [14, 42], [14, 43], [14, 44], [14, 45], [14, 46], [14, 47], [14, 49], [14, 50], [14, 51], [14, 52], [14, 53], [14, 54], [14, 55], [14, 56], [14, 57], [14, 58], [14, 59], [14, 60], [14, 61], [14, 62], [14, 63], [14, 64], [14, 65], [14, 66], [14, 67], [14, 68], [14, 69], [14, 70], [14, 71], [14, 73], [14, 74], [15, 16], [15, 21], [15, 22], [15, 23], [15, 26], [15, 27], [15, 28], [15, 29], [15, 31], [15, 34], [15, 38], [15, 39], [15, 40], [15, 41], [15, 42], [15, 45], [15, 47], [15, 49], [15, 50], [15, 51], [15, 52], [15, 53], [15, 54], [15, 56], [15, 57], [15, 59], [15, 60], [15, 61], [15, 65], [15, 66], [15, 67], [15, 68], [15, 73], [15, 74], [16, 17], [16, 19], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 31], [16, 32], [16, 33], [16, 34], [16, 35], [16, 37], [16, 38], [16, 39], [16, 40], [16, 41], [16, 42], [16, 43], [16, 45], [16, 46], [16, 47], [16, 48], [16, 49], [16, 50], [16, 51], [16, 52], [16, 53], [16, 54], [16, 55], [16, 56], [16, 57], [16, 58], [16, 59], [16, 60], [16, 61], [16, 62], [16, 64], [16, 65], [16, 66], [16, 67], [16, 68], [16, 69], [16, 70], [16, 71], [16, 73], [16, 74], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [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, 39], [17, 40], [17, 41], [17, 42], [17, 43], [17, 44], [17, 45], [17, 47], [17, 49], [17, 50], [17, 51], [17, 52], [17, 53], [17, 54], [17, 55], [17, 56], [17, 57], [17, 58], [17, 59], [17, 60], [17, 61], [17, 62], [17, 63], [17, 64], [17, 65], [17, 66], [17, 67], [17, 68], [17, 70], [17, 71], [17, 72], [17, 73], [17, 74], [18, 21], [18, 22], [18, 23], [18, 28], [18, 29], [18, 33], [18, 34], [18, 35], [18, 38], [18, 42], [18, 45], [18, 47], [18, 49], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [18, 56], [18, 57], [18, 58], [18, 59], [18, 60], [18, 61], [18, 66], [18, 67], [18, 68], [18, 71], [18, 73], [18, 74], [19, 21], [19, 23], [19, 26], [19, 27], [19, 28], [19, 29], [19, 31], [19, 33], [19, 34], [19, 38], [19, 39], [19, 40], [19, 42], [19, 47], [19, 49], [19, 51], [19, 52], [19, 54], [19, 56], [19, 58], [19, 59], [19, 60], [19, 65], [19, 66], [19, 67], [19, 68], [19, 73], [19, 74], [20, 21], [20, 22], [20, 26], [20, 27], [20, 28], [20, 31], [20, 33], [20, 34], [20, 35], [20, 38], [20, 39], [20, 40], [20, 41], [20, 42], [20, 45], [20, 49], [20, 50], [20, 51], [20, 52], [20, 53], [20, 56], [20, 57], [20, 58], [20, 59], [20, 60], [20, 61], [20, 65], [20, 66], [20, 67], [20, 68], [20, 71], [20, 73], [21, 22], [21, 23], [21, 24], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 33], [21, 34], [21, 35], [21, 36], [21, 37], [21, 38], [21, 39], [21, 40], [21, 41], [21, 42], [21, 43], [21, 44], [21, 45], [21, 46], [21, 47], [21, 48], [21, 49], [21, 50], [21, 51], [21, 52], [21, 53], [21, 54], [21, 55], [21, 56], [21, 57], [21, 58], [21, 59], [21, 60], [21, 61], [21, 63], [21, 64], [21, 65], [21, 66], [21, 67], [21, 68], [21, 70], [21, 71], [21, 72], [21, 73], [21, 74], [22, 23], [22, 25], [22, 26], [22, 27], [22, 28], [22, 29], [22, 30], [22, 31], [22, 32], [22, 33], [22, 34], [22, 35], [22, 36], [22, 37], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 43], [22, 44], [22, 45], [22, 47], [22, 48], [22, 49], [22, 50], [22, 51], [22, 52], [22, 53], [22, 54], [22, 55], [22, 56], [22, 57], [22, 58], [22, 59], [22, 60], [22, 61], [22, 62], [22, 64], [22, 65], [22, 66], [22, 67], [22, 68], [22, 69], [22, 70], [22, 71], [22, 72], [22, 73], [22, 74], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [23, 36], [23, 37], [23, 38], [23, 39], [23, 40], [23, 41], [23, 42], [23, 43], [23, 45], [23, 46], [23, 47], [23, 49], [23, 50], [23, 51], [23, 52], [23, 53], [23, 54], [23, 55], [23, 56], [23, 57], [23, 58], [23, 59], [23, 60], [23, 61], [23, 62], [23, 63], [23, 65], [23, 66], [23, 67], [23, 68], [23, 69], [23, 71], [23, 73], [23, 74], [24, 27], [24, 28], [24, 29], [24, 31], [24, 33], [24, 34], [24, 35], [24, 38], [24, 39], [24, 41], [24, 42], [24, 45], [24, 49], [24, 50], [24, 52], [24, 53], [24, 54], [24, 56], [24, 58], [24, 59], [24, 60], [24, 65], [24, 66], [24, 67], [24, 68], [24, 71], [24, 73], [25, 26], [25, 27], [25, 28], [25, 29], [25, 31], [25, 33], [25, 35], [25, 38], [25, 39], [25, 40], [25, 42], [25, 45], [25, 47], [25, 49], [25, 50], [25, 52], [25, 53], [25, 54], [25, 56], [25, 57], [25, 59], [25, 65], [25, 66], [25, 68], [25, 71], [25, 73], [25, 74], [26, 27], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [26, 36], [26, 37], [26, 38], [26, 39], [26, 40], [26, 41], [26, 42], [26, 43], [26, 45], [26, 46], [26, 47], [26, 49], [26, 50], [26, 51], [26, 52], [26, 53], [26, 54], [26, 55], [26, 56], [26, 57], [26, 58], [26, 59], [26, 60], [26, 61], [26, 62], [26, 63], [26, 64], [26, 65], [26, 66], [26, 67], [26, 68], [26, 69], [26, 71], [26, 72], [26, 73], [26, 74], [27, 28], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 34], [27, 35], [27, 36], [27, 37], [27, 38], [27, 39], [27, 40], [27, 41], [27, 42], [27, 43], [27, 44], [27, 45], [27, 46], [27, 47], [27, 49], [27, 50], [27, 51], [27, 52], [27, 53], [27, 54], [27, 55], [27, 56], [27, 57], [27, 58], [27, 59], [27, 60], [27, 61], [27, 62], [27, 63], [27, 64], [27, 65], [27, 66], [27, 67], [27, 68], [27, 70], [27, 71], [27, 72], [27, 73], [27, 74], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [28, 36], [28, 38], [28, 39], [28, 40], [28, 41], [28, 42], [28, 43], [28, 44], [28, 45], [28, 46], [28, 47], [28, 48], [28, 49], [28, 50], [28, 51], [28, 52], [28, 53], [28, 54], [28, 55], [28, 56], [28, 57], [28, 58], [28, 59], [28, 60], [28, 61], [28, 62], [28, 63], [28, 64], [28, 65], [28, 66], [28, 67], [28, 68], [28, 69], [28, 71], [28, 72], [28, 73], [28, 74], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 35], [29, 36], [29, 37], [29, 38], [29, 39], [29, 40], [29, 41], [29, 42], [29, 43], [29, 44], [29, 45], [29, 46], [29, 47], [29, 48], [29, 49], [29, 50], [29, 51], [29, 52], [29, 53], [29, 54], [29, 55], [29, 56], [29, 57], [29, 58], [29, 59], [29, 60], [29, 61], [29, 62], [29, 64], [29, 65], [29, 66], [29, 67], [29, 68], [29, 70], [29, 71], [29, 72], [29, 73], [29, 74], [30, 31], [30, 33], [30, 34], [30, 35], [30, 38], [30, 39], [30, 40], [30, 41], [30, 42], [30, 45], [30, 47], [30, 49], [30, 50], [30, 51], [30, 52], [30, 53], [30, 54], [30, 57], [30, 58], [30, 59], [30, 60], [30, 61], [30, 65], [30, 66], [30, 67], [30, 68], [30, 71], [30, 73], [30, 74], [31, 32], [31, 33], [31, 34], [31, 35], [31, 38], [31, 39], [31, 40], [31, 41], [31, 42], [31, 43], [31, 44], [31, 45], [31, 46], [31, 47], [31, 48], [31, 49], [31, 50], [31, 51], [31, 52], [31, 53], [31, 54], [31, 55], [31, 56], [31, 57], [31, 58], [31, 59], [31, 60], [31, 61], [31, 62], [31, 63], [31, 64], [31, 65], [31, 66], [31, 67], [31, 68], [31, 69], [31, 70], [31, 71], [31, 72], [31, 73], [31, 74], [32, 33], [32, 34], [32, 35], [32, 38], [32, 39], [32, 42], [32, 45], [32, 47], [32, 49], [32, 50], [32, 51], [32, 52], [32, 53], [32, 56], [32, 57], [32, 59], [32, 60], [32, 61], [32, 65], [32, 66], [32, 67], [32, 68], [32, 71], [32, 73], [32, 74], [33, 34], [33, 35], [33, 36], [33, 37], [33, 38], [33, 39], [33, 40], [33, 41], [33, 42], [33, 44], [33, 45], [33, 46], [33, 47], [33, 49], [33, 50], [33, 51], [33, 52], [33, 53], [33, 54], [33, 55], [33, 56], [33, 57], [33, 58], [33, 59], [33, 60], [33, 61], [33, 62], [33, 63], [33, 64], [33, 65], [33, 66], [33, 67], [33, 68], [33, 69], [33, 70], [33, 71], [33, 72], [33, 73], [33, 74], [34, 35], [34, 36], [34, 37], [34, 38], [34, 39], [34, 40], [34, 41], [34, 42], [34, 43], [34, 44], [34, 45], [34, 46], [34, 47], [34, 48], [34, 49], [34, 50], [34, 51], [34, 52], [34, 53], [34, 54], [34, 55], [34, 56], [34, 57], [34, 58], [34, 59], [34, 60], [34, 61], [34, 62], [34, 63], [34, 64], [34, 65], [34, 66], [34, 67], [34, 68], [34, 69], [34, 70], [34, 71], [34, 72], [34, 73], [34, 74], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 42], [35, 43], [35, 44], [35, 45], [35, 46], [35, 47], [35, 49], [35, 50], [35, 51], [35, 52], [35, 53], [35, 54], [35, 55], [35, 56], [35, 57], [35, 58], [35, 59], [35, 60], [35, 61], [35, 62], [35, 63], [35, 64], [35, 65], [35, 66], [35, 67], [35, 68], [35, 69], [35, 70], [35, 71], [35, 72], [35, 73], [35, 74], [36, 38], [36, 39], [36, 41], [36, 42], [36, 47], [36, 49], [36, 50], [36, 51], [36, 52], [36, 53], [36, 54], [36, 56], [36, 57], [36, 59], [36, 60], [36, 61], [36, 65], [36, 66], [36, 68], [36, 71], [36, 73], [36, 74], [37, 39], [37, 45], [37, 47], [37, 49], [37, 50], [37, 51], [37, 52], [37, 53], [37, 54], [37, 56], [37, 57], [37, 58], [37, 60], [37, 61], [37, 66], [37, 67], [37, 68], [37, 71], [37, 74], [38, 39], [38, 40], [38, 41], [38, 42], [38, 43], [38, 44], [38, 45], [38, 46], [38, 47], [38, 49], [38, 50], [38, 51], [38, 52], [38, 53], [38, 54], [38, 56], [38, 57], [38, 58], [38, 59], [38, 60], [38, 61], [38, 62], [38, 63], [38, 64], [38, 65], [38, 66], [38, 67], [38, 68], [38, 70], [38, 71], [38, 72], [38, 73], [38, 74], [39, 40], [39, 41], [39, 42], [39, 44], [39, 45], [39, 46], [39, 47], [39, 49], [39, 50], [39, 51], [39, 52], [39, 53], [39, 54], [39, 55], [39, 56], [39, 57], [39, 58], [39, 59], [39, 60], [39, 61], [39, 62], [39, 63], [39, 64], [39, 65], [39, 66], [39, 67], [39, 68], [39, 69], [39, 70], [39, 71], [39, 72], [39, 73], [39, 74], [40, 41], [40, 42], [40, 43], [40, 44], [40, 45], [40, 46], [40, 47], [40, 48], [40, 49], [40, 50], [40, 51], [40, 52], [40, 53], [40, 54], [40, 55], [40, 56], [40, 57], [40, 58], [40, 59], [40, 60], [40, 61], [40, 62], [40, 63], [40, 64], [40, 65], [40, 66], [40, 67], [40, 68], [40, 70], [40, 71], [40, 72], [40, 73], [40, 74], [41, 42], [41, 43], [41, 44], [41, 45], [41, 46], [41, 47], [41, 48], [41, 49], [41, 50], [41, 51], [41, 52], [41, 53], [41, 54], [41, 55], [41, 56], [41, 57], [41, 58], [41, 59], [41, 60], [41, 61], [41, 62], [41, 63], [41, 65], [41, 66], [41, 67], [41, 68], [41, 69], [41, 70], [41, 71], [41, 73], [41, 74], [42, 43], [42, 44], [42, 45], [42, 46], [42, 47], [42, 48], [42, 49], [42, 50], [42, 51], [42, 52], [42, 53], [42, 54], [42, 55], [42, 56], [42, 57], [42, 58], [42, 59], [42, 60], [42, 61], [42, 62], [42, 63], [42, 64], [42, 65], [42, 66], [42, 67], [42, 68], [42, 69], [42, 70], [42, 71], [42, 72], [42, 73], [42, 74], [43, 45], [43, 47], [43, 49], [43, 50], [43, 52], [43, 54], [43, 56], [43, 58], [43, 59], [43, 60], [43, 61], [43, 65], [43, 66], [43, 67], [43, 68], [43, 71], [43, 73], [43, 74], [44, 45], [44, 47], [44, 50], [44, 51], [44, 52], [44, 53], [44, 54], [44, 56], [44, 57], [44, 58], [44, 59], [44, 61], [44, 65], [44, 66], [44, 67], [44, 68], [44, 71], [44, 73], [45, 46], [45, 47], [45, 48], [45, 49], [45, 50], [45, 51], [45, 52], [45, 53], [45, 54], [45, 56], [45, 57], [45, 58], [45, 59], [45, 60], [45, 61], [45, 62], [45, 63], [45, 65], [45, 66], [45, 67], [45, 68], [45, 69], [45, 70], [45, 71], [45, 73], [45, 74], [46, 47], [46, 49], [46, 50], [46, 51], [46, 52], [46, 53], [46, 54], [46, 57], [46, 58], [46, 60], [46, 61], [46, 65], [46, 66], [46, 67], [46, 68], [46, 73], [46, 74], [47, 48], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [47, 54], [47, 55], [47, 56], [47, 57], [47, 58], [47, 59], [47, 60], [47, 61], [47, 62], [47, 63], [47, 64], [47, 65], [47, 66], [47, 67], [47, 68], [47, 69], [47, 71], [47, 73], [47, 74], [48, 49], [48, 50], [48, 51], [48, 52], [48, 56], [48, 57], [48, 58], [48, 59], [48, 60], [48, 65], [48, 66], [48, 67], [48, 68], [48, 71], [48, 73], [48, 74], [49, 50], [49, 51], [49, 52], [49, 53], [49, 54], [49, 55], [49, 56], [49, 57], [49, 58], [49, 59], [49, 60], [49, 61], [49, 62], [49, 63], [49, 64], [49, 65], [49, 66], [49, 67], [49, 68], [49, 69], [49, 70], [49, 71], [49, 73], [49, 74], [50, 51], [50, 52], [50, 53], [50, 54], [50, 55], [50, 56], [50, 57], [50, 58], [50, 59], [50, 60], [50, 61], [50, 62], [50, 64], [50, 65], [50, 66], [50, 67], [50, 68], [50, 69], [50, 71], [50, 72], [50, 73], [50, 74], [51, 52], [51, 53], [51, 54], [51, 55], [51, 56], [51, 57], [51, 58], [51, 59], [51, 60], [51, 61], [51, 63], [51, 64], [51, 65], [51, 66], [51, 67], [51, 68], [51, 69], [51, 70], [51, 71], [51, 72], [51, 73], [51, 74], [52, 53], [52, 54], [52, 55], [52, 56], [52, 57], [52, 58], [52, 59], [52, 60], [52, 61], [52, 62], [52, 64], [52, 65], [52, 66], [52, 67], [52, 68], [52, 69], [52, 70], [52, 71], [52, 72], [52, 73], [52, 74], [53, 54], [53, 55], [53, 56], [53, 57], [53, 58], [53, 59], [53, 60], [53, 61], [53, 62], [53, 63], [53, 64], [53, 65], [53, 66], [53, 67], [53, 68], [53, 69], [53, 70], [53, 71], [53, 72], [53, 73], [53, 74], [54, 55], [54, 56], [54, 57], [54, 58], [54, 59], [54, 60], [54, 61], [54, 63], [54, 64], [54, 65], [54, 66], [54, 67], [54, 68], [54, 69], [54, 71], [54, 72], [54, 73], [54, 74], [55, 56], [55, 58], [55, 59], [55, 60], [55, 61], [55, 65], [55, 67], [55, 71], [55, 73], [55, 74], [56, 57], [56, 58], [56, 59], [56, 60], [56, 61], [56, 62], [56, 63], [56, 64], [56, 65], [56, 66], [56, 67], [56, 68], [56, 69], [56, 70], [56, 71], [56, 72], [56, 73], [56, 74], [57, 58], [57, 59], [57, 60], [57, 61], [57, 63], [57, 64], [57, 65], [57, 66], [57, 67], [57, 68], [57, 69], [57, 70], [57, 71], [57, 72], [57, 73], [57, 74], [58, 59], [58, 60], [58, 61], [58, 62], [58, 63], [58, 64], [58, 65], [58, 66], [58, 67], [58, 68], [58, 69], [58, 70], [58, 71], [58, 72], [58, 73], [58, 74], [59, 60], [59, 61], [59, 62], [59, 63], [59, 65], [59, 66], [59, 67], [59, 68], [59, 69], [59, 70], [59, 71], [59, 72], [59, 73], [59, 74], [60, 61], [60, 62], [60, 63], [60, 64], [60, 65], [60, 66], [60, 67], [60, 68], [60, 69], [60, 71], [60, 72], [60, 73], [60, 74], [61, 63], [61, 64], [61, 65], [61, 66], [61, 67], [61, 68], [61, 70], [61, 71], [61, 73], [61, 74], [62, 66], [62, 67], [62, 68], [62, 71], [62, 73], [63, 66], [63, 67], [63, 71], [63, 73], [63, 74], [64, 65], [64, 66], [64, 67], [64, 68], [64, 71], [64, 74], [65, 66], [65, 67], [65, 68], [65, 70], [65, 71], [65, 73], [65, 74], [66, 67], [66, 68], [66, 69], [66, 71], [66, 72], [66, 73], [66, 74], [67, 68], [67, 70], [67, 71], [67, 72], [67, 73], [67, 74], [68, 69], [68, 70], [68, 71], [68, 72], [68, 73], [68, 74], [69, 71], [69, 73], [69, 74], [70, 71], [70, 73], [70, 74], [71, 72], [71, 73], [71, 74], [72, 73], [72, 74], [73, 74]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l6-s2/solution/solve.sh b/tasks/construct-rlve-imp-party-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..07fb634251271c02bdc3858c0927e183137b848f --- /dev/null +++ b/tasks/construct-rlve-imp-party-l6-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [1, 3, 5, 9, 16, 17, 23, 26, 35, 39, 40, 41, 42, 47, 51, 52, 54, 56, 57, 59, 60, 61, 66, 73, 74]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l6-s2/tests/check.py b/tasks/construct-rlve-imp-party-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l6-s2/tests/check.py @@ -0,0 +1,14 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + c = int_list(ans.get("clique"), n, 0, 3 * n - 1, "clique") + if len(set(c)) != n: + raise Invalid("vertices must be distinct") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(n): + for j in range(i + 1, n): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-imp-party-l6-s2/tests/instance.json b/tasks/construct-rlve-imp-party-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e129c30a80b83a737018e539d7645f955f43c508 --- /dev/null +++ b/tasks/construct-rlve-imp-party-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 25, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29], [0, 31], [0, 32], [0, 33], [0, 34], [0, 35], [0, 37], [0, 38], [0, 39], [0, 40], [0, 41], [0, 42], [0, 43], [0, 44], [0, 45], [0, 46], [0, 47], [0, 49], [0, 50], [0, 51], [0, 52], [0, 53], [0, 54], [0, 55], [0, 56], [0, 57], [0, 58], [0, 59], [0, 60], [0, 61], [0, 62], [0, 63], [0, 65], [0, 66], [0, 67], [0, 68], [0, 69], [0, 70], [0, 71], [0, 72], [0, 73], [0, 74], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 9], [1, 10], [1, 11], [1, 12], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 20], [1, 21], [1, 22], [1, 23], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 42], [1, 44], [1, 45], [1, 46], [1, 47], [1, 48], [1, 49], [1, 50], [1, 51], [1, 52], [1, 53], [1, 54], [1, 55], [1, 56], [1, 57], [1, 58], [1, 59], [1, 60], [1, 61], [1, 62], [1, 63], [1, 64], [1, 65], [1, 66], [1, 67], [1, 68], [1, 69], [1, 71], [1, 72], [1, 73], [1, 74], [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, 16], [2, 17], [2, 18], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 26], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 33], [2, 34], [2, 35], [2, 38], [2, 39], [2, 40], [2, 41], [2, 42], [2, 43], [2, 45], [2, 46], [2, 47], [2, 48], [2, 49], [2, 50], [2, 51], [2, 52], [2, 53], [2, 54], [2, 56], [2, 57], [2, 58], [2, 59], [2, 60], [2, 61], [2, 62], [2, 63], [2, 65], [2, 66], [2, 67], [2, 68], [2, 69], [2, 70], [2, 71], [2, 73], [2, 74], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [3, 40], [3, 41], [3, 42], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 51], [3, 52], [3, 53], [3, 54], [3, 56], [3, 57], [3, 58], [3, 59], [3, 60], [3, 61], [3, 62], [3, 63], [3, 64], [3, 65], [3, 66], [3, 67], [3, 68], [3, 69], [3, 70], [3, 71], [3, 72], [3, 73], [3, 74], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 21], [4, 22], [4, 23], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 37], [4, 38], [4, 39], [4, 40], [4, 41], [4, 42], [4, 43], [4, 45], [4, 46], [4, 47], [4, 48], [4, 49], [4, 50], [4, 51], [4, 52], [4, 53], [4, 54], [4, 55], [4, 56], [4, 57], [4, 58], [4, 59], [4, 60], [4, 61], [4, 62], [4, 63], [4, 64], [4, 65], [4, 66], [4, 67], [4, 68], [4, 69], [4, 70], [4, 71], [4, 72], [4, 73], [4, 74], [5, 6], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 28], [5, 29], [5, 31], [5, 32], [5, 33], [5, 34], [5, 35], [5, 37], [5, 38], [5, 39], [5, 40], [5, 41], [5, 42], [5, 43], [5, 44], [5, 45], [5, 47], [5, 48], [5, 49], [5, 50], [5, 51], [5, 52], [5, 53], [5, 54], [5, 55], [5, 56], [5, 57], [5, 58], [5, 59], [5, 60], [5, 61], [5, 62], [5, 63], [5, 64], [5, 65], [5, 66], [5, 67], [5, 68], [5, 69], [5, 70], [5, 71], [5, 72], [5, 73], [5, 74], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 27], [6, 28], [6, 29], [6, 31], [6, 32], [6, 33], [6, 34], [6, 35], [6, 37], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 44], [6, 45], [6, 46], [6, 47], [6, 48], [6, 49], [6, 50], [6, 51], [6, 52], [6, 53], [6, 54], [6, 55], [6, 56], [6, 57], [6, 58], [6, 59], [6, 60], [6, 61], [6, 62], [6, 64], [6, 65], [6, 66], [6, 67], [6, 68], [6, 69], [6, 70], [6, 71], [6, 72], [6, 73], [6, 74], [7, 10], [7, 11], [7, 14], [7, 17], [7, 21], [7, 31], [7, 33], [7, 34], [7, 35], [7, 38], [7, 39], [7, 42], [7, 45], [7, 47], [7, 49], [7, 52], [7, 53], [7, 54], [7, 57], [7, 58], [7, 59], [7, 60], [7, 65], [7, 67], [7, 68], [7, 71], [7, 74], [8, 9], [8, 10], [8, 14], [8, 16], [8, 17], [8, 21], [8, 22], [8, 26], [8, 27], [8, 29], [8, 31], [8, 33], [8, 34], [8, 35], [8, 38], [8, 40], [8, 42], [8, 45], [8, 47], [8, 49], [8, 50], [8, 51], [8, 52], [8, 53], [8, 54], [8, 56], [8, 58], [8, 61], [8, 67], [8, 68], [8, 71], [8, 73], [8, 74], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 35], [9, 36], [9, 37], [9, 38], [9, 39], [9, 40], [9, 41], [9, 42], [9, 44], [9, 45], [9, 46], [9, 47], [9, 48], [9, 49], [9, 50], [9, 51], [9, 52], [9, 53], [9, 54], [9, 55], [9, 56], [9, 57], [9, 58], [9, 59], [9, 60], [9, 61], [9, 62], [9, 64], [9, 65], [9, 66], [9, 67], [9, 68], [9, 69], [9, 70], [9, 71], [9, 73], [9, 74], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 25], [10, 26], [10, 27], [10, 28], [10, 29], [10, 30], [10, 31], [10, 32], [10, 33], [10, 34], [10, 35], [10, 36], [10, 37], [10, 38], [10, 39], [10, 40], [10, 41], [10, 42], [10, 43], [10, 44], [10, 45], [10, 46], [10, 47], [10, 48], [10, 49], [10, 50], [10, 51], [10, 52], [10, 53], [10, 54], [10, 55], [10, 56], [10, 57], [10, 58], [10, 59], [10, 60], [10, 61], [10, 63], [10, 64], [10, 65], [10, 66], [10, 67], [10, 68], [10, 69], [10, 70], [10, 71], [10, 73], [10, 74], [11, 13], [11, 14], [11, 15], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 25], [11, 26], [11, 27], [11, 28], [11, 29], [11, 30], [11, 31], [11, 32], [11, 33], [11, 34], [11, 35], [11, 36], [11, 37], [11, 38], [11, 39], [11, 40], [11, 41], [11, 42], [11, 43], [11, 44], [11, 45], [11, 46], [11, 47], [11, 49], [11, 50], [11, 51], [11, 52], [11, 53], [11, 54], [11, 55], [11, 56], [11, 57], [11, 58], [11, 59], [11, 60], [11, 61], [11, 62], [11, 63], [11, 64], [11, 65], [11, 66], [11, 67], [11, 68], [11, 69], [11, 71], [11, 72], [11, 73], [11, 74], [12, 14], [12, 16], [12, 17], [12, 21], [12, 22], [12, 26], [12, 27], [12, 28], [12, 33], [12, 34], [12, 35], [12, 41], [12, 45], [12, 47], [12, 49], [12, 50], [12, 53], [12, 54], [12, 56], [12, 57], [12, 58], [12, 60], [12, 61], [12, 65], [12, 66], [12, 67], [12, 68], [12, 74], [13, 14], [13, 16], [13, 17], [13, 21], [13, 22], [13, 23], [13, 26], [13, 27], [13, 28], [13, 29], [13, 31], [13, 33], [13, 34], [13, 35], [13, 38], [13, 39], [13, 40], [13, 41], [13, 42], [13, 45], [13, 47], [13, 49], [13, 50], [13, 51], [13, 52], [13, 53], [13, 54], [13, 56], [13, 57], [13, 58], [13, 60], [13, 65], [13, 66], [13, 67], [13, 68], [13, 71], [13, 73], [13, 74], [14, 15], [14, 16], [14, 17], [14, 18], [14, 21], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 30], [14, 31], [14, 32], [14, 33], [14, 34], [14, 35], [14, 36], [14, 37], [14, 38], [14, 39], [14, 40], [14, 41], [14, 42], [14, 43], [14, 44], [14, 45], [14, 46], [14, 47], [14, 49], [14, 50], [14, 51], [14, 52], [14, 53], [14, 54], [14, 55], [14, 56], [14, 57], [14, 58], [14, 59], [14, 60], [14, 61], [14, 62], [14, 63], [14, 64], [14, 65], [14, 66], [14, 67], [14, 68], [14, 69], [14, 70], [14, 71], [14, 73], [14, 74], [15, 16], [15, 21], [15, 22], [15, 23], [15, 26], [15, 27], [15, 28], [15, 29], [15, 31], [15, 34], [15, 38], [15, 39], [15, 40], [15, 41], [15, 42], [15, 45], [15, 47], [15, 49], [15, 50], [15, 51], [15, 52], [15, 53], [15, 54], [15, 56], [15, 57], [15, 59], [15, 60], [15, 61], [15, 65], [15, 66], [15, 67], [15, 68], [15, 73], [15, 74], [16, 17], [16, 19], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 31], [16, 32], [16, 33], [16, 34], [16, 35], [16, 37], [16, 38], [16, 39], [16, 40], [16, 41], [16, 42], [16, 43], [16, 45], [16, 46], [16, 47], [16, 48], [16, 49], [16, 50], [16, 51], [16, 52], [16, 53], [16, 54], [16, 55], [16, 56], [16, 57], [16, 58], [16, 59], [16, 60], [16, 61], [16, 62], [16, 64], [16, 65], [16, 66], [16, 67], [16, 68], [16, 69], [16, 70], [16, 71], [16, 73], [16, 74], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [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, 39], [17, 40], [17, 41], [17, 42], [17, 43], [17, 44], [17, 45], [17, 47], [17, 49], [17, 50], [17, 51], [17, 52], [17, 53], [17, 54], [17, 55], [17, 56], [17, 57], [17, 58], [17, 59], [17, 60], [17, 61], [17, 62], [17, 63], [17, 64], [17, 65], [17, 66], [17, 67], [17, 68], [17, 70], [17, 71], [17, 72], [17, 73], [17, 74], [18, 21], [18, 22], [18, 23], [18, 28], [18, 29], [18, 33], [18, 34], [18, 35], [18, 38], [18, 42], [18, 45], [18, 47], [18, 49], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [18, 56], [18, 57], [18, 58], [18, 59], [18, 60], [18, 61], [18, 66], [18, 67], [18, 68], [18, 71], [18, 73], [18, 74], [19, 21], [19, 23], [19, 26], [19, 27], [19, 28], [19, 29], [19, 31], [19, 33], [19, 34], [19, 38], [19, 39], [19, 40], [19, 42], [19, 47], [19, 49], [19, 51], [19, 52], [19, 54], [19, 56], [19, 58], [19, 59], [19, 60], [19, 65], [19, 66], [19, 67], [19, 68], [19, 73], [19, 74], [20, 21], [20, 22], [20, 26], [20, 27], [20, 28], [20, 31], [20, 33], [20, 34], [20, 35], [20, 38], [20, 39], [20, 40], [20, 41], [20, 42], [20, 45], [20, 49], [20, 50], [20, 51], [20, 52], [20, 53], [20, 56], [20, 57], [20, 58], [20, 59], [20, 60], [20, 61], [20, 65], [20, 66], [20, 67], [20, 68], [20, 71], [20, 73], [21, 22], [21, 23], [21, 24], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [21, 33], [21, 34], [21, 35], [21, 36], [21, 37], [21, 38], [21, 39], [21, 40], [21, 41], [21, 42], [21, 43], [21, 44], [21, 45], [21, 46], [21, 47], [21, 48], [21, 49], [21, 50], [21, 51], [21, 52], [21, 53], [21, 54], [21, 55], [21, 56], [21, 57], [21, 58], [21, 59], [21, 60], [21, 61], [21, 63], [21, 64], [21, 65], [21, 66], [21, 67], [21, 68], [21, 70], [21, 71], [21, 72], [21, 73], [21, 74], [22, 23], [22, 25], [22, 26], [22, 27], [22, 28], [22, 29], [22, 30], [22, 31], [22, 32], [22, 33], [22, 34], [22, 35], [22, 36], [22, 37], [22, 38], [22, 39], [22, 40], [22, 41], [22, 42], [22, 43], [22, 44], [22, 45], [22, 47], [22, 48], [22, 49], [22, 50], [22, 51], [22, 52], [22, 53], [22, 54], [22, 55], [22, 56], [22, 57], [22, 58], [22, 59], [22, 60], [22, 61], [22, 62], [22, 64], [22, 65], [22, 66], [22, 67], [22, 68], [22, 69], [22, 70], [22, 71], [22, 72], [22, 73], [22, 74], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 29], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [23, 36], [23, 37], [23, 38], [23, 39], [23, 40], [23, 41], [23, 42], [23, 43], [23, 45], [23, 46], [23, 47], [23, 49], [23, 50], [23, 51], [23, 52], [23, 53], [23, 54], [23, 55], [23, 56], [23, 57], [23, 58], [23, 59], [23, 60], [23, 61], [23, 62], [23, 63], [23, 65], [23, 66], [23, 67], [23, 68], [23, 69], [23, 71], [23, 73], [23, 74], [24, 27], [24, 28], [24, 29], [24, 31], [24, 33], [24, 34], [24, 35], [24, 38], [24, 39], [24, 41], [24, 42], [24, 45], [24, 49], [24, 50], [24, 52], [24, 53], [24, 54], [24, 56], [24, 58], [24, 59], [24, 60], [24, 65], [24, 66], [24, 67], [24, 68], [24, 71], [24, 73], [25, 26], [25, 27], [25, 28], [25, 29], [25, 31], [25, 33], [25, 35], [25, 38], [25, 39], [25, 40], [25, 42], [25, 45], [25, 47], [25, 49], [25, 50], [25, 52], [25, 53], [25, 54], [25, 56], [25, 57], [25, 59], [25, 65], [25, 66], [25, 68], [25, 71], [25, 73], [25, 74], [26, 27], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [26, 36], [26, 37], [26, 38], [26, 39], [26, 40], [26, 41], [26, 42], [26, 43], [26, 45], [26, 46], [26, 47], [26, 49], [26, 50], [26, 51], [26, 52], [26, 53], [26, 54], [26, 55], [26, 56], [26, 57], [26, 58], [26, 59], [26, 60], [26, 61], [26, 62], [26, 63], [26, 64], [26, 65], [26, 66], [26, 67], [26, 68], [26, 69], [26, 71], [26, 72], [26, 73], [26, 74], [27, 28], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 34], [27, 35], [27, 36], [27, 37], [27, 38], [27, 39], [27, 40], [27, 41], [27, 42], [27, 43], [27, 44], [27, 45], [27, 46], [27, 47], [27, 49], [27, 50], [27, 51], [27, 52], [27, 53], [27, 54], [27, 55], [27, 56], [27, 57], [27, 58], [27, 59], [27, 60], [27, 61], [27, 62], [27, 63], [27, 64], [27, 65], [27, 66], [27, 67], [27, 68], [27, 70], [27, 71], [27, 72], [27, 73], [27, 74], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [28, 36], [28, 38], [28, 39], [28, 40], [28, 41], [28, 42], [28, 43], [28, 44], [28, 45], [28, 46], [28, 47], [28, 48], [28, 49], [28, 50], [28, 51], [28, 52], [28, 53], [28, 54], [28, 55], [28, 56], [28, 57], [28, 58], [28, 59], [28, 60], [28, 61], [28, 62], [28, 63], [28, 64], [28, 65], [28, 66], [28, 67], [28, 68], [28, 69], [28, 71], [28, 72], [28, 73], [28, 74], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 35], [29, 36], [29, 37], [29, 38], [29, 39], [29, 40], [29, 41], [29, 42], [29, 43], [29, 44], [29, 45], [29, 46], [29, 47], [29, 48], [29, 49], [29, 50], [29, 51], [29, 52], [29, 53], [29, 54], [29, 55], [29, 56], [29, 57], [29, 58], [29, 59], [29, 60], [29, 61], [29, 62], [29, 64], [29, 65], [29, 66], [29, 67], [29, 68], [29, 70], [29, 71], [29, 72], [29, 73], [29, 74], [30, 31], [30, 33], [30, 34], [30, 35], [30, 38], [30, 39], [30, 40], [30, 41], [30, 42], [30, 45], [30, 47], [30, 49], [30, 50], [30, 51], [30, 52], [30, 53], [30, 54], [30, 57], [30, 58], [30, 59], [30, 60], [30, 61], [30, 65], [30, 66], [30, 67], [30, 68], [30, 71], [30, 73], [30, 74], [31, 32], [31, 33], [31, 34], [31, 35], [31, 38], [31, 39], [31, 40], [31, 41], [31, 42], [31, 43], [31, 44], [31, 45], [31, 46], [31, 47], [31, 48], [31, 49], [31, 50], [31, 51], [31, 52], [31, 53], [31, 54], [31, 55], [31, 56], [31, 57], [31, 58], [31, 59], [31, 60], [31, 61], [31, 62], [31, 63], [31, 64], [31, 65], [31, 66], [31, 67], [31, 68], [31, 69], [31, 70], [31, 71], [31, 72], [31, 73], [31, 74], [32, 33], [32, 34], [32, 35], [32, 38], [32, 39], [32, 42], [32, 45], [32, 47], [32, 49], [32, 50], [32, 51], [32, 52], [32, 53], [32, 56], [32, 57], [32, 59], [32, 60], [32, 61], [32, 65], [32, 66], [32, 67], [32, 68], [32, 71], [32, 73], [32, 74], [33, 34], [33, 35], [33, 36], [33, 37], [33, 38], [33, 39], [33, 40], [33, 41], [33, 42], [33, 44], [33, 45], [33, 46], [33, 47], [33, 49], [33, 50], [33, 51], [33, 52], [33, 53], [33, 54], [33, 55], [33, 56], [33, 57], [33, 58], [33, 59], [33, 60], [33, 61], [33, 62], [33, 63], [33, 64], [33, 65], [33, 66], [33, 67], [33, 68], [33, 69], [33, 70], [33, 71], [33, 72], [33, 73], [33, 74], [34, 35], [34, 36], [34, 37], [34, 38], [34, 39], [34, 40], [34, 41], [34, 42], [34, 43], [34, 44], [34, 45], [34, 46], [34, 47], [34, 48], [34, 49], [34, 50], [34, 51], [34, 52], [34, 53], [34, 54], [34, 55], [34, 56], [34, 57], [34, 58], [34, 59], [34, 60], [34, 61], [34, 62], [34, 63], [34, 64], [34, 65], [34, 66], [34, 67], [34, 68], [34, 69], [34, 70], [34, 71], [34, 72], [34, 73], [34, 74], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 42], [35, 43], [35, 44], [35, 45], [35, 46], [35, 47], [35, 49], [35, 50], [35, 51], [35, 52], [35, 53], [35, 54], [35, 55], [35, 56], [35, 57], [35, 58], [35, 59], [35, 60], [35, 61], [35, 62], [35, 63], [35, 64], [35, 65], [35, 66], [35, 67], [35, 68], [35, 69], [35, 70], [35, 71], [35, 72], [35, 73], [35, 74], [36, 38], [36, 39], [36, 41], [36, 42], [36, 47], [36, 49], [36, 50], [36, 51], [36, 52], [36, 53], [36, 54], [36, 56], [36, 57], [36, 59], [36, 60], [36, 61], [36, 65], [36, 66], [36, 68], [36, 71], [36, 73], [36, 74], [37, 39], [37, 45], [37, 47], [37, 49], [37, 50], [37, 51], [37, 52], [37, 53], [37, 54], [37, 56], [37, 57], [37, 58], [37, 60], [37, 61], [37, 66], [37, 67], [37, 68], [37, 71], [37, 74], [38, 39], [38, 40], [38, 41], [38, 42], [38, 43], [38, 44], [38, 45], [38, 46], [38, 47], [38, 49], [38, 50], [38, 51], [38, 52], [38, 53], [38, 54], [38, 56], [38, 57], [38, 58], [38, 59], [38, 60], [38, 61], [38, 62], [38, 63], [38, 64], [38, 65], [38, 66], [38, 67], [38, 68], [38, 70], [38, 71], [38, 72], [38, 73], [38, 74], [39, 40], [39, 41], [39, 42], [39, 44], [39, 45], [39, 46], [39, 47], [39, 49], [39, 50], [39, 51], [39, 52], [39, 53], [39, 54], [39, 55], [39, 56], [39, 57], [39, 58], [39, 59], [39, 60], [39, 61], [39, 62], [39, 63], [39, 64], [39, 65], [39, 66], [39, 67], [39, 68], [39, 69], [39, 70], [39, 71], [39, 72], [39, 73], [39, 74], [40, 41], [40, 42], [40, 43], [40, 44], [40, 45], [40, 46], [40, 47], [40, 48], [40, 49], [40, 50], [40, 51], [40, 52], [40, 53], [40, 54], [40, 55], [40, 56], [40, 57], [40, 58], [40, 59], [40, 60], [40, 61], [40, 62], [40, 63], [40, 64], [40, 65], [40, 66], [40, 67], [40, 68], [40, 70], [40, 71], [40, 72], [40, 73], [40, 74], [41, 42], [41, 43], [41, 44], [41, 45], [41, 46], [41, 47], [41, 48], [41, 49], [41, 50], [41, 51], [41, 52], [41, 53], [41, 54], [41, 55], [41, 56], [41, 57], [41, 58], [41, 59], [41, 60], [41, 61], [41, 62], [41, 63], [41, 65], [41, 66], [41, 67], [41, 68], [41, 69], [41, 70], [41, 71], [41, 73], [41, 74], [42, 43], [42, 44], [42, 45], [42, 46], [42, 47], [42, 48], [42, 49], [42, 50], [42, 51], [42, 52], [42, 53], [42, 54], [42, 55], [42, 56], [42, 57], [42, 58], [42, 59], [42, 60], [42, 61], [42, 62], [42, 63], [42, 64], [42, 65], [42, 66], [42, 67], [42, 68], [42, 69], [42, 70], [42, 71], [42, 72], [42, 73], [42, 74], [43, 45], [43, 47], [43, 49], [43, 50], [43, 52], [43, 54], [43, 56], [43, 58], [43, 59], [43, 60], [43, 61], [43, 65], [43, 66], [43, 67], [43, 68], [43, 71], [43, 73], [43, 74], [44, 45], [44, 47], [44, 50], [44, 51], [44, 52], [44, 53], [44, 54], [44, 56], [44, 57], [44, 58], [44, 59], [44, 61], [44, 65], [44, 66], [44, 67], [44, 68], [44, 71], [44, 73], [45, 46], [45, 47], [45, 48], [45, 49], [45, 50], [45, 51], [45, 52], [45, 53], [45, 54], [45, 56], [45, 57], [45, 58], [45, 59], [45, 60], [45, 61], [45, 62], [45, 63], [45, 65], [45, 66], [45, 67], [45, 68], [45, 69], [45, 70], [45, 71], [45, 73], [45, 74], [46, 47], [46, 49], [46, 50], [46, 51], [46, 52], [46, 53], [46, 54], [46, 57], [46, 58], [46, 60], [46, 61], [46, 65], [46, 66], [46, 67], [46, 68], [46, 73], [46, 74], [47, 48], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [47, 54], [47, 55], [47, 56], [47, 57], [47, 58], [47, 59], [47, 60], [47, 61], [47, 62], [47, 63], [47, 64], [47, 65], [47, 66], [47, 67], [47, 68], [47, 69], [47, 71], [47, 73], [47, 74], [48, 49], [48, 50], [48, 51], [48, 52], [48, 56], [48, 57], [48, 58], [48, 59], [48, 60], [48, 65], [48, 66], [48, 67], [48, 68], [48, 71], [48, 73], [48, 74], [49, 50], [49, 51], [49, 52], [49, 53], [49, 54], [49, 55], [49, 56], [49, 57], [49, 58], [49, 59], [49, 60], [49, 61], [49, 62], [49, 63], [49, 64], [49, 65], [49, 66], [49, 67], [49, 68], [49, 69], [49, 70], [49, 71], [49, 73], [49, 74], [50, 51], [50, 52], [50, 53], [50, 54], [50, 55], [50, 56], [50, 57], [50, 58], [50, 59], [50, 60], [50, 61], [50, 62], [50, 64], [50, 65], [50, 66], [50, 67], [50, 68], [50, 69], [50, 71], [50, 72], [50, 73], [50, 74], [51, 52], [51, 53], [51, 54], [51, 55], [51, 56], [51, 57], [51, 58], [51, 59], [51, 60], [51, 61], [51, 63], [51, 64], [51, 65], [51, 66], [51, 67], [51, 68], [51, 69], [51, 70], [51, 71], [51, 72], [51, 73], [51, 74], [52, 53], [52, 54], [52, 55], [52, 56], [52, 57], [52, 58], [52, 59], [52, 60], [52, 61], [52, 62], [52, 64], [52, 65], [52, 66], [52, 67], [52, 68], [52, 69], [52, 70], [52, 71], [52, 72], [52, 73], [52, 74], [53, 54], [53, 55], [53, 56], [53, 57], [53, 58], [53, 59], [53, 60], [53, 61], [53, 62], [53, 63], [53, 64], [53, 65], [53, 66], [53, 67], [53, 68], [53, 69], [53, 70], [53, 71], [53, 72], [53, 73], [53, 74], [54, 55], [54, 56], [54, 57], [54, 58], [54, 59], [54, 60], [54, 61], [54, 63], [54, 64], [54, 65], [54, 66], [54, 67], [54, 68], [54, 69], [54, 71], [54, 72], [54, 73], [54, 74], [55, 56], [55, 58], [55, 59], [55, 60], [55, 61], [55, 65], [55, 67], [55, 71], [55, 73], [55, 74], [56, 57], [56, 58], [56, 59], [56, 60], [56, 61], [56, 62], [56, 63], [56, 64], [56, 65], [56, 66], [56, 67], [56, 68], [56, 69], [56, 70], [56, 71], [56, 72], [56, 73], [56, 74], [57, 58], [57, 59], [57, 60], [57, 61], [57, 63], [57, 64], [57, 65], [57, 66], [57, 67], [57, 68], [57, 69], [57, 70], [57, 71], [57, 72], [57, 73], [57, 74], [58, 59], [58, 60], [58, 61], [58, 62], [58, 63], [58, 64], [58, 65], [58, 66], [58, 67], [58, 68], [58, 69], [58, 70], [58, 71], [58, 72], [58, 73], [58, 74], [59, 60], [59, 61], [59, 62], [59, 63], [59, 65], [59, 66], [59, 67], [59, 68], [59, 69], [59, 70], [59, 71], [59, 72], [59, 73], [59, 74], [60, 61], [60, 62], [60, 63], [60, 64], [60, 65], [60, 66], [60, 67], [60, 68], [60, 69], [60, 71], [60, 72], [60, 73], [60, 74], [61, 63], [61, 64], [61, 65], [61, 66], [61, 67], [61, 68], [61, 70], [61, 71], [61, 73], [61, 74], [62, 66], [62, 67], [62, 68], [62, 71], [62, 73], [63, 66], [63, 67], [63, 71], [63, 73], [63, 74], [64, 65], [64, 66], [64, 67], [64, 68], [64, 71], [64, 74], [65, 66], [65, 67], [65, 68], [65, 70], [65, 71], [65, 73], [65, 74], [66, 67], [66, 68], [66, 69], [66, 71], [66, 72], [66, 73], [66, 74], [67, 68], [67, 70], [67, 71], [67, 72], [67, 73], [67, 74], [68, 69], [68, 70], [68, 71], [68, 72], [68, 73], [68, 74], [69, 71], [69, 73], [69, 74], [70, 71], [70, 73], [70, 74], [71, 72], [71, 73], [71, 74], [72, 73], [72, 74], [73, 74]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l6-s2/tests/run.py b/tasks/construct-rlve-imp-party-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l6-s2/tests/test.sh b/tasks/construct-rlve-imp-party-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l6-s5/environment/Dockerfile b/tasks/construct-rlve-imp-party-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l6-s5/environment/instance.json b/tasks/construct-rlve-imp-party-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..60d1f273c4d0b41f61da95db54c98c19ec9ffa7c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 25, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 35], [0, 36], [0, 37], [0, 38], [0, 40], [0, 41], [0, 42], [0, 43], [0, 44], [0, 45], [0, 46], [0, 47], [0, 48], [0, 49], [0, 50], [0, 51], [0, 52], [0, 53], [0, 54], [0, 55], [0, 56], [0, 57], [0, 58], [0, 60], [0, 61], [0, 62], [0, 63], [0, 64], [0, 65], [0, 66], [0, 67], [0, 68], [0, 69], [0, 70], [0, 71], [0, 72], [0, 73], [0, 74], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 31], [1, 32], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 47], [1, 48], [1, 49], [1, 50], [1, 51], [1, 52], [1, 53], [1, 54], [1, 55], [1, 56], [1, 57], [1, 58], [1, 59], [1, 60], [1, 61], [1, 62], [1, 63], [1, 64], [1, 65], [1, 66], [1, 67], [1, 68], [1, 69], [1, 70], [1, 71], [1, 72], [1, 73], [1, 74], [2, 3], [2, 4], [2, 5], [2, 6], [2, 8], [2, 9], [2, 10], [2, 12], [2, 15], [2, 16], [2, 20], [2, 24], [2, 25], [2, 26], [2, 31], [2, 32], [2, 34], [2, 35], [2, 36], [2, 37], [2, 40], [2, 41], [2, 43], [2, 44], [2, 45], [2, 47], [2, 48], [2, 49], [2, 50], [2, 51], [2, 52], [2, 53], [2, 54], [2, 55], [2, 56], [2, 57], [2, 60], [2, 61], [2, 62], [2, 64], [2, 65], [2, 66], [2, 69], [2, 70], [2, 71], [2, 74], [3, 4], [3, 5], [3, 6], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [3, 40], [3, 41], [3, 42], [3, 43], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 51], [3, 52], [3, 53], [3, 54], [3, 55], [3, 56], [3, 57], [3, 58], [3, 59], [3, 60], [3, 61], [3, 62], [3, 63], [3, 64], [3, 65], [3, 66], [3, 67], [3, 68], [3, 69], [3, 70], [3, 71], [3, 72], [3, 73], [3, 74], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 37], [4, 39], [4, 40], [4, 41], [4, 42], [4, 43], [4, 44], [4, 45], [4, 46], [4, 47], [4, 48], [4, 49], [4, 50], [4, 51], [4, 52], [4, 53], [4, 54], [4, 55], [4, 56], [4, 57], [4, 58], [4, 59], [4, 60], [4, 61], [4, 62], [4, 63], [4, 64], [4, 65], [4, 66], [4, 68], [4, 69], [4, 70], [4, 71], [4, 72], [4, 73], [4, 74], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 29], [5, 30], [5, 31], [5, 32], [5, 34], [5, 35], [5, 36], [5, 37], [5, 39], [5, 40], [5, 41], [5, 43], [5, 44], [5, 45], [5, 46], [5, 47], [5, 48], [5, 49], [5, 50], [5, 51], [5, 52], [5, 53], [5, 54], [5, 55], [5, 56], [5, 57], [5, 59], [5, 60], [5, 61], [5, 62], [5, 63], [5, 64], [5, 65], [5, 66], [5, 68], [5, 69], [5, 70], [5, 71], [5, 73], [5, 74], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 18], [6, 19], [6, 20], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 28], [6, 29], [6, 31], [6, 32], [6, 33], [6, 34], [6, 35], [6, 36], [6, 37], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 44], [6, 45], [6, 46], [6, 47], [6, 48], [6, 49], [6, 50], [6, 51], [6, 52], [6, 53], [6, 54], [6, 55], [6, 56], [6, 57], [6, 58], [6, 59], [6, 60], [6, 61], [6, 62], [6, 63], [6, 64], [6, 65], [6, 66], [6, 68], [6, 69], [6, 70], [6, 71], [6, 72], [6, 73], [6, 74], [7, 8], [7, 10], [7, 12], [7, 15], [7, 16], [7, 18], [7, 20], [7, 24], [7, 25], [7, 26], [7, 29], [7, 31], [7, 32], [7, 34], [7, 35], [7, 36], [7, 37], [7, 41], [7, 43], [7, 44], [7, 45], [7, 47], [7, 48], [7, 49], [7, 50], [7, 51], [7, 52], [7, 53], [7, 54], [7, 55], [7, 56], [7, 57], [7, 60], [7, 61], [7, 62], [7, 64], [7, 66], [7, 70], [7, 71], [7, 74], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 18], [8, 19], [8, 20], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [8, 36], [8, 37], [8, 38], [8, 39], [8, 40], [8, 41], [8, 42], [8, 43], [8, 44], [8, 45], [8, 46], [8, 47], [8, 48], [8, 49], [8, 50], [8, 51], [8, 52], [8, 53], [8, 54], [8, 55], [8, 56], [8, 57], [8, 58], [8, 59], [8, 60], [8, 61], [8, 62], [8, 63], [8, 64], [8, 65], [8, 66], [8, 68], [8, 69], [8, 70], [8, 71], [8, 73], [8, 74], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 35], [9, 36], [9, 37], [9, 39], [9, 40], [9, 41], [9, 42], [9, 43], [9, 44], [9, 45], [9, 46], [9, 47], [9, 48], [9, 49], [9, 50], [9, 51], [9, 52], [9, 53], [9, 54], [9, 55], [9, 56], [9, 57], [9, 58], [9, 59], [9, 60], [9, 61], [9, 62], [9, 63], [9, 64], [9, 65], [9, 66], [9, 67], [9, 68], [9, 69], [9, 70], [9, 71], [9, 72], [9, 73], [9, 74], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 30], [10, 31], [10, 32], [10, 33], [10, 34], [10, 35], [10, 36], [10, 37], [10, 38], [10, 39], [10, 40], [10, 41], [10, 42], [10, 43], [10, 44], [10, 45], [10, 46], [10, 47], [10, 48], [10, 49], [10, 50], [10, 51], [10, 52], [10, 53], [10, 54], [10, 55], [10, 56], [10, 57], [10, 58], [10, 59], [10, 60], [10, 61], [10, 62], [10, 63], [10, 64], [10, 65], [10, 66], [10, 67], [10, 68], [10, 69], [10, 70], [10, 71], [10, 72], [10, 73], [10, 74], [11, 12], [11, 15], [11, 16], [11, 18], [11, 20], [11, 24], [11, 25], [11, 26], [11, 29], [11, 31], [11, 32], [11, 34], [11, 36], [11, 37], [11, 40], [11, 41], [11, 43], [11, 44], [11, 45], [11, 47], [11, 50], [11, 51], [11, 52], [11, 54], [11, 55], [11, 56], [11, 57], [11, 60], [11, 61], [11, 62], [11, 64], [11, 65], [11, 66], [11, 69], [11, 70], [11, 71], [11, 74], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [12, 40], [12, 41], [12, 42], [12, 43], [12, 44], [12, 45], [12, 46], [12, 47], [12, 48], [12, 49], [12, 50], [12, 51], [12, 52], [12, 53], [12, 54], [12, 55], [12, 56], [12, 57], [12, 58], [12, 59], [12, 60], [12, 61], [12, 62], [12, 63], [12, 64], [12, 65], [12, 66], [12, 67], [12, 68], [12, 69], [12, 70], [12, 71], [12, 72], [12, 73], [12, 74], [13, 15], [13, 16], [13, 18], [13, 20], [13, 25], [13, 26], [13, 29], [13, 31], [13, 32], [13, 34], [13, 36], [13, 37], [13, 40], [13, 41], [13, 43], [13, 44], [13, 45], [13, 47], [13, 48], [13, 50], [13, 51], [13, 52], [13, 53], [13, 54], [13, 55], [13, 56], [13, 57], [13, 60], [13, 61], [13, 64], [13, 66], [13, 70], [13, 71], [13, 74], [14, 15], [14, 16], [14, 20], [14, 24], [14, 25], [14, 26], [14, 29], [14, 31], [14, 32], [14, 34], [14, 35], [14, 37], [14, 40], [14, 41], [14, 43], [14, 44], [14, 45], [14, 47], [14, 48], [14, 49], [14, 50], [14, 51], [14, 52], [14, 53], [14, 54], [14, 55], [14, 56], [14, 60], [14, 61], [14, 62], [14, 64], [14, 65], [14, 66], [14, 69], [14, 70], [14, 71], [14, 74], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 34], [15, 35], [15, 36], [15, 37], [15, 38], [15, 40], [15, 41], [15, 42], [15, 43], [15, 44], [15, 45], [15, 46], [15, 47], [15, 48], [15, 49], [15, 50], [15, 51], [15, 52], [15, 53], [15, 54], [15, 55], [15, 56], [15, 57], [15, 58], [15, 59], [15, 60], [15, 61], [15, 62], [15, 63], [15, 64], [15, 65], [15, 66], [15, 67], [15, 68], [15, 69], [15, 70], [15, 71], [15, 72], [15, 73], [15, 74], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 31], [16, 32], [16, 33], [16, 34], [16, 35], [16, 36], [16, 37], [16, 38], [16, 39], [16, 40], [16, 41], [16, 42], [16, 43], [16, 44], [16, 45], [16, 46], [16, 47], [16, 48], [16, 49], [16, 50], [16, 51], [16, 52], [16, 53], [16, 54], [16, 55], [16, 56], [16, 57], [16, 58], [16, 59], [16, 60], [16, 61], [16, 62], [16, 63], [16, 64], [16, 65], [16, 66], [16, 67], [16, 68], [16, 69], [16, 70], [16, 71], [16, 72], [16, 73], [16, 74], [17, 24], [17, 25], [17, 26], [17, 29], [17, 31], [17, 32], [17, 34], [17, 35], [17, 37], [17, 40], [17, 41], [17, 43], [17, 44], [17, 45], [17, 47], [17, 48], [17, 49], [17, 51], [17, 53], [17, 54], [17, 55], [17, 56], [17, 57], [17, 61], [17, 62], [17, 64], [17, 65], [17, 66], [17, 69], [17, 70], [17, 71], [17, 74], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [18, 36], [18, 37], [18, 39], [18, 40], [18, 41], [18, 42], [18, 43], [18, 44], [18, 45], [18, 46], [18, 47], [18, 48], [18, 49], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [18, 55], [18, 56], [18, 57], [18, 60], [18, 61], [18, 62], [18, 63], [18, 64], [18, 65], [18, 66], [18, 68], [18, 69], [18, 70], [18, 71], [18, 73], [18, 74], [19, 20], [19, 25], [19, 26], [19, 29], [19, 31], [19, 32], [19, 34], [19, 35], [19, 36], [19, 37], [19, 40], [19, 41], [19, 43], [19, 44], [19, 45], [19, 47], [19, 48], [19, 49], [19, 50], [19, 51], [19, 52], [19, 53], [19, 54], [19, 55], [19, 56], [19, 57], [19, 60], [19, 61], [19, 62], [19, 64], [19, 65], [19, 66], [19, 69], [19, 70], [19, 71], [19, 74], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 33], [20, 34], [20, 35], [20, 36], [20, 37], [20, 39], [20, 40], [20, 41], [20, 42], [20, 43], [20, 44], [20, 45], [20, 47], [20, 48], [20, 49], [20, 50], [20, 51], [20, 52], [20, 53], [20, 54], [20, 55], [20, 56], [20, 57], [20, 58], [20, 59], [20, 60], [20, 61], [20, 62], [20, 63], [20, 64], [20, 65], [20, 66], [20, 67], [20, 68], [20, 69], [20, 70], [20, 71], [20, 72], [20, 74], [21, 24], [21, 25], [21, 26], [21, 31], [21, 32], [21, 34], [21, 35], [21, 36], [21, 37], [21, 43], [21, 44], [21, 45], [21, 47], [21, 48], [21, 49], [21, 50], [21, 51], [21, 52], [21, 53], [21, 54], [21, 55], [21, 56], [21, 60], [21, 61], [21, 62], [21, 64], [21, 66], [21, 69], [21, 70], [21, 71], [21, 74], [22, 24], [22, 25], [22, 26], [22, 29], [22, 31], [22, 32], [22, 36], [22, 37], [22, 41], [22, 43], [22, 44], [22, 45], [22, 47], [22, 48], [22, 49], [22, 50], [22, 51], [22, 52], [22, 53], [22, 54], [22, 55], [22, 56], [22, 57], [22, 60], [22, 61], [22, 62], [22, 64], [22, 65], [22, 66], [22, 69], [22, 70], [22, 71], [22, 74], [23, 26], [23, 29], [23, 31], [23, 32], [23, 34], [23, 37], [23, 41], [23, 43], [23, 45], [23, 47], [23, 48], [23, 49], [23, 50], [23, 51], [23, 53], [23, 54], [23, 55], [23, 56], [23, 57], [23, 60], [23, 61], [23, 62], [23, 65], [23, 66], [23, 69], [23, 70], [23, 71], [23, 74], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [24, 36], [24, 37], [24, 39], [24, 40], [24, 41], [24, 42], [24, 43], [24, 44], [24, 45], [24, 46], [24, 47], [24, 48], [24, 49], [24, 50], [24, 51], [24, 52], [24, 53], [24, 54], [24, 55], [24, 56], [24, 57], [24, 59], [24, 60], [24, 61], [24, 62], [24, 64], [24, 65], [24, 66], [24, 67], [24, 68], [24, 69], [24, 70], [24, 71], [24, 72], [24, 74], [25, 26], [25, 28], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [25, 36], [25, 37], [25, 38], [25, 39], [25, 40], [25, 41], [25, 42], [25, 43], [25, 44], [25, 45], [25, 46], [25, 47], [25, 48], [25, 49], [25, 50], [25, 51], [25, 52], [25, 53], [25, 54], [25, 55], [25, 56], [25, 57], [25, 58], [25, 60], [25, 61], [25, 62], [25, 63], [25, 64], [25, 65], [25, 66], [25, 67], [25, 68], [25, 69], [25, 70], [25, 71], [25, 72], [25, 73], [25, 74], [26, 27], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [26, 36], [26, 37], [26, 38], [26, 39], [26, 40], [26, 41], [26, 42], [26, 43], [26, 44], [26, 45], [26, 47], [26, 48], [26, 49], [26, 50], [26, 51], [26, 52], [26, 53], [26, 54], [26, 55], [26, 56], [26, 57], [26, 58], [26, 59], [26, 60], [26, 61], [26, 62], [26, 63], [26, 64], [26, 65], [26, 66], [26, 67], [26, 68], [26, 69], [26, 70], [26, 71], [26, 72], [26, 73], [26, 74], [27, 31], [27, 32], [27, 34], [27, 35], [27, 40], [27, 41], [27, 43], [27, 44], [27, 45], [27, 47], [27, 48], [27, 49], [27, 50], [27, 51], [27, 52], [27, 53], [27, 54], [27, 55], [27, 56], [27, 57], [27, 60], [27, 61], [27, 64], [27, 65], [27, 66], [27, 69], [27, 70], [27, 71], [27, 74], [28, 29], [28, 31], [28, 32], [28, 34], [28, 35], [28, 36], [28, 37], [28, 40], [28, 41], [28, 43], [28, 44], [28, 45], [28, 48], [28, 49], [28, 50], [28, 51], [28, 52], [28, 53], [28, 54], [28, 55], [28, 56], [28, 60], [28, 61], [28, 62], [28, 64], [28, 65], [28, 66], [28, 69], [28, 70], [28, 71], [28, 74], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 35], [29, 36], [29, 37], [29, 38], [29, 39], [29, 40], [29, 41], [29, 42], [29, 43], [29, 44], [29, 45], [29, 47], [29, 48], [29, 49], [29, 50], [29, 51], [29, 52], [29, 53], [29, 54], [29, 55], [29, 56], [29, 57], [29, 58], [29, 59], [29, 60], [29, 61], [29, 62], [29, 64], [29, 65], [29, 66], [29, 67], [29, 68], [29, 69], [29, 70], [29, 71], [29, 72], [29, 73], [29, 74], [30, 31], [30, 34], [30, 35], [30, 36], [30, 37], [30, 40], [30, 41], [30, 43], [30, 44], [30, 45], [30, 48], [30, 49], [30, 51], [30, 52], [30, 53], [30, 54], [30, 55], [30, 56], [30, 57], [30, 60], [30, 62], [30, 64], [30, 65], [30, 70], [30, 71], [30, 74], [31, 32], [31, 33], [31, 34], [31, 35], [31, 36], [31, 37], [31, 38], [31, 39], [31, 40], [31, 41], [31, 43], [31, 44], [31, 45], [31, 47], [31, 48], [31, 49], [31, 50], [31, 51], [31, 52], [31, 53], [31, 54], [31, 55], [31, 56], [31, 57], [31, 58], [31, 59], [31, 60], [31, 61], [31, 62], [31, 63], [31, 64], [31, 65], [31, 66], [31, 67], [31, 69], [31, 70], [31, 71], [31, 72], [31, 73], [31, 74], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 40], [32, 41], [32, 42], [32, 43], [32, 44], [32, 45], [32, 46], [32, 47], [32, 48], [32, 49], [32, 50], [32, 51], [32, 52], [32, 53], [32, 54], [32, 55], [32, 56], [32, 57], [32, 58], [32, 59], [32, 60], [32, 61], [32, 62], [32, 63], [32, 64], [32, 65], [32, 66], [32, 67], [32, 68], [32, 69], [32, 70], [32, 71], [32, 73], [32, 74], [33, 34], [33, 35], [33, 37], [33, 40], [33, 41], [33, 43], [33, 44], [33, 47], [33, 48], [33, 49], [33, 50], [33, 51], [33, 52], [33, 53], [33, 54], [33, 55], [33, 56], [33, 57], [33, 60], [33, 61], [33, 62], [33, 64], [33, 65], [33, 66], [33, 69], [33, 70], [33, 71], [33, 74], [34, 35], [34, 36], [34, 37], [34, 38], [34, 39], [34, 40], [34, 41], [34, 42], [34, 43], [34, 44], [34, 45], [34, 46], [34, 47], [34, 48], [34, 49], [34, 50], [34, 51], [34, 52], [34, 53], [34, 54], [34, 55], [34, 56], [34, 57], [34, 58], [34, 59], [34, 60], [34, 61], [34, 62], [34, 63], [34, 64], [34, 65], [34, 66], [34, 67], [34, 68], [34, 69], [34, 70], [34, 71], [34, 72], [34, 73], [34, 74], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 42], [35, 43], [35, 44], [35, 45], [35, 46], [35, 47], [35, 48], [35, 49], [35, 50], [35, 51], [35, 52], [35, 53], [35, 54], [35, 55], [35, 56], [35, 57], [35, 58], [35, 59], [35, 60], [35, 61], [35, 62], [35, 63], [35, 64], [35, 65], [35, 66], [35, 67], [35, 69], [35, 70], [35, 71], [35, 72], [35, 74], [36, 37], [36, 38], [36, 39], [36, 40], [36, 41], [36, 42], [36, 43], [36, 44], [36, 45], [36, 46], [36, 47], [36, 48], [36, 49], [36, 50], [36, 51], [36, 52], [36, 53], [36, 54], [36, 55], [36, 56], [36, 57], [36, 58], [36, 59], [36, 60], [36, 61], [36, 62], [36, 63], [36, 64], [36, 65], [36, 66], [36, 67], [36, 68], [36, 69], [36, 70], [36, 71], [36, 73], [36, 74], [37, 38], [37, 39], [37, 40], [37, 41], [37, 42], [37, 43], [37, 44], [37, 45], [37, 46], [37, 47], [37, 48], [37, 49], [37, 50], [37, 51], [37, 52], [37, 53], [37, 54], [37, 55], [37, 56], [37, 57], [37, 58], [37, 60], [37, 61], [37, 62], [37, 63], [37, 64], [37, 65], [37, 66], [37, 67], [37, 68], [37, 69], [37, 70], [37, 71], [37, 72], [37, 73], [37, 74], [38, 40], [38, 43], [38, 44], [38, 45], [38, 48], [38, 49], [38, 50], [38, 51], [38, 52], [38, 53], [38, 54], [38, 55], [38, 56], [38, 57], [38, 60], [38, 62], [38, 64], [38, 65], [38, 66], [38, 69], [38, 70], [38, 71], [38, 74], [39, 40], [39, 41], [39, 43], [39, 44], [39, 45], [39, 47], [39, 48], [39, 50], [39, 52], [39, 54], [39, 55], [39, 56], [39, 57], [39, 60], [39, 61], [39, 62], [39, 65], [39, 69], [39, 70], [39, 71], [39, 74], [40, 41], [40, 42], [40, 43], [40, 44], [40, 45], [40, 46], [40, 47], [40, 48], [40, 49], [40, 50], [40, 51], [40, 52], [40, 53], [40, 54], [40, 55], [40, 56], [40, 57], [40, 58], [40, 59], [40, 60], [40, 61], [40, 62], [40, 63], [40, 64], [40, 65], [40, 66], [40, 68], [40, 69], [40, 70], [40, 71], [40, 72], [40, 73], [40, 74], [41, 42], [41, 43], [41, 44], [41, 45], [41, 46], [41, 47], [41, 48], [41, 49], [41, 50], [41, 51], [41, 52], [41, 53], [41, 54], [41, 55], [41, 56], [41, 57], [41, 58], [41, 60], [41, 61], [41, 62], [41, 63], [41, 64], [41, 65], [41, 66], [41, 67], [41, 69], [41, 70], [41, 71], [41, 72], [41, 73], [41, 74], [42, 44], [42, 45], [42, 47], [42, 48], [42, 49], [42, 50], [42, 51], [42, 52], [42, 53], [42, 54], [42, 55], [42, 56], [42, 61], [42, 62], [42, 64], [42, 66], [42, 69], [42, 70], [42, 71], [42, 74], [43, 44], [43, 45], [43, 46], [43, 47], [43, 48], [43, 49], [43, 50], [43, 51], [43, 52], [43, 53], [43, 54], [43, 55], [43, 56], [43, 57], [43, 58], [43, 59], [43, 60], [43, 61], [43, 62], [43, 63], [43, 64], [43, 65], [43, 66], [43, 67], [43, 68], [43, 69], [43, 70], [43, 71], [43, 72], [43, 73], [43, 74], [44, 45], [44, 46], [44, 47], [44, 48], [44, 49], [44, 50], [44, 51], [44, 52], [44, 53], [44, 54], [44, 55], [44, 56], [44, 57], [44, 58], [44, 59], [44, 60], [44, 61], [44, 62], [44, 63], [44, 64], [44, 65], [44, 66], [44, 67], [44, 68], [44, 69], [44, 70], [44, 71], [44, 73], [44, 74], [45, 46], [45, 47], [45, 48], [45, 49], [45, 50], [45, 51], [45, 52], [45, 53], [45, 54], [45, 55], [45, 56], [45, 57], [45, 58], [45, 59], [45, 60], [45, 61], [45, 62], [45, 63], [45, 64], [45, 65], [45, 66], [45, 67], [45, 68], [45, 69], [45, 70], [45, 71], [45, 72], [45, 73], [45, 74], [46, 47], [46, 48], [46, 49], [46, 50], [46, 52], [46, 53], [46, 54], [46, 56], [46, 57], [46, 60], [46, 61], [46, 62], [46, 65], [46, 66], [46, 69], [46, 70], [46, 71], [46, 74], [47, 48], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [47, 54], [47, 55], [47, 56], [47, 57], [47, 58], [47, 59], [47, 60], [47, 61], [47, 62], [47, 63], [47, 64], [47, 65], [47, 66], [47, 67], [47, 69], [47, 70], [47, 71], [47, 72], [47, 74], [48, 49], [48, 50], [48, 51], [48, 52], [48, 53], [48, 54], [48, 55], [48, 56], [48, 57], [48, 58], [48, 59], [48, 60], [48, 61], [48, 62], [48, 64], [48, 65], [48, 66], [48, 67], [48, 68], [48, 69], [48, 70], [48, 71], [48, 72], [48, 73], [48, 74], [49, 50], [49, 51], [49, 52], [49, 53], [49, 54], [49, 55], [49, 56], [49, 57], [49, 58], [49, 60], [49, 61], [49, 62], [49, 63], [49, 64], [49, 65], [49, 66], [49, 68], [49, 69], [49, 70], [49, 71], [49, 72], [49, 73], [49, 74], [50, 51], [50, 52], [50, 53], [50, 54], [50, 55], [50, 56], [50, 57], [50, 59], [50, 60], [50, 61], [50, 62], [50, 63], [50, 64], [50, 65], [50, 66], [50, 68], [50, 69], [50, 70], [50, 71], [50, 72], [50, 73], [50, 74], [51, 52], [51, 53], [51, 54], [51, 55], [51, 56], [51, 57], [51, 58], [51, 59], [51, 60], [51, 61], [51, 62], [51, 63], [51, 64], [51, 65], [51, 66], [51, 67], [51, 68], [51, 69], [51, 70], [51, 71], [51, 72], [51, 73], [51, 74], [52, 53], [52, 54], [52, 55], [52, 56], [52, 57], [52, 58], [52, 60], [52, 61], [52, 62], [52, 63], [52, 64], [52, 65], [52, 66], [52, 67], [52, 68], [52, 69], [52, 70], [52, 71], [52, 72], [52, 74], [53, 54], [53, 55], [53, 56], [53, 57], [53, 58], [53, 59], [53, 60], [53, 61], [53, 62], [53, 63], [53, 64], [53, 65], [53, 66], [53, 67], [53, 68], [53, 69], [53, 70], [53, 71], [53, 72], [53, 73], [53, 74], [54, 55], [54, 56], [54, 57], [54, 58], [54, 59], [54, 60], [54, 61], [54, 62], [54, 63], [54, 64], [54, 65], [54, 66], [54, 67], [54, 68], [54, 69], [54, 70], [54, 71], [54, 72], [54, 73], [54, 74], [55, 56], [55, 57], [55, 58], [55, 59], [55, 60], [55, 61], [55, 62], [55, 63], [55, 64], [55, 65], [55, 66], [55, 68], [55, 69], [55, 70], [55, 71], [55, 72], [55, 73], [55, 74], [56, 57], [56, 58], [56, 59], [56, 60], [56, 61], [56, 62], [56, 63], [56, 64], [56, 65], [56, 66], [56, 68], [56, 69], [56, 70], [56, 71], [56, 72], [56, 73], [56, 74], [57, 58], [57, 59], [57, 60], [57, 61], [57, 62], [57, 63], [57, 64], [57, 65], [57, 66], [57, 67], [57, 68], [57, 69], [57, 70], [57, 71], [57, 72], [57, 73], [57, 74], [58, 60], [58, 62], [58, 64], [58, 65], [58, 66], [58, 69], [58, 70], [58, 74], [59, 60], [59, 61], [59, 62], [59, 64], [59, 65], [59, 66], [59, 69], [59, 71], [59, 74], [60, 61], [60, 62], [60, 64], [60, 65], [60, 66], [60, 67], [60, 68], [60, 69], [60, 70], [60, 71], [60, 72], [60, 73], [60, 74], [61, 62], [61, 63], [61, 64], [61, 65], [61, 66], [61, 67], [61, 68], [61, 69], [61, 70], [61, 71], [61, 72], [61, 73], [61, 74], [62, 63], [62, 64], [62, 65], [62, 66], [62, 67], [62, 68], [62, 69], [62, 70], [62, 71], [62, 72], [62, 73], [62, 74], [63, 64], [63, 66], [63, 71], [63, 74], [64, 65], [64, 66], [64, 68], [64, 69], [64, 70], [64, 71], [64, 73], [64, 74], [65, 66], [65, 67], [65, 68], [65, 69], [65, 70], [65, 71], [65, 72], [65, 73], [65, 74], [66, 67], [66, 68], [66, 69], [66, 70], [66, 71], [66, 72], [66, 74], [67, 69], [67, 70], [67, 71], [67, 74], [68, 69], [68, 70], [68, 71], [68, 74], [69, 70], [69, 71], [69, 72], [69, 73], [69, 74], [70, 71], [70, 72], [70, 73], [70, 74], [71, 72], [71, 73], [71, 74], [72, 74], [73, 74]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l6-s5/solution/solve.sh b/tasks/construct-rlve-imp-party-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4230d2f647ceb6593ac346ebcc0cb2636e57178f --- /dev/null +++ b/tasks/construct-rlve-imp-party-l6-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [0, 3, 4, 9, 15, 18, 20, 29, 31, 34, 35, 36, 37, 41, 43, 45, 49, 52, 56, 61, 62, 64, 66, 69, 70]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l6-s5/tests/check.py b/tasks/construct-rlve-imp-party-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l6-s5/tests/check.py @@ -0,0 +1,14 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + c = int_list(ans.get("clique"), n, 0, 3 * n - 1, "clique") + if len(set(c)) != n: + raise Invalid("vertices must be distinct") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(n): + for j in range(i + 1, n): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-imp-party-l6-s5/tests/instance.json b/tasks/construct-rlve-imp-party-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..60d1f273c4d0b41f61da95db54c98c19ec9ffa7c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 25, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20], [0, 21], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 29], [0, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 35], [0, 36], [0, 37], [0, 38], [0, 40], [0, 41], [0, 42], [0, 43], [0, 44], [0, 45], [0, 46], [0, 47], [0, 48], [0, 49], [0, 50], [0, 51], [0, 52], [0, 53], [0, 54], [0, 55], [0, 56], [0, 57], [0, 58], [0, 60], [0, 61], [0, 62], [0, 63], [0, 64], [0, 65], [0, 66], [0, 67], [0, 68], [0, 69], [0, 70], [0, 71], [0, 72], [0, 73], [0, 74], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 31], [1, 32], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 47], [1, 48], [1, 49], [1, 50], [1, 51], [1, 52], [1, 53], [1, 54], [1, 55], [1, 56], [1, 57], [1, 58], [1, 59], [1, 60], [1, 61], [1, 62], [1, 63], [1, 64], [1, 65], [1, 66], [1, 67], [1, 68], [1, 69], [1, 70], [1, 71], [1, 72], [1, 73], [1, 74], [2, 3], [2, 4], [2, 5], [2, 6], [2, 8], [2, 9], [2, 10], [2, 12], [2, 15], [2, 16], [2, 20], [2, 24], [2, 25], [2, 26], [2, 31], [2, 32], [2, 34], [2, 35], [2, 36], [2, 37], [2, 40], [2, 41], [2, 43], [2, 44], [2, 45], [2, 47], [2, 48], [2, 49], [2, 50], [2, 51], [2, 52], [2, 53], [2, 54], [2, 55], [2, 56], [2, 57], [2, 60], [2, 61], [2, 62], [2, 64], [2, 65], [2, 66], [2, 69], [2, 70], [2, 71], [2, 74], [3, 4], [3, 5], [3, 6], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [3, 40], [3, 41], [3, 42], [3, 43], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 51], [3, 52], [3, 53], [3, 54], [3, 55], [3, 56], [3, 57], [3, 58], [3, 59], [3, 60], [3, 61], [3, 62], [3, 63], [3, 64], [3, 65], [3, 66], [3, 67], [3, 68], [3, 69], [3, 70], [3, 71], [3, 72], [3, 73], [3, 74], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 27], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [4, 36], [4, 37], [4, 39], [4, 40], [4, 41], [4, 42], [4, 43], [4, 44], [4, 45], [4, 46], [4, 47], [4, 48], [4, 49], [4, 50], [4, 51], [4, 52], [4, 53], [4, 54], [4, 55], [4, 56], [4, 57], [4, 58], [4, 59], [4, 60], [4, 61], [4, 62], [4, 63], [4, 64], [4, 65], [4, 66], [4, 68], [4, 69], [4, 70], [4, 71], [4, 72], [4, 73], [4, 74], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 29], [5, 30], [5, 31], [5, 32], [5, 34], [5, 35], [5, 36], [5, 37], [5, 39], [5, 40], [5, 41], [5, 43], [5, 44], [5, 45], [5, 46], [5, 47], [5, 48], [5, 49], [5, 50], [5, 51], [5, 52], [5, 53], [5, 54], [5, 55], [5, 56], [5, 57], [5, 59], [5, 60], [5, 61], [5, 62], [5, 63], [5, 64], [5, 65], [5, 66], [5, 68], [5, 69], [5, 70], [5, 71], [5, 73], [5, 74], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 13], [6, 14], [6, 15], [6, 16], [6, 18], [6, 19], [6, 20], [6, 22], [6, 23], [6, 24], [6, 25], [6, 26], [6, 28], [6, 29], [6, 31], [6, 32], [6, 33], [6, 34], [6, 35], [6, 36], [6, 37], [6, 38], [6, 39], [6, 40], [6, 41], [6, 42], [6, 43], [6, 44], [6, 45], [6, 46], [6, 47], [6, 48], [6, 49], [6, 50], [6, 51], [6, 52], [6, 53], [6, 54], [6, 55], [6, 56], [6, 57], [6, 58], [6, 59], [6, 60], [6, 61], [6, 62], [6, 63], [6, 64], [6, 65], [6, 66], [6, 68], [6, 69], [6, 70], [6, 71], [6, 72], [6, 73], [6, 74], [7, 8], [7, 10], [7, 12], [7, 15], [7, 16], [7, 18], [7, 20], [7, 24], [7, 25], [7, 26], [7, 29], [7, 31], [7, 32], [7, 34], [7, 35], [7, 36], [7, 37], [7, 41], [7, 43], [7, 44], [7, 45], [7, 47], [7, 48], [7, 49], [7, 50], [7, 51], [7, 52], [7, 53], [7, 54], [7, 55], [7, 56], [7, 57], [7, 60], [7, 61], [7, 62], [7, 64], [7, 66], [7, 70], [7, 71], [7, 74], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [8, 15], [8, 16], [8, 18], [8, 19], [8, 20], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [8, 36], [8, 37], [8, 38], [8, 39], [8, 40], [8, 41], [8, 42], [8, 43], [8, 44], [8, 45], [8, 46], [8, 47], [8, 48], [8, 49], [8, 50], [8, 51], [8, 52], [8, 53], [8, 54], [8, 55], [8, 56], [8, 57], [8, 58], [8, 59], [8, 60], [8, 61], [8, 62], [8, 63], [8, 64], [8, 65], [8, 66], [8, 68], [8, 69], [8, 70], [8, 71], [8, 73], [8, 74], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [9, 15], [9, 16], [9, 17], [9, 18], [9, 19], [9, 20], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [9, 29], [9, 30], [9, 31], [9, 32], [9, 33], [9, 34], [9, 35], [9, 36], [9, 37], [9, 39], [9, 40], [9, 41], [9, 42], [9, 43], [9, 44], [9, 45], [9, 46], [9, 47], [9, 48], [9, 49], [9, 50], [9, 51], [9, 52], [9, 53], [9, 54], [9, 55], [9, 56], [9, 57], [9, 58], [9, 59], [9, 60], [9, 61], [9, 62], [9, 63], [9, 64], [9, 65], [9, 66], [9, 67], [9, 68], [9, 69], [9, 70], [9, 71], [9, 72], [9, 73], [9, 74], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 22], [10, 23], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 30], [10, 31], [10, 32], [10, 33], [10, 34], [10, 35], [10, 36], [10, 37], [10, 38], [10, 39], [10, 40], [10, 41], [10, 42], [10, 43], [10, 44], [10, 45], [10, 46], [10, 47], [10, 48], [10, 49], [10, 50], [10, 51], [10, 52], [10, 53], [10, 54], [10, 55], [10, 56], [10, 57], [10, 58], [10, 59], [10, 60], [10, 61], [10, 62], [10, 63], [10, 64], [10, 65], [10, 66], [10, 67], [10, 68], [10, 69], [10, 70], [10, 71], [10, 72], [10, 73], [10, 74], [11, 12], [11, 15], [11, 16], [11, 18], [11, 20], [11, 24], [11, 25], [11, 26], [11, 29], [11, 31], [11, 32], [11, 34], [11, 36], [11, 37], [11, 40], [11, 41], [11, 43], [11, 44], [11, 45], [11, 47], [11, 50], [11, 51], [11, 52], [11, 54], [11, 55], [11, 56], [11, 57], [11, 60], [11, 61], [11, 62], [11, 64], [11, 65], [11, 66], [11, 69], [11, 70], [11, 71], [11, 74], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [12, 40], [12, 41], [12, 42], [12, 43], [12, 44], [12, 45], [12, 46], [12, 47], [12, 48], [12, 49], [12, 50], [12, 51], [12, 52], [12, 53], [12, 54], [12, 55], [12, 56], [12, 57], [12, 58], [12, 59], [12, 60], [12, 61], [12, 62], [12, 63], [12, 64], [12, 65], [12, 66], [12, 67], [12, 68], [12, 69], [12, 70], [12, 71], [12, 72], [12, 73], [12, 74], [13, 15], [13, 16], [13, 18], [13, 20], [13, 25], [13, 26], [13, 29], [13, 31], [13, 32], [13, 34], [13, 36], [13, 37], [13, 40], [13, 41], [13, 43], [13, 44], [13, 45], [13, 47], [13, 48], [13, 50], [13, 51], [13, 52], [13, 53], [13, 54], [13, 55], [13, 56], [13, 57], [13, 60], [13, 61], [13, 64], [13, 66], [13, 70], [13, 71], [13, 74], [14, 15], [14, 16], [14, 20], [14, 24], [14, 25], [14, 26], [14, 29], [14, 31], [14, 32], [14, 34], [14, 35], [14, 37], [14, 40], [14, 41], [14, 43], [14, 44], [14, 45], [14, 47], [14, 48], [14, 49], [14, 50], [14, 51], [14, 52], [14, 53], [14, 54], [14, 55], [14, 56], [14, 60], [14, 61], [14, 62], [14, 64], [14, 65], [14, 66], [14, 69], [14, 70], [14, 71], [14, 74], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 34], [15, 35], [15, 36], [15, 37], [15, 38], [15, 40], [15, 41], [15, 42], [15, 43], [15, 44], [15, 45], [15, 46], [15, 47], [15, 48], [15, 49], [15, 50], [15, 51], [15, 52], [15, 53], [15, 54], [15, 55], [15, 56], [15, 57], [15, 58], [15, 59], [15, 60], [15, 61], [15, 62], [15, 63], [15, 64], [15, 65], [15, 66], [15, 67], [15, 68], [15, 69], [15, 70], [15, 71], [15, 72], [15, 73], [15, 74], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 29], [16, 31], [16, 32], [16, 33], [16, 34], [16, 35], [16, 36], [16, 37], [16, 38], [16, 39], [16, 40], [16, 41], [16, 42], [16, 43], [16, 44], [16, 45], [16, 46], [16, 47], [16, 48], [16, 49], [16, 50], [16, 51], [16, 52], [16, 53], [16, 54], [16, 55], [16, 56], [16, 57], [16, 58], [16, 59], [16, 60], [16, 61], [16, 62], [16, 63], [16, 64], [16, 65], [16, 66], [16, 67], [16, 68], [16, 69], [16, 70], [16, 71], [16, 72], [16, 73], [16, 74], [17, 24], [17, 25], [17, 26], [17, 29], [17, 31], [17, 32], [17, 34], [17, 35], [17, 37], [17, 40], [17, 41], [17, 43], [17, 44], [17, 45], [17, 47], [17, 48], [17, 49], [17, 51], [17, 53], [17, 54], [17, 55], [17, 56], [17, 57], [17, 61], [17, 62], [17, 64], [17, 65], [17, 66], [17, 69], [17, 70], [17, 71], [17, 74], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 30], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [18, 36], [18, 37], [18, 39], [18, 40], [18, 41], [18, 42], [18, 43], [18, 44], [18, 45], [18, 46], [18, 47], [18, 48], [18, 49], [18, 50], [18, 51], [18, 52], [18, 53], [18, 54], [18, 55], [18, 56], [18, 57], [18, 60], [18, 61], [18, 62], [18, 63], [18, 64], [18, 65], [18, 66], [18, 68], [18, 69], [18, 70], [18, 71], [18, 73], [18, 74], [19, 20], [19, 25], [19, 26], [19, 29], [19, 31], [19, 32], [19, 34], [19, 35], [19, 36], [19, 37], [19, 40], [19, 41], [19, 43], [19, 44], [19, 45], [19, 47], [19, 48], [19, 49], [19, 50], [19, 51], [19, 52], [19, 53], [19, 54], [19, 55], [19, 56], [19, 57], [19, 60], [19, 61], [19, 62], [19, 64], [19, 65], [19, 66], [19, 69], [19, 70], [19, 71], [19, 74], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 31], [20, 32], [20, 33], [20, 34], [20, 35], [20, 36], [20, 37], [20, 39], [20, 40], [20, 41], [20, 42], [20, 43], [20, 44], [20, 45], [20, 47], [20, 48], [20, 49], [20, 50], [20, 51], [20, 52], [20, 53], [20, 54], [20, 55], [20, 56], [20, 57], [20, 58], [20, 59], [20, 60], [20, 61], [20, 62], [20, 63], [20, 64], [20, 65], [20, 66], [20, 67], [20, 68], [20, 69], [20, 70], [20, 71], [20, 72], [20, 74], [21, 24], [21, 25], [21, 26], [21, 31], [21, 32], [21, 34], [21, 35], [21, 36], [21, 37], [21, 43], [21, 44], [21, 45], [21, 47], [21, 48], [21, 49], [21, 50], [21, 51], [21, 52], [21, 53], [21, 54], [21, 55], [21, 56], [21, 60], [21, 61], [21, 62], [21, 64], [21, 66], [21, 69], [21, 70], [21, 71], [21, 74], [22, 24], [22, 25], [22, 26], [22, 29], [22, 31], [22, 32], [22, 36], [22, 37], [22, 41], [22, 43], [22, 44], [22, 45], [22, 47], [22, 48], [22, 49], [22, 50], [22, 51], [22, 52], [22, 53], [22, 54], [22, 55], [22, 56], [22, 57], [22, 60], [22, 61], [22, 62], [22, 64], [22, 65], [22, 66], [22, 69], [22, 70], [22, 71], [22, 74], [23, 26], [23, 29], [23, 31], [23, 32], [23, 34], [23, 37], [23, 41], [23, 43], [23, 45], [23, 47], [23, 48], [23, 49], [23, 50], [23, 51], [23, 53], [23, 54], [23, 55], [23, 56], [23, 57], [23, 60], [23, 61], [23, 62], [23, 65], [23, 66], [23, 69], [23, 70], [23, 71], [23, 74], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 30], [24, 31], [24, 32], [24, 33], [24, 34], [24, 35], [24, 36], [24, 37], [24, 39], [24, 40], [24, 41], [24, 42], [24, 43], [24, 44], [24, 45], [24, 46], [24, 47], [24, 48], [24, 49], [24, 50], [24, 51], [24, 52], [24, 53], [24, 54], [24, 55], [24, 56], [24, 57], [24, 59], [24, 60], [24, 61], [24, 62], [24, 64], [24, 65], [24, 66], [24, 67], [24, 68], [24, 69], [24, 70], [24, 71], [24, 72], [24, 74], [25, 26], [25, 28], [25, 29], [25, 30], [25, 31], [25, 32], [25, 33], [25, 34], [25, 35], [25, 36], [25, 37], [25, 38], [25, 39], [25, 40], [25, 41], [25, 42], [25, 43], [25, 44], [25, 45], [25, 46], [25, 47], [25, 48], [25, 49], [25, 50], [25, 51], [25, 52], [25, 53], [25, 54], [25, 55], [25, 56], [25, 57], [25, 58], [25, 60], [25, 61], [25, 62], [25, 63], [25, 64], [25, 65], [25, 66], [25, 67], [25, 68], [25, 69], [25, 70], [25, 71], [25, 72], [25, 73], [25, 74], [26, 27], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [26, 36], [26, 37], [26, 38], [26, 39], [26, 40], [26, 41], [26, 42], [26, 43], [26, 44], [26, 45], [26, 47], [26, 48], [26, 49], [26, 50], [26, 51], [26, 52], [26, 53], [26, 54], [26, 55], [26, 56], [26, 57], [26, 58], [26, 59], [26, 60], [26, 61], [26, 62], [26, 63], [26, 64], [26, 65], [26, 66], [26, 67], [26, 68], [26, 69], [26, 70], [26, 71], [26, 72], [26, 73], [26, 74], [27, 31], [27, 32], [27, 34], [27, 35], [27, 40], [27, 41], [27, 43], [27, 44], [27, 45], [27, 47], [27, 48], [27, 49], [27, 50], [27, 51], [27, 52], [27, 53], [27, 54], [27, 55], [27, 56], [27, 57], [27, 60], [27, 61], [27, 64], [27, 65], [27, 66], [27, 69], [27, 70], [27, 71], [27, 74], [28, 29], [28, 31], [28, 32], [28, 34], [28, 35], [28, 36], [28, 37], [28, 40], [28, 41], [28, 43], [28, 44], [28, 45], [28, 48], [28, 49], [28, 50], [28, 51], [28, 52], [28, 53], [28, 54], [28, 55], [28, 56], [28, 60], [28, 61], [28, 62], [28, 64], [28, 65], [28, 66], [28, 69], [28, 70], [28, 71], [28, 74], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 35], [29, 36], [29, 37], [29, 38], [29, 39], [29, 40], [29, 41], [29, 42], [29, 43], [29, 44], [29, 45], [29, 47], [29, 48], [29, 49], [29, 50], [29, 51], [29, 52], [29, 53], [29, 54], [29, 55], [29, 56], [29, 57], [29, 58], [29, 59], [29, 60], [29, 61], [29, 62], [29, 64], [29, 65], [29, 66], [29, 67], [29, 68], [29, 69], [29, 70], [29, 71], [29, 72], [29, 73], [29, 74], [30, 31], [30, 34], [30, 35], [30, 36], [30, 37], [30, 40], [30, 41], [30, 43], [30, 44], [30, 45], [30, 48], [30, 49], [30, 51], [30, 52], [30, 53], [30, 54], [30, 55], [30, 56], [30, 57], [30, 60], [30, 62], [30, 64], [30, 65], [30, 70], [30, 71], [30, 74], [31, 32], [31, 33], [31, 34], [31, 35], [31, 36], [31, 37], [31, 38], [31, 39], [31, 40], [31, 41], [31, 43], [31, 44], [31, 45], [31, 47], [31, 48], [31, 49], [31, 50], [31, 51], [31, 52], [31, 53], [31, 54], [31, 55], [31, 56], [31, 57], [31, 58], [31, 59], [31, 60], [31, 61], [31, 62], [31, 63], [31, 64], [31, 65], [31, 66], [31, 67], [31, 69], [31, 70], [31, 71], [31, 72], [31, 73], [31, 74], [32, 33], [32, 34], [32, 35], [32, 36], [32, 37], [32, 40], [32, 41], [32, 42], [32, 43], [32, 44], [32, 45], [32, 46], [32, 47], [32, 48], [32, 49], [32, 50], [32, 51], [32, 52], [32, 53], [32, 54], [32, 55], [32, 56], [32, 57], [32, 58], [32, 59], [32, 60], [32, 61], [32, 62], [32, 63], [32, 64], [32, 65], [32, 66], [32, 67], [32, 68], [32, 69], [32, 70], [32, 71], [32, 73], [32, 74], [33, 34], [33, 35], [33, 37], [33, 40], [33, 41], [33, 43], [33, 44], [33, 47], [33, 48], [33, 49], [33, 50], [33, 51], [33, 52], [33, 53], [33, 54], [33, 55], [33, 56], [33, 57], [33, 60], [33, 61], [33, 62], [33, 64], [33, 65], [33, 66], [33, 69], [33, 70], [33, 71], [33, 74], [34, 35], [34, 36], [34, 37], [34, 38], [34, 39], [34, 40], [34, 41], [34, 42], [34, 43], [34, 44], [34, 45], [34, 46], [34, 47], [34, 48], [34, 49], [34, 50], [34, 51], [34, 52], [34, 53], [34, 54], [34, 55], [34, 56], [34, 57], [34, 58], [34, 59], [34, 60], [34, 61], [34, 62], [34, 63], [34, 64], [34, 65], [34, 66], [34, 67], [34, 68], [34, 69], [34, 70], [34, 71], [34, 72], [34, 73], [34, 74], [35, 36], [35, 37], [35, 38], [35, 39], [35, 40], [35, 41], [35, 42], [35, 43], [35, 44], [35, 45], [35, 46], [35, 47], [35, 48], [35, 49], [35, 50], [35, 51], [35, 52], [35, 53], [35, 54], [35, 55], [35, 56], [35, 57], [35, 58], [35, 59], [35, 60], [35, 61], [35, 62], [35, 63], [35, 64], [35, 65], [35, 66], [35, 67], [35, 69], [35, 70], [35, 71], [35, 72], [35, 74], [36, 37], [36, 38], [36, 39], [36, 40], [36, 41], [36, 42], [36, 43], [36, 44], [36, 45], [36, 46], [36, 47], [36, 48], [36, 49], [36, 50], [36, 51], [36, 52], [36, 53], [36, 54], [36, 55], [36, 56], [36, 57], [36, 58], [36, 59], [36, 60], [36, 61], [36, 62], [36, 63], [36, 64], [36, 65], [36, 66], [36, 67], [36, 68], [36, 69], [36, 70], [36, 71], [36, 73], [36, 74], [37, 38], [37, 39], [37, 40], [37, 41], [37, 42], [37, 43], [37, 44], [37, 45], [37, 46], [37, 47], [37, 48], [37, 49], [37, 50], [37, 51], [37, 52], [37, 53], [37, 54], [37, 55], [37, 56], [37, 57], [37, 58], [37, 60], [37, 61], [37, 62], [37, 63], [37, 64], [37, 65], [37, 66], [37, 67], [37, 68], [37, 69], [37, 70], [37, 71], [37, 72], [37, 73], [37, 74], [38, 40], [38, 43], [38, 44], [38, 45], [38, 48], [38, 49], [38, 50], [38, 51], [38, 52], [38, 53], [38, 54], [38, 55], [38, 56], [38, 57], [38, 60], [38, 62], [38, 64], [38, 65], [38, 66], [38, 69], [38, 70], [38, 71], [38, 74], [39, 40], [39, 41], [39, 43], [39, 44], [39, 45], [39, 47], [39, 48], [39, 50], [39, 52], [39, 54], [39, 55], [39, 56], [39, 57], [39, 60], [39, 61], [39, 62], [39, 65], [39, 69], [39, 70], [39, 71], [39, 74], [40, 41], [40, 42], [40, 43], [40, 44], [40, 45], [40, 46], [40, 47], [40, 48], [40, 49], [40, 50], [40, 51], [40, 52], [40, 53], [40, 54], [40, 55], [40, 56], [40, 57], [40, 58], [40, 59], [40, 60], [40, 61], [40, 62], [40, 63], [40, 64], [40, 65], [40, 66], [40, 68], [40, 69], [40, 70], [40, 71], [40, 72], [40, 73], [40, 74], [41, 42], [41, 43], [41, 44], [41, 45], [41, 46], [41, 47], [41, 48], [41, 49], [41, 50], [41, 51], [41, 52], [41, 53], [41, 54], [41, 55], [41, 56], [41, 57], [41, 58], [41, 60], [41, 61], [41, 62], [41, 63], [41, 64], [41, 65], [41, 66], [41, 67], [41, 69], [41, 70], [41, 71], [41, 72], [41, 73], [41, 74], [42, 44], [42, 45], [42, 47], [42, 48], [42, 49], [42, 50], [42, 51], [42, 52], [42, 53], [42, 54], [42, 55], [42, 56], [42, 61], [42, 62], [42, 64], [42, 66], [42, 69], [42, 70], [42, 71], [42, 74], [43, 44], [43, 45], [43, 46], [43, 47], [43, 48], [43, 49], [43, 50], [43, 51], [43, 52], [43, 53], [43, 54], [43, 55], [43, 56], [43, 57], [43, 58], [43, 59], [43, 60], [43, 61], [43, 62], [43, 63], [43, 64], [43, 65], [43, 66], [43, 67], [43, 68], [43, 69], [43, 70], [43, 71], [43, 72], [43, 73], [43, 74], [44, 45], [44, 46], [44, 47], [44, 48], [44, 49], [44, 50], [44, 51], [44, 52], [44, 53], [44, 54], [44, 55], [44, 56], [44, 57], [44, 58], [44, 59], [44, 60], [44, 61], [44, 62], [44, 63], [44, 64], [44, 65], [44, 66], [44, 67], [44, 68], [44, 69], [44, 70], [44, 71], [44, 73], [44, 74], [45, 46], [45, 47], [45, 48], [45, 49], [45, 50], [45, 51], [45, 52], [45, 53], [45, 54], [45, 55], [45, 56], [45, 57], [45, 58], [45, 59], [45, 60], [45, 61], [45, 62], [45, 63], [45, 64], [45, 65], [45, 66], [45, 67], [45, 68], [45, 69], [45, 70], [45, 71], [45, 72], [45, 73], [45, 74], [46, 47], [46, 48], [46, 49], [46, 50], [46, 52], [46, 53], [46, 54], [46, 56], [46, 57], [46, 60], [46, 61], [46, 62], [46, 65], [46, 66], [46, 69], [46, 70], [46, 71], [46, 74], [47, 48], [47, 49], [47, 50], [47, 51], [47, 52], [47, 53], [47, 54], [47, 55], [47, 56], [47, 57], [47, 58], [47, 59], [47, 60], [47, 61], [47, 62], [47, 63], [47, 64], [47, 65], [47, 66], [47, 67], [47, 69], [47, 70], [47, 71], [47, 72], [47, 74], [48, 49], [48, 50], [48, 51], [48, 52], [48, 53], [48, 54], [48, 55], [48, 56], [48, 57], [48, 58], [48, 59], [48, 60], [48, 61], [48, 62], [48, 64], [48, 65], [48, 66], [48, 67], [48, 68], [48, 69], [48, 70], [48, 71], [48, 72], [48, 73], [48, 74], [49, 50], [49, 51], [49, 52], [49, 53], [49, 54], [49, 55], [49, 56], [49, 57], [49, 58], [49, 60], [49, 61], [49, 62], [49, 63], [49, 64], [49, 65], [49, 66], [49, 68], [49, 69], [49, 70], [49, 71], [49, 72], [49, 73], [49, 74], [50, 51], [50, 52], [50, 53], [50, 54], [50, 55], [50, 56], [50, 57], [50, 59], [50, 60], [50, 61], [50, 62], [50, 63], [50, 64], [50, 65], [50, 66], [50, 68], [50, 69], [50, 70], [50, 71], [50, 72], [50, 73], [50, 74], [51, 52], [51, 53], [51, 54], [51, 55], [51, 56], [51, 57], [51, 58], [51, 59], [51, 60], [51, 61], [51, 62], [51, 63], [51, 64], [51, 65], [51, 66], [51, 67], [51, 68], [51, 69], [51, 70], [51, 71], [51, 72], [51, 73], [51, 74], [52, 53], [52, 54], [52, 55], [52, 56], [52, 57], [52, 58], [52, 60], [52, 61], [52, 62], [52, 63], [52, 64], [52, 65], [52, 66], [52, 67], [52, 68], [52, 69], [52, 70], [52, 71], [52, 72], [52, 74], [53, 54], [53, 55], [53, 56], [53, 57], [53, 58], [53, 59], [53, 60], [53, 61], [53, 62], [53, 63], [53, 64], [53, 65], [53, 66], [53, 67], [53, 68], [53, 69], [53, 70], [53, 71], [53, 72], [53, 73], [53, 74], [54, 55], [54, 56], [54, 57], [54, 58], [54, 59], [54, 60], [54, 61], [54, 62], [54, 63], [54, 64], [54, 65], [54, 66], [54, 67], [54, 68], [54, 69], [54, 70], [54, 71], [54, 72], [54, 73], [54, 74], [55, 56], [55, 57], [55, 58], [55, 59], [55, 60], [55, 61], [55, 62], [55, 63], [55, 64], [55, 65], [55, 66], [55, 68], [55, 69], [55, 70], [55, 71], [55, 72], [55, 73], [55, 74], [56, 57], [56, 58], [56, 59], [56, 60], [56, 61], [56, 62], [56, 63], [56, 64], [56, 65], [56, 66], [56, 68], [56, 69], [56, 70], [56, 71], [56, 72], [56, 73], [56, 74], [57, 58], [57, 59], [57, 60], [57, 61], [57, 62], [57, 63], [57, 64], [57, 65], [57, 66], [57, 67], [57, 68], [57, 69], [57, 70], [57, 71], [57, 72], [57, 73], [57, 74], [58, 60], [58, 62], [58, 64], [58, 65], [58, 66], [58, 69], [58, 70], [58, 74], [59, 60], [59, 61], [59, 62], [59, 64], [59, 65], [59, 66], [59, 69], [59, 71], [59, 74], [60, 61], [60, 62], [60, 64], [60, 65], [60, 66], [60, 67], [60, 68], [60, 69], [60, 70], [60, 71], [60, 72], [60, 73], [60, 74], [61, 62], [61, 63], [61, 64], [61, 65], [61, 66], [61, 67], [61, 68], [61, 69], [61, 70], [61, 71], [61, 72], [61, 73], [61, 74], [62, 63], [62, 64], [62, 65], [62, 66], [62, 67], [62, 68], [62, 69], [62, 70], [62, 71], [62, 72], [62, 73], [62, 74], [63, 64], [63, 66], [63, 71], [63, 74], [64, 65], [64, 66], [64, 68], [64, 69], [64, 70], [64, 71], [64, 73], [64, 74], [65, 66], [65, 67], [65, 68], [65, 69], [65, 70], [65, 71], [65, 72], [65, 73], [65, 74], [66, 67], [66, 68], [66, 69], [66, 70], [66, 71], [66, 72], [66, 74], [67, 69], [67, 70], [67, 71], [67, 74], [68, 69], [68, 70], [68, 71], [68, 74], [69, 70], [69, 71], [69, 72], [69, 73], [69, 74], [70, 71], [70, 72], [70, 73], [70, 74], [71, 72], [71, 73], [71, 74], [72, 74], [73, 74]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l6-s5/tests/run.py b/tasks/construct-rlve-imp-party-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l6-s5/tests/test.sh b/tasks/construct-rlve-imp-party-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-integer-linear-system-l1-s2/environment/Dockerfile b/tasks/construct-rlve-integer-linear-system-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l1-s2/environment/instance.json b/tasks/construct-rlve-integer-linear-system-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..117c00c631ca4f172338866698c5f9fe8311f47e --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 0, 1], [0, 0, 1], [1, 0, 1], [1, 0, 1], [0, 1, 0], [1, 1, 0]], "rhs": [6, 3, 6, 6, 1, 4], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l1-s2/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..373118fb837d1a491273dd1c09cc901dca5adc84 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l1-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [3, 1, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l1-s2/tests/check.py b/tasks/construct-rlve-integer-linear-system-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l1-s2/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = len(inst["coeffs"][0]) + x = int_list(ans.get("x"), n, name="x") + for k, (e, r) in enumerate(zip(inst["coeffs"], inst["rhs"])): + if sum(c * v for c, v in zip(e, x)) != r: + raise Invalid(f"equation {k} is violated") + return None, {} diff --git a/tasks/construct-rlve-integer-linear-system-l1-s2/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..117c00c631ca4f172338866698c5f9fe8311f47e --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 0, 1], [0, 0, 1], [1, 0, 1], [1, 0, 1], [0, 1, 0], [1, 1, 0]], "rhs": [6, 3, 6, 6, 1, 4], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l1-s2/tests/run.py b/tasks/construct-rlve-integer-linear-system-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l1-s2/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l1-s5/environment/Dockerfile b/tasks/construct-rlve-integer-linear-system-l1-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l1-s5/environment/instance.json b/tasks/construct-rlve-integer-linear-system-l1-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8e793714d37e8256d16d84c9be234711bdb9edb7 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l1-s5/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [[0, 0, 1], [1, 1, 0], [1, 0, 0], [1, 1, 1], [1, 0, 0], [1, 0, 0], [0, 0, 1]], "rhs": [1, 3, 1, 4, 1, 1, 1], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l1-s5/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l1-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c62c9777a0b9a290f34b766d9bbe8fa96cbf82d9 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l1-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [1, 2, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l1-s5/tests/check.py b/tasks/construct-rlve-integer-linear-system-l1-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l1-s5/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = len(inst["coeffs"][0]) + x = int_list(ans.get("x"), n, name="x") + for k, (e, r) in enumerate(zip(inst["coeffs"], inst["rhs"])): + if sum(c * v for c, v in zip(e, x)) != r: + raise Invalid(f"equation {k} is violated") + return None, {} diff --git a/tasks/construct-rlve-integer-linear-system-l1-s5/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l1-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8e793714d37e8256d16d84c9be234711bdb9edb7 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l1-s5/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [[0, 0, 1], [1, 1, 0], [1, 0, 0], [1, 1, 1], [1, 0, 0], [1, 0, 0], [0, 0, 1]], "rhs": [1, 3, 1, 4, 1, 1, 1], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l1-s5/tests/run.py b/tasks/construct-rlve-integer-linear-system-l1-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l1-s5/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l1-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l5-s3/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5049b6820009b226e0c8f5a64b12c56d8b469147 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l5-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [8, 11, 11, 16, 10, 12, 12, 9, 18, 9, 1, 2, 12, 3, 12, 12, 13, 14]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l5-s3/tests/check.py b/tasks/construct-rlve-integer-linear-system-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l5-s3/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = len(inst["coeffs"][0]) + x = int_list(ans.get("x"), n, name="x") + for k, (e, r) in enumerate(zip(inst["coeffs"], inst["rhs"])): + if sum(c * v for c, v in zip(e, x)) != r: + raise Invalid(f"equation {k} is violated") + return None, {} diff --git a/tasks/construct-rlve-integer-linear-system-l5-s3/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..650dda089ef683246389e2d4739bd9eb7822f850 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [[3, 0, 1, 2, 0, 0, 2, 2, 0, 0, 1, 3, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 3, 0, 1, 0, 1, 0, 2, 1], [3, 0, 0, 0, 0, 3, 2, 0, 3, 1, 1, 3, 2, 0, 0, 0, 3, 0], [3, 3, 2, 0, 0, 2, 0, 3, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 3, 3, 1, 2, 2, 0, 1, 0, 3, 0, 0, 0, 2, 0, 1, 0], [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 2, 0, 1, 0, 1, 3, 0, 2], [0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 2, 2, 2, 0, 0, 2, 0, 1, 0, 0, 0, 0, 2, 1], [2, 2, 1, 0, 1, 2, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 0], [0, 0, 0, 3, 2, 0, 1, 0, 0, 3, 0, 0, 0, 0, 1, 0, 0, 0], [2, 0, 0, 0, 3, 0, 0, 2, 2, 0, 1, 1, 0, 3, 0, 3, 0, 3], [2, 0, 0, 0, 0, 3, 0, 1, 2, 3, 0, 3, 0, 0, 0, 1, 0, 3], [0, 0, 0, 0, 3, 0, 0, 0, 3, 0, 3, 0, 3, 0, 0, 0, 0, 0], [3, 0, 0, 3, 0, 3, 3, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0], [3, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 0, 0, 0, 1], [0, 0, 1, 3, 0, 0, 3, 0, 0, 3, 2, 0, 3, 0, 2, 0, 0, 3], [0, 0, 2, 1, 2, 2, 1, 0, 2, 0, 0, 0, 0, 2, 0, 1, 0, 1], [0, 3, 3, 0, 0, 0, 3, 1, 0, 2, 3, 3, 2, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 3, 0, 0, 3, 2, 0, 0, 0, 1, 0, 3, 0, 2], [1, 0, 3, 3, 1, 0, 3, 3, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2], [0, 0, 0, 3, 0, 0, 1, 0, 0, 0, 0, 3, 0, 3, 0, 3, 1, 0], [1, 3, 1, 1, 0, 1, 2, 0, 1, 2, 2, 0, 0, 3, 0, 0, 0, 0], [0, 0, 0, 0, 2, 3, 3, 0, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 3, 0, 1, 3, 0, 0, 2, 0, 0, 2, 3, 0, 0, 2], [0, 1, 0, 0, 0, 0, 0, 0, 3, 2, 1, 0, 0, 2, 0, 1, 2, 3], [0, 3, 0, 1, 0, 0, 1, 0, 0, 3, 0, 2, 0, 2, 0, 1, 0, 1], [1, 0, 3, 2, 0, 0, 2, 0, 0, 0, 3, 3, 1, 0, 0, 0, 3, 1], [2, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 3, 0, 0, 2, 3, 1, 3], [0, 0, 3, 2, 0, 3, 3, 1, 3, 2, 0, 0, 0, 3, 1, 0, 1, 2], [0, 0, 1, 2, 1, 2, 1, 1, 0, 0, 3, 0, 0, 0, 0, 0, 2, 1], [3, 2, 0, 0, 0, 1, 3, 0, 2, 1, 1, 0, 0, 3, 1, 2, 3, 0], [2, 3, 0, 1, 0, 3, 3, 2, 2, 2, 0, 2, 1, 2, 2, 0, 0, 0], [3, 0, 0, 1, 0, 1, 3, 2, 0, 0, 0, 0, 0, 3, 3, 3, 1, 0], [0, 2, 0, 0, 0, 3, 2, 0, 0, 2, 2, 0, 0, 2, 0, 1, 1, 2], [1, 3, 3, 0, 1, 3, 0, 0, 1, 0, 0, 3, 1, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 3, 3, 0, 0, 0, 2, 0, 0, 0, 3, 0, 2], [0, 3, 2, 0, 2, 2, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 2, 1], [3, 1, 1, 0, 2, 1, 2, 2, 1, 0, 0, 0, 1, 2, 0, 0, 2, 3], [0, 0, 1, 0, 0, 1, 1, 2, 1, 3, 0, 2, 0, 2, 3, 3, 0, 2], [3, 0, 0, 0, 2, 1, 2, 0, 2, 0, 0, 3, 0, 3, 3, 0, 0, 3], [1, 2, 0, 0, 0, 1, 2, 0, 3, 3, 3, 3, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0, 2, 3, 3, 1, 0, 3, 1, 1, 0, 0, 0, 2], [1, 1, 0, 2, 2, 3, 3, 1, 0, 0, 1, 0, 0, 3, 1, 2, 1, 3], [3, 0, 1, 0, 1, 0, 2, 3, 0, 0, 0, 0, 2, 1, 2, 2, 0, 0], [1, 2, 3, 2, 0, 0, 0, 0, 2, 2, 0, 0, 2, 0, 3, 0, 3, 0], [1, 3, 1, 1, 2, 0, 0, 3, 0, 3, 0, 0, 0, 0, 2, 2, 1, 3], [0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 2, 2, 3, 0, 3], [0, 1, 1, 0, 0, 2, 2, 0, 3, 0, 0, 3, 1, 1, 1, 1, 0, 1], [0, 1, 1, 3, 2, 0, 1, 2, 0, 2, 3, 3, 2, 2, 3, 2, 0, 1], [0, 0, 3, 1, 0, 2, 0, 3, 3, 0, 2, 2, 1, 3, 0, 3, 2, 1]], "rhs": [142, 99, 217, 153, 197, 152, 49, 128, 123, 119, 190, 184, 123, 163, 93, 226, 162, 162, 202, 196, 124, 151, 112, 163, 170, 124, 171, 221, 280, 141, 224, 255, 200, 161, 171, 142, 167, 224, 208, 209, 171, 173, 253, 171, 248, 245, 148, 183, 251, 257], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l5-s3/tests/run.py b/tasks/construct-rlve-integer-linear-system-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l5-s3/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l5-s4/environment/Dockerfile b/tasks/construct-rlve-integer-linear-system-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l5-s4/environment/instance.json b/tasks/construct-rlve-integer-linear-system-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7b367b50017cdd714dbbf282ec8d14befddf6544 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [[0, 2, 3, 0, 1, 0, 0, 0, 2, 3, 0, 1, 0, 2, 0, 0, 0, 2], [0, 3, 3, 0, 0, 2, 2, 0, 3, 0, 2, 1, 0, 0, 0, 2, 1, 3], [0, 0, 0, 0, 0, 0, 2, 2, 0, 3, 0, 3, 0, 1, 3, 3, 1, 0], [2, 0, 0, 1, 2, 0, 2, 2, 0, 2, 2, 0, 1, 1, 0, 2, 0, 0], [0, 3, 3, 2, 2, 1, 1, 0, 3, 0, 0, 3, 2, 0, 0, 3, 0, 3], [0, 0, 0, 2, 0, 3, 3, 0, 1, 0, 0, 0, 0, 0, 0, 3, 2, 0], [0, 2, 0, 0, 0, 1, 1, 1, 0, 1, 0, 2, 2, 0, 2, 3, 0, 3], [0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1, 2, 0, 2, 0], [3, 1, 3, 0, 0, 1, 3, 3, 1, 2, 0, 0, 0, 0, 3, 3, 0, 0], [2, 3, 2, 0, 0, 2, 0, 3, 0, 0, 0, 2, 1, 0, 1, 2, 2, 0], [0, 3, 2, 2, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0], [3, 0, 2, 0, 3, 0, 2, 2, 1, 1, 3, 2, 2, 0, 0, 2, 0, 1], [0, 2, 0, 3, 0, 0, 1, 3, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3], [3, 1, 2, 2, 0, 3, 1, 3, 2, 3, 3, 1, 0, 0, 0, 0, 0, 0], [3, 3, 3, 3, 2, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 3, 0, 0], [1, 3, 3, 0, 0, 0, 0, 2, 3, 3, 3, 0, 0, 0, 0, 1, 2, 1], [2, 0, 2, 3, 0, 3, 0, 0, 1, 2, 3, 2, 0, 2, 0, 0, 2, 0], [0, 0, 0, 1, 3, 0, 3, 1, 3, 0, 3, 3, 1, 2, 1, 2, 1, 0], [0, 0, 0, 0, 2, 0, 1, 0, 2, 0, 0, 1, 2, 2, 0, 1, 0, 1], [0, 0, 0, 2, 1, 2, 0, 3, 2, 0, 2, 0, 2, 0, 1, 0, 0, 1], [2, 0, 0, 0, 1, 0, 2, 0, 3, 0, 0, 0, 0, 0, 1, 3, 2, 1], [0, 3, 1, 3, 0, 0, 0, 3, 0, 2, 2, 3, 1, 0, 3, 0, 0, 3], [0, 0, 0, 1, 2, 0, 2, 2, 2, 3, 0, 0, 0, 3, 0, 0, 0, 1], [0, 0, 1, 1, 3, 1, 0, 0, 0, 0, 2, 3, 1, 0, 0, 3, 0, 3], [0, 0, 0, 0, 0, 1, 3, 0, 0, 0, 2, 2, 1, 0, 0, 0, 0, 0], [1, 2, 1, 3, 2, 0, 1, 3, 0, 1, 0, 0, 0, 3, 0, 3, 2, 2], [3, 0, 1, 2, 2, 0, 1, 1, 1, 0, 0, 0, 0, 0, 2, 3, 3, 0], [3, 1, 0, 1, 0, 2, 2, 2, 0, 3, 2, 0, 2, 0, 1, 1, 1, 2], [0, 0, 0, 2, 3, 0, 2, 3, 0, 3, 0, 0, 3, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 3, 1, 0, 3, 0, 3, 0, 3, 0, 0, 0], [1, 3, 0, 2, 0, 1, 2, 0, 0, 1, 2, 0, 3, 3, 2, 2, 1, 0], [3, 0, 1, 0, 3, 1, 3, 1, 1, 0, 0, 0, 3, 0, 3, 0, 0, 3], [0, 0, 3, 1, 1, 0, 0, 3, 3, 0, 1, 3, 1, 0, 0, 0, 0, 0], [1, 1, 0, 3, 2, 3, 1, 1, 1, 2, 3, 2, 1, 3, 0, 0, 2, 0], [2, 0, 3, 0, 0, 0, 0, 0, 1, 2, 2, 0, 0, 3, 0, 0, 1, 3], [0, 0, 0, 0, 1, 0, 0, 0, 3, 1, 1, 3, 0, 3, 0, 0, 0, 3], [0, 0, 0, 2, 1, 1, 1, 0, 0, 3, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 3, 0, 2, 3, 0, 0, 0, 3, 0, 0, 3, 1, 0, 3, 2], [1, 0, 3, 3, 0, 1, 1, 2, 3, 0, 0, 0, 0, 2, 0, 0, 3, 0], [1, 0, 2, 1, 3, 0, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [0, 1, 1, 1, 2, 2, 2, 0, 1, 1, 3, 0, 3, 1, 0, 0, 0, 3], [0, 2, 3, 0, 0, 3, 1, 1, 0, 2, 1, 0, 0, 0, 0, 2, 2, 2], [2, 1, 0, 0, 0, 0, 2, 0, 0, 1, 1, 3, 2, 1, 0, 3, 2, 0]], "rhs": [216, 220, 172, 148, 282, 87, 185, 64, 204, 196, 94, 242, 93, 239, 214, 223, 234, 246, 158, 155, 132, 237, 180, 182, 84, 201, 148, 218, 156, 146, 236, 242, 179, 279, 204, 214, 107, 163, 174, 121, 230, 174, 180], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l5-s4/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4667c76e0fcdc5f3c5e1a842fcb352e25e56ff2d --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l5-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [12, 12, 11, 2, 13, 13, 3, 4, 16, 14, 7, 16, 16, 18, 12, 3, 5, 10]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l5-s4/tests/check.py b/tasks/construct-rlve-integer-linear-system-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l5-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-l5-s4/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7b367b50017cdd714dbbf282ec8d14befddf6544 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [[0, 2, 3, 0, 1, 0, 0, 0, 2, 3, 0, 1, 0, 2, 0, 0, 0, 2], [0, 3, 3, 0, 0, 2, 2, 0, 3, 0, 2, 1, 0, 0, 0, 2, 1, 3], [0, 0, 0, 0, 0, 0, 2, 2, 0, 3, 0, 3, 0, 1, 3, 3, 1, 0], [2, 0, 0, 1, 2, 0, 2, 2, 0, 2, 2, 0, 1, 1, 0, 2, 0, 0], [0, 3, 3, 2, 2, 1, 1, 0, 3, 0, 0, 3, 2, 0, 0, 3, 0, 3], [0, 0, 0, 2, 0, 3, 3, 0, 1, 0, 0, 0, 0, 0, 0, 3, 2, 0], [0, 2, 0, 0, 0, 1, 1, 1, 0, 1, 0, 2, 2, 0, 2, 3, 0, 3], [0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1, 2, 0, 2, 0], [3, 1, 3, 0, 0, 1, 3, 3, 1, 2, 0, 0, 0, 0, 3, 3, 0, 0], [2, 3, 2, 0, 0, 2, 0, 3, 0, 0, 0, 2, 1, 0, 1, 2, 2, 0], [0, 3, 2, 2, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0], [3, 0, 2, 0, 3, 0, 2, 2, 1, 1, 3, 2, 2, 0, 0, 2, 0, 1], [0, 2, 0, 3, 0, 0, 1, 3, 0, 0, 0, 0, 0, 1, 0, 0, 0, 3], [3, 1, 2, 2, 0, 3, 1, 3, 2, 3, 3, 1, 0, 0, 0, 0, 0, 0], [3, 3, 3, 3, 2, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 3, 0, 0], [1, 3, 3, 0, 0, 0, 0, 2, 3, 3, 3, 0, 0, 0, 0, 1, 2, 1], [2, 0, 2, 3, 0, 3, 0, 0, 1, 2, 3, 2, 0, 2, 0, 0, 2, 0], [0, 0, 0, 1, 3, 0, 3, 1, 3, 0, 3, 3, 1, 2, 1, 2, 1, 0], [0, 0, 0, 0, 2, 0, 1, 0, 2, 0, 0, 1, 2, 2, 0, 1, 0, 1], [0, 0, 0, 2, 1, 2, 0, 3, 2, 0, 2, 0, 2, 0, 1, 0, 0, 1], [2, 0, 0, 0, 1, 0, 2, 0, 3, 0, 0, 0, 0, 0, 1, 3, 2, 1], [0, 3, 1, 3, 0, 0, 0, 3, 0, 2, 2, 3, 1, 0, 3, 0, 0, 3], [0, 0, 0, 1, 2, 0, 2, 2, 2, 3, 0, 0, 0, 3, 0, 0, 0, 1], [0, 0, 1, 1, 3, 1, 0, 0, 0, 0, 2, 3, 1, 0, 0, 3, 0, 3], [0, 0, 0, 0, 0, 1, 3, 0, 0, 0, 2, 2, 1, 0, 0, 0, 0, 0], [1, 2, 1, 3, 2, 0, 1, 3, 0, 1, 0, 0, 0, 3, 0, 3, 2, 2], [3, 0, 1, 2, 2, 0, 1, 1, 1, 0, 0, 0, 0, 0, 2, 3, 3, 0], [3, 1, 0, 1, 0, 2, 2, 2, 0, 3, 2, 0, 2, 0, 1, 1, 1, 2], [0, 0, 0, 2, 3, 0, 2, 3, 0, 3, 0, 0, 3, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 3, 1, 0, 3, 0, 3, 0, 3, 0, 0, 0], [1, 3, 0, 2, 0, 1, 2, 0, 0, 1, 2, 0, 3, 3, 2, 2, 1, 0], [3, 0, 1, 0, 3, 1, 3, 1, 1, 0, 0, 0, 3, 0, 3, 0, 0, 3], [0, 0, 3, 1, 1, 0, 0, 3, 3, 0, 1, 3, 1, 0, 0, 0, 0, 0], [1, 1, 0, 3, 2, 3, 1, 1, 1, 2, 3, 2, 1, 3, 0, 0, 2, 0], [2, 0, 3, 0, 0, 0, 0, 0, 1, 2, 2, 0, 0, 3, 0, 0, 1, 3], [0, 0, 0, 0, 1, 0, 0, 0, 3, 1, 1, 3, 0, 3, 0, 0, 0, 3], [0, 0, 0, 2, 1, 1, 1, 0, 0, 3, 0, 2, 0, 0, 0, 0, 0, 0], [0, 0, 0, 3, 0, 2, 3, 0, 0, 0, 3, 0, 0, 3, 1, 0, 3, 2], [1, 0, 3, 3, 0, 1, 1, 2, 3, 0, 0, 0, 0, 2, 0, 0, 3, 0], [1, 0, 2, 1, 3, 0, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [0, 1, 1, 1, 2, 2, 2, 0, 1, 1, 3, 0, 3, 1, 0, 0, 0, 3], [0, 2, 3, 0, 0, 3, 1, 1, 0, 2, 1, 0, 0, 0, 0, 2, 2, 2], [2, 1, 0, 0, 0, 0, 2, 0, 0, 1, 1, 3, 2, 1, 0, 3, 2, 0]], "rhs": [216, 220, 172, 148, 282, 87, 185, 64, 204, 196, 94, 242, 93, 239, 214, 223, 234, 246, 158, 155, 132, 237, 180, 182, 84, 201, 148, 218, 156, 146, 236, 242, 179, 279, 204, 214, 107, 163, 174, 121, 230, 174, 180], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l5-s4/tests/run.py b/tasks/construct-rlve-integer-linear-system-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l5-s4/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-largest-rectangle-l5-s4/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l5-s4/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b5a26f36c2f990c3f40cc11b00098fcb262129f4 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"points": [[-11, 14], [25, 34], [-20, 12], [24, 30], [-14, -1], [-22, 16], [-12, 18], [-21, 13], [-24, 29], [38, 1], [-4, 1], [6, 16], [-34, -35], [-32, -14], [15, -13], [10, 9], [32, -12], [16, -30], [-15, 8], [-19, 15], [5, -32], [31, 18], [8, 0], [-22, 5], [17, -2], [19, -15], [-27, -14], [-35, -31], [32, 9], [-1, -6], [-15, -29], [-30, 6], [-32, 3], [31, -27], [15, 16], [-22, 40], [-17, 3], [1, 22], [-32, 14], [19, 7]], "area": 85, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l5-s4/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4eabac1fa23a56899a66c7fe333cebb85c5f4930 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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' +{"indices": [15, 22, 24, 39]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l5-s4/tests/check.py b/tasks/construct-rlve-largest-rectangle-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l5-s4/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid, int_list + + +def check(inst, ans): + P = inst["points"] + idx = int_list(ans.get("indices"), 4, 0, len(P) - 1, "indices") + if len(set(idx)) != 4: + raise Invalid("indices must be distinct") + A, *rest = [tuple(P[i]) for i in idx] + if len(set([A] + rest)) != 4: + raise Invalid("points must be distinct") + # the vertex farthest from A is opposite; the other two are A's neighbours + rest.sort(key=lambda X: (X[0] - A[0]) ** 2 + (X[1] - A[1]) ** 2) + B, D, C = rest + u = (B[0] - A[0], B[1] - A[1]) + v = (D[0] - A[0], D[1] - A[1]) + if u[0] * v[0] + u[1] * v[1] != 0: + raise Invalid("not a rectangle (no right angle at the first vertex)") + if (B[0] + D[0] - A[0], B[1] + D[1] - A[1]) != C: + raise Invalid("not a rectangle") + area = abs(u[0] * v[1] - u[1] * v[0]) + if area < inst["area"]: + raise Invalid(f"area {area} < {inst['area']}") + return None, {"area": area} diff --git a/tasks/construct-rlve-largest-rectangle-l5-s4/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b5a26f36c2f990c3f40cc11b00098fcb262129f4 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"points": [[-11, 14], [25, 34], [-20, 12], [24, 30], [-14, -1], [-22, 16], [-12, 18], [-21, 13], [-24, 29], [38, 1], [-4, 1], [6, 16], [-34, -35], [-32, -14], [15, -13], [10, 9], [32, -12], [16, -30], [-15, 8], [-19, 15], [5, -32], [31, 18], [8, 0], [-22, 5], [17, -2], [19, -15], [-27, -14], [-35, -31], [32, 9], [-1, -6], [-15, -29], [-30, 6], [-32, 3], [31, -27], [15, 16], [-22, 40], [-17, 3], [1, 22], [-32, 14], [19, 7]], "area": 85, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l5-s4/tests/run.py b/tasks/construct-rlve-largest-rectangle-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l5-s4/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-matrix-permutation-equivalence-l3-s1/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l3-s1/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3289bffa7963ea9ea668da940ca2598a9b0ea251 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"A": ["0101101", "0011011", "0010011", "1100000", "1111110", "0110000", "0001111"], "B": ["0100001", "0100110", "1010110", "1010101", "0001001", "1111011", "0110110"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l3-s1/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3a04a85378e499b2166dab1877181baacae7b3f6 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [5, 2, 6, 0, 3, 4, 1], "b": [4, 2, 3, 0, 6, 5, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l3-s1/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s1/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l3-s1/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3289bffa7963ea9ea668da940ca2598a9b0ea251 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"A": ["0101101", "0011011", "0010011", "1100000", "1111110", "0110000", "0001111"], "B": ["0100001", "0100110", "1010110", "1010101", "0001001", "1111011", "0110110"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l3-s1/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l3-s1/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l3-s6/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0005504e22f7980659935fea8b5a7c70aa5ab46b --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"A": ["1110111", "1111111"], "B": ["1111111", "1111011"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9c9cbf05a98a2c256b1dc9f25386c6c584c7def9 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [1, 0], "b": [4, 1, 0, 5, 3, 6, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l3-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-l3-s6/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0005504e22f7980659935fea8b5a7c70aa5ab46b --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"A": ["1110111", "1111111"], "B": ["1111111", "1111011"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l3-s8/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l3-s8/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f782cb2b10f2ccc61872f109af89e73e393fdc1e --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s8/environment/instance.json @@ -0,0 +1 @@ +{"A": ["111111", "111111", "111111", "111111", "010110", "111111"], "B": ["111111", "010011", "111111", "111111", "111111", "111111"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l3-s8/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ac26633e5c64ca02ce150bd6121494275eea1334 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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' +{"a": [2, 4, 3, 1, 5, 0], "b": [5, 1, 0, 2, 3, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l3-s8/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l3-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-l3-s8/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f782cb2b10f2ccc61872f109af89e73e393fdc1e --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s8/tests/instance.json @@ -0,0 +1 @@ +{"A": ["111111", "111111", "111111", "111111", "010110", "111111"], "B": ["111111", "010011", "111111", "111111", "111111", "111111"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l3-s8/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-matrix-permutation-equivalence-l3-s8/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l3-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-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-maximum-clique-l4-s1/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-maximum-clique-l4-s1/environment/instance.json b/tasks/construct-rlve-maximum-clique-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5e1d9eeef92fec1e4959c251624b815d7f035ba5 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 32, "k": 6, "edges": [[0, 4], [0, 5], [0, 6], [0, 8], [0, 13], [0, 14], [0, 16], [0, 18], [0, 19], [0, 20], [0, 22], [0, 23], [0, 25], [0, 26], [0, 28], [0, 29], [0, 31], [1, 2], [1, 3], [1, 6], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 19], [1, 23], [1, 24], [1, 27], [1, 28], [1, 30], [1, 31], [2, 4], [2, 5], [2, 8], [2, 10], [2, 14], [2, 15], [2, 20], [2, 22], [2, 24], [2, 25], [2, 26], [2, 28], [3, 4], [3, 8], [3, 9], [3, 12], [3, 17], [3, 19], [3, 22], [3, 23], [3, 24], [3, 29], [4, 5], [4, 7], [4, 9], [4, 14], [4, 17], [4, 22], [4, 30], [5, 7], [5, 9], [5, 10], [5, 11], [5, 13], [5, 15], [5, 16], [5, 17], [5, 22], [5, 25], [6, 8], [6, 9], [6, 11], [6, 13], [6, 14], [6, 15], [6, 17], [6, 18], [6, 19], [6, 22], [6, 23], [6, 26], [6, 27], [6, 28], [6, 30], [6, 31], [7, 8], [7, 11], [7, 12], [7, 13], [7, 16], [7, 18], [7, 22], [7, 24], [7, 25], [7, 26], [7, 28], [7, 30], [7, 31], [8, 11], [8, 13], [8, 16], [8, 18], [8, 20], [8, 21], [8, 26], [8, 27], [8, 29], [8, 31], [9, 13], [9, 14], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [10, 13], [10, 17], [10, 18], [10, 20], [10, 21], [10, 22], [10, 25], [10, 26], [10, 28], [10, 29], [10, 31], [11, 12], [11, 14], [11, 19], [11, 22], [11, 24], [11, 25], [11, 27], [11, 28], [11, 29], [11, 30], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 20], [12, 21], [12, 25], [12, 26], [12, 27], [12, 30], [12, 31], [13, 17], [13, 18], [13, 19], [13, 23], [13, 24], [13, 26], [13, 27], [13, 31], [14, 15], [14, 17], [14, 18], [14, 19], [14, 21], [14, 22], [14, 23], [14, 24], [14, 27], [14, 30], [14, 31], [15, 16], [15, 20], [15, 21], [15, 24], [15, 26], [15, 30], [15, 31], [16, 20], [16, 21], [16, 23], [16, 25], [16, 26], [16, 28], [16, 29], [16, 30], [17, 19], [17, 20], [17, 24], [17, 26], [17, 29], [17, 30], [17, 31], [18, 22], [18, 24], [18, 25], [18, 27], [18, 28], [18, 31], [19, 21], [19, 22], [19, 25], [19, 29], [19, 31], [20, 21], [20, 23], [20, 25], [20, 27], [21, 23], [21, 24], [21, 26], [21, 27], [21, 29], [21, 30], [22, 23], [22, 26], [22, 28], [22, 29], [22, 30], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 31], [24, 25], [24, 29], [24, 30], [24, 31], [25, 27], [25, 28], [25, 29], [25, 30], [26, 27], [26, 29], [26, 30], [27, 28], [27, 29], [27, 30], [27, 31], [28, 30], [29, 30], [29, 31]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l4-s1/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..943a3b2d6854b803c06bd816f3e8349f77631358 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [0, 6, 8, 13, 18, 31]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l4-s1/tests/check.py b/tasks/construct-rlve-maximum-clique-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s1/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("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-l4-s1/tests/instance.json b/tasks/construct-rlve-maximum-clique-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5e1d9eeef92fec1e4959c251624b815d7f035ba5 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 32, "k": 6, "edges": [[0, 4], [0, 5], [0, 6], [0, 8], [0, 13], [0, 14], [0, 16], [0, 18], [0, 19], [0, 20], [0, 22], [0, 23], [0, 25], [0, 26], [0, 28], [0, 29], [0, 31], [1, 2], [1, 3], [1, 6], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 19], [1, 23], [1, 24], [1, 27], [1, 28], [1, 30], [1, 31], [2, 4], [2, 5], [2, 8], [2, 10], [2, 14], [2, 15], [2, 20], [2, 22], [2, 24], [2, 25], [2, 26], [2, 28], [3, 4], [3, 8], [3, 9], [3, 12], [3, 17], [3, 19], [3, 22], [3, 23], [3, 24], [3, 29], [4, 5], [4, 7], [4, 9], [4, 14], [4, 17], [4, 22], [4, 30], [5, 7], [5, 9], [5, 10], [5, 11], [5, 13], [5, 15], [5, 16], [5, 17], [5, 22], [5, 25], [6, 8], [6, 9], [6, 11], [6, 13], [6, 14], [6, 15], [6, 17], [6, 18], [6, 19], [6, 22], [6, 23], [6, 26], [6, 27], [6, 28], [6, 30], [6, 31], [7, 8], [7, 11], [7, 12], [7, 13], [7, 16], [7, 18], [7, 22], [7, 24], [7, 25], [7, 26], [7, 28], [7, 30], [7, 31], [8, 11], [8, 13], [8, 16], [8, 18], [8, 20], [8, 21], [8, 26], [8, 27], [8, 29], [8, 31], [9, 13], [9, 14], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [10, 13], [10, 17], [10, 18], [10, 20], [10, 21], [10, 22], [10, 25], [10, 26], [10, 28], [10, 29], [10, 31], [11, 12], [11, 14], [11, 19], [11, 22], [11, 24], [11, 25], [11, 27], [11, 28], [11, 29], [11, 30], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 20], [12, 21], [12, 25], [12, 26], [12, 27], [12, 30], [12, 31], [13, 17], [13, 18], [13, 19], [13, 23], [13, 24], [13, 26], [13, 27], [13, 31], [14, 15], [14, 17], [14, 18], [14, 19], [14, 21], [14, 22], [14, 23], [14, 24], [14, 27], [14, 30], [14, 31], [15, 16], [15, 20], [15, 21], [15, 24], [15, 26], [15, 30], [15, 31], [16, 20], [16, 21], [16, 23], [16, 25], [16, 26], [16, 28], [16, 29], [16, 30], [17, 19], [17, 20], [17, 24], [17, 26], [17, 29], [17, 30], [17, 31], [18, 22], [18, 24], [18, 25], [18, 27], [18, 28], [18, 31], [19, 21], [19, 22], [19, 25], [19, 29], [19, 31], [20, 21], [20, 23], [20, 25], [20, 27], [21, 23], [21, 24], [21, 26], [21, 27], [21, 29], [21, 30], [22, 23], [22, 26], [22, 28], [22, 29], [22, 30], [23, 26], [23, 27], [23, 28], [23, 29], [23, 30], [23, 31], [24, 25], [24, 29], [24, 30], [24, 31], [25, 27], [25, 28], [25, 29], [25, 30], [26, 27], [26, 29], [26, 30], [27, 28], [27, 29], [27, 30], [27, 31], [28, 30], [29, 30], [29, 31]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l4-s1/tests/run.py b/tasks/construct-rlve-maximum-clique-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-maximum-clique-l4-s1/tests/test.sh b/tasks/construct-rlve-maximum-clique-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-maximum-clique-l4-s6/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-maximum-clique-l4-s6/environment/instance.json b/tasks/construct-rlve-maximum-clique-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..872a5005804899818abcaedd62859684a76a7ef6 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 32, "k": 7, "edges": [[0, 3], [0, 4], [0, 6], [0, 7], [0, 8], [0, 11], [0, 13], [0, 14], [0, 18], [0, 24], [0, 25], [0, 27], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 8], [1, 9], [1, 14], [1, 15], [1, 17], [1, 19], [1, 21], [1, 23], [1, 26], [1, 27], [1, 30], [2, 3], [2, 4], [2, 5], [2, 8], [2, 11], [2, 13], [2, 14], [2, 16], [2, 18], [2, 19], [2, 20], [2, 27], [2, 28], [2, 30], [3, 5], [3, 7], [3, 8], [3, 14], [3, 18], [3, 26], [3, 29], [4, 5], [4, 6], [4, 8], [4, 10], [4, 14], [4, 15], [4, 16], [4, 18], [4, 20], [4, 21], [4, 23], [4, 24], [4, 25], [4, 26], [4, 30], [5, 6], [5, 7], [5, 8], [5, 10], [5, 12], [5, 14], [5, 15], [5, 18], [5, 19], [5, 20], [5, 23], [5, 25], [5, 26], [5, 30], [5, 31], [6, 7], [6, 10], [6, 12], [6, 13], [6, 17], [6, 19], [6, 21], [6, 25], [6, 27], [6, 28], [6, 31], [7, 8], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 20], [7, 23], [7, 26], [7, 28], [7, 31], [8, 10], [8, 12], [8, 14], [8, 17], [8, 19], [8, 21], [8, 22], [8, 23], [8, 27], [8, 28], [8, 30], [9, 10], [9, 12], [9, 14], [9, 16], [9, 18], [9, 19], [9, 22], [9, 23], [9, 26], [9, 27], [9, 29], [10, 14], [10, 15], [10, 17], [10, 18], [10, 20], [10, 22], [10, 25], [10, 26], [10, 28], [10, 30], [10, 31], [11, 12], [11, 13], [11, 14], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 22], [11, 23], [11, 25], [11, 27], [11, 28], [11, 29], [12, 13], [12, 14], [12, 16], [12, 17], [12, 19], [12, 21], [12, 24], [12, 25], [12, 27], [12, 28], [12, 30], [12, 31], [13, 14], [13, 15], [13, 21], [13, 22], [13, 23], [13, 28], [13, 29], [13, 30], [13, 31], [14, 15], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 24], [14, 27], [14, 28], [14, 29], [14, 30], [15, 16], [15, 18], [15, 19], [15, 20], [15, 23], [15, 24], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [16, 18], [16, 19], [16, 20], [16, 21], [16, 27], [17, 19], [17, 22], [17, 24], [17, 28], [18, 19], [18, 21], [18, 22], [18, 23], [18, 24], [18, 27], [18, 28], [18, 29], [18, 31], [19, 20], [19, 21], [19, 22], [19, 25], [19, 26], [19, 28], [19, 31], [20, 22], [20, 24], [20, 28], [20, 29], [20, 30], [21, 23], [21, 24], [21, 25], [21, 27], [21, 28], [21, 31], [22, 25], [22, 26], [22, 27], [22, 29], [22, 31], [23, 27], [23, 29], [23, 31], [24, 27], [24, 31], [25, 26], [25, 27], [25, 30], [26, 30], [26, 31], [27, 31], [28, 29], [28, 30], [29, 30], [29, 31]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l4-s6/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..99f20f37a58bc3e73ac2889d6dbb20d1235d6895 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [1, 2, 4, 5, 8, 14, 30]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l4-s6/tests/check.py b/tasks/construct-rlve-maximum-clique-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s6/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l4-s6/tests/instance.json b/tasks/construct-rlve-maximum-clique-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..872a5005804899818abcaedd62859684a76a7ef6 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 32, "k": 7, "edges": [[0, 3], [0, 4], [0, 6], [0, 7], [0, 8], [0, 11], [0, 13], [0, 14], [0, 18], [0, 24], [0, 25], [0, 27], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 8], [1, 9], [1, 14], [1, 15], [1, 17], [1, 19], [1, 21], [1, 23], [1, 26], [1, 27], [1, 30], [2, 3], [2, 4], [2, 5], [2, 8], [2, 11], [2, 13], [2, 14], [2, 16], [2, 18], [2, 19], [2, 20], [2, 27], [2, 28], [2, 30], [3, 5], [3, 7], [3, 8], [3, 14], [3, 18], [3, 26], [3, 29], [4, 5], [4, 6], [4, 8], [4, 10], [4, 14], [4, 15], [4, 16], [4, 18], [4, 20], [4, 21], [4, 23], [4, 24], [4, 25], [4, 26], [4, 30], [5, 6], [5, 7], [5, 8], [5, 10], [5, 12], [5, 14], [5, 15], [5, 18], [5, 19], [5, 20], [5, 23], [5, 25], [5, 26], [5, 30], [5, 31], [6, 7], [6, 10], [6, 12], [6, 13], [6, 17], [6, 19], [6, 21], [6, 25], [6, 27], [6, 28], [6, 31], [7, 8], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 20], [7, 23], [7, 26], [7, 28], [7, 31], [8, 10], [8, 12], [8, 14], [8, 17], [8, 19], [8, 21], [8, 22], [8, 23], [8, 27], [8, 28], [8, 30], [9, 10], [9, 12], [9, 14], [9, 16], [9, 18], [9, 19], [9, 22], [9, 23], [9, 26], [9, 27], [9, 29], [10, 14], [10, 15], [10, 17], [10, 18], [10, 20], [10, 22], [10, 25], [10, 26], [10, 28], [10, 30], [10, 31], [11, 12], [11, 13], [11, 14], [11, 16], [11, 17], [11, 18], [11, 20], [11, 21], [11, 22], [11, 23], [11, 25], [11, 27], [11, 28], [11, 29], [12, 13], [12, 14], [12, 16], [12, 17], [12, 19], [12, 21], [12, 24], [12, 25], [12, 27], [12, 28], [12, 30], [12, 31], [13, 14], [13, 15], [13, 21], [13, 22], [13, 23], [13, 28], [13, 29], [13, 30], [13, 31], [14, 15], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 24], [14, 27], [14, 28], [14, 29], [14, 30], [15, 16], [15, 18], [15, 19], [15, 20], [15, 23], [15, 24], [15, 26], [15, 27], [15, 28], [15, 29], [15, 30], [16, 18], [16, 19], [16, 20], [16, 21], [16, 27], [17, 19], [17, 22], [17, 24], [17, 28], [18, 19], [18, 21], [18, 22], [18, 23], [18, 24], [18, 27], [18, 28], [18, 29], [18, 31], [19, 20], [19, 21], [19, 22], [19, 25], [19, 26], [19, 28], [19, 31], [20, 22], [20, 24], [20, 28], [20, 29], [20, 30], [21, 23], [21, 24], [21, 25], [21, 27], [21, 28], [21, 31], [22, 25], [22, 26], [22, 27], [22, 29], [22, 31], [23, 27], [23, 29], [23, 31], [24, 27], [24, 31], [25, 26], [25, 27], [25, 30], [26, 30], [26, 31], [27, 31], [28, 29], [28, 30], [29, 30], [29, 31]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l4-s6/tests/run.py b/tasks/construct-rlve-maximum-clique-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-maximum-clique-l4-s6/tests/test.sh b/tasks/construct-rlve-maximum-clique-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-maximum-clique-l4-s8/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-maximum-clique-l4-s8/environment/instance.json b/tasks/construct-rlve-maximum-clique-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b2a68ee36b2aee6e4823531ec3a24444b81aa01b --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 32, "k": 11, "edges": [[0, 1], [0, 2], [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, 19], [0, 20], [0, 21], [0, 22], [0, 24], [0, 25], [0, 26], [0, 27], [0, 29], [0, 31], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 11], [1, 13], [1, 15], [1, 16], [1, 18], [1, 19], [1, 21], [1, 22], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [2, 3], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 20], [2, 21], [2, 22], [2, 26], [2, 27], [2, 28], [2, 30], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 12], [3, 13], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [4, 5], [4, 6], [4, 8], [4, 9], [4, 10], [4, 11], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 28], [4, 29], [4, 30], [4, 31], [5, 6], [5, 9], [5, 10], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 29], [5, 30], [5, 31], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [6, 27], [6, 28], [6, 29], [6, 31], [7, 8], [7, 9], [7, 10], [7, 12], [7, 13], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 20], [7, 22], [7, 23], [7, 24], [7, 27], [7, 28], [7, 29], [7, 30], [7, 31], [8, 10], [8, 12], [8, 14], [8, 16], [8, 17], [8, 19], [8, 23], [8, 24], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [9, 12], [9, 13], [9, 14], [9, 16], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 28], [9, 29], [9, 30], [9, 31], [10, 11], [10, 12], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 23], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 30], [10, 31], [11, 12], [11, 14], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 26], [11, 28], [11, 30], [11, 31], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [13, 14], [13, 15], [13, 17], [13, 18], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 25], [13, 26], [13, 28], [13, 29], [13, 30], [13, 31], [14, 15], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 25], [14, 27], [14, 29], [14, 30], [14, 31], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 23], [15, 26], [15, 28], [15, 29], [15, 30], [15, 31], [16, 17], [16, 18], [16, 19], [16, 20], [16, 22], [16, 24], [16, 25], [16, 26], [16, 28], [16, 29], [16, 31], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 30], [17, 31], [18, 20], [18, 21], [18, 23], [18, 26], [18, 27], [18, 28], [18, 29], [18, 30], [18, 31], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [19, 30], [19, 31], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 30], [21, 22], [21, 23], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [22, 23], [22, 24], [22, 26], [22, 28], [22, 30], [22, 31], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 30], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 31], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [26, 28], [26, 29], [26, 30], [26, 31], [27, 28], [27, 29], [27, 30], [27, 31], [28, 30], [28, 31], [29, 30], [29, 31], [30, 31]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l4-s8/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e10cb1a275dc4c32ecba4f0b98a9ed34424e1feb --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [0, 1, 3, 5, 6, 15, 19, 21, 26, 29, 31]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l4-s8/tests/check.py b/tasks/construct-rlve-maximum-clique-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s8/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l4-s8/tests/instance.json b/tasks/construct-rlve-maximum-clique-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b2a68ee36b2aee6e4823531ec3a24444b81aa01b --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 32, "k": 11, "edges": [[0, 1], [0, 2], [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, 19], [0, 20], [0, 21], [0, 22], [0, 24], [0, 25], [0, 26], [0, 27], [0, 29], [0, 31], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 11], [1, 13], [1, 15], [1, 16], [1, 18], [1, 19], [1, 21], [1, 22], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [2, 3], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 20], [2, 21], [2, 22], [2, 26], [2, 27], [2, 28], [2, 30], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 12], [3, 13], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [4, 5], [4, 6], [4, 8], [4, 9], [4, 10], [4, 11], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 28], [4, 29], [4, 30], [4, 31], [5, 6], [5, 9], [5, 10], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 29], [5, 30], [5, 31], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [6, 14], [6, 15], [6, 16], [6, 17], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [6, 27], [6, 28], [6, 29], [6, 31], [7, 8], [7, 9], [7, 10], [7, 12], [7, 13], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 20], [7, 22], [7, 23], [7, 24], [7, 27], [7, 28], [7, 29], [7, 30], [7, 31], [8, 10], [8, 12], [8, 14], [8, 16], [8, 17], [8, 19], [8, 23], [8, 24], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [9, 12], [9, 13], [9, 14], [9, 16], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 28], [9, 29], [9, 30], [9, 31], [10, 11], [10, 12], [10, 14], [10, 15], [10, 16], [10, 17], [10, 18], [10, 19], [10, 20], [10, 23], [10, 24], [10, 25], [10, 26], [10, 28], [10, 29], [10, 30], [10, 31], [11, 12], [11, 14], [11, 16], [11, 17], [11, 18], [11, 19], [11, 20], [11, 21], [11, 22], [11, 23], [11, 24], [11, 26], [11, 28], [11, 30], [11, 31], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 21], [12, 22], [12, 23], [12, 24], [12, 25], [12, 26], [12, 27], [12, 28], [12, 29], [12, 30], [12, 31], [13, 14], [13, 15], [13, 17], [13, 18], [13, 20], [13, 21], [13, 22], [13, 23], [13, 24], [13, 25], [13, 26], [13, 28], [13, 29], [13, 30], [13, 31], [14, 15], [14, 17], [14, 18], [14, 19], [14, 20], [14, 21], [14, 22], [14, 23], [14, 25], [14, 27], [14, 29], [14, 30], [14, 31], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 23], [15, 26], [15, 28], [15, 29], [15, 30], [15, 31], [16, 17], [16, 18], [16, 19], [16, 20], [16, 22], [16, 24], [16, 25], [16, 26], [16, 28], [16, 29], [16, 31], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 23], [17, 24], [17, 25], [17, 26], [17, 27], [17, 28], [17, 30], [17, 31], [18, 20], [18, 21], [18, 23], [18, 26], [18, 27], [18, 28], [18, 29], [18, 30], [18, 31], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 29], [19, 30], [19, 31], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 30], [21, 22], [21, 23], [21, 25], [21, 26], [21, 27], [21, 28], [21, 29], [21, 30], [21, 31], [22, 23], [22, 24], [22, 26], [22, 28], [22, 30], [22, 31], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 30], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [24, 31], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [25, 31], [26, 28], [26, 29], [26, 30], [26, 31], [27, 28], [27, 29], [27, 30], [27, 31], [28, 30], [28, 31], [29, 30], [29, 31], [30, 31]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l4-s8/tests/run.py b/tasks/construct-rlve-maximum-clique-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-maximum-clique-l4-s8/tests/test.sh b/tasks/construct-rlve-maximum-clique-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l4-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-chromatic-number-l2-s3/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l2-s3/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b6d38a43c0deb477153403fe8313979a2a9b42c9 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 10, "k": 5, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 6], [0, 8], [0, 9], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 9], [2, 3], [2, 4], [2, 5], [2, 6], [2, 9], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 6], [5, 8], [5, 9], [6, 8], [7, 8], [7, 9], [8, 9]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l2-s3/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2d5ef45d3b23f0bb0e23bcba7197fd760d803b0a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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' +{"colors": [0, 1, 0, 2, 2, 3, 4, 0, 1, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l2-s3/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l2-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-l2-s3/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b6d38a43c0deb477153403fe8313979a2a9b42c9 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 10, "k": 5, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 6], [0, 8], [0, 9], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 9], [2, 3], [2, 4], [2, 5], [2, 6], [2, 9], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 6], [5, 8], [5, 9], [6, 8], [7, 8], [7, 9], [8, 9]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l2-s3/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l2-s3/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l2-s4/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l2-s4/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fefefc67450e03fc1d7b71f1eee72e8420bed338 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 10, "k": 4, "edges": [[0, 1], [0, 2], [0, 4], [0, 7], [1, 4], [1, 5], [1, 6], [1, 8], [2, 3], [2, 7], [2, 8], [2, 9], [3, 4], [3, 5], [3, 9], [4, 6], [4, 8], [4, 9], [6, 8], [6, 9]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l2-s4/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2cb29054a76a7757c17907a9f8e73415a167b02a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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' +{"colors": [0, 1, 1, 0, 2, 2, 0, 2, 3, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l2-s4/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l2-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-l2-s4/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fefefc67450e03fc1d7b71f1eee72e8420bed338 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 10, "k": 4, "edges": [[0, 1], [0, 2], [0, 4], [0, 7], [1, 4], [1, 5], [1, 6], [1, 8], [2, 3], [2, 7], [2, 8], [2, 9], [3, 4], [3, 5], [3, 9], [4, 6], [4, 8], [4, 9], [6, 8], [6, 9]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l2-s4/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l2-s4/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-harmonious-coloring-l2-s9/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l2-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-min-harmonious-coloring-l2-s9/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2d22636256ecffaf47d84056be99742f8e57a11b --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "k": 3, "edges": [[1, 3], [4, 5]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l2-s9/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7ca92f333e79e401dc15b4d08ff42f75064dd855 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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' +{"colors": [0, 0, 0, 1, 0, 2, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l2-s9/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l2-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-l2-s9/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2d22636256ecffaf47d84056be99742f8e57a11b --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "k": 3, "edges": [[1, 3], [4, 5]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l2-s9/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l2-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-min-harmonious-coloring-l2-s9/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l2-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-harmonious-coloring-l6-s1/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l6-s1/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7d88cf68774a666e6f64ff910fe14bf30cf77475 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "k": 13, "edges": [[0, 1], [0, 5], [0, 9], [0, 10], [0, 12], [0, 14], [1, 8], [1, 13], [2, 3], [2, 13], [2, 17], [3, 6], [3, 8], [3, 10], [3, 11], [3, 13], [3, 14], [3, 17], [4, 6], [4, 8], [4, 11], [4, 14], [5, 7], [5, 9], [5, 12], [5, 13], [5, 14], [6, 13], [6, 17], [8, 11], [9, 11], [9, 12], [9, 13], [10, 13], [10, 17], [11, 13], [11, 14], [11, 16], [12, 13], [13, 16], [13, 17], [14, 15], [14, 16], [14, 17], [15, 17]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l6-s1/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5822644b5ac9e0aa0b22378741c8cfee9523f022 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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' +{"colors": [0, 1, 0, 2, 3, 4, 5, 1, 6, 7, 3, 8, 6, 9, 10, 1, 11, 12]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l6-s1/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l6-s1/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + seen = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pair = (min(c[u], c[v]), max(c[u], c[v])) + if pair in seen: + raise Invalid(f"colour pair {pair} appears on two edges") + seen.add(pair) + return None, {} diff --git a/tasks/construct-rlve-min-harmonious-coloring-l6-s1/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7d88cf68774a666e6f64ff910fe14bf30cf77475 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "k": 13, "edges": [[0, 1], [0, 5], [0, 9], [0, 10], [0, 12], [0, 14], [1, 8], [1, 13], [2, 3], [2, 13], [2, 17], [3, 6], [3, 8], [3, 10], [3, 11], [3, 13], [3, 14], [3, 17], [4, 6], [4, 8], [4, 11], [4, 14], [5, 7], [5, 9], [5, 12], [5, 13], [5, 14], [6, 13], [6, 17], [8, 11], [9, 11], [9, 12], [9, 13], [10, 13], [10, 17], [11, 13], [11, 14], [11, 16], [12, 13], [13, 16], [13, 17], [14, 15], [14, 16], [14, 17], [15, 17]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l6-s1/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l6-s1/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-harmonious-coloring-l6-s6/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l6-s6/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bd4c3171643a4d60937ca11201f2cc9a51056921 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "k": 10, "edges": [[0, 1], [0, 9], [0, 12], [1, 4], [1, 12], [1, 13], [2, 8], [2, 11], [3, 9], [4, 8], [4, 12], [5, 6], [5, 10], [5, 12], [5, 14], [5, 16], [6, 9], [7, 8], [7, 10], [7, 14], [9, 10], [9, 14], [9, 15], [10, 11], [10, 12], [10, 15], [10, 16], [11, 13], [12, 16], [13, 15]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l6-s6/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8968a34f0cb5307f2005cf8f991a6cc8b9f1a52d --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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' +{"colors": [0, 1, 0, 1, 2, 3, 2, 1, 4, 5, 6, 2, 7, 8, 9, 4, 8, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l6-s6/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l6-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-l6-s6/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bd4c3171643a4d60937ca11201f2cc9a51056921 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "k": 10, "edges": [[0, 1], [0, 9], [0, 12], [1, 4], [1, 12], [1, 13], [2, 8], [2, 11], [3, 9], [4, 8], [4, 12], [5, 6], [5, 10], [5, 12], [5, 14], [5, 16], [6, 9], [7, 8], [7, 10], [7, 14], [9, 10], [9, 14], [9, 15], [10, 11], [10, 12], [10, 15], [10, 16], [11, 13], [12, 16], [13, 15]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l6-s6/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-min-harmonious-coloring-l6-s6/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-pairwise-sums-recovery-l4-s1/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..585eef04a63953fa337447fa8b9ca74178b886e0 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "sums": [31, 27, 38, 26, 34, 34, 36, 28, 35, 19, 21, 43, 40, 7, 34, 20, 30, 38, 35, 41, 25, 42, 33, 21, 28, 18, 23, 18, 23, 9, 20, 44, 40, 32, 27, 29, 16, 27, 20, 22, 31, 33, 29, 24, 32, 29, 15, 29, 26, 35, 27, 13, 25, 33, 37, 37, 36, 31, 22, 21, 32, 14, 25, 39, 36, 14], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7f5cd53d597459c05790a3ad2a93bae639b55eb4 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"numbers": [1, 6, 8, 12, 13, 14, 15, 17, 19, 20, 21, 23]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-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-l4-s1/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..585eef04a63953fa337447fa8b9ca74178b886e0 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "sums": [31, 27, 38, 26, 34, 34, 36, 28, 35, 19, 21, 43, 40, 7, 34, 20, 30, 38, 35, 41, 25, 42, 33, 21, 28, 18, 23, 18, 23, 9, 20, 44, 40, 32, 27, 29, 16, 27, 20, 22, 31, 33, 29, 24, 32, 29, 15, 29, 26, 35, 27, 13, 25, 33, 37, 37, 36, 31, 22, 21, 32, 14, 25, 39, 36, 14], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fe7b2793fa0ecf7c93fd54eb2dad486bffaf5838 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "sums": [20, 26, 34, 39, 6, 31, 15, 24, 21, 32, 18, 24, 9, 25, 22, 13, 36, 32, 17, 25, 32, 23, 34, 36, 30, 19, 25, 44, 16, 28, 15, 21, 29, 27, 26, 34, 34, 27, 28, 43, 26, 31, 42, 33, 35, 13, 28, 24, 38, 19, 33, 11, 37, 35, 29, 38, 40, 22, 20, 23, 20, 39, 30, 29, 17, 30], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d831f3a7ec267b646eb6e6dab8dacb30934b1e56 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"numbers": [1, 5, 8, 10, 12, 14, 15, 16, 18, 19, 20, 24]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/tests/check.py @@ -0,0 +1,14 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("numbers"), n, 1, None, "numbers") + if len(set(x)) != n: + raise Invalid("numbers must be distinct") + got = Counter(x[i] + x[j] for i in range(n) for j in range(i + 1, n)) + if got != Counter(inst["sums"]): + raise Invalid("pairwise sums do not match") + return None, {} diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fe7b2793fa0ecf7c93fd54eb2dad486bffaf5838 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "sums": [20, 26, 34, 39, 6, 31, 15, 24, 21, 32, 18, 24, 9, 25, 22, 13, 36, 32, 17, 25, 32, 23, 34, 36, 30, 19, 25, 44, 16, 28, 15, 21, 29, 27, 26, 34, 34, 27, 28, 43, 26, 31, 42, 33, 35, 13, 28, 24, 38, 19, 33, 11, 37, 35, 29, 38, 40, 22, 20, 23, 20, 39, 30, 29, 17, 30], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l4-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-pan-solar-panels-l5-s3/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l5-s3/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..81e38ea53a4825082f8af9c359c55cf2da17290c --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"A": 42553964, "B": 257723116, "C": 501693358, "D": 551265586, "target": 257723116, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l5-s3/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..23fa19a49bebaffb0b107329624eab2b4472c1f1 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l5-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"X": 257723116, "Y": 515446232} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l5-s3/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l5-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-l5-s3/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..81e38ea53a4825082f8af9c359c55cf2da17290c --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"A": 42553964, "B": 257723116, "C": 501693358, "D": 551265586, "target": 257723116, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l5-s3/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l5-s3/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l5-s4/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l5-s4/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9035e43ff6bd95b858df901af05963c1ce767962 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"A": 794675486, "B": 895288867, "C": 152346316, "D": 485347160, "target": 447644433, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l5-s4/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7f8652843ef370f5331beb08983c8a01de688d1c --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l5-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"X": 895288866, "Y": 447644433} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l5-s4/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l5-s4/tests/check.py @@ -0,0 +1,12 @@ +import math + +from run import Invalid, as_int + + +def check(inst, ans): + X = as_int(ans.get("X"), "X", lo=inst["A"], hi=inst["B"]) + Y = as_int(ans.get("Y"), "Y", lo=inst["C"], hi=inst["D"]) + g = math.gcd(X, Y) + if g < inst["target"]: + raise Invalid(f"gcd(X, Y) = {g} < {inst['target']}") + return None, {"gcd": g} diff --git a/tasks/construct-rlve-pan-solar-panels-l5-s4/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9035e43ff6bd95b858df901af05963c1ce767962 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"A": 794675486, "B": 895288867, "C": 152346316, "D": 485347160, "target": 447644433, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l5-s4/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l5-s4/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-polynomial-global-minimum-l4-s9/environment/Dockerfile b/tasks/construct-rlve-polynomial-global-minimum-l4-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-global-minimum-l4-s9/environment/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l4-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3cfccfdcceeed203c6d0a226260bc0b137f28559 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l4-s9/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [2, 6, 29, 56, 71, 56, 30, 8, 1], "fmin": "1.59415268296088023471190880488608201624969055", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l4-s9/solution/solve.sh b/tasks/construct-rlve-polynomial-global-minimum-l4-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f26c5814512d86e327f0ef79e186a724e47a6a32 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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' +{"x0": -0.16105159721585188} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-global-minimum-l4-s9/tests/check.py b/tasks/construct-rlve-polynomial-global-minimum-l4-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3be068f4391ad0838c29a4f7d521b8072cf39991 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l4-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-l4-s9/tests/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l4-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3cfccfdcceeed203c6d0a226260bc0b137f28559 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l4-s9/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [2, 6, 29, 56, 71, 56, 30, 8, 1], "fmin": "1.59415268296088023471190880488608201624969055", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l4-s9/tests/run.py b/tasks/construct-rlve-polynomial-global-minimum-l4-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-global-minimum-l4-s9/tests/test.sh b/tasks/construct-rlve-polynomial-global-minimum-l4-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-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-polynomial-interpolation-l4-s2/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-interpolation-l4-s2/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ab3f0f0764696fe2d174d847231631df3e1b8f76 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"X": [9, -3, -4, -1, 5, 8, -6, 7, 3, -5], "Y": [953685014, -93166, -1123672, -16, 4045226, 321804740, -38812006, 93491464, 31580, -7860284], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l4-s2/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..63d1363dc07a557d734d19ad4d08ce1f8140d388 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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' +{"coeffs": [-4, 1, -1, -3, -2, 5, 3, 1, -5, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l4-s2/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l4-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-l4-s2/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ab3f0f0764696fe2d174d847231631df3e1b8f76 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"X": [9, -3, -4, -1, 5, 8, -6, 7, 3, -5], "Y": [953685014, -93166, -1123672, -16, 4045226, 321804740, -38812006, 93491464, 31580, -7860284], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l4-s2/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-interpolation-l4-s2/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-interpolation-l4-s5/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l4-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-interpolation-l4-s5/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l4-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f726e7dee3d287d5b8dc18e58289e3e6a2ed37a0 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l4-s5/environment/instance.json @@ -0,0 +1 @@ +{"X": [8, -8, -9, 3, 2, 0, -6, -7, -2, -5], "Y": [384677117, -416175859, -1198198561, 51887, 1211, 5, -31422301, -125477473, -1393, -6100465], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l4-s5/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l4-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0f54e3126d0e698936562b207d72af33105d9994 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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' +{"coeffs": [5, -1, -4, 3, -5, -4, 4, -1, -1, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l4-s5/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l4-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l4-s5/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + X, Y = inst["X"], inst["Y"] + c = int_list(ans.get("coeffs"), len(X), name="coeffs") + for x, y in zip(X, Y): + v = 0 + for a in reversed(c): + v = v * x + a + if v != y: + raise Invalid(f"f({x}) = {v}, need {y}") + return None, {} diff --git a/tasks/construct-rlve-polynomial-interpolation-l4-s5/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l4-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f726e7dee3d287d5b8dc18e58289e3e6a2ed37a0 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l4-s5/tests/instance.json @@ -0,0 +1 @@ +{"X": [8, -8, -9, 3, 2, 0, -6, -7, -2, -5], "Y": [384677117, -416175859, -1198198561, 51887, 1211, 5, -31422301, -125477473, -1393, -6100465], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l4-s5/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l4-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-interpolation-l4-s5/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l4-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-prefix-product-permutation-l4-s0/environment/Dockerfile b/tasks/construct-rlve-prefix-product-permutation-l4-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-product-permutation-l4-s0/environment/instance.json b/tasks/construct-rlve-prefix-product-permutation-l4-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ba491d21b9151a6086d0afcf291cb621f1c401e --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 701, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l4-s0/solution/solve.sh b/tasks/construct-rlve-prefix-product-permutation-l4-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f5e3e830176c3b11bb6ebce989347d9afa2bdd1b --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [1, 2, 352, 235, 527, 562, 118, 602, 264, 79, 632, 256, 410, 55, 652, 188, 483, 166, 40, 370, 667, 435, 479, 62, 556, 674, 28, 27, 677, 557, 445, 295, 242, 86, 434, 682, 371, 361, 536, 19, 334, 172, 218, 539, 240, 297, 382, 180, 629, 187, 688, 56, 365, 292, 14, 52, 339, 124, 279, 203, 223, 24, 148, 613, 472, 152, 394, 566, 568, 255, 692, 80, 186, 654, 181, 459, 619, 438, 10, 72, 518, 477, 437, 626, 460, 34, 270, 420, 471, 639, 149, 209, 542, 99, 441, 215, 315, 160, 94, 263, 695, 119, 379, 457, 183, 228, 497, 191, 358, 329, 377, 121, 170, 336, 413, 574, 140, 7, 102, 325, 112, 534, 363, 58, 425, 416, 307, 139, 587, 414, 427, 199, 548, 254, 634, 567, 635, 395, 128, 117, 697, 528, 391, 452, 444, 673, 678, 63, 91, 495, 230, 66, 310, 253, 570, 200, 356, 193, 387, 98, 610, 210, 239, 659, 219, 18, 664, 362, 581, 113, 368, 42, 486, 390, 561, 698, 236, 302, 320, 48, 75, 245, 105, 476, 622, 73, 50, 16, 221, 205, 108, 346, 158, 317, 431, 285, 398, 275, 132, 156, 348, 423, 60, 481, 190, 596, 229, 553, 92, 162, 465, 403, 249, 261, 96, 389, 530, 43, 165, 686, 189, 499, 61, 680, 436, 621, 519, 106, 207, 151, 638, 614, 421, 350, 4, 177, 402, 492, 163, 45, 407, 33, 618, 627, 182, 599, 380, 299, 213, 443, 559, 392, 154, 134, 70, 12, 294, 672, 558, 453, 214, 608, 100, 9, 625, 620, 478, 681, 668, 87, 284, 508, 318, 304, 198, 572, 415, 578, 59, 501, 349, 470, 615, 271, 196, 306, 577, 426, 573, 588, 337, 54, 690, 257, 32, 462, 46, 322, 248, 491, 466, 178, 384, 274, 506, 286, 127, 565, 636, 153, 451, 560, 529, 487, 97, 544, 194, 273, 400, 179, 656, 298, 456, 600, 120, 592, 330, 344, 110, 327, 360, 666, 683, 41, 532, 114, 291, 650, 57, 580, 535, 665, 372, 328, 594, 192, 546, 201, 281, 234, 700, 3, 469, 422, 502, 157, 511, 109, 375, 331, 38, 168, 123, 646, 53, 412, 589, 171, 662, 20, 37, 343, 376, 593, 359, 373, 111, 583, 103, 247, 405, 47, 524, 303, 430, 509, 159, 606, 216, 174, 143, 252, 550, 67, 138, 576, 417, 197, 429, 319, 525, 237, 212, 455, 381, 657, 241, 671, 446, 13, 649, 366, 115, 130, 277, 126, 397, 507, 432, 88, 233, 354, 202, 644, 125, 288, 131, 505, 399, 385, 195, 419, 616, 35, 22, 225, 83, 78, 694, 603, 95, 489, 250, 145, 31, 409, 691, 633, 569, 549, 311, 144, 260, 490, 404, 323, 104, 521, 76, 85, 670, 296, 658, 540, 211, 301, 526, 699, 353, 282, 89, 65, 552, 496, 597, 184, 82, 267, 23, 642, 204, 514, 17, 538, 660, 173, 314, 607, 442, 454, 300, 238, 541, 611, 150, 474, 107, 513, 222, 643, 280, 355, 547, 571, 428, 305, 418, 272, 386, 545, 357, 595, 498, 482, 687, 653, 630, 81, 227, 598, 458, 628, 655, 383, 401, 467, 5, 142, 313, 217, 661, 335, 590, 122, 341, 39, 685, 484, 44, 464, 493, 93, 605, 316, 510, 347, 503, 133, 450, 393, 637, 473, 208, 612, 640, 25, 30, 259, 251, 312, 175, 6, 586, 575, 308, 68, 136, 69, 449, 155, 504, 276, 289, 116, 564, 396, 287, 278, 645, 340, 169, 591, 378, 601, 696, 563, 129, 290, 367, 533, 582, 326, 374, 345, 512, 206, 475, 520, 246, 324, 584, 8, 440, 609, 543, 388, 488, 262, 604, 161, 494, 554, 64, 232, 283, 433, 669, 243, 77, 266, 226, 185, 631, 693, 265, 84, 244, 522, 49, 517, 623, 11, 448, 135, 137, 309, 551, 231, 90, 555, 679, 480, 500, 424, 579, 364, 651, 689, 411, 338, 647, 15, 516, 74, 523, 321, 406, 463, 164, 485, 531, 369, 684, 167, 342, 332, 21, 269, 617, 461, 408, 258, 146, 26, 676, 675, 29, 147, 641, 224, 268, 36, 333, 663, 537, 220, 515, 51, 648, 293, 447, 71, 624, 439, 101, 585, 141, 176, 468, 351, 701]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-product-permutation-l4-s0/tests/check.py b/tasks/construct-rlve-prefix-product-permutation-l4-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3d93850acd79cc0f8fff05cdbb0c63aabc484815 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-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-l4-s0/tests/instance.json b/tasks/construct-rlve-prefix-product-permutation-l4-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ba491d21b9151a6086d0afcf291cb621f1c401e --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 701, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l4-s0/tests/run.py b/tasks/construct-rlve-prefix-product-permutation-l4-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-product-permutation-l4-s0/tests/test.sh b/tasks/construct-rlve-prefix-product-permutation-l4-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-product-permutation-l4-s7/environment/Dockerfile b/tasks/construct-rlve-prefix-product-permutation-l4-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-product-permutation-l4-s7/environment/instance.json b/tasks/construct-rlve-prefix-product-permutation-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c395dd831e6f334c5439993bd41e25f903652d8a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 1013, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l4-s7/solution/solve.sh b/tasks/construct-rlve-prefix-product-permutation-l4-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..85b76a8eade3c2c159e16a89f3913e228a85231b --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [1, 2, 508, 339, 761, 609, 170, 580, 381, 789, 305, 922, 592, 79, 797, 879, 191, 299, 395, 161, 153, 194, 968, 970, 803, 933, 40, 939, 399, 525, 440, 916, 96, 308, 150, 522, 198, 795, 81, 27, 77, 594, 604, 802, 991, 969, 992, 195, 402, 952, 467, 438, 527, 842, 470, 793, 200, 392, 263, 911, 727, 466, 965, 403, 555, 827, 661, 379, 582, 324, 768, 800, 606, 903, 398, 987, 41, 422, 14, 219, 39, 989, 804, 477, 809, 871, 908, 851, 496, 388, 485, 591, 1003, 306, 98, 33, 708, 95, 983, 441, 234, 673, 726, 955, 264, 850, 928, 872, 742, 159, 397, 941, 607, 763, 703, 600, 132, 685, 456, 333, 364, 361, 740, 874, 483, 390, 202, 679, 278, 268, 414, 117, 331, 458, 190, 999, 798, 770, 669, 482, 891, 741, 907, 929, 810, 511, 452, 318, 706, 35, 494, 853, 21, 822, 718, 184, 514, 272, 110, 619, 20, 863, 495, 927, 909, 265, 239, 553, 405, 7, 436, 469, 961, 528, 426, 713, 755, 642, 701, 765, 243, 348, 296, 156, 502, 565, 660, 949, 556, 135, 17, 717, 861, 22, 48, 614, 492, 37, 221, 57, 624, 127, 337, 510, 870, 930, 478, 784, 639, 476, 932, 990, 971, 605, 943, 769, 878, 1000, 80, 977, 199, 959, 471, 587, 304, 1005, 382, 657, 352, 638, 807, 479, 573, 101, 343, 445, 735, 749, 167, 463, 689, 249, 181, 668, 877, 799, 944, 325, 242, 835, 702, 901, 608, 1010, 340, 291, 646, 474, 641, 838, 714, 622, 59, 105, 166, 777, 736, 130, 602, 596, 500, 158, 906, 873, 892, 362, 335, 129, 748, 778, 446, 722, 371, 316, 454, 687, 465, 954, 912, 674, 256, 370, 733, 447, 666, 183, 860, 823, 18, 621, 754, 839, 427, 225, 11, 94, 918, 34, 866, 319, 599, 900, 764, 836, 643, 284, 562, 148, 310, 417, 517, 629, 432, 70, 248, 774, 464, 729, 455, 897, 133, 558, 120, 652, 277, 887, 203, 506, 4, 255, 725, 913, 235, 571, 481, 876, 771, 182, 720, 448, 357, 229, 378, 948, 828, 566, 351, 787, 383, 650, 122, 276, 681, 121, 655, 384, 585, 473, 758, 292, 283, 700, 837, 756, 475, 806, 785, 353, 68, 434, 9, 227, 359, 366, 431, 693, 518, 90, 531, 126, 814, 58, 753, 715, 19, 855, 111, 75, 29, 491, 819, 49, 64, 461, 169, 1009, 762, 902, 942, 801, 972, 595, 746, 131, 899, 704, 320, 499, 745, 603, 973, 78, 1002, 923, 486, 175, 303, 791, 472, 648, 385, 323, 946, 380, 1007, 171, 547, 52, 489, 31, 100, 782, 480, 671, 236, 281, 294, 350, 659, 829, 503, 147, 698, 285, 329, 119, 683, 134, 826, 950, 404, 847, 240, 327, 287, 62, 51, 578, 172, 55, 223, 429, 368, 258, 375, 210, 84, 207, 232, 443, 345, 140, 125, 626, 91, 425, 841, 962, 439, 985, 400, 197, 979, 151, 163, 89, 628, 694, 418, 271, 858, 185, 451, 869, 811, 338, 1012, 3, 677, 204, 146, 564, 830, 157, 744, 597, 321, 387, 926, 852, 864, 36, 818, 615, 30, 576, 53, 174, 590, 924, 389, 890, 875, 670, 572, 783, 808, 931, 805, 640, 757, 647, 586, 792, 960, 843, 437, 964, 953, 728, 688, 775, 168, 611, 65, 189, 881, 332, 896, 686, 730, 317, 868, 512, 186, 356, 665, 721, 734, 779, 344, 535, 233, 915, 984, 526, 963, 468, 844, 8, 635, 69, 692, 630, 367, 543, 224, 712, 840, 529, 92, 13, 937, 42, 412, 270, 516, 695, 311, 116, 884, 269, 420, 43, 214, 73, 113, 253, 6, 846, 554, 951, 966, 196, 524, 986, 940, 904, 160, 996, 300, 262, 957, 201, 889, 484, 925, 497, 322, 584, 649, 656, 788, 1006, 581, 947, 662, 230, 209, 540, 259, 178, 315, 732, 723, 257, 542, 430, 631, 360, 894, 334, 739, 893, 365, 632, 228, 664, 449, 187, 67, 637, 786, 658, 567, 295, 833, 244, 139, 534, 444, 780, 102, 290, 760, 1011, 509, 812, 128, 738, 363, 895, 457, 882, 118, 560, 286, 551, 241, 767, 945, 583, 386, 498, 598, 705, 867, 453, 731, 372, 179, 251, 115, 416, 696, 149, 981, 97, 921, 1004, 790, 588, 176, 261, 394, 997, 192, 155, 832, 349, 568, 282, 645, 759, 341, 103, 61, 550, 328, 561, 699, 644, 293, 569, 237, 267, 886, 680, 653, 123, 142, 109, 857, 515, 419, 413, 885, 279, 238, 849, 910, 956, 393, 301, 177, 374, 541, 369, 724, 675, 5, 407, 114, 313, 180, 773, 690, 71, 216, 138, 347, 834, 766, 326, 552, 848, 266, 280, 570, 672, 914, 442, 536, 208, 377, 663, 358, 633, 10, 711, 428, 544, 56, 816, 38, 935, 15, 137, 246, 72, 410, 44, 25, 83, 539, 376, 231, 537, 85, 145, 505, 678, 888, 391, 958, 794, 978, 523, 401, 967, 993, 154, 298, 998, 880, 459, 66, 355, 450, 513, 859, 719, 667, 772, 250, 314, 373, 260, 302, 589, 487, 54, 546, 579, 1008, 610, 462, 776, 750, 106, 88, 520, 152, 995, 396, 905, 743, 501, 831, 297, 193, 994, 162, 521, 980, 309, 697, 563, 504, 205, 86, 108, 274, 124, 533, 346, 245, 217, 16, 825, 557, 684, 898, 601, 747, 737, 336, 813, 625, 532, 141, 275, 654, 651, 682, 559, 330, 883, 415, 312, 252, 408, 74, 618, 856, 273, 143, 87, 165, 751, 60, 289, 342, 781, 574, 32, 920, 307, 982, 917, 709, 12, 424, 530, 627, 519, 164, 107, 144, 206, 538, 211, 26, 976, 796, 1001, 593, 974, 28, 617, 112, 409, 215, 247, 691, 433, 636, 354, 188, 460, 612, 50, 549, 288, 104, 752, 623, 815, 222, 545, 173, 488, 577, 548, 63, 613, 820, 23, 46, 24, 213, 411, 421, 938, 988, 934, 220, 817, 493, 865, 707, 919, 99, 575, 490, 616, 76, 975, 82, 212, 45, 47, 821, 862, 854, 620, 716, 824, 136, 218, 936, 423, 93, 710, 226, 634, 435, 845, 406, 254, 676, 507, 1013]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-product-permutation-l4-s7/tests/check.py b/tasks/construct-rlve-prefix-product-permutation-l4-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3d93850acd79cc0f8fff05cdbb0c63aabc484815 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-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-l4-s7/tests/instance.json b/tasks/construct-rlve-prefix-product-permutation-l4-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c395dd831e6f334c5439993bd41e25f903652d8a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 1013, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l4-s7/tests/run.py b/tasks/construct-rlve-prefix-product-permutation-l4-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-product-permutation-l4-s7/tests/test.sh b/tasks/construct-rlve-prefix-product-permutation-l4-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l4-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s1/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s1/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4b1fac7326e492bc00a708326f80348c27ee1ae5 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 1292, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s1/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0ffa5649013edcc159a95afce7e24500fc049384 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [1292, 1, 1290, 3, 1288, 5, 1286, 7, 1284, 9, 1282, 11, 1280, 13, 1278, 15, 1276, 17, 1274, 19, 1272, 21, 1270, 23, 1268, 25, 1266, 27, 1264, 29, 1262, 31, 1260, 33, 1258, 35, 1256, 37, 1254, 39, 1252, 41, 1250, 43, 1248, 45, 1246, 47, 1244, 49, 1242, 51, 1240, 53, 1238, 55, 1236, 57, 1234, 59, 1232, 61, 1230, 63, 1228, 65, 1226, 67, 1224, 69, 1222, 71, 1220, 73, 1218, 75, 1216, 77, 1214, 79, 1212, 81, 1210, 83, 1208, 85, 1206, 87, 1204, 89, 1202, 91, 1200, 93, 1198, 95, 1196, 97, 1194, 99, 1192, 101, 1190, 103, 1188, 105, 1186, 107, 1184, 109, 1182, 111, 1180, 113, 1178, 115, 1176, 117, 1174, 119, 1172, 121, 1170, 123, 1168, 125, 1166, 127, 1164, 129, 1162, 131, 1160, 133, 1158, 135, 1156, 137, 1154, 139, 1152, 141, 1150, 143, 1148, 145, 1146, 147, 1144, 149, 1142, 151, 1140, 153, 1138, 155, 1136, 157, 1134, 159, 1132, 161, 1130, 163, 1128, 165, 1126, 167, 1124, 169, 1122, 171, 1120, 173, 1118, 175, 1116, 177, 1114, 179, 1112, 181, 1110, 183, 1108, 185, 1106, 187, 1104, 189, 1102, 191, 1100, 193, 1098, 195, 1096, 197, 1094, 199, 1092, 201, 1090, 203, 1088, 205, 1086, 207, 1084, 209, 1082, 211, 1080, 213, 1078, 215, 1076, 217, 1074, 219, 1072, 221, 1070, 223, 1068, 225, 1066, 227, 1064, 229, 1062, 231, 1060, 233, 1058, 235, 1056, 237, 1054, 239, 1052, 241, 1050, 243, 1048, 245, 1046, 247, 1044, 249, 1042, 251, 1040, 253, 1038, 255, 1036, 257, 1034, 259, 1032, 261, 1030, 263, 1028, 265, 1026, 267, 1024, 269, 1022, 271, 1020, 273, 1018, 275, 1016, 277, 1014, 279, 1012, 281, 1010, 283, 1008, 285, 1006, 287, 1004, 289, 1002, 291, 1000, 293, 998, 295, 996, 297, 994, 299, 992, 301, 990, 303, 988, 305, 986, 307, 984, 309, 982, 311, 980, 313, 978, 315, 976, 317, 974, 319, 972, 321, 970, 323, 968, 325, 966, 327, 964, 329, 962, 331, 960, 333, 958, 335, 956, 337, 954, 339, 952, 341, 950, 343, 948, 345, 946, 347, 944, 349, 942, 351, 940, 353, 938, 355, 936, 357, 934, 359, 932, 361, 930, 363, 928, 365, 926, 367, 924, 369, 922, 371, 920, 373, 918, 375, 916, 377, 914, 379, 912, 381, 910, 383, 908, 385, 906, 387, 904, 389, 902, 391, 900, 393, 898, 395, 896, 397, 894, 399, 892, 401, 890, 403, 888, 405, 886, 407, 884, 409, 882, 411, 880, 413, 878, 415, 876, 417, 874, 419, 872, 421, 870, 423, 868, 425, 866, 427, 864, 429, 862, 431, 860, 433, 858, 435, 856, 437, 854, 439, 852, 441, 850, 443, 848, 445, 846, 447, 844, 449, 842, 451, 840, 453, 838, 455, 836, 457, 834, 459, 832, 461, 830, 463, 828, 465, 826, 467, 824, 469, 822, 471, 820, 473, 818, 475, 816, 477, 814, 479, 812, 481, 810, 483, 808, 485, 806, 487, 804, 489, 802, 491, 800, 493, 798, 495, 796, 497, 794, 499, 792, 501, 790, 503, 788, 505, 786, 507, 784, 509, 782, 511, 780, 513, 778, 515, 776, 517, 774, 519, 772, 521, 770, 523, 768, 525, 766, 527, 764, 529, 762, 531, 760, 533, 758, 535, 756, 537, 754, 539, 752, 541, 750, 543, 748, 545, 746, 547, 744, 549, 742, 551, 740, 553, 738, 555, 736, 557, 734, 559, 732, 561, 730, 563, 728, 565, 726, 567, 724, 569, 722, 571, 720, 573, 718, 575, 716, 577, 714, 579, 712, 581, 710, 583, 708, 585, 706, 587, 704, 589, 702, 591, 700, 593, 698, 595, 696, 597, 694, 599, 692, 601, 690, 603, 688, 605, 686, 607, 684, 609, 682, 611, 680, 613, 678, 615, 676, 617, 674, 619, 672, 621, 670, 623, 668, 625, 666, 627, 664, 629, 662, 631, 660, 633, 658, 635, 656, 637, 654, 639, 652, 641, 650, 643, 648, 645, 646, 647, 644, 649, 642, 651, 640, 653, 638, 655, 636, 657, 634, 659, 632, 661, 630, 663, 628, 665, 626, 667, 624, 669, 622, 671, 620, 673, 618, 675, 616, 677, 614, 679, 612, 681, 610, 683, 608, 685, 606, 687, 604, 689, 602, 691, 600, 693, 598, 695, 596, 697, 594, 699, 592, 701, 590, 703, 588, 705, 586, 707, 584, 709, 582, 711, 580, 713, 578, 715, 576, 717, 574, 719, 572, 721, 570, 723, 568, 725, 566, 727, 564, 729, 562, 731, 560, 733, 558, 735, 556, 737, 554, 739, 552, 741, 550, 743, 548, 745, 546, 747, 544, 749, 542, 751, 540, 753, 538, 755, 536, 757, 534, 759, 532, 761, 530, 763, 528, 765, 526, 767, 524, 769, 522, 771, 520, 773, 518, 775, 516, 777, 514, 779, 512, 781, 510, 783, 508, 785, 506, 787, 504, 789, 502, 791, 500, 793, 498, 795, 496, 797, 494, 799, 492, 801, 490, 803, 488, 805, 486, 807, 484, 809, 482, 811, 480, 813, 478, 815, 476, 817, 474, 819, 472, 821, 470, 823, 468, 825, 466, 827, 464, 829, 462, 831, 460, 833, 458, 835, 456, 837, 454, 839, 452, 841, 450, 843, 448, 845, 446, 847, 444, 849, 442, 851, 440, 853, 438, 855, 436, 857, 434, 859, 432, 861, 430, 863, 428, 865, 426, 867, 424, 869, 422, 871, 420, 873, 418, 875, 416, 877, 414, 879, 412, 881, 410, 883, 408, 885, 406, 887, 404, 889, 402, 891, 400, 893, 398, 895, 396, 897, 394, 899, 392, 901, 390, 903, 388, 905, 386, 907, 384, 909, 382, 911, 380, 913, 378, 915, 376, 917, 374, 919, 372, 921, 370, 923, 368, 925, 366, 927, 364, 929, 362, 931, 360, 933, 358, 935, 356, 937, 354, 939, 352, 941, 350, 943, 348, 945, 346, 947, 344, 949, 342, 951, 340, 953, 338, 955, 336, 957, 334, 959, 332, 961, 330, 963, 328, 965, 326, 967, 324, 969, 322, 971, 320, 973, 318, 975, 316, 977, 314, 979, 312, 981, 310, 983, 308, 985, 306, 987, 304, 989, 302, 991, 300, 993, 298, 995, 296, 997, 294, 999, 292, 1001, 290, 1003, 288, 1005, 286, 1007, 284, 1009, 282, 1011, 280, 1013, 278, 1015, 276, 1017, 274, 1019, 272, 1021, 270, 1023, 268, 1025, 266, 1027, 264, 1029, 262, 1031, 260, 1033, 258, 1035, 256, 1037, 254, 1039, 252, 1041, 250, 1043, 248, 1045, 246, 1047, 244, 1049, 242, 1051, 240, 1053, 238, 1055, 236, 1057, 234, 1059, 232, 1061, 230, 1063, 228, 1065, 226, 1067, 224, 1069, 222, 1071, 220, 1073, 218, 1075, 216, 1077, 214, 1079, 212, 1081, 210, 1083, 208, 1085, 206, 1087, 204, 1089, 202, 1091, 200, 1093, 198, 1095, 196, 1097, 194, 1099, 192, 1101, 190, 1103, 188, 1105, 186, 1107, 184, 1109, 182, 1111, 180, 1113, 178, 1115, 176, 1117, 174, 1119, 172, 1121, 170, 1123, 168, 1125, 166, 1127, 164, 1129, 162, 1131, 160, 1133, 158, 1135, 156, 1137, 154, 1139, 152, 1141, 150, 1143, 148, 1145, 146, 1147, 144, 1149, 142, 1151, 140, 1153, 138, 1155, 136, 1157, 134, 1159, 132, 1161, 130, 1163, 128, 1165, 126, 1167, 124, 1169, 122, 1171, 120, 1173, 118, 1175, 116, 1177, 114, 1179, 112, 1181, 110, 1183, 108, 1185, 106, 1187, 104, 1189, 102, 1191, 100, 1193, 98, 1195, 96, 1197, 94, 1199, 92, 1201, 90, 1203, 88, 1205, 86, 1207, 84, 1209, 82, 1211, 80, 1213, 78, 1215, 76, 1217, 74, 1219, 72, 1221, 70, 1223, 68, 1225, 66, 1227, 64, 1229, 62, 1231, 60, 1233, 58, 1235, 56, 1237, 54, 1239, 52, 1241, 50, 1243, 48, 1245, 46, 1247, 44, 1249, 42, 1251, 40, 1253, 38, 1255, 36, 1257, 34, 1259, 32, 1261, 30, 1263, 28, 1265, 26, 1267, 24, 1269, 22, 1271, 20, 1273, 18, 1275, 16, 1277, 14, 1279, 12, 1281, 10, 1283, 8, 1285, 6, 1287, 4, 1289, 2, 1291]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s1/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s1/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 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-l4-s1/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4b1fac7326e492bc00a708326f80348c27ee1ae5 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 1292, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s1/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s1/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s6/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s6/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..35bbca5031b7d7dde39ac4ff73e149bbaac983f8 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 1710, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s6/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8fa07470be07122d7906e0762582721bd03b5921 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [1710, 1, 1708, 3, 1706, 5, 1704, 7, 1702, 9, 1700, 11, 1698, 13, 1696, 15, 1694, 17, 1692, 19, 1690, 21, 1688, 23, 1686, 25, 1684, 27, 1682, 29, 1680, 31, 1678, 33, 1676, 35, 1674, 37, 1672, 39, 1670, 41, 1668, 43, 1666, 45, 1664, 47, 1662, 49, 1660, 51, 1658, 53, 1656, 55, 1654, 57, 1652, 59, 1650, 61, 1648, 63, 1646, 65, 1644, 67, 1642, 69, 1640, 71, 1638, 73, 1636, 75, 1634, 77, 1632, 79, 1630, 81, 1628, 83, 1626, 85, 1624, 87, 1622, 89, 1620, 91, 1618, 93, 1616, 95, 1614, 97, 1612, 99, 1610, 101, 1608, 103, 1606, 105, 1604, 107, 1602, 109, 1600, 111, 1598, 113, 1596, 115, 1594, 117, 1592, 119, 1590, 121, 1588, 123, 1586, 125, 1584, 127, 1582, 129, 1580, 131, 1578, 133, 1576, 135, 1574, 137, 1572, 139, 1570, 141, 1568, 143, 1566, 145, 1564, 147, 1562, 149, 1560, 151, 1558, 153, 1556, 155, 1554, 157, 1552, 159, 1550, 161, 1548, 163, 1546, 165, 1544, 167, 1542, 169, 1540, 171, 1538, 173, 1536, 175, 1534, 177, 1532, 179, 1530, 181, 1528, 183, 1526, 185, 1524, 187, 1522, 189, 1520, 191, 1518, 193, 1516, 195, 1514, 197, 1512, 199, 1510, 201, 1508, 203, 1506, 205, 1504, 207, 1502, 209, 1500, 211, 1498, 213, 1496, 215, 1494, 217, 1492, 219, 1490, 221, 1488, 223, 1486, 225, 1484, 227, 1482, 229, 1480, 231, 1478, 233, 1476, 235, 1474, 237, 1472, 239, 1470, 241, 1468, 243, 1466, 245, 1464, 247, 1462, 249, 1460, 251, 1458, 253, 1456, 255, 1454, 257, 1452, 259, 1450, 261, 1448, 263, 1446, 265, 1444, 267, 1442, 269, 1440, 271, 1438, 273, 1436, 275, 1434, 277, 1432, 279, 1430, 281, 1428, 283, 1426, 285, 1424, 287, 1422, 289, 1420, 291, 1418, 293, 1416, 295, 1414, 297, 1412, 299, 1410, 301, 1408, 303, 1406, 305, 1404, 307, 1402, 309, 1400, 311, 1398, 313, 1396, 315, 1394, 317, 1392, 319, 1390, 321, 1388, 323, 1386, 325, 1384, 327, 1382, 329, 1380, 331, 1378, 333, 1376, 335, 1374, 337, 1372, 339, 1370, 341, 1368, 343, 1366, 345, 1364, 347, 1362, 349, 1360, 351, 1358, 353, 1356, 355, 1354, 357, 1352, 359, 1350, 361, 1348, 363, 1346, 365, 1344, 367, 1342, 369, 1340, 371, 1338, 373, 1336, 375, 1334, 377, 1332, 379, 1330, 381, 1328, 383, 1326, 385, 1324, 387, 1322, 389, 1320, 391, 1318, 393, 1316, 395, 1314, 397, 1312, 399, 1310, 401, 1308, 403, 1306, 405, 1304, 407, 1302, 409, 1300, 411, 1298, 413, 1296, 415, 1294, 417, 1292, 419, 1290, 421, 1288, 423, 1286, 425, 1284, 427, 1282, 429, 1280, 431, 1278, 433, 1276, 435, 1274, 437, 1272, 439, 1270, 441, 1268, 443, 1266, 445, 1264, 447, 1262, 449, 1260, 451, 1258, 453, 1256, 455, 1254, 457, 1252, 459, 1250, 461, 1248, 463, 1246, 465, 1244, 467, 1242, 469, 1240, 471, 1238, 473, 1236, 475, 1234, 477, 1232, 479, 1230, 481, 1228, 483, 1226, 485, 1224, 487, 1222, 489, 1220, 491, 1218, 493, 1216, 495, 1214, 497, 1212, 499, 1210, 501, 1208, 503, 1206, 505, 1204, 507, 1202, 509, 1200, 511, 1198, 513, 1196, 515, 1194, 517, 1192, 519, 1190, 521, 1188, 523, 1186, 525, 1184, 527, 1182, 529, 1180, 531, 1178, 533, 1176, 535, 1174, 537, 1172, 539, 1170, 541, 1168, 543, 1166, 545, 1164, 547, 1162, 549, 1160, 551, 1158, 553, 1156, 555, 1154, 557, 1152, 559, 1150, 561, 1148, 563, 1146, 565, 1144, 567, 1142, 569, 1140, 571, 1138, 573, 1136, 575, 1134, 577, 1132, 579, 1130, 581, 1128, 583, 1126, 585, 1124, 587, 1122, 589, 1120, 591, 1118, 593, 1116, 595, 1114, 597, 1112, 599, 1110, 601, 1108, 603, 1106, 605, 1104, 607, 1102, 609, 1100, 611, 1098, 613, 1096, 615, 1094, 617, 1092, 619, 1090, 621, 1088, 623, 1086, 625, 1084, 627, 1082, 629, 1080, 631, 1078, 633, 1076, 635, 1074, 637, 1072, 639, 1070, 641, 1068, 643, 1066, 645, 1064, 647, 1062, 649, 1060, 651, 1058, 653, 1056, 655, 1054, 657, 1052, 659, 1050, 661, 1048, 663, 1046, 665, 1044, 667, 1042, 669, 1040, 671, 1038, 673, 1036, 675, 1034, 677, 1032, 679, 1030, 681, 1028, 683, 1026, 685, 1024, 687, 1022, 689, 1020, 691, 1018, 693, 1016, 695, 1014, 697, 1012, 699, 1010, 701, 1008, 703, 1006, 705, 1004, 707, 1002, 709, 1000, 711, 998, 713, 996, 715, 994, 717, 992, 719, 990, 721, 988, 723, 986, 725, 984, 727, 982, 729, 980, 731, 978, 733, 976, 735, 974, 737, 972, 739, 970, 741, 968, 743, 966, 745, 964, 747, 962, 749, 960, 751, 958, 753, 956, 755, 954, 757, 952, 759, 950, 761, 948, 763, 946, 765, 944, 767, 942, 769, 940, 771, 938, 773, 936, 775, 934, 777, 932, 779, 930, 781, 928, 783, 926, 785, 924, 787, 922, 789, 920, 791, 918, 793, 916, 795, 914, 797, 912, 799, 910, 801, 908, 803, 906, 805, 904, 807, 902, 809, 900, 811, 898, 813, 896, 815, 894, 817, 892, 819, 890, 821, 888, 823, 886, 825, 884, 827, 882, 829, 880, 831, 878, 833, 876, 835, 874, 837, 872, 839, 870, 841, 868, 843, 866, 845, 864, 847, 862, 849, 860, 851, 858, 853, 856, 855, 854, 857, 852, 859, 850, 861, 848, 863, 846, 865, 844, 867, 842, 869, 840, 871, 838, 873, 836, 875, 834, 877, 832, 879, 830, 881, 828, 883, 826, 885, 824, 887, 822, 889, 820, 891, 818, 893, 816, 895, 814, 897, 812, 899, 810, 901, 808, 903, 806, 905, 804, 907, 802, 909, 800, 911, 798, 913, 796, 915, 794, 917, 792, 919, 790, 921, 788, 923, 786, 925, 784, 927, 782, 929, 780, 931, 778, 933, 776, 935, 774, 937, 772, 939, 770, 941, 768, 943, 766, 945, 764, 947, 762, 949, 760, 951, 758, 953, 756, 955, 754, 957, 752, 959, 750, 961, 748, 963, 746, 965, 744, 967, 742, 969, 740, 971, 738, 973, 736, 975, 734, 977, 732, 979, 730, 981, 728, 983, 726, 985, 724, 987, 722, 989, 720, 991, 718, 993, 716, 995, 714, 997, 712, 999, 710, 1001, 708, 1003, 706, 1005, 704, 1007, 702, 1009, 700, 1011, 698, 1013, 696, 1015, 694, 1017, 692, 1019, 690, 1021, 688, 1023, 686, 1025, 684, 1027, 682, 1029, 680, 1031, 678, 1033, 676, 1035, 674, 1037, 672, 1039, 670, 1041, 668, 1043, 666, 1045, 664, 1047, 662, 1049, 660, 1051, 658, 1053, 656, 1055, 654, 1057, 652, 1059, 650, 1061, 648, 1063, 646, 1065, 644, 1067, 642, 1069, 640, 1071, 638, 1073, 636, 1075, 634, 1077, 632, 1079, 630, 1081, 628, 1083, 626, 1085, 624, 1087, 622, 1089, 620, 1091, 618, 1093, 616, 1095, 614, 1097, 612, 1099, 610, 1101, 608, 1103, 606, 1105, 604, 1107, 602, 1109, 600, 1111, 598, 1113, 596, 1115, 594, 1117, 592, 1119, 590, 1121, 588, 1123, 586, 1125, 584, 1127, 582, 1129, 580, 1131, 578, 1133, 576, 1135, 574, 1137, 572, 1139, 570, 1141, 568, 1143, 566, 1145, 564, 1147, 562, 1149, 560, 1151, 558, 1153, 556, 1155, 554, 1157, 552, 1159, 550, 1161, 548, 1163, 546, 1165, 544, 1167, 542, 1169, 540, 1171, 538, 1173, 536, 1175, 534, 1177, 532, 1179, 530, 1181, 528, 1183, 526, 1185, 524, 1187, 522, 1189, 520, 1191, 518, 1193, 516, 1195, 514, 1197, 512, 1199, 510, 1201, 508, 1203, 506, 1205, 504, 1207, 502, 1209, 500, 1211, 498, 1213, 496, 1215, 494, 1217, 492, 1219, 490, 1221, 488, 1223, 486, 1225, 484, 1227, 482, 1229, 480, 1231, 478, 1233, 476, 1235, 474, 1237, 472, 1239, 470, 1241, 468, 1243, 466, 1245, 464, 1247, 462, 1249, 460, 1251, 458, 1253, 456, 1255, 454, 1257, 452, 1259, 450, 1261, 448, 1263, 446, 1265, 444, 1267, 442, 1269, 440, 1271, 438, 1273, 436, 1275, 434, 1277, 432, 1279, 430, 1281, 428, 1283, 426, 1285, 424, 1287, 422, 1289, 420, 1291, 418, 1293, 416, 1295, 414, 1297, 412, 1299, 410, 1301, 408, 1303, 406, 1305, 404, 1307, 402, 1309, 400, 1311, 398, 1313, 396, 1315, 394, 1317, 392, 1319, 390, 1321, 388, 1323, 386, 1325, 384, 1327, 382, 1329, 380, 1331, 378, 1333, 376, 1335, 374, 1337, 372, 1339, 370, 1341, 368, 1343, 366, 1345, 364, 1347, 362, 1349, 360, 1351, 358, 1353, 356, 1355, 354, 1357, 352, 1359, 350, 1361, 348, 1363, 346, 1365, 344, 1367, 342, 1369, 340, 1371, 338, 1373, 336, 1375, 334, 1377, 332, 1379, 330, 1381, 328, 1383, 326, 1385, 324, 1387, 322, 1389, 320, 1391, 318, 1393, 316, 1395, 314, 1397, 312, 1399, 310, 1401, 308, 1403, 306, 1405, 304, 1407, 302, 1409, 300, 1411, 298, 1413, 296, 1415, 294, 1417, 292, 1419, 290, 1421, 288, 1423, 286, 1425, 284, 1427, 282, 1429, 280, 1431, 278, 1433, 276, 1435, 274, 1437, 272, 1439, 270, 1441, 268, 1443, 266, 1445, 264, 1447, 262, 1449, 260, 1451, 258, 1453, 256, 1455, 254, 1457, 252, 1459, 250, 1461, 248, 1463, 246, 1465, 244, 1467, 242, 1469, 240, 1471, 238, 1473, 236, 1475, 234, 1477, 232, 1479, 230, 1481, 228, 1483, 226, 1485, 224, 1487, 222, 1489, 220, 1491, 218, 1493, 216, 1495, 214, 1497, 212, 1499, 210, 1501, 208, 1503, 206, 1505, 204, 1507, 202, 1509, 200, 1511, 198, 1513, 196, 1515, 194, 1517, 192, 1519, 190, 1521, 188, 1523, 186, 1525, 184, 1527, 182, 1529, 180, 1531, 178, 1533, 176, 1535, 174, 1537, 172, 1539, 170, 1541, 168, 1543, 166, 1545, 164, 1547, 162, 1549, 160, 1551, 158, 1553, 156, 1555, 154, 1557, 152, 1559, 150, 1561, 148, 1563, 146, 1565, 144, 1567, 142, 1569, 140, 1571, 138, 1573, 136, 1575, 134, 1577, 132, 1579, 130, 1581, 128, 1583, 126, 1585, 124, 1587, 122, 1589, 120, 1591, 118, 1593, 116, 1595, 114, 1597, 112, 1599, 110, 1601, 108, 1603, 106, 1605, 104, 1607, 102, 1609, 100, 1611, 98, 1613, 96, 1615, 94, 1617, 92, 1619, 90, 1621, 88, 1623, 86, 1625, 84, 1627, 82, 1629, 80, 1631, 78, 1633, 76, 1635, 74, 1637, 72, 1639, 70, 1641, 68, 1643, 66, 1645, 64, 1647, 62, 1649, 60, 1651, 58, 1653, 56, 1655, 54, 1657, 52, 1659, 50, 1661, 48, 1663, 46, 1665, 44, 1667, 42, 1669, 40, 1671, 38, 1673, 36, 1675, 34, 1677, 32, 1679, 30, 1681, 28, 1683, 26, 1685, 24, 1687, 22, 1689, 20, 1691, 18, 1693, 16, 1695, 14, 1697, 12, 1699, 10, 1701, 8, 1703, 6, 1705, 4, 1707, 2, 1709]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s6/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-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-l4-s6/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..35bbca5031b7d7dde39ac4ff73e149bbaac983f8 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 1710, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s6/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s6/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s8/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s8/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a0716af752123affbc06f06418e4113bf25e66f9 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 306, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s8/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fb8ac2bb53b82e092f62da9e65a832f4907be2cb --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [306, 1, 304, 3, 302, 5, 300, 7, 298, 9, 296, 11, 294, 13, 292, 15, 290, 17, 288, 19, 286, 21, 284, 23, 282, 25, 280, 27, 278, 29, 276, 31, 274, 33, 272, 35, 270, 37, 268, 39, 266, 41, 264, 43, 262, 45, 260, 47, 258, 49, 256, 51, 254, 53, 252, 55, 250, 57, 248, 59, 246, 61, 244, 63, 242, 65, 240, 67, 238, 69, 236, 71, 234, 73, 232, 75, 230, 77, 228, 79, 226, 81, 224, 83, 222, 85, 220, 87, 218, 89, 216, 91, 214, 93, 212, 95, 210, 97, 208, 99, 206, 101, 204, 103, 202, 105, 200, 107, 198, 109, 196, 111, 194, 113, 192, 115, 190, 117, 188, 119, 186, 121, 184, 123, 182, 125, 180, 127, 178, 129, 176, 131, 174, 133, 172, 135, 170, 137, 168, 139, 166, 141, 164, 143, 162, 145, 160, 147, 158, 149, 156, 151, 154, 153, 152, 155, 150, 157, 148, 159, 146, 161, 144, 163, 142, 165, 140, 167, 138, 169, 136, 171, 134, 173, 132, 175, 130, 177, 128, 179, 126, 181, 124, 183, 122, 185, 120, 187, 118, 189, 116, 191, 114, 193, 112, 195, 110, 197, 108, 199, 106, 201, 104, 203, 102, 205, 100, 207, 98, 209, 96, 211, 94, 213, 92, 215, 90, 217, 88, 219, 86, 221, 84, 223, 82, 225, 80, 227, 78, 229, 76, 231, 74, 233, 72, 235, 70, 237, 68, 239, 66, 241, 64, 243, 62, 245, 60, 247, 58, 249, 56, 251, 54, 253, 52, 255, 50, 257, 48, 259, 46, 261, 44, 263, 42, 265, 40, 267, 38, 269, 36, 271, 34, 273, 32, 275, 30, 277, 28, 279, 26, 281, 24, 283, 22, 285, 20, 287, 18, 289, 16, 291, 14, 293, 12, 295, 10, 297, 8, 299, 6, 301, 4, 303, 2, 305]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s8/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-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-l4-s8/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a0716af752123affbc06f06418e4113bf25e66f9 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 306, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s8/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-sum-permutation-l4-s8/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l4-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s1/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s1/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..16dc659af67e4f444ffaf6769c4394c5fd800a13 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s1/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..575b530fc848f44fa13288801c3fe60fec1c91d7 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l1-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 0, 1, 1, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s1/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l1-s1/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + sieve = [True] * (n + 1) + sieve[0] = False + if n >= 1: + sieve[1] = False + for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: + for j in range(i * i, n + 1, i): + sieve[j] = False + for p in range(2, n): + if sieve[p]: + for u in range(n - p): + if c[u] == c[u + p]: + raise Invalid(f"vertices {u + 1} and {u + p + 1} (difference {p}) share a colour") + return None, {} diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s1/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..16dc659af67e4f444ffaf6769c4394c5fd800a13 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s1/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s1/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s6/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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-prime-graph-coloring-l1-s6/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ef265485b27141bff8222292a2272f2e4a380d10 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 3, "k": 2, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s6/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2f9119170bb4a88b3956a0cc69a02e8e1a4c37fa --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s6/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l1-s6/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + sieve = [True] * (n + 1) + sieve[0] = False + if n >= 1: + sieve[1] = False + for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: + for j in range(i * i, n + 1, i): + sieve[j] = False + for p in range(2, n): + if sieve[p]: + for u in range(n - p): + if c[u] == c[u + p]: + raise Invalid(f"vertices {u + 1} and {u + p + 1} (difference {p}) share a colour") + return None, {} diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s6/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ef265485b27141bff8222292a2272f2e4a380d10 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 3, "k": 2, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s6/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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-prime-graph-coloring-l1-s6/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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-prime-graph-coloring-l1-s8/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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-prime-graph-coloring-l1-s8/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d64527826a30a6af57235e9f5b293b762daa785a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 10, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s8/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d83705ac7a7e9da2bf25cdf840879ee767d2ec42 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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": [1, 2, 3, 0, 1, 2, 3, 0, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s8/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l1-s8/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + sieve = [True] * (n + 1) + sieve[0] = False + if n >= 1: + sieve[1] = False + for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: + for j in range(i * i, n + 1, i): + sieve[j] = False + for p in range(2, n): + if sieve[p]: + for u in range(n - p): + if c[u] == c[u + p]: + raise Invalid(f"vertices {u + 1} and {u + p + 1} (difference {p}) share a colour") + return None, {} diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s8/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d64527826a30a6af57235e9f5b293b762daa785a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 10, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l1-s8/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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-prime-graph-coloring-l1-s8/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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-prime-graph-coloring-l5-s0/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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-prime-graph-coloring-l5-s0/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..05ef84a63c4bf7f4601f46edfe2daf87658ecf35 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 516, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l5-s0/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5b3271358b85a5e29bfef2dbe79b659a8e47cca7 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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": [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l5-s0/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l5-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-l5-s0/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..05ef84a63c4bf7f4601f46edfe2daf87658ecf35 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 516, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l5-s0/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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-prime-graph-coloring-l5-s0/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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-prime-graph-coloring-l5-s9/environment/Dockerfile b/tasks/construct-rlve-prime-graph-coloring-l5-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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-prime-graph-coloring-l5-s9/environment/instance.json b/tasks/construct-rlve-prime-graph-coloring-l5-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..37518ac3c5b07c48e7eec582e851f55e03554d36 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l5-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 734, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l5-s9/solution/solve.sh b/tasks/construct-rlve-prime-graph-coloring-l5-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5073e988f9a0b6ef401ec78d36a56978c56ba304 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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": [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prime-graph-coloring-l5-s9/tests/check.py b/tasks/construct-rlve-prime-graph-coloring-l5-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b3736f1375f1862241999142c975ced361b8fcb5 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l5-s9/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + sieve = [True] * (n + 1) + sieve[0] = False + if n >= 1: + sieve[1] = False + for i in range(2, int(n ** 0.5) + 1): + if sieve[i]: + for j in range(i * i, n + 1, i): + sieve[j] = False + for p in range(2, n): + if sieve[p]: + for u in range(n - p): + if c[u] == c[u + p]: + raise Invalid(f"vertices {u + 1} and {u + p + 1} (difference {p}) share a colour") + return None, {} diff --git a/tasks/construct-rlve-prime-graph-coloring-l5-s9/tests/instance.json b/tasks/construct-rlve-prime-graph-coloring-l5-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..37518ac3c5b07c48e7eec582e851f55e03554d36 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-coloring-l5-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 734, "k": 4, "family": "rlve_prime_graph_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prime-graph-coloring-l5-s9/tests/run.py b/tasks/construct-rlve-prime-graph-coloring-l5-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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-prime-graph-coloring-l5-s9/tests/test.sh b/tasks/construct-rlve-prime-graph-coloring-l5-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prime-graph-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-recursive-sequence-sum-l2-s2/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-recursive-sequence-sum-l2-s2/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e239a744519fb9c27ff24aedd1581453f6b0a7db --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"F0": 68, "A": 11, "B": 12781, "S": 26468337650, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l2-s2/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5452caebe2d72ed053cc30f29a189f07808b5740 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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' +{"indices": [2, 4, 5, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l2-s2/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-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-l2-s2/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e239a744519fb9c27ff24aedd1581453f6b0a7db --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"F0": 68, "A": 11, "B": 12781, "S": 26468337650, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l2-s2/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-recursive-sequence-sum-l2-s2/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-recursive-sequence-sum-l2-s5/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-recursive-sequence-sum-l2-s5/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9d0e21932e3ec0e12aff2727d7cd371192ea47c9 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"F0": 79, "A": 1, "B": 7874, "S": 31654, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l2-s5/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..01c456d01c3e0ecdfa3571753f5011f45cc821a3 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [1, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l2-s5/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-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-l2-s5/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9d0e21932e3ec0e12aff2727d7cd371192ea47c9 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"F0": 79, "A": 1, "B": 7874, "S": 31654, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l2-s5/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-recursive-sequence-sum-l2-s5/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l2-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-round-robin-scores-l3-s1/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l3-s1/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..99bf24a82039ffb19dedc77af9cab9cc04172dcf --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"W": [9, 12, 11, 12, 12, 11, 8, 18, 10], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l3-s1/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b6eb9c2847a56179e931aa77de7591458d120990 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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' +{"A": ["022000020", "002002022", "000122102", "221001102", "220200200", "200120201", "221100000", "002222202", "200021200"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l3-s1/tests/check.py b/tasks/construct-rlve-round-robin-scores-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l3-s1/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l3-s1/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..99bf24a82039ffb19dedc77af9cab9cc04172dcf --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"W": [9, 12, 11, 12, 12, 11, 8, 18, 10], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l3-s1/tests/run.py b/tasks/construct-rlve-round-robin-scores-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l3-s1/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l3-s6/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l3-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-round-robin-scores-l3-s6/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b89c55125c4bae35216c5d36a0de08be18b68945 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"W": [10, 10, 7, 10, 7, 10, 8, 8, 6], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l3-s6/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9fe557934f084f6fe1d98e6b79028862e3a2c3d2 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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' +{"A": ["011111112", "101121111", "110110111", "111011112", "101101111", "112110111", "111111011", "111111101", "011011110"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l3-s6/tests/check.py b/tasks/construct-rlve-round-robin-scores-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l3-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-l3-s6/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b89c55125c4bae35216c5d36a0de08be18b68945 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"W": [10, 10, 7, 10, 7, 10, 8, 8, 6], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l3-s6/tests/run.py b/tasks/construct-rlve-round-robin-scores-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l3-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-round-robin-scores-l3-s6/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l3-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-round-robin-scores-l3-s8/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l3-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l3-s8/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l3-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..08bb1ff9974a84987d6b2109eed04cce788d4016 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l3-s8/environment/instance.json @@ -0,0 +1 @@ +{"W": [14, 9, 10, 8, 9, 17, 13, 6, 7], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l3-s8/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l3-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..dd7ed8605fd62a04b0009e3ffc01ea19099ee008 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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' +{"A": ["022020121", "001120012", "010211021", "210000210", "001200112", "221220012", "122012011", "010111101", "101200110"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l3-s8/tests/check.py b/tasks/construct-rlve-round-robin-scores-l3-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l3-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-l3-s8/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l3-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..08bb1ff9974a84987d6b2109eed04cce788d4016 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l3-s8/tests/instance.json @@ -0,0 +1 @@ +{"W": [14, 9, 10, 8, 9, 17, 13, 6, 7], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l3-s8/tests/run.py b/tasks/construct-rlve-round-robin-scores-l3-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-round-robin-scores-l3-s8/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l3-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-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-shortest-path-count-l4-s3/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l4-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l4-s3/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l4-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..582296fca89488003f9591bbc25eeaad703803a7 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l4-s3/environment/instance.json @@ -0,0 +1 @@ +{"K": 740396027, "n_max": 183, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l4-s3/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l4-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b67e76cd843c6d86bdf00d196a4e5ec6832a0cab --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 90, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l4-s3/tests/check.py b/tasks/construct-rlve-shortest-path-count-l4-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l4-s3/tests/check.py @@ -0,0 +1,34 @@ +from run import Invalid, as_int + + +def check(inst, ans): + n = as_int(ans.get("n"), "n", lo=2, hi=inst["n_max"]) + adj = ans.get("adj") + if not isinstance(adj, list) or len(adj) != n: + raise Invalid(f"adj must be a list of {n} strings") + for r in adj: + if not isinstance(r, str) or len(r) != n or set(r) - {"Y", "N"}: + raise Invalid("each row must be a string of length n over {'Y','N'}") + for i in range(n): + if adj[i][i] != "N": + raise Invalid("self-loop") + for j in range(i + 1, n): + if adj[i][j] != adj[j][i]: + raise Invalid("matrix not symmetric") + nb = [[j for j in range(n) if adj[i][j] == "Y"] for i in range(n)] + dist = [-1] * n + cnt = [0] * n + dist[0], cnt[0] = 0, 1 + q = [0] + for u in q: # BFS with exact (Python int) path counts + for v in nb[u]: + if dist[v] < 0: + dist[v] = dist[u] + 1 + q.append(v) + if dist[v] == dist[u] + 1: + cnt[v] += cnt[u] + if dist[1] < 0: + raise Invalid("vertex 2 is unreachable from vertex 1") + if cnt[1] != inst["K"]: + raise Invalid(f"{cnt[1]} shortest paths, need {inst['K']}") + return None, {} diff --git a/tasks/construct-rlve-shortest-path-count-l4-s3/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l4-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..582296fca89488003f9591bbc25eeaad703803a7 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l4-s3/tests/instance.json @@ -0,0 +1 @@ +{"K": 740396027, "n_max": 183, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l4-s3/tests/run.py b/tasks/construct-rlve-shortest-path-count-l4-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l4-s3/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l4-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l4-s4/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l4-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l4-s4/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l4-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cc44070f1e877ea19e8599a7faee58ff3c9f7f65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l4-s4/environment/instance.json @@ -0,0 +1 @@ +{"K": 387300533, "n_max": 177, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l4-s4/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l4-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..601acc5843abc2627ff3796ef3224bcfa08fdb0b --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 87, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l4-s4/tests/check.py b/tasks/construct-rlve-shortest-path-count-l4-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l4-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-l4-s4/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l4-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cc44070f1e877ea19e8599a7faee58ff3c9f7f65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l4-s4/tests/instance.json @@ -0,0 +1 @@ +{"K": 387300533, "n_max": 177, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l4-s4/tests/run.py b/tasks/construct-rlve-shortest-path-count-l4-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l4-s4/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l4-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-smallest-enclosing-circle-l3-s0/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l3-s0/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0ad027e012ab054137f11295a85d0a01b052927b --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"points": [[0, 17], [2, 5], [2, 7], [5, 2], [6, 22], [12, 10], [15, 6], [15, 10], [23, 20], [24, 4], [24, 28], [25, 5], [26, 7], [28, 9], [29, 21]], "r_opt": 16.101242188104617, "r2_num": 1037, "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-l3-s0/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2b66c62943c027906f8eaab1d2df2d89e30e7899 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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' +{"x": 14.5, "y": 15.0, "r": 16.101242189104617} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l3-s0/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l3-s0/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l3-s0/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0ad027e012ab054137f11295a85d0a01b052927b --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"points": [[0, 17], [2, 5], [2, 7], [5, 2], [6, 22], [12, 10], [15, 6], [15, 10], [23, 20], [24, 4], [24, 28], [25, 5], [26, 7], [28, 9], [29, 21]], "r_opt": 16.101242188104617, "r2_num": 1037, "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-l3-s0/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l3-s0/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l3-s7/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l3-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l3-s7/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l3-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e2ba5e2aca802f06d199b0c79ab075975aac08db --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l3-s7/environment/instance.json @@ -0,0 +1 @@ +{"points": [[0, 14], [1, 7], [1, 28], [2, 27], [7, 26], [8, 29], [9, 11], [10, 2], [19, 26], [21, 2], [21, 3], [23, 12], [26, 5], [27, 0], [29, 5]], "r_opt": 19.1049731745428, "r2_num": 365, "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-l3-s7/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l3-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..45d2217f1e74acb9b269a685b1266dac380e25fa --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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' +{"x": 14.0, "y": 14.0, "r": 19.1049731755428} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l3-s7/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l3-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l3-s7/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l3-s7/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l3-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e2ba5e2aca802f06d199b0c79ab075975aac08db --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l3-s7/tests/instance.json @@ -0,0 +1 @@ +{"points": [[0, 14], [1, 7], [1, 28], [2, 27], [7, 26], [8, 29], [9, 11], [10, 2], [19, 26], [21, 2], [21, 3], [23, 12], [26, 5], [27, 0], [29, 5]], "r_opt": 19.1049731745428, "r2_num": 365, "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-l3-s7/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l3-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l3-s7/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l3-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-subgraph-isomorphism-l6-s3/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l6-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-subgraph-isomorphism-l6-s3/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7b9c1b56d30ab451e3f7fcef9aef9a7c113f6f2a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"n1": 36, "n2": 36, "edges1": [[31, 32], [24, 32], [6, 15], [23, 25], [19, 25], [8, 27], [21, 22], [8, 11], [24, 30], [6, 7], [6, 23], [8, 20], [5, 12], [12, 13], [19, 27], [9, 28], [20, 28], [0, 13], [4, 22], [1, 11], [11, 24], [3, 26], [18, 33], [7, 30], [9, 17], [19, 23], [6, 11], [23, 34], [15, 20], [20, 21], [3, 22], [10, 34], [1, 9], [24, 28], [28, 33], [18, 28], [16, 23], [7, 20], [10, 30], [6, 8], [12, 17], [0, 25], [30, 32], [21, 31], [15, 17], [7, 27], [4, 5], [6, 19], [1, 4], [13, 21], [2, 12], [7, 23], [16, 17], [20, 35], [15, 19], [24, 25], [1, 20], [34, 35], [14, 30], [4, 15], [28, 32], [9, 29], [0, 12], [1, 19], [13, 33], [10, 35], [17, 21], [10, 15], [7, 19], [9, 34], [1, 16], [17, 28], [16, 34], [13, 23], [4, 24], [5, 27], [6, 13], [7, 12], [7, 31], [1, 35], [29, 33], [20, 33], [2, 26], [0, 20], [0, 31], [12, 23], [9, 31], [2, 25], [0, 34], [25, 30], [22, 35], [0, 27], [2, 31], [31, 35], [18, 31], [10, 20], [12, 14], [16, 25], [8, 16], [11, 35], [8, 26], [0, 23], [1, 30], [9, 35], [3, 29], [7, 13], [6, 14], [18, 19], [4, 14], [19, 33], [3, 30], [3, 19], [6, 35], [0, 26], [5, 20], [10, 31], [0, 35], [2, 21], [15, 33], [9, 10], [18, 23], [11, 22], [28, 30], [15, 30], [10, 28], [13, 14], [3, 31], [9, 32], [17, 30], [3, 14], [3, 28], [12, 16], [8, 19], [11, 31], [0, 5], [33, 34], [2, 13], [2, 35], [3, 34], [5, 13], [14, 15], [2, 19], [18, 32], [11, 16], [23, 35], [16, 20], [32, 35], [8, 31], [19, 34], [21, 26], [5, 22], [21, 29], [18, 21], [11, 33], [14, 33], [14, 31], [3, 13], [28, 35], [18, 25], [0, 2], [5, 17], [20, 29], [11, 15], [6, 31], [22, 28], [8, 21], [2, 32], [18, 30], [13, 18], [21, 34], [21, 23], [27, 34], [29, 30], [3, 15], [2, 17], [11, 32], [31, 33], [3, 24], [19, 26], [2, 24], [4, 32], [7, 28], [11, 18], [14, 27], [3, 6], [5, 28], [5, 30], [7, 34], [2, 28], [10, 13], [12, 34], [0, 22], [7, 18], [5, 35], [11, 13], [0, 19], [7, 15], [12, 24], [15, 35], [12, 26], [30, 31], [2, 22], [21, 27], [1, 15], [12, 30], [7, 17], [13, 30], [14, 28], [13, 22], [12, 21], [26, 27], [9, 14], [12, 28], [21, 30], [5, 34], [13, 32], [8, 23], [23, 27], [18, 26], [20, 23], [1, 5], [12, 19], [25, 28], [13, 31], [13, 34], [19, 35], [26, 31], [12, 15], [7, 10], [8, 10], [4, 23], [14, 20], [0, 11], [6, 24], [32, 33], [7, 29], [0, 30], [13, 19], [3, 16], [1, 8], [4, 28], [7, 32], [4, 18], [11, 28], [26, 29], [1, 32], [4, 13], [0, 21], [2, 20], [7, 24], [2, 10], [14, 19], [24, 33], [0, 33], [15, 28], [6, 22], [10, 17], [1, 3], [0, 16], [17, 22], [15, 16], [4, 10], [16, 29], [14, 23], [5, 32], [16, 18], [1, 7], [0, 7], [17, 23], [11, 25], [17, 26], [21, 25], [7, 9], [27, 33], [19, 31], [5, 21], [13, 25], [13, 26], [24, 26], [9, 26], [22, 27], [5, 26], [5, 25], [8, 28], [20, 26], [8, 14], [2, 18], [15, 34], [27, 30], [3, 9], [13, 16], [15, 27], [29, 32], [0, 3], [9, 20], [6, 26], [10, 18], [3, 4], [22, 25], [25, 31], [4, 6], [0, 14], [23, 24], [18, 34], [21, 35], [19, 20], [9, 18], [4, 27], [19, 21], [1, 31], [6, 20], [2, 11], [26, 33], [4, 8], [3, 18], [7, 14], [26, 30], [33, 35], [15, 21], [15, 29], [21, 32], [7, 26], [5, 10], [10, 33], [13, 29], [21, 28], [1, 12], [14, 25], [27, 28], [22, 24], [22, 32], [2, 34], [23, 28], [6, 30], [24, 34], [23, 26], [12, 29], [4, 30], [9, 27], [4, 9], [2, 14], [31, 34], [20, 27], [5, 16], [9, 13], [20, 24], [4, 7], [1, 33], [0, 9], [9, 11], [2, 4], [13, 15], [30, 34], [20, 32], [8, 15], [1, 17], [15, 31], [23, 33], [18, 27], [4, 17], [1, 28], [10, 23], [16, 32], [7, 16], [11, 14], [18, 35], [4, 21], [2, 9], [7, 25], [5, 8], [12, 20], [11, 34], [22, 34], [19, 29], [27, 32], [30, 33], [11, 23], [11, 30], [17, 31], [23, 32], [11, 19], [10, 19], [15, 18], [4, 35], [1, 29], [10, 25], [22, 33], [19, 30], [8, 13], [10, 11], [15, 25], [5, 7], [17, 18], [8, 30], [17, 20], [25, 32], [14, 18], [19, 24], [17, 32], [11, 21], [14, 34], [14, 22], [6, 9], [19, 22], [14, 24], [2, 30], [0, 6], [5, 23], [2, 33], [17, 19], [7, 8], [5, 15], [29, 35], [4, 33], [0, 18], [3, 8], [16, 21], [14, 35], [22, 30], [25, 33], [2, 7], [3, 23], [3, 11], [20, 25], [22, 29], [27, 31], [22, 31], [17, 27], [5, 6], [21, 24], [2, 3], [9, 12], [26, 32], [3, 32], [25, 27], [6, 17], [7, 33], [8, 18], [13, 17], [4, 34], [8, 24], [10, 21], [17, 35], [18, 22], [7, 22], [0, 4], [24, 31], [0, 32], [16, 27], [16, 35], [5, 19], [5, 11], [16, 30], [5, 18], [16, 22], [12, 31], [2, 27], [13, 27], [2, 6], [30, 35], [6, 16], [2, 8], [17, 24], [11, 12], [4, 12], [4, 31], [8, 12], [12, 33], [1, 6], [5, 24], [12, 22], [0, 28]], "edges2": [[5, 28], [15, 33], [1, 6], [8, 17], [20, 31], [6, 11], [13, 28], [29, 35], [3, 19], [0, 8], [10, 12], [4, 26], [10, 11], [21, 30], [30, 35], [7, 18], [15, 32], [25, 33], [4, 32], [8, 31], [10, 31], [9, 27], [7, 27], [14, 26], [7, 32], [0, 30], [24, 28], [16, 18], [15, 26], [12, 32], [20, 26], [1, 13], [28, 35], [25, 29], [11, 23], [7, 13], [9, 15], [1, 19], [12, 14], [7, 22], [5, 13], [16, 29], [14, 25], [16, 25], [33, 35], [19, 20], [5, 30], [3, 10], [26, 31], [9, 21], [17, 23], [32, 35], [1, 31], [14, 18], [10, 30], [13, 31], [3, 23], [21, 26], [8, 34], [10, 32], [14, 34], [7, 26], [15, 34], [3, 31], [2, 17], [26, 30], [29, 31], [27, 34], [1, 11], [4, 33], [3, 25], [14, 24], [10, 23], [0, 29], [22, 32], [16, 32], [17, 32], [19, 34], [2, 32], [17, 26], [6, 18], [23, 26], [18, 32], [21, 27], [27, 35], [24, 34], [28, 33], [11, 18], [7, 33], [6, 17], [31, 34], [5, 10], [17, 21], [19, 25], [7, 19], [23, 27], [9, 25], [23, 34], [20, 21], [0, 25], [3, 7], [11, 27], [29, 34], [20, 35], [6, 7], [9, 33], [12, 13], [24, 32], [22, 34], [2, 14], [10, 25], [9, 13], [2, 9], [5, 23], [0, 18], [2, 23], [0, 26], [6, 31], [21, 23], [14, 28], [6, 35], [7, 25], [0, 10], [2, 27], [0, 24], [1, 7], [4, 13], [13, 21], [20, 23], [8, 12], [1, 21], [8, 16], [6, 10], [18, 30], [20, 33], [24, 30], [12, 20], [18, 34], [4, 8], [26, 29], [0, 32], [20, 30], [1, 10], [11, 25], [13, 23], [16, 20], [1, 26], [5, 11], [29, 33], [5, 26], [23, 28], [0, 3], [9, 30], [10, 27], [11, 19], [7, 17], [19, 30], [7, 21], [20, 22], [4, 27], [16, 31], [3, 22], [10, 13], [26, 32], [2, 4], [17, 20], [2, 8], [16, 24], [27, 30], [8, 9], [17, 19], [24, 25], [8, 13], [6, 28], [30, 32], [12, 15], [12, 35], [10, 24], [3, 20], [21, 28], [9, 14], [11, 16], [8, 22], [2, 22], [13, 14], [2, 15], [0, 14], [13, 27], [21, 34], [0, 20], [3, 17], [12, 31], [28, 29], [2, 31], [24, 27], [7, 20], [7, 24], [23, 33], [5, 27], [12, 18], [32, 34], [10, 19], [19, 28], [11, 26], [5, 20], [4, 12], [6, 22], [3, 16], [8, 10], [14, 16], [3, 6], [7, 29], [4, 17], [23, 24], [19, 32], [10, 17], [2, 26], [8, 26], [10, 20], [9, 26], [0, 21], [12, 25], [18, 27], [14, 17], [14, 30], [5, 34], [15, 18], [6, 13], [14, 27], [19, 27], [10, 21], [7, 16], [28, 31], [13, 16], [9, 28], [11, 31], [15, 22], [8, 29], [30, 34], [2, 11], [0, 35], [21, 35], [9, 23], [0, 28], [13, 35], [18, 21], [15, 28], [13, 20], [3, 32], [14, 22], [6, 12], [4, 14], [14, 23], [18, 24], [12, 17], [6, 9], [0, 11], [18, 25], [15, 16], [3, 28], [20, 27], [10, 18], [8, 24], [5, 14], [13, 17], [8, 19], [2, 3], [9, 17], [7, 15], [1, 16], [5, 17], [22, 25], [11, 15], [16, 26], [12, 24], [22, 30], [20, 29], [7, 35], [15, 30], [3, 33], [3, 18], [21, 31], [17, 34], [8, 18], [6, 20], [2, 35], [3, 35], [15, 27], [18, 29], [11, 21], [6, 23], [5, 16], [17, 24], [34, 35], [4, 9], [3, 11], [14, 31], [22, 24], [24, 29], [16, 19], [27, 29], [3, 34], [12, 30], [9, 11], [13, 25], [18, 20], [4, 7], [11, 14], [14, 29], [0, 27], [13, 18], [0, 15], [32, 33], [3, 21], [7, 23], [1, 24], [5, 19], [20, 25], [5, 18], [24, 35], [25, 27], [0, 2], [15, 23], [17, 25], [8, 35], [16, 22], [7, 10], [3, 29], [5, 15], [0, 5], [14, 33], [10, 26], [2, 34], [16, 23], [5, 32], [15, 35], [18, 31], [17, 35], [6, 15], [5, 33], [9, 29], [4, 29], [11, 30], [12, 16], [2, 29], [3, 4], [0, 16], [9, 18], [10, 16], [25, 34], [14, 19], [11, 35], [19, 31], [23, 31], [27, 33], [7, 14], [25, 30], [22, 31], [19, 23], [3, 13], [7, 11], [3, 12], [25, 32], [9, 31], [16, 30], [26, 27], [7, 12], [28, 32], [8, 25], [1, 34], [10, 22], [5, 7], [18, 35], [18, 33], [27, 32], [12, 34], [6, 26], [12, 29], [7, 30], [11, 29], [1, 27], [19, 21], [6, 33], [11, 33], [16, 35], [13, 19], [11, 17], [3, 9], [0, 1], [26, 34], [25, 35], [11, 12], [5, 31], [26, 35], [3, 8], [15, 19], [6, 16], [21, 25], [0, 13], [14, 35], [19, 24], [29, 30], [0, 33], [25, 31], [19, 33], [5, 9], [8, 30], [10, 34], [23, 25], [1, 35], [15, 17], [11, 28], [31, 35], [28, 30], [6, 19], [22, 33], [0, 34], [11, 24], [13, 33], [20, 24], [1, 8], [0, 22], [18, 28], [31, 32], [19, 29], [1, 22], [16, 28], [2, 6], [28, 34], [4, 11], [9, 20], [30, 31], [4, 35], [6, 27], [12, 27], [0, 6], [2, 5], [1, 5], [13, 24], [23, 35], [8, 23], [1, 9], [11, 20], [1, 23], [9, 19], [1, 29], [27, 28], [10, 33], [7, 34], [5, 35], [8, 27], [0, 12], [10, 29], [13, 26], [12, 21], [13, 34], [11, 22], [2, 16], [18, 22], [21, 29], [10, 35], [6, 8], [1, 18], [12, 28], [0, 7], [4, 22], [15, 25], [6, 14], [12, 23], [24, 26], [8, 15], [9, 22]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l6-s3/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3c5d16622db97ff39f2d252aa644bc6dcd7c3c5b --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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' +{"p": [25, 2, 18, 32, 16, 23, 15, 11, 5, 22, 1, 34, 14, 7, 30, 26, 17, 6, 10, 27, 9, 13, 12, 19, 28, 21, 33, 20, 31, 4, 35, 0, 3, 29, 24, 8]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l6-s3/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l6-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-l6-s3/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7b9c1b56d30ab451e3f7fcef9aef9a7c113f6f2a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"n1": 36, "n2": 36, "edges1": [[31, 32], [24, 32], [6, 15], [23, 25], [19, 25], [8, 27], [21, 22], [8, 11], [24, 30], [6, 7], [6, 23], [8, 20], [5, 12], [12, 13], [19, 27], [9, 28], [20, 28], [0, 13], [4, 22], [1, 11], [11, 24], [3, 26], [18, 33], [7, 30], [9, 17], [19, 23], [6, 11], [23, 34], [15, 20], [20, 21], [3, 22], [10, 34], [1, 9], [24, 28], [28, 33], [18, 28], [16, 23], [7, 20], [10, 30], [6, 8], [12, 17], [0, 25], [30, 32], [21, 31], [15, 17], [7, 27], [4, 5], [6, 19], [1, 4], [13, 21], [2, 12], [7, 23], [16, 17], [20, 35], [15, 19], [24, 25], [1, 20], [34, 35], [14, 30], [4, 15], [28, 32], [9, 29], [0, 12], [1, 19], [13, 33], [10, 35], [17, 21], [10, 15], [7, 19], [9, 34], [1, 16], [17, 28], [16, 34], [13, 23], [4, 24], [5, 27], [6, 13], [7, 12], [7, 31], [1, 35], [29, 33], [20, 33], [2, 26], [0, 20], [0, 31], [12, 23], [9, 31], [2, 25], [0, 34], [25, 30], [22, 35], [0, 27], [2, 31], [31, 35], [18, 31], [10, 20], [12, 14], [16, 25], [8, 16], [11, 35], [8, 26], [0, 23], [1, 30], [9, 35], [3, 29], [7, 13], [6, 14], [18, 19], [4, 14], [19, 33], [3, 30], [3, 19], [6, 35], [0, 26], [5, 20], [10, 31], [0, 35], [2, 21], [15, 33], [9, 10], [18, 23], [11, 22], [28, 30], [15, 30], [10, 28], [13, 14], [3, 31], [9, 32], [17, 30], [3, 14], [3, 28], [12, 16], [8, 19], [11, 31], [0, 5], [33, 34], [2, 13], [2, 35], [3, 34], [5, 13], [14, 15], [2, 19], [18, 32], [11, 16], [23, 35], [16, 20], [32, 35], [8, 31], [19, 34], [21, 26], [5, 22], [21, 29], [18, 21], [11, 33], [14, 33], [14, 31], [3, 13], [28, 35], [18, 25], [0, 2], [5, 17], [20, 29], [11, 15], [6, 31], [22, 28], [8, 21], [2, 32], [18, 30], [13, 18], [21, 34], [21, 23], [27, 34], [29, 30], [3, 15], [2, 17], [11, 32], [31, 33], [3, 24], [19, 26], [2, 24], [4, 32], [7, 28], [11, 18], [14, 27], [3, 6], [5, 28], [5, 30], [7, 34], [2, 28], [10, 13], [12, 34], [0, 22], [7, 18], [5, 35], [11, 13], [0, 19], [7, 15], [12, 24], [15, 35], [12, 26], [30, 31], [2, 22], [21, 27], [1, 15], [12, 30], [7, 17], [13, 30], [14, 28], [13, 22], [12, 21], [26, 27], [9, 14], [12, 28], [21, 30], [5, 34], [13, 32], [8, 23], [23, 27], [18, 26], [20, 23], [1, 5], [12, 19], [25, 28], [13, 31], [13, 34], [19, 35], [26, 31], [12, 15], [7, 10], [8, 10], [4, 23], [14, 20], [0, 11], [6, 24], [32, 33], [7, 29], [0, 30], [13, 19], [3, 16], [1, 8], [4, 28], [7, 32], [4, 18], [11, 28], [26, 29], [1, 32], [4, 13], [0, 21], [2, 20], [7, 24], [2, 10], [14, 19], [24, 33], [0, 33], [15, 28], [6, 22], [10, 17], [1, 3], [0, 16], [17, 22], [15, 16], [4, 10], [16, 29], [14, 23], [5, 32], [16, 18], [1, 7], [0, 7], [17, 23], [11, 25], [17, 26], [21, 25], [7, 9], [27, 33], [19, 31], [5, 21], [13, 25], [13, 26], [24, 26], [9, 26], [22, 27], [5, 26], [5, 25], [8, 28], [20, 26], [8, 14], [2, 18], [15, 34], [27, 30], [3, 9], [13, 16], [15, 27], [29, 32], [0, 3], [9, 20], [6, 26], [10, 18], [3, 4], [22, 25], [25, 31], [4, 6], [0, 14], [23, 24], [18, 34], [21, 35], [19, 20], [9, 18], [4, 27], [19, 21], [1, 31], [6, 20], [2, 11], [26, 33], [4, 8], [3, 18], [7, 14], [26, 30], [33, 35], [15, 21], [15, 29], [21, 32], [7, 26], [5, 10], [10, 33], [13, 29], [21, 28], [1, 12], [14, 25], [27, 28], [22, 24], [22, 32], [2, 34], [23, 28], [6, 30], [24, 34], [23, 26], [12, 29], [4, 30], [9, 27], [4, 9], [2, 14], [31, 34], [20, 27], [5, 16], [9, 13], [20, 24], [4, 7], [1, 33], [0, 9], [9, 11], [2, 4], [13, 15], [30, 34], [20, 32], [8, 15], [1, 17], [15, 31], [23, 33], [18, 27], [4, 17], [1, 28], [10, 23], [16, 32], [7, 16], [11, 14], [18, 35], [4, 21], [2, 9], [7, 25], [5, 8], [12, 20], [11, 34], [22, 34], [19, 29], [27, 32], [30, 33], [11, 23], [11, 30], [17, 31], [23, 32], [11, 19], [10, 19], [15, 18], [4, 35], [1, 29], [10, 25], [22, 33], [19, 30], [8, 13], [10, 11], [15, 25], [5, 7], [17, 18], [8, 30], [17, 20], [25, 32], [14, 18], [19, 24], [17, 32], [11, 21], [14, 34], [14, 22], [6, 9], [19, 22], [14, 24], [2, 30], [0, 6], [5, 23], [2, 33], [17, 19], [7, 8], [5, 15], [29, 35], [4, 33], [0, 18], [3, 8], [16, 21], [14, 35], [22, 30], [25, 33], [2, 7], [3, 23], [3, 11], [20, 25], [22, 29], [27, 31], [22, 31], [17, 27], [5, 6], [21, 24], [2, 3], [9, 12], [26, 32], [3, 32], [25, 27], [6, 17], [7, 33], [8, 18], [13, 17], [4, 34], [8, 24], [10, 21], [17, 35], [18, 22], [7, 22], [0, 4], [24, 31], [0, 32], [16, 27], [16, 35], [5, 19], [5, 11], [16, 30], [5, 18], [16, 22], [12, 31], [2, 27], [13, 27], [2, 6], [30, 35], [6, 16], [2, 8], [17, 24], [11, 12], [4, 12], [4, 31], [8, 12], [12, 33], [1, 6], [5, 24], [12, 22], [0, 28]], "edges2": [[5, 28], [15, 33], [1, 6], [8, 17], [20, 31], [6, 11], [13, 28], [29, 35], [3, 19], [0, 8], [10, 12], [4, 26], [10, 11], [21, 30], [30, 35], [7, 18], [15, 32], [25, 33], [4, 32], [8, 31], [10, 31], [9, 27], [7, 27], [14, 26], [7, 32], [0, 30], [24, 28], [16, 18], [15, 26], [12, 32], [20, 26], [1, 13], [28, 35], [25, 29], [11, 23], [7, 13], [9, 15], [1, 19], [12, 14], [7, 22], [5, 13], [16, 29], [14, 25], [16, 25], [33, 35], [19, 20], [5, 30], [3, 10], [26, 31], [9, 21], [17, 23], [32, 35], [1, 31], [14, 18], [10, 30], [13, 31], [3, 23], [21, 26], [8, 34], [10, 32], [14, 34], [7, 26], [15, 34], [3, 31], [2, 17], [26, 30], [29, 31], [27, 34], [1, 11], [4, 33], [3, 25], [14, 24], [10, 23], [0, 29], [22, 32], [16, 32], [17, 32], [19, 34], [2, 32], [17, 26], [6, 18], [23, 26], [18, 32], [21, 27], [27, 35], [24, 34], [28, 33], [11, 18], [7, 33], [6, 17], [31, 34], [5, 10], [17, 21], [19, 25], [7, 19], [23, 27], [9, 25], [23, 34], [20, 21], [0, 25], [3, 7], [11, 27], [29, 34], [20, 35], [6, 7], [9, 33], [12, 13], [24, 32], [22, 34], [2, 14], [10, 25], [9, 13], [2, 9], [5, 23], [0, 18], [2, 23], [0, 26], [6, 31], [21, 23], [14, 28], [6, 35], [7, 25], [0, 10], [2, 27], [0, 24], [1, 7], [4, 13], [13, 21], [20, 23], [8, 12], [1, 21], [8, 16], [6, 10], [18, 30], [20, 33], [24, 30], [12, 20], [18, 34], [4, 8], [26, 29], [0, 32], [20, 30], [1, 10], [11, 25], [13, 23], [16, 20], [1, 26], [5, 11], [29, 33], [5, 26], [23, 28], [0, 3], [9, 30], [10, 27], [11, 19], [7, 17], [19, 30], [7, 21], [20, 22], [4, 27], [16, 31], [3, 22], [10, 13], [26, 32], [2, 4], [17, 20], [2, 8], [16, 24], [27, 30], [8, 9], [17, 19], [24, 25], [8, 13], [6, 28], [30, 32], [12, 15], [12, 35], [10, 24], [3, 20], [21, 28], [9, 14], [11, 16], [8, 22], [2, 22], [13, 14], [2, 15], [0, 14], [13, 27], [21, 34], [0, 20], [3, 17], [12, 31], [28, 29], [2, 31], [24, 27], [7, 20], [7, 24], [23, 33], [5, 27], [12, 18], [32, 34], [10, 19], [19, 28], [11, 26], [5, 20], [4, 12], [6, 22], [3, 16], [8, 10], [14, 16], [3, 6], [7, 29], [4, 17], [23, 24], [19, 32], [10, 17], [2, 26], [8, 26], [10, 20], [9, 26], [0, 21], [12, 25], [18, 27], [14, 17], [14, 30], [5, 34], [15, 18], [6, 13], [14, 27], [19, 27], [10, 21], [7, 16], [28, 31], [13, 16], [9, 28], [11, 31], [15, 22], [8, 29], [30, 34], [2, 11], [0, 35], [21, 35], [9, 23], [0, 28], [13, 35], [18, 21], [15, 28], [13, 20], [3, 32], [14, 22], [6, 12], [4, 14], [14, 23], [18, 24], [12, 17], [6, 9], [0, 11], [18, 25], [15, 16], [3, 28], [20, 27], [10, 18], [8, 24], [5, 14], [13, 17], [8, 19], [2, 3], [9, 17], [7, 15], [1, 16], [5, 17], [22, 25], [11, 15], [16, 26], [12, 24], [22, 30], [20, 29], [7, 35], [15, 30], [3, 33], [3, 18], [21, 31], [17, 34], [8, 18], [6, 20], [2, 35], [3, 35], [15, 27], [18, 29], [11, 21], [6, 23], [5, 16], [17, 24], [34, 35], [4, 9], [3, 11], [14, 31], [22, 24], [24, 29], [16, 19], [27, 29], [3, 34], [12, 30], [9, 11], [13, 25], [18, 20], [4, 7], [11, 14], [14, 29], [0, 27], [13, 18], [0, 15], [32, 33], [3, 21], [7, 23], [1, 24], [5, 19], [20, 25], [5, 18], [24, 35], [25, 27], [0, 2], [15, 23], [17, 25], [8, 35], [16, 22], [7, 10], [3, 29], [5, 15], [0, 5], [14, 33], [10, 26], [2, 34], [16, 23], [5, 32], [15, 35], [18, 31], [17, 35], [6, 15], [5, 33], [9, 29], [4, 29], [11, 30], [12, 16], [2, 29], [3, 4], [0, 16], [9, 18], [10, 16], [25, 34], [14, 19], [11, 35], [19, 31], [23, 31], [27, 33], [7, 14], [25, 30], [22, 31], [19, 23], [3, 13], [7, 11], [3, 12], [25, 32], [9, 31], [16, 30], [26, 27], [7, 12], [28, 32], [8, 25], [1, 34], [10, 22], [5, 7], [18, 35], [18, 33], [27, 32], [12, 34], [6, 26], [12, 29], [7, 30], [11, 29], [1, 27], [19, 21], [6, 33], [11, 33], [16, 35], [13, 19], [11, 17], [3, 9], [0, 1], [26, 34], [25, 35], [11, 12], [5, 31], [26, 35], [3, 8], [15, 19], [6, 16], [21, 25], [0, 13], [14, 35], [19, 24], [29, 30], [0, 33], [25, 31], [19, 33], [5, 9], [8, 30], [10, 34], [23, 25], [1, 35], [15, 17], [11, 28], [31, 35], [28, 30], [6, 19], [22, 33], [0, 34], [11, 24], [13, 33], [20, 24], [1, 8], [0, 22], [18, 28], [31, 32], [19, 29], [1, 22], [16, 28], [2, 6], [28, 34], [4, 11], [9, 20], [30, 31], [4, 35], [6, 27], [12, 27], [0, 6], [2, 5], [1, 5], [13, 24], [23, 35], [8, 23], [1, 9], [11, 20], [1, 23], [9, 19], [1, 29], [27, 28], [10, 33], [7, 34], [5, 35], [8, 27], [0, 12], [10, 29], [13, 26], [12, 21], [13, 34], [11, 22], [2, 16], [18, 22], [21, 29], [10, 35], [6, 8], [1, 18], [12, 28], [0, 7], [4, 22], [15, 25], [6, 14], [12, 23], [24, 26], [8, 15], [9, 22]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l6-s3/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l6-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-subgraph-isomorphism-l6-s3/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l6-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-subgraph-isomorphism-l6-s4/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l6-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l6-s4/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l6-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0ace6121edb12cb6cf2a7381cdd1ec38bc6f3f6d --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l6-s4/environment/instance.json @@ -0,0 +1 @@ +{"n1": 26, "n2": 36, "edges1": [[16, 18], [4, 17], [2, 11], [7, 16], [2, 14], [13, 16], [15, 18], [1, 3], [16, 24], [8, 19], [14, 25], [2, 4], [15, 22], [1, 7], [18, 19], [9, 25], [5, 16], [17, 20], [8, 17], [18, 23], [2, 12], [5, 12], [1, 13], [5, 20], [0, 22], [4, 5], [5, 7], [0, 9], [5, 23], [4, 16], [2, 5], [2, 16], [8, 21], [19, 21], [15, 20], [12, 14], [0, 25], [4, 9], [10, 15], [1, 25], [1, 6], [3, 12], [12, 25], [6, 11], [4, 20], [9, 15], [4, 14], [10, 25], [11, 19], [21, 23], [11, 17], [0, 17], [13, 20], [1, 5], [3, 11], [22, 24], [0, 13], [8, 24], [13, 19], [15, 25], [3, 17], [13, 24], [5, 10], [0, 16], [10, 23], [7, 15], [3, 19], [7, 13], [9, 11], [2, 25], [11, 22], [6, 23], [5, 22], [21, 24], [12, 19], [17, 21], [11, 12], [9, 19], [13, 17], [11, 16], [2, 7], [2, 20], [16, 19], [2, 13], [6, 20], [4, 11], [20, 21], [6, 10], [12, 23], [6, 12], [13, 21], [3, 5], [0, 14], [8, 13], [17, 22], [3, 4], [2, 22], [15, 17], [1, 17], [13, 25], [14, 17], [18, 22], [19, 24], [6, 7], [16, 23], [11, 20], [10, 16], [9, 23], [12, 15], [6, 19], [3, 13], [9, 16], [18, 25], [13, 18], [1, 23], [18, 24], [7, 18], [6, 15], [11, 13], [5, 21], [12, 20], [6, 24], [10, 14], [14, 21], [8, 18], [15, 24], [0, 6], [5, 13], [0, 18], [20, 23], [0, 20], [20, 25], [7, 21], [6, 25], [12, 16], [3, 8], [9, 13], [0, 12], [5, 15], [8, 14], [0, 3], [13, 14], [1, 19], [15, 19], [9, 10], [10, 18], [7, 12], [0, 2], [5, 17], [7, 22], [11, 23], [3, 20], [2, 8], [16, 20], [3, 10], [19, 22], [4, 18], [16, 21], [8, 12], [8, 15], [9, 24], [3, 9], [17, 25], [12, 24], [4, 8], [18, 20], [11, 25], [11, 21], [7, 19], [12, 17], [2, 17], [3, 7], [8, 9], [6, 22], [8, 25], [12, 18], [5, 18], [3, 24], [0, 10], [10, 20], [2, 24], [3, 16], [11, 14], [23, 24], [3, 25], [4, 15], [4, 23], [20, 22], [0, 1], [2, 15], [11, 24], [11, 15], [14, 20], [7, 25], [9, 17], [20, 24], [12, 22], [8, 11], [17, 24], [5, 14], [10, 24], [3, 14], [9, 14], [15, 21], [7, 20], [3, 15], [13, 23], [7, 8], [4, 21], [0, 11], [3, 18], [3, 6], [6, 17], [9, 12], [15, 23], [4, 25], [4, 6], [6, 14], [5, 8], [10, 11], [2, 21], [10, 21], [5, 9], [19, 23], [1, 12], [6, 9], [2, 10], [16, 17], [2, 23], [4, 22], [0, 5], [19, 25], [21, 22], [8, 16], [13, 15], [4, 7], [17, 19], [2, 6], [3, 22], [1, 11], [5, 19], [7, 23], [6, 16], [3, 23], [7, 24], [5, 6], [1, 15], [22, 23]], "edges2": [[4, 25], [10, 22], [26, 27], [7, 30], [18, 20], [2, 3], [2, 33], [25, 33], [8, 15], [1, 23], [8, 17], [2, 34], [20, 21], [2, 4], [11, 26], [1, 5], [22, 30], [2, 5], [0, 15], [33, 35], [0, 12], [11, 20], [13, 27], [9, 17], [21, 31], [14, 23], [21, 24], [0, 3], [17, 31], [0, 9], [17, 27], [5, 18], [1, 6], [8, 31], [26, 35], [26, 33], [8, 32], [17, 21], [7, 32], [7, 16], [4, 20], [24, 34], [4, 27], [1, 14], [2, 23], [32, 33], [1, 28], [2, 8], [24, 31], [2, 32], [7, 34], [15, 27], [24, 32], [24, 35], [3, 7], [5, 27], [8, 11], [21, 23], [29, 32], [19, 35], [10, 12], [14, 25], [7, 33], [14, 22], [9, 22], [28, 30], [0, 27], [0, 22], [6, 24], [16, 29], [22, 34], [0, 29], [0, 16], [1, 27], [20, 33], [14, 35], [17, 29], [0, 26], [15, 16], [8, 20], [4, 28], [1, 10], [13, 15], [22, 26], [1, 17], [6, 9], [4, 17], [15, 26], [20, 30], [12, 14], [3, 18], [16, 27], [22, 27], [4, 16], [24, 28], [21, 34], [8, 9], [5, 6], [3, 30], [1, 7], [10, 32], [34, 35], [5, 28], [12, 31], [29, 34], [11, 16], [11, 15], [15, 31], [0, 21], [13, 25], [19, 29], [4, 35], [19, 32], [3, 28], [6, 20], [2, 27], [6, 26], [30, 34], [15, 28], [2, 19], [22, 25], [0, 8], [13, 30], [11, 31], [9, 11], [5, 17], [19, 31], [1, 24], [0, 18], [3, 15], [32, 35], [3, 31], [21, 27], [10, 15], [18, 23], [7, 13], [14, 17], [18, 27], [18, 31], [7, 9], [30, 31], [23, 26], [22, 23], [8, 23], [2, 24], [14, 24], [19, 22], [12, 13], [15, 32], [13, 19], [5, 21], [15, 33], [22, 35], [4, 31], [6, 33], [13, 22], [1, 9], [23, 31], [26, 31], [0, 23], [18, 25], [9, 14], [4, 33], [17, 18], [26, 29], [0, 2], [8, 22], [7, 12], [25, 28], [2, 11], [6, 10], [11, 27], [23, 32], [17, 23], [16, 31], [17, 35], [0, 13], [1, 8], [1, 31], [2, 21], [6, 23], [3, 34], [12, 34], [8, 12], [2, 16], [26, 28], [21, 22], [12, 29], [25, 35], [10, 21], [18, 26], [16, 25], [9, 16], [3, 11], [8, 16], [18, 24], [0, 34], [27, 32], [9, 20], [4, 24], [8, 24], [17, 33], [5, 23], [8, 25], [5, 14], [18, 22], [6, 19], [9, 15], [6, 22], [3, 25], [1, 30], [2, 13], [7, 25], [8, 29], [3, 20], [6, 8], [16, 32], [0, 19], [11, 12], [3, 13], [32, 34], [18, 35], [6, 31], [16, 18], [20, 24], [1, 2], [1, 21], [20, 26], [24, 26], [10, 17], [4, 22], [15, 23], [11, 13], [8, 33], [10, 23], [20, 35], [2, 15], [11, 19], [12, 18], [22, 24], [4, 29], [17, 24], [12, 16], [29, 33], [14, 19], [10, 31], [7, 10], [11, 22], [27, 29], [25, 30], [0, 4], [27, 35], [4, 6], [1, 35], [8, 19], [24, 29], [17, 25], [6, 29], [2, 12], [23, 34], [16, 24], [15, 17], [4, 15], [2, 17], [14, 21], [26, 32], [7, 26], [27, 28], [0, 33], [18, 28], [10, 19], [4, 7], [9, 34], [3, 12], [6, 18], [21, 28], [8, 10], [3, 21], [20, 25], [1, 16], [8, 30], [31, 33], [13, 31], [11, 17], [5, 20], [4, 26], [4, 23], [18, 34], [27, 31], [5, 25], [1, 20], [18, 29], [5, 29], [1, 3], [15, 35], [3, 32], [10, 13], [5, 33], [20, 28], [9, 35], [4, 11], [7, 15], [12, 25], [12, 19], [8, 13], [1, 4], [3, 23], [23, 28], [4, 10], [19, 20], [19, 28], [22, 28], [15, 34], [6, 11], [15, 29], [4, 13], [1, 12], [6, 28], [29, 31], [21, 25], [12, 21], [9, 30], [1, 18], [19, 27], [8, 35], [27, 30], [12, 30], [9, 19], [17, 26], [2, 22], [5, 8], [10, 11], [19, 26], [26, 30], [2, 6], [7, 20], [15, 21], [9, 24], [23, 33], [9, 29], [4, 8], [19, 25], [17, 30], [1, 19], [10, 18], [5, 9], [9, 33], [9, 13], [21, 33], [4, 14], [2, 28], [2, 7], [1, 11], [22, 32], [23, 35], [6, 14], [28, 33], [6, 30], [10, 28], [16, 28], [20, 27], [23, 25], [16, 26], [13, 16], [18, 19], [23, 30], [0, 1], [24, 30], [13, 17], [2, 10], [11, 14], [11, 30], [31, 34], [18, 32], [18, 33], [5, 26], [13, 23], [20, 31], [6, 13], [9, 32], [11, 23], [3, 24], [3, 35], [14, 16], [12, 24], [12, 22], [25, 29], [15, 30], [23, 27], [17, 32], [16, 33], [5, 32], [5, 10], [6, 7], [19, 21], [9, 26], [3, 33], [25, 31], [6, 25], [8, 27], [8, 28], [14, 29], [5, 35], [11, 18], [1, 33], [13, 14], [15, 19], [10, 20], [19, 33], [2, 18], [17, 20], [11, 25], [2, 35], [11, 32], [27, 34], [7, 24], [6, 35], [22, 33], [16, 17], [24, 33], [12, 33], [4, 12], [4, 9], [25, 26], [28, 34], [10, 29], [14, 32], [0, 24], [22, 31], [28, 32], [12, 27], [20, 29], [21, 26], [21, 32], [13, 24], [2, 26], [3, 6], [33, 34], [14, 33], [3, 10], [5, 34], [0, 5], [17, 22], [20, 22], [13, 33], [2, 14], [14, 15], [30, 32], [19, 23], [0, 20], [3, 17], [8, 14], [16, 30], [31, 32], [0, 25], [12, 23], [7, 19], [15, 24], [1, 13], [3, 8], [13, 26], [5, 13], [16, 23], [3, 27], [6, 16], [1, 22], [13, 29], [11, 28], [9, 18], [30, 35], [14, 28], [9, 31]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l6-s4/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l6-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..52afbe7800589ca977a83a5063bded1f6c143700 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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' +{"p": [21, 10, 24, 23, 35, 22, 2, 6, 30, 27, 0, 15, 28, 31, 34, 8, 26, 32, 25, 11, 33, 9, 14, 4, 16, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l6-s4/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l6-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l6-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-l6-s4/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l6-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0ace6121edb12cb6cf2a7381cdd1ec38bc6f3f6d --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l6-s4/tests/instance.json @@ -0,0 +1 @@ +{"n1": 26, "n2": 36, "edges1": [[16, 18], [4, 17], [2, 11], [7, 16], [2, 14], [13, 16], [15, 18], [1, 3], [16, 24], [8, 19], [14, 25], [2, 4], [15, 22], [1, 7], [18, 19], [9, 25], [5, 16], [17, 20], [8, 17], [18, 23], [2, 12], [5, 12], [1, 13], [5, 20], [0, 22], [4, 5], [5, 7], [0, 9], [5, 23], [4, 16], [2, 5], [2, 16], [8, 21], [19, 21], [15, 20], [12, 14], [0, 25], [4, 9], [10, 15], [1, 25], [1, 6], [3, 12], [12, 25], [6, 11], [4, 20], [9, 15], [4, 14], [10, 25], [11, 19], [21, 23], [11, 17], [0, 17], [13, 20], [1, 5], [3, 11], [22, 24], [0, 13], [8, 24], [13, 19], [15, 25], [3, 17], [13, 24], [5, 10], [0, 16], [10, 23], [7, 15], [3, 19], [7, 13], [9, 11], [2, 25], [11, 22], [6, 23], [5, 22], [21, 24], [12, 19], [17, 21], [11, 12], [9, 19], [13, 17], [11, 16], [2, 7], [2, 20], [16, 19], [2, 13], [6, 20], [4, 11], [20, 21], [6, 10], [12, 23], [6, 12], [13, 21], [3, 5], [0, 14], [8, 13], [17, 22], [3, 4], [2, 22], [15, 17], [1, 17], [13, 25], [14, 17], [18, 22], [19, 24], [6, 7], [16, 23], [11, 20], [10, 16], [9, 23], [12, 15], [6, 19], [3, 13], [9, 16], [18, 25], [13, 18], [1, 23], [18, 24], [7, 18], [6, 15], [11, 13], [5, 21], [12, 20], [6, 24], [10, 14], [14, 21], [8, 18], [15, 24], [0, 6], [5, 13], [0, 18], [20, 23], [0, 20], [20, 25], [7, 21], [6, 25], [12, 16], [3, 8], [9, 13], [0, 12], [5, 15], [8, 14], [0, 3], [13, 14], [1, 19], [15, 19], [9, 10], [10, 18], [7, 12], [0, 2], [5, 17], [7, 22], [11, 23], [3, 20], [2, 8], [16, 20], [3, 10], [19, 22], [4, 18], [16, 21], [8, 12], [8, 15], [9, 24], [3, 9], [17, 25], [12, 24], [4, 8], [18, 20], [11, 25], [11, 21], [7, 19], [12, 17], [2, 17], [3, 7], [8, 9], [6, 22], [8, 25], [12, 18], [5, 18], [3, 24], [0, 10], [10, 20], [2, 24], [3, 16], [11, 14], [23, 24], [3, 25], [4, 15], [4, 23], [20, 22], [0, 1], [2, 15], [11, 24], [11, 15], [14, 20], [7, 25], [9, 17], [20, 24], [12, 22], [8, 11], [17, 24], [5, 14], [10, 24], [3, 14], [9, 14], [15, 21], [7, 20], [3, 15], [13, 23], [7, 8], [4, 21], [0, 11], [3, 18], [3, 6], [6, 17], [9, 12], [15, 23], [4, 25], [4, 6], [6, 14], [5, 8], [10, 11], [2, 21], [10, 21], [5, 9], [19, 23], [1, 12], [6, 9], [2, 10], [16, 17], [2, 23], [4, 22], [0, 5], [19, 25], [21, 22], [8, 16], [13, 15], [4, 7], [17, 19], [2, 6], [3, 22], [1, 11], [5, 19], [7, 23], [6, 16], [3, 23], [7, 24], [5, 6], [1, 15], [22, 23]], "edges2": [[4, 25], [10, 22], [26, 27], [7, 30], [18, 20], [2, 3], [2, 33], [25, 33], [8, 15], [1, 23], [8, 17], [2, 34], [20, 21], [2, 4], [11, 26], [1, 5], [22, 30], [2, 5], [0, 15], [33, 35], [0, 12], [11, 20], [13, 27], [9, 17], [21, 31], [14, 23], [21, 24], [0, 3], [17, 31], [0, 9], [17, 27], [5, 18], [1, 6], [8, 31], [26, 35], [26, 33], [8, 32], [17, 21], [7, 32], [7, 16], [4, 20], [24, 34], [4, 27], [1, 14], [2, 23], [32, 33], [1, 28], [2, 8], [24, 31], [2, 32], [7, 34], [15, 27], [24, 32], [24, 35], [3, 7], [5, 27], [8, 11], [21, 23], [29, 32], [19, 35], [10, 12], [14, 25], [7, 33], [14, 22], [9, 22], [28, 30], [0, 27], [0, 22], [6, 24], [16, 29], [22, 34], [0, 29], [0, 16], [1, 27], [20, 33], [14, 35], [17, 29], [0, 26], [15, 16], [8, 20], [4, 28], [1, 10], [13, 15], [22, 26], [1, 17], [6, 9], [4, 17], [15, 26], [20, 30], [12, 14], [3, 18], [16, 27], [22, 27], [4, 16], [24, 28], [21, 34], [8, 9], [5, 6], [3, 30], [1, 7], [10, 32], [34, 35], [5, 28], [12, 31], [29, 34], [11, 16], [11, 15], [15, 31], [0, 21], [13, 25], [19, 29], [4, 35], [19, 32], [3, 28], [6, 20], [2, 27], [6, 26], [30, 34], [15, 28], [2, 19], [22, 25], [0, 8], [13, 30], [11, 31], [9, 11], [5, 17], [19, 31], [1, 24], [0, 18], [3, 15], [32, 35], [3, 31], [21, 27], [10, 15], [18, 23], [7, 13], [14, 17], [18, 27], [18, 31], [7, 9], [30, 31], [23, 26], [22, 23], [8, 23], [2, 24], [14, 24], [19, 22], [12, 13], [15, 32], [13, 19], [5, 21], [15, 33], [22, 35], [4, 31], [6, 33], [13, 22], [1, 9], [23, 31], [26, 31], [0, 23], [18, 25], [9, 14], [4, 33], [17, 18], [26, 29], [0, 2], [8, 22], [7, 12], [25, 28], [2, 11], [6, 10], [11, 27], [23, 32], [17, 23], [16, 31], [17, 35], [0, 13], [1, 8], [1, 31], [2, 21], [6, 23], [3, 34], [12, 34], [8, 12], [2, 16], [26, 28], [21, 22], [12, 29], [25, 35], [10, 21], [18, 26], [16, 25], [9, 16], [3, 11], [8, 16], [18, 24], [0, 34], [27, 32], [9, 20], [4, 24], [8, 24], [17, 33], [5, 23], [8, 25], [5, 14], [18, 22], [6, 19], [9, 15], [6, 22], [3, 25], [1, 30], [2, 13], [7, 25], [8, 29], [3, 20], [6, 8], [16, 32], [0, 19], [11, 12], [3, 13], [32, 34], [18, 35], [6, 31], [16, 18], [20, 24], [1, 2], [1, 21], [20, 26], [24, 26], [10, 17], [4, 22], [15, 23], [11, 13], [8, 33], [10, 23], [20, 35], [2, 15], [11, 19], [12, 18], [22, 24], [4, 29], [17, 24], [12, 16], [29, 33], [14, 19], [10, 31], [7, 10], [11, 22], [27, 29], [25, 30], [0, 4], [27, 35], [4, 6], [1, 35], [8, 19], [24, 29], [17, 25], [6, 29], [2, 12], [23, 34], [16, 24], [15, 17], [4, 15], [2, 17], [14, 21], [26, 32], [7, 26], [27, 28], [0, 33], [18, 28], [10, 19], [4, 7], [9, 34], [3, 12], [6, 18], [21, 28], [8, 10], [3, 21], [20, 25], [1, 16], [8, 30], [31, 33], [13, 31], [11, 17], [5, 20], [4, 26], [4, 23], [18, 34], [27, 31], [5, 25], [1, 20], [18, 29], [5, 29], [1, 3], [15, 35], [3, 32], [10, 13], [5, 33], [20, 28], [9, 35], [4, 11], [7, 15], [12, 25], [12, 19], [8, 13], [1, 4], [3, 23], [23, 28], [4, 10], [19, 20], [19, 28], [22, 28], [15, 34], [6, 11], [15, 29], [4, 13], [1, 12], [6, 28], [29, 31], [21, 25], [12, 21], [9, 30], [1, 18], [19, 27], [8, 35], [27, 30], [12, 30], [9, 19], [17, 26], [2, 22], [5, 8], [10, 11], [19, 26], [26, 30], [2, 6], [7, 20], [15, 21], [9, 24], [23, 33], [9, 29], [4, 8], [19, 25], [17, 30], [1, 19], [10, 18], [5, 9], [9, 33], [9, 13], [21, 33], [4, 14], [2, 28], [2, 7], [1, 11], [22, 32], [23, 35], [6, 14], [28, 33], [6, 30], [10, 28], [16, 28], [20, 27], [23, 25], [16, 26], [13, 16], [18, 19], [23, 30], [0, 1], [24, 30], [13, 17], [2, 10], [11, 14], [11, 30], [31, 34], [18, 32], [18, 33], [5, 26], [13, 23], [20, 31], [6, 13], [9, 32], [11, 23], [3, 24], [3, 35], [14, 16], [12, 24], [12, 22], [25, 29], [15, 30], [23, 27], [17, 32], [16, 33], [5, 32], [5, 10], [6, 7], [19, 21], [9, 26], [3, 33], [25, 31], [6, 25], [8, 27], [8, 28], [14, 29], [5, 35], [11, 18], [1, 33], [13, 14], [15, 19], [10, 20], [19, 33], [2, 18], [17, 20], [11, 25], [2, 35], [11, 32], [27, 34], [7, 24], [6, 35], [22, 33], [16, 17], [24, 33], [12, 33], [4, 12], [4, 9], [25, 26], [28, 34], [10, 29], [14, 32], [0, 24], [22, 31], [28, 32], [12, 27], [20, 29], [21, 26], [21, 32], [13, 24], [2, 26], [3, 6], [33, 34], [14, 33], [3, 10], [5, 34], [0, 5], [17, 22], [20, 22], [13, 33], [2, 14], [14, 15], [30, 32], [19, 23], [0, 20], [3, 17], [8, 14], [16, 30], [31, 32], [0, 25], [12, 23], [7, 19], [15, 24], [1, 13], [3, 8], [13, 26], [5, 13], [16, 23], [3, 27], [6, 16], [1, 22], [13, 29], [11, 28], [9, 18], [30, 35], [14, 28], [9, 31]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l6-s4/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l6-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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-subgraph-isomorphism-l6-s4/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l6-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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/optimize-ae-p1-ff-kakeya-d3-p5/environment/Dockerfile b/tasks/optimize-ae-p1-ff-kakeya-d3-p5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p5/environment/instance.json b/tasks/optimize-ae-p1-ff-kakeya-d3-p5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2fbf79166b6a90a0294b0e4dbe7bab3e0c1c42ab --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p5/environment/instance.json @@ -0,0 +1 @@ +{"p": 5, "d": 3, "direction": "minimize", "family": "ae_p1_ff_kakeya", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p5/solution/solve.sh b/tasks/optimize-ae-p1-ff-kakeya-d3-p5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4be42067bd10894e42b674d4b7f0e5f325add542 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"points": [[0, 0, 0], [0, 0, 1], [0, 0, 2], [0, 0, 3], [0, 0, 4], [0, 1, 0], [0, 1, 1], [0, 1, 4], [0, 2, 2], [0, 2, 3], [0, 2, 4], [0, 3, 2], [0, 3, 3], [0, 3, 4], [0, 4, 0], [0, 4, 1], [0, 4, 4], [1, 0, 2], [1, 0, 3], [1, 1, 0], [1, 2, 0], [1, 2, 1], [1, 2, 4], [1, 3, 0], [1, 4, 2], [1, 4, 3], [2, 0, 0], [2, 1, 0], [2, 1, 1], [2, 1, 4], [2, 2, 0], [2, 3, 2], [2, 3, 3], [2, 4, 2], [2, 4, 3], [3, 0, 2], [3, 0, 3], [3, 1, 0], [3, 2, 0], [3, 2, 1], [3, 2, 4], [3, 3, 0], [3, 4, 2], [3, 4, 3], [4, 0, 0], [4, 0, 1], [4, 0, 4], [4, 1, 0], [4, 2, 2], [4, 2, 3], [4, 3, 2], [4, 3, 3], [4, 4, 0]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p5/tests/check.py b/tasks/optimize-ae-p1-ff-kakeya-d3-p5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..dac5049b59a505ff843bc5e086d0c1c303695b2a --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p5/tests/check.py @@ -0,0 +1,32 @@ +"""Finite-field Kakeya set in F_p^d: every direction contains a full line. Score = |K| (minimize). + +Upstream (AlphaEvolve notebook `finite_field_kakeya.ipynb`) silently deduplicated points and only checked +d in {3, 4}; here duplicates, out-of-range or non-integer coordinates are rejected and every projective +direction (first non-zero coordinate = 1) is checked for any d. +""" +import itertools + +import numpy as np + +from run import Invalid, int_list + + +def check(inst, ans): + p, d = inst["p"], inst["d"] + pts = ans.get("points") + if not isinstance(pts, list) or not pts: + raise Invalid("points must be a non-empty list") + if len(pts) > p ** d: + raise Invalid("more points than the whole space") + K = np.array([int_list(x, d, 0, p - 1, "point") for x in pts], dtype=np.int64) + w = p ** np.arange(d - 1, -1, -1, dtype=np.int64) + codes = K @ w + if len(np.unique(codes)) != len(codes): + raise Invalid("duplicate points") + for i in range(d): # directions v = (0,..,0,1,*,..,*) with the 1 in position i + for tail in itertools.product(range(p), repeat=d - 1 - i): + v = np.array([0] * i + [1] + list(tail), dtype=np.int64) + base = (K - K[:, i:i + 1] * v) % p # canonical point of the line through x with direction v + if np.bincount(base @ w, minlength=p ** d).max() < p: + raise Invalid(f"no full line in direction {v.tolist()}") + return len(pts), {"size": len(pts)} diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p5/tests/instance.json b/tasks/optimize-ae-p1-ff-kakeya-d3-p5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7b1fae9aedaeb35f3e3b2da846d3657044df6453 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p5/tests/instance.json @@ -0,0 +1 @@ +{"p": 5, "d": 3, "direction": "minimize", "best_known": 53, "baseline": 125, "family": "ae_p1_ff_kakeya", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p5/tests/run.py b/tasks/optimize-ae-p1-ff-kakeya-d3-p5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/optimize-ae-p1-ff-kakeya-d3-p5/tests/test.sh b/tasks/optimize-ae-p1-ff-kakeya-d3-p5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-kakeya-d3-p5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/optimize-ae-p1-ff-nikodym-d3-p53/environment/Dockerfile b/tasks/optimize-ae-p1-ff-nikodym-d3-p53/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p53/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/optimize-ae-p1-ff-nikodym-d3-p53/environment/instance.json b/tasks/optimize-ae-p1-ff-nikodym-d3-p53/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2ab76b6ecdae202a1a20fca5c533b8fbb86a797f --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p53/environment/instance.json @@ -0,0 +1 @@ +{"p": 53, "direction": "minimize", "family": "ae_p1_ff_nikodym", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p1-ff-nikodym-d3-p53/solution/solve.sh b/tasks/optimize-ae-p1-ff-nikodym-d3-p53/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fd8cf4d0815cc8f89b06a0788931057c4bbcc1ac --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p53/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"removed": [[0, 1, 1], [0, 2, 2], [0, 3, 3], [0, 4, 4], [0, 5, 5], [0, 6, 6], [0, 7, 7], [0, 8, 8], [0, 9, 9], [0, 10, 10], [0, 11, 11], [0, 12, 12], [0, 13, 13], [0, 14, 14], [0, 15, 15], [0, 16, 16], [0, 17, 17], [0, 18, 18], [0, 19, 19], [0, 20, 20], [0, 21, 21], [0, 22, 22], [0, 23, 23], [0, 24, 24], [0, 25, 25], [0, 26, 26], [0, 27, 27], [0, 28, 28], [0, 29, 29], [0, 30, 30], [0, 31, 31], [0, 32, 32], [0, 33, 33], [0, 34, 34], [0, 35, 35], [0, 36, 36], [0, 37, 37], [0, 38, 38], [0, 39, 39], [0, 40, 40], [0, 41, 41], [0, 42, 42], [0, 43, 43], [0, 44, 44], [0, 45, 45], [0, 46, 46], [0, 47, 47], [0, 48, 48], [0, 49, 49], [0, 50, 50], [0, 51, 51], [0, 52, 52], [1, 0, 1], [1, 1, 0], [1, 1, 1], [2, 0, 2], [2, 1, 2], [2, 1, 4], [2, 1, 8], [2, 1, 10], [2, 1, 16], [2, 1, 20], [2, 1, 27], [2, 1, 40], [2, 2, 0], [2, 2, 1], [2, 2, 2], [2, 2, 4], [2, 2, 8], [2, 2, 16], [2, 2, 20], [2, 2, 27], [2, 2, 32], [2, 2, 40], [2, 3, 6], [2, 3, 7], [2, 3, 12], [2, 3, 14], [2, 3, 24], [2, 3, 28], [2, 3, 30], [2, 3, 48], [2, 4, 1], [2, 4, 2], [2, 4, 8], [2, 4, 11], [2, 4, 16], [2, 4, 27], [2, 4, 32], [2, 4, 40], [2, 5, 10], [2, 5, 20], [2, 5, 27], [2, 5, 29], [2, 5, 40], [2, 5, 41], [2, 5, 47], [2, 5, 50], [2, 6, 3], [2, 6, 7], [2, 6, 12], [2, 6, 14], [2, 6, 24], [2, 6, 28], [2, 6, 43], [2, 6, 48], [2, 7, 3], [2, 7, 6], [2, 7, 14], [2, 7, 15], [2, 7, 17], [2, 7, 28], [2, 7, 30], [2, 7, 34], [2, 8, 1], [2, 8, 2], [2, 8, 4], [2, 8, 11], [2, 8, 16], [2, 8, 22], [2, 8, 27], [2, 8, 32], [2, 9, 18], [2, 9, 19], [2, 9, 21], [2, 9, 31], [2, 9, 36], [2, 9, 37], [2, 9, 38], [2, 9, 42], [2, 10, 1], [2, 10, 5], [2, 10, 20], [2, 10, 27], [2, 10, 29], [2, 10, 40], [2, 10, 41], [2, 10, 47], [2, 11, 4], [2, 11, 8], [2, 11, 16], [2, 11, 17], [2, 11, 22], [2, 11, 32], [2, 11, 35], [2, 11, 44], [2, 12, 3], [2, 12, 6], [2, 12, 14], [2, 12, 24], [2, 12, 28], [2, 12, 33], [2, 12, 43], [2, 12, 48], [2, 13, 24], [2, 13, 26], [2, 13, 33], [2, 13, 43], [2, 13, 48], [2, 13, 49], [2, 13, 51], [2, 13, 52], [2, 14, 3], [2, 14, 6], [2, 14, 7], [2, 14, 12], [2, 14, 15], [2, 14, 28], [2, 14, 30], [2, 14, 34], [2, 15, 7], [2, 15, 14], [2, 15, 17], [2, 15, 28], [2, 15, 30], [2, 15, 34], [2, 15, 35], [2, 15, 44], [2, 16, 1], [2, 16, 2], [2, 16, 4], [2, 16, 8], [2, 16, 11], [2, 16, 22], [2, 16, 32], [2, 16, 44], [2, 17, 7], [2, 17, 11], [2, 17, 15], [2, 17, 22], [2, 17, 30], [2, 17, 34], [2, 17, 35], [2, 17, 44], [2, 18, 9], [2, 18, 19], [2, 18, 21], [2, 18, 23], [2, 18, 31], [2, 18, 36], [2, 18, 38], [2, 18, 42], [2, 19, 9], [2, 19, 18], [2, 19, 23], [2, 19, 31], [2, 19, 36], [2, 19, 38], [2, 19, 39], [2, 19, 46], [2, 20, 1], [2, 20, 2], [2, 20, 5], [2, 20, 10], [2, 20, 27], [2, 20, 29], [2, 20, 40], [2, 20, 41], [2, 21, 9], [2, 21, 18], [2, 21, 31], [2, 21, 37], [2, 21, 42], [2, 21, 45], [2, 21, 49], [2, 21, 51], [2, 22, 8], [2, 22, 11], [2, 22, 16], [2, 22, 17], [2, 22, 32], [2, 22, 34], [2, 22, 35], [2, 22, 44], [2, 23, 18], [2, 23, 19], [2, 23, 25], [2, 23, 36], [2, 23, 38], [2, 23, 39], [2, 23, 46], [2, 23, 50], [2, 24, 3], [2, 24, 6], [2, 24, 12], [2, 24, 13], [2, 24, 28], [2, 24, 33], [2, 24, 43], [2, 24, 48], [2, 25, 23], [2, 25, 29], [2, 25, 38], [2, 25, 39], [2, 25, 41], [2, 25, 46], [2, 25, 47], [2, 25, 50], [2, 26, 13], [2, 26, 33], [2, 26, 43], [2, 26, 45], [2, 26, 48], [2, 26, 49], [2, 26, 51], [2, 26, 52], [2, 27, 1], [2, 27, 2], [2, 27, 4], [2, 27, 5], [2, 27, 8], [2, 27, 10], [2, 27, 20], [2, 27, 40], [2, 28, 3], [2, 28, 6], [2, 28, 7], [2, 28, 12], [2, 28, 14], [2, 28, 15], [2, 28, 24], [2, 28, 30], [2, 29, 5], [2, 29, 10], [2, 29, 20], [2, 29, 25], [2, 29, 40], [2, 29, 41], [2, 29, 47], [2, 29, 50], [2, 30, 3], [2, 30, 7], [2, 30, 14], [2, 30, 15], [2, 30, 17], [2, 30, 28], [2, 30, 34], [2, 30, 35], [2, 31, 9], [2, 31, 18], [2, 31, 19], [2, 31, 21], [2, 31, 36], [2, 31, 37], [2, 31, 42], [2, 31, 45], [2, 32, 2], [2, 32, 4], [2, 32, 8], [2, 32, 11], [2, 32, 16], [2, 32, 22], [2, 32, 35], [2, 32, 44], [2, 33, 12], [2, 33, 13], [2, 33, 24], [2, 33, 26], [2, 33, 43], [2, 33, 48], [2, 33, 51], [2, 33, 52], [2, 34, 7], [2, 34, 14], [2, 34, 15], [2, 34, 17], [2, 34, 22], [2, 34, 30], [2, 34, 35], [2, 34, 44], [2, 35, 11], [2, 35, 15], [2, 35, 17], [2, 35, 22], [2, 35, 30], [2, 35, 32], [2, 35, 34], [2, 35, 44], [2, 36, 9], [2, 36, 18], [2, 36, 19], [2, 36, 23], [2, 36, 31], [2, 36, 38], [2, 36, 42], [2, 36, 46], [2, 37, 9], [2, 37, 21], [2, 37, 31], [2, 37, 42], [2, 37, 45], [2, 37, 49], [2, 37, 51], [2, 37, 52], [2, 38, 9], [2, 38, 18], [2, 38, 19], [2, 38, 23], [2, 38, 25], [2, 38, 36], [2, 38, 39], [2, 38, 46], [2, 39, 19], [2, 39, 23], [2, 39, 25], [2, 39, 38], [2, 39, 41], [2, 39, 46], [2, 39, 47], [2, 39, 50], [2, 40, 1], [2, 40, 2], [2, 40, 4], [2, 40, 5], [2, 40, 10], [2, 40, 20], [2, 40, 27], [2, 40, 29], [2, 41, 5], [2, 41, 10], [2, 41, 20], [2, 41, 25], [2, 41, 29], [2, 41, 39], [2, 41, 47], [2, 41, 50], [2, 42, 9], [2, 42, 18], [2, 42, 21], [2, 42, 31], [2, 42, 36], [2, 42, 37], [2, 42, 45], [2, 42, 49], [2, 43, 6], [2, 43, 12], [2, 43, 13], [2, 43, 24], [2, 43, 26], [2, 43, 33], [2, 43, 48], [2, 43, 52], [2, 44, 11], [2, 44, 15], [2, 44, 16], [2, 44, 17], [2, 44, 22], [2, 44, 32], [2, 44, 34], [2, 44, 35], [2, 45, 21], [2, 45, 26], [2, 45, 31], [2, 45, 37], [2, 45, 42], [2, 45, 49], [2, 45, 51], [2, 45, 52], [2, 46, 19], [2, 46, 23], [2, 46, 25], [2, 46, 36], [2, 46, 38], [2, 46, 39], [2, 46, 47], [2, 46, 50], [2, 47, 5], [2, 47, 10], [2, 47, 25], [2, 47, 29], [2, 47, 39], [2, 47, 41], [2, 47, 46], [2, 47, 50], [2, 48, 3], [2, 48, 6], [2, 48, 12], [2, 48, 13], [2, 48, 24], [2, 48, 26], [2, 48, 33], [2, 48, 43], [2, 49, 13], [2, 49, 21], [2, 49, 26], [2, 49, 37], [2, 49, 42], [2, 49, 45], [2, 49, 51], [2, 49, 52], [2, 50, 5], [2, 50, 23], [2, 50, 25], [2, 50, 29], [2, 50, 39], [2, 50, 41], [2, 50, 46], [2, 50, 47], [2, 51, 13], [2, 51, 21], [2, 51, 26], [2, 51, 33], [2, 51, 37], [2, 51, 45], [2, 51, 49], [2, 51, 52], [2, 52, 13], [2, 52, 26], [2, 52, 33], [2, 52, 37], [2, 52, 43], [2, 52, 45], [2, 52, 49], [2, 52, 51], [3, 0, 3], [3, 1, 2], [3, 1, 3], [3, 1, 6], [3, 1, 9], [3, 1, 18], [3, 1, 27], [3, 1, 28], [3, 1, 36], [3, 2, 1], [3, 2, 3], [3, 2, 4], [3, 2, 6], [3, 2, 12], [3, 2, 18], [3, 2, 19], [3, 2, 36], [3, 3, 0], [3, 3, 1], [3, 3, 2], [3, 3, 3], [3, 3, 6], [3, 3, 9], [3, 3, 18], [3, 3, 27], [3, 3, 28], [3, 3, 31], [3, 4, 2], [3, 4, 6], [3, 4, 8], [3, 4, 12], [3, 4, 19], [3, 4, 24], [3, 4, 36], [3, 4, 38], [3, 5, 10], [3, 5, 15], [3, 5, 21], [3, 5, 29], [3, 5, 30], [3, 5, 34], [3, 5, 37], [3, 5, 45], [3, 6, 1], [3, 6, 2], [3, 6, 3], [3, 6, 4], [3, 6, 9], [3, 6, 12], [3, 6, 18], [3, 6, 36], [3, 7, 10], [3, 7, 14], [3, 7, 20], [3, 7, 21], [3, 7, 30], [3, 7, 37], [3, 7, 40], [3, 7, 42], [3, 8, 4], [3, 8, 12], [3, 8, 16], [3, 8, 19], [3, 8, 23], [3, 8, 24], [3, 8, 38], [3, 8, 48], [3, 9, 1], [3, 9, 3], [3, 9, 6], [3, 9, 18], [3, 9, 27], [3, 9, 28], [3, 9, 31], [3, 9, 40], [3, 10, 5], [3, 10, 7], [3, 10, 15], [3, 10, 20], [3, 10, 21], [3, 10, 30], [3, 10, 37], [3, 10, 42], [3, 11, 13], [3, 11, 22], [3, 11, 25], [3, 11, 32], [3, 11, 33], [3, 11, 39], [3, 11, 43], [3, 11, 46], [3, 12, 2], [3, 12, 4], [3, 12, 6], [3, 12, 8], [3, 12, 18], [3, 12, 19], [3, 12, 24], [3, 12, 36], [3, 13, 11], [3, 13, 22], [3, 13, 25], [3, 13, 26], [3, 13, 33], [3, 13, 39], [3, 13, 44], [3, 13, 46], [3, 14, 7], [3, 14, 20], [3, 14, 21], [3, 14, 27], [3, 14, 28], [3, 14, 31], [3, 14, 40], [3, 14, 42], [3, 15, 5], [3, 15, 10], [3, 15, 29], [3, 15, 30], [3, 15, 34], [3, 15, 37], [3, 15, 45], [3, 15, 49], [3, 16, 8], [3, 16, 23], [3, 16, 24], [3, 16, 32], [3, 16, 38], [3, 16, 43], [3, 16, 46], [3, 16, 48], [3, 17, 29], [3, 17, 34], [3, 17, 35], [3, 17, 41], [3, 17, 47], [3, 17, 49], [3, 17, 51], [3, 17, 52], [3, 18, 1], [3, 18, 2], [3, 18, 3], [3, 18, 6], [3, 18, 9], [3, 18, 12], [3, 18, 27], [3, 18, 36], [3, 19, 2], [3, 19, 4], [3, 19, 8], [3, 19, 12], [3, 19, 24], [3, 19, 36], [3, 19, 38], [3, 19, 48], [3, 20, 7], [3, 20, 10], [3, 20, 14], [3, 20, 21], [3, 20, 30], [3, 20, 31], [3, 20, 40], [3, 20, 42], [3, 21, 5], [3, 21, 7], [3, 21, 10], [3, 21, 14], [3, 21, 20], [3, 21, 30], [3, 21, 37], [3, 21, 42], [3, 22, 11], [3, 22, 13], [3, 22, 25], [3, 22, 26], [3, 22, 33], [3, 22, 39], [3, 22, 44], [3, 22, 50], [3, 23, 8], [3, 23, 16], [3, 23, 32], [3, 23, 33], [3, 23, 38], [3, 23, 43], [3, 23, 46], [3, 23, 48], [3, 24, 4], [3, 24, 8], [3, 24, 12], [3, 24, 16], [3, 24, 19], [3, 24, 36], [3, 24, 38], [3, 24, 48], [3, 25, 11], [3, 25, 13], [3, 25, 22], [3, 25, 26], [3, 25, 39], [3, 25, 44], [3, 25, 50], [3, 25, 52], [3, 26, 13], [3, 26, 22], [3, 26, 25], [3, 26, 35], [3, 26, 39], [3, 26, 44], [3, 26, 50], [3, 26, 52], [3, 27, 1], [3, 27, 3], [3, 27, 9], [3, 27, 14], [3, 27, 18], [3, 27, 28], [3, 27, 31], [3, 27, 40], [3, 28, 1], [3, 28, 3], [3, 28, 9], [3, 28, 14], [3, 28, 27], [3, 28, 31], [3, 28, 40], [3, 28, 42], [3, 29, 5], [3, 29, 15], [3, 29, 17], [3, 29, 34], [3, 29, 37], [3, 29, 41], [3, 29, 45], [3, 29, 49], [3, 30, 5], [3, 30, 7], [3, 30, 10], [3, 30, 15], [3, 30, 20], [3, 30, 21], [3, 30, 37], [3, 30, 45], [3, 31, 3], [3, 31, 9], [3, 31, 14], [3, 31, 20], [3, 31, 27], [3, 31, 28], [3, 31, 40], [3, 31, 42], [3, 32, 11], [3, 32, 16], [3, 32, 23], [3, 32, 33], [3, 32, 39], [3, 32, 43], [3, 32, 46], [3, 32, 48], [3, 33, 11], [3, 33, 13], [3, 33, 22], [3, 33, 23], [3, 33, 32], [3, 33, 39], [3, 33, 43], [3, 33, 46], [3, 34, 5], [3, 34, 15], [3, 34, 17], [3, 34, 29], [3, 34, 41], [3, 34, 45], [3, 34, 49], [3, 34, 51], [3, 35, 17], [3, 35, 26], [3, 35, 41], [3, 35, 44], [3, 35, 47], [3, 35, 50], [3, 35, 51], [3, 35, 52], [3, 36, 1], [3, 36, 2], [3, 36, 4], [3, 36, 6], [3, 36, 12], [3, 36, 18], [3, 36, 19], [3, 36, 24], [3, 37, 5], [3, 37, 7], [3, 37, 10], [3, 37, 15], [3, 37, 21], [3, 37, 29], [3, 37, 30], [3, 37, 45], [3, 38, 4], [3, 38, 8], [3, 38, 16], [3, 38, 19], [3, 38, 23], [3, 38, 24], [3, 38, 43], [3, 38, 48], [3, 39, 11], [3, 39, 13], [3, 39, 22], [3, 39, 25], [3, 39, 26], [3, 39, 32], [3, 39, 33], [3, 39, 46], [3, 40, 7], [3, 40, 9], [3, 40, 14], [3, 40, 20], [3, 40, 27], [3, 40, 28], [3, 40, 31], [3, 40, 42], [3, 41, 17], [3, 41, 29], [3, 41, 34], [3, 41, 35], [3, 41, 45], [3, 41, 47], [3, 41, 49], [3, 41, 51], [3, 42, 7], [3, 42, 10], [3, 42, 14], [3, 42, 20], [3, 42, 21], [3, 42, 28], [3, 42, 31], [3, 42, 40], [3, 43, 11], [3, 43, 16], [3, 43, 23], [3, 43, 32], [3, 43, 33], [3, 43, 38], [3, 43, 46], [3, 43, 48], [3, 44, 13], [3, 44, 22], [3, 44, 25], [3, 44, 26], [3, 44, 35], [3, 44, 47], [3, 44, 50], [3, 44, 52], [3, 45, 5], [3, 45, 15], [3, 45, 29], [3, 45, 30], [3, 45, 34], [3, 45, 37], [3, 45, 41], [3, 45, 49], [3, 46, 11], [3, 46, 13], [3, 46, 16], [3, 46, 23], [3, 46, 32], [3, 46, 33], [3, 46, 39], [3, 46, 43], [3, 47, 17], [3, 47, 35], [3, 47, 41], [3, 47, 44], [3, 47, 49], [3, 47, 50], [3, 47, 51], [3, 47, 52], [3, 48, 8], [3, 48, 16], [3, 48, 19], [3, 48, 23], [3, 48, 24], [3, 48, 32], [3, 48, 38], [3, 48, 43], [3, 49, 15], [3, 49, 17], [3, 49, 29], [3, 49, 34], [3, 49, 41], [3, 49, 45], [3, 49, 47], [3, 49, 51], [3, 50, 22], [3, 50, 25], [3, 50, 26], [3, 50, 35], [3, 50, 44], [3, 50, 47], [3, 50, 51], [3, 50, 52], [3, 51, 17], [3, 51, 34], [3, 51, 35], [3, 51, 41], [3, 51, 47], [3, 51, 49], [3, 51, 50], [3, 51, 52], [3, 52, 17], [3, 52, 25], [3, 52, 26], [3, 52, 35], [3, 52, 44], [3, 52, 47], [3, 52, 50], [3, 52, 51], [4, 0, 4], [4, 1, 4], [4, 1, 10], [4, 1, 11], [4, 1, 16], [4, 1, 29], [4, 1, 40], [4, 1, 44], [4, 1, 47], [4, 4, 0], [4, 4, 1], [4, 4, 4], [4, 4, 10], [4, 4, 11], [4, 4, 16], [4, 4, 17], [4, 4, 29], [4, 4, 40], [4, 4, 44], [4, 6, 7], [4, 6, 13], [4, 6, 15], [4, 6, 17], [4, 6, 24], [4, 6, 28], [4, 6, 43], [4, 6, 52], [4, 7, 6], [4, 7, 11], [4, 7, 15], [4, 7, 17], [4, 7, 24], [4, 7, 28], [4, 7, 43], [4, 7, 44], [4, 9, 25], [4, 9, 36], [4, 9, 37], [4, 9, 38], [4, 9, 42], [4, 9, 46], [4, 9, 49], [4, 9, 52], [4, 10, 1], [4, 10, 4], [4, 10, 16], [4, 10, 25], [4, 10, 29], [4, 10, 40], [4, 10, 46], [4, 10, 47], [4, 11, 1], [4, 11, 4], [4, 11, 7], [4, 11, 15], [4, 11, 16], [4, 11, 17], [4, 11, 40], [4, 11, 44], [4, 13, 6], [4, 13, 24], [4, 13, 28], [4, 13, 37], [4, 13, 42], [4, 13, 43], [4, 13, 49], [4, 13, 52], [4, 15, 6], [4, 15, 7], [4, 15, 11], [4, 15, 16], [4, 15, 17], [4, 15, 24], [4, 15, 28], [4, 15, 44], [4, 16, 1], [4, 16, 4], [4, 16, 10], [4, 16, 11], [4, 16, 15], [4, 16, 17], [4, 16, 40], [4, 16, 44], [4, 17, 4], [4, 17, 6], [4, 17, 7], [4, 17, 11], [4, 17, 15], [4, 17, 16], [4, 17, 28], [4, 17, 44], [4, 24, 6], [4, 24, 7], [4, 24, 13], [4, 24, 15], [4, 24, 28], [4, 24, 43], [4, 24, 49], [4, 24, 52], [4, 25, 9], [4, 25, 10], [4, 25, 29], [4, 25, 36], [4, 25, 38], [4, 25, 40], [4, 25, 46], [4, 25, 47], [4, 28, 6], [4, 28, 7], [4, 28, 13], [4, 28, 15], [4, 28, 17], [4, 28, 24], [4, 28, 43], [4, 28, 44], [4, 29, 1], [4, 29, 4], [4, 29, 10], [4, 29, 25], [4, 29, 38], [4, 29, 40], [4, 29, 46], [4, 29, 47], [4, 36, 9], [4, 36, 25], [4, 36, 37], [4, 36, 38], [4, 36, 42], [4, 36, 46], [4, 36, 47], [4, 36, 49], [4, 37, 9], [4, 37, 13], [4, 37, 36], [4, 37, 38], [4, 37, 42], [4, 37, 43], [4, 37, 49], [4, 37, 52], [4, 38, 9], [4, 38, 25], [4, 38, 29], [4, 38, 36], [4, 38, 37], [4, 38, 42], [4, 38, 46], [4, 38, 47], [4, 40, 1], [4, 40, 4], [4, 40, 10], [4, 40, 11], [4, 40, 16], [4, 40, 25], [4, 40, 29], [4, 40, 47], [4, 42, 9], [4, 42, 13], [4, 42, 36], [4, 42, 37], [4, 42, 38], [4, 42, 46], [4, 42, 49], [4, 42, 52], [4, 43, 6], [4, 43, 7], [4, 43, 13], [4, 43, 24], [4, 43, 28], [4, 43, 37], [4, 43, 49], [4, 43, 52], [4, 44, 1], [4, 44, 4], [4, 44, 7], [4, 44, 11], [4, 44, 15], [4, 44, 16], [4, 44, 17], [4, 44, 28], [4, 46, 9], [4, 46, 10], [4, 46, 25], [4, 46, 29], [4, 46, 36], [4, 46, 38], [4, 46, 42], [4, 46, 47], [4, 47, 1], [4, 47, 10], [4, 47, 25], [4, 47, 29], [4, 47, 36], [4, 47, 38], [4, 47, 40], [4, 47, 46], [4, 49, 9], [4, 49, 13], [4, 49, 24], [4, 49, 36], [4, 49, 37], [4, 49, 42], [4, 49, 43], [4, 49, 52], [4, 52, 6], [4, 52, 9], [4, 52, 13], [4, 52, 24], [4, 52, 37], [4, 52, 42], [4, 52, 43], [4, 52, 49], [5, 0, 5], [5, 1, 5], [5, 1, 14], [5, 1, 17], [5, 1, 19], [5, 1, 24], [5, 1, 25], [5, 1, 32], [5, 1, 42], [5, 2, 10], [5, 2, 11], [5, 2, 28], [5, 2, 31], [5, 2, 34], [5, 2, 38], [5, 2, 48], [5, 2, 50], [5, 3, 4], [5, 3, 15], [5, 3, 19], [5, 3, 20], [5, 3, 22], [5, 3, 42], [5, 3, 43], [5, 3, 51], [5, 4, 3], [5, 4, 9], [5, 4, 15], [5, 4, 20], [5, 4, 22], [5, 4, 23], [5, 4, 43], [5, 4, 47], [5, 5, 0], [5, 5, 1], [5, 5, 5], [5, 5, 14], [5, 5, 17], [5, 5, 19], [5, 5, 25], [5, 5, 32], [5, 5, 42], [5, 5, 51], [5, 6, 8], [5, 6, 30], [5, 6, 31], [5, 6, 33], [5, 6, 38], [5, 6, 40], [5, 6, 44], [5, 6, 49], [5, 7, 9], [5, 7, 12], [5, 7, 13], [5, 7, 16], [5, 7, 27], [5, 7, 29], [5, 7, 35], [5, 7, 45], [5, 8, 6], [5, 8, 18], [5, 8, 30], [5, 8, 33], [5, 8, 40], [5, 8, 41], [5, 8, 44], [5, 8, 46], [5, 9, 4], [5, 9, 7], [5, 9, 12], [5, 9, 13], [5, 9, 20], [5, 9, 23], [5, 9, 45], [5, 9, 47], [5, 10, 2], [5, 10, 11], [5, 10, 28], [5, 10, 31], [5, 10, 34], [5, 10, 38], [5, 10, 49], [5, 10, 50], [5, 11, 2], [5, 11, 10], [5, 11, 28], [5, 11, 34], [5, 11, 38], [5, 11, 48], [5, 11, 50], [5, 11, 52], [5, 12, 7], [5, 12, 9], [5, 12, 13], [5, 12, 16], [5, 12, 23], [5, 12, 27], [5, 12, 35], [5, 12, 45], [5, 13, 7], [5, 13, 9], [5, 13, 12], [5, 13, 16], [5, 13, 23], [5, 13, 35], [5, 13, 45], [5, 13, 47], [5, 14, 1], [5, 14, 5], [5, 14, 17], [5, 14, 18], [5, 14, 24], [5, 14, 26], [5, 14, 32], [5, 14, 37], [5, 15, 3], [5, 15, 4], [5, 15, 20], [5, 15, 22], [5, 15, 42], [5, 15, 43], [5, 15, 47], [5, 15, 51], [5, 16, 7], [5, 16, 12], [5, 16, 13], [5, 16, 27], [5, 16, 29], [5, 16, 35], [5, 16, 36], [5, 16, 39], [5, 17, 1], [5, 17, 5], [5, 17, 14], [5, 17, 24], [5, 17, 25], [5, 17, 26], [5, 17, 32], [5, 17, 37], [5, 18, 8], [5, 18, 14], [5, 18, 24], [5, 18, 26], [5, 18, 37], [5, 18, 40], [5, 18, 41], [5, 18, 46], [5, 19, 1], [5, 19, 3], [5, 19, 5], [5, 19, 25], [5, 19, 32], [5, 19, 42], [5, 19, 43], [5, 19, 51], [5, 20, 3], [5, 20, 4], [5, 20, 9], [5, 20, 15], [5, 20, 22], [5, 20, 23], [5, 20, 45], [5, 20, 47], [5, 21, 27], [5, 21, 28], [5, 21, 29], [5, 21, 34], [5, 21, 36], [5, 21, 39], [5, 21, 48], [5, 21, 52], [5, 22, 3], [5, 22, 4], [5, 22, 15], [5, 22, 20], [5, 22, 23], [5, 22, 43], [5, 22, 47], [5, 22, 51], [5, 23, 4], [5, 23, 9], [5, 23, 12], [5, 23, 13], [5, 23, 20], [5, 23, 22], [5, 23, 45], [5, 23, 47], [5, 24, 1], [5, 24, 14], [5, 24, 17], [5, 24, 18], [5, 24, 26], [5, 24, 32], [5, 24, 37], [5, 24, 46], [5, 25, 1], [5, 25, 5], [5, 25, 17], [5, 25, 19], [5, 25, 32], [5, 25, 42], [5, 25, 43], [5, 25, 51], [5, 26, 14], [5, 26, 17], [5, 26, 18], [5, 26, 24], [5, 26, 32], [5, 26, 37], [5, 26, 41], [5, 26, 46], [5, 27, 7], [5, 27, 12], [5, 27, 16], [5, 27, 21], [5, 27, 29], [5, 27, 35], [5, 27, 36], [5, 27, 39], [5, 28, 2], [5, 28, 10], [5, 28, 11], [5, 28, 21], [5, 28, 34], [5, 28, 36], [5, 28, 48], [5, 28, 52], [5, 29, 7], [5, 29, 16], [5, 29, 21], [5, 29, 27], [5, 29, 35], [5, 29, 36], [5, 29, 39], [5, 29, 52], [5, 30, 6], [5, 30, 8], [5, 30, 31], [5, 30, 33], [5, 30, 40], [5, 30, 41], [5, 30, 44], [5, 30, 49], [5, 31, 2], [5, 31, 6], [5, 31, 10], [5, 31, 30], [5, 31, 33], [5, 31, 38], [5, 31, 49], [5, 31, 50], [5, 32, 1], [5, 32, 5], [5, 32, 14], [5, 32, 17], [5, 32, 19], [5, 32, 24], [5, 32, 25], [5, 32, 26], [5, 33, 6], [5, 33, 8], [5, 33, 30], [5, 33, 31], [5, 33, 38], [5, 33, 44], [5, 33, 49], [5, 33, 50], [5, 34, 2], [5, 34, 10], [5, 34, 11], [5, 34, 21], [5, 34, 28], [5, 34, 48], [5, 34, 50], [5, 34, 52], [5, 35, 7], [5, 35, 12], [5, 35, 13], [5, 35, 16], [5, 35, 27], [5, 35, 29], [5, 35, 39], [5, 35, 45], [5, 36, 16], [5, 36, 21], [5, 36, 27], [5, 36, 28], [5, 36, 29], [5, 36, 39], [5, 36, 48], [5, 36, 52], [5, 37, 14], [5, 37, 17], [5, 37, 18], [5, 37, 24], [5, 37, 26], [5, 37, 40], [5, 37, 41], [5, 37, 46], [5, 38, 2], [5, 38, 6], [5, 38, 10], [5, 38, 11], [5, 38, 31], [5, 38, 33], [5, 38, 49], [5, 38, 50], [5, 39, 16], [5, 39, 21], [5, 39, 27], [5, 39, 29], [5, 39, 35], [5, 39, 36], [5, 39, 48], [5, 39, 52], [5, 40, 6], [5, 40, 8], [5, 40, 18], [5, 40, 30], [5, 40, 37], [5, 40, 41], [5, 40, 44], [5, 40, 46], [5, 41, 8], [5, 41, 18], [5, 41, 26], [5, 41, 30], [5, 41, 37], [5, 41, 40], [5, 41, 44], [5, 41, 46], [5, 42, 1], [5, 42, 3], [5, 42, 5], [5, 42, 15], [5, 42, 19], [5, 42, 25], [5, 42, 43], [5, 42, 51], [5, 43, 3], [5, 43, 4], [5, 43, 15], [5, 43, 19], [5, 43, 22], [5, 43, 25], [5, 43, 42], [5, 43, 51], [5, 44, 6], [5, 44, 8], [5, 44, 30], [5, 44, 33], [5, 44, 40], [5, 44, 41], [5, 44, 46], [5, 44, 49], [5, 45, 7], [5, 45, 9], [5, 45, 12], [5, 45, 13], [5, 45, 20], [5, 45, 23], [5, 45, 35], [5, 45, 47], [5, 46, 8], [5, 46, 18], [5, 46, 24], [5, 46, 26], [5, 46, 37], [5, 46, 40], [5, 46, 41], [5, 46, 44], [5, 47, 4], [5, 47, 9], [5, 47, 13], [5, 47, 15], [5, 47, 20], [5, 47, 22], [5, 47, 23], [5, 47, 45], [5, 48, 2], [5, 48, 11], [5, 48, 21], [5, 48, 28], [5, 48, 34], [5, 48, 36], [5, 48, 39], [5, 48, 52], [5, 49, 6], [5, 49, 10], [5, 49, 30], [5, 49, 31], [5, 49, 33], [5, 49, 38], [5, 49, 44], [5, 49, 50], [5, 50, 2], [5, 50, 10], [5, 50, 11], [5, 50, 31], [5, 50, 33], [5, 50, 34], [5, 50, 38], [5, 50, 49], [5, 51, 3], [5, 51, 5], [5, 51, 15], [5, 51, 19], [5, 51, 22], [5, 51, 25], [5, 51, 42], [5, 51, 43], [5, 52, 11], [5, 52, 21], [5, 52, 28], [5, 52, 29], [5, 52, 34], [5, 52, 36], [5, 52, 39], [5, 52, 48], [6, 0, 6], [6, 1, 4], [6, 1, 6], [6, 1, 9], [6, 1, 24], [6, 1, 28], [6, 1, 36], [6, 1, 40], [6, 1, 42], [6, 4, 1], [6, 4, 6], [6, 4, 9], [6, 4, 16], [6, 4, 24], [6, 4, 36], [6, 4, 38], [6, 4, 43], [6, 6, 0], [6, 6, 1], [6, 6, 4], [6, 6, 6], [6, 6, 9], [6, 6, 24], [6, 6, 28], [6, 6, 36], [6, 6, 38], [6, 6, 40], [6, 7, 9], [6, 7, 10], [6, 7, 15], [6, 7, 28], [6, 7, 29], [6, 7, 37], [6, 7, 40], [6, 7, 42], [6, 9, 1], [6, 9, 4], [6, 9, 6], [6, 9, 7], [6, 9, 28], [6, 9, 36], [6, 9, 40], [6, 9, 42], [6, 10, 7], [6, 10, 15], [6, 10, 28], [6, 10, 29], [6, 10, 37], [6, 10, 40], [6, 10, 42], [6, 10, 49], [6, 11, 13], [6, 11, 16], [6, 11, 25], [6, 11, 38], [6, 11, 43], [6, 11, 44], [6, 11, 46], [6, 11, 52], [6, 13, 11], [6, 13, 16], [6, 13, 25], [6, 13, 43], [6, 13, 44], [6, 13, 46], [6, 13, 47], [6, 13, 52], [6, 15, 7], [6, 15, 10], [6, 15, 17], [6, 15, 29], [6, 15, 37], [6, 15, 42], [6, 15, 47], [6, 15, 49], [6, 16, 4], [6, 16, 11], [6, 16, 13], [6, 16, 24], [6, 16, 36], [6, 16, 38], [6, 16, 43], [6, 16, 46], [6, 17, 15], [6, 17, 25], [6, 17, 29], [6, 17, 37], [6, 17, 44], [6, 17, 47], [6, 17, 49], [6, 17, 52], [6, 24, 1], [6, 24, 4], [6, 24, 6], [6, 24, 16], [6, 24, 36], [6, 24, 38], [6, 24, 43], [6, 24, 46], [6, 25, 11], [6, 25, 13], [6, 25, 17], [6, 25, 43], [6, 25, 44], [6, 25, 46], [6, 25, 47], [6, 25, 52], [6, 28, 1], [6, 28, 6], [6, 28, 7], [6, 28, 9], [6, 28, 10], [6, 28, 36], [6, 28, 40], [6, 28, 42], [6, 29, 7], [6, 29, 10], [6, 29, 15], [6, 29, 17], [6, 29, 37], [6, 29, 47], [6, 29, 49], [6, 29, 52], [6, 36, 1], [6, 36, 4], [6, 36, 6], [6, 36, 9], [6, 36, 16], [6, 36, 24], [6, 36, 28], [6, 36, 38], [6, 37, 7], [6, 37, 10], [6, 37, 15], [6, 37, 17], [6, 37, 29], [6, 37, 40], [6, 37, 42], [6, 37, 49], [6, 38, 4], [6, 38, 6], [6, 38, 11], [6, 38, 16], [6, 38, 24], [6, 38, 36], [6, 38, 43], [6, 38, 46], [6, 40, 1], [6, 40, 6], [6, 40, 7], [6, 40, 9], [6, 40, 10], [6, 40, 28], [6, 40, 37], [6, 40, 42], [6, 42, 1], [6, 42, 7], [6, 42, 9], [6, 42, 10], [6, 42, 15], [6, 42, 28], [6, 42, 37], [6, 42, 40], [6, 43, 4], [6, 43, 11], [6, 43, 13], [6, 43, 16], [6, 43, 24], [6, 43, 25], [6, 43, 38], [6, 43, 46], [6, 44, 11], [6, 44, 13], [6, 44, 17], [6, 44, 25], [6, 44, 46], [6, 44, 47], [6, 44, 49], [6, 44, 52], [6, 46, 11], [6, 46, 13], [6, 46, 16], [6, 46, 24], [6, 46, 25], [6, 46, 38], [6, 46, 43], [6, 46, 44], [6, 47, 13], [6, 47, 15], [6, 47, 17], [6, 47, 25], [6, 47, 29], [6, 47, 44], [6, 47, 49], [6, 47, 52], [6, 49, 10], [6, 49, 15], [6, 49, 17], [6, 49, 29], [6, 49, 37], [6, 49, 44], [6, 49, 47], [6, 49, 52], [6, 52, 11], [6, 52, 13], [6, 52, 17], [6, 52, 25], [6, 52, 29], [6, 52, 44], [6, 52, 47], [6, 52, 49], [7, 0, 7], [7, 1, 7], [7, 1, 10], [7, 1, 13], [7, 1, 16], [7, 1, 17], [7, 1, 25], [7, 1, 38], [7, 1, 49], [7, 4, 11], [7, 4, 15], [7, 4, 28], [7, 4, 37], [7, 4, 40], [7, 4, 46], [7, 4, 47], [7, 4, 52], [7, 6, 7], [7, 6, 16], [7, 6, 25], [7, 6, 29], [7, 6, 42], [7, 6, 43], [7, 6, 44], [7, 6, 49], [7, 7, 0], [7, 7, 1], [7, 7, 6], [7, 7, 7], [7, 7, 13], [7, 7, 16], [7, 7, 17], [7, 7, 25], [7, 7, 38], [7, 7, 49], [7, 9, 10], [7, 9, 11], [7, 9, 13], [7, 9, 17], [7, 9, 24], [7, 9, 37], [7, 9, 38], [7, 9, 47], [7, 10, 1], [7, 10, 9], [7, 10, 11], [7, 10, 13], [7, 10, 17], [7, 10, 24], [7, 10, 38], [7, 10, 47], [7, 11, 4], [7, 11, 9], [7, 11, 10], [7, 11, 17], [7, 11, 24], [7, 11, 28], [7, 11, 37], [7, 11, 47], [7, 13, 1], [7, 13, 7], [7, 13, 9], [7, 13, 10], [7, 13, 17], [7, 13, 24], [7, 13, 38], [7, 13, 49], [7, 15, 4], [7, 15, 28], [7, 15, 36], [7, 15, 40], [7, 15, 43], [7, 15, 44], [7, 15, 46], [7, 15, 52], [7, 16, 1], [7, 16, 6], [7, 16, 7], [7, 16, 25], [7, 16, 29], [7, 16, 42], [7, 16, 44], [7, 16, 49], [7, 17, 1], [7, 17, 7], [7, 17, 9], [7, 17, 10], [7, 17, 11], [7, 17, 13], [7, 17, 24], [7, 17, 38], [7, 24, 9], [7, 24, 10], [7, 24, 11], [7, 24, 13], [7, 24, 17], [7, 24, 28], [7, 24, 37], [7, 24, 47], [7, 25, 1], [7, 25, 6], [7, 25, 7], [7, 25, 16], [7, 25, 29], [7, 25, 38], [7, 25, 42], [7, 25, 49], [7, 28, 4], [7, 28, 11], [7, 28, 15], [7, 28, 24], [7, 28, 37], [7, 28, 46], [7, 28, 47], [7, 28, 52], [7, 29, 6], [7, 29, 16], [7, 29, 25], [7, 29, 36], [7, 29, 40], [7, 29, 42], [7, 29, 43], [7, 29, 44], [7, 36, 15], [7, 36, 29], [7, 36, 40], [7, 36, 42], [7, 36, 43], [7, 36, 44], [7, 36, 46], [7, 36, 52], [7, 37, 4], [7, 37, 9], [7, 37, 11], [7, 37, 24], [7, 37, 28], [7, 37, 46], [7, 37, 47], [7, 37, 52], [7, 38, 1], [7, 38, 7], [7, 38, 9], [7, 38, 10], [7, 38, 13], [7, 38, 17], [7, 38, 25], [7, 38, 49], [7, 40, 4], [7, 40, 15], [7, 40, 29], [7, 40, 36], [7, 40, 43], [7, 40, 44], [7, 40, 46], [7, 40, 52], [7, 42, 6], [7, 42, 16], [7, 42, 25], [7, 42, 29], [7, 42, 36], [7, 42, 43], [7, 42, 44], [7, 42, 49], [7, 43, 6], [7, 43, 15], [7, 43, 29], [7, 43, 36], [7, 43, 40], [7, 43, 42], [7, 43, 44], [7, 43, 52], [7, 44, 6], [7, 44, 15], [7, 44, 16], [7, 44, 29], [7, 44, 36], [7, 44, 40], [7, 44, 42], [7, 44, 43], [7, 46, 4], [7, 46, 15], [7, 46, 28], [7, 46, 36], [7, 46, 37], [7, 46, 40], [7, 46, 47], [7, 46, 52], [7, 47, 4], [7, 47, 9], [7, 47, 10], [7, 47, 11], [7, 47, 24], [7, 47, 28], [7, 47, 37], [7, 47, 46], [7, 49, 1], [7, 49, 6], [7, 49, 7], [7, 49, 13], [7, 49, 16], [7, 49, 25], [7, 49, 38], [7, 49, 42], [7, 52, 4], [7, 52, 15], [7, 52, 28], [7, 52, 36], [7, 52, 37], [7, 52, 40], [7, 52, 43], [7, 52, 46], [8, 0, 8], [8, 1, 8], [8, 1, 11], [8, 1, 15], [8, 1, 20], [8, 1, 29], [8, 1, 35], [8, 1, 46], [8, 1, 50], [8, 2, 5], [8, 2, 16], [8, 2, 17], [8, 2, 22], [8, 2, 30], [8, 2, 39], [8, 2, 40], [8, 2, 47], [8, 3, 7], [8, 3, 24], [8, 3, 32], [8, 3, 33], [8, 3, 34], [8, 3, 44], [8, 3, 45], [8, 3, 52], [8, 4, 7], [8, 4, 10], [8, 4, 25], [8, 4, 27], [8, 4, 32], [8, 4, 34], [8, 4, 41], [8, 4, 44], [8, 5, 2], [8, 5, 16], [8, 5, 18], [8, 5, 22], [8, 5, 38], [8, 5, 39], [8, 5, 40], [8, 5, 47], [8, 6, 11], [8, 6, 13], [8, 6, 14], [8, 6, 15], [8, 6, 35], [8, 6, 37], [8, 6, 48], [8, 6, 51], [8, 7, 3], [8, 7, 4], [8, 7, 24], [8, 7, 32], [8, 7, 33], [8, 7, 34], [8, 7, 44], [8, 7, 52], [8, 8, 0], [8, 8, 1], [8, 8, 8], [8, 8, 11], [8, 8, 14], [8, 8, 15], [8, 8, 20], [8, 8, 29], [8, 8, 35], [8, 8, 50], [8, 9, 19], [8, 9, 21], [8, 9, 26], [8, 9, 29], [8, 9, 43], [8, 9, 46], [8, 9, 49], [8, 9, 50], [8, 10, 4], [8, 10, 23], [8, 10, 25], [8, 10, 27], [8, 10, 32], [8, 10, 36], [8, 10, 41], [8, 10, 44], [8, 11, 1], [8, 11, 6], [8, 11, 8], [8, 11, 14], [8, 11, 15], [8, 11, 20], [8, 11, 29], [8, 11, 35], [8, 12, 17], [8, 12, 21], [8, 12, 22], [8, 12, 26], [8, 12, 28], [8, 12, 30], [8, 12, 43], [8, 12, 49], [8, 13, 6], [8, 13, 14], [8, 13, 15], [8, 13, 31], [8, 13, 36], [8, 13, 37], [8, 13, 48], [8, 13, 51], [8, 14, 6], [8, 14, 8], [8, 14, 11], [8, 14, 13], [8, 14, 15], [8, 14, 35], [8, 14, 48], [8, 14, 51], [8, 15, 1], [8, 15, 6], [8, 15, 8], [8, 15, 11], [8, 15, 13], [8, 15, 14], [8, 15, 35], [8, 15, 48], [8, 16, 2], [8, 16, 5], [8, 16, 17], [8, 16, 22], [8, 16, 28], [8, 16, 30], [8, 16, 40], [8, 16, 47], [8, 17, 2], [8, 17, 12], [8, 17, 16], [8, 17, 22], [8, 17, 28], [8, 17, 30], [8, 17, 40], [8, 17, 43], [8, 18, 5], [8, 18, 33], [8, 18, 38], [8, 18, 39], [8, 18, 42], [8, 18, 45], [8, 18, 47], [8, 18, 52], [8, 19, 9], [8, 19, 20], [8, 19, 21], [8, 19, 26], [8, 19, 29], [8, 19, 46], [8, 19, 49], [8, 19, 50], [8, 20, 1], [8, 20, 8], [8, 20, 11], [8, 20, 19], [8, 20, 29], [8, 20, 35], [8, 20, 46], [8, 20, 50], [8, 21, 9], [8, 21, 12], [8, 21, 19], [8, 21, 26], [8, 21, 43], [8, 21, 46], [8, 21, 49], [8, 21, 50], [8, 22, 2], [8, 22, 5], [8, 22, 12], [8, 22, 16], [8, 22, 17], [8, 22, 28], [8, 22, 30], [8, 22, 40], [8, 23, 10], [8, 23, 25], [8, 23, 27], [8, 23, 31], [8, 23, 36], [8, 23, 37], [8, 23, 41], [8, 23, 51], [8, 24, 3], [8, 24, 7], [8, 24, 33], [8, 24, 34], [8, 24, 42], [8, 24, 44], [8, 24, 45], [8, 24, 52], [8, 25, 4], [8, 25, 10], [8, 25, 23], [8, 25, 27], [8, 25, 31], [8, 25, 36], [8, 25, 37], [8, 25, 41], [8, 26, 9], [8, 26, 12], [8, 26, 19], [8, 26, 21], [8, 26, 28], [8, 26, 30], [8, 26, 43], [8, 26, 49], [8, 27, 4], [8, 27, 10], [8, 27, 23], [8, 27, 25], [8, 27, 32], [8, 27, 34], [8, 27, 41], [8, 27, 44], [8, 28, 12], [8, 28, 16], [8, 28, 17], [8, 28, 22], [8, 28, 26], [8, 28, 30], [8, 28, 43], [8, 28, 49], [8, 29, 1], [8, 29, 8], [8, 29, 9], [8, 29, 11], [8, 29, 19], [8, 29, 20], [8, 29, 46], [8, 29, 50], [8, 30, 2], [8, 30, 12], [8, 30, 16], [8, 30, 17], [8, 30, 22], [8, 30, 26], [8, 30, 28], [8, 30, 43], [8, 31, 13], [8, 31, 23], [8, 31, 25], [8, 31, 36], [8, 31, 37], [8, 31, 41], [8, 31, 48], [8, 31, 51], [8, 32, 3], [8, 32, 4], [8, 32, 7], [8, 32, 10], [8, 32, 27], [8, 32, 34], [8, 32, 41], [8, 32, 44], [8, 33, 3], [8, 33, 7], [8, 33, 18], [8, 33, 24], [8, 33, 34], [8, 33, 42], [8, 33, 45], [8, 33, 52], [8, 34, 3], [8, 34, 4], [8, 34, 7], [8, 34, 24], [8, 34, 27], [8, 34, 32], [8, 34, 33], [8, 34, 44], [8, 35, 1], [8, 35, 6], [8, 35, 8], [8, 35, 11], [8, 35, 14], [8, 35, 15], [8, 35, 20], [8, 35, 48], [8, 36, 10], [8, 36, 13], [8, 36, 23], [8, 36, 25], [8, 36, 31], [8, 36, 37], [8, 36, 41], [8, 36, 51], [8, 37, 6], [8, 37, 13], [8, 37, 23], [8, 37, 25], [8, 37, 31], [8, 37, 36], [8, 37, 48], [8, 37, 51], [8, 38, 5], [8, 38, 18], [8, 38, 39], [8, 38, 40], [8, 38, 42], [8, 38, 45], [8, 38, 47], [8, 38, 52], [8, 39, 2], [8, 39, 5], [8, 39, 18], [8, 39, 38], [8, 39, 40], [8, 39, 42], [8, 39, 45], [8, 39, 47], [8, 40, 2], [8, 40, 5], [8, 40, 16], [8, 40, 17], [8, 40, 22], [8, 40, 38], [8, 40, 39], [8, 40, 47], [8, 41, 4], [8, 41, 10], [8, 41, 23], [8, 41, 25], [8, 41, 27], [8, 41, 31], [8, 41, 32], [8, 41, 36], [8, 42, 18], [8, 42, 24], [8, 42, 33], [8, 42, 38], [8, 42, 39], [8, 42, 45], [8, 42, 47], [8, 42, 52], [8, 43, 9], [8, 43, 12], [8, 43, 17], [8, 43, 21], [8, 43, 26], [8, 43, 28], [8, 43, 30], [8, 43, 49], [8, 44, 3], [8, 44, 4], [8, 44, 7], [8, 44, 10], [8, 44, 24], [8, 44, 27], [8, 44, 32], [8, 44, 34], [8, 45, 3], [8, 45, 18], [8, 45, 24], [8, 45, 33], [8, 45, 38], [8, 45, 39], [8, 45, 42], [8, 45, 52], [8, 46, 1], [8, 46, 9], [8, 46, 19], [8, 46, 20], [8, 46, 21], [8, 46, 29], [8, 46, 49], [8, 46, 50], [8, 47, 2], [8, 47, 5], [8, 47, 16], [8, 47, 18], [8, 47, 38], [8, 47, 39], [8, 47, 40], [8, 47, 42], [8, 48, 6], [8, 48, 13], [8, 48, 14], [8, 48, 15], [8, 48, 31], [8, 48, 35], [8, 48, 37], [8, 48, 51], [8, 49, 9], [8, 49, 12], [8, 49, 19], [8, 49, 21], [8, 49, 26], [8, 49, 28], [8, 49, 43], [8, 49, 46], [8, 50, 1], [8, 50, 8], [8, 50, 9], [8, 50, 19], [8, 50, 20], [8, 50, 21], [8, 50, 29], [8, 50, 46], [8, 51, 6], [8, 51, 13], [8, 51, 14], [8, 51, 23], [8, 51, 31], [8, 51, 36], [8, 51, 37], [8, 51, 48], [8, 52, 3], [8, 52, 7], [8, 52, 18], [8, 52, 24], [8, 52, 33], [8, 52, 38], [8, 52, 42], [8, 52, 45], [9, 0, 9], [9, 1, 4], [9, 1, 6], [9, 1, 9], [9, 1, 24], [9, 1, 28], [9, 1, 36], [9, 1, 40], [9, 1, 42], [9, 4, 1], [9, 4, 6], [9, 4, 9], [9, 4, 16], [9, 4, 24], [9, 4, 36], [9, 4, 38], [9, 4, 43], [9, 6, 1], [9, 6, 4], [9, 6, 9], [9, 6, 24], [9, 6, 28], [9, 6, 36], [9, 6, 38], [9, 6, 40], [9, 7, 9], [9, 7, 10], [9, 7, 15], [9, 7, 28], [9, 7, 29], [9, 7, 37], [9, 7, 40], [9, 7, 42], [9, 9, 0], [9, 9, 1], [9, 9, 4], [9, 9, 6], [9, 9, 7], [9, 9, 9], [9, 9, 28], [9, 9, 36], [9, 9, 40], [9, 9, 42], [9, 10, 7], [9, 10, 15], [9, 10, 28], [9, 10, 29], [9, 10, 37], [9, 10, 40], [9, 10, 42], [9, 10, 49], [9, 11, 13], [9, 11, 16], [9, 11, 25], [9, 11, 38], [9, 11, 43], [9, 11, 44], [9, 11, 46], [9, 11, 52], [9, 13, 11], [9, 13, 16], [9, 13, 25], [9, 13, 43], [9, 13, 44], [9, 13, 46], [9, 13, 47], [9, 13, 52], [9, 15, 7], [9, 15, 10], [9, 15, 17], [9, 15, 29], [9, 15, 37], [9, 15, 42], [9, 15, 47], [9, 15, 49], [9, 16, 4], [9, 16, 11], [9, 16, 13], [9, 16, 24], [9, 16, 36], [9, 16, 38], [9, 16, 43], [9, 16, 46], [9, 17, 15], [9, 17, 25], [9, 17, 29], [9, 17, 37], [9, 17, 44], [9, 17, 47], [9, 17, 49], [9, 17, 52], [9, 24, 1], [9, 24, 4], [9, 24, 6], [9, 24, 16], [9, 24, 36], [9, 24, 38], [9, 24, 43], [9, 24, 46], [9, 25, 11], [9, 25, 13], [9, 25, 17], [9, 25, 43], [9, 25, 44], [9, 25, 46], [9, 25, 47], [9, 25, 52], [9, 28, 1], [9, 28, 6], [9, 28, 7], [9, 28, 9], [9, 28, 10], [9, 28, 36], [9, 28, 40], [9, 28, 42], [9, 29, 7], [9, 29, 10], [9, 29, 15], [9, 29, 17], [9, 29, 37], [9, 29, 47], [9, 29, 49], [9, 29, 52], [9, 36, 1], [9, 36, 4], [9, 36, 6], [9, 36, 9], [9, 36, 16], [9, 36, 24], [9, 36, 28], [9, 36, 38], [9, 37, 7], [9, 37, 10], [9, 37, 15], [9, 37, 17], [9, 37, 29], [9, 37, 40], [9, 37, 42], [9, 37, 49], [9, 38, 4], [9, 38, 6], [9, 38, 11], [9, 38, 16], [9, 38, 24], [9, 38, 36], [9, 38, 43], [9, 38, 46], [9, 40, 1], [9, 40, 6], [9, 40, 7], [9, 40, 9], [9, 40, 10], [9, 40, 28], [9, 40, 37], [9, 40, 42], [9, 42, 1], [9, 42, 7], [9, 42, 9], [9, 42, 10], [9, 42, 15], [9, 42, 28], [9, 42, 37], [9, 42, 40], [9, 43, 4], [9, 43, 11], [9, 43, 13], [9, 43, 16], [9, 43, 24], [9, 43, 25], [9, 43, 38], [9, 43, 46], [9, 44, 11], [9, 44, 13], [9, 44, 17], [9, 44, 25], [9, 44, 46], [9, 44, 47], [9, 44, 49], [9, 44, 52], [9, 46, 11], [9, 46, 13], [9, 46, 16], [9, 46, 24], [9, 46, 25], [9, 46, 38], [9, 46, 43], [9, 46, 44], [9, 47, 13], [9, 47, 15], [9, 47, 17], [9, 47, 25], [9, 47, 29], [9, 47, 44], [9, 47, 49], [9, 47, 52], [9, 49, 10], [9, 49, 15], [9, 49, 17], [9, 49, 29], [9, 49, 37], [9, 49, 44], [9, 49, 47], [9, 49, 52], [9, 52, 11], [9, 52, 13], [9, 52, 17], [9, 52, 25], [9, 52, 29], [9, 52, 44], [9, 52, 47], [9, 52, 49], [10, 0, 10], [10, 1, 10], [10, 1, 15], [10, 1, 16], [10, 1, 28], [10, 1, 36], [10, 1, 44], [10, 1, 46], [10, 1, 47], [10, 10, 0], [10, 10, 1], [10, 10, 10], [10, 10, 15], [10, 10, 16], [10, 10, 36], [10, 10, 42], [10, 10, 44], [10, 10, 46], [10, 10, 47], [10, 13, 15], [10, 13, 24], [10, 13, 28], [10, 13, 36], [10, 13, 42], [10, 13, 44], [10, 13, 46], [10, 13, 49], [10, 15, 1], [10, 15, 10], [10, 15, 13], [10, 15, 16], [10, 15, 24], [10, 15, 28], [10, 15, 44], [10, 15, 49], [10, 16, 1], [10, 16, 10], [10, 16, 15], [10, 16, 24], [10, 16, 28], [10, 16, 44], [10, 16, 46], [10, 16, 47], [10, 24, 13], [10, 24, 15], [10, 24, 16], [10, 24, 28], [10, 24, 36], [10, 24, 42], [10, 24, 44], [10, 24, 49], [10, 28, 1], [10, 28, 13], [10, 28, 15], [10, 28, 16], [10, 28, 24], [10, 28, 42], [10, 28, 44], [10, 28, 49], [10, 36, 1], [10, 36, 10], [10, 36, 13], [10, 36, 24], [10, 36, 42], [10, 36, 46], [10, 36, 47], [10, 36, 49], [10, 42, 10], [10, 42, 13], [10, 42, 24], [10, 42, 28], [10, 42, 36], [10, 42, 46], [10, 42, 47], [10, 42, 49], [10, 44, 1], [10, 44, 10], [10, 44, 13], [10, 44, 15], [10, 44, 16], [10, 44, 24], [10, 44, 28], [10, 44, 47], [10, 46, 1], [10, 46, 10], [10, 46, 13], [10, 46, 16], [10, 46, 36], [10, 46, 42], [10, 46, 47], [10, 46, 49], [10, 47, 1], [10, 47, 10], [10, 47, 16], [10, 47, 36], [10, 47, 42], [10, 47, 44], [10, 47, 46], [10, 47, 49], [10, 49, 13], [10, 49, 15], [10, 49, 24], [10, 49, 28], [10, 49, 36], [10, 49, 42], [10, 49, 46], [10, 49, 47], [11, 0, 11], [11, 1, 6], [11, 1, 9], [11, 1, 11], [11, 1, 13], [11, 1, 15], [11, 1, 29], [11, 1, 46], [11, 1, 49], [11, 4, 7], [11, 4, 10], [11, 4, 24], [11, 4, 25], [11, 4, 36], [11, 4, 37], [11, 4, 44], [11, 4, 52], [11, 6, 1], [11, 6, 11], [11, 6, 13], [11, 6, 15], [11, 6, 25], [11, 6, 29], [11, 6, 36], [11, 6, 37], [11, 7, 4], [11, 7, 10], [11, 7, 24], [11, 7, 25], [11, 7, 38], [11, 7, 42], [11, 7, 44], [11, 7, 52], [11, 9, 1], [11, 9, 11], [11, 9, 17], [11, 9, 28], [11, 9, 29], [11, 9, 43], [11, 9, 46], [11, 9, 49], [11, 10, 4], [11, 10, 7], [11, 10, 13], [11, 10, 24], [11, 10, 25], [11, 10, 36], [11, 10, 37], [11, 10, 44], [11, 11, 0], [11, 11, 1], [11, 11, 6], [11, 11, 9], [11, 11, 11], [11, 11, 13], [11, 11, 15], [11, 11, 29], [11, 11, 37], [11, 11, 46], [11, 13, 1], [11, 13, 6], [11, 13, 10], [11, 13, 11], [11, 13, 15], [11, 13, 25], [11, 13, 36], [11, 13, 37], [11, 15, 1], [11, 15, 6], [11, 15, 11], [11, 15, 13], [11, 15, 29], [11, 15, 36], [11, 15, 37], [11, 15, 46], [11, 16, 17], [11, 16, 28], [11, 16, 38], [11, 16, 40], [11, 16, 42], [11, 16, 43], [11, 16, 47], [11, 16, 49], [11, 17, 9], [11, 17, 16], [11, 17, 28], [11, 17, 38], [11, 17, 40], [11, 17, 43], [11, 17, 47], [11, 17, 49], [11, 24, 4], [11, 24, 7], [11, 24, 10], [11, 24, 38], [11, 24, 42], [11, 24, 44], [11, 24, 47], [11, 24, 52], [11, 25, 4], [11, 25, 6], [11, 25, 7], [11, 25, 10], [11, 25, 13], [11, 25, 36], [11, 25, 37], [11, 25, 44], [11, 28, 9], [11, 28, 16], [11, 28, 17], [11, 28, 40], [11, 28, 43], [11, 28, 46], [11, 28, 47], [11, 28, 49], [11, 29, 1], [11, 29, 6], [11, 29, 9], [11, 29, 11], [11, 29, 15], [11, 29, 43], [11, 29, 46], [11, 29, 49], [11, 36, 4], [11, 36, 6], [11, 36, 10], [11, 36, 13], [11, 36, 15], [11, 36, 25], [11, 36, 37], [11, 36, 44], [11, 37, 4], [11, 37, 6], [11, 37, 10], [11, 37, 11], [11, 37, 13], [11, 37, 15], [11, 37, 25], [11, 37, 36], [11, 38, 7], [11, 38, 16], [11, 38, 17], [11, 38, 24], [11, 38, 40], [11, 38, 42], [11, 38, 47], [11, 38, 52], [11, 40, 16], [11, 40, 17], [11, 40, 28], [11, 40, 38], [11, 40, 42], [11, 40, 43], [11, 40, 47], [11, 40, 52], [11, 42, 7], [11, 42, 16], [11, 42, 24], [11, 42, 38], [11, 42, 40], [11, 42, 44], [11, 42, 47], [11, 42, 52], [11, 43, 9], [11, 43, 16], [11, 43, 17], [11, 43, 28], [11, 43, 29], [11, 43, 40], [11, 43, 46], [11, 43, 49], [11, 44, 4], [11, 44, 7], [11, 44, 10], [11, 44, 24], [11, 44, 25], [11, 44, 36], [11, 44, 42], [11, 44, 52], [11, 46, 1], [11, 46, 9], [11, 46, 11], [11, 46, 15], [11, 46, 28], [11, 46, 29], [11, 46, 43], [11, 46, 49], [11, 47, 16], [11, 47, 17], [11, 47, 24], [11, 47, 28], [11, 47, 38], [11, 47, 40], [11, 47, 42], [11, 47, 52], [11, 49, 1], [11, 49, 9], [11, 49, 16], [11, 49, 17], [11, 49, 28], [11, 49, 29], [11, 49, 43], [11, 49, 46], [11, 52, 4], [11, 52, 7], [11, 52, 24], [11, 52, 38], [11, 52, 40], [11, 52, 42], [11, 52, 44], [11, 52, 47], [12, 0, 12], [12, 1, 5], [12, 1, 7], [12, 1, 12], [12, 1, 13], [12, 1, 31], [12, 1, 32], [12, 1, 38], [12, 1, 49], [12, 2, 9], [12, 2, 10], [12, 2, 11], [12, 2, 14], [12, 2, 23], [12, 2, 24], [12, 2, 26], [12, 2, 45], [12, 3, 8], [12, 3, 15], [12, 3, 21], [12, 3, 36], [12, 3, 39], [12, 3, 40], [12, 3, 41], [12, 3, 43], [12, 4, 18], [12, 4, 20], [12, 4, 22], [12, 4, 28], [12, 4, 37], [12, 4, 46], [12, 4, 48], [12, 4, 52], [12, 5, 1], [12, 5, 7], [12, 5, 12], [12, 5, 25], [12, 5, 31], [12, 5, 33], [12, 5, 35], [12, 5, 49], [12, 6, 16], [12, 6, 19], [12, 6, 25], [12, 6, 27], [12, 6, 29], [12, 6, 30], [12, 6, 33], [12, 6, 42], [12, 7, 1], [12, 7, 5], [12, 7, 12], [12, 7, 25], [12, 7, 31], [12, 7, 35], [12, 7, 38], [12, 7, 49], [12, 8, 3], [12, 8, 21], [12, 8, 36], [12, 8, 39], [12, 8, 40], [12, 8, 43], [12, 8, 44], [12, 8, 51], [12, 9, 2], [12, 9, 10], [12, 9, 11], [12, 9, 14], [12, 9, 17], [12, 9, 23], [12, 9, 24], [12, 9, 45], [12, 10, 2], [12, 10, 9], [12, 10, 13], [12, 10, 14], [12, 10, 17], [12, 10, 24], [12, 10, 45], [12, 10, 50], [12, 11, 2], [12, 11, 9], [12, 11, 23], [12, 11, 24], [12, 11, 26], [12, 11, 34], [12, 11, 37], [12, 11, 47], [12, 12, 0], [12, 12, 1], [12, 12, 5], [12, 12, 7], [12, 12, 12], [12, 12, 13], [12, 12, 31], [12, 12, 32], [12, 12, 38], [12, 12, 50], [12, 13, 1], [12, 13, 10], [12, 13, 12], [12, 13, 17], [12, 13, 32], [12, 13, 38], [12, 13, 45], [12, 13, 50], [12, 14, 2], [12, 14, 9], [12, 14, 10], [12, 14, 17], [12, 14, 23], [12, 14, 24], [12, 14, 45], [12, 14, 50], [12, 15, 3], [12, 15, 21], [12, 15, 22], [12, 15, 36], [12, 15, 40], [12, 15, 41], [12, 15, 46], [12, 15, 52], [12, 16, 6], [12, 16, 19], [12, 16, 25], [12, 16, 27], [12, 16, 33], [12, 16, 35], [12, 16, 42], [12, 16, 49], [12, 17, 9], [12, 17, 10], [12, 17, 13], [12, 17, 14], [12, 17, 32], [12, 17, 38], [12, 17, 45], [12, 17, 50], [12, 18, 4], [12, 18, 20], [12, 18, 22], [12, 18, 28], [12, 18, 34], [12, 18, 37], [12, 18, 46], [12, 18, 48], [12, 19, 6], [12, 19, 16], [12, 19, 25], [12, 19, 27], [12, 19, 30], [12, 19, 33], [12, 19, 35], [12, 19, 42], [12, 20, 4], [12, 20, 18], [12, 20, 26], [12, 20, 28], [12, 20, 34], [12, 20, 37], [12, 20, 47], [12, 20, 48], [12, 21, 3], [12, 21, 8], [12, 21, 15], [12, 21, 22], [12, 21, 36], [12, 21, 40], [12, 21, 41], [12, 21, 52], [12, 22, 4], [12, 22, 15], [12, 22, 18], [12, 22, 21], [12, 22, 41], [12, 22, 46], [12, 22, 48], [12, 22, 52], [12, 23, 2], [12, 23, 9], [12, 23, 11], [12, 23, 14], [12, 23, 24], [12, 23, 26], [12, 23, 34], [12, 23, 47], [12, 24, 2], [12, 24, 9], [12, 24, 10], [12, 24, 11], [12, 24, 14], [12, 24, 23], [12, 24, 26], [12, 24, 47], [12, 25, 5], [12, 25, 6], [12, 25, 7], [12, 25, 16], [12, 25, 19], [12, 25, 33], [12, 25, 35], [12, 25, 49], [12, 26, 2], [12, 26, 11], [12, 26, 20], [12, 26, 23], [12, 26, 24], [12, 26, 34], [12, 26, 37], [12, 26, 47], [12, 27, 6], [12, 27, 16], [12, 27, 19], [12, 27, 29], [12, 27, 30], [12, 27, 33], [12, 27, 42], [12, 27, 51], [12, 28, 4], [12, 28, 18], [12, 28, 20], [12, 28, 34], [12, 28, 37], [12, 28, 46], [12, 28, 47], [12, 28, 48], [12, 29, 6], [12, 29, 27], [12, 29, 30], [12, 29, 39], [12, 29, 42], [12, 29, 43], [12, 29, 44], [12, 29, 51], [12, 30, 6], [12, 30, 19], [12, 30, 27], [12, 30, 29], [12, 30, 39], [12, 30, 42], [12, 30, 44], [12, 30, 51], [12, 31, 1], [12, 31, 5], [12, 31, 7], [12, 31, 12], [12, 31, 32], [12, 31, 35], [12, 31, 38], [12, 31, 49], [12, 32, 1], [12, 32, 12], [12, 32, 13], [12, 32, 17], [12, 32, 31], [12, 32, 38], [12, 32, 45], [12, 32, 50], [12, 33, 5], [12, 33, 6], [12, 33, 16], [12, 33, 19], [12, 33, 25], [12, 33, 27], [12, 33, 35], [12, 33, 49], [12, 34, 11], [12, 34, 18], [12, 34, 20], [12, 34, 23], [12, 34, 26], [12, 34, 28], [12, 34, 37], [12, 34, 47], [12, 35, 5], [12, 35, 7], [12, 35, 16], [12, 35, 19], [12, 35, 25], [12, 35, 31], [12, 35, 33], [12, 35, 49], [12, 36, 3], [12, 36, 8], [12, 36, 15], [12, 36, 21], [12, 36, 39], [12, 36, 40], [12, 36, 43], [12, 36, 44], [12, 37, 4], [12, 37, 11], [12, 37, 18], [12, 37, 20], [12, 37, 26], [12, 37, 28], [12, 37, 34], [12, 37, 47], [12, 38, 1], [12, 38, 7], [12, 38, 12], [12, 38, 13], [12, 38, 17], [12, 38, 31], [12, 38, 32], [12, 38, 50], [12, 39, 3], [12, 39, 8], [12, 39, 29], [12, 39, 30], [12, 39, 36], [12, 39, 43], [12, 39, 44], [12, 39, 51], [12, 40, 3], [12, 40, 8], [12, 40, 15], [12, 40, 21], [12, 40, 36], [12, 40, 41], [12, 40, 43], [12, 40, 52], [12, 41, 3], [12, 41, 15], [12, 41, 21], [12, 41, 22], [12, 41, 40], [12, 41, 46], [12, 41, 48], [12, 41, 52], [12, 42, 6], [12, 42, 16], [12, 42, 19], [12, 42, 27], [12, 42, 29], [12, 42, 30], [12, 42, 44], [12, 42, 51], [12, 43, 3], [12, 43, 8], [12, 43, 29], [12, 43, 36], [12, 43, 39], [12, 43, 40], [12, 43, 44], [12, 43, 51], [12, 44, 8], [12, 44, 29], [12, 44, 30], [12, 44, 36], [12, 44, 39], [12, 44, 42], [12, 44, 43], [12, 44, 51], [12, 45, 2], [12, 45, 9], [12, 45, 10], [12, 45, 13], [12, 45, 14], [12, 45, 17], [12, 45, 32], [12, 45, 50], [12, 46, 4], [12, 46, 15], [12, 46, 18], [12, 46, 22], [12, 46, 28], [12, 46, 41], [12, 46, 48], [12, 46, 52], [12, 47, 11], [12, 47, 20], [12, 47, 23], [12, 47, 24], [12, 47, 26], [12, 47, 28], [12, 47, 34], [12, 47, 37], [12, 48, 4], [12, 48, 18], [12, 48, 20], [12, 48, 22], [12, 48, 28], [12, 48, 41], [12, 48, 46], [12, 48, 52], [12, 49, 1], [12, 49, 5], [12, 49, 7], [12, 49, 16], [12, 49, 25], [12, 49, 31], [12, 49, 33], [12, 49, 35], [12, 50, 10], [12, 50, 12], [12, 50, 13], [12, 50, 14], [12, 50, 17], [12, 50, 32], [12, 50, 38], [12, 50, 45], [12, 51, 8], [12, 51, 27], [12, 51, 29], [12, 51, 30], [12, 51, 39], [12, 51, 42], [12, 51, 43], [12, 51, 44], [12, 52, 4], [12, 52, 15], [12, 52, 21], [12, 52, 22], [12, 52, 40], [12, 52, 41], [12, 52, 46], [12, 52, 48], [13, 0, 13], [13, 1, 10], [13, 1, 13], [13, 1, 16], [13, 1, 24], [13, 1, 42], [13, 1, 44], [13, 1, 47], [13, 1, 49], [13, 10, 1], [13, 10, 13], [13, 10, 16], [13, 10, 24], [13, 10, 28], [13, 10, 46], [13, 10, 47], [13, 10, 49], [13, 13, 0], [13, 13, 1], [13, 13, 10], [13, 13, 13], [13, 13, 16], [13, 13, 24], [13, 13, 28], [13, 13, 42], [13, 13, 47], [13, 13, 49], [13, 15, 16], [13, 15, 24], [13, 15, 28], [13, 15, 36], [13, 15, 42], [13, 15, 44], [13, 15, 46], [13, 15, 47], [13, 16, 1], [13, 16, 10], [13, 16, 13], [13, 16, 15], [13, 16, 36], [13, 16, 42], [13, 16, 44], [13, 16, 49], [13, 24, 1], [13, 24, 10], [13, 24, 13], [13, 24, 15], [13, 24, 28], [13, 24, 46], [13, 24, 47], [13, 24, 49], [13, 28, 10], [13, 28, 13], [13, 28, 15], [13, 28, 24], [13, 28, 36], [13, 28, 44], [13, 28, 46], [13, 28, 47], [13, 36, 15], [13, 36, 16], [13, 36, 28], [13, 36, 42], [13, 36, 44], [13, 36, 46], [13, 36, 47], [13, 36, 49], [13, 42, 1], [13, 42, 13], [13, 42, 15], [13, 42, 16], [13, 42, 36], [13, 42, 44], [13, 42, 46], [13, 42, 49], [13, 44, 1], [13, 44, 15], [13, 44, 16], [13, 44, 28], [13, 44, 36], [13, 44, 42], [13, 44, 46], [13, 44, 49], [13, 46, 10], [13, 46, 15], [13, 46, 24], [13, 46, 28], [13, 46, 36], [13, 46, 42], [13, 46, 44], [13, 46, 47], [13, 47, 1], [13, 47, 10], [13, 47, 13], [13, 47, 15], [13, 47, 24], [13, 47, 28], [13, 47, 36], [13, 47, 46], [13, 49, 1], [13, 49, 10], [13, 49, 13], [13, 49, 16], [13, 49, 24], [13, 49, 36], [13, 49, 42], [13, 49, 44], [14, 0, 14], [14, 1, 14], [14, 1, 19], [14, 1, 22], [14, 1, 37], [14, 1, 41], [14, 1, 43], [14, 1, 44], [14, 1, 47], [14, 2, 21], [14, 2, 28], [14, 2, 29], [14, 2, 33], [14, 2, 35], [14, 2, 38], [14, 2, 41], [14, 2, 44], [14, 3, 4], [14, 3, 5], [14, 3, 13], [14, 3, 17], [14, 3, 23], [14, 3, 26], [14, 3, 35], [14, 3, 42], [14, 4, 3], [14, 4, 5], [14, 4, 13], [14, 4, 17], [14, 4, 23], [14, 4, 29], [14, 4, 35], [14, 4, 42], [14, 5, 3], [14, 5, 4], [14, 5, 8], [14, 5, 17], [14, 5, 23], [14, 5, 26], [14, 5, 42], [14, 5, 46], [14, 6, 8], [14, 6, 10], [14, 6, 17], [14, 6, 26], [14, 6, 31], [14, 6, 34], [14, 6, 46], [14, 6, 52], [14, 7, 11], [14, 7, 22], [14, 7, 27], [14, 7, 36], [14, 7, 43], [14, 7, 45], [14, 7, 47], [14, 7, 48], [14, 8, 5], [14, 8, 6], [14, 8, 10], [14, 8, 17], [14, 8, 26], [14, 8, 31], [14, 8, 34], [14, 8, 46], [14, 9, 12], [14, 9, 15], [14, 9, 16], [14, 9, 20], [14, 9, 25], [14, 9, 39], [14, 9, 51], [14, 9, 52], [14, 10, 6], [14, 10, 8], [14, 10, 16], [14, 10, 31], [14, 10, 34], [14, 10, 39], [14, 10, 46], [14, 10, 52], [14, 11, 7], [14, 11, 27], [14, 11, 30], [14, 11, 36], [14, 11, 40], [14, 11, 48], [14, 11, 49], [14, 11, 50], [14, 12, 9], [14, 12, 15], [14, 12, 16], [14, 12, 20], [14, 12, 34], [14, 12, 39], [14, 12, 51], [14, 12, 52], [14, 13, 3], [14, 13, 4], [14, 13, 21], [14, 13, 23], [14, 13, 28], [14, 13, 29], [14, 13, 35], [14, 13, 42], [14, 14, 0], [14, 14, 1], [14, 14, 14], [14, 14, 19], [14, 14, 22], [14, 14, 33], [14, 14, 37], [14, 14, 41], [14, 14, 43], [14, 14, 44], [14, 15, 9], [14, 15, 12], [14, 15, 16], [14, 15, 20], [14, 15, 24], [14, 15, 25], [14, 15, 32], [14, 15, 51], [14, 16, 9], [14, 16, 10], [14, 16, 12], [14, 16, 15], [14, 16, 20], [14, 16, 34], [14, 16, 39], [14, 16, 52], [14, 17, 3], [14, 17, 4], [14, 17, 5], [14, 17, 6], [14, 17, 8], [14, 17, 26], [14, 17, 42], [14, 17, 46], [14, 18, 24], [14, 18, 25], [14, 18, 30], [14, 18, 32], [14, 18, 40], [14, 18, 49], [14, 18, 50], [14, 18, 51], [14, 19, 1], [14, 19, 14], [14, 19, 22], [14, 19, 37], [14, 19, 41], [14, 19, 43], [14, 19, 45], [14, 19, 47], [14, 20, 9], [14, 20, 12], [14, 20, 15], [14, 20, 16], [14, 20, 25], [14, 20, 32], [14, 20, 39], [14, 20, 51], [14, 21, 2], [14, 21, 13], [14, 21, 23], [14, 21, 28], [14, 21, 29], [14, 21, 33], [14, 21, 35], [14, 21, 38], [14, 22, 1], [14, 22, 7], [14, 22, 14], [14, 22, 19], [14, 22, 27], [14, 22, 43], [14, 22, 45], [14, 22, 47], [14, 23, 3], [14, 23, 4], [14, 23, 5], [14, 23, 13], [14, 23, 21], [14, 23, 29], [14, 23, 35], [14, 23, 42], [14, 24, 15], [14, 24, 18], [14, 24, 25], [14, 24, 30], [14, 24, 32], [14, 24, 40], [14, 24, 49], [14, 24, 51], [14, 25, 9], [14, 25, 15], [14, 25, 18], [14, 25, 20], [14, 25, 24], [14, 25, 32], [14, 25, 40], [14, 25, 51], [14, 26, 3], [14, 26, 5], [14, 26, 6], [14, 26, 8], [14, 26, 17], [14, 26, 31], [14, 26, 42], [14, 26, 46], [14, 27, 7], [14, 27, 11], [14, 27, 22], [14, 27, 36], [14, 27, 45], [14, 27, 47], [14, 27, 48], [14, 27, 50], [14, 28, 2], [14, 28, 13], [14, 28, 21], [14, 28, 29], [14, 28, 33], [14, 28, 35], [14, 28, 38], [14, 28, 44], [14, 29, 2], [14, 29, 4], [14, 29, 13], [14, 29, 21], [14, 29, 23], [14, 29, 28], [14, 29, 35], [14, 29, 38], [14, 30, 11], [14, 30, 18], [14, 30, 24], [14, 30, 32], [14, 30, 40], [14, 30, 48], [14, 30, 49], [14, 30, 50], [14, 31, 6], [14, 31, 8], [14, 31, 10], [14, 31, 26], [14, 31, 34], [14, 31, 39], [14, 31, 46], [14, 31, 52], [14, 32, 15], [14, 32, 18], [14, 32, 20], [14, 32, 24], [14, 32, 25], [14, 32, 30], [14, 32, 40], [14, 32, 51], [14, 33, 2], [14, 33, 14], [14, 33, 21], [14, 33, 28], [14, 33, 37], [14, 33, 38], [14, 33, 41], [14, 33, 44], [14, 34, 6], [14, 34, 8], [14, 34, 10], [14, 34, 12], [14, 34, 16], [14, 34, 31], [14, 34, 39], [14, 34, 52], [14, 35, 2], [14, 35, 3], [14, 35, 4], [14, 35, 13], [14, 35, 21], [14, 35, 23], [14, 35, 28], [14, 35, 29], [14, 36, 7], [14, 36, 11], [14, 36, 27], [14, 36, 45], [14, 36, 47], [14, 36, 48], [14, 36, 49], [14, 36, 50], [14, 37, 1], [14, 37, 14], [14, 37, 19], [14, 37, 33], [14, 37, 38], [14, 37, 41], [14, 37, 43], [14, 37, 44], [14, 38, 2], [14, 38, 21], [14, 38, 28], [14, 38, 29], [14, 38, 33], [14, 38, 37], [14, 38, 41], [14, 38, 44], [14, 39, 9], [14, 39, 10], [14, 39, 12], [14, 39, 16], [14, 39, 20], [14, 39, 31], [14, 39, 34], [14, 39, 52], [14, 40, 11], [14, 40, 18], [14, 40, 24], [14, 40, 25], [14, 40, 30], [14, 40, 32], [14, 40, 49], [14, 40, 50], [14, 41, 1], [14, 41, 2], [14, 41, 14], [14, 41, 19], [14, 41, 33], [14, 41, 37], [14, 41, 38], [14, 41, 44], [14, 42, 3], [14, 42, 4], [14, 42, 5], [14, 42, 13], [14, 42, 17], [14, 42, 23], [14, 42, 26], [14, 42, 46], [14, 43, 1], [14, 43, 7], [14, 43, 14], [14, 43, 19], [14, 43, 22], [14, 43, 37], [14, 43, 45], [14, 43, 47], [14, 44, 1], [14, 44, 2], [14, 44, 14], [14, 44, 28], [14, 44, 33], [14, 44, 37], [14, 44, 38], [14, 44, 41], [14, 45, 7], [14, 45, 19], [14, 45, 22], [14, 45, 27], [14, 45, 36], [14, 45, 43], [14, 45, 47], [14, 45, 48], [14, 46, 5], [14, 46, 6], [14, 46, 8], [14, 46, 10], [14, 46, 17], [14, 46, 26], [14, 46, 31], [14, 46, 42], [14, 47, 1], [14, 47, 7], [14, 47, 19], [14, 47, 22], [14, 47, 27], [14, 47, 36], [14, 47, 43], [14, 47, 45], [14, 48, 7], [14, 48, 11], [14, 48, 27], [14, 48, 30], [14, 48, 36], [14, 48, 45], [14, 48, 49], [14, 48, 50], [14, 49, 11], [14, 49, 18], [14, 49, 24], [14, 49, 30], [14, 49, 36], [14, 49, 40], [14, 49, 48], [14, 49, 50], [14, 50, 11], [14, 50, 18], [14, 50, 27], [14, 50, 30], [14, 50, 36], [14, 50, 40], [14, 50, 48], [14, 50, 49], [14, 51, 9], [14, 51, 12], [14, 51, 15], [14, 51, 18], [14, 51, 20], [14, 51, 24], [14, 51, 25], [14, 51, 32], [14, 52, 6], [14, 52, 9], [14, 52, 10], [14, 52, 12], [14, 52, 16], [14, 52, 31], [14, 52, 34], [14, 52, 39], [15, 0, 15], [15, 1, 10], [15, 1, 13], [15, 1, 15], [15, 1, 16], [15, 1, 28], [15, 1, 36], [15, 1, 46], [15, 1, 49], [15, 10, 1], [15, 10, 13], [15, 10, 15], [15, 10, 24], [15, 10, 36], [15, 10, 42], [15, 10, 44], [15, 10, 47], [15, 13, 1], [15, 13, 10], [15, 13, 15], [15, 13, 24], [15, 13, 36], [15, 13, 44], [15, 13, 46], [15, 13, 49], [15, 15, 0], [15, 15, 1], [15, 15, 10], [15, 15, 13], [15, 15, 15], [15, 15, 28], [15, 15, 36], [15, 15, 44], [15, 15, 46], [15, 15, 49], [15, 16, 1], [15, 16, 24], [15, 16, 28], [15, 16, 42], [15, 16, 44], [15, 16, 46], [15, 16, 47], [15, 16, 49], [15, 24, 10], [15, 24, 13], [15, 24, 16], [15, 24, 28], [15, 24, 36], [15, 24, 42], [15, 24, 44], [15, 24, 47], [15, 28, 1], [15, 28, 15], [15, 28, 16], [15, 28, 24], [15, 28, 42], [15, 28, 46], [15, 28, 47], [15, 28, 49], [15, 36, 1], [15, 36, 10], [15, 36, 13], [15, 36, 15], [15, 36, 24], [15, 36, 42], [15, 36, 44], [15, 36, 46], [15, 42, 10], [15, 42, 16], [15, 42, 24], [15, 42, 28], [15, 42, 36], [15, 42, 44], [15, 42, 47], [15, 42, 49], [15, 44, 10], [15, 44, 13], [15, 44, 15], [15, 44, 16], [15, 44, 24], [15, 44, 36], [15, 44, 42], [15, 44, 47], [15, 46, 1], [15, 46, 13], [15, 46, 15], [15, 46, 16], [15, 46, 28], [15, 46, 36], [15, 46, 47], [15, 46, 49], [15, 47, 10], [15, 47, 16], [15, 47, 24], [15, 47, 28], [15, 47, 42], [15, 47, 44], [15, 47, 46], [15, 47, 49], [15, 49, 1], [15, 49, 13], [15, 49, 15], [15, 49, 16], [15, 49, 28], [15, 49, 42], [15, 49, 46], [15, 49, 47], [16, 0, 16], [16, 1, 10], [16, 1, 15], [16, 1, 16], [16, 1, 28], [16, 1, 36], [16, 1, 44], [16, 1, 46], [16, 1, 47], [16, 10, 1], [16, 10, 15], [16, 10, 16], [16, 10, 36], [16, 10, 42], [16, 10, 44], [16, 10, 46], [16, 10, 47], [16, 13, 15], [16, 13, 24], [16, 13, 28], [16, 13, 36], [16, 13, 42], [16, 13, 44], [16, 13, 46], [16, 13, 49], [16, 15, 1], [16, 15, 10], [16, 15, 13], [16, 15, 16], [16, 15, 24], [16, 15, 28], [16, 15, 44], [16, 15, 49], [16, 16, 0], [16, 16, 1], [16, 16, 10], [16, 16, 15], [16, 16, 16], [16, 16, 24], [16, 16, 28], [16, 16, 44], [16, 16, 46], [16, 16, 47], [16, 24, 13], [16, 24, 15], [16, 24, 16], [16, 24, 28], [16, 24, 36], [16, 24, 42], [16, 24, 44], [16, 24, 49], [16, 28, 1], [16, 28, 13], [16, 28, 15], [16, 28, 16], [16, 28, 24], [16, 28, 42], [16, 28, 44], [16, 28, 49], [16, 36, 1], [16, 36, 10], [16, 36, 13], [16, 36, 24], [16, 36, 42], [16, 36, 46], [16, 36, 47], [16, 36, 49], [16, 42, 10], [16, 42, 13], [16, 42, 24], [16, 42, 28], [16, 42, 36], [16, 42, 46], [16, 42, 47], [16, 42, 49], [16, 44, 1], [16, 44, 10], [16, 44, 13], [16, 44, 15], [16, 44, 16], [16, 44, 24], [16, 44, 28], [16, 44, 47], [16, 46, 1], [16, 46, 10], [16, 46, 13], [16, 46, 16], [16, 46, 36], [16, 46, 42], [16, 46, 47], [16, 46, 49], [16, 47, 1], [16, 47, 10], [16, 47, 16], [16, 47, 36], [16, 47, 42], [16, 47, 44], [16, 47, 46], [16, 47, 49], [16, 49, 13], [16, 49, 15], [16, 49, 24], [16, 49, 28], [16, 49, 36], [16, 49, 42], [16, 49, 46], [16, 49, 47], [17, 0, 17], [17, 1, 15], [17, 1, 17], [17, 1, 24], [17, 1, 25], [17, 1, 37], [17, 1, 42], [17, 1, 43], [17, 1, 46], [17, 4, 7], [17, 4, 9], [17, 4, 13], [17, 4, 15], [17, 4, 25], [17, 4, 42], [17, 4, 43], [17, 4, 47], [17, 6, 10], [17, 6, 11], [17, 6, 37], [17, 6, 38], [17, 6, 40], [17, 6, 44], [17, 6, 46], [17, 6, 49], [17, 7, 4], [17, 7, 9], [17, 7, 13], [17, 7, 16], [17, 7, 29], [17, 7, 36], [17, 7, 47], [17, 7, 52], [17, 9, 4], [17, 9, 7], [17, 9, 13], [17, 9, 15], [17, 9, 16], [17, 9, 29], [17, 9, 43], [17, 9, 47], [17, 10, 6], [17, 10, 11], [17, 10, 28], [17, 10, 36], [17, 10, 38], [17, 10, 44], [17, 10, 49], [17, 10, 52], [17, 11, 6], [17, 11, 10], [17, 11, 28], [17, 11, 29], [17, 11, 36], [17, 11, 38], [17, 11, 49], [17, 11, 52], [17, 13, 4], [17, 13, 7], [17, 13, 9], [17, 13, 15], [17, 13, 16], [17, 13, 29], [17, 13, 36], [17, 13, 47], [17, 15, 1], [17, 15, 4], [17, 15, 9], [17, 15, 13], [17, 15, 25], [17, 15, 42], [17, 15, 43], [17, 15, 47], [17, 16, 7], [17, 16, 9], [17, 16, 13], [17, 16, 28], [17, 16, 29], [17, 16, 36], [17, 16, 47], [17, 16, 52], [17, 17, 0], [17, 17, 1], [17, 17, 17], [17, 17, 24], [17, 17, 25], [17, 17, 37], [17, 17, 40], [17, 17, 42], [17, 17, 43], [17, 17, 46], [17, 24, 1], [17, 24, 17], [17, 24, 25], [17, 24, 37], [17, 24, 40], [17, 24, 42], [17, 24, 44], [17, 24, 46], [17, 25, 1], [17, 25, 4], [17, 25, 15], [17, 25, 17], [17, 25, 24], [17, 25, 37], [17, 25, 42], [17, 25, 43], [17, 28, 10], [17, 28, 11], [17, 28, 16], [17, 28, 29], [17, 28, 36], [17, 28, 38], [17, 28, 49], [17, 28, 52], [17, 29, 7], [17, 29, 9], [17, 29, 11], [17, 29, 13], [17, 29, 16], [17, 29, 28], [17, 29, 36], [17, 29, 52], [17, 36, 7], [17, 36, 10], [17, 36, 11], [17, 36, 13], [17, 36, 16], [17, 36, 28], [17, 36, 29], [17, 36, 52], [17, 37, 1], [17, 37, 6], [17, 37, 17], [17, 37, 24], [17, 37, 25], [17, 37, 40], [17, 37, 44], [17, 37, 46], [17, 38, 6], [17, 38, 10], [17, 38, 11], [17, 38, 28], [17, 38, 40], [17, 38, 44], [17, 38, 49], [17, 38, 52], [17, 40, 6], [17, 40, 17], [17, 40, 24], [17, 40, 37], [17, 40, 38], [17, 40, 44], [17, 40, 46], [17, 40, 49], [17, 42, 1], [17, 42, 4], [17, 42, 15], [17, 42, 17], [17, 42, 24], [17, 42, 25], [17, 42, 43], [17, 42, 47], [17, 43, 1], [17, 43, 4], [17, 43, 9], [17, 43, 15], [17, 43, 17], [17, 43, 25], [17, 43, 42], [17, 43, 47], [17, 44, 6], [17, 44, 10], [17, 44, 24], [17, 44, 37], [17, 44, 38], [17, 44, 40], [17, 44, 46], [17, 44, 49], [17, 46, 1], [17, 46, 6], [17, 46, 17], [17, 46, 24], [17, 46, 37], [17, 46, 40], [17, 46, 44], [17, 46, 49], [17, 47, 4], [17, 47, 7], [17, 47, 9], [17, 47, 13], [17, 47, 15], [17, 47, 16], [17, 47, 42], [17, 47, 43], [17, 49, 6], [17, 49, 10], [17, 49, 11], [17, 49, 28], [17, 49, 38], [17, 49, 40], [17, 49, 44], [17, 49, 46], [17, 52, 7], [17, 52, 10], [17, 52, 11], [17, 52, 16], [17, 52, 28], [17, 52, 29], [17, 52, 36], [17, 52, 38], [18, 0, 18], [18, 1, 2], [18, 1, 3], [18, 1, 6], [18, 1, 9], [18, 1, 18], [18, 1, 27], [18, 1, 28], [18, 1, 36], [18, 2, 1], [18, 2, 3], [18, 2, 4], [18, 2, 6], [18, 2, 12], [18, 2, 18], [18, 2, 19], [18, 2, 36], [18, 3, 1], [18, 3, 2], [18, 3, 6], [18, 3, 9], [18, 3, 18], [18, 3, 27], [18, 3, 28], [18, 3, 31], [18, 4, 2], [18, 4, 6], [18, 4, 8], [18, 4, 12], [18, 4, 19], [18, 4, 24], [18, 4, 36], [18, 4, 38], [18, 5, 10], [18, 5, 15], [18, 5, 21], [18, 5, 29], [18, 5, 30], [18, 5, 34], [18, 5, 37], [18, 5, 45], [18, 6, 1], [18, 6, 2], [18, 6, 3], [18, 6, 4], [18, 6, 9], [18, 6, 12], [18, 6, 18], [18, 6, 36], [18, 7, 10], [18, 7, 14], [18, 7, 20], [18, 7, 21], [18, 7, 30], [18, 7, 37], [18, 7, 40], [18, 7, 42], [18, 8, 4], [18, 8, 12], [18, 8, 16], [18, 8, 19], [18, 8, 23], [18, 8, 24], [18, 8, 38], [18, 8, 48], [18, 9, 1], [18, 9, 3], [18, 9, 6], [18, 9, 18], [18, 9, 27], [18, 9, 28], [18, 9, 31], [18, 9, 40], [18, 10, 5], [18, 10, 7], [18, 10, 15], [18, 10, 20], [18, 10, 21], [18, 10, 30], [18, 10, 37], [18, 10, 42], [18, 11, 13], [18, 11, 22], [18, 11, 25], [18, 11, 32], [18, 11, 33], [18, 11, 39], [18, 11, 43], [18, 11, 46], [18, 12, 2], [18, 12, 4], [18, 12, 6], [18, 12, 8], [18, 12, 18], [18, 12, 19], [18, 12, 24], [18, 12, 36], [18, 13, 11], [18, 13, 22], [18, 13, 25], [18, 13, 26], [18, 13, 33], [18, 13, 39], [18, 13, 44], [18, 13, 46], [18, 14, 7], [18, 14, 20], [18, 14, 21], [18, 14, 27], [18, 14, 28], [18, 14, 31], [18, 14, 40], [18, 14, 42], [18, 15, 5], [18, 15, 10], [18, 15, 29], [18, 15, 30], [18, 15, 34], [18, 15, 37], [18, 15, 45], [18, 15, 49], [18, 16, 8], [18, 16, 23], [18, 16, 24], [18, 16, 32], [18, 16, 38], [18, 16, 43], [18, 16, 46], [18, 16, 48], [18, 17, 29], [18, 17, 34], [18, 17, 35], [18, 17, 41], [18, 17, 47], [18, 17, 49], [18, 17, 51], [18, 17, 52], [18, 18, 0], [18, 18, 1], [18, 18, 2], [18, 18, 3], [18, 18, 6], [18, 18, 9], [18, 18, 12], [18, 18, 18], [18, 18, 27], [18, 18, 36], [18, 19, 2], [18, 19, 4], [18, 19, 8], [18, 19, 12], [18, 19, 24], [18, 19, 36], [18, 19, 38], [18, 19, 48], [18, 20, 7], [18, 20, 10], [18, 20, 14], [18, 20, 21], [18, 20, 30], [18, 20, 31], [18, 20, 40], [18, 20, 42], [18, 21, 5], [18, 21, 7], [18, 21, 10], [18, 21, 14], [18, 21, 20], [18, 21, 30], [18, 21, 37], [18, 21, 42], [18, 22, 11], [18, 22, 13], [18, 22, 25], [18, 22, 26], [18, 22, 33], [18, 22, 39], [18, 22, 44], [18, 22, 50], [18, 23, 8], [18, 23, 16], [18, 23, 32], [18, 23, 33], [18, 23, 38], [18, 23, 43], [18, 23, 46], [18, 23, 48], [18, 24, 4], [18, 24, 8], [18, 24, 12], [18, 24, 16], [18, 24, 19], [18, 24, 36], [18, 24, 38], [18, 24, 48], [18, 25, 11], [18, 25, 13], [18, 25, 22], [18, 25, 26], [18, 25, 39], [18, 25, 44], [18, 25, 50], [18, 25, 52], [18, 26, 13], [18, 26, 22], [18, 26, 25], [18, 26, 35], [18, 26, 39], [18, 26, 44], [18, 26, 50], [18, 26, 52], [18, 27, 1], [18, 27, 3], [18, 27, 9], [18, 27, 14], [18, 27, 18], [18, 27, 28], [18, 27, 31], [18, 27, 40], [18, 28, 1], [18, 28, 3], [18, 28, 9], [18, 28, 14], [18, 28, 27], [18, 28, 31], [18, 28, 40], [18, 28, 42], [18, 29, 5], [18, 29, 15], [18, 29, 17], [18, 29, 34], [18, 29, 37], [18, 29, 41], [18, 29, 45], [18, 29, 49], [18, 30, 5], [18, 30, 7], [18, 30, 10], [18, 30, 15], [18, 30, 20], [18, 30, 21], [18, 30, 37], [18, 30, 45], [18, 31, 3], [18, 31, 9], [18, 31, 14], [18, 31, 20], [18, 31, 27], [18, 31, 28], [18, 31, 40], [18, 31, 42], [18, 32, 11], [18, 32, 16], [18, 32, 23], [18, 32, 33], [18, 32, 39], [18, 32, 43], [18, 32, 46], [18, 32, 48], [18, 33, 11], [18, 33, 13], [18, 33, 22], [18, 33, 23], [18, 33, 32], [18, 33, 39], [18, 33, 43], [18, 33, 46], [18, 34, 5], [18, 34, 15], [18, 34, 17], [18, 34, 29], [18, 34, 41], [18, 34, 45], [18, 34, 49], [18, 34, 51], [18, 35, 17], [18, 35, 26], [18, 35, 41], [18, 35, 44], [18, 35, 47], [18, 35, 50], [18, 35, 51], [18, 35, 52], [18, 36, 1], [18, 36, 2], [18, 36, 4], [18, 36, 6], [18, 36, 12], [18, 36, 18], [18, 36, 19], [18, 36, 24], [18, 37, 5], [18, 37, 7], [18, 37, 10], [18, 37, 15], [18, 37, 21], [18, 37, 29], [18, 37, 30], [18, 37, 45], [18, 38, 4], [18, 38, 8], [18, 38, 16], [18, 38, 19], [18, 38, 23], [18, 38, 24], [18, 38, 43], [18, 38, 48], [18, 39, 11], [18, 39, 13], [18, 39, 22], [18, 39, 25], [18, 39, 26], [18, 39, 32], [18, 39, 33], [18, 39, 46], [18, 40, 7], [18, 40, 9], [18, 40, 14], [18, 40, 20], [18, 40, 27], [18, 40, 28], [18, 40, 31], [18, 40, 42], [18, 41, 17], [18, 41, 29], [18, 41, 34], [18, 41, 35], [18, 41, 45], [18, 41, 47], [18, 41, 49], [18, 41, 51], [18, 42, 7], [18, 42, 10], [18, 42, 14], [18, 42, 20], [18, 42, 21], [18, 42, 28], [18, 42, 31], [18, 42, 40], [18, 43, 11], [18, 43, 16], [18, 43, 23], [18, 43, 32], [18, 43, 33], [18, 43, 38], [18, 43, 46], [18, 43, 48], [18, 44, 13], [18, 44, 22], [18, 44, 25], [18, 44, 26], [18, 44, 35], [18, 44, 47], [18, 44, 50], [18, 44, 52], [18, 45, 5], [18, 45, 15], [18, 45, 29], [18, 45, 30], [18, 45, 34], [18, 45, 37], [18, 45, 41], [18, 45, 49], [18, 46, 11], [18, 46, 13], [18, 46, 16], [18, 46, 23], [18, 46, 32], [18, 46, 33], [18, 46, 39], [18, 46, 43], [18, 47, 17], [18, 47, 35], [18, 47, 41], [18, 47, 44], [18, 47, 49], [18, 47, 50], [18, 47, 51], [18, 47, 52], [18, 48, 8], [18, 48, 16], [18, 48, 19], [18, 48, 23], [18, 48, 24], [18, 48, 32], [18, 48, 38], [18, 48, 43], [18, 49, 15], [18, 49, 17], [18, 49, 29], [18, 49, 34], [18, 49, 41], [18, 49, 45], [18, 49, 47], [18, 49, 51], [18, 50, 22], [18, 50, 25], [18, 50, 26], [18, 50, 35], [18, 50, 44], [18, 50, 47], [18, 50, 51], [18, 50, 52], [18, 51, 17], [18, 51, 34], [18, 51, 35], [18, 51, 41], [18, 51, 47], [18, 51, 49], [18, 51, 50], [18, 51, 52], [18, 52, 17], [18, 52, 25], [18, 52, 26], [18, 52, 35], [18, 52, 44], [18, 52, 47], [18, 52, 50], [18, 52, 51], [19, 0, 19], [19, 1, 14], [19, 1, 19], [19, 1, 22], [19, 1, 37], [19, 1, 41], [19, 1, 43], [19, 1, 44], [19, 1, 47], [19, 2, 21], [19, 2, 28], [19, 2, 29], [19, 2, 33], [19, 2, 35], [19, 2, 38], [19, 2, 41], [19, 2, 44], [19, 3, 4], [19, 3, 5], [19, 3, 13], [19, 3, 17], [19, 3, 23], [19, 3, 26], [19, 3, 35], [19, 3, 42], [19, 4, 3], [19, 4, 5], [19, 4, 13], [19, 4, 17], [19, 4, 23], [19, 4, 29], [19, 4, 35], [19, 4, 42], [19, 5, 3], [19, 5, 4], [19, 5, 8], [19, 5, 17], [19, 5, 23], [19, 5, 26], [19, 5, 42], [19, 5, 46], [19, 6, 8], [19, 6, 10], [19, 6, 17], [19, 6, 26], [19, 6, 31], [19, 6, 34], [19, 6, 46], [19, 6, 52], [19, 7, 11], [19, 7, 22], [19, 7, 27], [19, 7, 36], [19, 7, 43], [19, 7, 45], [19, 7, 47], [19, 7, 48], [19, 8, 5], [19, 8, 6], [19, 8, 10], [19, 8, 17], [19, 8, 26], [19, 8, 31], [19, 8, 34], [19, 8, 46], [19, 9, 12], [19, 9, 15], [19, 9, 16], [19, 9, 20], [19, 9, 25], [19, 9, 39], [19, 9, 51], [19, 9, 52], [19, 10, 6], [19, 10, 8], [19, 10, 16], [19, 10, 31], [19, 10, 34], [19, 10, 39], [19, 10, 46], [19, 10, 52], [19, 11, 7], [19, 11, 27], [19, 11, 30], [19, 11, 36], [19, 11, 40], [19, 11, 48], [19, 11, 49], [19, 11, 50], [19, 12, 9], [19, 12, 15], [19, 12, 16], [19, 12, 20], [19, 12, 34], [19, 12, 39], [19, 12, 51], [19, 12, 52], [19, 13, 3], [19, 13, 4], [19, 13, 21], [19, 13, 23], [19, 13, 28], [19, 13, 29], [19, 13, 35], [19, 13, 42], [19, 14, 1], [19, 14, 19], [19, 14, 22], [19, 14, 33], [19, 14, 37], [19, 14, 41], [19, 14, 43], [19, 14, 44], [19, 15, 9], [19, 15, 12], [19, 15, 16], [19, 15, 20], [19, 15, 24], [19, 15, 25], [19, 15, 32], [19, 15, 51], [19, 16, 9], [19, 16, 10], [19, 16, 12], [19, 16, 15], [19, 16, 20], [19, 16, 34], [19, 16, 39], [19, 16, 52], [19, 17, 3], [19, 17, 4], [19, 17, 5], [19, 17, 6], [19, 17, 8], [19, 17, 26], [19, 17, 42], [19, 17, 46], [19, 18, 24], [19, 18, 25], [19, 18, 30], [19, 18, 32], [19, 18, 40], [19, 18, 49], [19, 18, 50], [19, 18, 51], [19, 19, 0], [19, 19, 1], [19, 19, 14], [19, 19, 19], [19, 19, 22], [19, 19, 37], [19, 19, 41], [19, 19, 43], [19, 19, 45], [19, 19, 47], [19, 20, 9], [19, 20, 12], [19, 20, 15], [19, 20, 16], [19, 20, 25], [19, 20, 32], [19, 20, 39], [19, 20, 51], [19, 21, 2], [19, 21, 13], [19, 21, 23], [19, 21, 28], [19, 21, 29], [19, 21, 33], [19, 21, 35], [19, 21, 38], [19, 22, 1], [19, 22, 7], [19, 22, 14], [19, 22, 19], [19, 22, 27], [19, 22, 43], [19, 22, 45], [19, 22, 47], [19, 23, 3], [19, 23, 4], [19, 23, 5], [19, 23, 13], [19, 23, 21], [19, 23, 29], [19, 23, 35], [19, 23, 42], [19, 24, 15], [19, 24, 18], [19, 24, 25], [19, 24, 30], [19, 24, 32], [19, 24, 40], [19, 24, 49], [19, 24, 51], [19, 25, 9], [19, 25, 15], [19, 25, 18], [19, 25, 20], [19, 25, 24], [19, 25, 32], [19, 25, 40], [19, 25, 51], [19, 26, 3], [19, 26, 5], [19, 26, 6], [19, 26, 8], [19, 26, 17], [19, 26, 31], [19, 26, 42], [19, 26, 46], [19, 27, 7], [19, 27, 11], [19, 27, 22], [19, 27, 36], [19, 27, 45], [19, 27, 47], [19, 27, 48], [19, 27, 50], [19, 28, 2], [19, 28, 13], [19, 28, 21], [19, 28, 29], [19, 28, 33], [19, 28, 35], [19, 28, 38], [19, 28, 44], [19, 29, 2], [19, 29, 4], [19, 29, 13], [19, 29, 21], [19, 29, 23], [19, 29, 28], [19, 29, 35], [19, 29, 38], [19, 30, 11], [19, 30, 18], [19, 30, 24], [19, 30, 32], [19, 30, 40], [19, 30, 48], [19, 30, 49], [19, 30, 50], [19, 31, 6], [19, 31, 8], [19, 31, 10], [19, 31, 26], [19, 31, 34], [19, 31, 39], [19, 31, 46], [19, 31, 52], [19, 32, 15], [19, 32, 18], [19, 32, 20], [19, 32, 24], [19, 32, 25], [19, 32, 30], [19, 32, 40], [19, 32, 51], [19, 33, 2], [19, 33, 14], [19, 33, 21], [19, 33, 28], [19, 33, 37], [19, 33, 38], [19, 33, 41], [19, 33, 44], [19, 34, 6], [19, 34, 8], [19, 34, 10], [19, 34, 12], [19, 34, 16], [19, 34, 31], [19, 34, 39], [19, 34, 52], [19, 35, 2], [19, 35, 3], [19, 35, 4], [19, 35, 13], [19, 35, 21], [19, 35, 23], [19, 35, 28], [19, 35, 29], [19, 36, 7], [19, 36, 11], [19, 36, 27], [19, 36, 45], [19, 36, 47], [19, 36, 48], [19, 36, 49], [19, 36, 50], [19, 37, 1], [19, 37, 14], [19, 37, 19], [19, 37, 33], [19, 37, 38], [19, 37, 41], [19, 37, 43], [19, 37, 44], [19, 38, 2], [19, 38, 21], [19, 38, 28], [19, 38, 29], [19, 38, 33], [19, 38, 37], [19, 38, 41], [19, 38, 44], [19, 39, 9], [19, 39, 10], [19, 39, 12], [19, 39, 16], [19, 39, 20], [19, 39, 31], [19, 39, 34], [19, 39, 52], [19, 40, 11], [19, 40, 18], [19, 40, 24], [19, 40, 25], [19, 40, 30], [19, 40, 32], [19, 40, 49], [19, 40, 50], [19, 41, 1], [19, 41, 2], [19, 41, 14], [19, 41, 19], [19, 41, 33], [19, 41, 37], [19, 41, 38], [19, 41, 44], [19, 42, 3], [19, 42, 4], [19, 42, 5], [19, 42, 13], [19, 42, 17], [19, 42, 23], [19, 42, 26], [19, 42, 46], [19, 43, 1], [19, 43, 7], [19, 43, 14], [19, 43, 19], [19, 43, 22], [19, 43, 37], [19, 43, 45], [19, 43, 47], [19, 44, 1], [19, 44, 2], [19, 44, 14], [19, 44, 28], [19, 44, 33], [19, 44, 37], [19, 44, 38], [19, 44, 41], [19, 45, 7], [19, 45, 19], [19, 45, 22], [19, 45, 27], [19, 45, 36], [19, 45, 43], [19, 45, 47], [19, 45, 48], [19, 46, 5], [19, 46, 6], [19, 46, 8], [19, 46, 10], [19, 46, 17], [19, 46, 26], [19, 46, 31], [19, 46, 42], [19, 47, 1], [19, 47, 7], [19, 47, 19], [19, 47, 22], [19, 47, 27], [19, 47, 36], [19, 47, 43], [19, 47, 45], [19, 48, 7], [19, 48, 11], [19, 48, 27], [19, 48, 30], [19, 48, 36], [19, 48, 45], [19, 48, 49], [19, 48, 50], [19, 49, 11], [19, 49, 18], [19, 49, 24], [19, 49, 30], [19, 49, 36], [19, 49, 40], [19, 49, 48], [19, 49, 50], [19, 50, 11], [19, 50, 18], [19, 50, 27], [19, 50, 30], [19, 50, 36], [19, 50, 40], [19, 50, 48], [19, 50, 49], [19, 51, 9], [19, 51, 12], [19, 51, 15], [19, 51, 18], [19, 51, 20], [19, 51, 24], [19, 51, 25], [19, 51, 32], [19, 52, 6], [19, 52, 9], [19, 52, 10], [19, 52, 12], [19, 52, 16], [19, 52, 31], [19, 52, 34], [19, 52, 39], [20, 0, 20], [20, 1, 8], [20, 1, 11], [20, 1, 15], [20, 1, 20], [20, 1, 29], [20, 1, 35], [20, 1, 46], [20, 1, 50], [20, 2, 5], [20, 2, 16], [20, 2, 17], [20, 2, 22], [20, 2, 30], [20, 2, 39], [20, 2, 40], [20, 2, 47], [20, 3, 7], [20, 3, 24], [20, 3, 32], [20, 3, 33], [20, 3, 34], [20, 3, 44], [20, 3, 45], [20, 3, 52], [20, 4, 7], [20, 4, 10], [20, 4, 25], [20, 4, 27], [20, 4, 32], [20, 4, 34], [20, 4, 41], [20, 4, 44], [20, 5, 2], [20, 5, 16], [20, 5, 18], [20, 5, 22], [20, 5, 38], [20, 5, 39], [20, 5, 40], [20, 5, 47], [20, 6, 11], [20, 6, 13], [20, 6, 14], [20, 6, 15], [20, 6, 35], [20, 6, 37], [20, 6, 48], [20, 6, 51], [20, 7, 3], [20, 7, 4], [20, 7, 24], [20, 7, 32], [20, 7, 33], [20, 7, 34], [20, 7, 44], [20, 7, 52], [20, 8, 1], [20, 8, 11], [20, 8, 14], [20, 8, 15], [20, 8, 20], [20, 8, 29], [20, 8, 35], [20, 8, 50], [20, 9, 19], [20, 9, 21], [20, 9, 26], [20, 9, 29], [20, 9, 43], [20, 9, 46], [20, 9, 49], [20, 9, 50], [20, 10, 4], [20, 10, 23], [20, 10, 25], [20, 10, 27], [20, 10, 32], [20, 10, 36], [20, 10, 41], [20, 10, 44], [20, 11, 1], [20, 11, 6], [20, 11, 8], [20, 11, 14], [20, 11, 15], [20, 11, 20], [20, 11, 29], [20, 11, 35], [20, 12, 17], [20, 12, 21], [20, 12, 22], [20, 12, 26], [20, 12, 28], [20, 12, 30], [20, 12, 43], [20, 12, 49], [20, 13, 6], [20, 13, 14], [20, 13, 15], [20, 13, 31], [20, 13, 36], [20, 13, 37], [20, 13, 48], [20, 13, 51], [20, 14, 6], [20, 14, 8], [20, 14, 11], [20, 14, 13], [20, 14, 15], [20, 14, 35], [20, 14, 48], [20, 14, 51], [20, 15, 1], [20, 15, 6], [20, 15, 8], [20, 15, 11], [20, 15, 13], [20, 15, 14], [20, 15, 35], [20, 15, 48], [20, 16, 2], [20, 16, 5], [20, 16, 17], [20, 16, 22], [20, 16, 28], [20, 16, 30], [20, 16, 40], [20, 16, 47], [20, 17, 2], [20, 17, 12], [20, 17, 16], [20, 17, 22], [20, 17, 28], [20, 17, 30], [20, 17, 40], [20, 17, 43], [20, 18, 5], [20, 18, 33], [20, 18, 38], [20, 18, 39], [20, 18, 42], [20, 18, 45], [20, 18, 47], [20, 18, 52], [20, 19, 9], [20, 19, 20], [20, 19, 21], [20, 19, 26], [20, 19, 29], [20, 19, 46], [20, 19, 49], [20, 19, 50], [20, 20, 0], [20, 20, 1], [20, 20, 8], [20, 20, 11], [20, 20, 19], [20, 20, 20], [20, 20, 29], [20, 20, 35], [20, 20, 46], [20, 20, 50], [20, 21, 9], [20, 21, 12], [20, 21, 19], [20, 21, 26], [20, 21, 43], [20, 21, 46], [20, 21, 49], [20, 21, 50], [20, 22, 2], [20, 22, 5], [20, 22, 12], [20, 22, 16], [20, 22, 17], [20, 22, 28], [20, 22, 30], [20, 22, 40], [20, 23, 10], [20, 23, 25], [20, 23, 27], [20, 23, 31], [20, 23, 36], [20, 23, 37], [20, 23, 41], [20, 23, 51], [20, 24, 3], [20, 24, 7], [20, 24, 33], [20, 24, 34], [20, 24, 42], [20, 24, 44], [20, 24, 45], [20, 24, 52], [20, 25, 4], [20, 25, 10], [20, 25, 23], [20, 25, 27], [20, 25, 31], [20, 25, 36], [20, 25, 37], [20, 25, 41], [20, 26, 9], [20, 26, 12], [20, 26, 19], [20, 26, 21], [20, 26, 28], [20, 26, 30], [20, 26, 43], [20, 26, 49], [20, 27, 4], [20, 27, 10], [20, 27, 23], [20, 27, 25], [20, 27, 32], [20, 27, 34], [20, 27, 41], [20, 27, 44], [20, 28, 12], [20, 28, 16], [20, 28, 17], [20, 28, 22], [20, 28, 26], [20, 28, 30], [20, 28, 43], [20, 28, 49], [20, 29, 1], [20, 29, 8], [20, 29, 9], [20, 29, 11], [20, 29, 19], [20, 29, 20], [20, 29, 46], [20, 29, 50], [20, 30, 2], [20, 30, 12], [20, 30, 16], [20, 30, 17], [20, 30, 22], [20, 30, 26], [20, 30, 28], [20, 30, 43], [20, 31, 13], [20, 31, 23], [20, 31, 25], [20, 31, 36], [20, 31, 37], [20, 31, 41], [20, 31, 48], [20, 31, 51], [20, 32, 3], [20, 32, 4], [20, 32, 7], [20, 32, 10], [20, 32, 27], [20, 32, 34], [20, 32, 41], [20, 32, 44], [20, 33, 3], [20, 33, 7], [20, 33, 18], [20, 33, 24], [20, 33, 34], [20, 33, 42], [20, 33, 45], [20, 33, 52], [20, 34, 3], [20, 34, 4], [20, 34, 7], [20, 34, 24], [20, 34, 27], [20, 34, 32], [20, 34, 33], [20, 34, 44], [20, 35, 1], [20, 35, 6], [20, 35, 8], [20, 35, 11], [20, 35, 14], [20, 35, 15], [20, 35, 20], [20, 35, 48], [20, 36, 10], [20, 36, 13], [20, 36, 23], [20, 36, 25], [20, 36, 31], [20, 36, 37], [20, 36, 41], [20, 36, 51], [20, 37, 6], [20, 37, 13], [20, 37, 23], [20, 37, 25], [20, 37, 31], [20, 37, 36], [20, 37, 48], [20, 37, 51], [20, 38, 5], [20, 38, 18], [20, 38, 39], [20, 38, 40], [20, 38, 42], [20, 38, 45], [20, 38, 47], [20, 38, 52], [20, 39, 2], [20, 39, 5], [20, 39, 18], [20, 39, 38], [20, 39, 40], [20, 39, 42], [20, 39, 45], [20, 39, 47], [20, 40, 2], [20, 40, 5], [20, 40, 16], [20, 40, 17], [20, 40, 22], [20, 40, 38], [20, 40, 39], [20, 40, 47], [20, 41, 4], [20, 41, 10], [20, 41, 23], [20, 41, 25], [20, 41, 27], [20, 41, 31], [20, 41, 32], [20, 41, 36], [20, 42, 18], [20, 42, 24], [20, 42, 33], [20, 42, 38], [20, 42, 39], [20, 42, 45], [20, 42, 47], [20, 42, 52], [20, 43, 9], [20, 43, 12], [20, 43, 17], [20, 43, 21], [20, 43, 26], [20, 43, 28], [20, 43, 30], [20, 43, 49], [20, 44, 3], [20, 44, 4], [20, 44, 7], [20, 44, 10], [20, 44, 24], [20, 44, 27], [20, 44, 32], [20, 44, 34], [20, 45, 3], [20, 45, 18], [20, 45, 24], [20, 45, 33], [20, 45, 38], [20, 45, 39], [20, 45, 42], [20, 45, 52], [20, 46, 1], [20, 46, 9], [20, 46, 19], [20, 46, 20], [20, 46, 21], [20, 46, 29], [20, 46, 49], [20, 46, 50], [20, 47, 2], [20, 47, 5], [20, 47, 16], [20, 47, 18], [20, 47, 38], [20, 47, 39], [20, 47, 40], [20, 47, 42], [20, 48, 6], [20, 48, 13], [20, 48, 14], [20, 48, 15], [20, 48, 31], [20, 48, 35], [20, 48, 37], [20, 48, 51], [20, 49, 9], [20, 49, 12], [20, 49, 19], [20, 49, 21], [20, 49, 26], [20, 49, 28], [20, 49, 43], [20, 49, 46], [20, 50, 1], [20, 50, 8], [20, 50, 9], [20, 50, 19], [20, 50, 20], [20, 50, 21], [20, 50, 29], [20, 50, 46], [20, 51, 6], [20, 51, 13], [20, 51, 14], [20, 51, 23], [20, 51, 31], [20, 51, 36], [20, 51, 37], [20, 51, 48], [20, 52, 3], [20, 52, 7], [20, 52, 18], [20, 52, 24], [20, 52, 33], [20, 52, 38], [20, 52, 42], [20, 52, 45], [21, 0, 21], [21, 1, 17], [21, 1, 21], [21, 1, 24], [21, 1, 25], [21, 1, 34], [21, 1, 39], [21, 1, 42], [21, 1, 48], [21, 2, 15], [21, 2, 25], [21, 2, 31], [21, 2, 34], [21, 2, 42], [21, 2, 43], [21, 2, 48], [21, 2, 50], [21, 3, 10], [21, 3, 11], [21, 3, 19], [21, 3, 20], [21, 3, 22], [21, 3, 38], [21, 3, 49], [21, 3, 51], [21, 4, 9], [21, 4, 15], [21, 4, 30], [21, 4, 31], [21, 4, 33], [21, 4, 43], [21, 4, 47], [21, 4, 50], [21, 5, 11], [21, 5, 14], [21, 5, 19], [21, 5, 28], [21, 5, 32], [21, 5, 36], [21, 5, 51], [21, 5, 52], [21, 6, 20], [21, 6, 22], [21, 6, 23], [21, 6, 38], [21, 6, 40], [21, 6, 44], [21, 6, 45], [21, 6, 49], [21, 7, 8], [21, 7, 9], [21, 7, 13], [21, 7, 16], [21, 7, 18], [21, 7, 26], [21, 7, 29], [21, 7, 41], [21, 8, 7], [21, 8, 9], [21, 8, 13], [21, 8, 18], [21, 8, 30], [21, 8, 33], [21, 8, 41], [21, 8, 47], [21, 9, 4], [21, 9, 7], [21, 9, 8], [21, 9, 13], [21, 9, 30], [21, 9, 33], [21, 9, 41], [21, 9, 47], [21, 10, 3], [21, 10, 11], [21, 10, 19], [21, 10, 22], [21, 10, 28], [21, 10, 38], [21, 10, 49], [21, 10, 51], [21, 11, 3], [21, 11, 5], [21, 11, 10], [21, 11, 19], [21, 11, 28], [21, 11, 38], [21, 11, 51], [21, 11, 52], [21, 12, 23], [21, 12, 27], [21, 12, 35], [21, 12, 37], [21, 12, 40], [21, 12, 44], [21, 12, 45], [21, 12, 46], [21, 13, 7], [21, 13, 8], [21, 13, 9], [21, 13, 16], [21, 13, 18], [21, 13, 30], [21, 13, 41], [21, 13, 47], [21, 14, 5], [21, 14, 16], [21, 14, 18], [21, 14, 26], [21, 14, 29], [21, 14, 32], [21, 14, 36], [21, 14, 52], [21, 15, 2], [21, 15, 4], [21, 15, 31], [21, 15, 33], [21, 15, 42], [21, 15, 43], [21, 15, 47], [21, 15, 50], [21, 16, 7], [21, 16, 13], [21, 16, 14], [21, 16, 18], [21, 16, 26], [21, 16, 29], [21, 16, 36], [21, 16, 41], [21, 17, 1], [21, 17, 21], [21, 17, 24], [21, 17, 25], [21, 17, 27], [21, 17, 37], [21, 17, 39], [21, 17, 48], [21, 18, 7], [21, 18, 8], [21, 18, 13], [21, 18, 14], [21, 18, 16], [21, 18, 26], [21, 18, 29], [21, 18, 41], [21, 19, 3], [21, 19, 5], [21, 19, 10], [21, 19, 11], [21, 19, 28], [21, 19, 32], [21, 19, 51], [21, 19, 52], [21, 20, 3], [21, 20, 6], [21, 20, 22], [21, 20, 23], [21, 20, 38], [21, 20, 44], [21, 20, 45], [21, 20, 49], [21, 21, 0], [21, 21, 1], [21, 21, 17], [21, 21, 21], [21, 21, 24], [21, 21, 25], [21, 21, 27], [21, 21, 34], [21, 21, 39], [21, 21, 48], [21, 22, 3], [21, 22, 6], [21, 22, 10], [21, 22, 20], [21, 22, 23], [21, 22, 38], [21, 22, 49], [21, 22, 51], [21, 23, 6], [21, 23, 12], [21, 23, 20], [21, 23, 22], [21, 23, 40], [21, 23, 44], [21, 23, 45], [21, 23, 49], [21, 24, 1], [21, 24, 17], [21, 24, 21], [21, 24, 27], [21, 24, 35], [21, 24, 37], [21, 24, 39], [21, 24, 46], [21, 25, 1], [21, 25, 2], [21, 25, 17], [21, 25, 21], [21, 25, 34], [21, 25, 42], [21, 25, 43], [21, 25, 48], [21, 26, 7], [21, 26, 14], [21, 26, 16], [21, 26, 18], [21, 26, 29], [21, 26, 32], [21, 26, 36], [21, 26, 41], [21, 27, 12], [21, 27, 17], [21, 27, 21], [21, 27, 24], [21, 27, 35], [21, 27, 37], [21, 27, 39], [21, 27, 46], [21, 28, 5], [21, 28, 10], [21, 28, 11], [21, 28, 19], [21, 28, 32], [21, 28, 36], [21, 28, 51], [21, 28, 52], [21, 29, 7], [21, 29, 14], [21, 29, 16], [21, 29, 18], [21, 29, 26], [21, 29, 32], [21, 29, 36], [21, 29, 52], [21, 30, 4], [21, 30, 8], [21, 30, 9], [21, 30, 13], [21, 30, 31], [21, 30, 33], [21, 30, 41], [21, 30, 47], [21, 31, 2], [21, 31, 4], [21, 31, 15], [21, 31, 30], [21, 31, 33], [21, 31, 43], [21, 31, 47], [21, 31, 50], [21, 32, 5], [21, 32, 14], [21, 32, 19], [21, 32, 26], [21, 32, 28], [21, 32, 29], [21, 32, 36], [21, 32, 52], [21, 33, 4], [21, 33, 8], [21, 33, 9], [21, 33, 15], [21, 33, 30], [21, 33, 31], [21, 33, 47], [21, 33, 50], [21, 34, 1], [21, 34, 2], [21, 34, 21], [21, 34, 25], [21, 34, 42], [21, 34, 43], [21, 34, 48], [21, 34, 50], [21, 35, 12], [21, 35, 24], [21, 35, 27], [21, 35, 37], [21, 35, 39], [21, 35, 40], [21, 35, 45], [21, 35, 46], [21, 36, 5], [21, 36, 14], [21, 36, 16], [21, 36, 26], [21, 36, 28], [21, 36, 29], [21, 36, 32], [21, 36, 52], [21, 37, 12], [21, 37, 17], [21, 37, 24], [21, 37, 27], [21, 37, 35], [21, 37, 39], [21, 37, 40], [21, 37, 46], [21, 38, 3], [21, 38, 6], [21, 38, 10], [21, 38, 11], [21, 38, 20], [21, 38, 22], [21, 38, 49], [21, 38, 51], [21, 39, 1], [21, 39, 17], [21, 39, 21], [21, 39, 24], [21, 39, 27], [21, 39, 35], [21, 39, 37], [21, 39, 48], [21, 40, 6], [21, 40, 12], [21, 40, 23], [21, 40, 35], [21, 40, 37], [21, 40, 44], [21, 40, 45], [21, 40, 46], [21, 41, 7], [21, 41, 8], [21, 41, 9], [21, 41, 13], [21, 41, 16], [21, 41, 18], [21, 41, 26], [21, 41, 30], [21, 42, 1], [21, 42, 2], [21, 42, 15], [21, 42, 25], [21, 42, 34], [21, 42, 43], [21, 42, 48], [21, 42, 50], [21, 43, 2], [21, 43, 4], [21, 43, 15], [21, 43, 25], [21, 43, 31], [21, 43, 34], [21, 43, 42], [21, 43, 50], [21, 44, 6], [21, 44, 12], [21, 44, 20], [21, 44, 23], [21, 44, 40], [21, 44, 45], [21, 44, 46], [21, 44, 49], [21, 45, 6], [21, 45, 12], [21, 45, 20], [21, 45, 23], [21, 45, 35], [21, 45, 40], [21, 45, 44], [21, 45, 46], [21, 46, 12], [21, 46, 24], [21, 46, 27], [21, 46, 35], [21, 46, 37], [21, 46, 40], [21, 46, 44], [21, 46, 45], [21, 47, 4], [21, 47, 8], [21, 47, 9], [21, 47, 13], [21, 47, 15], [21, 47, 30], [21, 47, 31], [21, 47, 33], [21, 48, 1], [21, 48, 2], [21, 48, 17], [21, 48, 21], [21, 48, 25], [21, 48, 34], [21, 48, 39], [21, 48, 42], [21, 49, 3], [21, 49, 6], [21, 49, 10], [21, 49, 20], [21, 49, 22], [21, 49, 23], [21, 49, 38], [21, 49, 44], [21, 50, 2], [21, 50, 4], [21, 50, 15], [21, 50, 31], [21, 50, 33], [21, 50, 34], [21, 50, 42], [21, 50, 43], [21, 51, 3], [21, 51, 5], [21, 51, 10], [21, 51, 11], [21, 51, 19], [21, 51, 22], [21, 51, 28], [21, 51, 38], [21, 52, 5], [21, 52, 11], [21, 52, 14], [21, 52, 19], [21, 52, 28], [21, 52, 29], [21, 52, 32], [21, 52, 36], [22, 0, 22], [22, 1, 7], [22, 1, 13], [22, 1, 21], [22, 1, 22], [22, 1, 38], [22, 1, 41], [22, 1, 48], [22, 1, 49], [22, 2, 14], [22, 2, 23], [22, 2, 26], [22, 2, 29], [22, 2, 42], [22, 2, 43], [22, 2, 44], [22, 2, 45], [22, 3, 8], [22, 3, 10], [22, 3, 13], [22, 3, 17], [22, 3, 21], [22, 3, 38], [22, 3, 39], [22, 3, 41], [22, 4, 5], [22, 4, 28], [22, 4, 31], [22, 4, 33], [22, 4, 35], [22, 4, 37], [22, 4, 46], [22, 4, 52], [22, 5, 4], [22, 5, 12], [22, 5, 28], [22, 5, 31], [22, 5, 33], [22, 5, 35], [22, 5, 46], [22, 5, 52], [22, 6, 16], [22, 6, 20], [22, 6, 23], [22, 6, 25], [22, 6, 26], [22, 6, 29], [22, 6, 34], [22, 6, 42], [22, 7, 1], [22, 7, 18], [22, 7, 22], [22, 7, 25], [22, 7, 38], [22, 7, 41], [22, 7, 48], [22, 7, 49], [22, 8, 3], [22, 8, 9], [22, 8, 10], [22, 8, 13], [22, 8, 17], [22, 8, 21], [22, 8, 39], [22, 8, 51], [22, 9, 8], [22, 9, 10], [22, 9, 11], [22, 9, 17], [22, 9, 24], [22, 9, 30], [22, 9, 39], [22, 9, 51], [22, 10, 3], [22, 10, 8], [22, 10, 9], [22, 10, 13], [22, 10, 17], [22, 10, 24], [22, 10, 39], [22, 10, 51], [22, 11, 9], [22, 11, 19], [22, 11, 24], [22, 11, 27], [22, 11, 30], [22, 11, 37], [22, 11, 47], [22, 11, 51], [22, 12, 5], [22, 12, 15], [22, 12, 31], [22, 12, 32], [22, 12, 40], [22, 12, 46], [22, 12, 50], [22, 12, 52], [22, 13, 1], [22, 13, 3], [22, 13, 8], [22, 13, 10], [22, 13, 17], [22, 13, 21], [22, 13, 38], [22, 13, 41], [22, 14, 2], [22, 14, 23], [22, 14, 29], [22, 14, 36], [22, 14, 43], [22, 14, 44], [22, 14, 45], [22, 14, 50], [22, 15, 12], [22, 15, 31], [22, 15, 32], [22, 15, 36], [22, 15, 40], [22, 15, 46], [22, 15, 50], [22, 15, 52], [22, 16, 6], [22, 16, 18], [22, 16, 20], [22, 16, 25], [22, 16, 26], [22, 16, 34], [22, 16, 42], [22, 16, 49], [22, 17, 3], [22, 17, 8], [22, 17, 9], [22, 17, 10], [22, 17, 13], [22, 17, 21], [22, 17, 38], [22, 17, 39], [22, 18, 7], [22, 18, 16], [22, 18, 20], [22, 18, 22], [22, 18, 25], [22, 18, 34], [22, 18, 48], [22, 18, 49], [22, 19, 11], [22, 19, 27], [22, 19, 28], [22, 19, 30], [22, 19, 33], [22, 19, 35], [22, 19, 37], [22, 19, 47], [22, 20, 6], [22, 20, 16], [22, 20, 18], [22, 20, 25], [22, 20, 26], [22, 20, 34], [22, 20, 48], [22, 20, 49], [22, 21, 1], [22, 21, 3], [22, 21, 8], [22, 21, 13], [22, 21, 17], [22, 21, 22], [22, 21, 38], [22, 21, 41], [22, 22, 0], [22, 22, 1], [22, 22, 7], [22, 22, 18], [22, 22, 21], [22, 22, 22], [22, 22, 38], [22, 22, 41], [22, 22, 48], [22, 22, 49], [22, 23, 2], [22, 23, 6], [22, 23, 14], [22, 23, 26], [22, 23, 29], [22, 23, 34], [22, 23, 42], [22, 23, 44], [22, 24, 9], [22, 24, 10], [22, 24, 11], [22, 24, 27], [22, 24, 30], [22, 24, 39], [22, 24, 47], [22, 24, 51], [22, 25, 6], [22, 25, 7], [22, 25, 16], [22, 25, 18], [22, 25, 20], [22, 25, 34], [22, 25, 48], [22, 25, 49], [22, 26, 2], [22, 26, 6], [22, 26, 16], [22, 26, 20], [22, 26, 23], [22, 26, 29], [22, 26, 34], [22, 26, 42], [22, 27, 11], [22, 27, 19], [22, 27, 24], [22, 27, 30], [22, 27, 33], [22, 27, 37], [22, 27, 47], [22, 27, 51], [22, 28, 4], [22, 28, 5], [22, 28, 19], [22, 28, 33], [22, 28, 35], [22, 28, 37], [22, 28, 46], [22, 28, 47], [22, 29, 2], [22, 29, 6], [22, 29, 14], [22, 29, 23], [22, 29, 26], [22, 29, 42], [22, 29, 43], [22, 29, 44], [22, 30, 9], [22, 30, 11], [22, 30, 19], [22, 30, 24], [22, 30, 27], [22, 30, 39], [22, 30, 47], [22, 30, 51], [22, 31, 4], [22, 31, 5], [22, 31, 12], [22, 31, 15], [22, 31, 32], [22, 31, 35], [22, 31, 46], [22, 31, 52], [22, 32, 12], [22, 32, 15], [22, 32, 31], [22, 32, 36], [22, 32, 40], [22, 32, 45], [22, 32, 50], [22, 32, 52], [22, 33, 4], [22, 33, 5], [22, 33, 19], [22, 33, 27], [22, 33, 28], [22, 33, 35], [22, 33, 37], [22, 33, 47], [22, 34, 6], [22, 34, 16], [22, 34, 18], [22, 34, 20], [22, 34, 23], [22, 34, 25], [22, 34, 26], [22, 34, 42], [22, 35, 4], [22, 35, 5], [22, 35, 19], [22, 35, 28], [22, 35, 31], [22, 35, 33], [22, 35, 37], [22, 35, 46], [22, 36, 14], [22, 36, 15], [22, 36, 32], [22, 36, 40], [22, 36, 43], [22, 36, 44], [22, 36, 45], [22, 36, 50], [22, 37, 4], [22, 37, 11], [22, 37, 19], [22, 37, 27], [22, 37, 28], [22, 37, 33], [22, 37, 35], [22, 37, 47], [22, 38, 1], [22, 38, 3], [22, 38, 7], [22, 38, 13], [22, 38, 17], [22, 38, 21], [22, 38, 22], [22, 38, 41], [22, 39, 3], [22, 39, 8], [22, 39, 9], [22, 39, 10], [22, 39, 17], [22, 39, 24], [22, 39, 30], [22, 39, 51], [22, 40, 12], [22, 40, 15], [22, 40, 32], [22, 40, 36], [22, 40, 43], [22, 40, 45], [22, 40, 50], [22, 40, 52], [22, 41, 1], [22, 41, 3], [22, 41, 7], [22, 41, 13], [22, 41, 21], [22, 41, 22], [22, 41, 38], [22, 41, 48], [22, 42, 2], [22, 42, 6], [22, 42, 16], [22, 42, 23], [22, 42, 26], [22, 42, 29], [22, 42, 34], [22, 42, 44], [22, 43, 2], [22, 43, 14], [22, 43, 29], [22, 43, 36], [22, 43, 40], [22, 43, 44], [22, 43, 45], [22, 43, 50], [22, 44, 2], [22, 44, 14], [22, 44, 23], [22, 44, 29], [22, 44, 36], [22, 44, 42], [22, 44, 43], [22, 44, 45], [22, 45, 2], [22, 45, 14], [22, 45, 32], [22, 45, 36], [22, 45, 40], [22, 45, 43], [22, 45, 44], [22, 45, 50], [22, 46, 4], [22, 46, 5], [22, 46, 12], [22, 46, 15], [22, 46, 28], [22, 46, 31], [22, 46, 35], [22, 46, 52], [22, 47, 11], [22, 47, 19], [22, 47, 24], [22, 47, 27], [22, 47, 28], [22, 47, 30], [22, 47, 33], [22, 47, 37], [22, 48, 1], [22, 48, 7], [22, 48, 18], [22, 48, 20], [22, 48, 22], [22, 48, 25], [22, 48, 41], [22, 48, 49], [22, 49, 1], [22, 49, 7], [22, 49, 16], [22, 49, 18], [22, 49, 20], [22, 49, 22], [22, 49, 25], [22, 49, 48], [22, 50, 12], [22, 50, 14], [22, 50, 15], [22, 50, 32], [22, 50, 36], [22, 50, 40], [22, 50, 43], [22, 50, 45], [22, 51, 8], [22, 51, 9], [22, 51, 10], [22, 51, 11], [22, 51, 24], [22, 51, 27], [22, 51, 30], [22, 51, 39], [22, 52, 4], [22, 52, 5], [22, 52, 12], [22, 52, 15], [22, 52, 31], [22, 52, 32], [22, 52, 40], [22, 52, 46], [23, 0, 23], [23, 1, 1], [23, 1, 23], [23, 1, 30], [23, 1, 52], [23, 23, 0], [23, 23, 1], [23, 23, 23], [23, 23, 30], [23, 23, 52], [23, 30, 1], [23, 30, 23], [23, 30, 30], [23, 30, 52], [23, 52, 1], [23, 52, 23], [23, 52, 30], [23, 52, 52], [24, 0, 24], [24, 1, 13], [24, 1, 15], [24, 1, 24], [24, 1, 42], [24, 1, 44], [24, 1, 46], [24, 1, 47], [24, 1, 49], [24, 10, 13], [24, 10, 16], [24, 10, 24], [24, 10, 28], [24, 10, 36], [24, 10, 44], [24, 10, 46], [24, 10, 49], [24, 13, 1], [24, 13, 10], [24, 13, 15], [24, 13, 16], [24, 13, 28], [24, 13, 36], [24, 13, 42], [24, 13, 47], [24, 15, 1], [24, 15, 13], [24, 15, 16], [24, 15, 24], [24, 15, 36], [24, 15, 42], [24, 15, 46], [24, 15, 47], [24, 16, 10], [24, 16, 13], [24, 16, 15], [24, 16, 28], [24, 16, 36], [24, 16, 42], [24, 16, 47], [24, 16, 49], [24, 24, 0], [24, 24, 1], [24, 24, 10], [24, 24, 15], [24, 24, 24], [24, 24, 42], [24, 24, 44], [24, 24, 46], [24, 24, 47], [24, 24, 49], [24, 28, 10], [24, 28, 13], [24, 28, 16], [24, 28, 36], [24, 28, 44], [24, 28, 46], [24, 28, 47], [24, 28, 49], [24, 36, 10], [24, 36, 13], [24, 36, 15], [24, 36, 16], [24, 36, 28], [24, 36, 44], [24, 36, 47], [24, 36, 49], [24, 42, 1], [24, 42, 13], [24, 42, 15], [24, 42, 16], [24, 42, 24], [24, 42, 44], [24, 42, 46], [24, 42, 47], [24, 44, 1], [24, 44, 10], [24, 44, 24], [24, 44, 28], [24, 44, 36], [24, 44, 42], [24, 44, 46], [24, 44, 49], [24, 46, 1], [24, 46, 10], [24, 46, 15], [24, 46, 24], [24, 46, 28], [24, 46, 42], [24, 46, 44], [24, 46, 49], [24, 47, 1], [24, 47, 13], [24, 47, 15], [24, 47, 16], [24, 47, 24], [24, 47, 28], [24, 47, 36], [24, 47, 42], [24, 49, 1], [24, 49, 10], [24, 49, 16], [24, 49, 24], [24, 49, 28], [24, 49, 36], [24, 49, 44], [24, 49, 46], [25, 0, 25], [25, 1, 15], [25, 1, 17], [25, 1, 24], [25, 1, 25], [25, 1, 37], [25, 1, 42], [25, 1, 43], [25, 1, 46], [25, 4, 7], [25, 4, 9], [25, 4, 13], [25, 4, 15], [25, 4, 25], [25, 4, 42], [25, 4, 43], [25, 4, 47], [25, 6, 10], [25, 6, 11], [25, 6, 37], [25, 6, 38], [25, 6, 40], [25, 6, 44], [25, 6, 46], [25, 6, 49], [25, 7, 4], [25, 7, 9], [25, 7, 13], [25, 7, 16], [25, 7, 29], [25, 7, 36], [25, 7, 47], [25, 7, 52], [25, 9, 4], [25, 9, 7], [25, 9, 13], [25, 9, 15], [25, 9, 16], [25, 9, 29], [25, 9, 43], [25, 9, 47], [25, 10, 6], [25, 10, 11], [25, 10, 28], [25, 10, 36], [25, 10, 38], [25, 10, 44], [25, 10, 49], [25, 10, 52], [25, 11, 6], [25, 11, 10], [25, 11, 28], [25, 11, 29], [25, 11, 36], [25, 11, 38], [25, 11, 49], [25, 11, 52], [25, 13, 4], [25, 13, 7], [25, 13, 9], [25, 13, 15], [25, 13, 16], [25, 13, 29], [25, 13, 36], [25, 13, 47], [25, 15, 1], [25, 15, 4], [25, 15, 9], [25, 15, 13], [25, 15, 25], [25, 15, 42], [25, 15, 43], [25, 15, 47], [25, 16, 7], [25, 16, 9], [25, 16, 13], [25, 16, 28], [25, 16, 29], [25, 16, 36], [25, 16, 47], [25, 16, 52], [25, 17, 1], [25, 17, 24], [25, 17, 25], [25, 17, 37], [25, 17, 40], [25, 17, 42], [25, 17, 43], [25, 17, 46], [25, 24, 1], [25, 24, 17], [25, 24, 25], [25, 24, 37], [25, 24, 40], [25, 24, 42], [25, 24, 44], [25, 24, 46], [25, 25, 0], [25, 25, 1], [25, 25, 4], [25, 25, 15], [25, 25, 17], [25, 25, 24], [25, 25, 25], [25, 25, 37], [25, 25, 42], [25, 25, 43], [25, 28, 10], [25, 28, 11], [25, 28, 16], [25, 28, 29], [25, 28, 36], [25, 28, 38], [25, 28, 49], [25, 28, 52], [25, 29, 7], [25, 29, 9], [25, 29, 11], [25, 29, 13], [25, 29, 16], [25, 29, 28], [25, 29, 36], [25, 29, 52], [25, 36, 7], [25, 36, 10], [25, 36, 11], [25, 36, 13], [25, 36, 16], [25, 36, 28], [25, 36, 29], [25, 36, 52], [25, 37, 1], [25, 37, 6], [25, 37, 17], [25, 37, 24], [25, 37, 25], [25, 37, 40], [25, 37, 44], [25, 37, 46], [25, 38, 6], [25, 38, 10], [25, 38, 11], [25, 38, 28], [25, 38, 40], [25, 38, 44], [25, 38, 49], [25, 38, 52], [25, 40, 6], [25, 40, 17], [25, 40, 24], [25, 40, 37], [25, 40, 38], [25, 40, 44], [25, 40, 46], [25, 40, 49], [25, 42, 1], [25, 42, 4], [25, 42, 15], [25, 42, 17], [25, 42, 24], [25, 42, 25], [25, 42, 43], [25, 42, 47], [25, 43, 1], [25, 43, 4], [25, 43, 9], [25, 43, 15], [25, 43, 17], [25, 43, 25], [25, 43, 42], [25, 43, 47], [25, 44, 6], [25, 44, 10], [25, 44, 24], [25, 44, 37], [25, 44, 38], [25, 44, 40], [25, 44, 46], [25, 44, 49], [25, 46, 1], [25, 46, 6], [25, 46, 17], [25, 46, 24], [25, 46, 37], [25, 46, 40], [25, 46, 44], [25, 46, 49], [25, 47, 4], [25, 47, 7], [25, 47, 9], [25, 47, 13], [25, 47, 15], [25, 47, 16], [25, 47, 42], [25, 47, 43], [25, 49, 6], [25, 49, 10], [25, 49, 11], [25, 49, 28], [25, 49, 38], [25, 49, 40], [25, 49, 44], [25, 49, 46], [25, 52, 7], [25, 52, 10], [25, 52, 11], [25, 52, 16], [25, 52, 28], [25, 52, 29], [25, 52, 36], [25, 52, 38], [26, 0, 26], [26, 1, 4], [26, 1, 10], [26, 1, 16], [26, 1, 26], [26, 1, 33], [26, 1, 40], [26, 1, 45], [26, 1, 51], [26, 2, 8], [26, 2, 13], [26, 2, 20], [26, 2, 27], [26, 2, 32], [26, 2, 37], [26, 2, 49], [26, 2, 52], [26, 3, 12], [26, 3, 14], [26, 3, 25], [26, 3, 29], [26, 3, 30], [26, 3, 46], [26, 3, 47], [26, 3, 48], [26, 4, 1], [26, 4, 11], [26, 4, 16], [26, 4, 21], [26, 4, 26], [26, 4, 40], [26, 4, 45], [26, 4, 51], [26, 5, 6], [26, 5, 13], [26, 5, 20], [26, 5, 24], [26, 5, 27], [26, 5, 41], [26, 5, 43], [26, 5, 50], [26, 6, 5], [26, 6, 7], [26, 6, 24], [26, 6, 28], [26, 6, 39], [26, 6, 41], [26, 6, 43], [26, 6, 50], [26, 7, 6], [26, 7, 15], [26, 7, 17], [26, 7, 19], [26, 7, 23], [26, 7, 28], [26, 7, 39], [26, 7, 50], [26, 8, 2], [26, 8, 22], [26, 8, 27], [26, 8, 32], [26, 8, 37], [26, 8, 42], [26, 8, 49], [26, 8, 52], [26, 9, 22], [26, 9, 32], [26, 9, 34], [26, 9, 35], [26, 9, 36], [26, 9, 37], [26, 9, 38], [26, 9, 42], [26, 10, 1], [26, 10, 12], [26, 10, 26], [26, 10, 29], [26, 10, 33], [26, 10, 40], [26, 10, 47], [26, 10, 48], [26, 11, 4], [26, 11, 16], [26, 11, 17], [26, 11, 18], [26, 11, 21], [26, 11, 31], [26, 11, 44], [26, 11, 45], [26, 12, 3], [26, 12, 10], [26, 12, 14], [26, 12, 25], [26, 12, 29], [26, 12, 33], [26, 12, 47], [26, 12, 48], [26, 13, 2], [26, 13, 5], [26, 13, 20], [26, 13, 24], [26, 13, 27], [26, 13, 43], [26, 13, 49], [26, 13, 52], [26, 14, 3], [26, 14, 12], [26, 14, 25], [26, 14, 30], [26, 14, 34], [26, 14, 38], [26, 14, 46], [26, 14, 47], [26, 15, 7], [26, 15, 17], [26, 15, 18], [26, 15, 19], [26, 15, 23], [26, 15, 28], [26, 15, 39], [26, 15, 44], [26, 16, 1], [26, 16, 4], [26, 16, 11], [26, 16, 21], [26, 16, 31], [26, 16, 44], [26, 16, 45], [26, 16, 51], [26, 17, 7], [26, 17, 11], [26, 17, 15], [26, 17, 18], [26, 17, 19], [26, 17, 23], [26, 17, 31], [26, 17, 44], [26, 18, 11], [26, 18, 15], [26, 18, 17], [26, 18, 19], [26, 18, 21], [26, 18, 23], [26, 18, 31], [26, 18, 44], [26, 19, 7], [26, 19, 15], [26, 19, 17], [26, 19, 18], [26, 19, 23], [26, 19, 31], [26, 19, 39], [26, 19, 44], [26, 20, 2], [26, 20, 5], [26, 20, 13], [26, 20, 24], [26, 20, 27], [26, 20, 41], [26, 20, 43], [26, 20, 52], [26, 21, 4], [26, 21, 11], [26, 21, 16], [26, 21, 18], [26, 21, 31], [26, 21, 44], [26, 21, 45], [26, 21, 51], [26, 22, 8], [26, 22, 9], [26, 22, 32], [26, 22, 34], [26, 22, 35], [26, 22, 36], [26, 22, 37], [26, 22, 42], [26, 23, 7], [26, 23, 15], [26, 23, 17], [26, 23, 18], [26, 23, 19], [26, 23, 28], [26, 23, 39], [26, 23, 50], [26, 24, 5], [26, 24, 6], [26, 24, 13], [26, 24, 20], [26, 24, 28], [26, 24, 41], [26, 24, 43], [26, 24, 50], [26, 25, 3], [26, 25, 12], [26, 25, 14], [26, 25, 29], [26, 25, 30], [26, 25, 38], [26, 25, 46], [26, 25, 47], [26, 26, 0], [26, 26, 1], [26, 26, 4], [26, 26, 10], [26, 26, 26], [26, 26, 33], [26, 26, 40], [26, 26, 45], [26, 26, 48], [26, 26, 51], [26, 27, 2], [26, 27, 5], [26, 27, 8], [26, 27, 13], [26, 27, 20], [26, 27, 43], [26, 27, 49], [26, 27, 52], [26, 28, 6], [26, 28, 7], [26, 28, 15], [26, 28, 23], [26, 28, 24], [26, 28, 39], [26, 28, 41], [26, 28, 50], [26, 29, 3], [26, 29, 10], [26, 29, 12], [26, 29, 25], [26, 29, 33], [26, 29, 40], [26, 29, 47], [26, 29, 48], [26, 30, 3], [26, 30, 14], [26, 30, 25], [26, 30, 34], [26, 30, 35], [26, 30, 36], [26, 30, 38], [26, 30, 46], [26, 31, 11], [26, 31, 16], [26, 31, 17], [26, 31, 18], [26, 31, 19], [26, 31, 21], [26, 31, 44], [26, 31, 45], [26, 32, 2], [26, 32, 8], [26, 32, 9], [26, 32, 22], [26, 32, 35], [26, 32, 37], [26, 32, 42], [26, 32, 49], [26, 33, 1], [26, 33, 10], [26, 33, 12], [26, 33, 26], [26, 33, 29], [26, 33, 40], [26, 33, 48], [26, 33, 51], [26, 34, 9], [26, 34, 14], [26, 34, 22], [26, 34, 30], [26, 34, 35], [26, 34, 36], [26, 34, 38], [26, 34, 46], [26, 35, 9], [26, 35, 22], [26, 35, 30], [26, 35, 32], [26, 35, 34], [26, 35, 36], [26, 35, 38], [26, 35, 42], [26, 36, 9], [26, 36, 22], [26, 36, 30], [26, 36, 34], [26, 36, 35], [26, 36, 38], [26, 36, 42], [26, 36, 46], [26, 37, 2], [26, 37, 8], [26, 37, 9], [26, 37, 22], [26, 37, 32], [26, 37, 42], [26, 37, 49], [26, 37, 52], [26, 38, 9], [26, 38, 14], [26, 38, 25], [26, 38, 30], [26, 38, 34], [26, 38, 35], [26, 38, 36], [26, 38, 46], [26, 39, 6], [26, 39, 7], [26, 39, 15], [26, 39, 19], [26, 39, 23], [26, 39, 28], [26, 39, 41], [26, 39, 50], [26, 40, 1], [26, 40, 4], [26, 40, 10], [26, 40, 26], [26, 40, 29], [26, 40, 33], [26, 40, 48], [26, 40, 51], [26, 41, 5], [26, 41, 6], [26, 41, 20], [26, 41, 24], [26, 41, 28], [26, 41, 39], [26, 41, 43], [26, 41, 50], [26, 42, 8], [26, 42, 9], [26, 42, 22], [26, 42, 32], [26, 42, 35], [26, 42, 36], [26, 42, 37], [26, 42, 49], [26, 43, 5], [26, 43, 6], [26, 43, 13], [26, 43, 20], [26, 43, 24], [26, 43, 27], [26, 43, 41], [26, 43, 52], [26, 44, 11], [26, 44, 15], [26, 44, 16], [26, 44, 17], [26, 44, 18], [26, 44, 19], [26, 44, 21], [26, 44, 31], [26, 45, 1], [26, 45, 4], [26, 45, 11], [26, 45, 16], [26, 45, 21], [26, 45, 26], [26, 45, 31], [26, 45, 51], [26, 46, 3], [26, 46, 14], [26, 46, 25], [26, 46, 30], [26, 46, 34], [26, 46, 36], [26, 46, 38], [26, 46, 47], [26, 47, 3], [26, 47, 10], [26, 47, 12], [26, 47, 14], [26, 47, 25], [26, 47, 29], [26, 47, 46], [26, 47, 48], [26, 48, 3], [26, 48, 10], [26, 48, 12], [26, 48, 26], [26, 48, 29], [26, 48, 33], [26, 48, 40], [26, 48, 47], [26, 49, 2], [26, 49, 8], [26, 49, 13], [26, 49, 27], [26, 49, 32], [26, 49, 37], [26, 49, 42], [26, 49, 52], [26, 50, 5], [26, 50, 6], [26, 50, 7], [26, 50, 23], [26, 50, 24], [26, 50, 28], [26, 50, 39], [26, 50, 41], [26, 51, 1], [26, 51, 4], [26, 51, 16], [26, 51, 21], [26, 51, 26], [26, 51, 33], [26, 51, 40], [26, 51, 45], [26, 52, 2], [26, 52, 8], [26, 52, 13], [26, 52, 20], [26, 52, 27], [26, 52, 37], [26, 52, 43], [26, 52, 49], [27, 0, 27], [27, 1, 2], [27, 1, 4], [27, 1, 8], [27, 1, 10], [27, 1, 16], [27, 1, 20], [27, 1, 27], [27, 1, 40], [27, 2, 1], [27, 2, 4], [27, 2, 8], [27, 2, 16], [27, 2, 20], [27, 2, 27], [27, 2, 32], [27, 2, 40], [27, 3, 6], [27, 3, 7], [27, 3, 12], [27, 3, 14], [27, 3, 24], [27, 3, 28], [27, 3, 30], [27, 3, 48], [27, 4, 1], [27, 4, 2], [27, 4, 8], [27, 4, 11], [27, 4, 16], [27, 4, 27], [27, 4, 32], [27, 4, 40], [27, 5, 10], [27, 5, 20], [27, 5, 27], [27, 5, 29], [27, 5, 40], [27, 5, 41], [27, 5, 47], [27, 5, 50], [27, 6, 3], [27, 6, 7], [27, 6, 12], [27, 6, 14], [27, 6, 24], [27, 6, 28], [27, 6, 43], [27, 6, 48], [27, 7, 3], [27, 7, 6], [27, 7, 14], [27, 7, 15], [27, 7, 17], [27, 7, 28], [27, 7, 30], [27, 7, 34], [27, 8, 1], [27, 8, 2], [27, 8, 4], [27, 8, 11], [27, 8, 16], [27, 8, 22], [27, 8, 27], [27, 8, 32], [27, 9, 18], [27, 9, 19], [27, 9, 21], [27, 9, 31], [27, 9, 36], [27, 9, 37], [27, 9, 38], [27, 9, 42], [27, 10, 1], [27, 10, 5], [27, 10, 20], [27, 10, 27], [27, 10, 29], [27, 10, 40], [27, 10, 41], [27, 10, 47], [27, 11, 4], [27, 11, 8], [27, 11, 16], [27, 11, 17], [27, 11, 22], [27, 11, 32], [27, 11, 35], [27, 11, 44], [27, 12, 3], [27, 12, 6], [27, 12, 14], [27, 12, 24], [27, 12, 28], [27, 12, 33], [27, 12, 43], [27, 12, 48], [27, 13, 24], [27, 13, 26], [27, 13, 33], [27, 13, 43], [27, 13, 48], [27, 13, 49], [27, 13, 51], [27, 13, 52], [27, 14, 3], [27, 14, 6], [27, 14, 7], [27, 14, 12], [27, 14, 15], [27, 14, 28], [27, 14, 30], [27, 14, 34], [27, 15, 7], [27, 15, 14], [27, 15, 17], [27, 15, 28], [27, 15, 30], [27, 15, 34], [27, 15, 35], [27, 15, 44], [27, 16, 1], [27, 16, 2], [27, 16, 4], [27, 16, 8], [27, 16, 11], [27, 16, 22], [27, 16, 32], [27, 16, 44], [27, 17, 7], [27, 17, 11], [27, 17, 15], [27, 17, 22], [27, 17, 30], [27, 17, 34], [27, 17, 35], [27, 17, 44], [27, 18, 9], [27, 18, 19], [27, 18, 21], [27, 18, 23], [27, 18, 31], [27, 18, 36], [27, 18, 38], [27, 18, 42], [27, 19, 9], [27, 19, 18], [27, 19, 23], [27, 19, 31], [27, 19, 36], [27, 19, 38], [27, 19, 39], [27, 19, 46], [27, 20, 1], [27, 20, 2], [27, 20, 5], [27, 20, 10], [27, 20, 27], [27, 20, 29], [27, 20, 40], [27, 20, 41], [27, 21, 9], [27, 21, 18], [27, 21, 31], [27, 21, 37], [27, 21, 42], [27, 21, 45], [27, 21, 49], [27, 21, 51], [27, 22, 8], [27, 22, 11], [27, 22, 16], [27, 22, 17], [27, 22, 32], [27, 22, 34], [27, 22, 35], [27, 22, 44], [27, 23, 18], [27, 23, 19], [27, 23, 25], [27, 23, 36], [27, 23, 38], [27, 23, 39], [27, 23, 46], [27, 23, 50], [27, 24, 3], [27, 24, 6], [27, 24, 12], [27, 24, 13], [27, 24, 28], [27, 24, 33], [27, 24, 43], [27, 24, 48], [27, 25, 23], [27, 25, 29], [27, 25, 38], [27, 25, 39], [27, 25, 41], [27, 25, 46], [27, 25, 47], [27, 25, 50], [27, 26, 13], [27, 26, 33], [27, 26, 43], [27, 26, 45], [27, 26, 48], [27, 26, 49], [27, 26, 51], [27, 26, 52], [27, 27, 0], [27, 27, 1], [27, 27, 2], [27, 27, 4], [27, 27, 5], [27, 27, 8], [27, 27, 10], [27, 27, 20], [27, 27, 27], [27, 27, 40], [27, 28, 3], [27, 28, 6], [27, 28, 7], [27, 28, 12], [27, 28, 14], [27, 28, 15], [27, 28, 24], [27, 28, 30], [27, 29, 5], [27, 29, 10], [27, 29, 20], [27, 29, 25], [27, 29, 40], [27, 29, 41], [27, 29, 47], [27, 29, 50], [27, 30, 3], [27, 30, 7], [27, 30, 14], [27, 30, 15], [27, 30, 17], [27, 30, 28], [27, 30, 34], [27, 30, 35], [27, 31, 9], [27, 31, 18], [27, 31, 19], [27, 31, 21], [27, 31, 36], [27, 31, 37], [27, 31, 42], [27, 31, 45], [27, 32, 2], [27, 32, 4], [27, 32, 8], [27, 32, 11], [27, 32, 16], [27, 32, 22], [27, 32, 35], [27, 32, 44], [27, 33, 12], [27, 33, 13], [27, 33, 24], [27, 33, 26], [27, 33, 43], [27, 33, 48], [27, 33, 51], [27, 33, 52], [27, 34, 7], [27, 34, 14], [27, 34, 15], [27, 34, 17], [27, 34, 22], [27, 34, 30], [27, 34, 35], [27, 34, 44], [27, 35, 11], [27, 35, 15], [27, 35, 17], [27, 35, 22], [27, 35, 30], [27, 35, 32], [27, 35, 34], [27, 35, 44], [27, 36, 9], [27, 36, 18], [27, 36, 19], [27, 36, 23], [27, 36, 31], [27, 36, 38], [27, 36, 42], [27, 36, 46], [27, 37, 9], [27, 37, 21], [27, 37, 31], [27, 37, 42], [27, 37, 45], [27, 37, 49], [27, 37, 51], [27, 37, 52], [27, 38, 9], [27, 38, 18], [27, 38, 19], [27, 38, 23], [27, 38, 25], [27, 38, 36], [27, 38, 39], [27, 38, 46], [27, 39, 19], [27, 39, 23], [27, 39, 25], [27, 39, 38], [27, 39, 41], [27, 39, 46], [27, 39, 47], [27, 39, 50], [27, 40, 1], [27, 40, 2], [27, 40, 4], [27, 40, 5], [27, 40, 10], [27, 40, 20], [27, 40, 27], [27, 40, 29], [27, 41, 5], [27, 41, 10], [27, 41, 20], [27, 41, 25], [27, 41, 29], [27, 41, 39], [27, 41, 47], [27, 41, 50], [27, 42, 9], [27, 42, 18], [27, 42, 21], [27, 42, 31], [27, 42, 36], [27, 42, 37], [27, 42, 45], [27, 42, 49], [27, 43, 6], [27, 43, 12], [27, 43, 13], [27, 43, 24], [27, 43, 26], [27, 43, 33], [27, 43, 48], [27, 43, 52], [27, 44, 11], [27, 44, 15], [27, 44, 16], [27, 44, 17], [27, 44, 22], [27, 44, 32], [27, 44, 34], [27, 44, 35], [27, 45, 21], [27, 45, 26], [27, 45, 31], [27, 45, 37], [27, 45, 42], [27, 45, 49], [27, 45, 51], [27, 45, 52], [27, 46, 19], [27, 46, 23], [27, 46, 25], [27, 46, 36], [27, 46, 38], [27, 46, 39], [27, 46, 47], [27, 46, 50], [27, 47, 5], [27, 47, 10], [27, 47, 25], [27, 47, 29], [27, 47, 39], [27, 47, 41], [27, 47, 46], [27, 47, 50], [27, 48, 3], [27, 48, 6], [27, 48, 12], [27, 48, 13], [27, 48, 24], [27, 48, 26], [27, 48, 33], [27, 48, 43], [27, 49, 13], [27, 49, 21], [27, 49, 26], [27, 49, 37], [27, 49, 42], [27, 49, 45], [27, 49, 51], [27, 49, 52], [27, 50, 5], [27, 50, 23], [27, 50, 25], [27, 50, 29], [27, 50, 39], [27, 50, 41], [27, 50, 46], [27, 50, 47], [27, 51, 13], [27, 51, 21], [27, 51, 26], [27, 51, 33], [27, 51, 37], [27, 51, 45], [27, 51, 49], [27, 51, 52], [27, 52, 13], [27, 52, 26], [27, 52, 33], [27, 52, 37], [27, 52, 43], [27, 52, 45], [27, 52, 49], [27, 52, 51], [28, 0, 28], [28, 1, 10], [28, 1, 15], [28, 1, 16], [28, 1, 24], [28, 1, 28], [28, 1, 36], [28, 1, 42], [28, 1, 46], [28, 10, 1], [28, 10, 15], [28, 10, 28], [28, 10, 36], [28, 10, 42], [28, 10, 44], [28, 10, 47], [28, 10, 49], [28, 13, 15], [28, 13, 16], [28, 13, 24], [28, 13, 36], [28, 13, 44], [28, 13, 46], [28, 13, 47], [28, 13, 49], [28, 15, 1], [28, 15, 10], [28, 15, 13], [28, 15, 28], [28, 15, 42], [28, 15, 44], [28, 15, 47], [28, 15, 49], [28, 16, 1], [28, 16, 13], [28, 16, 24], [28, 16, 28], [28, 16, 36], [28, 16, 44], [28, 16, 46], [28, 16, 47], [28, 24, 1], [28, 24, 13], [28, 24, 16], [28, 24, 28], [28, 24, 36], [28, 24, 42], [28, 24, 44], [28, 24, 46], [28, 28, 0], [28, 28, 1], [28, 28, 10], [28, 28, 15], [28, 28, 16], [28, 28, 24], [28, 28, 28], [28, 28, 36], [28, 28, 42], [28, 28, 49], [28, 36, 1], [28, 36, 10], [28, 36, 13], [28, 36, 16], [28, 36, 24], [28, 36, 28], [28, 36, 42], [28, 36, 46], [28, 42, 1], [28, 42, 10], [28, 42, 15], [28, 42, 24], [28, 42, 28], [28, 42, 36], [28, 42, 47], [28, 42, 49], [28, 44, 10], [28, 44, 13], [28, 44, 15], [28, 44, 16], [28, 44, 24], [28, 44, 46], [28, 44, 47], [28, 44, 49], [28, 46, 1], [28, 46, 13], [28, 46, 16], [28, 46, 24], [28, 46, 36], [28, 46, 44], [28, 46, 47], [28, 46, 49], [28, 47, 10], [28, 47, 13], [28, 47, 15], [28, 47, 16], [28, 47, 42], [28, 47, 44], [28, 47, 46], [28, 47, 49], [28, 49, 10], [28, 49, 13], [28, 49, 15], [28, 49, 28], [28, 49, 42], [28, 49, 44], [28, 49, 46], [28, 49, 47], [29, 0, 29], [29, 1, 6], [29, 1, 9], [29, 1, 11], [29, 1, 13], [29, 1, 15], [29, 1, 29], [29, 1, 46], [29, 1, 49], [29, 4, 7], [29, 4, 10], [29, 4, 24], [29, 4, 25], [29, 4, 36], [29, 4, 37], [29, 4, 44], [29, 4, 52], [29, 6, 1], [29, 6, 11], [29, 6, 13], [29, 6, 15], [29, 6, 25], [29, 6, 29], [29, 6, 36], [29, 6, 37], [29, 7, 4], [29, 7, 10], [29, 7, 24], [29, 7, 25], [29, 7, 38], [29, 7, 42], [29, 7, 44], [29, 7, 52], [29, 9, 1], [29, 9, 11], [29, 9, 17], [29, 9, 28], [29, 9, 29], [29, 9, 43], [29, 9, 46], [29, 9, 49], [29, 10, 4], [29, 10, 7], [29, 10, 13], [29, 10, 24], [29, 10, 25], [29, 10, 36], [29, 10, 37], [29, 10, 44], [29, 11, 1], [29, 11, 6], [29, 11, 9], [29, 11, 13], [29, 11, 15], [29, 11, 29], [29, 11, 37], [29, 11, 46], [29, 13, 1], [29, 13, 6], [29, 13, 10], [29, 13, 11], [29, 13, 15], [29, 13, 25], [29, 13, 36], [29, 13, 37], [29, 15, 1], [29, 15, 6], [29, 15, 11], [29, 15, 13], [29, 15, 29], [29, 15, 36], [29, 15, 37], [29, 15, 46], [29, 16, 17], [29, 16, 28], [29, 16, 38], [29, 16, 40], [29, 16, 42], [29, 16, 43], [29, 16, 47], [29, 16, 49], [29, 17, 9], [29, 17, 16], [29, 17, 28], [29, 17, 38], [29, 17, 40], [29, 17, 43], [29, 17, 47], [29, 17, 49], [29, 24, 4], [29, 24, 7], [29, 24, 10], [29, 24, 38], [29, 24, 42], [29, 24, 44], [29, 24, 47], [29, 24, 52], [29, 25, 4], [29, 25, 6], [29, 25, 7], [29, 25, 10], [29, 25, 13], [29, 25, 36], [29, 25, 37], [29, 25, 44], [29, 28, 9], [29, 28, 16], [29, 28, 17], [29, 28, 40], [29, 28, 43], [29, 28, 46], [29, 28, 47], [29, 28, 49], [29, 29, 0], [29, 29, 1], [29, 29, 6], [29, 29, 9], [29, 29, 11], [29, 29, 15], [29, 29, 29], [29, 29, 43], [29, 29, 46], [29, 29, 49], [29, 36, 4], [29, 36, 6], [29, 36, 10], [29, 36, 13], [29, 36, 15], [29, 36, 25], [29, 36, 37], [29, 36, 44], [29, 37, 4], [29, 37, 6], [29, 37, 10], [29, 37, 11], [29, 37, 13], [29, 37, 15], [29, 37, 25], [29, 37, 36], [29, 38, 7], [29, 38, 16], [29, 38, 17], [29, 38, 24], [29, 38, 40], [29, 38, 42], [29, 38, 47], [29, 38, 52], [29, 40, 16], [29, 40, 17], [29, 40, 28], [29, 40, 38], [29, 40, 42], [29, 40, 43], [29, 40, 47], [29, 40, 52], [29, 42, 7], [29, 42, 16], [29, 42, 24], [29, 42, 38], [29, 42, 40], [29, 42, 44], [29, 42, 47], [29, 42, 52], [29, 43, 9], [29, 43, 16], [29, 43, 17], [29, 43, 28], [29, 43, 29], [29, 43, 40], [29, 43, 46], [29, 43, 49], [29, 44, 4], [29, 44, 7], [29, 44, 10], [29, 44, 24], [29, 44, 25], [29, 44, 36], [29, 44, 42], [29, 44, 52], [29, 46, 1], [29, 46, 9], [29, 46, 11], [29, 46, 15], [29, 46, 28], [29, 46, 29], [29, 46, 43], [29, 46, 49], [29, 47, 16], [29, 47, 17], [29, 47, 24], [29, 47, 28], [29, 47, 38], [29, 47, 40], [29, 47, 42], [29, 47, 52], [29, 49, 1], [29, 49, 9], [29, 49, 16], [29, 49, 17], [29, 49, 28], [29, 49, 29], [29, 49, 43], [29, 49, 46], [29, 52, 4], [29, 52, 7], [29, 52, 24], [29, 52, 38], [29, 52, 40], [29, 52, 42], [29, 52, 44], [29, 52, 47], [30, 0, 30], [30, 1, 1], [30, 1, 23], [30, 1, 30], [30, 1, 52], [30, 23, 1], [30, 23, 23], [30, 23, 30], [30, 23, 52], [30, 30, 0], [30, 30, 1], [30, 30, 23], [30, 30, 30], [30, 30, 52], [30, 52, 1], [30, 52, 23], [30, 52, 30], [30, 52, 52], [31, 0, 31], [31, 1, 5], [31, 1, 7], [31, 1, 12], [31, 1, 13], [31, 1, 31], [31, 1, 32], [31, 1, 38], [31, 1, 49], [31, 2, 9], [31, 2, 10], [31, 2, 11], [31, 2, 14], [31, 2, 23], [31, 2, 24], [31, 2, 26], [31, 2, 45], [31, 3, 8], [31, 3, 15], [31, 3, 21], [31, 3, 36], [31, 3, 39], [31, 3, 40], [31, 3, 41], [31, 3, 43], [31, 4, 18], [31, 4, 20], [31, 4, 22], [31, 4, 28], [31, 4, 37], [31, 4, 46], [31, 4, 48], [31, 4, 52], [31, 5, 1], [31, 5, 7], [31, 5, 12], [31, 5, 25], [31, 5, 31], [31, 5, 33], [31, 5, 35], [31, 5, 49], [31, 6, 16], [31, 6, 19], [31, 6, 25], [31, 6, 27], [31, 6, 29], [31, 6, 30], [31, 6, 33], [31, 6, 42], [31, 7, 1], [31, 7, 5], [31, 7, 12], [31, 7, 25], [31, 7, 31], [31, 7, 35], [31, 7, 38], [31, 7, 49], [31, 8, 3], [31, 8, 21], [31, 8, 36], [31, 8, 39], [31, 8, 40], [31, 8, 43], [31, 8, 44], [31, 8, 51], [31, 9, 2], [31, 9, 10], [31, 9, 11], [31, 9, 14], [31, 9, 17], [31, 9, 23], [31, 9, 24], [31, 9, 45], [31, 10, 2], [31, 10, 9], [31, 10, 13], [31, 10, 14], [31, 10, 17], [31, 10, 24], [31, 10, 45], [31, 10, 50], [31, 11, 2], [31, 11, 9], [31, 11, 23], [31, 11, 24], [31, 11, 26], [31, 11, 34], [31, 11, 37], [31, 11, 47], [31, 12, 1], [31, 12, 5], [31, 12, 7], [31, 12, 13], [31, 12, 31], [31, 12, 32], [31, 12, 38], [31, 12, 50], [31, 13, 1], [31, 13, 10], [31, 13, 12], [31, 13, 17], [31, 13, 32], [31, 13, 38], [31, 13, 45], [31, 13, 50], [31, 14, 2], [31, 14, 9], [31, 14, 10], [31, 14, 17], [31, 14, 23], [31, 14, 24], [31, 14, 45], [31, 14, 50], [31, 15, 3], [31, 15, 21], [31, 15, 22], [31, 15, 36], [31, 15, 40], [31, 15, 41], [31, 15, 46], [31, 15, 52], [31, 16, 6], [31, 16, 19], [31, 16, 25], [31, 16, 27], [31, 16, 33], [31, 16, 35], [31, 16, 42], [31, 16, 49], [31, 17, 9], [31, 17, 10], [31, 17, 13], [31, 17, 14], [31, 17, 32], [31, 17, 38], [31, 17, 45], [31, 17, 50], [31, 18, 4], [31, 18, 20], [31, 18, 22], [31, 18, 28], [31, 18, 34], [31, 18, 37], [31, 18, 46], [31, 18, 48], [31, 19, 6], [31, 19, 16], [31, 19, 25], [31, 19, 27], [31, 19, 30], [31, 19, 33], [31, 19, 35], [31, 19, 42], [31, 20, 4], [31, 20, 18], [31, 20, 26], [31, 20, 28], [31, 20, 34], [31, 20, 37], [31, 20, 47], [31, 20, 48], [31, 21, 3], [31, 21, 8], [31, 21, 15], [31, 21, 22], [31, 21, 36], [31, 21, 40], [31, 21, 41], [31, 21, 52], [31, 22, 4], [31, 22, 15], [31, 22, 18], [31, 22, 21], [31, 22, 41], [31, 22, 46], [31, 22, 48], [31, 22, 52], [31, 23, 2], [31, 23, 9], [31, 23, 11], [31, 23, 14], [31, 23, 24], [31, 23, 26], [31, 23, 34], [31, 23, 47], [31, 24, 2], [31, 24, 9], [31, 24, 10], [31, 24, 11], [31, 24, 14], [31, 24, 23], [31, 24, 26], [31, 24, 47], [31, 25, 5], [31, 25, 6], [31, 25, 7], [31, 25, 16], [31, 25, 19], [31, 25, 33], [31, 25, 35], [31, 25, 49], [31, 26, 2], [31, 26, 11], [31, 26, 20], [31, 26, 23], [31, 26, 24], [31, 26, 34], [31, 26, 37], [31, 26, 47], [31, 27, 6], [31, 27, 16], [31, 27, 19], [31, 27, 29], [31, 27, 30], [31, 27, 33], [31, 27, 42], [31, 27, 51], [31, 28, 4], [31, 28, 18], [31, 28, 20], [31, 28, 34], [31, 28, 37], [31, 28, 46], [31, 28, 47], [31, 28, 48], [31, 29, 6], [31, 29, 27], [31, 29, 30], [31, 29, 39], [31, 29, 42], [31, 29, 43], [31, 29, 44], [31, 29, 51], [31, 30, 6], [31, 30, 19], [31, 30, 27], [31, 30, 29], [31, 30, 39], [31, 30, 42], [31, 30, 44], [31, 30, 51], [31, 31, 0], [31, 31, 1], [31, 31, 5], [31, 31, 7], [31, 31, 12], [31, 31, 31], [31, 31, 32], [31, 31, 35], [31, 31, 38], [31, 31, 49], [31, 32, 1], [31, 32, 12], [31, 32, 13], [31, 32, 17], [31, 32, 31], [31, 32, 38], [31, 32, 45], [31, 32, 50], [31, 33, 5], [31, 33, 6], [31, 33, 16], [31, 33, 19], [31, 33, 25], [31, 33, 27], [31, 33, 35], [31, 33, 49], [31, 34, 11], [31, 34, 18], [31, 34, 20], [31, 34, 23], [31, 34, 26], [31, 34, 28], [31, 34, 37], [31, 34, 47], [31, 35, 5], [31, 35, 7], [31, 35, 16], [31, 35, 19], [31, 35, 25], [31, 35, 31], [31, 35, 33], [31, 35, 49], [31, 36, 3], [31, 36, 8], [31, 36, 15], [31, 36, 21], [31, 36, 39], [31, 36, 40], [31, 36, 43], [31, 36, 44], [31, 37, 4], [31, 37, 11], [31, 37, 18], [31, 37, 20], [31, 37, 26], [31, 37, 28], [31, 37, 34], [31, 37, 47], [31, 38, 1], [31, 38, 7], [31, 38, 12], [31, 38, 13], [31, 38, 17], [31, 38, 31], [31, 38, 32], [31, 38, 50], [31, 39, 3], [31, 39, 8], [31, 39, 29], [31, 39, 30], [31, 39, 36], [31, 39, 43], [31, 39, 44], [31, 39, 51], [31, 40, 3], [31, 40, 8], [31, 40, 15], [31, 40, 21], [31, 40, 36], [31, 40, 41], [31, 40, 43], [31, 40, 52], [31, 41, 3], [31, 41, 15], [31, 41, 21], [31, 41, 22], [31, 41, 40], [31, 41, 46], [31, 41, 48], [31, 41, 52], [31, 42, 6], [31, 42, 16], [31, 42, 19], [31, 42, 27], [31, 42, 29], [31, 42, 30], [31, 42, 44], [31, 42, 51], [31, 43, 3], [31, 43, 8], [31, 43, 29], [31, 43, 36], [31, 43, 39], [31, 43, 40], [31, 43, 44], [31, 43, 51], [31, 44, 8], [31, 44, 29], [31, 44, 30], [31, 44, 36], [31, 44, 39], [31, 44, 42], [31, 44, 43], [31, 44, 51], [31, 45, 2], [31, 45, 9], [31, 45, 10], [31, 45, 13], [31, 45, 14], [31, 45, 17], [31, 45, 32], [31, 45, 50], [31, 46, 4], [31, 46, 15], [31, 46, 18], [31, 46, 22], [31, 46, 28], [31, 46, 41], [31, 46, 48], [31, 46, 52], [31, 47, 11], [31, 47, 20], [31, 47, 23], [31, 47, 24], [31, 47, 26], [31, 47, 28], [31, 47, 34], [31, 47, 37], [31, 48, 4], [31, 48, 18], [31, 48, 20], [31, 48, 22], [31, 48, 28], [31, 48, 41], [31, 48, 46], [31, 48, 52], [31, 49, 1], [31, 49, 5], [31, 49, 7], [31, 49, 16], [31, 49, 25], [31, 49, 31], [31, 49, 33], [31, 49, 35], [31, 50, 10], [31, 50, 12], [31, 50, 13], [31, 50, 14], [31, 50, 17], [31, 50, 32], [31, 50, 38], [31, 50, 45], [31, 51, 8], [31, 51, 27], [31, 51, 29], [31, 51, 30], [31, 51, 39], [31, 51, 42], [31, 51, 43], [31, 51, 44], [31, 52, 4], [31, 52, 15], [31, 52, 21], [31, 52, 22], [31, 52, 40], [31, 52, 41], [31, 52, 46], [31, 52, 48], [32, 0, 32], [32, 1, 5], [32, 1, 14], [32, 1, 17], [32, 1, 19], [32, 1, 24], [32, 1, 25], [32, 1, 32], [32, 1, 42], [32, 2, 10], [32, 2, 11], [32, 2, 28], [32, 2, 31], [32, 2, 34], [32, 2, 38], [32, 2, 48], [32, 2, 50], [32, 3, 4], [32, 3, 15], [32, 3, 19], [32, 3, 20], [32, 3, 22], [32, 3, 42], [32, 3, 43], [32, 3, 51], [32, 4, 3], [32, 4, 9], [32, 4, 15], [32, 4, 20], [32, 4, 22], [32, 4, 23], [32, 4, 43], [32, 4, 47], [32, 5, 1], [32, 5, 14], [32, 5, 17], [32, 5, 19], [32, 5, 25], [32, 5, 32], [32, 5, 42], [32, 5, 51], [32, 6, 8], [32, 6, 30], [32, 6, 31], [32, 6, 33], [32, 6, 38], [32, 6, 40], [32, 6, 44], [32, 6, 49], [32, 7, 9], [32, 7, 12], [32, 7, 13], [32, 7, 16], [32, 7, 27], [32, 7, 29], [32, 7, 35], [32, 7, 45], [32, 8, 6], [32, 8, 18], [32, 8, 30], [32, 8, 33], [32, 8, 40], [32, 8, 41], [32, 8, 44], [32, 8, 46], [32, 9, 4], [32, 9, 7], [32, 9, 12], [32, 9, 13], [32, 9, 20], [32, 9, 23], [32, 9, 45], [32, 9, 47], [32, 10, 2], [32, 10, 11], [32, 10, 28], [32, 10, 31], [32, 10, 34], [32, 10, 38], [32, 10, 49], [32, 10, 50], [32, 11, 2], [32, 11, 10], [32, 11, 28], [32, 11, 34], [32, 11, 38], [32, 11, 48], [32, 11, 50], [32, 11, 52], [32, 12, 7], [32, 12, 9], [32, 12, 13], [32, 12, 16], [32, 12, 23], [32, 12, 27], [32, 12, 35], [32, 12, 45], [32, 13, 7], [32, 13, 9], [32, 13, 12], [32, 13, 16], [32, 13, 23], [32, 13, 35], [32, 13, 45], [32, 13, 47], [32, 14, 1], [32, 14, 5], [32, 14, 17], [32, 14, 18], [32, 14, 24], [32, 14, 26], [32, 14, 32], [32, 14, 37], [32, 15, 3], [32, 15, 4], [32, 15, 20], [32, 15, 22], [32, 15, 42], [32, 15, 43], [32, 15, 47], [32, 15, 51], [32, 16, 7], [32, 16, 12], [32, 16, 13], [32, 16, 27], [32, 16, 29], [32, 16, 35], [32, 16, 36], [32, 16, 39], [32, 17, 1], [32, 17, 5], [32, 17, 14], [32, 17, 24], [32, 17, 25], [32, 17, 26], [32, 17, 32], [32, 17, 37], [32, 18, 8], [32, 18, 14], [32, 18, 24], [32, 18, 26], [32, 18, 37], [32, 18, 40], [32, 18, 41], [32, 18, 46], [32, 19, 1], [32, 19, 3], [32, 19, 5], [32, 19, 25], [32, 19, 32], [32, 19, 42], [32, 19, 43], [32, 19, 51], [32, 20, 3], [32, 20, 4], [32, 20, 9], [32, 20, 15], [32, 20, 22], [32, 20, 23], [32, 20, 45], [32, 20, 47], [32, 21, 27], [32, 21, 28], [32, 21, 29], [32, 21, 34], [32, 21, 36], [32, 21, 39], [32, 21, 48], [32, 21, 52], [32, 22, 3], [32, 22, 4], [32, 22, 15], [32, 22, 20], [32, 22, 23], [32, 22, 43], [32, 22, 47], [32, 22, 51], [32, 23, 4], [32, 23, 9], [32, 23, 12], [32, 23, 13], [32, 23, 20], [32, 23, 22], [32, 23, 45], [32, 23, 47], [32, 24, 1], [32, 24, 14], [32, 24, 17], [32, 24, 18], [32, 24, 26], [32, 24, 32], [32, 24, 37], [32, 24, 46], [32, 25, 1], [32, 25, 5], [32, 25, 17], [32, 25, 19], [32, 25, 32], [32, 25, 42], [32, 25, 43], [32, 25, 51], [32, 26, 14], [32, 26, 17], [32, 26, 18], [32, 26, 24], [32, 26, 32], [32, 26, 37], [32, 26, 41], [32, 26, 46], [32, 27, 7], [32, 27, 12], [32, 27, 16], [32, 27, 21], [32, 27, 29], [32, 27, 35], [32, 27, 36], [32, 27, 39], [32, 28, 2], [32, 28, 10], [32, 28, 11], [32, 28, 21], [32, 28, 34], [32, 28, 36], [32, 28, 48], [32, 28, 52], [32, 29, 7], [32, 29, 16], [32, 29, 21], [32, 29, 27], [32, 29, 35], [32, 29, 36], [32, 29, 39], [32, 29, 52], [32, 30, 6], [32, 30, 8], [32, 30, 31], [32, 30, 33], [32, 30, 40], [32, 30, 41], [32, 30, 44], [32, 30, 49], [32, 31, 2], [32, 31, 6], [32, 31, 10], [32, 31, 30], [32, 31, 33], [32, 31, 38], [32, 31, 49], [32, 31, 50], [32, 32, 0], [32, 32, 1], [32, 32, 5], [32, 32, 14], [32, 32, 17], [32, 32, 19], [32, 32, 24], [32, 32, 25], [32, 32, 26], [32, 32, 32], [32, 33, 6], [32, 33, 8], [32, 33, 30], [32, 33, 31], [32, 33, 38], [32, 33, 44], [32, 33, 49], [32, 33, 50], [32, 34, 2], [32, 34, 10], [32, 34, 11], [32, 34, 21], [32, 34, 28], [32, 34, 48], [32, 34, 50], [32, 34, 52], [32, 35, 7], [32, 35, 12], [32, 35, 13], [32, 35, 16], [32, 35, 27], [32, 35, 29], [32, 35, 39], [32, 35, 45], [32, 36, 16], [32, 36, 21], [32, 36, 27], [32, 36, 28], [32, 36, 29], [32, 36, 39], [32, 36, 48], [32, 36, 52], [32, 37, 14], [32, 37, 17], [32, 37, 18], [32, 37, 24], [32, 37, 26], [32, 37, 40], [32, 37, 41], [32, 37, 46], [32, 38, 2], [32, 38, 6], [32, 38, 10], [32, 38, 11], [32, 38, 31], [32, 38, 33], [32, 38, 49], [32, 38, 50], [32, 39, 16], [32, 39, 21], [32, 39, 27], [32, 39, 29], [32, 39, 35], [32, 39, 36], [32, 39, 48], [32, 39, 52], [32, 40, 6], [32, 40, 8], [32, 40, 18], [32, 40, 30], [32, 40, 37], [32, 40, 41], [32, 40, 44], [32, 40, 46], [32, 41, 8], [32, 41, 18], [32, 41, 26], [32, 41, 30], [32, 41, 37], [32, 41, 40], [32, 41, 44], [32, 41, 46], [32, 42, 1], [32, 42, 3], [32, 42, 5], [32, 42, 15], [32, 42, 19], [32, 42, 25], [32, 42, 43], [32, 42, 51], [32, 43, 3], [32, 43, 4], [32, 43, 15], [32, 43, 19], [32, 43, 22], [32, 43, 25], [32, 43, 42], [32, 43, 51], [32, 44, 6], [32, 44, 8], [32, 44, 30], [32, 44, 33], [32, 44, 40], [32, 44, 41], [32, 44, 46], [32, 44, 49], [32, 45, 7], [32, 45, 9], [32, 45, 12], [32, 45, 13], [32, 45, 20], [32, 45, 23], [32, 45, 35], [32, 45, 47], [32, 46, 8], [32, 46, 18], [32, 46, 24], [32, 46, 26], [32, 46, 37], [32, 46, 40], [32, 46, 41], [32, 46, 44], [32, 47, 4], [32, 47, 9], [32, 47, 13], [32, 47, 15], [32, 47, 20], [32, 47, 22], [32, 47, 23], [32, 47, 45], [32, 48, 2], [32, 48, 11], [32, 48, 21], [32, 48, 28], [32, 48, 34], [32, 48, 36], [32, 48, 39], [32, 48, 52], [32, 49, 6], [32, 49, 10], [32, 49, 30], [32, 49, 31], [32, 49, 33], [32, 49, 38], [32, 49, 44], [32, 49, 50], [32, 50, 2], [32, 50, 10], [32, 50, 11], [32, 50, 31], [32, 50, 33], [32, 50, 34], [32, 50, 38], [32, 50, 49], [32, 51, 3], [32, 51, 5], [32, 51, 15], [32, 51, 19], [32, 51, 22], [32, 51, 25], [32, 51, 42], [32, 51, 43], [32, 52, 11], [32, 52, 21], [32, 52, 28], [32, 52, 29], [32, 52, 34], [32, 52, 36], [32, 52, 39], [32, 52, 48], [33, 0, 33], [33, 1, 3], [33, 1, 11], [33, 1, 15], [33, 1, 18], [33, 1, 29], [33, 1, 33], [33, 1, 45], [33, 1, 46], [33, 2, 5], [33, 2, 6], [33, 2, 13], [33, 2, 22], [33, 2, 30], [33, 2, 36], [33, 2, 37], [33, 2, 39], [33, 3, 1], [33, 3, 9], [33, 3, 29], [33, 3, 32], [33, 3, 33], [33, 3, 34], [33, 3, 45], [33, 3, 46], [33, 4, 7], [33, 4, 10], [33, 4, 12], [33, 4, 19], [33, 4, 21], [33, 4, 25], [33, 4, 26], [33, 4, 44], [33, 5, 2], [33, 5, 6], [33, 5, 13], [33, 5, 15], [33, 5, 18], [33, 5, 22], [33, 5, 37], [33, 5, 39], [33, 6, 2], [33, 6, 5], [33, 6, 11], [33, 6, 13], [33, 6, 15], [33, 6, 18], [33, 6, 37], [33, 6, 39], [33, 7, 4], [33, 7, 19], [33, 7, 20], [33, 7, 21], [33, 7, 24], [33, 7, 44], [33, 7, 50], [33, 7, 52], [33, 8, 14], [33, 8, 20], [33, 8, 24], [33, 8, 35], [33, 8, 38], [33, 8, 42], [33, 8, 50], [33, 8, 52], [33, 9, 3], [33, 9, 27], [33, 9, 29], [33, 9, 32], [33, 9, 34], [33, 9, 43], [33, 9, 46], [33, 9, 49], [33, 10, 4], [33, 10, 12], [33, 10, 21], [33, 10, 25], [33, 10, 26], [33, 10, 30], [33, 10, 36], [33, 10, 44], [33, 11, 1], [33, 11, 6], [33, 11, 15], [33, 11, 18], [33, 11, 29], [33, 11, 33], [33, 11, 39], [33, 11, 45], [33, 12, 4], [33, 12, 10], [33, 12, 21], [33, 12, 22], [33, 12, 25], [33, 12, 26], [33, 12, 30], [33, 12, 36], [33, 13, 2], [33, 13, 5], [33, 13, 6], [33, 13, 15], [33, 13, 22], [33, 13, 36], [33, 13, 37], [33, 13, 39], [33, 14, 8], [33, 14, 35], [33, 14, 38], [33, 14, 40], [33, 14, 42], [33, 14, 47], [33, 14, 48], [33, 14, 51], [33, 15, 1], [33, 15, 5], [33, 15, 6], [33, 15, 11], [33, 15, 13], [33, 15, 18], [33, 15, 39], [33, 15, 45], [33, 16, 17], [33, 16, 23], [33, 16, 28], [33, 16, 31], [33, 16, 40], [33, 16, 47], [33, 16, 48], [33, 16, 51], [33, 17, 16], [33, 17, 23], [33, 17, 28], [33, 17, 31], [33, 17, 40], [33, 17, 41], [33, 17, 43], [33, 17, 51], [33, 18, 1], [33, 18, 5], [33, 18, 6], [33, 18, 11], [33, 18, 15], [33, 18, 33], [33, 18, 39], [33, 18, 45], [33, 19, 4], [33, 19, 7], [33, 19, 20], [33, 19, 21], [33, 19, 24], [33, 19, 26], [33, 19, 44], [33, 19, 50], [33, 20, 7], [33, 20, 8], [33, 20, 19], [33, 20, 24], [33, 20, 35], [33, 20, 42], [33, 20, 50], [33, 20, 52], [33, 21, 4], [33, 21, 7], [33, 21, 10], [33, 21, 12], [33, 21, 19], [33, 21, 26], [33, 21, 44], [33, 21, 50], [33, 22, 2], [33, 22, 5], [33, 22, 12], [33, 22, 13], [33, 22, 25], [33, 22, 30], [33, 22, 36], [33, 22, 37], [33, 23, 16], [33, 23, 17], [33, 23, 27], [33, 23, 28], [33, 23, 31], [33, 23, 41], [33, 23, 43], [33, 23, 51], [33, 24, 7], [33, 24, 8], [33, 24, 19], [33, 24, 20], [33, 24, 42], [33, 24, 44], [33, 24, 50], [33, 24, 52], [33, 25, 4], [33, 25, 10], [33, 25, 12], [33, 25, 22], [33, 25, 26], [33, 25, 30], [33, 25, 36], [33, 25, 37], [33, 26, 4], [33, 26, 10], [33, 26, 12], [33, 26, 19], [33, 26, 21], [33, 26, 25], [33, 26, 30], [33, 26, 44], [33, 27, 9], [33, 27, 23], [33, 27, 28], [33, 27, 32], [33, 27, 34], [33, 27, 41], [33, 27, 43], [33, 27, 49], [33, 28, 16], [33, 28, 17], [33, 28, 23], [33, 28, 27], [33, 28, 31], [33, 28, 41], [33, 28, 43], [33, 28, 49], [33, 29, 1], [33, 29, 3], [33, 29, 9], [33, 29, 11], [33, 29, 33], [33, 29, 34], [33, 29, 45], [33, 29, 46], [33, 30, 2], [33, 30, 10], [33, 30, 12], [33, 30, 22], [33, 30, 25], [33, 30, 26], [33, 30, 36], [33, 30, 37], [33, 31, 16], [33, 31, 17], [33, 31, 23], [33, 31, 28], [33, 31, 40], [33, 31, 41], [33, 31, 48], [33, 31, 51], [33, 32, 3], [33, 32, 9], [33, 32, 27], [33, 32, 34], [33, 32, 41], [33, 32, 43], [33, 32, 46], [33, 32, 49], [33, 33, 0], [33, 33, 1], [33, 33, 3], [33, 33, 11], [33, 33, 18], [33, 33, 29], [33, 33, 33], [33, 33, 34], [33, 33, 45], [33, 33, 46], [33, 34, 3], [33, 34, 9], [33, 34, 27], [33, 34, 29], [33, 34, 32], [33, 34, 33], [33, 34, 46], [33, 34, 49], [33, 35, 8], [33, 35, 14], [33, 35, 20], [33, 35, 38], [33, 35, 42], [33, 35, 47], [33, 35, 48], [33, 35, 52], [33, 36, 2], [33, 36, 10], [33, 36, 12], [33, 36, 13], [33, 36, 22], [33, 36, 25], [33, 36, 30], [33, 36, 37], [33, 37, 2], [33, 37, 5], [33, 37, 6], [33, 37, 13], [33, 37, 22], [33, 37, 25], [33, 37, 30], [33, 37, 36], [33, 38, 8], [33, 38, 14], [33, 38, 35], [33, 38, 40], [33, 38, 42], [33, 38, 47], [33, 38, 48], [33, 38, 52], [33, 39, 2], [33, 39, 5], [33, 39, 6], [33, 39, 11], [33, 39, 13], [33, 39, 15], [33, 39, 18], [33, 39, 45], [33, 40, 14], [33, 40, 16], [33, 40, 17], [33, 40, 31], [33, 40, 38], [33, 40, 47], [33, 40, 48], [33, 40, 51], [33, 41, 17], [33, 41, 23], [33, 41, 27], [33, 41, 28], [33, 41, 31], [33, 41, 32], [33, 41, 43], [33, 41, 49], [33, 42, 8], [33, 42, 14], [33, 42, 20], [33, 42, 24], [33, 42, 35], [33, 42, 38], [33, 42, 47], [33, 42, 52], [33, 43, 9], [33, 43, 17], [33, 43, 23], [33, 43, 27], [33, 43, 28], [33, 43, 32], [33, 43, 41], [33, 43, 49], [33, 44, 4], [33, 44, 7], [33, 44, 10], [33, 44, 19], [33, 44, 21], [33, 44, 24], [33, 44, 26], [33, 44, 50], [33, 45, 1], [33, 45, 3], [33, 45, 11], [33, 45, 15], [33, 45, 18], [33, 45, 29], [33, 45, 33], [33, 45, 39], [33, 46, 1], [33, 46, 3], [33, 46, 9], [33, 46, 29], [33, 46, 32], [33, 46, 33], [33, 46, 34], [33, 46, 49], [33, 47, 14], [33, 47, 16], [33, 47, 35], [33, 47, 38], [33, 47, 40], [33, 47, 42], [33, 47, 48], [33, 47, 51], [33, 48, 14], [33, 48, 16], [33, 48, 31], [33, 48, 35], [33, 48, 38], [33, 48, 40], [33, 48, 47], [33, 48, 51], [33, 49, 9], [33, 49, 27], [33, 49, 28], [33, 49, 32], [33, 49, 34], [33, 49, 41], [33, 49, 43], [33, 49, 46], [33, 50, 7], [33, 50, 8], [33, 50, 19], [33, 50, 20], [33, 50, 21], [33, 50, 24], [33, 50, 44], [33, 50, 52], [33, 51, 14], [33, 51, 16], [33, 51, 17], [33, 51, 23], [33, 51, 31], [33, 51, 40], [33, 51, 47], [33, 51, 48], [33, 52, 7], [33, 52, 8], [33, 52, 20], [33, 52, 24], [33, 52, 35], [33, 52, 38], [33, 52, 42], [33, 52, 50], [34, 0, 34], [34, 1, 12], [34, 1, 31], [34, 1, 34], [34, 1, 37], [34, 1, 39], [34, 1, 43], [34, 1, 44], [34, 1, 47], [34, 2, 9], [34, 2, 15], [34, 2, 21], [34, 2, 24], [34, 2, 25], [34, 2, 33], [34, 2, 35], [34, 2, 41], [34, 3, 5], [34, 3, 11], [34, 3, 23], [34, 3, 26], [34, 3, 35], [34, 3, 36], [34, 3, 40], [34, 3, 49], [34, 4, 13], [34, 4, 17], [34, 4, 18], [34, 4, 29], [34, 4, 30], [34, 4, 42], [34, 4, 48], [34, 4, 50], [34, 5, 3], [34, 5, 7], [34, 5, 8], [34, 5, 11], [34, 5, 23], [34, 5, 26], [34, 5, 36], [34, 5, 49], [34, 6, 10], [34, 6, 17], [34, 6, 19], [34, 6, 22], [34, 6, 27], [34, 6, 45], [34, 6, 46], [34, 6, 52], [34, 7, 5], [34, 7, 8], [34, 7, 11], [34, 7, 26], [34, 7, 31], [34, 7, 36], [34, 7, 43], [34, 7, 47], [34, 8, 5], [34, 8, 7], [34, 8, 26], [34, 8, 31], [34, 8, 34], [34, 8, 36], [34, 8, 43], [34, 8, 47], [34, 9, 2], [34, 9, 14], [34, 9, 15], [34, 9, 16], [34, 9, 25], [34, 9, 33], [34, 9, 41], [34, 9, 52], [34, 10, 6], [34, 10, 14], [34, 10, 16], [34, 10, 19], [34, 10, 22], [34, 10, 45], [34, 10, 46], [34, 10, 52], [34, 11, 3], [34, 11, 5], [34, 11, 7], [34, 11, 23], [34, 11, 26], [34, 11, 36], [34, 11, 40], [34, 11, 49], [34, 12, 1], [34, 12, 20], [34, 12, 34], [34, 12, 37], [34, 12, 38], [34, 12, 39], [34, 12, 44], [34, 12, 51], [34, 13, 4], [34, 13, 18], [34, 13, 28], [34, 13, 29], [34, 13, 30], [34, 13, 32], [34, 13, 42], [34, 13, 50], [34, 14, 9], [34, 14, 10], [34, 14, 16], [34, 14, 19], [34, 14, 22], [34, 14, 33], [34, 14, 41], [34, 14, 52], [34, 15, 2], [34, 15, 9], [34, 15, 16], [34, 15, 21], [34, 15, 24], [34, 15, 25], [34, 15, 33], [34, 15, 41], [34, 16, 9], [34, 16, 10], [34, 16, 14], [34, 16, 15], [34, 16, 19], [34, 16, 33], [34, 16, 41], [34, 16, 52], [34, 17, 4], [34, 17, 6], [34, 17, 27], [34, 17, 42], [34, 17, 45], [34, 17, 46], [34, 17, 48], [34, 17, 50], [34, 18, 4], [34, 18, 13], [34, 18, 28], [34, 18, 29], [34, 18, 30], [34, 18, 32], [34, 18, 50], [34, 18, 51], [34, 19, 6], [34, 19, 10], [34, 19, 14], [34, 19, 16], [34, 19, 22], [34, 19, 41], [34, 19, 45], [34, 19, 52], [34, 20, 12], [34, 20, 28], [34, 20, 32], [34, 20, 37], [34, 20, 38], [34, 20, 39], [34, 20, 44], [34, 20, 51], [34, 21, 2], [34, 21, 15], [34, 21, 23], [34, 21, 24], [34, 21, 25], [34, 21, 33], [34, 21, 35], [34, 21, 40], [34, 22, 6], [34, 22, 10], [34, 22, 14], [34, 22, 19], [34, 22, 27], [34, 22, 45], [34, 22, 46], [34, 22, 52], [34, 23, 3], [34, 23, 5], [34, 23, 11], [34, 23, 21], [34, 23, 24], [34, 23, 35], [34, 23, 40], [34, 23, 49], [34, 24, 2], [34, 24, 15], [34, 24, 21], [34, 24, 23], [34, 24, 25], [34, 24, 35], [34, 24, 40], [34, 24, 49], [34, 25, 2], [34, 25, 9], [34, 25, 15], [34, 25, 21], [34, 25, 24], [34, 25, 33], [34, 25, 35], [34, 25, 40], [34, 26, 3], [34, 26, 5], [34, 26, 7], [34, 26, 8], [34, 26, 11], [34, 26, 31], [34, 26, 36], [34, 26, 47], [34, 27, 6], [34, 27, 17], [34, 27, 22], [34, 27, 42], [34, 27, 45], [34, 27, 46], [34, 27, 48], [34, 27, 50], [34, 28, 13], [34, 28, 18], [34, 28, 20], [34, 28, 29], [34, 28, 32], [34, 28, 38], [34, 28, 44], [34, 28, 51], [34, 29, 4], [34, 29, 13], [34, 29, 18], [34, 29, 28], [34, 29, 30], [34, 29, 32], [34, 29, 38], [34, 29, 51], [34, 30, 4], [34, 30, 13], [34, 30, 18], [34, 30, 29], [34, 30, 32], [34, 30, 42], [34, 30, 48], [34, 30, 50], [34, 31, 1], [34, 31, 7], [34, 31, 8], [34, 31, 26], [34, 31, 34], [34, 31, 39], [34, 31, 43], [34, 31, 47], [34, 32, 13], [34, 32, 18], [34, 32, 20], [34, 32, 28], [34, 32, 29], [34, 32, 30], [34, 32, 38], [34, 32, 51], [34, 33, 2], [34, 33, 9], [34, 33, 14], [34, 33, 15], [34, 33, 16], [34, 33, 21], [34, 33, 25], [34, 33, 41], [34, 34, 0], [34, 34, 1], [34, 34, 8], [34, 34, 12], [34, 34, 31], [34, 34, 34], [34, 34, 37], [34, 34, 39], [34, 34, 43], [34, 34, 47], [34, 35, 2], [34, 35, 3], [34, 35, 21], [34, 35, 23], [34, 35, 24], [34, 35, 25], [34, 35, 40], [34, 35, 49], [34, 36, 3], [34, 36, 5], [34, 36, 7], [34, 36, 8], [34, 36, 11], [34, 36, 26], [34, 36, 47], [34, 36, 49], [34, 37, 1], [34, 37, 12], [34, 37, 20], [34, 37, 34], [34, 37, 38], [34, 37, 39], [34, 37, 43], [34, 37, 44], [34, 38, 12], [34, 38, 20], [34, 38, 28], [34, 38, 29], [34, 38, 32], [34, 38, 37], [34, 38, 44], [34, 38, 51], [34, 39, 1], [34, 39, 12], [34, 39, 20], [34, 39, 31], [34, 39, 34], [34, 39, 37], [34, 39, 43], [34, 39, 44], [34, 40, 3], [34, 40, 11], [34, 40, 21], [34, 40, 23], [34, 40, 24], [34, 40, 25], [34, 40, 35], [34, 40, 49], [34, 41, 2], [34, 41, 9], [34, 41, 14], [34, 41, 15], [34, 41, 16], [34, 41, 19], [34, 41, 33], [34, 41, 52], [34, 42, 4], [34, 42, 13], [34, 42, 17], [34, 42, 27], [34, 42, 30], [34, 42, 46], [34, 42, 48], [34, 42, 50], [34, 43, 1], [34, 43, 7], [34, 43, 8], [34, 43, 31], [34, 43, 34], [34, 43, 37], [34, 43, 39], [34, 43, 47], [34, 44, 1], [34, 44, 12], [34, 44, 20], [34, 44, 28], [34, 44, 37], [34, 44, 38], [34, 44, 39], [34, 44, 51], [34, 45, 6], [34, 45, 10], [34, 45, 17], [34, 45, 19], [34, 45, 22], [34, 45, 27], [34, 45, 46], [34, 45, 48], [34, 46, 6], [34, 46, 10], [34, 46, 17], [34, 46, 22], [34, 46, 27], [34, 46, 42], [34, 46, 45], [34, 46, 48], [34, 47, 1], [34, 47, 7], [34, 47, 8], [34, 47, 26], [34, 47, 31], [34, 47, 34], [34, 47, 36], [34, 47, 43], [34, 48, 4], [34, 48, 17], [34, 48, 27], [34, 48, 30], [34, 48, 42], [34, 48, 45], [34, 48, 46], [34, 48, 50], [34, 49, 3], [34, 49, 5], [34, 49, 11], [34, 49, 23], [34, 49, 24], [34, 49, 35], [34, 49, 36], [34, 49, 40], [34, 50, 4], [34, 50, 13], [34, 50, 17], [34, 50, 18], [34, 50, 27], [34, 50, 30], [34, 50, 42], [34, 50, 48], [34, 51, 12], [34, 51, 18], [34, 51, 20], [34, 51, 28], [34, 51, 29], [34, 51, 32], [34, 51, 38], [34, 51, 44], [34, 52, 6], [34, 52, 9], [34, 52, 10], [34, 52, 14], [34, 52, 16], [34, 52, 19], [34, 52, 22], [34, 52, 41], [35, 0, 35], [35, 1, 6], [35, 1, 9], [35, 1, 26], [35, 1, 28], [35, 1, 35], [35, 1, 36], [35, 1, 50], [35, 1, 51], [35, 2, 3], [35, 2, 12], [35, 2, 17], [35, 2, 18], [35, 2, 19], [35, 2, 47], [35, 2, 49], [35, 2, 52], [35, 3, 2], [35, 3, 18], [35, 3, 25], [35, 3, 27], [35, 3, 31], [35, 3, 44], [35, 3, 47], [35, 3, 52], [35, 4, 6], [35, 4, 24], [35, 4, 34], [35, 4, 36], [35, 4, 38], [35, 4, 41], [35, 4, 45], [35, 4, 51], [35, 5, 16], [35, 5, 21], [35, 5, 24], [35, 5, 30], [35, 5, 34], [35, 5, 38], [35, 5, 43], [35, 5, 45], [35, 6, 1], [35, 6, 4], [35, 6, 9], [35, 6, 35], [35, 6, 36], [35, 6, 41], [35, 6, 50], [35, 6, 51], [35, 7, 10], [35, 7, 23], [35, 7, 32], [35, 7, 33], [35, 7, 37], [35, 7, 39], [35, 7, 40], [35, 7, 42], [35, 8, 12], [35, 8, 15], [35, 8, 19], [35, 8, 23], [35, 8, 29], [35, 8, 37], [35, 8, 48], [35, 8, 49], [35, 9, 1], [35, 9, 6], [35, 9, 22], [35, 9, 26], [35, 9, 28], [35, 9, 35], [35, 9, 40], [35, 9, 50], [35, 10, 7], [35, 10, 15], [35, 10, 23], [35, 10, 32], [35, 10, 33], [35, 10, 37], [35, 10, 42], [35, 10, 48], [35, 11, 13], [35, 11, 14], [35, 11, 20], [35, 11, 21], [35, 11, 25], [35, 11, 31], [35, 11, 43], [35, 11, 46], [35, 12, 2], [35, 12, 8], [35, 12, 17], [35, 12, 18], [35, 12, 19], [35, 12, 29], [35, 12, 47], [35, 12, 49], [35, 13, 11], [35, 13, 14], [35, 13, 20], [35, 13, 25], [35, 13, 27], [35, 13, 31], [35, 13, 44], [35, 13, 46], [35, 14, 11], [35, 14, 13], [35, 14, 20], [35, 14, 21], [35, 14, 25], [35, 14, 27], [35, 14, 31], [35, 14, 46], [35, 15, 8], [35, 15, 10], [35, 15, 19], [35, 15, 23], [35, 15, 29], [35, 15, 37], [35, 15, 48], [35, 15, 49], [35, 16, 5], [35, 16, 21], [35, 16, 24], [35, 16, 30], [35, 16, 38], [35, 16, 43], [35, 16, 45], [35, 16, 46], [35, 17, 2], [35, 17, 12], [35, 17, 18], [35, 17, 19], [35, 17, 29], [35, 17, 47], [35, 17, 49], [35, 17, 52], [35, 18, 2], [35, 18, 3], [35, 18, 12], [35, 18, 17], [35, 18, 27], [35, 18, 44], [35, 18, 47], [35, 18, 52], [35, 19, 2], [35, 19, 8], [35, 19, 12], [35, 19, 15], [35, 19, 17], [35, 19, 29], [35, 19, 48], [35, 19, 49], [35, 20, 11], [35, 20, 13], [35, 20, 14], [35, 20, 21], [35, 20, 30], [35, 20, 31], [35, 20, 43], [35, 20, 46], [35, 21, 5], [35, 21, 11], [35, 21, 14], [35, 21, 16], [35, 21, 20], [35, 21, 30], [35, 21, 43], [35, 21, 46], [35, 22, 9], [35, 22, 26], [35, 22, 28], [35, 22, 33], [35, 22, 39], [35, 22, 40], [35, 22, 42], [35, 22, 50], [35, 23, 7], [35, 23, 8], [35, 23, 10], [35, 23, 15], [35, 23, 32], [35, 23, 33], [35, 23, 37], [35, 23, 48], [35, 24, 4], [35, 24, 5], [35, 24, 16], [35, 24, 34], [35, 24, 36], [35, 24, 38], [35, 24, 41], [35, 24, 45], [35, 25, 3], [35, 25, 11], [35, 25, 13], [35, 25, 14], [35, 25, 27], [35, 25, 31], [35, 25, 44], [35, 25, 52], [35, 26, 1], [35, 26, 9], [35, 26, 22], [35, 26, 28], [35, 26, 35], [35, 26, 39], [35, 26, 40], [35, 26, 50], [35, 27, 3], [35, 27, 13], [35, 27, 14], [35, 27, 18], [35, 27, 25], [35, 27, 31], [35, 27, 44], [35, 27, 52], [35, 28, 1], [35, 28, 9], [35, 28, 22], [35, 28, 26], [35, 28, 39], [35, 28, 40], [35, 28, 42], [35, 28, 50], [35, 29, 8], [35, 29, 12], [35, 29, 15], [35, 29, 17], [35, 29, 19], [35, 29, 37], [35, 29, 48], [35, 29, 49], [35, 30, 5], [35, 30, 16], [35, 30, 20], [35, 30, 21], [35, 30, 38], [35, 30, 43], [35, 30, 45], [35, 30, 46], [35, 31, 3], [35, 31, 11], [35, 31, 13], [35, 31, 14], [35, 31, 20], [35, 31, 25], [35, 31, 27], [35, 31, 44], [35, 32, 7], [35, 32, 10], [35, 32, 23], [35, 32, 33], [35, 32, 37], [35, 32, 39], [35, 32, 42], [35, 32, 48], [35, 33, 7], [35, 33, 10], [35, 33, 22], [35, 33, 23], [35, 33, 32], [35, 33, 39], [35, 33, 40], [35, 33, 42], [35, 34, 4], [35, 34, 5], [35, 34, 24], [35, 34, 36], [35, 34, 38], [35, 34, 41], [35, 34, 45], [35, 34, 51], [35, 35, 0], [35, 35, 1], [35, 35, 6], [35, 35, 9], [35, 35, 26], [35, 35, 35], [35, 35, 36], [35, 35, 41], [35, 35, 50], [35, 35, 51], [35, 36, 1], [35, 36, 4], [35, 36, 6], [35, 36, 24], [35, 36, 34], [35, 36, 35], [35, 36, 41], [35, 36, 51], [35, 37, 7], [35, 37, 8], [35, 37, 10], [35, 37, 15], [35, 37, 23], [35, 37, 29], [35, 37, 32], [35, 37, 48], [35, 38, 4], [35, 38, 5], [35, 38, 16], [35, 38, 24], [35, 38, 30], [35, 38, 34], [35, 38, 43], [35, 38, 45], [35, 39, 7], [35, 39, 22], [35, 39, 26], [35, 39, 28], [35, 39, 32], [35, 39, 33], [35, 39, 40], [35, 39, 42], [35, 40, 7], [35, 40, 9], [35, 40, 22], [35, 40, 26], [35, 40, 28], [35, 40, 33], [35, 40, 39], [35, 40, 42], [35, 41, 4], [35, 41, 6], [35, 41, 24], [35, 41, 34], [35, 41, 35], [35, 41, 36], [35, 41, 45], [35, 41, 51], [35, 42, 7], [35, 42, 10], [35, 42, 22], [35, 42, 28], [35, 42, 32], [35, 42, 33], [35, 42, 39], [35, 42, 40], [35, 43, 5], [35, 43, 11], [35, 43, 16], [35, 43, 20], [35, 43, 21], [35, 43, 30], [35, 43, 38], [35, 43, 46], [35, 44, 3], [35, 44, 13], [35, 44, 18], [35, 44, 25], [35, 44, 27], [35, 44, 31], [35, 44, 47], [35, 44, 52], [35, 45, 4], [35, 45, 5], [35, 45, 16], [35, 45, 24], [35, 45, 30], [35, 45, 34], [35, 45, 38], [35, 45, 41], [35, 46, 11], [35, 46, 13], [35, 46, 14], [35, 46, 16], [35, 46, 20], [35, 46, 21], [35, 46, 30], [35, 46, 43], [35, 47, 2], [35, 47, 3], [35, 47, 12], [35, 47, 17], [35, 47, 18], [35, 47, 44], [35, 47, 49], [35, 47, 52], [35, 48, 8], [35, 48, 10], [35, 48, 15], [35, 48, 19], [35, 48, 23], [35, 48, 29], [35, 48, 32], [35, 48, 37], [35, 49, 2], [35, 49, 8], [35, 49, 12], [35, 49, 15], [35, 49, 17], [35, 49, 19], [35, 49, 29], [35, 49, 47], [35, 50, 1], [35, 50, 6], [35, 50, 9], [35, 50, 22], [35, 50, 26], [35, 50, 28], [35, 50, 35], [35, 50, 51], [35, 51, 1], [35, 51, 4], [35, 51, 6], [35, 51, 34], [35, 51, 35], [35, 51, 36], [35, 51, 41], [35, 51, 50], [35, 52, 2], [35, 52, 3], [35, 52, 17], [35, 52, 18], [35, 52, 25], [35, 52, 27], [35, 52, 44], [35, 52, 47], [36, 0, 36], [36, 1, 10], [36, 1, 15], [36, 1, 16], [36, 1, 24], [36, 1, 28], [36, 1, 36], [36, 1, 42], [36, 1, 46], [36, 10, 1], [36, 10, 15], [36, 10, 28], [36, 10, 36], [36, 10, 42], [36, 10, 44], [36, 10, 47], [36, 10, 49], [36, 13, 15], [36, 13, 16], [36, 13, 24], [36, 13, 36], [36, 13, 44], [36, 13, 46], [36, 13, 47], [36, 13, 49], [36, 15, 1], [36, 15, 10], [36, 15, 13], [36, 15, 28], [36, 15, 42], [36, 15, 44], [36, 15, 47], [36, 15, 49], [36, 16, 1], [36, 16, 13], [36, 16, 24], [36, 16, 28], [36, 16, 36], [36, 16, 44], [36, 16, 46], [36, 16, 47], [36, 24, 1], [36, 24, 13], [36, 24, 16], [36, 24, 28], [36, 24, 36], [36, 24, 42], [36, 24, 44], [36, 24, 46], [36, 28, 1], [36, 28, 10], [36, 28, 15], [36, 28, 16], [36, 28, 24], [36, 28, 36], [36, 28, 42], [36, 28, 49], [36, 36, 0], [36, 36, 1], [36, 36, 10], [36, 36, 13], [36, 36, 16], [36, 36, 24], [36, 36, 28], [36, 36, 36], [36, 36, 42], [36, 36, 46], [36, 42, 1], [36, 42, 10], [36, 42, 15], [36, 42, 24], [36, 42, 28], [36, 42, 36], [36, 42, 47], [36, 42, 49], [36, 44, 10], [36, 44, 13], [36, 44, 15], [36, 44, 16], [36, 44, 24], [36, 44, 46], [36, 44, 47], [36, 44, 49], [36, 46, 1], [36, 46, 13], [36, 46, 16], [36, 46, 24], [36, 46, 36], [36, 46, 44], [36, 46, 47], [36, 46, 49], [36, 47, 10], [36, 47, 13], [36, 47, 15], [36, 47, 16], [36, 47, 42], [36, 47, 44], [36, 47, 46], [36, 47, 49], [36, 49, 10], [36, 49, 13], [36, 49, 15], [36, 49, 28], [36, 49, 42], [36, 49, 44], [36, 49, 46], [36, 49, 47], [37, 0, 37], [37, 1, 7], [37, 1, 28], [37, 1, 36], [37, 1, 37], [37, 1, 38], [37, 1, 43], [37, 1, 44], [37, 1, 47], [37, 4, 6], [37, 4, 13], [37, 4, 17], [37, 4, 28], [37, 4, 29], [37, 4, 38], [37, 4, 42], [37, 4, 46], [37, 6, 4], [37, 6, 9], [37, 6, 10], [37, 6, 16], [37, 6, 17], [37, 6, 42], [37, 6, 46], [37, 6, 52], [37, 7, 1], [37, 7, 11], [37, 7, 36], [37, 7, 37], [37, 7, 40], [37, 7, 43], [37, 7, 47], [37, 7, 49], [37, 9, 6], [37, 9, 10], [37, 9, 15], [37, 9, 16], [37, 9, 24], [37, 9, 25], [37, 9, 40], [37, 9, 52], [37, 10, 6], [37, 10, 9], [37, 10, 15], [37, 10, 16], [37, 10, 17], [37, 10, 42], [37, 10, 46], [37, 10, 52], [37, 11, 7], [37, 11, 24], [37, 11, 25], [37, 11, 36], [37, 11, 40], [37, 11, 43], [37, 11, 47], [37, 11, 49], [37, 13, 4], [37, 13, 17], [37, 13, 28], [37, 13, 29], [37, 13, 38], [37, 13, 42], [37, 13, 44], [37, 13, 46], [37, 15, 9], [37, 15, 10], [37, 15, 16], [37, 15, 24], [37, 15, 25], [37, 15, 40], [37, 15, 49], [37, 15, 52], [37, 16, 6], [37, 16, 9], [37, 16, 10], [37, 16, 15], [37, 16, 24], [37, 16, 25], [37, 16, 46], [37, 16, 52], [37, 17, 4], [37, 17, 6], [37, 17, 10], [37, 17, 13], [37, 17, 29], [37, 17, 42], [37, 17, 46], [37, 17, 52], [37, 24, 9], [37, 24, 11], [37, 24, 15], [37, 24, 16], [37, 24, 25], [37, 24, 36], [37, 24, 40], [37, 24, 49], [37, 25, 9], [37, 25, 11], [37, 25, 15], [37, 25, 16], [37, 25, 24], [37, 25, 40], [37, 25, 49], [37, 25, 52], [37, 28, 1], [37, 28, 4], [37, 28, 13], [37, 28, 29], [37, 28, 37], [37, 28, 38], [37, 28, 42], [37, 28, 44], [37, 29, 4], [37, 29, 13], [37, 29, 17], [37, 29, 28], [37, 29, 37], [37, 29, 38], [37, 29, 42], [37, 29, 44], [37, 36, 1], [37, 36, 7], [37, 36, 11], [37, 36, 24], [37, 36, 40], [37, 36, 43], [37, 36, 47], [37, 36, 49], [37, 37, 0], [37, 37, 1], [37, 37, 7], [37, 37, 28], [37, 37, 29], [37, 37, 37], [37, 37, 38], [37, 37, 43], [37, 37, 44], [37, 37, 47], [37, 38, 1], [37, 38, 4], [37, 38, 13], [37, 38, 28], [37, 38, 29], [37, 38, 37], [37, 38, 43], [37, 38, 44], [37, 40, 7], [37, 40, 9], [37, 40, 11], [37, 40, 15], [37, 40, 24], [37, 40, 25], [37, 40, 36], [37, 40, 49], [37, 42, 4], [37, 42, 6], [37, 42, 10], [37, 42, 13], [37, 42, 17], [37, 42, 28], [37, 42, 29], [37, 42, 46], [37, 43, 1], [37, 43, 7], [37, 43, 11], [37, 43, 36], [37, 43, 37], [37, 43, 38], [37, 43, 44], [37, 43, 47], [37, 44, 1], [37, 44, 13], [37, 44, 28], [37, 44, 29], [37, 44, 37], [37, 44, 38], [37, 44, 43], [37, 44, 47], [37, 46, 4], [37, 46, 6], [37, 46, 10], [37, 46, 13], [37, 46, 16], [37, 46, 17], [37, 46, 42], [37, 46, 52], [37, 47, 1], [37, 47, 7], [37, 47, 11], [37, 47, 36], [37, 47, 37], [37, 47, 43], [37, 47, 44], [37, 47, 49], [37, 49, 7], [37, 49, 11], [37, 49, 15], [37, 49, 24], [37, 49, 25], [37, 49, 36], [37, 49, 40], [37, 49, 47], [37, 52, 6], [37, 52, 9], [37, 52, 10], [37, 52, 15], [37, 52, 16], [37, 52, 17], [37, 52, 25], [37, 52, 46], [38, 0, 38], [38, 1, 7], [38, 1, 10], [38, 1, 13], [38, 1, 16], [38, 1, 17], [38, 1, 25], [38, 1, 38], [38, 1, 49], [38, 4, 11], [38, 4, 15], [38, 4, 28], [38, 4, 37], [38, 4, 40], [38, 4, 46], [38, 4, 47], [38, 4, 52], [38, 6, 7], [38, 6, 16], [38, 6, 25], [38, 6, 29], [38, 6, 42], [38, 6, 43], [38, 6, 44], [38, 6, 49], [38, 7, 1], [38, 7, 6], [38, 7, 13], [38, 7, 16], [38, 7, 17], [38, 7, 25], [38, 7, 38], [38, 7, 49], [38, 9, 10], [38, 9, 11], [38, 9, 13], [38, 9, 17], [38, 9, 24], [38, 9, 37], [38, 9, 38], [38, 9, 47], [38, 10, 1], [38, 10, 9], [38, 10, 11], [38, 10, 13], [38, 10, 17], [38, 10, 24], [38, 10, 38], [38, 10, 47], [38, 11, 4], [38, 11, 9], [38, 11, 10], [38, 11, 17], [38, 11, 24], [38, 11, 28], [38, 11, 37], [38, 11, 47], [38, 13, 1], [38, 13, 7], [38, 13, 9], [38, 13, 10], [38, 13, 17], [38, 13, 24], [38, 13, 38], [38, 13, 49], [38, 15, 4], [38, 15, 28], [38, 15, 36], [38, 15, 40], [38, 15, 43], [38, 15, 44], [38, 15, 46], [38, 15, 52], [38, 16, 1], [38, 16, 6], [38, 16, 7], [38, 16, 25], [38, 16, 29], [38, 16, 42], [38, 16, 44], [38, 16, 49], [38, 17, 1], [38, 17, 7], [38, 17, 9], [38, 17, 10], [38, 17, 11], [38, 17, 13], [38, 17, 24], [38, 17, 38], [38, 24, 9], [38, 24, 10], [38, 24, 11], [38, 24, 13], [38, 24, 17], [38, 24, 28], [38, 24, 37], [38, 24, 47], [38, 25, 1], [38, 25, 6], [38, 25, 7], [38, 25, 16], [38, 25, 29], [38, 25, 38], [38, 25, 42], [38, 25, 49], [38, 28, 4], [38, 28, 11], [38, 28, 15], [38, 28, 24], [38, 28, 37], [38, 28, 46], [38, 28, 47], [38, 28, 52], [38, 29, 6], [38, 29, 16], [38, 29, 25], [38, 29, 36], [38, 29, 40], [38, 29, 42], [38, 29, 43], [38, 29, 44], [38, 36, 15], [38, 36, 29], [38, 36, 40], [38, 36, 42], [38, 36, 43], [38, 36, 44], [38, 36, 46], [38, 36, 52], [38, 37, 4], [38, 37, 9], [38, 37, 11], [38, 37, 24], [38, 37, 28], [38, 37, 46], [38, 37, 47], [38, 37, 52], [38, 38, 0], [38, 38, 1], [38, 38, 7], [38, 38, 9], [38, 38, 10], [38, 38, 13], [38, 38, 17], [38, 38, 25], [38, 38, 38], [38, 38, 49], [38, 40, 4], [38, 40, 15], [38, 40, 29], [38, 40, 36], [38, 40, 43], [38, 40, 44], [38, 40, 46], [38, 40, 52], [38, 42, 6], [38, 42, 16], [38, 42, 25], [38, 42, 29], [38, 42, 36], [38, 42, 43], [38, 42, 44], [38, 42, 49], [38, 43, 6], [38, 43, 15], [38, 43, 29], [38, 43, 36], [38, 43, 40], [38, 43, 42], [38, 43, 44], [38, 43, 52], [38, 44, 6], [38, 44, 15], [38, 44, 16], [38, 44, 29], [38, 44, 36], [38, 44, 40], [38, 44, 42], [38, 44, 43], [38, 46, 4], [38, 46, 15], [38, 46, 28], [38, 46, 36], [38, 46, 37], [38, 46, 40], [38, 46, 47], [38, 46, 52], [38, 47, 4], [38, 47, 9], [38, 47, 10], [38, 47, 11], [38, 47, 24], [38, 47, 28], [38, 47, 37], [38, 47, 46], [38, 49, 1], [38, 49, 6], [38, 49, 7], [38, 49, 13], [38, 49, 16], [38, 49, 25], [38, 49, 38], [38, 49, 42], [38, 52, 4], [38, 52, 15], [38, 52, 28], [38, 52, 36], [38, 52, 37], [38, 52, 40], [38, 52, 43], [38, 52, 46], [39, 0, 39], [39, 1, 12], [39, 1, 31], [39, 1, 34], [39, 1, 37], [39, 1, 39], [39, 1, 43], [39, 1, 44], [39, 1, 47], [39, 2, 9], [39, 2, 15], [39, 2, 21], [39, 2, 24], [39, 2, 25], [39, 2, 33], [39, 2, 35], [39, 2, 41], [39, 3, 5], [39, 3, 11], [39, 3, 23], [39, 3, 26], [39, 3, 35], [39, 3, 36], [39, 3, 40], [39, 3, 49], [39, 4, 13], [39, 4, 17], [39, 4, 18], [39, 4, 29], [39, 4, 30], [39, 4, 42], [39, 4, 48], [39, 4, 50], [39, 5, 3], [39, 5, 7], [39, 5, 8], [39, 5, 11], [39, 5, 23], [39, 5, 26], [39, 5, 36], [39, 5, 49], [39, 6, 10], [39, 6, 17], [39, 6, 19], [39, 6, 22], [39, 6, 27], [39, 6, 45], [39, 6, 46], [39, 6, 52], [39, 7, 5], [39, 7, 8], [39, 7, 11], [39, 7, 26], [39, 7, 31], [39, 7, 36], [39, 7, 43], [39, 7, 47], [39, 8, 5], [39, 8, 7], [39, 8, 26], [39, 8, 31], [39, 8, 34], [39, 8, 36], [39, 8, 43], [39, 8, 47], [39, 9, 2], [39, 9, 14], [39, 9, 15], [39, 9, 16], [39, 9, 25], [39, 9, 33], [39, 9, 41], [39, 9, 52], [39, 10, 6], [39, 10, 14], [39, 10, 16], [39, 10, 19], [39, 10, 22], [39, 10, 45], [39, 10, 46], [39, 10, 52], [39, 11, 3], [39, 11, 5], [39, 11, 7], [39, 11, 23], [39, 11, 26], [39, 11, 36], [39, 11, 40], [39, 11, 49], [39, 12, 1], [39, 12, 20], [39, 12, 34], [39, 12, 37], [39, 12, 38], [39, 12, 39], [39, 12, 44], [39, 12, 51], [39, 13, 4], [39, 13, 18], [39, 13, 28], [39, 13, 29], [39, 13, 30], [39, 13, 32], [39, 13, 42], [39, 13, 50], [39, 14, 9], [39, 14, 10], [39, 14, 16], [39, 14, 19], [39, 14, 22], [39, 14, 33], [39, 14, 41], [39, 14, 52], [39, 15, 2], [39, 15, 9], [39, 15, 16], [39, 15, 21], [39, 15, 24], [39, 15, 25], [39, 15, 33], [39, 15, 41], [39, 16, 9], [39, 16, 10], [39, 16, 14], [39, 16, 15], [39, 16, 19], [39, 16, 33], [39, 16, 41], [39, 16, 52], [39, 17, 4], [39, 17, 6], [39, 17, 27], [39, 17, 42], [39, 17, 45], [39, 17, 46], [39, 17, 48], [39, 17, 50], [39, 18, 4], [39, 18, 13], [39, 18, 28], [39, 18, 29], [39, 18, 30], [39, 18, 32], [39, 18, 50], [39, 18, 51], [39, 19, 6], [39, 19, 10], [39, 19, 14], [39, 19, 16], [39, 19, 22], [39, 19, 41], [39, 19, 45], [39, 19, 52], [39, 20, 12], [39, 20, 28], [39, 20, 32], [39, 20, 37], [39, 20, 38], [39, 20, 39], [39, 20, 44], [39, 20, 51], [39, 21, 2], [39, 21, 15], [39, 21, 23], [39, 21, 24], [39, 21, 25], [39, 21, 33], [39, 21, 35], [39, 21, 40], [39, 22, 6], [39, 22, 10], [39, 22, 14], [39, 22, 19], [39, 22, 27], [39, 22, 45], [39, 22, 46], [39, 22, 52], [39, 23, 3], [39, 23, 5], [39, 23, 11], [39, 23, 21], [39, 23, 24], [39, 23, 35], [39, 23, 40], [39, 23, 49], [39, 24, 2], [39, 24, 15], [39, 24, 21], [39, 24, 23], [39, 24, 25], [39, 24, 35], [39, 24, 40], [39, 24, 49], [39, 25, 2], [39, 25, 9], [39, 25, 15], [39, 25, 21], [39, 25, 24], [39, 25, 33], [39, 25, 35], [39, 25, 40], [39, 26, 3], [39, 26, 5], [39, 26, 7], [39, 26, 8], [39, 26, 11], [39, 26, 31], [39, 26, 36], [39, 26, 47], [39, 27, 6], [39, 27, 17], [39, 27, 22], [39, 27, 42], [39, 27, 45], [39, 27, 46], [39, 27, 48], [39, 27, 50], [39, 28, 13], [39, 28, 18], [39, 28, 20], [39, 28, 29], [39, 28, 32], [39, 28, 38], [39, 28, 44], [39, 28, 51], [39, 29, 4], [39, 29, 13], [39, 29, 18], [39, 29, 28], [39, 29, 30], [39, 29, 32], [39, 29, 38], [39, 29, 51], [39, 30, 4], [39, 30, 13], [39, 30, 18], [39, 30, 29], [39, 30, 32], [39, 30, 42], [39, 30, 48], [39, 30, 50], [39, 31, 1], [39, 31, 7], [39, 31, 8], [39, 31, 26], [39, 31, 34], [39, 31, 39], [39, 31, 43], [39, 31, 47], [39, 32, 13], [39, 32, 18], [39, 32, 20], [39, 32, 28], [39, 32, 29], [39, 32, 30], [39, 32, 38], [39, 32, 51], [39, 33, 2], [39, 33, 9], [39, 33, 14], [39, 33, 15], [39, 33, 16], [39, 33, 21], [39, 33, 25], [39, 33, 41], [39, 34, 1], [39, 34, 8], [39, 34, 12], [39, 34, 31], [39, 34, 37], [39, 34, 39], [39, 34, 43], [39, 34, 47], [39, 35, 2], [39, 35, 3], [39, 35, 21], [39, 35, 23], [39, 35, 24], [39, 35, 25], [39, 35, 40], [39, 35, 49], [39, 36, 3], [39, 36, 5], [39, 36, 7], [39, 36, 8], [39, 36, 11], [39, 36, 26], [39, 36, 47], [39, 36, 49], [39, 37, 1], [39, 37, 12], [39, 37, 20], [39, 37, 34], [39, 37, 38], [39, 37, 39], [39, 37, 43], [39, 37, 44], [39, 38, 12], [39, 38, 20], [39, 38, 28], [39, 38, 29], [39, 38, 32], [39, 38, 37], [39, 38, 44], [39, 38, 51], [39, 39, 0], [39, 39, 1], [39, 39, 12], [39, 39, 20], [39, 39, 31], [39, 39, 34], [39, 39, 37], [39, 39, 39], [39, 39, 43], [39, 39, 44], [39, 40, 3], [39, 40, 11], [39, 40, 21], [39, 40, 23], [39, 40, 24], [39, 40, 25], [39, 40, 35], [39, 40, 49], [39, 41, 2], [39, 41, 9], [39, 41, 14], [39, 41, 15], [39, 41, 16], [39, 41, 19], [39, 41, 33], [39, 41, 52], [39, 42, 4], [39, 42, 13], [39, 42, 17], [39, 42, 27], [39, 42, 30], [39, 42, 46], [39, 42, 48], [39, 42, 50], [39, 43, 1], [39, 43, 7], [39, 43, 8], [39, 43, 31], [39, 43, 34], [39, 43, 37], [39, 43, 39], [39, 43, 47], [39, 44, 1], [39, 44, 12], [39, 44, 20], [39, 44, 28], [39, 44, 37], [39, 44, 38], [39, 44, 39], [39, 44, 51], [39, 45, 6], [39, 45, 10], [39, 45, 17], [39, 45, 19], [39, 45, 22], [39, 45, 27], [39, 45, 46], [39, 45, 48], [39, 46, 6], [39, 46, 10], [39, 46, 17], [39, 46, 22], [39, 46, 27], [39, 46, 42], [39, 46, 45], [39, 46, 48], [39, 47, 1], [39, 47, 7], [39, 47, 8], [39, 47, 26], [39, 47, 31], [39, 47, 34], [39, 47, 36], [39, 47, 43], [39, 48, 4], [39, 48, 17], [39, 48, 27], [39, 48, 30], [39, 48, 42], [39, 48, 45], [39, 48, 46], [39, 48, 50], [39, 49, 3], [39, 49, 5], [39, 49, 11], [39, 49, 23], [39, 49, 24], [39, 49, 35], [39, 49, 36], [39, 49, 40], [39, 50, 4], [39, 50, 13], [39, 50, 17], [39, 50, 18], [39, 50, 27], [39, 50, 30], [39, 50, 42], [39, 50, 48], [39, 51, 12], [39, 51, 18], [39, 51, 20], [39, 51, 28], [39, 51, 29], [39, 51, 32], [39, 51, 38], [39, 51, 44], [39, 52, 6], [39, 52, 9], [39, 52, 10], [39, 52, 14], [39, 52, 16], [39, 52, 19], [39, 52, 22], [39, 52, 41], [40, 0, 40], [40, 1, 4], [40, 1, 10], [40, 1, 11], [40, 1, 16], [40, 1, 29], [40, 1, 40], [40, 1, 44], [40, 1, 47], [40, 4, 1], [40, 4, 10], [40, 4, 11], [40, 4, 16], [40, 4, 17], [40, 4, 29], [40, 4, 40], [40, 4, 44], [40, 6, 7], [40, 6, 13], [40, 6, 15], [40, 6, 17], [40, 6, 24], [40, 6, 28], [40, 6, 43], [40, 6, 52], [40, 7, 6], [40, 7, 11], [40, 7, 15], [40, 7, 17], [40, 7, 24], [40, 7, 28], [40, 7, 43], [40, 7, 44], [40, 9, 25], [40, 9, 36], [40, 9, 37], [40, 9, 38], [40, 9, 42], [40, 9, 46], [40, 9, 49], [40, 9, 52], [40, 10, 1], [40, 10, 4], [40, 10, 16], [40, 10, 25], [40, 10, 29], [40, 10, 40], [40, 10, 46], [40, 10, 47], [40, 11, 1], [40, 11, 4], [40, 11, 7], [40, 11, 15], [40, 11, 16], [40, 11, 17], [40, 11, 40], [40, 11, 44], [40, 13, 6], [40, 13, 24], [40, 13, 28], [40, 13, 37], [40, 13, 42], [40, 13, 43], [40, 13, 49], [40, 13, 52], [40, 15, 6], [40, 15, 7], [40, 15, 11], [40, 15, 16], [40, 15, 17], [40, 15, 24], [40, 15, 28], [40, 15, 44], [40, 16, 1], [40, 16, 4], [40, 16, 10], [40, 16, 11], [40, 16, 15], [40, 16, 17], [40, 16, 40], [40, 16, 44], [40, 17, 4], [40, 17, 6], [40, 17, 7], [40, 17, 11], [40, 17, 15], [40, 17, 16], [40, 17, 28], [40, 17, 44], [40, 24, 6], [40, 24, 7], [40, 24, 13], [40, 24, 15], [40, 24, 28], [40, 24, 43], [40, 24, 49], [40, 24, 52], [40, 25, 9], [40, 25, 10], [40, 25, 29], [40, 25, 36], [40, 25, 38], [40, 25, 40], [40, 25, 46], [40, 25, 47], [40, 28, 6], [40, 28, 7], [40, 28, 13], [40, 28, 15], [40, 28, 17], [40, 28, 24], [40, 28, 43], [40, 28, 44], [40, 29, 1], [40, 29, 4], [40, 29, 10], [40, 29, 25], [40, 29, 38], [40, 29, 40], [40, 29, 46], [40, 29, 47], [40, 36, 9], [40, 36, 25], [40, 36, 37], [40, 36, 38], [40, 36, 42], [40, 36, 46], [40, 36, 47], [40, 36, 49], [40, 37, 9], [40, 37, 13], [40, 37, 36], [40, 37, 38], [40, 37, 42], [40, 37, 43], [40, 37, 49], [40, 37, 52], [40, 38, 9], [40, 38, 25], [40, 38, 29], [40, 38, 36], [40, 38, 37], [40, 38, 42], [40, 38, 46], [40, 38, 47], [40, 40, 0], [40, 40, 1], [40, 40, 4], [40, 40, 10], [40, 40, 11], [40, 40, 16], [40, 40, 25], [40, 40, 29], [40, 40, 40], [40, 40, 47], [40, 42, 9], [40, 42, 13], [40, 42, 36], [40, 42, 37], [40, 42, 38], [40, 42, 46], [40, 42, 49], [40, 42, 52], [40, 43, 6], [40, 43, 7], [40, 43, 13], [40, 43, 24], [40, 43, 28], [40, 43, 37], [40, 43, 49], [40, 43, 52], [40, 44, 1], [40, 44, 4], [40, 44, 7], [40, 44, 11], [40, 44, 15], [40, 44, 16], [40, 44, 17], [40, 44, 28], [40, 46, 9], [40, 46, 10], [40, 46, 25], [40, 46, 29], [40, 46, 36], [40, 46, 38], [40, 46, 42], [40, 46, 47], [40, 47, 1], [40, 47, 10], [40, 47, 25], [40, 47, 29], [40, 47, 36], [40, 47, 38], [40, 47, 40], [40, 47, 46], [40, 49, 9], [40, 49, 13], [40, 49, 24], [40, 49, 36], [40, 49, 37], [40, 49, 42], [40, 49, 43], [40, 49, 52], [40, 52, 6], [40, 52, 9], [40, 52, 13], [40, 52, 24], [40, 52, 37], [40, 52, 42], [40, 52, 43], [40, 52, 49], [41, 0, 41], [41, 1, 7], [41, 1, 13], [41, 1, 21], [41, 1, 22], [41, 1, 38], [41, 1, 41], [41, 1, 48], [41, 1, 49], [41, 2, 14], [41, 2, 23], [41, 2, 26], [41, 2, 29], [41, 2, 42], [41, 2, 43], [41, 2, 44], [41, 2, 45], [41, 3, 8], [41, 3, 10], [41, 3, 13], [41, 3, 17], [41, 3, 21], [41, 3, 38], [41, 3, 39], [41, 3, 41], [41, 4, 5], [41, 4, 28], [41, 4, 31], [41, 4, 33], [41, 4, 35], [41, 4, 37], [41, 4, 46], [41, 4, 52], [41, 5, 4], [41, 5, 12], [41, 5, 28], [41, 5, 31], [41, 5, 33], [41, 5, 35], [41, 5, 46], [41, 5, 52], [41, 6, 16], [41, 6, 20], [41, 6, 23], [41, 6, 25], [41, 6, 26], [41, 6, 29], [41, 6, 34], [41, 6, 42], [41, 7, 1], [41, 7, 18], [41, 7, 22], [41, 7, 25], [41, 7, 38], [41, 7, 41], [41, 7, 48], [41, 7, 49], [41, 8, 3], [41, 8, 9], [41, 8, 10], [41, 8, 13], [41, 8, 17], [41, 8, 21], [41, 8, 39], [41, 8, 51], [41, 9, 8], [41, 9, 10], [41, 9, 11], [41, 9, 17], [41, 9, 24], [41, 9, 30], [41, 9, 39], [41, 9, 51], [41, 10, 3], [41, 10, 8], [41, 10, 9], [41, 10, 13], [41, 10, 17], [41, 10, 24], [41, 10, 39], [41, 10, 51], [41, 11, 9], [41, 11, 19], [41, 11, 24], [41, 11, 27], [41, 11, 30], [41, 11, 37], [41, 11, 47], [41, 11, 51], [41, 12, 5], [41, 12, 15], [41, 12, 31], [41, 12, 32], [41, 12, 40], [41, 12, 46], [41, 12, 50], [41, 12, 52], [41, 13, 1], [41, 13, 3], [41, 13, 8], [41, 13, 10], [41, 13, 17], [41, 13, 21], [41, 13, 38], [41, 13, 41], [41, 14, 2], [41, 14, 23], [41, 14, 29], [41, 14, 36], [41, 14, 43], [41, 14, 44], [41, 14, 45], [41, 14, 50], [41, 15, 12], [41, 15, 31], [41, 15, 32], [41, 15, 36], [41, 15, 40], [41, 15, 46], [41, 15, 50], [41, 15, 52], [41, 16, 6], [41, 16, 18], [41, 16, 20], [41, 16, 25], [41, 16, 26], [41, 16, 34], [41, 16, 42], [41, 16, 49], [41, 17, 3], [41, 17, 8], [41, 17, 9], [41, 17, 10], [41, 17, 13], [41, 17, 21], [41, 17, 38], [41, 17, 39], [41, 18, 7], [41, 18, 16], [41, 18, 20], [41, 18, 22], [41, 18, 25], [41, 18, 34], [41, 18, 48], [41, 18, 49], [41, 19, 11], [41, 19, 27], [41, 19, 28], [41, 19, 30], [41, 19, 33], [41, 19, 35], [41, 19, 37], [41, 19, 47], [41, 20, 6], [41, 20, 16], [41, 20, 18], [41, 20, 25], [41, 20, 26], [41, 20, 34], [41, 20, 48], [41, 20, 49], [41, 21, 1], [41, 21, 3], [41, 21, 8], [41, 21, 13], [41, 21, 17], [41, 21, 22], [41, 21, 38], [41, 21, 41], [41, 22, 1], [41, 22, 7], [41, 22, 18], [41, 22, 21], [41, 22, 38], [41, 22, 41], [41, 22, 48], [41, 22, 49], [41, 23, 2], [41, 23, 6], [41, 23, 14], [41, 23, 26], [41, 23, 29], [41, 23, 34], [41, 23, 42], [41, 23, 44], [41, 24, 9], [41, 24, 10], [41, 24, 11], [41, 24, 27], [41, 24, 30], [41, 24, 39], [41, 24, 47], [41, 24, 51], [41, 25, 6], [41, 25, 7], [41, 25, 16], [41, 25, 18], [41, 25, 20], [41, 25, 34], [41, 25, 48], [41, 25, 49], [41, 26, 2], [41, 26, 6], [41, 26, 16], [41, 26, 20], [41, 26, 23], [41, 26, 29], [41, 26, 34], [41, 26, 42], [41, 27, 11], [41, 27, 19], [41, 27, 24], [41, 27, 30], [41, 27, 33], [41, 27, 37], [41, 27, 47], [41, 27, 51], [41, 28, 4], [41, 28, 5], [41, 28, 19], [41, 28, 33], [41, 28, 35], [41, 28, 37], [41, 28, 46], [41, 28, 47], [41, 29, 2], [41, 29, 6], [41, 29, 14], [41, 29, 23], [41, 29, 26], [41, 29, 42], [41, 29, 43], [41, 29, 44], [41, 30, 9], [41, 30, 11], [41, 30, 19], [41, 30, 24], [41, 30, 27], [41, 30, 39], [41, 30, 47], [41, 30, 51], [41, 31, 4], [41, 31, 5], [41, 31, 12], [41, 31, 15], [41, 31, 32], [41, 31, 35], [41, 31, 46], [41, 31, 52], [41, 32, 12], [41, 32, 15], [41, 32, 31], [41, 32, 36], [41, 32, 40], [41, 32, 45], [41, 32, 50], [41, 32, 52], [41, 33, 4], [41, 33, 5], [41, 33, 19], [41, 33, 27], [41, 33, 28], [41, 33, 35], [41, 33, 37], [41, 33, 47], [41, 34, 6], [41, 34, 16], [41, 34, 18], [41, 34, 20], [41, 34, 23], [41, 34, 25], [41, 34, 26], [41, 34, 42], [41, 35, 4], [41, 35, 5], [41, 35, 19], [41, 35, 28], [41, 35, 31], [41, 35, 33], [41, 35, 37], [41, 35, 46], [41, 36, 14], [41, 36, 15], [41, 36, 32], [41, 36, 40], [41, 36, 43], [41, 36, 44], [41, 36, 45], [41, 36, 50], [41, 37, 4], [41, 37, 11], [41, 37, 19], [41, 37, 27], [41, 37, 28], [41, 37, 33], [41, 37, 35], [41, 37, 47], [41, 38, 1], [41, 38, 3], [41, 38, 7], [41, 38, 13], [41, 38, 17], [41, 38, 21], [41, 38, 22], [41, 38, 41], [41, 39, 3], [41, 39, 8], [41, 39, 9], [41, 39, 10], [41, 39, 17], [41, 39, 24], [41, 39, 30], [41, 39, 51], [41, 40, 12], [41, 40, 15], [41, 40, 32], [41, 40, 36], [41, 40, 43], [41, 40, 45], [41, 40, 50], [41, 40, 52], [41, 41, 0], [41, 41, 1], [41, 41, 3], [41, 41, 7], [41, 41, 13], [41, 41, 21], [41, 41, 22], [41, 41, 38], [41, 41, 41], [41, 41, 48], [41, 42, 2], [41, 42, 6], [41, 42, 16], [41, 42, 23], [41, 42, 26], [41, 42, 29], [41, 42, 34], [41, 42, 44], [41, 43, 2], [41, 43, 14], [41, 43, 29], [41, 43, 36], [41, 43, 40], [41, 43, 44], [41, 43, 45], [41, 43, 50], [41, 44, 2], [41, 44, 14], [41, 44, 23], [41, 44, 29], [41, 44, 36], [41, 44, 42], [41, 44, 43], [41, 44, 45], [41, 45, 2], [41, 45, 14], [41, 45, 32], [41, 45, 36], [41, 45, 40], [41, 45, 43], [41, 45, 44], [41, 45, 50], [41, 46, 4], [41, 46, 5], [41, 46, 12], [41, 46, 15], [41, 46, 28], [41, 46, 31], [41, 46, 35], [41, 46, 52], [41, 47, 11], [41, 47, 19], [41, 47, 24], [41, 47, 27], [41, 47, 28], [41, 47, 30], [41, 47, 33], [41, 47, 37], [41, 48, 1], [41, 48, 7], [41, 48, 18], [41, 48, 20], [41, 48, 22], [41, 48, 25], [41, 48, 41], [41, 48, 49], [41, 49, 1], [41, 49, 7], [41, 49, 16], [41, 49, 18], [41, 49, 20], [41, 49, 22], [41, 49, 25], [41, 49, 48], [41, 50, 12], [41, 50, 14], [41, 50, 15], [41, 50, 32], [41, 50, 36], [41, 50, 40], [41, 50, 43], [41, 50, 45], [41, 51, 8], [41, 51, 9], [41, 51, 10], [41, 51, 11], [41, 51, 24], [41, 51, 27], [41, 51, 30], [41, 51, 39], [41, 52, 4], [41, 52, 5], [41, 52, 12], [41, 52, 15], [41, 52, 31], [41, 52, 32], [41, 52, 40], [41, 52, 46], [42, 0, 42], [42, 1, 13], [42, 1, 15], [42, 1, 24], [42, 1, 42], [42, 1, 44], [42, 1, 46], [42, 1, 47], [42, 1, 49], [42, 10, 13], [42, 10, 16], [42, 10, 24], [42, 10, 28], [42, 10, 36], [42, 10, 44], [42, 10, 46], [42, 10, 49], [42, 13, 1], [42, 13, 10], [42, 13, 15], [42, 13, 16], [42, 13, 28], [42, 13, 36], [42, 13, 42], [42, 13, 47], [42, 15, 1], [42, 15, 13], [42, 15, 16], [42, 15, 24], [42, 15, 36], [42, 15, 42], [42, 15, 46], [42, 15, 47], [42, 16, 10], [42, 16, 13], [42, 16, 15], [42, 16, 28], [42, 16, 36], [42, 16, 42], [42, 16, 47], [42, 16, 49], [42, 24, 1], [42, 24, 10], [42, 24, 15], [42, 24, 42], [42, 24, 44], [42, 24, 46], [42, 24, 47], [42, 24, 49], [42, 28, 10], [42, 28, 13], [42, 28, 16], [42, 28, 36], [42, 28, 44], [42, 28, 46], [42, 28, 47], [42, 28, 49], [42, 36, 10], [42, 36, 13], [42, 36, 15], [42, 36, 16], [42, 36, 28], [42, 36, 44], [42, 36, 47], [42, 36, 49], [42, 42, 0], [42, 42, 1], [42, 42, 13], [42, 42, 15], [42, 42, 16], [42, 42, 24], [42, 42, 42], [42, 42, 44], [42, 42, 46], [42, 42, 47], [42, 44, 1], [42, 44, 10], [42, 44, 24], [42, 44, 28], [42, 44, 36], [42, 44, 42], [42, 44, 46], [42, 44, 49], [42, 46, 1], [42, 46, 10], [42, 46, 15], [42, 46, 24], [42, 46, 28], [42, 46, 42], [42, 46, 44], [42, 46, 49], [42, 47, 1], [42, 47, 13], [42, 47, 15], [42, 47, 16], [42, 47, 24], [42, 47, 28], [42, 47, 36], [42, 47, 42], [42, 49, 1], [42, 49, 10], [42, 49, 16], [42, 49, 24], [42, 49, 28], [42, 49, 36], [42, 49, 44], [42, 49, 46], [43, 0, 43], [43, 1, 7], [43, 1, 28], [43, 1, 36], [43, 1, 37], [43, 1, 38], [43, 1, 43], [43, 1, 44], [43, 1, 47], [43, 4, 6], [43, 4, 13], [43, 4, 17], [43, 4, 28], [43, 4, 29], [43, 4, 38], [43, 4, 42], [43, 4, 46], [43, 6, 4], [43, 6, 9], [43, 6, 10], [43, 6, 16], [43, 6, 17], [43, 6, 42], [43, 6, 46], [43, 6, 52], [43, 7, 1], [43, 7, 11], [43, 7, 36], [43, 7, 37], [43, 7, 40], [43, 7, 43], [43, 7, 47], [43, 7, 49], [43, 9, 6], [43, 9, 10], [43, 9, 15], [43, 9, 16], [43, 9, 24], [43, 9, 25], [43, 9, 40], [43, 9, 52], [43, 10, 6], [43, 10, 9], [43, 10, 15], [43, 10, 16], [43, 10, 17], [43, 10, 42], [43, 10, 46], [43, 10, 52], [43, 11, 7], [43, 11, 24], [43, 11, 25], [43, 11, 36], [43, 11, 40], [43, 11, 43], [43, 11, 47], [43, 11, 49], [43, 13, 4], [43, 13, 17], [43, 13, 28], [43, 13, 29], [43, 13, 38], [43, 13, 42], [43, 13, 44], [43, 13, 46], [43, 15, 9], [43, 15, 10], [43, 15, 16], [43, 15, 24], [43, 15, 25], [43, 15, 40], [43, 15, 49], [43, 15, 52], [43, 16, 6], [43, 16, 9], [43, 16, 10], [43, 16, 15], [43, 16, 24], [43, 16, 25], [43, 16, 46], [43, 16, 52], [43, 17, 4], [43, 17, 6], [43, 17, 10], [43, 17, 13], [43, 17, 29], [43, 17, 42], [43, 17, 46], [43, 17, 52], [43, 24, 9], [43, 24, 11], [43, 24, 15], [43, 24, 16], [43, 24, 25], [43, 24, 36], [43, 24, 40], [43, 24, 49], [43, 25, 9], [43, 25, 11], [43, 25, 15], [43, 25, 16], [43, 25, 24], [43, 25, 40], [43, 25, 49], [43, 25, 52], [43, 28, 1], [43, 28, 4], [43, 28, 13], [43, 28, 29], [43, 28, 37], [43, 28, 38], [43, 28, 42], [43, 28, 44], [43, 29, 4], [43, 29, 13], [43, 29, 17], [43, 29, 28], [43, 29, 37], [43, 29, 38], [43, 29, 42], [43, 29, 44], [43, 36, 1], [43, 36, 7], [43, 36, 11], [43, 36, 24], [43, 36, 40], [43, 36, 43], [43, 36, 47], [43, 36, 49], [43, 37, 1], [43, 37, 7], [43, 37, 28], [43, 37, 29], [43, 37, 38], [43, 37, 43], [43, 37, 44], [43, 37, 47], [43, 38, 1], [43, 38, 4], [43, 38, 13], [43, 38, 28], [43, 38, 29], [43, 38, 37], [43, 38, 43], [43, 38, 44], [43, 40, 7], [43, 40, 9], [43, 40, 11], [43, 40, 15], [43, 40, 24], [43, 40, 25], [43, 40, 36], [43, 40, 49], [43, 42, 4], [43, 42, 6], [43, 42, 10], [43, 42, 13], [43, 42, 17], [43, 42, 28], [43, 42, 29], [43, 42, 46], [43, 43, 0], [43, 43, 1], [43, 43, 7], [43, 43, 11], [43, 43, 36], [43, 43, 37], [43, 43, 38], [43, 43, 43], [43, 43, 44], [43, 43, 47], [43, 44, 1], [43, 44, 13], [43, 44, 28], [43, 44, 29], [43, 44, 37], [43, 44, 38], [43, 44, 43], [43, 44, 47], [43, 46, 4], [43, 46, 6], [43, 46, 10], [43, 46, 13], [43, 46, 16], [43, 46, 17], [43, 46, 42], [43, 46, 52], [43, 47, 1], [43, 47, 7], [43, 47, 11], [43, 47, 36], [43, 47, 37], [43, 47, 43], [43, 47, 44], [43, 47, 49], [43, 49, 7], [43, 49, 11], [43, 49, 15], [43, 49, 24], [43, 49, 25], [43, 49, 36], [43, 49, 40], [43, 49, 47], [43, 52, 6], [43, 52, 9], [43, 52, 10], [43, 52, 15], [43, 52, 16], [43, 52, 17], [43, 52, 25], [43, 52, 46], [44, 0, 44], [44, 1, 13], [44, 1, 24], [44, 1, 28], [44, 1, 36], [44, 1, 42], [44, 1, 44], [44, 1, 47], [44, 1, 49], [44, 10, 13], [44, 10, 15], [44, 10, 16], [44, 10, 24], [44, 10, 28], [44, 10, 42], [44, 10, 46], [44, 10, 49], [44, 13, 1], [44, 13, 10], [44, 13, 16], [44, 13, 28], [44, 13, 42], [44, 13, 44], [44, 13, 46], [44, 13, 47], [44, 15, 10], [44, 15, 16], [44, 15, 24], [44, 15, 36], [44, 15, 42], [44, 15, 46], [44, 15, 47], [44, 15, 49], [44, 16, 10], [44, 16, 13], [44, 16, 15], [44, 16, 24], [44, 16, 36], [44, 16, 42], [44, 16, 46], [44, 16, 49], [44, 24, 1], [44, 24, 10], [44, 24, 15], [44, 24, 16], [44, 24, 36], [44, 24, 46], [44, 24, 47], [44, 24, 49], [44, 28, 1], [44, 28, 10], [44, 28, 13], [44, 28, 36], [44, 28, 42], [44, 28, 44], [44, 28, 46], [44, 28, 47], [44, 36, 1], [44, 36, 15], [44, 36, 16], [44, 36, 24], [44, 36, 28], [44, 36, 44], [44, 36, 47], [44, 36, 49], [44, 42, 1], [44, 42, 10], [44, 42, 13], [44, 42, 15], [44, 42, 16], [44, 42, 28], [44, 42, 44], [44, 42, 46], [44, 44, 0], [44, 44, 1], [44, 44, 13], [44, 44, 28], [44, 44, 36], [44, 44, 42], [44, 44, 44], [44, 44, 46], [44, 44, 47], [44, 44, 49], [44, 46, 10], [44, 46, 13], [44, 46, 15], [44, 46, 16], [44, 46, 24], [44, 46, 28], [44, 46, 42], [44, 46, 44], [44, 47, 1], [44, 47, 13], [44, 47, 15], [44, 47, 24], [44, 47, 28], [44, 47, 36], [44, 47, 44], [44, 47, 49], [44, 49, 1], [44, 49, 10], [44, 49, 15], [44, 49, 16], [44, 49, 24], [44, 49, 36], [44, 49, 44], [44, 49, 47], [45, 0, 45], [45, 1, 3], [45, 1, 11], [45, 1, 15], [45, 1, 18], [45, 1, 29], [45, 1, 33], [45, 1, 45], [45, 1, 46], [45, 2, 5], [45, 2, 6], [45, 2, 13], [45, 2, 22], [45, 2, 30], [45, 2, 36], [45, 2, 37], [45, 2, 39], [45, 3, 1], [45, 3, 9], [45, 3, 29], [45, 3, 32], [45, 3, 33], [45, 3, 34], [45, 3, 45], [45, 3, 46], [45, 4, 7], [45, 4, 10], [45, 4, 12], [45, 4, 19], [45, 4, 21], [45, 4, 25], [45, 4, 26], [45, 4, 44], [45, 5, 2], [45, 5, 6], [45, 5, 13], [45, 5, 15], [45, 5, 18], [45, 5, 22], [45, 5, 37], [45, 5, 39], [45, 6, 2], [45, 6, 5], [45, 6, 11], [45, 6, 13], [45, 6, 15], [45, 6, 18], [45, 6, 37], [45, 6, 39], [45, 7, 4], [45, 7, 19], [45, 7, 20], [45, 7, 21], [45, 7, 24], [45, 7, 44], [45, 7, 50], [45, 7, 52], [45, 8, 14], [45, 8, 20], [45, 8, 24], [45, 8, 35], [45, 8, 38], [45, 8, 42], [45, 8, 50], [45, 8, 52], [45, 9, 3], [45, 9, 27], [45, 9, 29], [45, 9, 32], [45, 9, 34], [45, 9, 43], [45, 9, 46], [45, 9, 49], [45, 10, 4], [45, 10, 12], [45, 10, 21], [45, 10, 25], [45, 10, 26], [45, 10, 30], [45, 10, 36], [45, 10, 44], [45, 11, 1], [45, 11, 6], [45, 11, 15], [45, 11, 18], [45, 11, 29], [45, 11, 33], [45, 11, 39], [45, 11, 45], [45, 12, 4], [45, 12, 10], [45, 12, 21], [45, 12, 22], [45, 12, 25], [45, 12, 26], [45, 12, 30], [45, 12, 36], [45, 13, 2], [45, 13, 5], [45, 13, 6], [45, 13, 15], [45, 13, 22], [45, 13, 36], [45, 13, 37], [45, 13, 39], [45, 14, 8], [45, 14, 35], [45, 14, 38], [45, 14, 40], [45, 14, 42], [45, 14, 47], [45, 14, 48], [45, 14, 51], [45, 15, 1], [45, 15, 5], [45, 15, 6], [45, 15, 11], [45, 15, 13], [45, 15, 18], [45, 15, 39], [45, 15, 45], [45, 16, 17], [45, 16, 23], [45, 16, 28], [45, 16, 31], [45, 16, 40], [45, 16, 47], [45, 16, 48], [45, 16, 51], [45, 17, 16], [45, 17, 23], [45, 17, 28], [45, 17, 31], [45, 17, 40], [45, 17, 41], [45, 17, 43], [45, 17, 51], [45, 18, 1], [45, 18, 5], [45, 18, 6], [45, 18, 11], [45, 18, 15], [45, 18, 33], [45, 18, 39], [45, 18, 45], [45, 19, 4], [45, 19, 7], [45, 19, 20], [45, 19, 21], [45, 19, 24], [45, 19, 26], [45, 19, 44], [45, 19, 50], [45, 20, 7], [45, 20, 8], [45, 20, 19], [45, 20, 24], [45, 20, 35], [45, 20, 42], [45, 20, 50], [45, 20, 52], [45, 21, 4], [45, 21, 7], [45, 21, 10], [45, 21, 12], [45, 21, 19], [45, 21, 26], [45, 21, 44], [45, 21, 50], [45, 22, 2], [45, 22, 5], [45, 22, 12], [45, 22, 13], [45, 22, 25], [45, 22, 30], [45, 22, 36], [45, 22, 37], [45, 23, 16], [45, 23, 17], [45, 23, 27], [45, 23, 28], [45, 23, 31], [45, 23, 41], [45, 23, 43], [45, 23, 51], [45, 24, 7], [45, 24, 8], [45, 24, 19], [45, 24, 20], [45, 24, 42], [45, 24, 44], [45, 24, 50], [45, 24, 52], [45, 25, 4], [45, 25, 10], [45, 25, 12], [45, 25, 22], [45, 25, 26], [45, 25, 30], [45, 25, 36], [45, 25, 37], [45, 26, 4], [45, 26, 10], [45, 26, 12], [45, 26, 19], [45, 26, 21], [45, 26, 25], [45, 26, 30], [45, 26, 44], [45, 27, 9], [45, 27, 23], [45, 27, 28], [45, 27, 32], [45, 27, 34], [45, 27, 41], [45, 27, 43], [45, 27, 49], [45, 28, 16], [45, 28, 17], [45, 28, 23], [45, 28, 27], [45, 28, 31], [45, 28, 41], [45, 28, 43], [45, 28, 49], [45, 29, 1], [45, 29, 3], [45, 29, 9], [45, 29, 11], [45, 29, 33], [45, 29, 34], [45, 29, 45], [45, 29, 46], [45, 30, 2], [45, 30, 10], [45, 30, 12], [45, 30, 22], [45, 30, 25], [45, 30, 26], [45, 30, 36], [45, 30, 37], [45, 31, 16], [45, 31, 17], [45, 31, 23], [45, 31, 28], [45, 31, 40], [45, 31, 41], [45, 31, 48], [45, 31, 51], [45, 32, 3], [45, 32, 9], [45, 32, 27], [45, 32, 34], [45, 32, 41], [45, 32, 43], [45, 32, 46], [45, 32, 49], [45, 33, 1], [45, 33, 3], [45, 33, 11], [45, 33, 18], [45, 33, 29], [45, 33, 34], [45, 33, 45], [45, 33, 46], [45, 34, 3], [45, 34, 9], [45, 34, 27], [45, 34, 29], [45, 34, 32], [45, 34, 33], [45, 34, 46], [45, 34, 49], [45, 35, 8], [45, 35, 14], [45, 35, 20], [45, 35, 38], [45, 35, 42], [45, 35, 47], [45, 35, 48], [45, 35, 52], [45, 36, 2], [45, 36, 10], [45, 36, 12], [45, 36, 13], [45, 36, 22], [45, 36, 25], [45, 36, 30], [45, 36, 37], [45, 37, 2], [45, 37, 5], [45, 37, 6], [45, 37, 13], [45, 37, 22], [45, 37, 25], [45, 37, 30], [45, 37, 36], [45, 38, 8], [45, 38, 14], [45, 38, 35], [45, 38, 40], [45, 38, 42], [45, 38, 47], [45, 38, 48], [45, 38, 52], [45, 39, 2], [45, 39, 5], [45, 39, 6], [45, 39, 11], [45, 39, 13], [45, 39, 15], [45, 39, 18], [45, 39, 45], [45, 40, 14], [45, 40, 16], [45, 40, 17], [45, 40, 31], [45, 40, 38], [45, 40, 47], [45, 40, 48], [45, 40, 51], [45, 41, 17], [45, 41, 23], [45, 41, 27], [45, 41, 28], [45, 41, 31], [45, 41, 32], [45, 41, 43], [45, 41, 49], [45, 42, 8], [45, 42, 14], [45, 42, 20], [45, 42, 24], [45, 42, 35], [45, 42, 38], [45, 42, 47], [45, 42, 52], [45, 43, 9], [45, 43, 17], [45, 43, 23], [45, 43, 27], [45, 43, 28], [45, 43, 32], [45, 43, 41], [45, 43, 49], [45, 44, 4], [45, 44, 7], [45, 44, 10], [45, 44, 19], [45, 44, 21], [45, 44, 24], [45, 44, 26], [45, 44, 50], [45, 45, 0], [45, 45, 1], [45, 45, 3], [45, 45, 11], [45, 45, 15], [45, 45, 18], [45, 45, 29], [45, 45, 33], [45, 45, 39], [45, 45, 45], [45, 46, 1], [45, 46, 3], [45, 46, 9], [45, 46, 29], [45, 46, 32], [45, 46, 33], [45, 46, 34], [45, 46, 49], [45, 47, 14], [45, 47, 16], [45, 47, 35], [45, 47, 38], [45, 47, 40], [45, 47, 42], [45, 47, 48], [45, 47, 51], [45, 48, 14], [45, 48, 16], [45, 48, 31], [45, 48, 35], [45, 48, 38], [45, 48, 40], [45, 48, 47], [45, 48, 51], [45, 49, 9], [45, 49, 27], [45, 49, 28], [45, 49, 32], [45, 49, 34], [45, 49, 41], [45, 49, 43], [45, 49, 46], [45, 50, 7], [45, 50, 8], [45, 50, 19], [45, 50, 20], [45, 50, 21], [45, 50, 24], [45, 50, 44], [45, 50, 52], [45, 51, 14], [45, 51, 16], [45, 51, 17], [45, 51, 23], [45, 51, 31], [45, 51, 40], [45, 51, 47], [45, 51, 48], [45, 52, 7], [45, 52, 8], [45, 52, 20], [45, 52, 24], [45, 52, 35], [45, 52, 38], [45, 52, 42], [45, 52, 50], [46, 0, 46], [46, 1, 10], [46, 1, 13], [46, 1, 15], [46, 1, 16], [46, 1, 28], [46, 1, 36], [46, 1, 46], [46, 1, 49], [46, 10, 1], [46, 10, 13], [46, 10, 15], [46, 10, 24], [46, 10, 36], [46, 10, 42], [46, 10, 44], [46, 10, 47], [46, 13, 1], [46, 13, 10], [46, 13, 15], [46, 13, 24], [46, 13, 36], [46, 13, 44], [46, 13, 46], [46, 13, 49], [46, 15, 1], [46, 15, 10], [46, 15, 13], [46, 15, 28], [46, 15, 36], [46, 15, 44], [46, 15, 46], [46, 15, 49], [46, 16, 1], [46, 16, 24], [46, 16, 28], [46, 16, 42], [46, 16, 44], [46, 16, 46], [46, 16, 47], [46, 16, 49], [46, 24, 10], [46, 24, 13], [46, 24, 16], [46, 24, 28], [46, 24, 36], [46, 24, 42], [46, 24, 44], [46, 24, 47], [46, 28, 1], [46, 28, 15], [46, 28, 16], [46, 28, 24], [46, 28, 42], [46, 28, 46], [46, 28, 47], [46, 28, 49], [46, 36, 1], [46, 36, 10], [46, 36, 13], [46, 36, 15], [46, 36, 24], [46, 36, 42], [46, 36, 44], [46, 36, 46], [46, 42, 10], [46, 42, 16], [46, 42, 24], [46, 42, 28], [46, 42, 36], [46, 42, 44], [46, 42, 47], [46, 42, 49], [46, 44, 10], [46, 44, 13], [46, 44, 15], [46, 44, 16], [46, 44, 24], [46, 44, 36], [46, 44, 42], [46, 44, 47], [46, 46, 0], [46, 46, 1], [46, 46, 13], [46, 46, 15], [46, 46, 16], [46, 46, 28], [46, 46, 36], [46, 46, 46], [46, 46, 47], [46, 46, 49], [46, 47, 10], [46, 47, 16], [46, 47, 24], [46, 47, 28], [46, 47, 42], [46, 47, 44], [46, 47, 46], [46, 47, 49], [46, 49, 1], [46, 49, 13], [46, 49, 15], [46, 49, 16], [46, 49, 28], [46, 49, 42], [46, 49, 46], [46, 49, 47], [47, 0, 47], [47, 1, 13], [47, 1, 24], [47, 1, 28], [47, 1, 36], [47, 1, 42], [47, 1, 44], [47, 1, 47], [47, 1, 49], [47, 10, 13], [47, 10, 15], [47, 10, 16], [47, 10, 24], [47, 10, 28], [47, 10, 42], [47, 10, 46], [47, 10, 49], [47, 13, 1], [47, 13, 10], [47, 13, 16], [47, 13, 28], [47, 13, 42], [47, 13, 44], [47, 13, 46], [47, 13, 47], [47, 15, 10], [47, 15, 16], [47, 15, 24], [47, 15, 36], [47, 15, 42], [47, 15, 46], [47, 15, 47], [47, 15, 49], [47, 16, 10], [47, 16, 13], [47, 16, 15], [47, 16, 24], [47, 16, 36], [47, 16, 42], [47, 16, 46], [47, 16, 49], [47, 24, 1], [47, 24, 10], [47, 24, 15], [47, 24, 16], [47, 24, 36], [47, 24, 46], [47, 24, 47], [47, 24, 49], [47, 28, 1], [47, 28, 10], [47, 28, 13], [47, 28, 36], [47, 28, 42], [47, 28, 44], [47, 28, 46], [47, 28, 47], [47, 36, 1], [47, 36, 15], [47, 36, 16], [47, 36, 24], [47, 36, 28], [47, 36, 44], [47, 36, 47], [47, 36, 49], [47, 42, 1], [47, 42, 10], [47, 42, 13], [47, 42, 15], [47, 42, 16], [47, 42, 28], [47, 42, 44], [47, 42, 46], [47, 44, 1], [47, 44, 13], [47, 44, 28], [47, 44, 36], [47, 44, 42], [47, 44, 46], [47, 44, 47], [47, 44, 49], [47, 46, 10], [47, 46, 13], [47, 46, 15], [47, 46, 16], [47, 46, 24], [47, 46, 28], [47, 46, 42], [47, 46, 44], [47, 47, 0], [47, 47, 1], [47, 47, 13], [47, 47, 15], [47, 47, 24], [47, 47, 28], [47, 47, 36], [47, 47, 44], [47, 47, 47], [47, 47, 49], [47, 49, 1], [47, 49, 10], [47, 49, 15], [47, 49, 16], [47, 49, 24], [47, 49, 36], [47, 49, 44], [47, 49, 47], [48, 0, 48], [48, 1, 17], [48, 1, 21], [48, 1, 24], [48, 1, 25], [48, 1, 34], [48, 1, 39], [48, 1, 42], [48, 1, 48], [48, 2, 15], [48, 2, 25], [48, 2, 31], [48, 2, 34], [48, 2, 42], [48, 2, 43], [48, 2, 48], [48, 2, 50], [48, 3, 10], [48, 3, 11], [48, 3, 19], [48, 3, 20], [48, 3, 22], [48, 3, 38], [48, 3, 49], [48, 3, 51], [48, 4, 9], [48, 4, 15], [48, 4, 30], [48, 4, 31], [48, 4, 33], [48, 4, 43], [48, 4, 47], [48, 4, 50], [48, 5, 11], [48, 5, 14], [48, 5, 19], [48, 5, 28], [48, 5, 32], [48, 5, 36], [48, 5, 51], [48, 5, 52], [48, 6, 20], [48, 6, 22], [48, 6, 23], [48, 6, 38], [48, 6, 40], [48, 6, 44], [48, 6, 45], [48, 6, 49], [48, 7, 8], [48, 7, 9], [48, 7, 13], [48, 7, 16], [48, 7, 18], [48, 7, 26], [48, 7, 29], [48, 7, 41], [48, 8, 7], [48, 8, 9], [48, 8, 13], [48, 8, 18], [48, 8, 30], [48, 8, 33], [48, 8, 41], [48, 8, 47], [48, 9, 4], [48, 9, 7], [48, 9, 8], [48, 9, 13], [48, 9, 30], [48, 9, 33], [48, 9, 41], [48, 9, 47], [48, 10, 3], [48, 10, 11], [48, 10, 19], [48, 10, 22], [48, 10, 28], [48, 10, 38], [48, 10, 49], [48, 10, 51], [48, 11, 3], [48, 11, 5], [48, 11, 10], [48, 11, 19], [48, 11, 28], [48, 11, 38], [48, 11, 51], [48, 11, 52], [48, 12, 23], [48, 12, 27], [48, 12, 35], [48, 12, 37], [48, 12, 40], [48, 12, 44], [48, 12, 45], [48, 12, 46], [48, 13, 7], [48, 13, 8], [48, 13, 9], [48, 13, 16], [48, 13, 18], [48, 13, 30], [48, 13, 41], [48, 13, 47], [48, 14, 5], [48, 14, 16], [48, 14, 18], [48, 14, 26], [48, 14, 29], [48, 14, 32], [48, 14, 36], [48, 14, 52], [48, 15, 2], [48, 15, 4], [48, 15, 31], [48, 15, 33], [48, 15, 42], [48, 15, 43], [48, 15, 47], [48, 15, 50], [48, 16, 7], [48, 16, 13], [48, 16, 14], [48, 16, 18], [48, 16, 26], [48, 16, 29], [48, 16, 36], [48, 16, 41], [48, 17, 1], [48, 17, 21], [48, 17, 24], [48, 17, 25], [48, 17, 27], [48, 17, 37], [48, 17, 39], [48, 17, 48], [48, 18, 7], [48, 18, 8], [48, 18, 13], [48, 18, 14], [48, 18, 16], [48, 18, 26], [48, 18, 29], [48, 18, 41], [48, 19, 3], [48, 19, 5], [48, 19, 10], [48, 19, 11], [48, 19, 28], [48, 19, 32], [48, 19, 51], [48, 19, 52], [48, 20, 3], [48, 20, 6], [48, 20, 22], [48, 20, 23], [48, 20, 38], [48, 20, 44], [48, 20, 45], [48, 20, 49], [48, 21, 1], [48, 21, 17], [48, 21, 24], [48, 21, 25], [48, 21, 27], [48, 21, 34], [48, 21, 39], [48, 21, 48], [48, 22, 3], [48, 22, 6], [48, 22, 10], [48, 22, 20], [48, 22, 23], [48, 22, 38], [48, 22, 49], [48, 22, 51], [48, 23, 6], [48, 23, 12], [48, 23, 20], [48, 23, 22], [48, 23, 40], [48, 23, 44], [48, 23, 45], [48, 23, 49], [48, 24, 1], [48, 24, 17], [48, 24, 21], [48, 24, 27], [48, 24, 35], [48, 24, 37], [48, 24, 39], [48, 24, 46], [48, 25, 1], [48, 25, 2], [48, 25, 17], [48, 25, 21], [48, 25, 34], [48, 25, 42], [48, 25, 43], [48, 25, 48], [48, 26, 7], [48, 26, 14], [48, 26, 16], [48, 26, 18], [48, 26, 29], [48, 26, 32], [48, 26, 36], [48, 26, 41], [48, 27, 12], [48, 27, 17], [48, 27, 21], [48, 27, 24], [48, 27, 35], [48, 27, 37], [48, 27, 39], [48, 27, 46], [48, 28, 5], [48, 28, 10], [48, 28, 11], [48, 28, 19], [48, 28, 32], [48, 28, 36], [48, 28, 51], [48, 28, 52], [48, 29, 7], [48, 29, 14], [48, 29, 16], [48, 29, 18], [48, 29, 26], [48, 29, 32], [48, 29, 36], [48, 29, 52], [48, 30, 4], [48, 30, 8], [48, 30, 9], [48, 30, 13], [48, 30, 31], [48, 30, 33], [48, 30, 41], [48, 30, 47], [48, 31, 2], [48, 31, 4], [48, 31, 15], [48, 31, 30], [48, 31, 33], [48, 31, 43], [48, 31, 47], [48, 31, 50], [48, 32, 5], [48, 32, 14], [48, 32, 19], [48, 32, 26], [48, 32, 28], [48, 32, 29], [48, 32, 36], [48, 32, 52], [48, 33, 4], [48, 33, 8], [48, 33, 9], [48, 33, 15], [48, 33, 30], [48, 33, 31], [48, 33, 47], [48, 33, 50], [48, 34, 1], [48, 34, 2], [48, 34, 21], [48, 34, 25], [48, 34, 42], [48, 34, 43], [48, 34, 48], [48, 34, 50], [48, 35, 12], [48, 35, 24], [48, 35, 27], [48, 35, 37], [48, 35, 39], [48, 35, 40], [48, 35, 45], [48, 35, 46], [48, 36, 5], [48, 36, 14], [48, 36, 16], [48, 36, 26], [48, 36, 28], [48, 36, 29], [48, 36, 32], [48, 36, 52], [48, 37, 12], [48, 37, 17], [48, 37, 24], [48, 37, 27], [48, 37, 35], [48, 37, 39], [48, 37, 40], [48, 37, 46], [48, 38, 3], [48, 38, 6], [48, 38, 10], [48, 38, 11], [48, 38, 20], [48, 38, 22], [48, 38, 49], [48, 38, 51], [48, 39, 1], [48, 39, 17], [48, 39, 21], [48, 39, 24], [48, 39, 27], [48, 39, 35], [48, 39, 37], [48, 39, 48], [48, 40, 6], [48, 40, 12], [48, 40, 23], [48, 40, 35], [48, 40, 37], [48, 40, 44], [48, 40, 45], [48, 40, 46], [48, 41, 7], [48, 41, 8], [48, 41, 9], [48, 41, 13], [48, 41, 16], [48, 41, 18], [48, 41, 26], [48, 41, 30], [48, 42, 1], [48, 42, 2], [48, 42, 15], [48, 42, 25], [48, 42, 34], [48, 42, 43], [48, 42, 48], [48, 42, 50], [48, 43, 2], [48, 43, 4], [48, 43, 15], [48, 43, 25], [48, 43, 31], [48, 43, 34], [48, 43, 42], [48, 43, 50], [48, 44, 6], [48, 44, 12], [48, 44, 20], [48, 44, 23], [48, 44, 40], [48, 44, 45], [48, 44, 46], [48, 44, 49], [48, 45, 6], [48, 45, 12], [48, 45, 20], [48, 45, 23], [48, 45, 35], [48, 45, 40], [48, 45, 44], [48, 45, 46], [48, 46, 12], [48, 46, 24], [48, 46, 27], [48, 46, 35], [48, 46, 37], [48, 46, 40], [48, 46, 44], [48, 46, 45], [48, 47, 4], [48, 47, 8], [48, 47, 9], [48, 47, 13], [48, 47, 15], [48, 47, 30], [48, 47, 31], [48, 47, 33], [48, 48, 0], [48, 48, 1], [48, 48, 2], [48, 48, 17], [48, 48, 21], [48, 48, 25], [48, 48, 34], [48, 48, 39], [48, 48, 42], [48, 48, 48], [48, 49, 3], [48, 49, 6], [48, 49, 10], [48, 49, 20], [48, 49, 22], [48, 49, 23], [48, 49, 38], [48, 49, 44], [48, 50, 2], [48, 50, 4], [48, 50, 15], [48, 50, 31], [48, 50, 33], [48, 50, 34], [48, 50, 42], [48, 50, 43], [48, 51, 3], [48, 51, 5], [48, 51, 10], [48, 51, 11], [48, 51, 19], [48, 51, 22], [48, 51, 28], [48, 51, 38], [48, 52, 5], [48, 52, 11], [48, 52, 14], [48, 52, 19], [48, 52, 28], [48, 52, 29], [48, 52, 32], [48, 52, 36], [49, 0, 49], [49, 1, 10], [49, 1, 13], [49, 1, 16], [49, 1, 24], [49, 1, 42], [49, 1, 44], [49, 1, 47], [49, 1, 49], [49, 10, 1], [49, 10, 13], [49, 10, 16], [49, 10, 24], [49, 10, 28], [49, 10, 46], [49, 10, 47], [49, 10, 49], [49, 13, 1], [49, 13, 10], [49, 13, 16], [49, 13, 24], [49, 13, 28], [49, 13, 42], [49, 13, 47], [49, 13, 49], [49, 15, 16], [49, 15, 24], [49, 15, 28], [49, 15, 36], [49, 15, 42], [49, 15, 44], [49, 15, 46], [49, 15, 47], [49, 16, 1], [49, 16, 10], [49, 16, 13], [49, 16, 15], [49, 16, 36], [49, 16, 42], [49, 16, 44], [49, 16, 49], [49, 24, 1], [49, 24, 10], [49, 24, 13], [49, 24, 15], [49, 24, 28], [49, 24, 46], [49, 24, 47], [49, 24, 49], [49, 28, 10], [49, 28, 13], [49, 28, 15], [49, 28, 24], [49, 28, 36], [49, 28, 44], [49, 28, 46], [49, 28, 47], [49, 36, 15], [49, 36, 16], [49, 36, 28], [49, 36, 42], [49, 36, 44], [49, 36, 46], [49, 36, 47], [49, 36, 49], [49, 42, 1], [49, 42, 13], [49, 42, 15], [49, 42, 16], [49, 42, 36], [49, 42, 44], [49, 42, 46], [49, 42, 49], [49, 44, 1], [49, 44, 15], [49, 44, 16], [49, 44, 28], [49, 44, 36], [49, 44, 42], [49, 44, 46], [49, 44, 49], [49, 46, 10], [49, 46, 15], [49, 46, 24], [49, 46, 28], [49, 46, 36], [49, 46, 42], [49, 46, 44], [49, 46, 47], [49, 47, 1], [49, 47, 10], [49, 47, 13], [49, 47, 15], [49, 47, 24], [49, 47, 28], [49, 47, 36], [49, 47, 46], [49, 49, 0], [49, 49, 1], [49, 49, 10], [49, 49, 13], [49, 49, 16], [49, 49, 24], [49, 49, 36], [49, 49, 42], [49, 49, 44], [49, 49, 49], [50, 0, 50], [50, 1, 6], [50, 1, 9], [50, 1, 26], [50, 1, 28], [50, 1, 35], [50, 1, 36], [50, 1, 50], [50, 1, 51], [50, 2, 3], [50, 2, 12], [50, 2, 17], [50, 2, 18], [50, 2, 19], [50, 2, 47], [50, 2, 49], [50, 2, 52], [50, 3, 2], [50, 3, 18], [50, 3, 25], [50, 3, 27], [50, 3, 31], [50, 3, 44], [50, 3, 47], [50, 3, 52], [50, 4, 6], [50, 4, 24], [50, 4, 34], [50, 4, 36], [50, 4, 38], [50, 4, 41], [50, 4, 45], [50, 4, 51], [50, 5, 16], [50, 5, 21], [50, 5, 24], [50, 5, 30], [50, 5, 34], [50, 5, 38], [50, 5, 43], [50, 5, 45], [50, 6, 1], [50, 6, 4], [50, 6, 9], [50, 6, 35], [50, 6, 36], [50, 6, 41], [50, 6, 50], [50, 6, 51], [50, 7, 10], [50, 7, 23], [50, 7, 32], [50, 7, 33], [50, 7, 37], [50, 7, 39], [50, 7, 40], [50, 7, 42], [50, 8, 12], [50, 8, 15], [50, 8, 19], [50, 8, 23], [50, 8, 29], [50, 8, 37], [50, 8, 48], [50, 8, 49], [50, 9, 1], [50, 9, 6], [50, 9, 22], [50, 9, 26], [50, 9, 28], [50, 9, 35], [50, 9, 40], [50, 9, 50], [50, 10, 7], [50, 10, 15], [50, 10, 23], [50, 10, 32], [50, 10, 33], [50, 10, 37], [50, 10, 42], [50, 10, 48], [50, 11, 13], [50, 11, 14], [50, 11, 20], [50, 11, 21], [50, 11, 25], [50, 11, 31], [50, 11, 43], [50, 11, 46], [50, 12, 2], [50, 12, 8], [50, 12, 17], [50, 12, 18], [50, 12, 19], [50, 12, 29], [50, 12, 47], [50, 12, 49], [50, 13, 11], [50, 13, 14], [50, 13, 20], [50, 13, 25], [50, 13, 27], [50, 13, 31], [50, 13, 44], [50, 13, 46], [50, 14, 11], [50, 14, 13], [50, 14, 20], [50, 14, 21], [50, 14, 25], [50, 14, 27], [50, 14, 31], [50, 14, 46], [50, 15, 8], [50, 15, 10], [50, 15, 19], [50, 15, 23], [50, 15, 29], [50, 15, 37], [50, 15, 48], [50, 15, 49], [50, 16, 5], [50, 16, 21], [50, 16, 24], [50, 16, 30], [50, 16, 38], [50, 16, 43], [50, 16, 45], [50, 16, 46], [50, 17, 2], [50, 17, 12], [50, 17, 18], [50, 17, 19], [50, 17, 29], [50, 17, 47], [50, 17, 49], [50, 17, 52], [50, 18, 2], [50, 18, 3], [50, 18, 12], [50, 18, 17], [50, 18, 27], [50, 18, 44], [50, 18, 47], [50, 18, 52], [50, 19, 2], [50, 19, 8], [50, 19, 12], [50, 19, 15], [50, 19, 17], [50, 19, 29], [50, 19, 48], [50, 19, 49], [50, 20, 11], [50, 20, 13], [50, 20, 14], [50, 20, 21], [50, 20, 30], [50, 20, 31], [50, 20, 43], [50, 20, 46], [50, 21, 5], [50, 21, 11], [50, 21, 14], [50, 21, 16], [50, 21, 20], [50, 21, 30], [50, 21, 43], [50, 21, 46], [50, 22, 9], [50, 22, 26], [50, 22, 28], [50, 22, 33], [50, 22, 39], [50, 22, 40], [50, 22, 42], [50, 22, 50], [50, 23, 7], [50, 23, 8], [50, 23, 10], [50, 23, 15], [50, 23, 32], [50, 23, 33], [50, 23, 37], [50, 23, 48], [50, 24, 4], [50, 24, 5], [50, 24, 16], [50, 24, 34], [50, 24, 36], [50, 24, 38], [50, 24, 41], [50, 24, 45], [50, 25, 3], [50, 25, 11], [50, 25, 13], [50, 25, 14], [50, 25, 27], [50, 25, 31], [50, 25, 44], [50, 25, 52], [50, 26, 1], [50, 26, 9], [50, 26, 22], [50, 26, 28], [50, 26, 35], [50, 26, 39], [50, 26, 40], [50, 26, 50], [50, 27, 3], [50, 27, 13], [50, 27, 14], [50, 27, 18], [50, 27, 25], [50, 27, 31], [50, 27, 44], [50, 27, 52], [50, 28, 1], [50, 28, 9], [50, 28, 22], [50, 28, 26], [50, 28, 39], [50, 28, 40], [50, 28, 42], [50, 28, 50], [50, 29, 8], [50, 29, 12], [50, 29, 15], [50, 29, 17], [50, 29, 19], [50, 29, 37], [50, 29, 48], [50, 29, 49], [50, 30, 5], [50, 30, 16], [50, 30, 20], [50, 30, 21], [50, 30, 38], [50, 30, 43], [50, 30, 45], [50, 30, 46], [50, 31, 3], [50, 31, 11], [50, 31, 13], [50, 31, 14], [50, 31, 20], [50, 31, 25], [50, 31, 27], [50, 31, 44], [50, 32, 7], [50, 32, 10], [50, 32, 23], [50, 32, 33], [50, 32, 37], [50, 32, 39], [50, 32, 42], [50, 32, 48], [50, 33, 7], [50, 33, 10], [50, 33, 22], [50, 33, 23], [50, 33, 32], [50, 33, 39], [50, 33, 40], [50, 33, 42], [50, 34, 4], [50, 34, 5], [50, 34, 24], [50, 34, 36], [50, 34, 38], [50, 34, 41], [50, 34, 45], [50, 34, 51], [50, 35, 1], [50, 35, 6], [50, 35, 9], [50, 35, 26], [50, 35, 36], [50, 35, 41], [50, 35, 50], [50, 35, 51], [50, 36, 1], [50, 36, 4], [50, 36, 6], [50, 36, 24], [50, 36, 34], [50, 36, 35], [50, 36, 41], [50, 36, 51], [50, 37, 7], [50, 37, 8], [50, 37, 10], [50, 37, 15], [50, 37, 23], [50, 37, 29], [50, 37, 32], [50, 37, 48], [50, 38, 4], [50, 38, 5], [50, 38, 16], [50, 38, 24], [50, 38, 30], [50, 38, 34], [50, 38, 43], [50, 38, 45], [50, 39, 7], [50, 39, 22], [50, 39, 26], [50, 39, 28], [50, 39, 32], [50, 39, 33], [50, 39, 40], [50, 39, 42], [50, 40, 7], [50, 40, 9], [50, 40, 22], [50, 40, 26], [50, 40, 28], [50, 40, 33], [50, 40, 39], [50, 40, 42], [50, 41, 4], [50, 41, 6], [50, 41, 24], [50, 41, 34], [50, 41, 35], [50, 41, 36], [50, 41, 45], [50, 41, 51], [50, 42, 7], [50, 42, 10], [50, 42, 22], [50, 42, 28], [50, 42, 32], [50, 42, 33], [50, 42, 39], [50, 42, 40], [50, 43, 5], [50, 43, 11], [50, 43, 16], [50, 43, 20], [50, 43, 21], [50, 43, 30], [50, 43, 38], [50, 43, 46], [50, 44, 3], [50, 44, 13], [50, 44, 18], [50, 44, 25], [50, 44, 27], [50, 44, 31], [50, 44, 47], [50, 44, 52], [50, 45, 4], [50, 45, 5], [50, 45, 16], [50, 45, 24], [50, 45, 30], [50, 45, 34], [50, 45, 38], [50, 45, 41], [50, 46, 11], [50, 46, 13], [50, 46, 14], [50, 46, 16], [50, 46, 20], [50, 46, 21], [50, 46, 30], [50, 46, 43], [50, 47, 2], [50, 47, 3], [50, 47, 12], [50, 47, 17], [50, 47, 18], [50, 47, 44], [50, 47, 49], [50, 47, 52], [50, 48, 8], [50, 48, 10], [50, 48, 15], [50, 48, 19], [50, 48, 23], [50, 48, 29], [50, 48, 32], [50, 48, 37], [50, 49, 2], [50, 49, 8], [50, 49, 12], [50, 49, 15], [50, 49, 17], [50, 49, 19], [50, 49, 29], [50, 49, 47], [50, 50, 0], [50, 50, 1], [50, 50, 6], [50, 50, 9], [50, 50, 22], [50, 50, 26], [50, 50, 28], [50, 50, 35], [50, 50, 50], [50, 50, 51], [50, 51, 1], [50, 51, 4], [50, 51, 6], [50, 51, 34], [50, 51, 35], [50, 51, 36], [50, 51, 41], [50, 51, 50], [50, 52, 2], [50, 52, 3], [50, 52, 17], [50, 52, 18], [50, 52, 25], [50, 52, 27], [50, 52, 44], [50, 52, 47], [51, 0, 51], [51, 1, 4], [51, 1, 10], [51, 1, 16], [51, 1, 26], [51, 1, 33], [51, 1, 40], [51, 1, 45], [51, 1, 51], [51, 2, 8], [51, 2, 13], [51, 2, 20], [51, 2, 27], [51, 2, 32], [51, 2, 37], [51, 2, 49], [51, 2, 52], [51, 3, 12], [51, 3, 14], [51, 3, 25], [51, 3, 29], [51, 3, 30], [51, 3, 46], [51, 3, 47], [51, 3, 48], [51, 4, 1], [51, 4, 11], [51, 4, 16], [51, 4, 21], [51, 4, 26], [51, 4, 40], [51, 4, 45], [51, 4, 51], [51, 5, 6], [51, 5, 13], [51, 5, 20], [51, 5, 24], [51, 5, 27], [51, 5, 41], [51, 5, 43], [51, 5, 50], [51, 6, 5], [51, 6, 7], [51, 6, 24], [51, 6, 28], [51, 6, 39], [51, 6, 41], [51, 6, 43], [51, 6, 50], [51, 7, 6], [51, 7, 15], [51, 7, 17], [51, 7, 19], [51, 7, 23], [51, 7, 28], [51, 7, 39], [51, 7, 50], [51, 8, 2], [51, 8, 22], [51, 8, 27], [51, 8, 32], [51, 8, 37], [51, 8, 42], [51, 8, 49], [51, 8, 52], [51, 9, 22], [51, 9, 32], [51, 9, 34], [51, 9, 35], [51, 9, 36], [51, 9, 37], [51, 9, 38], [51, 9, 42], [51, 10, 1], [51, 10, 12], [51, 10, 26], [51, 10, 29], [51, 10, 33], [51, 10, 40], [51, 10, 47], [51, 10, 48], [51, 11, 4], [51, 11, 16], [51, 11, 17], [51, 11, 18], [51, 11, 21], [51, 11, 31], [51, 11, 44], [51, 11, 45], [51, 12, 3], [51, 12, 10], [51, 12, 14], [51, 12, 25], [51, 12, 29], [51, 12, 33], [51, 12, 47], [51, 12, 48], [51, 13, 2], [51, 13, 5], [51, 13, 20], [51, 13, 24], [51, 13, 27], [51, 13, 43], [51, 13, 49], [51, 13, 52], [51, 14, 3], [51, 14, 12], [51, 14, 25], [51, 14, 30], [51, 14, 34], [51, 14, 38], [51, 14, 46], [51, 14, 47], [51, 15, 7], [51, 15, 17], [51, 15, 18], [51, 15, 19], [51, 15, 23], [51, 15, 28], [51, 15, 39], [51, 15, 44], [51, 16, 1], [51, 16, 4], [51, 16, 11], [51, 16, 21], [51, 16, 31], [51, 16, 44], [51, 16, 45], [51, 16, 51], [51, 17, 7], [51, 17, 11], [51, 17, 15], [51, 17, 18], [51, 17, 19], [51, 17, 23], [51, 17, 31], [51, 17, 44], [51, 18, 11], [51, 18, 15], [51, 18, 17], [51, 18, 19], [51, 18, 21], [51, 18, 23], [51, 18, 31], [51, 18, 44], [51, 19, 7], [51, 19, 15], [51, 19, 17], [51, 19, 18], [51, 19, 23], [51, 19, 31], [51, 19, 39], [51, 19, 44], [51, 20, 2], [51, 20, 5], [51, 20, 13], [51, 20, 24], [51, 20, 27], [51, 20, 41], [51, 20, 43], [51, 20, 52], [51, 21, 4], [51, 21, 11], [51, 21, 16], [51, 21, 18], [51, 21, 31], [51, 21, 44], [51, 21, 45], [51, 21, 51], [51, 22, 8], [51, 22, 9], [51, 22, 32], [51, 22, 34], [51, 22, 35], [51, 22, 36], [51, 22, 37], [51, 22, 42], [51, 23, 7], [51, 23, 15], [51, 23, 17], [51, 23, 18], [51, 23, 19], [51, 23, 28], [51, 23, 39], [51, 23, 50], [51, 24, 5], [51, 24, 6], [51, 24, 13], [51, 24, 20], [51, 24, 28], [51, 24, 41], [51, 24, 43], [51, 24, 50], [51, 25, 3], [51, 25, 12], [51, 25, 14], [51, 25, 29], [51, 25, 30], [51, 25, 38], [51, 25, 46], [51, 25, 47], [51, 26, 1], [51, 26, 4], [51, 26, 10], [51, 26, 33], [51, 26, 40], [51, 26, 45], [51, 26, 48], [51, 26, 51], [51, 27, 2], [51, 27, 5], [51, 27, 8], [51, 27, 13], [51, 27, 20], [51, 27, 43], [51, 27, 49], [51, 27, 52], [51, 28, 6], [51, 28, 7], [51, 28, 15], [51, 28, 23], [51, 28, 24], [51, 28, 39], [51, 28, 41], [51, 28, 50], [51, 29, 3], [51, 29, 10], [51, 29, 12], [51, 29, 25], [51, 29, 33], [51, 29, 40], [51, 29, 47], [51, 29, 48], [51, 30, 3], [51, 30, 14], [51, 30, 25], [51, 30, 34], [51, 30, 35], [51, 30, 36], [51, 30, 38], [51, 30, 46], [51, 31, 11], [51, 31, 16], [51, 31, 17], [51, 31, 18], [51, 31, 19], [51, 31, 21], [51, 31, 44], [51, 31, 45], [51, 32, 2], [51, 32, 8], [51, 32, 9], [51, 32, 22], [51, 32, 35], [51, 32, 37], [51, 32, 42], [51, 32, 49], [51, 33, 1], [51, 33, 10], [51, 33, 12], [51, 33, 26], [51, 33, 29], [51, 33, 40], [51, 33, 48], [51, 33, 51], [51, 34, 9], [51, 34, 14], [51, 34, 22], [51, 34, 30], [51, 34, 35], [51, 34, 36], [51, 34, 38], [51, 34, 46], [51, 35, 9], [51, 35, 22], [51, 35, 30], [51, 35, 32], [51, 35, 34], [51, 35, 36], [51, 35, 38], [51, 35, 42], [51, 36, 9], [51, 36, 22], [51, 36, 30], [51, 36, 34], [51, 36, 35], [51, 36, 38], [51, 36, 42], [51, 36, 46], [51, 37, 2], [51, 37, 8], [51, 37, 9], [51, 37, 22], [51, 37, 32], [51, 37, 42], [51, 37, 49], [51, 37, 52], [51, 38, 9], [51, 38, 14], [51, 38, 25], [51, 38, 30], [51, 38, 34], [51, 38, 35], [51, 38, 36], [51, 38, 46], [51, 39, 6], [51, 39, 7], [51, 39, 15], [51, 39, 19], [51, 39, 23], [51, 39, 28], [51, 39, 41], [51, 39, 50], [51, 40, 1], [51, 40, 4], [51, 40, 10], [51, 40, 26], [51, 40, 29], [51, 40, 33], [51, 40, 48], [51, 40, 51], [51, 41, 5], [51, 41, 6], [51, 41, 20], [51, 41, 24], [51, 41, 28], [51, 41, 39], [51, 41, 43], [51, 41, 50], [51, 42, 8], [51, 42, 9], [51, 42, 22], [51, 42, 32], [51, 42, 35], [51, 42, 36], [51, 42, 37], [51, 42, 49], [51, 43, 5], [51, 43, 6], [51, 43, 13], [51, 43, 20], [51, 43, 24], [51, 43, 27], [51, 43, 41], [51, 43, 52], [51, 44, 11], [51, 44, 15], [51, 44, 16], [51, 44, 17], [51, 44, 18], [51, 44, 19], [51, 44, 21], [51, 44, 31], [51, 45, 1], [51, 45, 4], [51, 45, 11], [51, 45, 16], [51, 45, 21], [51, 45, 26], [51, 45, 31], [51, 45, 51], [51, 46, 3], [51, 46, 14], [51, 46, 25], [51, 46, 30], [51, 46, 34], [51, 46, 36], [51, 46, 38], [51, 46, 47], [51, 47, 3], [51, 47, 10], [51, 47, 12], [51, 47, 14], [51, 47, 25], [51, 47, 29], [51, 47, 46], [51, 47, 48], [51, 48, 3], [51, 48, 10], [51, 48, 12], [51, 48, 26], [51, 48, 29], [51, 48, 33], [51, 48, 40], [51, 48, 47], [51, 49, 2], [51, 49, 8], [51, 49, 13], [51, 49, 27], [51, 49, 32], [51, 49, 37], [51, 49, 42], [51, 49, 52], [51, 50, 5], [51, 50, 6], [51, 50, 7], [51, 50, 23], [51, 50, 24], [51, 50, 28], [51, 50, 39], [51, 50, 41], [51, 51, 0], [51, 51, 1], [51, 51, 4], [51, 51, 16], [51, 51, 21], [51, 51, 26], [51, 51, 33], [51, 51, 40], [51, 51, 45], [51, 51, 51], [51, 52, 2], [51, 52, 8], [51, 52, 13], [51, 52, 20], [51, 52, 27], [51, 52, 37], [51, 52, 43], [51, 52, 49], [52, 0, 52], [52, 1, 1], [52, 1, 52], [52, 52, 0], [52, 52, 1], [52, 52, 52]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p1-ff-nikodym-d3-p53/tests/check.py b/tasks/optimize-ae-p1-ff-nikodym-d3-p53/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..6345846c9b9114bf209db5350d6863485823b433 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p53/tests/check.py @@ -0,0 +1,47 @@ +"""Finite-field Nikodym set N in F_p^3, submitted as its complement. Score = |N| (minimize). + +Every point x of F_p^3 needs a direction v != 0 with x + t v in N for all t != 0 (x itself may lie outside N). +Upstream (AlphaEvolve `finite_field_nikodym.ipynb`) deduplicated silently; here the complement list must be +duplicate-free and in range. All p^2 + p + 1 projective directions are checked, vectorised over all points. +""" +import itertools + +import numpy as np + +from run import Invalid, int_list + + +def check(inst, ans): + p, d = inst["p"], 3 + rem = ans.get("removed") + if not isinstance(rem, list): + raise Invalid("removed must be a list") + if len(rem) >= p ** d: + raise Invalid("cannot remove every point") + w = np.array([p * p, p, 1], dtype=np.int64) + R = np.array([int_list(x, d, 0, p - 1, "point") for x in rem], dtype=np.int64).reshape(-1, d) + codes_r = R @ w + if len(np.unique(codes_r)) != len(codes_r): + raise Invalid("duplicate removed points") + in_n = np.ones(p ** d, dtype=bool) + in_n[codes_r] = False + X = np.stack(np.unravel_index(np.arange(p ** d), (p,) * d), axis=1).astype(np.int64) + good = np.zeros(p ** d, dtype=bool) + need = p - 1 + in_n.astype(np.int64) # points of N on the line through x, other than x, must number p-1 + done = False + for i in range(d): + for tail in itertools.product(range(p), repeat=d - 1 - i): + v = np.array([0] * i + [1] + list(tail), dtype=np.int64) + lid = ((X - X[:, i:i + 1] * v) % p) @ w + cnt = np.bincount(lid[in_n], minlength=p ** d) + good |= cnt[lid] == need + if good.all(): + done = True + break + if done: + break + if not done: + x = np.flatnonzero(~good)[0] + raise Invalid(f"point {X[x].tolist()} lies on no punctured line inside N") + size = p ** d - len(rem) + return size, {"size": size} diff --git a/tasks/optimize-ae-p1-ff-nikodym-d3-p53/tests/instance.json b/tasks/optimize-ae-p1-ff-nikodym-d3-p53/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e28781637d2f90a4b400ad5727fc1b12182ef8a5 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p53/tests/instance.json @@ -0,0 +1 @@ +{"p": 53, "direction": "minimize", "baseline": 148877, "best_known": 134908, "family": "ae_p1_ff_nikodym", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p1-ff-nikodym-d3-p53/tests/run.py b/tasks/optimize-ae-p1-ff-nikodym-d3-p53/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p53/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/optimize-ae-p1-ff-nikodym-d3-p53/tests/test.sh b/tasks/optimize-ae-p1-ff-nikodym-d3-p53/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p53/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/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-p17-young-convolution-p5-4-q5-3/environment/Dockerfile b/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==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-p17-young-convolution-p5-4-q5-3/environment/instance.json b/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9dbedd6e983016b3b5c1989b09724ec2bca3b4c1 --- /dev/null +++ b/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/environment/instance.json @@ -0,0 +1 @@ +{"p": 1.25, "q": 1.6666666666666667, "max_len": 10000, "direction": "maximize", "family": "ae_p17_young_convolution", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/solution/solve.sh b/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..338125d29274a5d0e4111080560781b32ba6ec51 --- /dev/null +++ b/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/solution/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": [7.885054154707537e-07, 8.034193240279514e-07, 8.186050838394927e-07, 8.340674500484888e-07, 8.498112571760517e-07, 8.658414203766359e-07, 8.821629367119889e-07, 8.987808864439844e-07, 9.15700434346581e-07, 9.329268310371573e-07, 9.504654143275374e-07, 9.683216105948993e-07, 9.865009361729048e-07, 1.0050089987632872e-06, 1.0238514988681896e-06, 1.0430342312435222e-06, 1.0625630863736429e-06, 1.0824440519676344e-06, 1.1026832144774559e-06, 1.1232867606383127e-06, 1.144260979031483e-06, 1.1656122616699423e-06, 1.187347105607082e-06, 1.2094721145688172e-06, 1.2319940006094348e-06, 1.2549195857914454e-06, 1.2782558038897943e-06, 1.3020097021207698e-06, 1.3261884428958988e-06, 1.3507993056011755e-06, 1.3758496884019687e-06, 1.401347110073961e-06, 1.4272992118604102e-06, 1.4537137593561612e-06, 1.4805986444186573e-06, 1.5079618871064305e-06, 1.5358116376453338e-06, 1.564156178422905e-06, 1.5930039260112622e-06, 1.6223634332188747e-06, 1.6522433911715805e-06, 1.6826526314232793e-06, 1.713600128096621e-06, 1.7450950000541179e-06, 1.7771465131001076e-06, 1.8097640822138895e-06, 1.8429572738145197e-06, 1.8767358080575837e-06, 1.9111095611644816e-06, 1.9460885677845126e-06, 1.981683023390307e-06, 2.017903286706891e-06, 2.054759882174993e-06, 2.0922635024488845e-06, 2.130425010929239e-06, 2.169255444331503e-06, 2.2087660152901782e-06, 2.2489681149994994e-06, 2.28987331589096e-06, 2.331493374348137e-06, 2.37384023345938e-06, 2.4169260258087e-06, 2.4607630763054385e-06, 2.505363905053204e-06, 2.5507412302585312e-06, 2.5969079711798012e-06, 2.643877251116883e-06, 2.6916624004420804e-06, 2.7402769596727943e-06, 2.789734682586581e-06, 2.840049539378956e-06, 2.891235719864593e-06, 2.9433076367224446e-06, 2.996279928785307e-06, 3.0501674643743633e-06, 3.104985344679363e-06, 3.160748907184798e-06, 3.2174737291429516e-06, 3.2751756310940548e-06, 3.333870680434425e-06, 3.393575195032958e-06, 3.454305746896726e-06, 3.5160791658861915e-06, 3.5789125434806696e-06, 3.642823236594626e-06, 3.707828871445565e-06, 3.7739473474739042e-06, 3.841196841315677e-06, 3.90959581082857e-06, 3.979162999172045e-06, 4.049917438942129e-06, 4.1218784563615205e-06, 4.195065675525812e-06, 4.26949902270623e-06, 4.345198730709975e-06, 4.422185343298448e-06, 4.500479719664291e-06, 4.580103038967913e-06, 4.661076804934169e-06, 4.743422850509934e-06, 4.827163342583276e-06, 4.9123207867649734e-06, 4.9989180322331855e-06, 5.086978276641876e-06, 5.176525071093829e-06, 5.267582325179107e-06, 5.360174312079504e-06, 5.454325673740002e-06, 5.550061426107846e-06, 5.6474069644401045e-06, 5.746388068680582e-06, 5.847030908906715e-06, 5.949362050847448e-06, 6.053408461472784e-06, 6.159197514655953e-06, 6.266756996908957e-06, 6.376115113192391e-06, 6.487300492800331e-06, 6.600342195321235e-06, 6.715269716675743e-06, 6.832112995232149e-06, 6.9509024180004836e-06, 7.071668826906256e-06, 7.194443525144471e-06, 7.319258283615136e-06, 7.446145347440973e-06, 7.575137442568363e-06, 7.706267782452537e-06, 7.839570074827766e-06, 7.975078528563723e-06, 8.11282786060879e-06, 8.25285330302158e-06, 8.395190610091276e-06, 8.539876065548121e-06, 8.686946489864868e-06, 8.83643924765037e-06, 8.988392255136207e-06, 9.142843987757264e-06, 9.299833487827776e-06, 9.459400372313274e-06, 9.6215848407001e-06, 9.786427682962939e-06, 9.953970287632187e-06, 1.012425464996143e-05, 1.0297323380196954e-05, 1.0473219711949729e-05, 1.0651987510671414e-05, 1.0833671282235262e-05, 1.1018316181623306e-05, 1.1205968021720777e-05, 1.139667328221905e-05, 1.1590479118628077e-05, 1.1787433371399938e-05, 1.1987584575164287e-05, 1.2190981968076836e-05, 1.2397675501282714e-05, 1.2607715848495096e-05, 1.2821154415691118e-05, 1.3038043350925676e-05, 1.3258435554264707e-05, 1.3482384687839415e-05, 1.3709945186022188e-05, 1.3941172265725933e-05, 1.4176121936827966e-05, 1.4414851012719817e-05, 1.4657417120984158e-05, 1.4903878714200435e-05, 1.515429508088037e-05, 1.5408726356534485e-05, 1.566723353487171e-05, 1.5929878479132618e-05, 1.6196723933558247e-05, 1.6467833534995695e-05, 1.674327182464188e-05, 1.7023104259927083e-05, 1.7307397226539566e-05, 1.7596218050592426e-05, 1.788963501093512e-05, 1.818771735160972e-05, 1.8490535294454657e-05, 1.8798160051856722e-05, 1.911066383965296e-05, 1.9428119890184397e-05, 1.97506024655024e-05, 2.0078186870729614e-05, 2.041094946757766e-05, 2.074896768802162e-05, 2.109232004813447e-05, 2.1441086162082098e-05, 2.1795346756280936e-05, 2.2155183683719487e-05, 2.2520679938445853e-05, 2.2891919670222526e-05, 2.3268988199349872e-05, 2.365197203166115e-05, 2.4040958873688912e-05, 2.443603764800615e-05, 2.483729850874295e-05, 2.524483285728075e-05, 2.565873335812558e-05, 2.60790939549627e-05, 2.6506009886893262e-05, 2.6939577704856484e-05, 2.7379895288236948e-05, 2.7827061861660925e-05, 2.828117801198185e-05, 2.8742345705457794e-05, 2.9210668305122715e-05, 2.968625058835255e-05, 3.0169198764628565e-05, 3.0659620493500547e-05, 3.115762490275009e-05, 3.166332260675699e-05, 3.217682572507067e-05, 3.2698247901188155e-05, 3.322770432154046e-05, 3.376531173469012e-05, 3.431118847074066e-05, 3.4865454460960596e-05, 3.5428231257624866e-05, 3.599964205407341e-05, 3.6579811704991446e-05, 3.716886674691143e-05, 3.776693541893996e-05, 3.837414768371168e-05, 3.899063524857121e-05, 3.961653158698587e-05, 4.025197196019235e-05, 4.0897093439077065e-05, 4.155203492629405e-05, 4.2216937178622396e-05, 4.289194282956468e-05, 4.3577196412189145e-05, 4.427284438221735e-05, 4.4979035141359716e-05, 4.5695919060901726e-05, 4.642364850554135e-05, 4.716237785748214e-05, 4.7912263540782016e-05, 4.867346404596177e-05, 4.9446139954874615e-05, 5.0230453965838864e-05, 5.102657091903755e-05, 5.183465782218405e-05, 5.2654883876460996e-05, 5.348742050272918e-05, 5.433244136801365e-05, 5.5190122412265686e-05, 5.606064187540569e-05, 5.694418032464736e-05, 5.7840920682107696e-05, 5.875104825270211e-05, 5.96747507523306e-05, 6.061221833635522e-05, 6.156364362837146e-05, 6.252922174927635e-05, 6.350915034663621e-05, 6.45036296243558e-05, 6.551286237265131e-05, 6.653705399833006e-05, 6.757641255538015e-05, 6.863114877587061e-05, 6.970147610116654e-05, 7.07876107134603e-05, 7.188977156762292e-05, 7.300818042337667e-05, 7.414306187779255e-05, 7.529464339811438e-05, 7.646315535491264e-05, 7.764883105557146e-05, 7.885190677810946e-05, 8.00726218053383e-05, 8.131121845936202e-05, 8.256794213641884e-05, 8.38430413420686e-05, 8.513676772672871e-05, 8.644937612155976e-05, 8.778112457470701e-05, 8.913227438789657e-05, 9.050309015339053e-05, 9.189383979130558e-05, 9.330479458729409e-05, 9.473622923059426e-05, 9.618842185244928e-05, 9.766165406489933e-05, 9.915621099995126e-05, 0.00010067238134912367, 0.00010221045740337486, 0.00010377073509341588, 0.00010535351403040821, 0.00010695909754705301, 0.00010858779273907228, 0.00011023991050708595, 0.00011191576559888546, 0.00011361567665211183, 0.00011533996623733509, 0.00011708896090154093, 0.00011886299121202927, 0.0001206623918007226, 0.00012248750140889233, 0.0001243386629323032, 0.00012621622346677719, 0.00012812053435418572, 0.0001300519512288659, 0.00013201083406446865, 0.00013399754722123898, 0.00013601245949373475, 0.00013805594415898162, 0.00014012837902507302, 0.00014223014648021202, 0.00014436163354220562, 0.00014652323190840632, 0.00014871533800610978, 0.00015093835304340924, 0.00015319268306050884, 0.00015547873898150307, 0.00015779693666661873, 0.00016014769696492834, 0.00016253144576753412, 0.00016494861406123084, 0.0001673996379826411, 0.00016988495887283682, 0.00017240502333244152, 0.00017496028327722356, 0.00017755119599417553, 0.00018017822419809091, 0.00018284183608863278, 0.0001855425054079074, 0.00018828071149853582, 0.00019105693936223282, 0.00019387167971889434, 0.00019672542906619655, 0.00019961868973970842, 0.00020255196997352474, 0.00020552578396141474, 0.0002085406519185027, 0.0002115971001434662, 0.00021469566108127063, 0.00021783687338643387, 0.0002210212819868279, 0.0002242494381480176, 0.00022752189953814425, 0.0002308392302933526, 0.00023420200108376289, 0.00023761078918000197, 0.00024106617852027903, 0.0002445687597780246, 0.00024811913043008745, 0.00025171789482549386, 0.000255365664254774, 0.00025906305701985945, 0.00026281069850454445, 0.00026660922124553297, 0.0002704592650040578, 0.00027436147683807866, 0.00027831651117506893, 0.00028232502988538436, 0.0002863877023562269, 0.00029050520556619524, 0.00029467822416043353, 0.00029890745052637896, 0.0003031935848701116, 0.0003075373352933031, 0.0003119394178707781, 0.0003164005567286831, 0.0003209214841232658, 0.0003255029405202756, 0.00033014567467497637, 0.0003348504437127798, 0.00033961801321051257, 0.00034444915727829616, 0.0003493446586420658, 0.0003543053087267175, 0.000359331907739891, 0.00036442526475638796, 0.0003695861978032357, 0.0003748155339453838, 0.00038011410937205885, 0.00038548276948375686, 0.0003909223689798914, 0.00039643377194709226, 0.0004020178519481628, 0.0004076754921116925, 0.0004134075852223329, 0.0004192150338117329, 0.00042509875025014733, 0.00043105965683870476, 0.00043709868590235214, 0.00044321677988346913, 0.0004494148914361602, 0.000455693983521222, 0.00046205502950179294, 0.00046849901323968554, 0.0004750269291923961, 0.0004816397825108143, 0.0004883385891376105, 0.0004951243759063193, 0.0005019981806411141, 0.0005089610522572798, 0.0005160140508623799, 0.0005231582478581274, 0.0005303947260429473, 0.0005377245797152604, 0.0005451489147774535, 0.0005526688488405691, 0.0005602855113297005, 0.0005680000435900949, 0.0005758135989939776, 0.0005837273430480826, 0.0005917424535018999, 0.0005998601204566506, 0.0006080815464749688, 0.0006164079466913127, 0.0006248405489230971, 0.0006333805937825471, 0.0006420293347892826, 0.000650788038483625, 0.0006596579845406391, 0.0006686404658848911, 0.0006777367888059599, 0.0006869482730746615, 0.0006962762520600144, 0.0007057220728469395, 0.0007152870963546979, 0.0007249726974560602, 0.0007347802650972244, 0.0007447112024184513, 0.00075476692687547, 0.0007649488703615997, 0.0007752584793306218, 0.0007856972149203949, 0.00079626655307721, 0.0008069679846808929, 0.0008178030156706476, 0.0008287731671716384, 0.000839879975622337, 0.000851124992902591, 0.0008625097864624511, 0.0008740359394517444, 0.0008857050508503869, 0.0008975187355994539, 0.0009094786247329815, 0.0009215863655105305, 0.0009338436215504791, 0.0009462520729640834, 0.000958813416490266, 0.0009715293656311558, 0.000984401650788378, 0.0009974320194000815, 0.0010106222360787187, 0.0010239740827495633, 0.0010374893587899714, 0.001051169881169394, 0.0010650174845901225, 0.0010790340216287764, 0.0010932213628785362, 0.0011075813970921123, 0.0011221160313254505, 0.001136827191082184, 0.0011517168204587963, 0.0011667868822905607, 0.0011820393582981715, 0.0011974762492351315, 0.0012130995750358592, 0.0012289113749645313, 0.0012449137077646445, 0.0012611086518093107, 0.0012774983052522696, 0.0012940847861796193, 0.0013108702327622786, 0.0013278568034091546, 0.0013450466769210293, 0.0013624420526451573, 0.001380045150630572, 0.0013978582117841053, 0.00141588349802711, 0.001434123292452869, 0.001452579899484732, 0.0014712556450349294, 0.001490152876664079, 0.0015092739637413886, 0.0015286212976055474, 0.0015481972917262934, 0.0015680043818666722, 0.00158804502624595, 0.0016083217057032367, 0.0016288369238617402, 0.0016495932072937095, 0.001670593105686033, 0.0016918391920064883, 0.0017133340626706568, 0.0017350803377094758, 0.0017570806609374498, 0.0017793377001214686, 0.0018018541471503185, 0.0018246327182047655, 0.0018476761539282982, 0.0018709872195984839, 0.0018945687052989346, 0.001918423426091889, 0.0019425542221914074, 0.0019669639591371373, 0.00199165552796872, 0.0020166318454007464, 0.002041895853998308, 0.002067450522353127, 0.0020932988452602593, 0.002119443843895358, 0.0021458885659924945, 0.0021726360860225267, 0.002199689505372032, 0.002227051952522759, 0.0022547265832316135, 0.0022827165807111824, 0.0023110251558107558, 0.002339655547197879, 0.0023686110215403963, 0.0023978948736889955, 0.0024275104268602177, 0.0024574610328199995, 0.002487750072067637, 0.0025183809540202315, 0.002549357117197599, 0.0025806820294076156, 0.002612359187932003, 0.0026443921197125725, 0.0026767843815378215, 0.002709539560230036, 0.0027426612728327247, 0.0027761531667984795, 0.002810018920177212, 0.002844262241804765, 0.0028788868714919027, 0.0029138965802136528, 0.0029492951702989535, 0.002985086475620731, 0.003021274361786204, 0.003057862726327566, 0.003094855498892941, 0.003132256641437657, 0.0031700701484157815, 0.0032083000469719505, 0.003246950397133442, 0.003286025292002498, 0.0033255288579489106, 0.003365465254802812, 0.003405838676047674, 0.0034466533490135356, 0.0034879135350704047, 0.0035296235298218335, 0.00357178766329869, 0.0036144103001530133, 0.003657495839852124, 0.0037010487168727467, 0.0037450734008953224, 0.00378957439699838, 0.0038345562458530287, 0.0038800235239174934, 0.003925980843631749, 0.003972432853612135, 0.004019384238846097, 0.00406683972088688, 0.0041148040580482066, 0.004163282045599032, 0.004212278515958179, 0.004261798338888996, 0.004311846421693924, 0.0043624277094090145, 0.004413547184998324, 0.004465209869548281, 0.0045174208224618454, 0.004570185141652593, 0.004623507963738623, 0.004677394464236316, 0.004731849857753886, 0.004786879398184765, 0.004842488378900723, 0.004898682132944803, 0.004955466033223987, 0.00501284549270157, 0.005070825964589283, 0.005129412942539084, 0.005188611960834638, 0.005248428594582473, 0.005308868459902723, 0.005369937214119574, 0.005431640555951249, 0.005493984225699593, 0.005556974005439248, 0.005620615719206335, 0.005684915233186703, 0.005749878455903665, 0.005815511338405225, 0.0058818198744507305, 0.005948810100697093, 0.006016488096884284, 0.006084859986020368, 0.00615393193456581, 0.006223710152617235, 0.0062942008940905, 0.006365410456903074, 0.006437345183155714, 0.006510011459313489, 0.006583415716385976, 0.006657564430106733, 0.006732464121111991, 0.0068081213551185096, 0.006884542743100637, 0.0069617349414665105, 0.007039704652233303, 0.0071184586232017144, 0.007198003648129421, 0.007278346566903629, 0.007359494265712631, 0.0074414536772164095, 0.00752423178071617, 0.00760783560232289, 0.007692272215124763, 0.007777548739353499, 0.007863672342549699, 0.00795065023972686, 0.00803848969353434, 0.008127198014419133, 0.00821678256078637, 0.00830725073915864, 0.00839861000433403, 0.008490867859542789, 0.008584031856602814, 0.00867810959607373, 0.008773108727409515, 0.008869036949109857, 0.008965902008870026, 0.009063711703729273, 0.009162473880217818, 0.009262196434502202, 0.009362887312529307, 0.009464554510168631, 0.009567206073353063, 0.009670850098218001, 0.009775494731238878, 0.009881148169366971, 0.009987818660163522, 0.01009551450193213, 0.010204244043849339, 0.010314015686093587, 0.010424837879972141, 0.010536719128046329, 0.010649667984254813, 0.010763693054035038, 0.010878802994442657, 0.010995006514269101, 0.011112312374156975, 0.011230729386713706, 0.011350266416622866, 0.011470932380753567, 0.011592736248267708, 0.011715687040725039, 0.011839793832186115, 0.011965065749313004, 0.012091511971467678, 0.012219141730808361, 0.012347964312383362, 0.012477989054222623, 0.012609225347426997, 0.012741682636255, 0.012875370418207266, 0.013010298244108426, 0.01314647571818661, 0.013283912498150282, 0.013422618295262718, 0.013562602874413698, 0.013703876054188715, 0.013846447706935478, 0.013990327758827732, 0.014135526189926327, 0.014282053034237716, 0.014429918379769289, 0.014579132368582371, 0.014729705196842021, 0.014881647114864092, 0.015034968427159269, 0.015189679492474352, 0.01534579072383035, 0.015503312588557675, 0.015662255608328204, 0.015822630359184405, 0.015984447471565175, 0.016147717630328653, 0.016312451574771725, 0.016478660098646448, 0.016646354050173114, 0.016815544332050035, 0.01698624190146018, 0.01715845777007401, 0.01733220300404961, 0.01750748872402866, 0.017684326105129548, 0.01786272637693658, 0.018042700823485854, 0.018224260783247574, 0.018407417649104668, 0.018592182868327856, 0.018778567942547057, 0.01896658442771897, 0.019156243934091106, 0.01934755812616193, 0.01954053872263719, 0.0197351974963824, 0.019931546274371607, 0.020129596937631996, 0.020329361421184765, 0.020530851713981838, 0.02073407985883874, 0.02093905795236331, 0.021145798144880358, 0.021354312640352206, 0.021564613696295018, 0.02177671362369109, 0.02199062478689677, 0.022206359603546187, 0.022423930544450594, 0.02264335013349362, 0.022864630947521863, 0.023087785616231305, 0.023312826822049135, 0.023539767300011314, 0.023768619837635386, 0.02399939727478901, 0.024232112503553654, 0.024466778468083983, 0.024703408164462346, 0.024942014640548803, 0.02518261099582622, 0.025425210381240928, 0.025669825999038307, 0.025916471102593777, 0.026165158996238762, 0.026415903035082067, 0.026668716624826023, 0.0269236132215779, 0.027180606331656337, 0.027439709511392598, 0.027700936366927033, 0.027964300554000326, 0.02822981577773965, 0.02849749579243963, 0.028767354401338353, 0.029039405456387928, 0.029313662858019972, 0.029590140554905685, 0.02986885254371085, 0.03014981286884534, 0.030433035622207283, 0.03071853494292177, 0.03100632501707446, 0.03129642007743929, 0.03158883440320107, 0.03188358231967226, 0.03218067819800448, 0.0324801364548943, 0.03278197155228346, 0.033086197997053333, 0.033392830340714025, 0.03370188317908747, 0.034013371151984995, 0.03432730894287907, 0.03464371127856921, 0.03496259292884228, 0.03528396870612675, 0.03560785346514126, 0.03593426210253699, 0.036263209556534635, 0.03659471080655498, 0.036928780872843646, 0.03726543481608985, 0.037604687737039275, 0.03794655477610064, 0.03829105111294643, 0.03863819196610723, 0.03898799259256038, 0.03934046828731208, 0.0396956343829735, 0.04005350624933065, 0.040414099292908075, 0.040777428956526335, 0.041143510718853055, 0.041512360093947806, 0.04188399263080075, 0.04225842391286482, 0.04263566955758159, 0.043015745215900826, 0.043398666571793414, 0.04378444934175824, 0.04417310927432237, 0.044564662149534924, 0.04495912377845411, 0.045356510002628414, 0.04575683669357066, 0.046160119752225996, 0.04656637510843276, 0.04697561872037764, 0.04738786657404334, 0.04780313468265034, 0.048221439086091535, 0.04864279585036065, 0.049067221066973796, 0.0494947308523844, 0.04992534134739132, 0.05035906871654068, 0.05079592914752057, 0.051235938850549244, 0.05167911405775649, 0.052125471022558476, 0.05257502601902555, 0.05302779534124348, 0.053483795302667954, 0.05394304223547201, 0.05440555248988706, 0.054871342433536974, 0.055340428450765165, 0.05581282694195506, 0.05628855432284383, 0.0567676270238291, 0.05725006148926891, 0.05773587417677467, 0.05822508155649774, 0.0587177001104086, 0.05921374633156962, 0.05971323672340041, 0.06021618779893719, 0.06072261608008438, 0.06123253809685991, 0.061745970386633375, 0.062262929493357655, 0.06278343196679322, 0.06330749436172603, 0.06383513323717811, 0.06436636515561175, 0.06490120668212655, 0.0654396743836496, 0.065981784828119, 0.0665275545836602, 0.06707700021775613, 0.06763013829640974, 0.06818698538330023, 0.0687475580389322, 0.0693118728197782, 0.06987994627741437, 0.07045179495764922, 0.07102743539964558, 0.07160688413503617, 0.07219015768703195, 0.07277727256952393, 0.07336824528617807, 0.07396309232952386, 0.07456183018003577, 0.07516447530520821, 0.07577104415862355, 0.07638155317901414, 0.07699601878931676, 0.07761445739572123, 0.07823688538671184, 0.07886331913210262, 0.07949377498206586, 0.08012826926615399, 0.08076681829231498, 0.08140943834590124, 0.08205614568867227, 0.08270695655779044, 0.08336188716481063, 0.08402095369466309, 0.08468417230463053, 0.08535155912331839, 0.08602313024961877, 0.086698901751668, 0.08737888966579861, 0.08806310999548403, 0.08875157871027796, 0.08944431174474661, 0.09014132499739605, 0.09084263432959234, 0.09154825556447592, 0.09225820448587012, 0.09297249683718344, 0.09369114832030606, 0.09441417459450019, 0.09514159127528447, 0.09587341393331282, 0.09660965809324717, 0.09735033923262443, 0.09809547278071803, 0.09884507411739288, 0.09959915857195606, 0.10035774142200048, 0.10112083789224403, 0.10188846315336217, 0.10266063232081628, 0.10343736045367533, 0.10421866255343315, 0.10500455356281939, 0.1057950483646063, 0.10659016178040932, 0.10738990856948291, 0.108194303427511, 0.10900336098539272, 0.10981709580802285, 0.11063552239306715, 0.1114586551697328, 0.11228650849753441, 0.11311909666505474, 0.1139564338887006, 0.1147985343114544, 0.11564541200162086, 0.11649708095156922, 0.11735355507647077, 0.1182148482130322, 0.1190809741182239, 0.11995194646800501, 0.1208277788560432, 0.12170848479243096, 0.12259407770239661, 0.12348457092501317, 0.12437997771190125, 0.1252803112259292, 0.12618558453990888, 0.12709581063528788, 0.12801100240083804, 0.12893117263133985, 0.12985633402626381, 0.1307864991884483, 0.13172168062277329, 0.13266189073483164, 0.13360714182959638, 0.13455744611008524, 0.13551281567602183, 0.13647326252249387, 0.13743879853860808, 0.13840943550614293, 0.13938518509819794, 0.1403660588778404, 0.1413520682967497, 0.1423432246938584, 0.14333953929399196, 0.14434102320650496, 0.14534768742391582, 0.14635954282053837, 0.1473766001511126, 0.1483988700494322, 0.1494263630269707, 0.15045908947150535, 0.15149705964574, 0.15254028368592537, 0.1535887716004784, 0.15464253326859942, 0.1557015784388889, 0.15676591672796197, 0.1578355576190622, 0.15891051046067384, 0.15999078446513382, 0.16107638870724197, 0.16216733212287107, 0.1632636235075752, 0.16436527151519909, 0.16547228465648528, 0.16658467129768179, 0.16770243965914938, 0.16882559781396783, 0.16995415368654357, 0.17108811505121582, 0.17222748953086364, 0.17337228459551274, 0.17452250756094315, 0.17567816558729674, 0.17683926567768557, 0.1780058146768004, 0.17917781926952092, 0.18035528597952574, 0.181538221167904, 0.18272663103176734, 0.1839205216028643, 0.1851198987461946, 0.18632476815862603, 0.18753513536751137, 0.18875100572930875, 0.18997238442820236, 0.19119927647472565, 0.19243168670438607, 0.19366961977629255, 0.19491308017178446, 0.1961620721930634, 0.19741659996182737, 0.19867666741790677, 0.1999422783179045, 0.20121343623383753, 0.20249014455178213, 0.20377240647052142, 0.20506022500019716, 0.206353602960964, 0.20765254298164723, 0.20895704749840396, 0.2102671187533887, 0.21158275879342173, 0.212903969468662, 0.21423075243128342, 0.21556310913415638, 0.2169010408295322, 0.2182445485677333, 0.21959363319584616, 0.22094829535642124, 0.22230853548617563, 0.22367435381470163, 0.22504575036317978, 0.22642272494309784, 0.2278052771549744, 0.22919340638708793, 0.2305871118142118, 0.23198639239635405, 0.23339124687750445, 0.23480167378438607, 0.23621767142521377, 0.23763923788845795, 0.239066371041616, 0.240499068529989, 0.2419373277754657, 0.24338114597531227, 0.24483052010097042, 0.24628544689686108, 0.24774592287919603, 0.24921194433479582, 0.2506835073199166, 0.25216060765908305, 0.25364324094392954, 0.25513140253204825, 0.2566250875458474, 0.2581242908714146, 0.25962900715739035, 0.261139230813849, 0.2626549560111886, 0.2641761766790289, 0.2657028865051183, 0.2672350789342496, 0.26877274716718397, 0.2703158841595858, 0.27186448262096496, 0.27341853501362906, 0.2749780335516452, 0.27654297019981194, 0.2781133366726398, 0.2796891244333429, 0.28127032469283886, 0.2828569284087615, 0.28444892628448143, 0.28604630876813814, 0.28764906605168206, 0.2892571880699284, 0.2908706644996204, 0.2924894847585047, 0.2941136380044164, 0.2957431131343772, 0.29737789878370313, 0.29901798332512475, 0.30066335486791834, 0.3023140012570494, 0.30396991007232743, 0.3056310686275731, 0.30729746396979757, 0.30896908287839286, 0.3106459118643367, 0.31232793716940827, 0.3140151447654169, 0.3157075203534434, 0.317405049363095, 0.3191077169517723, 0.3208155080039499, 0.32252840713047015, 0.32424639866785004, 0.3259694666776023, 0.3276975949455692, 0.32943076698127016, 0.3311689660172643, 0.3329121750085256, 0.33466037663183335, 0.3364135532851751, 0.33817168708716644, 0.339934759876483, 0.3417027532113083, 0.34347564836879513, 0.34525342634454376, 0.34703606785209273, 0.3488235533224261, 0.3506158629034959, 0.3524129764597586, 0.35421487357172854, 0.356021533535546, 0.3578329353625612, 0.359649057778933, 0.36146987922524526, 0.3632953778561377, 0.3651255315399534, 0.3669603178584019, 0.3687997141062395, 0.3706436972909654, 0.3724922441325338, 0.37434533106308354, 0.37620293422668377, 0.37806502947909687, 0.3799315923875575, 0.3818025982305698, 0.38367802199772016, 0.385557838389509, 0.3874420218171979, 0.3893305464026758, 0.3912233859783412, 0.3931205140870036, 0.3950219039818006, 0.39692752862613445, 0.39883736069362574, 0.4007513725680847, 0.4026695363435015, 0.40459182382405323, 0.40651820652413073, 0.4084486556683823, 0.4103831421917766, 0.41232163673968336, 0.41426410966797383, 0.41621053104313777, 0.4181608706424215, 0.4201150979539828, 0.4220731821770658, 0.42403509222219404, 0.42600079671138363, 0.42797026397837357, 0.42994346206887757, 0.4319203587408528, 0.4339009214647898, 0.4358851174240203, 0.43787291351504554, 0.43986427634788294, 0.4418591722464337, 0.4438575672488686, 0.4458594271080342, 0.44786471729187904, 0.4498734029838983, 0.45188544908360023, 0.45390082020699063, 0.45591948068707855, 0.4579413945744008, 0.459966525637568, 0.4619948373638292, 0.46402629295965764, 0.466060855351356, 0.4680984871856827, 0.4701391508304974, 0.4721828083754278, 0.47422942163255605, 0.47627895213712595, 0.4783313611482703, 0.48038660964975904, 0.4824446583507672, 0.48450546768666447, 0.4865689978198239, 0.4886352086404525, 0.49070405976744125, 0.49277551054923685, 0.4948495200647331, 0.49692604712418353, 0.49900505027013475, 0.5010864877783797, 0.503170317658933, 0.5052564976570254, 0.5073449852541204, 0.5094357376689503, 0.5115287118585746, 0.5136238645194572, 0.515721152088566, 0.5178205307444923, 0.519921956408592, 0.5220253847461455, 0.5241307711675413, 0.5262380708294773, 0.5283472386361857, 0.5304582292406759, 0.5325709970460004, 0.5346854962065402, 0.5368016806293111, 0.5389195039752909, 0.5410389196607671, 0.5431598808587053, 0.545282340500138, 0.547406251275575, 0.5495315656364324, 0.5516582357964843, 0.5537862137333337, 0.5559154511899045, 0.5580458996759533, 0.5601775104696026, 0.5623102346188933, 0.5644440229433586, 0.5665788260356172, 0.5687145942629875, 0.5708512777691224, 0.5729888264756623, 0.5751271900839108, 0.5772663180765287, 0.5794061597192487, 0.5815466640626102, 0.5836877799437133, 0.5858294559879937, 0.5879716406110161, 0.5901142820202891, 0.5922573282170978, 0.5944007269983571, 0.596544425958485, 0.5986883724912943, 0.6008325137919037, 0.60297679685867, 0.6051211684951365, 0.6072655753120036, 0.6094099637291169, 0.6115542799774739, 0.6136984701012514, 0.6158424799598496, 0.617986255229957, 0.6201297414076316, 0.6222728838104038, 0.6244156275793944, 0.626557917681454, 0.6286996989113177, 0.6308409158937811, 0.6329815130858918, 0.6351214347791607, 0.6372606251017897, 0.6393990280209184, 0.6415365873448877, 0.6436732467255214, 0.6458089496604248, 0.6479436394953011, 0.6500772594262845, 0.6522097525022911, 0.6543410616273859, 0.6564711295631673, 0.6585998989311682, 0.6607273122152731, 0.6628533117641532, 0.6649778397937155, 0.6671008383895706, 0.6692222495095148, 0.6713420149860291, 0.673460076528793, 0.6755763757272157, 0.6776908540529807, 0.6798034528626075, 0.6819141134000275, 0.6840227767991759, 0.6861293840865973, 0.6882338761840675, 0.6903361939112288, 0.6924362779882407, 0.6945340690384438, 0.6966295075910396, 0.6987225340837822, 0.7008130888656858, 0.7029011121997449, 0.7049865442656679, 0.7070693251626248, 0.7091493949120073, 0.7112266934602031, 0.7133011606813808, 0.7153727363802912, 0.7174413602950769, 0.7195069721000974, 0.7215695114087651, 0.7236289177763936, 0.7256851307030568, 0.7277380896364619, 0.7297877339748315, 0.7318340030697985, 0.7338768362293107, 0.7359161727205483, 0.7379519517728502, 0.7399841125806518, 0.7420125943064326, 0.744037336083675, 0.746058277019831, 0.7480753561993014, 0.750088512686422, 0.7520976855284606, 0.7541028137586228, 0.7561038363990666, 0.7581006924639264, 0.7600933209623438, 0.7620816609015094, 0.7640656512897102, 0.7660452311393866, 0.7680203394701963, 0.7699909153120862, 0.7719568977083706, 0.7739182257188184, 0.7758748384227447, 0.7778266749221117, 0.779773674344633, 0.7817157758468875, 0.7836529186174362, 0.7855850418799476, 0.7875120848963256, 0.7894339869698459, 0.7913506874482948, 0.7932621257271154, 0.7951682412525556, 0.7970689735248236, 0.7989642621012453, 0.8008540465994268, 0.8027382667004205, 0.8046168621518942, 0.8064897727713048, 0.8083569384490734, 0.8102182991517646, 0.8120737949252677, 0.8139233658979803, 0.815766952283995, 0.817604494386286, 0.8194359325998999, 0.8212612074151457, 0.8230802594207878, 0.8248930293072382, 0.8266994578697511, 0.8284994860116173, 0.8302930547473583, 0.8320801052059215, 0.8338605786338739, 0.8356344163985971, 0.8374015599914796, 0.8391619510311097, 0.8409155312664662, 0.8426622425801084, 0.844402026991364, 0.8461348266595153, 0.847860583886983, 0.8495792411225078, 0.8512907409643292, 0.8529950261633619, 0.8546920396263681, 0.8563817244191275, 0.8580640237696029, 0.8597388810711022, 0.8614062398854365, 0.8630660439460734, 0.8647182371612862, 0.8663627636172974, 0.8679995675814187, 0.8696285935051837, 0.8712497860274765, 0.8728630899776535, 0.8744684503786602, 0.8760658124501403, 0.8776551216115397, 0.8792363234852022, 0.8808093638994599, 0.8823741888917139, 0.8839307447115106, 0.8854789778236068, 0.8870188349110297, 0.8885502628781267, 0.8900732088536072, 0.8915876201935765, 0.8930934444845596, 0.8945906295465157, 0.8960791234358442, 0.8975588744483801, 0.8990298311223802, 0.9004919422414978, 0.9019451568377483, 0.9033894241944637, 0.9048246938492356, 0.9062509155968477, 0.9076680394921963, 0.9090760158532004, 0.9104747952636979, 0.9118643285763315, 0.9132445669154212, 0.914615461679825, 0.9159769645457855, 0.9173290274697651, 0.9186716026912668, 0.9200046427356416, 0.9213281004168824, 0.9226419288404039, 0.9239460814058078, 0.9252405118096351, 0.9265251740481009, 0.9278000224198176, 0.9290650115285004, 0.9303200962856589, 0.9315652319132728, 0.932800373946451, 0.9340254782360763, 0.9352405009514325, 0.9364453985828155, 0.937640127944128, 0.9388246461754567, 0.9399989107456334, 0.9411628794547774, 0.9423165104368221, 0.9434597621620219, 0.944592593439443, 0.945714963419435, 0.9468268315960837, 0.9479281578096476, 0.9490189022489722, 0.9500990254538884, 0.9511684883175899, 0.9522272520889923, 0.9532752783750715, 0.9543125291431837, 0.9553389667233638, 0.9563545538106056, 0.9573592534671197, 0.9583530291245719, 0.9593358445863012, 0.9603076640295157, 0.9612684520074686, 0.9622181734516118, 0.963156793673729, 0.9640842783680468, 0.9650005936133235, 0.9659057058749161, 0.9667995820068263, 0.9676821892537214, 0.9685534952529363, 0.969413468036449, 0.9702620760328364, 0.9710992880692048, 0.9719250733730986, 0.972739401574385, 0.973542242707115, 0.9743335672113612, 0.9751133459350315, 0.9758815501356588, 0.9766381514821663, 0.9773831220566087, 0.9781164343558894, 0.978838061293452, 0.9795479762009479, 0.980246152829879, 0.9809325653532146, 0.9816071883669838, 0.9822699968918427, 0.9829209663746151, 0.9835600726898093, 0.9841872921411069, 0.9848026014628285, 0.985405977821371, 0.9859973988166197, 0.986576842483335, 0.9871442872925114, 0.9876997121527102, 0.9882430964113676, 0.9887744198560726, 0.9892936627158213, 0.9898008056622428, 0.9902958298107981, 0.9907787167219521, 0.9912494484023183, 0.9917080073057768, 0.9921543763345634, 0.9925885388403328, 0.9930104786251931, 0.9934201799427134, 0.9938176274989023, 0.9942028064531608, 0.9945757024192045, 0.9949363014659599, 0.9952845901184317, 0.995620555358542, 0.9959441846259408, 0.9962554658187895, 0.9965543872945147, 0.9968409378705334, 0.9971151068249512, 0.9973768838972303, 0.9976262592888298, 0.9978632236638165, 0.9980877681494482, 0.9982998843367267, 0.9984995642809228, 0.9986868005020727, 0.9988615859854443, 0.9990239141819757, 0.999173779008684, 0.9993111748490452, 0.9994360965533452, 0.9995485394390012, 0.9996484992908544, 0.9997359723614333, 0.9998109553711881, 0.9998734455086953, 0.9999234404308334, 0.9999609382629295, 0.9999859375988764, 0.9999984375012207, 0.9999984375012207, 0.9999859375988764, 0.9999609382629295, 0.9999234404308334, 0.9998734455086953, 0.9998109553711881, 0.9997359723614333, 0.9996484992908544, 0.9995485394390012, 0.9994360965533452, 0.9993111748490452, 0.999173779008684, 0.9990239141819757, 0.9988615859854443, 0.9986868005020727, 0.9984995642809228, 0.9982998843367267, 0.9980877681494482, 0.9978632236638165, 0.9976262592888298, 0.9973768838972303, 0.9971151068249512, 0.9968409378705334, 0.9965543872945147, 0.9962554658187895, 0.9959441846259408, 0.995620555358542, 0.9952845901184317, 0.9949363014659599, 0.9945757024192045, 0.9942028064531608, 0.9938176274989023, 0.9934201799427134, 0.9930104786251931, 0.9925885388403328, 0.9921543763345634, 0.9917080073057768, 0.9912494484023183, 0.9907787167219521, 0.9902958298107981, 0.9898008056622428, 0.9892936627158213, 0.9887744198560726, 0.9882430964113676, 0.9876997121527102, 0.9871442872925114, 0.986576842483335, 0.9859973988166197, 0.985405977821371, 0.9848026014628285, 0.9841872921411069, 0.9835600726898093, 0.9829209663746151, 0.9822699968918427, 0.9816071883669838, 0.9809325653532146, 0.980246152829879, 0.9795479762009479, 0.978838061293452, 0.9781164343558894, 0.9773831220566087, 0.9766381514821663, 0.9758815501356588, 0.9751133459350315, 0.9743335672113612, 0.973542242707115, 0.972739401574385, 0.9719250733730986, 0.9710992880692048, 0.9702620760328364, 0.969413468036449, 0.9685534952529363, 0.9676821892537214, 0.9667995820068263, 0.9659057058749161, 0.9650005936133235, 0.9640842783680468, 0.963156793673729, 0.9622181734516118, 0.9612684520074686, 0.9603076640295157, 0.9593358445863012, 0.9583530291245719, 0.9573592534671197, 0.9563545538106056, 0.9553389667233638, 0.9543125291431837, 0.9532752783750715, 0.9522272520889923, 0.9511684883175899, 0.9500990254538884, 0.9490189022489722, 0.9479281578096476, 0.9468268315960837, 0.945714963419435, 0.944592593439443, 0.9434597621620219, 0.9423165104368221, 0.9411628794547774, 0.9399989107456334, 0.9388246461754567, 0.937640127944128, 0.9364453985828155, 0.9352405009514325, 0.9340254782360763, 0.932800373946451, 0.9315652319132728, 0.9303200962856589, 0.9290650115285004, 0.9278000224198176, 0.9265251740481009, 0.9252405118096351, 0.9239460814058078, 0.9226419288404039, 0.9213281004168824, 0.9200046427356416, 0.9186716026912668, 0.9173290274697651, 0.9159769645457855, 0.914615461679825, 0.9132445669154212, 0.9118643285763315, 0.9104747952636979, 0.9090760158532004, 0.9076680394921963, 0.9062509155968477, 0.9048246938492356, 0.9033894241944637, 0.9019451568377483, 0.9004919422414978, 0.8990298311223802, 0.8975588744483801, 0.8960791234358442, 0.8945906295465157, 0.8930934444845596, 0.8915876201935765, 0.8900732088536072, 0.8885502628781267, 0.8870188349110297, 0.8854789778236068, 0.8839307447115106, 0.8823741888917139, 0.8808093638994599, 0.8792363234852022, 0.8776551216115397, 0.8760658124501403, 0.8744684503786602, 0.8728630899776535, 0.8712497860274765, 0.8696285935051837, 0.8679995675814187, 0.8663627636172974, 0.8647182371612862, 0.8630660439460734, 0.8614062398854365, 0.8597388810711022, 0.8580640237696029, 0.8563817244191275, 0.8546920396263681, 0.8529950261633619, 0.8512907409643292, 0.8495792411225078, 0.847860583886983, 0.8461348266595153, 0.844402026991364, 0.8426622425801084, 0.8409155312664662, 0.8391619510311097, 0.8374015599914796, 0.8356344163985971, 0.8338605786338739, 0.8320801052059215, 0.8302930547473583, 0.8284994860116173, 0.8266994578697511, 0.8248930293072382, 0.8230802594207878, 0.8212612074151457, 0.8194359325998999, 0.817604494386286, 0.815766952283995, 0.8139233658979803, 0.8120737949252677, 0.8102182991517646, 0.8083569384490734, 0.8064897727713048, 0.8046168621518942, 0.8027382667004205, 0.8008540465994268, 0.7989642621012453, 0.7970689735248236, 0.7951682412525556, 0.7932621257271154, 0.7913506874482948, 0.7894339869698459, 0.7875120848963256, 0.7855850418799476, 0.7836529186174362, 0.7817157758468875, 0.779773674344633, 0.7778266749221117, 0.7758748384227447, 0.7739182257188184, 0.7719568977083706, 0.7699909153120862, 0.7680203394701963, 0.7660452311393866, 0.7640656512897102, 0.7620816609015094, 0.7600933209623438, 0.7581006924639264, 0.7561038363990666, 0.7541028137586228, 0.7520976855284606, 0.750088512686422, 0.7480753561993014, 0.746058277019831, 0.744037336083675, 0.7420125943064326, 0.7399841125806518, 0.7379519517728502, 0.7359161727205483, 0.7338768362293107, 0.7318340030697985, 0.7297877339748315, 0.7277380896364619, 0.7256851307030568, 0.7236289177763936, 0.7215695114087651, 0.7195069721000974, 0.7174413602950769, 0.7153727363802912, 0.7133011606813808, 0.7112266934602031, 0.7091493949120073, 0.7070693251626248, 0.7049865442656679, 0.7029011121997449, 0.7008130888656858, 0.6987225340837822, 0.6966295075910396, 0.6945340690384438, 0.6924362779882407, 0.6903361939112288, 0.6882338761840675, 0.6861293840865973, 0.6840227767991759, 0.6819141134000275, 0.6798034528626075, 0.6776908540529807, 0.6755763757272157, 0.673460076528793, 0.6713420149860291, 0.6692222495095148, 0.6671008383895706, 0.6649778397937155, 0.6628533117641532, 0.6607273122152731, 0.6585998989311682, 0.6564711295631673, 0.6543410616273859, 0.6522097525022911, 0.6500772594262845, 0.6479436394953011, 0.6458089496604248, 0.6436732467255214, 0.6415365873448877, 0.6393990280209184, 0.6372606251017897, 0.6351214347791607, 0.6329815130858918, 0.6308409158937811, 0.6286996989113177, 0.626557917681454, 0.6244156275793944, 0.6222728838104038, 0.6201297414076316, 0.617986255229957, 0.6158424799598496, 0.6136984701012514, 0.6115542799774739, 0.6094099637291169, 0.6072655753120036, 0.6051211684951365, 0.60297679685867, 0.6008325137919037, 0.5986883724912943, 0.596544425958485, 0.5944007269983571, 0.5922573282170978, 0.5901142820202891, 0.5879716406110161, 0.5858294559879937, 0.5836877799437133, 0.5815466640626102, 0.5794061597192487, 0.5772663180765287, 0.5751271900839108, 0.5729888264756623, 0.5708512777691224, 0.5687145942629875, 0.5665788260356172, 0.5644440229433586, 0.5623102346188933, 0.5601775104696026, 0.5580458996759533, 0.5559154511899045, 0.5537862137333337, 0.5516582357964843, 0.5495315656364324, 0.547406251275575, 0.545282340500138, 0.5431598808587053, 0.5410389196607671, 0.5389195039752909, 0.5368016806293111, 0.5346854962065402, 0.5325709970460004, 0.5304582292406759, 0.5283472386361857, 0.5262380708294773, 0.5241307711675413, 0.5220253847461455, 0.519921956408592, 0.5178205307444923, 0.515721152088566, 0.5136238645194572, 0.5115287118585746, 0.5094357376689503, 0.5073449852541204, 0.5052564976570254, 0.503170317658933, 0.5010864877783797, 0.49900505027013475, 0.49692604712418353, 0.4948495200647331, 0.49277551054923685, 0.49070405976744125, 0.4886352086404525, 0.4865689978198239, 0.48450546768666447, 0.4824446583507672, 0.48038660964975904, 0.4783313611482703, 0.47627895213712595, 0.47422942163255605, 0.4721828083754278, 0.4701391508304974, 0.4680984871856827, 0.466060855351356, 0.46402629295965764, 0.4619948373638292, 0.459966525637568, 0.4579413945744008, 0.45591948068707855, 0.45390082020699063, 0.45188544908360023, 0.4498734029838983, 0.44786471729187904, 0.4458594271080342, 0.4438575672488686, 0.4418591722464337, 0.43986427634788294, 0.43787291351504554, 0.4358851174240203, 0.4339009214647898, 0.4319203587408528, 0.42994346206887757, 0.42797026397837357, 0.42600079671138363, 0.42403509222219404, 0.4220731821770658, 0.4201150979539828, 0.4181608706424215, 0.41621053104313777, 0.41426410966797383, 0.41232163673968336, 0.4103831421917766, 0.4084486556683823, 0.40651820652413073, 0.40459182382405323, 0.4026695363435015, 0.4007513725680847, 0.39883736069362574, 0.39692752862613445, 0.3950219039818006, 0.3931205140870036, 0.3912233859783412, 0.3893305464026758, 0.3874420218171979, 0.385557838389509, 0.38367802199772016, 0.3818025982305698, 0.3799315923875575, 0.37806502947909687, 0.37620293422668377, 0.37434533106308354, 0.3724922441325338, 0.3706436972909654, 0.3687997141062395, 0.3669603178584019, 0.3651255315399534, 0.3632953778561377, 0.36146987922524526, 0.359649057778933, 0.3578329353625612, 0.356021533535546, 0.35421487357172854, 0.3524129764597586, 0.3506158629034959, 0.3488235533224261, 0.34703606785209273, 0.34525342634454376, 0.34347564836879513, 0.3417027532113083, 0.339934759876483, 0.33817168708716644, 0.3364135532851751, 0.33466037663183335, 0.3329121750085256, 0.3311689660172643, 0.32943076698127016, 0.3276975949455692, 0.3259694666776023, 0.32424639866785004, 0.32252840713047015, 0.3208155080039499, 0.3191077169517723, 0.317405049363095, 0.3157075203534434, 0.3140151447654169, 0.31232793716940827, 0.3106459118643367, 0.30896908287839286, 0.30729746396979757, 0.3056310686275731, 0.30396991007232743, 0.3023140012570494, 0.30066335486791834, 0.29901798332512475, 0.29737789878370313, 0.2957431131343772, 0.2941136380044164, 0.2924894847585047, 0.2908706644996204, 0.2892571880699284, 0.28764906605168206, 0.28604630876813814, 0.28444892628448143, 0.2828569284087615, 0.28127032469283886, 0.2796891244333429, 0.2781133366726398, 0.27654297019981194, 0.2749780335516452, 0.27341853501362906, 0.27186448262096496, 0.2703158841595858, 0.26877274716718397, 0.2672350789342496, 0.2657028865051183, 0.2641761766790289, 0.2626549560111886, 0.261139230813849, 0.25962900715739035, 0.2581242908714146, 0.2566250875458474, 0.25513140253204825, 0.25364324094392954, 0.25216060765908305, 0.2506835073199166, 0.24921194433479582, 0.24774592287919603, 0.24628544689686108, 0.24483052010097042, 0.24338114597531227, 0.2419373277754657, 0.240499068529989, 0.239066371041616, 0.23763923788845795, 0.23621767142521377, 0.23480167378438607, 0.23339124687750445, 0.23198639239635405, 0.2305871118142118, 0.22919340638708793, 0.2278052771549744, 0.22642272494309784, 0.22504575036317978, 0.22367435381470163, 0.22230853548617563, 0.22094829535642124, 0.21959363319584616, 0.2182445485677333, 0.2169010408295322, 0.21556310913415638, 0.21423075243128342, 0.212903969468662, 0.21158275879342173, 0.2102671187533887, 0.20895704749840396, 0.20765254298164723, 0.206353602960964, 0.20506022500019716, 0.20377240647052142, 0.20249014455178213, 0.20121343623383753, 0.1999422783179045, 0.19867666741790677, 0.19741659996182737, 0.1961620721930634, 0.19491308017178446, 0.19366961977629255, 0.19243168670438607, 0.19119927647472565, 0.18997238442820236, 0.18875100572930875, 0.18753513536751137, 0.18632476815862603, 0.1851198987461946, 0.1839205216028643, 0.18272663103176734, 0.181538221167904, 0.18035528597952574, 0.17917781926952092, 0.1780058146768004, 0.17683926567768557, 0.17567816558729674, 0.17452250756094315, 0.17337228459551274, 0.17222748953086364, 0.17108811505121582, 0.16995415368654357, 0.16882559781396783, 0.16770243965914938, 0.16658467129768179, 0.16547228465648528, 0.16436527151519909, 0.1632636235075752, 0.16216733212287107, 0.16107638870724197, 0.15999078446513382, 0.15891051046067384, 0.1578355576190622, 0.15676591672796197, 0.1557015784388889, 0.15464253326859942, 0.1535887716004784, 0.15254028368592537, 0.15149705964574, 0.15045908947150535, 0.1494263630269707, 0.1483988700494322, 0.1473766001511126, 0.14635954282053837, 0.14534768742391582, 0.14434102320650496, 0.14333953929399196, 0.1423432246938584, 0.1413520682967497, 0.1403660588778404, 0.13938518509819794, 0.13840943550614293, 0.13743879853860808, 0.13647326252249387, 0.13551281567602183, 0.13455744611008524, 0.13360714182959638, 0.13266189073483164, 0.13172168062277329, 0.1307864991884483, 0.12985633402626381, 0.12893117263133985, 0.12801100240083804, 0.12709581063528788, 0.12618558453990888, 0.1252803112259292, 0.12437997771190125, 0.12348457092501317, 0.12259407770239661, 0.12170848479243096, 0.1208277788560432, 0.11995194646800501, 0.1190809741182239, 0.1182148482130322, 0.11735355507647077, 0.11649708095156922, 0.11564541200162086, 0.1147985343114544, 0.1139564338887006, 0.11311909666505474, 0.11228650849753441, 0.1114586551697328, 0.11063552239306715, 0.10981709580802285, 0.10900336098539272, 0.108194303427511, 0.10738990856948291, 0.10659016178040932, 0.1057950483646063, 0.10500455356281939, 0.10421866255343315, 0.10343736045367533, 0.10266063232081628, 0.10188846315336217, 0.10112083789224403, 0.10035774142200048, 0.09959915857195606, 0.09884507411739288, 0.09809547278071803, 0.09735033923262443, 0.09660965809324717, 0.09587341393331282, 0.09514159127528447, 0.09441417459450019, 0.09369114832030606, 0.09297249683718344, 0.09225820448587012, 0.09154825556447592, 0.09084263432959234, 0.09014132499739605, 0.08944431174474661, 0.08875157871027796, 0.08806310999548403, 0.08737888966579861, 0.086698901751668, 0.08602313024961877, 0.08535155912331839, 0.08468417230463053, 0.08402095369466309, 0.08336188716481063, 0.08270695655779044, 0.08205614568867227, 0.08140943834590124, 0.08076681829231498, 0.08012826926615399, 0.07949377498206586, 0.07886331913210262, 0.07823688538671184, 0.07761445739572123, 0.07699601878931676, 0.07638155317901414, 0.07577104415862355, 0.07516447530520821, 0.07456183018003577, 0.07396309232952386, 0.07336824528617807, 0.07277727256952393, 0.07219015768703195, 0.07160688413503617, 0.07102743539964558, 0.07045179495764922, 0.06987994627741437, 0.0693118728197782, 0.0687475580389322, 0.06818698538330023, 0.06763013829640974, 0.06707700021775613, 0.0665275545836602, 0.065981784828119, 0.0654396743836496, 0.06490120668212655, 0.06436636515561175, 0.06383513323717811, 0.06330749436172603, 0.06278343196679322, 0.062262929493357655, 0.061745970386633375, 0.06123253809685991, 0.06072261608008438, 0.06021618779893719, 0.05971323672340041, 0.05921374633156962, 0.0587177001104086, 0.05822508155649774, 0.05773587417677467, 0.05725006148926891, 0.0567676270238291, 0.05628855432284383, 0.05581282694195506, 0.055340428450765165, 0.054871342433536974, 0.05440555248988706, 0.05394304223547201, 0.053483795302667954, 0.05302779534124348, 0.05257502601902555, 0.052125471022558476, 0.05167911405775649, 0.051235938850549244, 0.05079592914752057, 0.05035906871654068, 0.04992534134739132, 0.0494947308523844, 0.049067221066973796, 0.04864279585036065, 0.048221439086091535, 0.04780313468265034, 0.04738786657404334, 0.04697561872037764, 0.04656637510843276, 0.046160119752225996, 0.04575683669357066, 0.045356510002628414, 0.04495912377845411, 0.044564662149534924, 0.04417310927432237, 0.04378444934175824, 0.043398666571793414, 0.043015745215900826, 0.04263566955758159, 0.04225842391286482, 0.04188399263080075, 0.041512360093947806, 0.041143510718853055, 0.040777428956526335, 0.040414099292908075, 0.04005350624933065, 0.0396956343829735, 0.03934046828731208, 0.03898799259256038, 0.03863819196610723, 0.03829105111294643, 0.03794655477610064, 0.037604687737039275, 0.03726543481608985, 0.036928780872843646, 0.03659471080655498, 0.036263209556534635, 0.03593426210253699, 0.03560785346514126, 0.03528396870612675, 0.03496259292884228, 0.03464371127856921, 0.03432730894287907, 0.034013371151984995, 0.03370188317908747, 0.033392830340714025, 0.033086197997053333, 0.03278197155228346, 0.0324801364548943, 0.03218067819800448, 0.03188358231967226, 0.03158883440320107, 0.03129642007743929, 0.03100632501707446, 0.03071853494292177, 0.030433035622207283, 0.03014981286884534, 0.02986885254371085, 0.029590140554905685, 0.029313662858019972, 0.029039405456387928, 0.028767354401338353, 0.02849749579243963, 0.02822981577773965, 0.027964300554000326, 0.027700936366927033, 0.027439709511392598, 0.027180606331656337, 0.0269236132215779, 0.026668716624826023, 0.026415903035082067, 0.026165158996238762, 0.025916471102593777, 0.025669825999038307, 0.025425210381240928, 0.02518261099582622, 0.024942014640548803, 0.024703408164462346, 0.024466778468083983, 0.024232112503553654, 0.02399939727478901, 0.023768619837635386, 0.023539767300011314, 0.023312826822049135, 0.023087785616231305, 0.022864630947521863, 0.02264335013349362, 0.022423930544450594, 0.022206359603546187, 0.02199062478689677, 0.02177671362369109, 0.021564613696295018, 0.021354312640352206, 0.021145798144880358, 0.02093905795236331, 0.02073407985883874, 0.020530851713981838, 0.020329361421184765, 0.020129596937631996, 0.019931546274371607, 0.0197351974963824, 0.01954053872263719, 0.01934755812616193, 0.019156243934091106, 0.01896658442771897, 0.018778567942547057, 0.018592182868327856, 0.018407417649104668, 0.018224260783247574, 0.018042700823485854, 0.01786272637693658, 0.017684326105129548, 0.01750748872402866, 0.01733220300404961, 0.01715845777007401, 0.01698624190146018, 0.016815544332050035, 0.016646354050173114, 0.016478660098646448, 0.016312451574771725, 0.016147717630328653, 0.015984447471565175, 0.015822630359184405, 0.015662255608328204, 0.015503312588557675, 0.01534579072383035, 0.015189679492474352, 0.015034968427159269, 0.014881647114864092, 0.014729705196842021, 0.014579132368582371, 0.014429918379769289, 0.014282053034237716, 0.014135526189926327, 0.013990327758827732, 0.013846447706935478, 0.013703876054188715, 0.013562602874413698, 0.013422618295262718, 0.013283912498150282, 0.01314647571818661, 0.013010298244108426, 0.012875370418207266, 0.012741682636255, 0.012609225347426997, 0.012477989054222623, 0.012347964312383362, 0.012219141730808361, 0.012091511971467678, 0.011965065749313004, 0.011839793832186115, 0.011715687040725039, 0.011592736248267708, 0.011470932380753567, 0.011350266416622866, 0.011230729386713706, 0.011112312374156975, 0.010995006514269101, 0.010878802994442657, 0.010763693054035038, 0.010649667984254813, 0.010536719128046329, 0.010424837879972141, 0.010314015686093587, 0.010204244043849339, 0.01009551450193213, 0.009987818660163522, 0.009881148169366971, 0.009775494731238878, 0.009670850098218001, 0.009567206073353063, 0.009464554510168631, 0.009362887312529307, 0.009262196434502202, 0.009162473880217818, 0.009063711703729273, 0.008965902008870026, 0.008869036949109857, 0.008773108727409515, 0.00867810959607373, 0.008584031856602814, 0.008490867859542789, 0.00839861000433403, 0.00830725073915864, 0.00821678256078637, 0.008127198014419133, 0.00803848969353434, 0.00795065023972686, 0.007863672342549699, 0.007777548739353499, 0.007692272215124763, 0.00760783560232289, 0.00752423178071617, 0.0074414536772164095, 0.007359494265712631, 0.007278346566903629, 0.007198003648129421, 0.0071184586232017144, 0.007039704652233303, 0.0069617349414665105, 0.006884542743100637, 0.0068081213551185096, 0.006732464121111991, 0.006657564430106733, 0.006583415716385976, 0.006510011459313489, 0.006437345183155714, 0.006365410456903074, 0.0062942008940905, 0.006223710152617235, 0.00615393193456581, 0.006084859986020368, 0.006016488096884284, 0.005948810100697093, 0.0058818198744507305, 0.005815511338405225, 0.005749878455903665, 0.005684915233186703, 0.005620615719206335, 0.005556974005439248, 0.005493984225699593, 0.005431640555951249, 0.005369937214119574, 0.005308868459902723, 0.005248428594582473, 0.005188611960834638, 0.005129412942539084, 0.005070825964589283, 0.00501284549270157, 0.004955466033223987, 0.004898682132944803, 0.004842488378900723, 0.004786879398184765, 0.004731849857753886, 0.004677394464236316, 0.004623507963738623, 0.004570185141652593, 0.0045174208224618454, 0.004465209869548281, 0.004413547184998324, 0.0043624277094090145, 0.004311846421693924, 0.004261798338888996, 0.004212278515958179, 0.004163282045599032, 0.0041148040580482066, 0.00406683972088688, 0.004019384238846097, 0.003972432853612135, 0.003925980843631749, 0.0038800235239174934, 0.0038345562458530287, 0.00378957439699838, 0.0037450734008953224, 0.0037010487168727467, 0.003657495839852124, 0.0036144103001530133, 0.00357178766329869, 0.0035296235298218335, 0.0034879135350704047, 0.0034466533490135356, 0.003405838676047674, 0.003365465254802812, 0.0033255288579489106, 0.003286025292002498, 0.003246950397133442, 0.0032083000469719505, 0.0031700701484157815, 0.003132256641437657, 0.003094855498892941, 0.003057862726327566, 0.003021274361786204, 0.002985086475620731, 0.0029492951702989535, 0.0029138965802136528, 0.0028788868714919027, 0.002844262241804765, 0.002810018920177212, 0.0027761531667984795, 0.0027426612728327247, 0.002709539560230036, 0.0026767843815378215, 0.0026443921197125725, 0.002612359187932003, 0.0025806820294076156, 0.002549357117197599, 0.0025183809540202315, 0.002487750072067637, 0.0024574610328199995, 0.0024275104268602177, 0.0023978948736889955, 0.0023686110215403963, 0.002339655547197879, 0.0023110251558107558, 0.0022827165807111824, 0.0022547265832316135, 0.002227051952522759, 0.002199689505372032, 0.0021726360860225267, 0.0021458885659924945, 0.002119443843895358, 0.0020932988452602593, 0.002067450522353127, 0.002041895853998308, 0.0020166318454007464, 0.00199165552796872, 0.0019669639591371373, 0.0019425542221914074, 0.001918423426091889, 0.0018945687052989346, 0.0018709872195984839, 0.0018476761539282982, 0.0018246327182047655, 0.0018018541471503185, 0.0017793377001214686, 0.0017570806609374498, 0.0017350803377094758, 0.0017133340626706568, 0.0016918391920064883, 0.001670593105686033, 0.0016495932072937095, 0.0016288369238617402, 0.0016083217057032367, 0.00158804502624595, 0.0015680043818666722, 0.0015481972917262934, 0.0015286212976055474, 0.0015092739637413886, 0.001490152876664079, 0.0014712556450349294, 0.001452579899484732, 0.001434123292452869, 0.00141588349802711, 0.0013978582117841053, 0.001380045150630572, 0.0013624420526451573, 0.0013450466769210293, 0.0013278568034091546, 0.0013108702327622786, 0.0012940847861796193, 0.0012774983052522696, 0.0012611086518093107, 0.0012449137077646445, 0.0012289113749645313, 0.0012130995750358592, 0.0011974762492351315, 0.0011820393582981715, 0.0011667868822905607, 0.0011517168204587963, 0.001136827191082184, 0.0011221160313254505, 0.0011075813970921123, 0.0010932213628785362, 0.0010790340216287764, 0.0010650174845901225, 0.001051169881169394, 0.0010374893587899714, 0.0010239740827495633, 0.0010106222360787187, 0.0009974320194000815, 0.000984401650788378, 0.0009715293656311558, 0.000958813416490266, 0.0009462520729640834, 0.0009338436215504791, 0.0009215863655105305, 0.0009094786247329815, 0.0008975187355994539, 0.0008857050508503869, 0.0008740359394517444, 0.0008625097864624511, 0.000851124992902591, 0.000839879975622337, 0.0008287731671716384, 0.0008178030156706476, 0.0008069679846808929, 0.00079626655307721, 0.0007856972149203949, 0.0007752584793306218, 0.0007649488703615997, 0.00075476692687547, 0.0007447112024184513, 0.0007347802650972244, 0.0007249726974560602, 0.0007152870963546979, 0.0007057220728469395, 0.0006962762520600144, 0.0006869482730746615, 0.0006777367888059599, 0.0006686404658848911, 0.0006596579845406391, 0.000650788038483625, 0.0006420293347892826, 0.0006333805937825471, 0.0006248405489230971, 0.0006164079466913127, 0.0006080815464749688, 0.0005998601204566506, 0.0005917424535018999, 0.0005837273430480826, 0.0005758135989939776, 0.0005680000435900949, 0.0005602855113297005, 0.0005526688488405691, 0.0005451489147774535, 0.0005377245797152604, 0.0005303947260429473, 0.0005231582478581274, 0.0005160140508623799, 0.0005089610522572798, 0.0005019981806411141, 0.0004951243759063193, 0.0004883385891376105, 0.0004816397825108143, 0.0004750269291923961, 0.00046849901323968554, 0.00046205502950179294, 0.000455693983521222, 0.0004494148914361602, 0.00044321677988346913, 0.00043709868590235214, 0.00043105965683870476, 0.00042509875025014733, 0.0004192150338117329, 0.0004134075852223329, 0.0004076754921116925, 0.0004020178519481628, 0.00039643377194709226, 0.0003909223689798914, 0.00038548276948375686, 0.00038011410937205885, 0.0003748155339453838, 0.0003695861978032357, 0.00036442526475638796, 0.000359331907739891, 0.0003543053087267175, 0.0003493446586420658, 0.00034444915727829616, 0.00033961801321051257, 0.0003348504437127798, 0.00033014567467497637, 0.0003255029405202756, 0.0003209214841232658, 0.0003164005567286831, 0.0003119394178707781, 0.0003075373352933031, 0.0003031935848701116, 0.00029890745052637896, 0.00029467822416043353, 0.00029050520556619524, 0.0002863877023562269, 0.00028232502988538436, 0.00027831651117506893, 0.00027436147683807866, 0.0002704592650040578, 0.00026660922124553297, 0.00026281069850454445, 0.00025906305701985945, 0.000255365664254774, 0.00025171789482549386, 0.00024811913043008745, 0.0002445687597780246, 0.00024106617852027903, 0.00023761078918000197, 0.00023420200108376289, 0.0002308392302933526, 0.00022752189953814425, 0.0002242494381480176, 0.0002210212819868279, 0.00021783687338643387, 0.00021469566108127063, 0.0002115971001434662, 0.0002085406519185027, 0.00020552578396141474, 0.00020255196997352474, 0.00019961868973970842, 0.00019672542906619655, 0.00019387167971889434, 0.00019105693936223282, 0.00018828071149853582, 0.0001855425054079074, 0.00018284183608863278, 0.00018017822419809091, 0.00017755119599417553, 0.00017496028327722356, 0.00017240502333244152, 0.00016988495887283682, 0.0001673996379826411, 0.00016494861406123084, 0.00016253144576753412, 0.00016014769696492834, 0.00015779693666661873, 0.00015547873898150307, 0.00015319268306050884, 0.00015093835304340924, 0.00014871533800610978, 0.00014652323190840632, 0.00014436163354220562, 0.00014223014648021202, 0.00014012837902507302, 0.00013805594415898162, 0.00013601245949373475, 0.00013399754722123898, 0.00013201083406446865, 0.0001300519512288659, 0.00012812053435418572, 0.00012621622346677719, 0.0001243386629323032, 0.00012248750140889233, 0.0001206623918007226, 0.00011886299121202927, 0.00011708896090154093, 0.00011533996623733509, 0.00011361567665211183, 0.00011191576559888546, 0.00011023991050708595, 0.00010858779273907228, 0.00010695909754705301, 0.00010535351403040821, 0.00010377073509341588, 0.00010221045740337486, 0.00010067238134912367, 9.915621099995126e-05, 9.766165406489933e-05, 9.618842185244928e-05, 9.473622923059426e-05, 9.330479458729409e-05, 9.189383979130558e-05, 9.050309015339053e-05, 8.913227438789657e-05, 8.778112457470701e-05, 8.644937612155976e-05, 8.513676772672871e-05, 8.38430413420686e-05, 8.256794213641884e-05, 8.131121845936202e-05, 8.00726218053383e-05, 7.885190677810946e-05, 7.764883105557146e-05, 7.646315535491264e-05, 7.529464339811438e-05, 7.414306187779255e-05, 7.300818042337667e-05, 7.188977156762292e-05, 7.07876107134603e-05, 6.970147610116654e-05, 6.863114877587061e-05, 6.757641255538015e-05, 6.653705399833006e-05, 6.551286237265131e-05, 6.45036296243558e-05, 6.350915034663621e-05, 6.252922174927635e-05, 6.156364362837146e-05, 6.061221833635522e-05, 5.96747507523306e-05, 5.875104825270211e-05, 5.7840920682107696e-05, 5.694418032464736e-05, 5.606064187540569e-05, 5.5190122412265686e-05, 5.433244136801365e-05, 5.348742050272918e-05, 5.2654883876460996e-05, 5.183465782218405e-05, 5.102657091903755e-05, 5.0230453965838864e-05, 4.9446139954874615e-05, 4.867346404596177e-05, 4.7912263540782016e-05, 4.716237785748214e-05, 4.642364850554135e-05, 4.5695919060901726e-05, 4.4979035141359716e-05, 4.427284438221735e-05, 4.3577196412189145e-05, 4.289194282956468e-05, 4.2216937178622396e-05, 4.155203492629405e-05, 4.0897093439077065e-05, 4.025197196019235e-05, 3.961653158698587e-05, 3.899063524857121e-05, 3.837414768371168e-05, 3.776693541893996e-05, 3.716886674691143e-05, 3.6579811704991446e-05, 3.599964205407341e-05, 3.5428231257624866e-05, 3.4865454460960596e-05, 3.431118847074066e-05, 3.376531173469012e-05, 3.322770432154046e-05, 3.2698247901188155e-05, 3.217682572507067e-05, 3.166332260675699e-05, 3.115762490275009e-05, 3.0659620493500547e-05, 3.0169198764628565e-05, 2.968625058835255e-05, 2.9210668305122715e-05, 2.8742345705457794e-05, 2.828117801198185e-05, 2.7827061861660925e-05, 2.7379895288236948e-05, 2.6939577704856484e-05, 2.6506009886893262e-05, 2.60790939549627e-05, 2.565873335812558e-05, 2.524483285728075e-05, 2.483729850874295e-05, 2.443603764800615e-05, 2.4040958873688912e-05, 2.365197203166115e-05, 2.3268988199349872e-05, 2.2891919670222526e-05, 2.2520679938445853e-05, 2.2155183683719487e-05, 2.1795346756280936e-05, 2.1441086162082098e-05, 2.109232004813447e-05, 2.074896768802162e-05, 2.041094946757766e-05, 2.0078186870729614e-05, 1.97506024655024e-05, 1.9428119890184397e-05, 1.911066383965296e-05, 1.8798160051856722e-05, 1.8490535294454657e-05, 1.818771735160972e-05, 1.788963501093512e-05, 1.7596218050592426e-05, 1.7307397226539566e-05, 1.7023104259927083e-05, 1.674327182464188e-05, 1.6467833534995695e-05, 1.6196723933558247e-05, 1.5929878479132618e-05, 1.566723353487171e-05, 1.5408726356534485e-05, 1.515429508088037e-05, 1.4903878714200435e-05, 1.4657417120984158e-05, 1.4414851012719817e-05, 1.4176121936827966e-05, 1.3941172265725933e-05, 1.3709945186022188e-05, 1.3482384687839415e-05, 1.3258435554264707e-05, 1.3038043350925676e-05, 1.2821154415691118e-05, 1.2607715848495096e-05, 1.2397675501282714e-05, 1.2190981968076836e-05, 1.1987584575164287e-05, 1.1787433371399938e-05, 1.1590479118628077e-05, 1.139667328221905e-05, 1.1205968021720777e-05, 1.1018316181623306e-05, 1.0833671282235262e-05, 1.0651987510671414e-05, 1.0473219711949729e-05, 1.0297323380196954e-05, 1.012425464996143e-05, 9.953970287632187e-06, 9.786427682962939e-06, 9.6215848407001e-06, 9.459400372313274e-06, 9.299833487827776e-06, 9.142843987757264e-06, 8.988392255136207e-06, 8.83643924765037e-06, 8.686946489864868e-06, 8.539876065548121e-06, 8.395190610091276e-06, 8.25285330302158e-06, 8.11282786060879e-06, 7.975078528563723e-06, 7.839570074827766e-06, 7.706267782452537e-06, 7.575137442568363e-06, 7.446145347440973e-06, 7.319258283615136e-06, 7.194443525144471e-06, 7.071668826906256e-06, 6.9509024180004836e-06, 6.832112995232149e-06, 6.715269716675743e-06, 6.600342195321235e-06, 6.487300492800331e-06, 6.376115113192391e-06, 6.266756996908957e-06, 6.159197514655953e-06, 6.053408461472784e-06, 5.949362050847448e-06, 5.847030908906715e-06, 5.746388068680582e-06, 5.6474069644401045e-06, 5.550061426107846e-06, 5.454325673740002e-06, 5.360174312079504e-06, 5.267582325179107e-06, 5.176525071093829e-06, 5.086978276641876e-06, 4.9989180322331855e-06, 4.9123207867649734e-06, 4.827163342583276e-06, 4.743422850509934e-06, 4.661076804934169e-06, 4.580103038967913e-06, 4.500479719664291e-06, 4.422185343298448e-06, 4.345198730709975e-06, 4.26949902270623e-06, 4.195065675525812e-06, 4.1218784563615205e-06, 4.049917438942129e-06, 3.979162999172045e-06, 3.90959581082857e-06, 3.841196841315677e-06, 3.7739473474739042e-06, 3.707828871445565e-06, 3.642823236594626e-06, 3.5789125434806696e-06, 3.5160791658861915e-06, 3.454305746896726e-06, 3.393575195032958e-06, 3.333870680434425e-06, 3.2751756310940548e-06, 3.2174737291429516e-06, 3.160748907184798e-06, 3.104985344679363e-06, 3.0501674643743633e-06, 2.996279928785307e-06, 2.9433076367224446e-06, 2.891235719864593e-06, 2.840049539378956e-06, 2.789734682586581e-06, 2.7402769596727943e-06, 2.6916624004420804e-06, 2.643877251116883e-06, 2.5969079711798012e-06, 2.5507412302585312e-06, 2.505363905053204e-06, 2.4607630763054385e-06, 2.4169260258087e-06, 2.37384023345938e-06, 2.331493374348137e-06, 2.28987331589096e-06, 2.2489681149994994e-06, 2.2087660152901782e-06, 2.169255444331503e-06, 2.130425010929239e-06, 2.0922635024488845e-06, 2.054759882174993e-06, 2.017903286706891e-06, 1.981683023390307e-06, 1.9460885677845126e-06, 1.9111095611644816e-06, 1.8767358080575837e-06, 1.8429572738145197e-06, 1.8097640822138895e-06, 1.7771465131001076e-06, 1.7450950000541179e-06, 1.713600128096621e-06, 1.6826526314232793e-06, 1.6522433911715805e-06, 1.6223634332188747e-06, 1.5930039260112622e-06, 1.564156178422905e-06, 1.5358116376453338e-06, 1.5079618871064305e-06, 1.4805986444186573e-06, 1.4537137593561612e-06, 1.4272992118604102e-06, 1.401347110073961e-06, 1.3758496884019687e-06, 1.3507993056011755e-06, 1.3261884428958988e-06, 1.3020097021207698e-06, 1.2782558038897943e-06, 1.2549195857914454e-06, 1.2319940006094348e-06, 1.2094721145688172e-06, 1.187347105607082e-06, 1.1656122616699423e-06, 1.144260979031483e-06, 1.1232867606383127e-06, 1.1026832144774559e-06, 1.0824440519676344e-06, 1.0625630863736429e-06, 1.0430342312435222e-06, 1.0238514988681896e-06, 1.0050089987632872e-06, 9.865009361729048e-07, 9.683216105948993e-07, 9.504654143275374e-07, 9.329268310371573e-07, 9.15700434346581e-07, 8.987808864439844e-07, 8.821629367119889e-07, 8.658414203766359e-07, 8.498112571760517e-07, 8.340674500484888e-07, 8.186050838394927e-07, 8.034193240279514e-07, 7.885054154707537e-07], "g": [0.0008875883516681134, 0.0008959435450042954, 0.0009043717361326656, 0.0009128735058933445, 0.0009214494392024501, 0.0009301001250757173, 0.0009388261566522272, 0.000947628131218205, 0.0009565066502309429, 0.0009654623193427769, 0.0009744957484251954, 0.0009836075515930191, 0.0009927983472286666, 0.0010020687580065471, 0.0010114194109174994, 0.0010208509372933734, 0.0010303639728316556, 0.0010399591576202296, 0.0010496371361622076, 0.0010593985574008443, 0.0010692440747445825, 0.001079174346092139, 0.0010891900338577368, 0.0010992918049963778, 0.0011094803310292562, 0.0011197562880692201, 0.0011301203568463635, 0.0011405732227336874, 0.001151115575772847, 0.0011617481107000218, 0.0011724715269718394, 0.001183286528791425, 0.0011941938251345079, 0.0012051941297756548, 0.0012162881613145722, 0.0012274766432024905, 0.001238760303768676, 0.001250139876246986, 0.0012616160988025652, 0.0012731897145585767, 0.0012848614716230765, 0.0012966321231159415, 0.001308502427195897, 0.0013204731470876478, 0.001332545051109068, 0.0013447189126985248, 0.0013569955104422347, 0.001369375628101767, 0.0013818600546415824, 0.0013944495842567067, 0.0014071450164004598, 0.001419947155812275, 0.0014328568125456362, 0.0014458748019960529, 0.0014590019449291826, 0.001472239067508966, 0.0014855870013259266, 0.001499046583425505, 0.0015126186563364785, 0.0015263040680995098, 0.0015401036722957236, 0.0015540183280754235, 0.0015680489001868405, 0.0015821962590050185, 0.0015964612805607309, 0.001610844846569531, 0.0016253478444608516, 0.0016399711674071878, 0.0016547157143533982, 0.0016695823900460334, 0.001684572105062806, 0.0016996857758420816, 0.0017149243247125093, 0.0017302886799226915, 0.0017457797756709377, 0.0017613985521351355, 0.0017771459555026427, 0.0017930229380003209, 0.0018090304579245872, 0.001825169479671594, 0.0018414409737674692, 0.0018578459168986036, 0.0018743852919420804, 0.0018910600879961075, 0.0019078713004105968, 0.0019248199308177505, 0.0019419069871627853, 0.001959133483734677, 0.0019765004411970285, 0.0019940088866189742, 0.0020116598535061593, 0.0020294543818318352, 0.002047393518067952, 0.002065478315216411, 0.0020837098328403024, 0.0021020891370952793, 0.0021206173007609704, 0.00213929540327245, 0.002158124530751826, 0.002177105776039828, 0.002196240238727535, 0.0022155290251881, 0.002234973248608603, 0.0022545740290219195, 0.0022743324933386937, 0.0022942497753793557, 0.0023143270159061862, 0.0023345653626555005, 0.0023549659703698106, 0.002375530000830151, 0.002396258622888361, 0.002417153012499514, 0.0024382143527543598, 0.0024594438339118176, 0.0024808426534315884, 0.002502412016006729, 0.0025241531335963986, 0.002546067225458537, 0.0025681555181827184, 0.0025904192457229724, 0.002612859649430682, 0.0026354779780875712, 0.0026582754879386854, 0.0026812534427254914, 0.0027044131137189393, 0.0027277557797526896, 0.0027512827272562607, 0.002774995250288341, 0.002798894650570082, 0.002822982237518433, 0.0028472593282795754, 0.0028717272477623416, 0.002896387328671729, 0.0029212409115424087, 0.0029462893447723235, 0.0029715339846563015, 0.0029969761954196906, 0.0030226173492520917, 0.003048458826341062, 0.0030745020149059183, 0.003100748311231519, 0.0031271991197021416, 0.0031538558528353237, 0.0031807199313158194, 0.003207792784029533, 0.003235075848097474, 0.0032625705689098145, 0.003290278400159872, 0.0033182008038782503, 0.0033463392504668598, 0.0033746952187331015, 0.0034032701959240018, 0.0034320656777603437, 0.003461083168470944, 0.0034903241808267866, 0.0035197902361753493, 0.003549482864474784, 0.00357940360432826, 0.003609554003018247, 0.00363993561654079, 0.0036705500096399176, 0.003701398755841902, 0.003732483437489695, 0.003763805645777242, 0.0037953669807839117, 0.003827169051508834, 0.003859213475905359, 0.0038915018809154316, 0.003924035902503998, 0.003956817185693463, 0.003989847384598055, 0.004023128162458331, 0.004056661191675508, 0.004090448153845976, 0.004124490739795672, 0.0041587906496145036, 0.004193349592690802, 0.004228169287745674, 0.004263251462867485, 0.004298597855546173, 0.004334210212707712, 0.004370090290748432, 0.00440623985556941, 0.004442660682610837, 0.004479354556886294, 0.004516323273017149, 0.004553568635266783, 0.004591092457574948, 0.004628896563591949, 0.00466698278671295, 0.0047053529701121585, 0.004744008966777, 0.004782952639542327, 0.004822185861124488, 0.004861710514155513, 0.004901528491217105, 0.004941641694874748, 0.0049820520377116895, 0.0050227614423628665, 0.00506377184154894, 0.005105085178110071, 0.005146703405039879, 0.005188628485519161, 0.005230862392949749, 0.005273407110988144, 0.0053162646335792535, 0.0053594369649900015, 0.0054029261198428775, 0.005446734123149492, 0.0054908630103440255, 0.00553531482731666, 0.005580091630446896, 0.005625195486636912, 0.00567062847334476, 0.00571639267861751, 0.005762490201124447, 0.005808923150190012, 0.0058556936458268784, 0.005902803818768756, 0.0059502558105033335, 0.0059980517733049365, 0.006046193870267288, 0.006094684275336108, 0.006143525173341583, 0.006192718760030923, 0.0062422672421006175, 0.006292172837228815, 0.006342437774107441, 0.006393064292474381, 0.006444054643145466, 0.006495411088046357, 0.0065471359002444805, 0.006599231363980658, 0.006651699774700839, 0.006704543439087563, 0.006757764675091463, 0.006811365811962582, 0.006865349190281568, 0.006919717161990852, 0.006974472090425594, 0.007029616350344679, 0.0070851523279613915, 0.007141082420974188, 0.007197409038597163, 0.007254134601590553, 0.007311261542291032, 0.007368792304641829, 0.007426729344222921, 0.0074850751282808, 0.00754383213575845, 0.007603002857324861, 0.007662589795404664, 0.007722595464207509, 0.007783022389757258, 0.0078438731099212, 0.007905150174438923, 0.007966856144951262, 0.008028993595028818, 0.008091565110200654, 0.008154573287982558, 0.00821802073790527, 0.008281910081542632, 0.00834624395253937, 0.00841102499663895, 0.008476255871711058, 0.008541939247779106, 0.00860807780704738, 0.008674674243928199, 0.00874173126506878, 0.008809251589377912, 0.008877237948052601, 0.008945693084604333, 0.009014619754885352, 0.009084020727114565, 0.009153898781903431, 0.009224256712281548, 0.00929509732372203, 0.009366423434166868, 0.009438237874051804, 0.009510543486331322, 0.009583343126503116, 0.009656639662632725, 0.009730435975377523, 0.009804734958010927, 0.009879539516446092, 0.00995485256925948, 0.010030677047714355, 0.010107015895783729, 0.010183872070173494, 0.010261248540344962, 0.01033914828853745, 0.01041757430979047, 0.010496529611965703, 0.010576017215768879, 0.01065604015477119, 0.010736601475430717, 0.010817704237113332, 0.010899351512113652, 0.010981546385675547, 0.01106429195601237, 0.01114759133432715, 0.011231447644832256, 0.011315864024769076, 0.01140084362442713, 0.01148638960716327, 0.011572505149420235, 0.011659193440745291, 0.01174645768380839, 0.011834301094419977, 0.01192272690154884, 0.012011738347339316, 0.012101338687128512, 0.012191531189462946, 0.012282319136115235, 0.012373705822100215, 0.012465694555690833, 0.012558288658433895, 0.012651491465165258, 0.012745306324025, 0.012839736596471956, 0.012934785657298354, 0.013030456894643678, 0.013126753710008661, 0.013223679518268649, 0.013321237747686685, 0.013419431839926513, 0.013518265250064908, 0.013617741446603947, 0.0137178639114828, 0.013818636140089257, 0.013920061641270918, 0.014022143937345938, 0.014124886564113648, 0.014228293070864508, 0.014332367020390127, 0.014437111988992455, 0.014542531566493086, 0.01464862935624187, 0.014755408975125239, 0.014862874053574364, 0.014971028235572573, 0.015079875178662869, 0.015189418553954559, 0.015299662046130045, 0.015410609353450698, 0.015522264187762813, 0.015634630274502927, 0.015747711352702743, 0.015861511174993813, 0.01597603350761168, 0.01609128213039975, 0.016207260836812575, 0.01632397343391905, 0.016441423742404888, 0.01655961559657473, 0.016678552844354176, 0.016798239347290852, 0.016918678980555654, 0.017039875632942982, 0.01716183320687117, 0.017284555618381776, 0.01740804679713922, 0.01753231068642938, 0.017657351243157926, 0.017783172437848483, 0.017909778254639876, 0.018037172691283406, 0.01816535975913925, 0.018294343483172854, 0.018424127901950436, 0.018554717067634268, 0.018686115045977544, 0.018818325916318664, 0.018951353771575037, 0.019085202718236532, 0.019219876876358337, 0.019355380379553463, 0.019491717374984636, 0.019628892023355837, 0.019766908498903214, 0.01990577098938571, 0.020045483696074937, 0.020186050833744806, 0.02032747663066047, 0.02046976532856692, 0.020612921182676953, 0.020756948461658698, 0.02090185144762262, 0.021047634436108062, 0.021194301736069128, 0.021341857669860215, 0.021490306573220905, 0.021639652795260398, 0.02178990069844142, 0.02194105465856352, 0.022093119064745925, 0.02224609831940984, 0.022399996838260147, 0.02255481905026661, 0.022710569397644577, 0.022867252335835017, 0.023024872333484117, 0.023183433872422252, 0.023342941447642495, 0.02350339956727835, 0.023664812752581213, 0.023827185537897023, 0.023990522470642477, 0.02415482811128062, 0.02432010703329588, 0.024486363823168485, 0.024653603080348387, 0.024821829417228478, 0.02499104745911728, 0.025161261844211084, 0.025332477223565426, 0.025504698261066, 0.025677929633398964, 0.025852176030020626, 0.026027442153126596, 0.026203732717620172, 0.026381052451080314, 0.02655940609372884, 0.026738798398397105, 0.026919234130491965, 0.027100718067961264, 0.027283255001258472, 0.02746684973330703, 0.02765150707946362, 0.027837231867481167, 0.02802402893747107, 0.028211903141864766, 0.02840085934537466, 0.028590902424954493, 0.028782037269758882, 0.028974268781102475, 0.029167601872418125, 0.029362041469214673, 0.02955759250903396, 0.029754259941407138, 0.029952048727810442, 0.0301509638416201, 0.03035101026806685, 0.03055219300418943, 0.03075451705878768, 0.030957987452374852, 0.031162609217129232, 0.03136838739684507, 0.03157532704688284, 0.031783433234118835, 0.0319927110368941, 0.03220316554496245, 0.03241480185943803, 0.032627625092742155, 0.03284164036854927, 0.03305685282173243, 0.033273267598307836, 0.033490889855378826, 0.03370972476107922, 0.03392977749451558, 0.03415105324570923, 0.034373557215537226, 0.03459729461567269, 0.034822270668524447, 0.03504849060717593, 0.03527595967532328, 0.035504683127212895, 0.0357346662275779, 0.035965914251574284, 0.03619843248471598, 0.03643222622280939, 0.036667300771887054, 0.03690366144814062, 0.03714131357785315, 0.03738026249733035, 0.0376205135528315, 0.037862072100499265, 0.0381049435062889, 0.03834913314589676, 0.03859464640468777, 0.03884148867762246, 0.03908966536918313, 0.039339181893299, 0.039590043673270896, 0.03984225614169512, 0.04009582474038633, 0.04035075492029989, 0.040607052141453215, 0.04086472187284657, 0.04112376959238294, 0.04138420078678705, 0.041646020951523706, 0.04190923559071536, 0.042173850217058814, 0.042439870351741155, 0.04270730152435483, 0.0429761492728121, 0.04324641914325851, 0.04351811668998558, 0.04379124747534277, 0.04406581706964863, 0.044341831051101094, 0.04461929500568692, 0.04489821452709051, 0.04517859521660163, 0.0454604426830227, 0.04574376254257476, 0.04602856041880314, 0.046314841942481914, 0.04660261275151782, 0.046891878490853106, 0.0471826448123677, 0.0474749173747807, 0.04776870184355059, 0.0480640038907751, 0.04836082919508997, 0.04865918344156701, 0.04895907232161115, 0.0492605015328569, 0.04956347677906385, 0.04986800377001129, 0.05017408822139204, 0.05048173585470547, 0.05079095239714968, 0.05110174358151271, 0.051414115146063186, 0.051728072834439774, 0.05204362239554004, 0.05236076958340857, 0.05267952015712367, 0.052999879880684005, 0.05332185452289376, 0.05364544985724737, 0.05397067166181309, 0.05429752571911591, 0.05462601781601958, 0.05495615374360779, 0.05528793929706438, 0.055621380275552926, 0.055956482482095185, 0.056293251723448984, 0.05663169380998504, 0.05697181455556302, 0.05731361977740672, 0.057657115295978445, 0.05800230693485241, 0.05834920052058733, 0.05869780188259828, 0.05904811685302755, 0.05940015126661469, 0.059753910960565655, 0.060109401774421305, 0.06046662954992466, 0.060825600130887614, 0.061186319363056706, 0.061548793093978, 0.06191302717286115, 0.062279027450442545, 0.06264679977884763, 0.06301635001145253, 0.06338768400274436, 0.06376080760818123, 0.06413572668405103, 0.06451244708732952, 0.06489097467553748, 0.06527131530659705, 0.06565347483868712, 0.06603745913009818, 0.06642327403908573, 0.06681092542372351, 0.06720041914175527, 0.06759176105044622, 0.06798495700643323, 0.06838001286557426, 0.06877693448279716, 0.06917572771194747, 0.06957639840563513, 0.06997895241508073, 0.07038339558996078, 0.07078973377825204, 0.07119797282607504, 0.07160811857753685, 0.07202017687457299, 0.07243415355678826, 0.07285005446129701, 0.07326788542256249, 0.07368765227223537, 0.07410936083899121, 0.07453301694836757, 0.07495862642259966, 0.07538619508045585, 0.07581572873707162, 0.07624723320378315, 0.07668071428796011, 0.0771161777928374, 0.07755362951734604, 0.07799307525594341, 0.07843452079844258, 0.07887797192984108, 0.07932343443014805, 0.07977091407421161, 0.08022041663154475, 0.08067194786615053, 0.08112551353634662, 0.08158111939458884, 0.08203877118729405, 0.08249847465466219, 0.08296023553049733, 0.0834240595420283, 0.08388995240972806, 0.08435791984713266, 0.08482796756065926, 0.08530010124942328, 0.08577432660505484, 0.08625064931151455, 0.08672907504490818, 0.08720960947330073, 0.08769225825652988, 0.08817702704601842, 0.08866392148458598, 0.08915294720626003, 0.08964410983608619, 0.09013741498993746, 0.09063286827432297, 0.091130475286196, 0.09163024161276098, 0.09213217283128006, 0.09263627450887862, 0.09314255220235024, 0.09365101145796098, 0.09416165781125249, 0.09467449678684497, 0.09518953389823905, 0.09570677464761693, 0.09622622452564299, 0.09674788901126351, 0.09727177357150554, 0.0977978836612757, 0.09832622472315723, 0.09885680218720724, 0.09938962147075285, 0.09992468797818667, 0.10046200710076163, 0.10100158421638501, 0.1015434246894119, 0.10208753387043813, 0.10263391709609201, 0.10318257968882584, 0.10373352695670666, 0.10428676419320632, 0.1048422966769906, 0.10540012967170821, 0.10596026842577874, 0.10652271817218009, 0.10708748412823513, 0.10765457149539785, 0.10822398545903901, 0.10879573118823067, 0.10936981383553064, 0.10994623853676605, 0.11052501041081635, 0.11110613455939546, 0.11168961606683378, 0.11227545999985923, 0.11286367140737777, 0.11345425532025333, 0.11404721675108744, 0.11464256069399761, 0.11524029212439596, 0.11584041599876649, 0.11644293725444241, 0.11704786080938247, 0.11765519156194697, 0.11826493439067333, 0.11887709415405068, 0.11949167569029427, 0.1201086838171195, 0.12072812333151466, 0.12134999900951418, 0.12197431560597048, 0.122601077854326, 0.12323029046638409, 0.12386195813207995, 0.12449608551925055, 0.12513267727340488, 0.12577173801749264, 0.12641327235167332, 0.12705728485308432, 0.12770378007560915, 0.12835276254964426, 0.12900423678186643, 0.12965820725499924, 0.13031467842757893, 0.13097365473372008, 0.13163514058288087, 0.13229914035962792, 0.13296565842340058, 0.13363469910827505, 0.13430626672272775, 0.1349803655493989, 0.13565699984485485, 0.13633617383935087, 0.13701789173659315, 0.1377021577135005, 0.13838897591996566, 0.13907835047861647, 0.13977028548457635, 0.1404647850052249, 0.14116185307995782, 0.14186149371994636, 0.14256371090789716, 0.14326850859781107, 0.14397589071474198, 0.14468586115455548, 0.1453984237836869, 0.1461135824388996, 0.14683134092704228, 0.14755170302480666, 0.1482746724784847, 0.14900025300372538, 0.14972844828529172, 0.15045926197681705, 0.1511926977005613, 0.15192875904716743, 0.15266744957541686, 0.15340877281198542, 0.1541527322511988, 0.15489933135478787, 0.15564857355164397, 0.15640046223757367, 0.15715500077505412, 0.15791219249298716, 0.1586720406864544, 0.15943454861647136, 0.16019971950974204, 0.16096755655841316, 0.1617380629198281, 0.16251124171628112, 0.16328709603477162, 0.16406562892675738, 0.16484684340790903, 0.1656307424578635, 0.1664173290199778, 0.167206606001083, 0.16799857627123763, 0.1687932426634813, 0.1695906079735889, 0.17039067495982352, 0.1711934463426906, 0.17199892480469153, 0.1728071129900773, 0.17361801350460246, 0.17443162891527864, 0.1752479617501285, 0.17606701449794013, 0.17688878960802024, 0.17771328948994894, 0.17854051651333355, 0.17937047300756315, 0.18020316126156277, 0.18103858352354824, 0.18187674200078033, 0.18271763885932044, 0.18356127622378454, 0.18440765617709917, 0.1852567807602562, 0.18610865197206863, 0.18696327176892627, 0.1878206420645513, 0.188680764729755, 0.18954364159219356, 0.1904092744361248, 0.19127766500216506, 0.1921488149870463, 0.19302272604337323, 0.19389939977938123, 0.19477883775869392, 0.1956610415000819, 0.19654601247722053, 0.19743375211844924, 0.1983242618065306, 0.19921754287840984, 0.20011359662497452, 0.20101242429081492, 0.20191402707398448, 0.20281840612576107, 0.2037255625504078, 0.2046354974049352, 0.20554821169886325, 0.20646370639398393, 0.20738198240412425, 0.20830304059490992, 0.20922688178352877, 0.210153506738496, 0.2110829161794182, 0.21201511077675902, 0.21295009115160524, 0.2138878578754329, 0.21482841146987422, 0.21577175240648516, 0.21671788110651347, 0.21766679794066685, 0.21861850322888243, 0.2195729972400962, 0.22053028019201348, 0.2214903522508797, 0.22245321353125178, 0.22341886409577033, 0.22438730395493275, 0.2253585330668658, 0.2263325513371003, 0.22730935861834578, 0.22828895471026545, 0.22927133935925284, 0.2302565122582082, 0.23124447304631604, 0.2322352213088238, 0.23322875657682007, 0.2342250783270148, 0.2352241859815197, 0.23622607890762945, 0.23723075641760363, 0.23823821776844975, 0.23924846216170642, 0.24026148874322875, 0.24127729660297248, 0.24229588477478076, 0.24331725223617096, 0.24434139790812254, 0.24536832065486566, 0.246398019283671, 0.24743049254463978, 0.24846573913049588, 0.24950375767637747, 0.25054454675963067, 0.25158810489960354, 0.2526344305574415, 0.2536835221358831, 0.25473537797905743, 0.2557899963722822, 0.2568473755418629, 0.2579075136548923, 0.25897040881905253, 0.26003605908241667, 0.2611044624332523, 0.26217561679982543, 0.26324952005020613, 0.2643261699920753, 0.26540556437253165, 0.2664877008779006, 0.26757257713354404, 0.2686601907036714, 0.26975053909115176, 0.27084361973732674, 0.27193943002182497, 0.27303796726237833, 0.2741392287146377, 0.27524321157199144, 0.2763499129653848, 0.27745932996313977, 0.2785714595707772, 0.27968629873083956, 0.28080384432271477, 0.2819240931624625, 0.28304704200263986, 0.2841726875321299, 0.2853010263759711, 0.28643205509518777, 0.2875657701866218, 0.2887021680827667, 0.2898412451516017, 0.29098299769642777, 0.2921274219557053, 0.2932745141028926, 0.2944242702462867, 0.2955766864288642, 0.29673175862812484, 0.2978894827559357, 0.29904985465837775, 0.30021287011559195, 0.3013785248416295, 0.3025468144843015, 0.3037177346250304, 0.3048912807787043, 0.306067448393531, 0.30724623285089464, 0.308427629465214, 0.30961163348380116, 0.310798240086723, 0.311987444386664, 0.31317924142878983, 0.3143736261906136, 0.3155705935818632, 0.3167701384443498, 0.31797225555183944, 0.31917693960992416, 0.3203841852558967, 0.3215939870586257, 0.322806339518433, 0.32402123706697283, 0.3252386740671118, 0.3264586448128119, 0.3276811435290144, 0.3289061643715252, 0.3301337014269025, 0.33136374871234636, 0.3325963001755893, 0.3338313496947893, 0.3350688910784241, 0.3363089180651882, 0.33755142432389007, 0.3387964034533526, 0.3400438489823151, 0.3412937543693361, 0.3425461130026999, 0.34380091820032277, 0.34505816320966276, 0.346317841207631, 0.3475799453005036, 0.3488444685238375, 0.3501114038423865, 0.35138074415002, 0.3526524822696441, 0.3539266109531233, 0.3552031228812053, 0.35648201066344776, 0.35776326683814574, 0.3590468838722627, 0.3603328541613628, 0.36162117002954464, 0.36291182372937825, 0.36420480744184286, 0.3655001132762673, 0.3667977332702731, 0.36809765938971756, 0.3693998835286411, 0.37070439750921574, 0.3720111930816953, 0.3733202619243681, 0.3746315956435123, 0.3759451857733518, 0.3772610237760156, 0.37857910104149933, 0.3798994088876275, 0.38122193856001935, 0.3825466812320561, 0.38387362800485103, 0.38520276990722024, 0.3865340978956575, 0.38786760285430966, 0.38920327559495554, 0.3905411068569858, 0.3918810873073858, 0.39322320754072054, 0.39456745807912186, 0.39591382937227737, 0.3972623117974221, 0.3986128956593324, 0.39996557119032194, 0.40132032855023997, 0.4026771578264716, 0.4040360490339408, 0.4053969921151159, 0.4067599769400159, 0.40812499330622126, 0.40949203093888503, 0.41086107949074774, 0.4122321285421534, 0.41360516760106886, 0.4149801861031048, 0.4163571734115394, 0.41773611881734407, 0.41911701153921205, 0.4204998407235886, 0.4218845954447044, 0.4232712647046106, 0.42465983743321656, 0.42605030248833003, 0.42744264865569986, 0.4288368646490604, 0.4302329391101792, 0.43163086060890654, 0.4330306176432276, 0.43443219863931687, 0.43583559195159516, 0.4372407858627892, 0.43864776858399307, 0.44005652825473285, 0.44146705294303284, 0.44287933064548546, 0.4442933492873221, 0.4457090967224876, 0.44712656073371676, 0.4485457290326135, 0.449966589259732, 0.4513891289846608, 0.45281333570610977, 0.45423919685199826, 0.4556666997795472, 0.4570958317753728, 0.4585265800555828, 0.45995893176587616, 0.46139287398164386, 0.46282839370807294, 0.4642654778802535, 0.4657041133632876, 0.4671442869524003, 0.46858598537305474, 0.47002919528106774, 0.47147390326273014, 0.47292009583492745, 0.47436775944526494, 0.47581688047219384, 0.47726744522514153, 0.47871943994464267, 0.48017285080247396, 0.4816276639017918, 0.483083865277271, 0.4845414408952474, 0.486000376653863, 0.4874606583832127, 0.48892227184549436, 0.49038520273516173, 0.4918494366790789, 0.4933149592366784, 0.4947817559001212, 0.4962498120944596, 0.4977191131778025, 0.4991896444414838, 0.5006613911102324, 0.5021343383423459, 0.5036084712298656, 0.5050837747987561, 0.5065602340090849, 0.5080378337552066, 0.5095165588659489, 0.5109963941048018, 0.5124773241701078, 0.5139593336952569, 0.5154424072488824, 0.5169265293350604, 0.5184116843935117, 0.519897856799805, 0.5213850308655651, 0.5228731908386817, 0.5243623209035214, 0.5258524051811428, 0.5273434277295136, 0.5288353725437299, 0.5303282235562395, 0.5318219646370665, 0.5333165795940391, 0.5348120521730193, 0.5363083660581365, 0.537805504872022, 0.5393034521760484, 0.540802191470568, 0.5423017061951579, 0.5438019797288649, 0.5453029953904538, 0.5468047364386578, 0.5483071860724333, 0.5498103274312143, 0.5513141435951722, 0.5528186175854762, 0.5543237323645573, 0.5558294708363746, 0.5573358158466837, 0.5588427501833088, 0.5603502565764157, 0.5618583176987891, 0.5633669161661115, 0.5648760345372438, 0.5663856553145105, 0.5678957609439854, 0.5694063338157822, 0.570917356264344, 0.5724288105687393, 0.5739406789529578, 0.5754529435862098, 0.5769655865832279, 0.5784785900045716, 0.5799919358569329, 0.5815056060934467, 0.5830195826140021, 0.5845338472655558, 0.5860483818424503, 0.5875631680867314, 0.5890781876884706, 0.5905934222860889, 0.5921088534666837, 0.5936244627663569, 0.5951402316705473, 0.5966561416143631, 0.5981721739829196, 0.5996883101116768, 0.6012045312867806, 0.6027208187454068, 0.6042371536761066, 0.6057535172191548, 0.6072698904669004, 0.60878625446412, 0.6103025902083733, 0.6118188786503601, 0.6133351006942812, 0.6148512371982006, 0.6163672689744103, 0.6178831767897977, 0.6193989413662147, 0.6209145433808497, 0.6224299634666022, 0.6239451822124584, 0.6254601801638703, 0.6269749378231367, 0.628489435649787, 0.6300036540609656, 0.6315175734318206, 0.6330311740958935, 0.6345444363455119, 0.6360573404321836, 0.6375698665669935, 0.6390819949210024, 0.6405937056256484, 0.6421049787731504, 0.6436157944169132, 0.6451261325719355, 0.6466359732152197, 0.6481452962861839, 0.6496540816870761, 0.6511623092833906, 0.6526699589042865, 0.6541770103430075, 0.6556834433573054, 0.657189237669865, 0.6586943729687296, 0.6601988289077309, 0.6617025851069197, 0.6632056211529992, 0.664707916599759, 0.666209450968513, 0.6677102037485382, 0.6692101543975153, 0.6707092823419726, 0.6722075669777297, 0.6737049876703454, 0.6752015237555665, 0.6766971545397781, 0.6781918593004567, 0.6796856172866245, 0.6811784077193065, 0.6826702097919883, 0.6841610026710768, 0.6856507654963621, 0.6871394773814815, 0.6886271174143855, 0.6901136646578052, 0.6915990981497219, 0.6930833969038382, 0.6945665399100511, 0.6960485061349264, 0.697529274522176, 0.6990088239931351, 0.7004871334472432, 0.7019641817625247, 0.7034399477960734, 0.7049144103845365, 0.7063875483446016, 0.7078593404734854, 0.7093297655494235, 0.7107988023321615, 0.712266429563449, 0.7137326259675335, 0.7151973702516574, 0.7166606411065557, 0.7181224172069552, 0.7195826772120758, 0.7210413997661327, 0.7224985634988405, 0.7239541470259185, 0.725408128949598, 0.72686048785913, 0.7283112023312955, 0.7297602509309165, 0.7312076122113681, 0.7326532647150935, 0.7340971869741186, 0.7355393575105686, 0.7369797548371864, 0.7384183574578513, 0.7398551438681008, 0.7412900925556507, 0.74272318200092, 0.7441543906775542, 0.7455836970529511, 0.7470110795887881, 0.7484365167415498, 0.7498599869630569, 0.7512814687009974, 0.7527009403994575, 0.7541183804994539, 0.7555337674394687, 0.7569470796559827, 0.7583582955840125, 0.7597673936576467, 0.7611743523105843, 0.7625791499766731, 0.7639817650904502, 0.7653821760876831, 0.7667803614059105, 0.7681762994849866, 0.7695699687676235, 0.7709613476999372, 0.7723504147319916, 0.7737371483183465, 0.7751215269186036, 0.7765035289979554, 0.7778831330277333, 0.7792603174859583, 0.7806350608578903, 0.7820073416365803, 0.7833771383234217, 0.7847444294287031, 0.7861091934721618, 0.7874714089835373, 0.7888310545031267, 0.7901881085823392, 0.7915425497842528, 0.7928943566841699, 0.7942435078701751, 0.7955899819436923, 0.7969337575200435, 0.7982748132290066, 0.7996131277153752, 0.8009486796395181, 0.802281447677939, 0.8036114105238378, 0.8049385468876705, 0.8062628354977115, 0.8075842551006146, 0.8089027844619755, 0.8102184023668936, 0.8115310876205354, 0.812840819048697, 0.8141475754983674, 0.8154513358382919, 0.8167520789595363, 0.8180497837760501, 0.8193444292252313, 0.82063599426849, 0.8219244578918135, 0.8232097991063301, 0.8244919969488744, 0.8257710304825517, 0.8270468787973029, 0.8283195210104689, 0.8295889362673562, 0.830855103741801, 0.8321180026367346, 0.8333776121847475, 0.8346339116486547, 0.8358868803220602, 0.8371364975299209, 0.8383827426291118, 0.8396255950089899, 0.8408650340919579, 0.8421010393340282, 0.8433335902253871, 0.8445626662909573, 0.8457882470909617, 0.8470103122214857, 0.8482288413150403, 0.8494438140411237, 0.8506552101067839, 0.8518630092571796, 0.8530671912761414, 0.8542677359867327, 0.85546462325181, 0.8566578329745825, 0.8578473450991716, 0.8590331396111693, 0.8602151965381976, 0.8613934959504648, 0.8625680179613241, 0.8637387427278292, 0.8649056504512911, 0.8660687213778328, 0.8672279357989446, 0.8683832740520382, 0.8695347165209993, 0.8706822436367413, 0.8718258358777565, 0.8729654737706679, 0.8741011378907788, 0.8752328088626233, 0.8763604673605142, 0.8774840941090916, 0.8786036698838697, 0.8797191755117829, 0.8808305918717313, 0.8819378998951247, 0.8830410805664264, 0.8841401149236952, 0.885234984059127, 0.8863256691195954, 0.8874121513071906, 0.8884944118797582, 0.8895724321514359, 0.8906461934931901, 0.8917156773333504, 0.892780865158144, 0.8938417385122278, 0.8948982789992205, 0.8959504682822319, 0.8969982880843933, 0.8980417201893841, 0.8990807464419589, 0.9001153487484724, 0.9011455090774038, 0.9021712094598788, 0.9031924319901911, 0.9042091588263221, 0.9052213721904597, 0.9062290543695145, 0.9072321877156363, 0.9082307546467273, 0.9092247376469554, 0.910214119267265, 0.9111988821258866, 0.9121790089088447, 0.9131544823704647, 0.9141252853338772, 0.9150914006915213, 0.9160528114056468, 0.9170095005088137, 0.9179614511043904, 0.918908646367051, 0.9198510695432692, 0.9207887039518123, 0.921721532984232, 0.9226495401053546, 0.9235727088537685, 0.9244910228423101, 0.9254044657585486, 0.9263130213652676, 0.9272166735009462, 0.9281154060802368, 0.9290092030944428, 0.9298980486119925, 0.9307819267789125, 0.9316608218192974, 0.9325347180357804, 0.9334035998099982, 0.9342674516030572, 0.9351262579559955, 0.9359800034902435, 0.9368286729080831, 0.9376722509931036, 0.9385107226106559, 0.9393440727083053, 0.940172286316281, 0.9409953485479241, 0.9418132446001334, 0.9426259597538083, 0.9434334793742906, 0.9442357889118029, 0.9450328739018858, 0.9458247199658317, 0.946611312811117, 0.9473926382318317, 0.9481686821091072, 0.9489394304115407, 0.9497048691956183, 0.9504649846061345, 0.9512197628766109, 0.951969190329711, 0.9527132533776526, 0.9534519385226193, 0.9541852323571678, 0.954913121564633, 0.9556355929195316, 0.9563526332879617, 0.9570642296280014, 0.9577703689901033, 0.9584710385174872, 0.9591662254465305, 0.9598559171071555, 0.9605401009232135, 0.9612187644128678, 0.9618918951889726, 0.9625594809594493, 0.9632215095276616, 0.9638779687927859, 0.9645288467501798, 0.9651741314917485, 0.9658138112063075, 0.9664478741799425, 0.9670763087963676, 0.9676991035372791, 0.9683162469827077, 0.9689277278113674, 0.9695335348010017, 0.9701336568287263, 0.9707280828713702, 0.9713168020058123, 0.9718998034093161, 0.972477076359862, 0.9730486102364747, 0.9736143945195496, 0.9741744187911751, 0.9747286727354528, 0.9752771461388136, 0.9758198288903313, 0.976356710982034, 0.9768877825092107, 0.9774130336707163, 0.9779324547692733, 0.9784460362117695, 0.9789537685095536, 0.9794556422787277, 0.9799516482404357, 0.9804417772211496, 0.9809260201529519, 0.9814043680738159, 0.9818768121278814, 0.9823433435657277, 0.982803953744645, 0.9832586341288998, 0.9837073762899992, 0.984150171906951, 0.9845870127665212, 0.9850178907634877, 0.9854427979008907, 0.9858617262902806, 0.9862746681519615, 0.9866816158152324, 0.9870825617186244, 0.9874774984101349, 0.9878664185474587, 0.9882493148982151, 0.9886261803401725, 0.9889970078614684, 0.989361790560828, 0.9897205216477772, 0.9900731944428538, 0.9904198023778148, 0.9907603389958399, 0.9910947979517324, 0.9914231730121159, 0.9917454580556282, 0.9920616470731114, 0.9923717341677982, 0.9926757135554962, 0.9929735795647666, 0.9932653266371011, 0.9935509493270951, 0.9938304423026162, 0.9941038003449709, 0.9943710183490669, 0.9946320913235716, 0.9948870143910674, 0.9951357827882047, 0.9953783918658486, 0.995614837089225, 0.9958451140380613, 0.9960692184067242, 0.996287146004354, 0.9964988927549947, 0.9967044546977221, 0.9969038279867661, 0.9970970088916317, 0.9972839937972143, 0.9974647792039133, 0.9976393617277409, 0.9978077381004274, 0.997969905169524, 0.9981258598985001, 0.998275599366839, 0.9984191207701282, 0.9985564214201479, 0.9986874987449542, 0.9988123502889595, 0.9989309737130095, 0.9990433667944558, 0.9991495274272256, 0.9992494536218876, 0.9993431435057135, 0.9994305953227375, 0.9995118074338101, 0.99958677831665, 0.9996555065658915, 0.9997179908931283, 0.9997742301269538, 0.9998242232129976, 0.9998679692139588, 0.9999054673096349, 0.9999367167969475, 0.9999617170899645, 0.9999804677199183, 0.9999929683352202, 0.9999992187014717, 0.9999992187014717, 0.9999929683352202, 0.9999804677199183, 0.9999617170899645, 0.9999367167969475, 0.9999054673096349, 0.9998679692139588, 0.9998242232129976, 0.9997742301269538, 0.9997179908931283, 0.9996555065658915, 0.99958677831665, 0.9995118074338101, 0.9994305953227375, 0.9993431435057135, 0.9992494536218876, 0.9991495274272256, 0.9990433667944558, 0.9989309737130095, 0.9988123502889595, 0.9986874987449542, 0.9985564214201479, 0.9984191207701282, 0.998275599366839, 0.9981258598985001, 0.997969905169524, 0.9978077381004274, 0.9976393617277409, 0.9974647792039133, 0.9972839937972143, 0.9970970088916317, 0.9969038279867661, 0.9967044546977221, 0.9964988927549947, 0.996287146004354, 0.9960692184067242, 0.9958451140380613, 0.995614837089225, 0.9953783918658486, 0.9951357827882047, 0.9948870143910674, 0.9946320913235716, 0.9943710183490669, 0.9941038003449709, 0.9938304423026162, 0.9935509493270951, 0.9932653266371011, 0.9929735795647666, 0.9926757135554962, 0.9923717341677982, 0.9920616470731114, 0.9917454580556282, 0.9914231730121159, 0.9910947979517324, 0.9907603389958399, 0.9904198023778148, 0.9900731944428538, 0.9897205216477772, 0.989361790560828, 0.9889970078614684, 0.9886261803401725, 0.9882493148982151, 0.9878664185474587, 0.9874774984101349, 0.9870825617186244, 0.9866816158152324, 0.9862746681519615, 0.9858617262902806, 0.9854427979008907, 0.9850178907634877, 0.9845870127665212, 0.984150171906951, 0.9837073762899992, 0.9832586341288998, 0.982803953744645, 0.9823433435657277, 0.9818768121278814, 0.9814043680738159, 0.9809260201529519, 0.9804417772211496, 0.9799516482404357, 0.9794556422787277, 0.9789537685095536, 0.9784460362117695, 0.9779324547692733, 0.9774130336707163, 0.9768877825092107, 0.976356710982034, 0.9758198288903313, 0.9752771461388136, 0.9747286727354528, 0.9741744187911751, 0.9736143945195496, 0.9730486102364747, 0.972477076359862, 0.9718998034093161, 0.9713168020058123, 0.9707280828713702, 0.9701336568287263, 0.9695335348010017, 0.9689277278113674, 0.9683162469827077, 0.9676991035372791, 0.9670763087963676, 0.9664478741799425, 0.9658138112063075, 0.9651741314917485, 0.9645288467501798, 0.9638779687927859, 0.9632215095276616, 0.9625594809594493, 0.9618918951889726, 0.9612187644128678, 0.9605401009232135, 0.9598559171071555, 0.9591662254465305, 0.9584710385174872, 0.9577703689901033, 0.9570642296280014, 0.9563526332879617, 0.9556355929195316, 0.954913121564633, 0.9541852323571678, 0.9534519385226193, 0.9527132533776526, 0.951969190329711, 0.9512197628766109, 0.9504649846061345, 0.9497048691956183, 0.9489394304115407, 0.9481686821091072, 0.9473926382318317, 0.946611312811117, 0.9458247199658317, 0.9450328739018858, 0.9442357889118029, 0.9434334793742906, 0.9426259597538083, 0.9418132446001334, 0.9409953485479241, 0.940172286316281, 0.9393440727083053, 0.9385107226106559, 0.9376722509931036, 0.9368286729080831, 0.9359800034902435, 0.9351262579559955, 0.9342674516030572, 0.9334035998099982, 0.9325347180357804, 0.9316608218192974, 0.9307819267789125, 0.9298980486119925, 0.9290092030944428, 0.9281154060802368, 0.9272166735009462, 0.9263130213652676, 0.9254044657585486, 0.9244910228423101, 0.9235727088537685, 0.9226495401053546, 0.921721532984232, 0.9207887039518123, 0.9198510695432692, 0.918908646367051, 0.9179614511043904, 0.9170095005088137, 0.9160528114056468, 0.9150914006915213, 0.9141252853338772, 0.9131544823704647, 0.9121790089088447, 0.9111988821258866, 0.910214119267265, 0.9092247376469554, 0.9082307546467273, 0.9072321877156363, 0.9062290543695145, 0.9052213721904597, 0.9042091588263221, 0.9031924319901911, 0.9021712094598788, 0.9011455090774038, 0.9001153487484724, 0.8990807464419589, 0.8980417201893841, 0.8969982880843933, 0.8959504682822319, 0.8948982789992205, 0.8938417385122278, 0.892780865158144, 0.8917156773333504, 0.8906461934931901, 0.8895724321514359, 0.8884944118797582, 0.8874121513071906, 0.8863256691195954, 0.885234984059127, 0.8841401149236952, 0.8830410805664264, 0.8819378998951247, 0.8808305918717313, 0.8797191755117829, 0.8786036698838697, 0.8774840941090916, 0.8763604673605142, 0.8752328088626233, 0.8741011378907788, 0.8729654737706679, 0.8718258358777565, 0.8706822436367413, 0.8695347165209993, 0.8683832740520382, 0.8672279357989446, 0.8660687213778328, 0.8649056504512911, 0.8637387427278292, 0.8625680179613241, 0.8613934959504648, 0.8602151965381976, 0.8590331396111693, 0.8578473450991716, 0.8566578329745825, 0.85546462325181, 0.8542677359867327, 0.8530671912761414, 0.8518630092571796, 0.8506552101067839, 0.8494438140411237, 0.8482288413150403, 0.8470103122214857, 0.8457882470909617, 0.8445626662909573, 0.8433335902253871, 0.8421010393340282, 0.8408650340919579, 0.8396255950089899, 0.8383827426291118, 0.8371364975299209, 0.8358868803220602, 0.8346339116486547, 0.8333776121847475, 0.8321180026367346, 0.830855103741801, 0.8295889362673562, 0.8283195210104689, 0.8270468787973029, 0.8257710304825517, 0.8244919969488744, 0.8232097991063301, 0.8219244578918135, 0.82063599426849, 0.8193444292252313, 0.8180497837760501, 0.8167520789595363, 0.8154513358382919, 0.8141475754983674, 0.812840819048697, 0.8115310876205354, 0.8102184023668936, 0.8089027844619755, 0.8075842551006146, 0.8062628354977115, 0.8049385468876705, 0.8036114105238378, 0.802281447677939, 0.8009486796395181, 0.7996131277153752, 0.7982748132290066, 0.7969337575200435, 0.7955899819436923, 0.7942435078701751, 0.7928943566841699, 0.7915425497842528, 0.7901881085823392, 0.7888310545031267, 0.7874714089835373, 0.7861091934721618, 0.7847444294287031, 0.7833771383234217, 0.7820073416365803, 0.7806350608578903, 0.7792603174859583, 0.7778831330277333, 0.7765035289979554, 0.7751215269186036, 0.7737371483183465, 0.7723504147319916, 0.7709613476999372, 0.7695699687676235, 0.7681762994849866, 0.7667803614059105, 0.7653821760876831, 0.7639817650904502, 0.7625791499766731, 0.7611743523105843, 0.7597673936576467, 0.7583582955840125, 0.7569470796559827, 0.7555337674394687, 0.7541183804994539, 0.7527009403994575, 0.7512814687009974, 0.7498599869630569, 0.7484365167415498, 0.7470110795887881, 0.7455836970529511, 0.7441543906775542, 0.74272318200092, 0.7412900925556507, 0.7398551438681008, 0.7384183574578513, 0.7369797548371864, 0.7355393575105686, 0.7340971869741186, 0.7326532647150935, 0.7312076122113681, 0.7297602509309165, 0.7283112023312955, 0.72686048785913, 0.725408128949598, 0.7239541470259185, 0.7224985634988405, 0.7210413997661327, 0.7195826772120758, 0.7181224172069552, 0.7166606411065557, 0.7151973702516574, 0.7137326259675335, 0.712266429563449, 0.7107988023321615, 0.7093297655494235, 0.7078593404734854, 0.7063875483446016, 0.7049144103845365, 0.7034399477960734, 0.7019641817625247, 0.7004871334472432, 0.6990088239931351, 0.697529274522176, 0.6960485061349264, 0.6945665399100511, 0.6930833969038382, 0.6915990981497219, 0.6901136646578052, 0.6886271174143855, 0.6871394773814815, 0.6856507654963621, 0.6841610026710768, 0.6826702097919883, 0.6811784077193065, 0.6796856172866245, 0.6781918593004567, 0.6766971545397781, 0.6752015237555665, 0.6737049876703454, 0.6722075669777297, 0.6707092823419726, 0.6692101543975153, 0.6677102037485382, 0.666209450968513, 0.664707916599759, 0.6632056211529992, 0.6617025851069197, 0.6601988289077309, 0.6586943729687296, 0.657189237669865, 0.6556834433573054, 0.6541770103430075, 0.6526699589042865, 0.6511623092833906, 0.6496540816870761, 0.6481452962861839, 0.6466359732152197, 0.6451261325719355, 0.6436157944169132, 0.6421049787731504, 0.6405937056256484, 0.6390819949210024, 0.6375698665669935, 0.6360573404321836, 0.6345444363455119, 0.6330311740958935, 0.6315175734318206, 0.6300036540609656, 0.628489435649787, 0.6269749378231367, 0.6254601801638703, 0.6239451822124584, 0.6224299634666022, 0.6209145433808497, 0.6193989413662147, 0.6178831767897977, 0.6163672689744103, 0.6148512371982006, 0.6133351006942812, 0.6118188786503601, 0.6103025902083733, 0.60878625446412, 0.6072698904669004, 0.6057535172191548, 0.6042371536761066, 0.6027208187454068, 0.6012045312867806, 0.5996883101116768, 0.5981721739829196, 0.5966561416143631, 0.5951402316705473, 0.5936244627663569, 0.5921088534666837, 0.5905934222860889, 0.5890781876884706, 0.5875631680867314, 0.5860483818424503, 0.5845338472655558, 0.5830195826140021, 0.5815056060934467, 0.5799919358569329, 0.5784785900045716, 0.5769655865832279, 0.5754529435862098, 0.5739406789529578, 0.5724288105687393, 0.570917356264344, 0.5694063338157822, 0.5678957609439854, 0.5663856553145105, 0.5648760345372438, 0.5633669161661115, 0.5618583176987891, 0.5603502565764157, 0.5588427501833088, 0.5573358158466837, 0.5558294708363746, 0.5543237323645573, 0.5528186175854762, 0.5513141435951722, 0.5498103274312143, 0.5483071860724333, 0.5468047364386578, 0.5453029953904538, 0.5438019797288649, 0.5423017061951579, 0.540802191470568, 0.5393034521760484, 0.537805504872022, 0.5363083660581365, 0.5348120521730193, 0.5333165795940391, 0.5318219646370665, 0.5303282235562395, 0.5288353725437299, 0.5273434277295136, 0.5258524051811428, 0.5243623209035214, 0.5228731908386817, 0.5213850308655651, 0.519897856799805, 0.5184116843935117, 0.5169265293350604, 0.5154424072488824, 0.5139593336952569, 0.5124773241701078, 0.5109963941048018, 0.5095165588659489, 0.5080378337552066, 0.5065602340090849, 0.5050837747987561, 0.5036084712298656, 0.5021343383423459, 0.5006613911102324, 0.4991896444414838, 0.4977191131778025, 0.4962498120944596, 0.4947817559001212, 0.4933149592366784, 0.4918494366790789, 0.49038520273516173, 0.48892227184549436, 0.4874606583832127, 0.486000376653863, 0.4845414408952474, 0.483083865277271, 0.4816276639017918, 0.48017285080247396, 0.47871943994464267, 0.47726744522514153, 0.47581688047219384, 0.47436775944526494, 0.47292009583492745, 0.47147390326273014, 0.47002919528106774, 0.46858598537305474, 0.4671442869524003, 0.4657041133632876, 0.4642654778802535, 0.46282839370807294, 0.46139287398164386, 0.45995893176587616, 0.4585265800555828, 0.4570958317753728, 0.4556666997795472, 0.45423919685199826, 0.45281333570610977, 0.4513891289846608, 0.449966589259732, 0.4485457290326135, 0.44712656073371676, 0.4457090967224876, 0.4442933492873221, 0.44287933064548546, 0.44146705294303284, 0.44005652825473285, 0.43864776858399307, 0.4372407858627892, 0.43583559195159516, 0.43443219863931687, 0.4330306176432276, 0.43163086060890654, 0.4302329391101792, 0.4288368646490604, 0.42744264865569986, 0.42605030248833003, 0.42465983743321656, 0.4232712647046106, 0.4218845954447044, 0.4204998407235886, 0.41911701153921205, 0.41773611881734407, 0.4163571734115394, 0.4149801861031048, 0.41360516760106886, 0.4122321285421534, 0.41086107949074774, 0.40949203093888503, 0.40812499330622126, 0.4067599769400159, 0.4053969921151159, 0.4040360490339408, 0.4026771578264716, 0.40132032855023997, 0.39996557119032194, 0.3986128956593324, 0.3972623117974221, 0.39591382937227737, 0.39456745807912186, 0.39322320754072054, 0.3918810873073858, 0.3905411068569858, 0.38920327559495554, 0.38786760285430966, 0.3865340978956575, 0.38520276990722024, 0.38387362800485103, 0.3825466812320561, 0.38122193856001935, 0.3798994088876275, 0.37857910104149933, 0.3772610237760156, 0.3759451857733518, 0.3746315956435123, 0.3733202619243681, 0.3720111930816953, 0.37070439750921574, 0.3693998835286411, 0.36809765938971756, 0.3667977332702731, 0.3655001132762673, 0.36420480744184286, 0.36291182372937825, 0.36162117002954464, 0.3603328541613628, 0.3590468838722627, 0.35776326683814574, 0.35648201066344776, 0.3552031228812053, 0.3539266109531233, 0.3526524822696441, 0.35138074415002, 0.3501114038423865, 0.3488444685238375, 0.3475799453005036, 0.346317841207631, 0.34505816320966276, 0.34380091820032277, 0.3425461130026999, 0.3412937543693361, 0.3400438489823151, 0.3387964034533526, 0.33755142432389007, 0.3363089180651882, 0.3350688910784241, 0.3338313496947893, 0.3325963001755893, 0.33136374871234636, 0.3301337014269025, 0.3289061643715252, 0.3276811435290144, 0.3264586448128119, 0.3252386740671118, 0.32402123706697283, 0.322806339518433, 0.3215939870586257, 0.3203841852558967, 0.31917693960992416, 0.31797225555183944, 0.3167701384443498, 0.3155705935818632, 0.3143736261906136, 0.31317924142878983, 0.311987444386664, 0.310798240086723, 0.30961163348380116, 0.308427629465214, 0.30724623285089464, 0.306067448393531, 0.3048912807787043, 0.3037177346250304, 0.3025468144843015, 0.3013785248416295, 0.30021287011559195, 0.29904985465837775, 0.2978894827559357, 0.29673175862812484, 0.2955766864288642, 0.2944242702462867, 0.2932745141028926, 0.2921274219557053, 0.29098299769642777, 0.2898412451516017, 0.2887021680827667, 0.2875657701866218, 0.28643205509518777, 0.2853010263759711, 0.2841726875321299, 0.28304704200263986, 0.2819240931624625, 0.28080384432271477, 0.27968629873083956, 0.2785714595707772, 0.27745932996313977, 0.2763499129653848, 0.27524321157199144, 0.2741392287146377, 0.27303796726237833, 0.27193943002182497, 0.27084361973732674, 0.26975053909115176, 0.2686601907036714, 0.26757257713354404, 0.2664877008779006, 0.26540556437253165, 0.2643261699920753, 0.26324952005020613, 0.26217561679982543, 0.2611044624332523, 0.26003605908241667, 0.25897040881905253, 0.2579075136548923, 0.2568473755418629, 0.2557899963722822, 0.25473537797905743, 0.2536835221358831, 0.2526344305574415, 0.25158810489960354, 0.25054454675963067, 0.24950375767637747, 0.24846573913049588, 0.24743049254463978, 0.246398019283671, 0.24536832065486566, 0.24434139790812254, 0.24331725223617096, 0.24229588477478076, 0.24127729660297248, 0.24026148874322875, 0.23924846216170642, 0.23823821776844975, 0.23723075641760363, 0.23622607890762945, 0.2352241859815197, 0.2342250783270148, 0.23322875657682007, 0.2322352213088238, 0.23124447304631604, 0.2302565122582082, 0.22927133935925284, 0.22828895471026545, 0.22730935861834578, 0.2263325513371003, 0.2253585330668658, 0.22438730395493275, 0.22341886409577033, 0.22245321353125178, 0.2214903522508797, 0.22053028019201348, 0.2195729972400962, 0.21861850322888243, 0.21766679794066685, 0.21671788110651347, 0.21577175240648516, 0.21482841146987422, 0.2138878578754329, 0.21295009115160524, 0.21201511077675902, 0.2110829161794182, 0.210153506738496, 0.20922688178352877, 0.20830304059490992, 0.20738198240412425, 0.20646370639398393, 0.20554821169886325, 0.2046354974049352, 0.2037255625504078, 0.20281840612576107, 0.20191402707398448, 0.20101242429081492, 0.20011359662497452, 0.19921754287840984, 0.1983242618065306, 0.19743375211844924, 0.19654601247722053, 0.1956610415000819, 0.19477883775869392, 0.19389939977938123, 0.19302272604337323, 0.1921488149870463, 0.19127766500216506, 0.1904092744361248, 0.18954364159219356, 0.188680764729755, 0.1878206420645513, 0.18696327176892627, 0.18610865197206863, 0.1852567807602562, 0.18440765617709917, 0.18356127622378454, 0.18271763885932044, 0.18187674200078033, 0.18103858352354824, 0.18020316126156277, 0.17937047300756315, 0.17854051651333355, 0.17771328948994894, 0.17688878960802024, 0.17606701449794013, 0.1752479617501285, 0.17443162891527864, 0.17361801350460246, 0.1728071129900773, 0.17199892480469153, 0.1711934463426906, 0.17039067495982352, 0.1695906079735889, 0.1687932426634813, 0.16799857627123763, 0.167206606001083, 0.1664173290199778, 0.1656307424578635, 0.16484684340790903, 0.16406562892675738, 0.16328709603477162, 0.16251124171628112, 0.1617380629198281, 0.16096755655841316, 0.16019971950974204, 0.15943454861647136, 0.1586720406864544, 0.15791219249298716, 0.15715500077505412, 0.15640046223757367, 0.15564857355164397, 0.15489933135478787, 0.1541527322511988, 0.15340877281198542, 0.15266744957541686, 0.15192875904716743, 0.1511926977005613, 0.15045926197681705, 0.14972844828529172, 0.14900025300372538, 0.1482746724784847, 0.14755170302480666, 0.14683134092704228, 0.1461135824388996, 0.1453984237836869, 0.14468586115455548, 0.14397589071474198, 0.14326850859781107, 0.14256371090789716, 0.14186149371994636, 0.14116185307995782, 0.1404647850052249, 0.13977028548457635, 0.13907835047861647, 0.13838897591996566, 0.1377021577135005, 0.13701789173659315, 0.13633617383935087, 0.13565699984485485, 0.1349803655493989, 0.13430626672272775, 0.13363469910827505, 0.13296565842340058, 0.13229914035962792, 0.13163514058288087, 0.13097365473372008, 0.13031467842757893, 0.12965820725499924, 0.12900423678186643, 0.12835276254964426, 0.12770378007560915, 0.12705728485308432, 0.12641327235167332, 0.12577173801749264, 0.12513267727340488, 0.12449608551925055, 0.12386195813207995, 0.12323029046638409, 0.122601077854326, 0.12197431560597048, 0.12134999900951418, 0.12072812333151466, 0.1201086838171195, 0.11949167569029427, 0.11887709415405068, 0.11826493439067333, 0.11765519156194697, 0.11704786080938247, 0.11644293725444241, 0.11584041599876649, 0.11524029212439596, 0.11464256069399761, 0.11404721675108744, 0.11345425532025333, 0.11286367140737777, 0.11227545999985923, 0.11168961606683378, 0.11110613455939546, 0.11052501041081635, 0.10994623853676605, 0.10936981383553064, 0.10879573118823067, 0.10822398545903901, 0.10765457149539785, 0.10708748412823513, 0.10652271817218009, 0.10596026842577874, 0.10540012967170821, 0.1048422966769906, 0.10428676419320632, 0.10373352695670666, 0.10318257968882584, 0.10263391709609201, 0.10208753387043813, 0.1015434246894119, 0.10100158421638501, 0.10046200710076163, 0.09992468797818667, 0.09938962147075285, 0.09885680218720724, 0.09832622472315723, 0.0977978836612757, 0.09727177357150554, 0.09674788901126351, 0.09622622452564299, 0.09570677464761693, 0.09518953389823905, 0.09467449678684497, 0.09416165781125249, 0.09365101145796098, 0.09314255220235024, 0.09263627450887862, 0.09213217283128006, 0.09163024161276098, 0.091130475286196, 0.09063286827432297, 0.09013741498993746, 0.08964410983608619, 0.08915294720626003, 0.08866392148458598, 0.08817702704601842, 0.08769225825652988, 0.08720960947330073, 0.08672907504490818, 0.08625064931151455, 0.08577432660505484, 0.08530010124942328, 0.08482796756065926, 0.08435791984713266, 0.08388995240972806, 0.0834240595420283, 0.08296023553049733, 0.08249847465466219, 0.08203877118729405, 0.08158111939458884, 0.08112551353634662, 0.08067194786615053, 0.08022041663154475, 0.07977091407421161, 0.07932343443014805, 0.07887797192984108, 0.07843452079844258, 0.07799307525594341, 0.07755362951734604, 0.0771161777928374, 0.07668071428796011, 0.07624723320378315, 0.07581572873707162, 0.07538619508045585, 0.07495862642259966, 0.07453301694836757, 0.07410936083899121, 0.07368765227223537, 0.07326788542256249, 0.07285005446129701, 0.07243415355678826, 0.07202017687457299, 0.07160811857753685, 0.07119797282607504, 0.07078973377825204, 0.07038339558996078, 0.06997895241508073, 0.06957639840563513, 0.06917572771194747, 0.06877693448279716, 0.06838001286557426, 0.06798495700643323, 0.06759176105044622, 0.06720041914175527, 0.06681092542372351, 0.06642327403908573, 0.06603745913009818, 0.06565347483868712, 0.06527131530659705, 0.06489097467553748, 0.06451244708732952, 0.06413572668405103, 0.06376080760818123, 0.06338768400274436, 0.06301635001145253, 0.06264679977884763, 0.062279027450442545, 0.06191302717286115, 0.061548793093978, 0.061186319363056706, 0.060825600130887614, 0.06046662954992466, 0.060109401774421305, 0.059753910960565655, 0.05940015126661469, 0.05904811685302755, 0.05869780188259828, 0.05834920052058733, 0.05800230693485241, 0.057657115295978445, 0.05731361977740672, 0.05697181455556302, 0.05663169380998504, 0.056293251723448984, 0.055956482482095185, 0.055621380275552926, 0.05528793929706438, 0.05495615374360779, 0.05462601781601958, 0.05429752571911591, 0.05397067166181309, 0.05364544985724737, 0.05332185452289376, 0.052999879880684005, 0.05267952015712367, 0.05236076958340857, 0.05204362239554004, 0.051728072834439774, 0.051414115146063186, 0.05110174358151271, 0.05079095239714968, 0.05048173585470547, 0.05017408822139204, 0.04986800377001129, 0.04956347677906385, 0.0492605015328569, 0.04895907232161115, 0.04865918344156701, 0.04836082919508997, 0.0480640038907751, 0.04776870184355059, 0.0474749173747807, 0.0471826448123677, 0.046891878490853106, 0.04660261275151782, 0.046314841942481914, 0.04602856041880314, 0.04574376254257476, 0.0454604426830227, 0.04517859521660163, 0.04489821452709051, 0.04461929500568692, 0.044341831051101094, 0.04406581706964863, 0.04379124747534277, 0.04351811668998558, 0.04324641914325851, 0.0429761492728121, 0.04270730152435483, 0.042439870351741155, 0.042173850217058814, 0.04190923559071536, 0.041646020951523706, 0.04138420078678705, 0.04112376959238294, 0.04086472187284657, 0.040607052141453215, 0.04035075492029989, 0.04009582474038633, 0.03984225614169512, 0.039590043673270896, 0.039339181893299, 0.03908966536918313, 0.03884148867762246, 0.03859464640468777, 0.03834913314589676, 0.0381049435062889, 0.037862072100499265, 0.0376205135528315, 0.03738026249733035, 0.03714131357785315, 0.03690366144814062, 0.036667300771887054, 0.03643222622280939, 0.03619843248471598, 0.035965914251574284, 0.0357346662275779, 0.035504683127212895, 0.03527595967532328, 0.03504849060717593, 0.034822270668524447, 0.03459729461567269, 0.034373557215537226, 0.03415105324570923, 0.03392977749451558, 0.03370972476107922, 0.033490889855378826, 0.033273267598307836, 0.03305685282173243, 0.03284164036854927, 0.032627625092742155, 0.03241480185943803, 0.03220316554496245, 0.0319927110368941, 0.031783433234118835, 0.03157532704688284, 0.03136838739684507, 0.031162609217129232, 0.030957987452374852, 0.03075451705878768, 0.03055219300418943, 0.03035101026806685, 0.0301509638416201, 0.029952048727810442, 0.029754259941407138, 0.02955759250903396, 0.029362041469214673, 0.029167601872418125, 0.028974268781102475, 0.028782037269758882, 0.028590902424954493, 0.02840085934537466, 0.028211903141864766, 0.02802402893747107, 0.027837231867481167, 0.02765150707946362, 0.02746684973330703, 0.027283255001258472, 0.027100718067961264, 0.026919234130491965, 0.026738798398397105, 0.02655940609372884, 0.026381052451080314, 0.026203732717620172, 0.026027442153126596, 0.025852176030020626, 0.025677929633398964, 0.025504698261066, 0.025332477223565426, 0.025161261844211084, 0.02499104745911728, 0.024821829417228478, 0.024653603080348387, 0.024486363823168485, 0.02432010703329588, 0.02415482811128062, 0.023990522470642477, 0.023827185537897023, 0.023664812752581213, 0.02350339956727835, 0.023342941447642495, 0.023183433872422252, 0.023024872333484117, 0.022867252335835017, 0.022710569397644577, 0.02255481905026661, 0.022399996838260147, 0.02224609831940984, 0.022093119064745925, 0.02194105465856352, 0.02178990069844142, 0.021639652795260398, 0.021490306573220905, 0.021341857669860215, 0.021194301736069128, 0.021047634436108062, 0.02090185144762262, 0.020756948461658698, 0.020612921182676953, 0.02046976532856692, 0.02032747663066047, 0.020186050833744806, 0.020045483696074937, 0.01990577098938571, 0.019766908498903214, 0.019628892023355837, 0.019491717374984636, 0.019355380379553463, 0.019219876876358337, 0.019085202718236532, 0.018951353771575037, 0.018818325916318664, 0.018686115045977544, 0.018554717067634268, 0.018424127901950436, 0.018294343483172854, 0.01816535975913925, 0.018037172691283406, 0.017909778254639876, 0.017783172437848483, 0.017657351243157926, 0.01753231068642938, 0.01740804679713922, 0.017284555618381776, 0.01716183320687117, 0.017039875632942982, 0.016918678980555654, 0.016798239347290852, 0.016678552844354176, 0.01655961559657473, 0.016441423742404888, 0.01632397343391905, 0.016207260836812575, 0.01609128213039975, 0.01597603350761168, 0.015861511174993813, 0.015747711352702743, 0.015634630274502927, 0.015522264187762813, 0.015410609353450698, 0.015299662046130045, 0.015189418553954559, 0.015079875178662869, 0.014971028235572573, 0.014862874053574364, 0.014755408975125239, 0.01464862935624187, 0.014542531566493086, 0.014437111988992455, 0.014332367020390127, 0.014228293070864508, 0.014124886564113648, 0.014022143937345938, 0.013920061641270918, 0.013818636140089257, 0.0137178639114828, 0.013617741446603947, 0.013518265250064908, 0.013419431839926513, 0.013321237747686685, 0.013223679518268649, 0.013126753710008661, 0.013030456894643678, 0.012934785657298354, 0.012839736596471956, 0.012745306324025, 0.012651491465165258, 0.012558288658433895, 0.012465694555690833, 0.012373705822100215, 0.012282319136115235, 0.012191531189462946, 0.012101338687128512, 0.012011738347339316, 0.01192272690154884, 0.011834301094419977, 0.01174645768380839, 0.011659193440745291, 0.011572505149420235, 0.01148638960716327, 0.01140084362442713, 0.011315864024769076, 0.011231447644832256, 0.01114759133432715, 0.01106429195601237, 0.010981546385675547, 0.010899351512113652, 0.010817704237113332, 0.010736601475430717, 0.01065604015477119, 0.010576017215768879, 0.010496529611965703, 0.01041757430979047, 0.01033914828853745, 0.010261248540344962, 0.010183872070173494, 0.010107015895783729, 0.010030677047714355, 0.00995485256925948, 0.009879539516446092, 0.009804734958010927, 0.009730435975377523, 0.009656639662632725, 0.009583343126503116, 0.009510543486331322, 0.009438237874051804, 0.009366423434166868, 0.00929509732372203, 0.009224256712281548, 0.009153898781903431, 0.009084020727114565, 0.009014619754885352, 0.008945693084604333, 0.008877237948052601, 0.008809251589377912, 0.00874173126506878, 0.008674674243928199, 0.00860807780704738, 0.008541939247779106, 0.008476255871711058, 0.00841102499663895, 0.00834624395253937, 0.008281910081542632, 0.00821802073790527, 0.008154573287982558, 0.008091565110200654, 0.008028993595028818, 0.007966856144951262, 0.007905150174438923, 0.0078438731099212, 0.007783022389757258, 0.007722595464207509, 0.007662589795404664, 0.007603002857324861, 0.00754383213575845, 0.0074850751282808, 0.007426729344222921, 0.007368792304641829, 0.007311261542291032, 0.007254134601590553, 0.007197409038597163, 0.007141082420974188, 0.0070851523279613915, 0.007029616350344679, 0.006974472090425594, 0.006919717161990852, 0.006865349190281568, 0.006811365811962582, 0.006757764675091463, 0.006704543439087563, 0.006651699774700839, 0.006599231363980658, 0.0065471359002444805, 0.006495411088046357, 0.006444054643145466, 0.006393064292474381, 0.006342437774107441, 0.006292172837228815, 0.0062422672421006175, 0.006192718760030923, 0.006143525173341583, 0.006094684275336108, 0.006046193870267288, 0.0059980517733049365, 0.0059502558105033335, 0.005902803818768756, 0.0058556936458268784, 0.005808923150190012, 0.005762490201124447, 0.00571639267861751, 0.00567062847334476, 0.005625195486636912, 0.005580091630446896, 0.00553531482731666, 0.0054908630103440255, 0.005446734123149492, 0.0054029261198428775, 0.0053594369649900015, 0.0053162646335792535, 0.005273407110988144, 0.005230862392949749, 0.005188628485519161, 0.005146703405039879, 0.005105085178110071, 0.00506377184154894, 0.0050227614423628665, 0.0049820520377116895, 0.004941641694874748, 0.004901528491217105, 0.004861710514155513, 0.004822185861124488, 0.004782952639542327, 0.004744008966777, 0.0047053529701121585, 0.00466698278671295, 0.004628896563591949, 0.004591092457574948, 0.004553568635266783, 0.004516323273017149, 0.004479354556886294, 0.004442660682610837, 0.00440623985556941, 0.004370090290748432, 0.004334210212707712, 0.004298597855546173, 0.004263251462867485, 0.004228169287745674, 0.004193349592690802, 0.0041587906496145036, 0.004124490739795672, 0.004090448153845976, 0.004056661191675508, 0.004023128162458331, 0.003989847384598055, 0.003956817185693463, 0.003924035902503998, 0.0038915018809154316, 0.003859213475905359, 0.003827169051508834, 0.0037953669807839117, 0.003763805645777242, 0.003732483437489695, 0.003701398755841902, 0.0036705500096399176, 0.00363993561654079, 0.003609554003018247, 0.00357940360432826, 0.003549482864474784, 0.0035197902361753493, 0.0034903241808267866, 0.003461083168470944, 0.0034320656777603437, 0.0034032701959240018, 0.0033746952187331015, 0.0033463392504668598, 0.0033182008038782503, 0.003290278400159872, 0.0032625705689098145, 0.003235075848097474, 0.003207792784029533, 0.0031807199313158194, 0.0031538558528353237, 0.0031271991197021416, 0.003100748311231519, 0.0030745020149059183, 0.003048458826341062, 0.0030226173492520917, 0.0029969761954196906, 0.0029715339846563015, 0.0029462893447723235, 0.0029212409115424087, 0.002896387328671729, 0.0028717272477623416, 0.0028472593282795754, 0.002822982237518433, 0.002798894650570082, 0.002774995250288341, 0.0027512827272562607, 0.0027277557797526896, 0.0027044131137189393, 0.0026812534427254914, 0.0026582754879386854, 0.0026354779780875712, 0.002612859649430682, 0.0025904192457229724, 0.0025681555181827184, 0.002546067225458537, 0.0025241531335963986, 0.002502412016006729, 0.0024808426534315884, 0.0024594438339118176, 0.0024382143527543598, 0.002417153012499514, 0.002396258622888361, 0.002375530000830151, 0.0023549659703698106, 0.0023345653626555005, 0.0023143270159061862, 0.0022942497753793557, 0.0022743324933386937, 0.0022545740290219195, 0.002234973248608603, 0.0022155290251881, 0.002196240238727535, 0.002177105776039828, 0.002158124530751826, 0.00213929540327245, 0.0021206173007609704, 0.0021020891370952793, 0.0020837098328403024, 0.002065478315216411, 0.002047393518067952, 0.0020294543818318352, 0.0020116598535061593, 0.0019940088866189742, 0.0019765004411970285, 0.001959133483734677, 0.0019419069871627853, 0.0019248199308177505, 0.0019078713004105968, 0.0018910600879961075, 0.0018743852919420804, 0.0018578459168986036, 0.0018414409737674692, 0.001825169479671594, 0.0018090304579245872, 0.0017930229380003209, 0.0017771459555026427, 0.0017613985521351355, 0.0017457797756709377, 0.0017302886799226915, 0.0017149243247125093, 0.0016996857758420816, 0.001684572105062806, 0.0016695823900460334, 0.0016547157143533982, 0.0016399711674071878, 0.0016253478444608516, 0.001610844846569531, 0.0015964612805607309, 0.0015821962590050185, 0.0015680489001868405, 0.0015540183280754235, 0.0015401036722957236, 0.0015263040680995098, 0.0015126186563364785, 0.001499046583425505, 0.0014855870013259266, 0.001472239067508966, 0.0014590019449291826, 0.0014458748019960529, 0.0014328568125456362, 0.001419947155812275, 0.0014071450164004598, 0.0013944495842567067, 0.0013818600546415824, 0.001369375628101767, 0.0013569955104422347, 0.0013447189126985248, 0.001332545051109068, 0.0013204731470876478, 0.001308502427195897, 0.0012966321231159415, 0.0012848614716230765, 0.0012731897145585767, 0.0012616160988025652, 0.001250139876246986, 0.001238760303768676, 0.0012274766432024905, 0.0012162881613145722, 0.0012051941297756548, 0.0011941938251345079, 0.001183286528791425, 0.0011724715269718394, 0.0011617481107000218, 0.001151115575772847, 0.0011405732227336874, 0.0011301203568463635, 0.0011197562880692201, 0.0011094803310292562, 0.0010992918049963778, 0.0010891900338577368, 0.001079174346092139, 0.0010692440747445825, 0.0010593985574008443, 0.0010496371361622076, 0.0010399591576202296, 0.0010303639728316556, 0.0010208509372933734, 0.0010114194109174994, 0.0010020687580065471, 0.0009927983472286666, 0.0009836075515930191, 0.0009744957484251954, 0.0009654623193427769, 0.0009565066502309429, 0.000947628131218205, 0.0009388261566522272, 0.0009301001250757173, 0.0009214494392024501, 0.0009128735058933445, 0.0009043717361326656, 0.0008959435450042954, 0.0008875883516681134]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/tests/check.py b/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..07bb4cd68383438009c25cbca2ce4027016a66bc --- /dev/null +++ b/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/tests/check.py @@ -0,0 +1,45 @@ +"""Young's convolution inequality quotient ||f*g||_r / (||f||_p ||g||_q) for non-negative step functions. + +f = sum_i a_i 1_[i, i+1), g = sum_j b_j 1_[j, j+1); then f*g is piecewise linear with knot values +(f*g)(k) = sum_{i+j=k-1} a_i b_j, so all three norms are integrated exactly (up to float64 rounding). +Upstream (classical_inequalities.ipynb) used np.convolve(mode="same") on samples of user callables, which +truncates the convolution's support; this closed form replaces it. +""" +import numpy as np + +from run import Invalid, float_list + + +def _seg_power_integral(c0, c1, r): + """int_0^1 ((1-s) c0 + s c1)^r ds for non-negative c0, c1 (vectorised, cancellation-free).""" + hi, lo = np.maximum(c0, c1), np.minimum(c0, c1) + out = np.zeros_like(hi) + pos = hi > 0 + t = lo[pos] / hi[pos] + with np.errstate(divide="ignore"): + u = np.log(t) + num, den = np.expm1((r + 1) * u), np.expm1(u) + ratio = np.where(u == 0, r + 1, num / np.where(u == 0, 1.0, den)) # (1 - t^{r+1}) / (1 - t) + out[pos] = hi[pos] ** r * ratio / (r + 1) + return out + + +def _vec(v, name, max_len): + a = np.array(float_list(v, None, name)) + if not 1 <= len(a) <= max_len: + raise Invalid(f"need 1 <= len({name}) <= {max_len}") + if a.min() < 0 or a.max() > 1e6 or a.max() <= 0: + raise Invalid(f"{name}: entries must be in [0, 1e6] and not all zero") + return a / a.max() + + +def check(inst, ans): + p, q = inst["p"], inst["q"] + r = 1.0 / (1.0 / p + 1.0 / q - 1.0) + a = _vec(ans.get("f"), "f", inst["max_len"]) + b = _vec(ans.get("g"), "g", inst["max_len"]) + c = np.concatenate([[0.0], np.convolve(a, b), [0.0]]) + conv_r = float(np.sum(_seg_power_integral(c[:-1], c[1:], r))) ** (1.0 / r) + fp = float(np.sum(a ** p)) ** (1.0 / p) + gq = float(np.sum(b ** q)) ** (1.0 / q) + return conv_r / (fp * gq), {"r": r} diff --git a/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/tests/instance.json b/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d96dc988e7de9736c454b2228c9a303fa0d606e0 --- /dev/null +++ b/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/tests/instance.json @@ -0,0 +1 @@ +{"p": 1.25, "q": 1.6666666666666667, "max_len": 10000, "direction": "maximize", "best_known": 0.8765975470922255, "baseline": 0.7994379864165807, "family": "ae_p17_young_convolution", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/tests/run.py b/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/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-p17-young-convolution-p5-4-q5-3/tests/test.sh b/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p17-young-convolution-p5-4-q5-3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/optimize-ae-p45-sum-product-fp-n100049/environment/Dockerfile b/tasks/optimize-ae-p45-sum-product-fp-n100049/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p45-sum-product-fp-n100049/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/optimize-ae-p45-sum-product-fp-n100049/environment/instance.json b/tasks/optimize-ae-p45-sum-product-fp-n100049/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5be75f0ca2e3a2ee4c7a8910e7939be637db4987 --- /dev/null +++ b/tasks/optimize-ae-p45-sum-product-fp-n100049/environment/instance.json @@ -0,0 +1 @@ +{"p": 100049, "k": 316, "direction": "minimize", "family": "ae_p45_sum_product_fp", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p45-sum-product-fp-n100049/solution/solve.sh b/tasks/optimize-ae-p45-sum-product-fp-n100049/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1887a8e42b260292286433f8dec38d8bc27025a1 --- /dev/null +++ b/tasks/optimize-ae-p45-sum-product-fp-n100049/solution/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, 8, 9, 10, 12, 15, 16, 18, 20, 24, 27, 32, 36, 48, 54, 5594, 5598, 6025, 6031, 6035, 6037, 6040, 6041, 6043, 6045, 6046, 6049, 6051, 6055, 6061, 11624, 11629, 11634, 11639, 11644, 11649, 11654, 12070, 12074, 12077, 12080, 12082, 12086, 12090, 12092, 12095, 12098, 12102, 17219, 17223, 17227, 17235, 17243, 17247, 17251, 17675, 17679, 17680, 17681, 17682, 17683, 17684, 17685, 17689, 18111, 18120, 18123, 18129, 18135, 18147, 22804, 22831, 22858, 23268, 23273, 23278, 23283, 23288, 23724, 23726, 24148, 24172, 24196, 29309, 29313, 29317, 29318, 29319, 29321, 29323, 29324, 29325, 29329, 29333, 29759, 29777, 34438, 34470, 34502, 34912, 34917, 34922, 35350, 35353, 35358, 35360, 35362, 35363, 35364, 35365, 35366, 35368, 35370, 35375, 35378, 36222, 36258, 36294, 40942, 40947, 40948, 40951, 40957, 40960, 40963, 40969, 40972, 40973, 41391, 41399, 41401, 41403, 41407, 41411, 41413, 41415, 41423, 45662, 46556, 46994, 46997, 46999, 47000, 47002, 47003, 47004, 47006, 47007, 47009, 47012, 47448, 47452, 48344, 51705, 52597, 52601, 53037, 53040, 53042, 53043, 53045, 53046, 53047, 53049, 53050, 53052, 53055, 53493, 54387, 58626, 58634, 58636, 58638, 58642, 58646, 58648, 58650, 58658, 59071, 59076, 59077, 59080, 59086, 59089, 59092, 59098, 59101, 59102, 63755, 63791, 63827, 64671, 64674, 64679, 64681, 64683, 64684, 64685, 64686, 64687, 64689, 64691, 64696, 64699, 65127, 65132, 65137, 65547, 65579, 65611, 70272, 70290, 70716, 70720, 70724, 70725, 70726, 70728, 70730, 70731, 70732, 70736, 70740, 75853, 75877, 75901, 76323, 76325, 76761, 76766, 76771, 76776, 76781, 77191, 77218, 77245, 81902, 81914, 81920, 81926, 81938, 82360, 82364, 82365, 82366, 82367, 82368, 82369, 82370, 82374, 82798, 82802, 82806, 82814, 82822, 82826, 82830, 87947, 87951, 87954, 87957, 87959, 87963, 87967, 87969, 87972, 87975, 87979, 88395, 88400, 88405, 88410, 88415, 88420, 88425, 93988, 93994, 93998, 94000, 94003, 94004, 94006, 94008, 94009, 94012, 94014, 94018, 94024, 94451, 94455, 99995, 100001, 100013, 100017, 100022, 100025, 100029, 100031, 100033, 100034, 100037, 100039, 100040, 100041, 100043, 100044, 100045, 100046, 100047, 100048]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p45-sum-product-fp-n100049/tests/check.py b/tasks/optimize-ae-p45-sum-product-fp-n100049/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..7184ef5e5926255a1a72ddf7fe632faebdd9012c --- /dev/null +++ b/tasks/optimize-ae-p45-sum-product-fp-n100049/tests/check.py @@ -0,0 +1,15 @@ +"""Finite-field sum-product problem (AlphaEvolve problem 45): minimize max(|X+X|, |X*X|) in F_p, |X| = floor(sqrt p).""" +import numpy as np + +from run import Invalid, int_list + + +def check(inst, ans): + p, k = inst["p"], inst["k"] + x = int_list(ans.get("X"), k, 0, p - 1, "X") + if len(set(x)) != k: + raise Invalid("X must consist of distinct residues") + a = np.array(sorted(x), dtype=np.int64) + s = int(np.unique(np.add.outer(a, a) % p).size) + q = int(np.unique(np.multiply.outer(a, a) % p).size) # products < p^2 < 2^63 + return float(max(s, q)), {"sumset": s, "productset": q} diff --git a/tasks/optimize-ae-p45-sum-product-fp-n100049/tests/instance.json b/tasks/optimize-ae-p45-sum-product-fp-n100049/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c5867131b9350c413b493fc76bd6084ccbbf572f --- /dev/null +++ b/tasks/optimize-ae-p45-sum-product-fp-n100049/tests/instance.json @@ -0,0 +1 @@ +{"p": 100049, "k": 316, "direction": "minimize", "best_known": 8411.0, "baseline": 26511.0, "family": "ae_p45_sum_product_fp", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p45-sum-product-fp-n100049/tests/run.py b/tasks/optimize-ae-p45-sum-product-fp-n100049/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p45-sum-product-fp-n100049/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/optimize-ae-p45-sum-product-fp-n100049/tests/test.sh b/tasks/optimize-ae-p45-sum-product-fp-n100049/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p45-sum-product-fp-n100049/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/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-n8/environment/Dockerfile b/tasks/optimize-ae-p60-no5-on-sphere-n8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==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-n8/environment/instance.json b/tasks/optimize-ae-p60-no5-on-sphere-n8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ebdc349c2892c6124e4866db8e928fe543c38ad7 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n8/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "max_points": 32, "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-n8/solution/solve.sh b/tasks/optimize-ae-p60-no5-on-sphere-n8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c3236b1d4b3c1ba5f367cf7994a1752023368010 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n8/solution/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": [[7, 7, 5], [3, 7, 7], [1, 2, 0], [5, 0, 4], [0, 5, 0], [0, 6, 7], [4, 2, 2], [6, 1, 0], [7, 6, 1], [0, 0, 7], [2, 4, 6], [4, 6, 5], [1, 7, 1], [5, 4, 7], [7, 1, 0], [7, 3, 5], [1, 7, 2], [6, 0, 3], [1, 2, 4], [2, 3, 3], [6, 6, 2], [2, 5, 2], [0, 1, 5]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p60-no5-on-sphere-n8/tests/check.py b/tasks/optimize-ae-p60-no5-on-sphere-n8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..535715270fb95983b4b3896cda93a8746da1a961 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n8/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-n8/tests/instance.json b/tasks/optimize-ae-p60-no5-on-sphere-n8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..747e5342ed73dfac08ae4cc1ed70373484c36dbd --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n8/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "max_points": 32, "direction": "maximize", "best_known": 23.0, "baseline": 17.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-n8/tests/run.py b/tasks/optimize-ae-p60-no5-on-sphere-n8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/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-n8/tests/test.sh b/tasks/optimize-ae-p60-no5-on-sphere-n8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p60-no5-on-sphere-n8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/optimize-finch-lcm-chain-x10000/environment/Dockerfile b/tasks/optimize-finch-lcm-chain-x10000/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-finch-lcm-chain-x10000/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/optimize-finch-lcm-chain-x10000/environment/instance.json b/tasks/optimize-finch-lcm-chain-x10000/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b3c313f0a0579f0944b21279ca351ea2a133ee39 --- /dev/null +++ b/tasks/optimize-finch-lcm-chain-x10000/environment/instance.json @@ -0,0 +1 @@ +{"x": 10000, "max_len": 20000, "max_value": 1000000000000, "direction": "maximize", "family": "finch_lcm_chain_10000", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-finch-lcm-chain-x10000/solution/solve.sh b/tasks/optimize-finch-lcm-chain-x10000/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2f6fae7efcd518126060b05696ecf624c8b7923f --- /dev/null +++ b/tasks/optimize-finch-lcm-chain-x10000/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"sequence": [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, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 176, 180, 184, 188, 192, 196, 200, 205, 210, 215, 220, 225, 228, 234, 240, 246, 248, 256, 264, 272, 280, 290, 300, 310, 320, 324, 336, 348, 351, 364, 378, 396, 414, 432, 456, 480, 510, 540, 544, 576, 612, 615, 656, 658, 705, 708, 767, 768, 832, 840, 924, 927, 1030, 1032, 1161, 1162, 1328, 1332, 1554, 1555, 1866, 1868, 2335, 2337, 3116, 4674, 9348]} +RLMATH_EOF diff --git a/tasks/optimize-finch-lcm-chain-x10000/tests/check.py b/tasks/optimize-finch-lcm-chain-x10000/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..5ab38960f0d8348ee15c89ca9a46a7fbff15f87c --- /dev/null +++ b/tasks/optimize-finch-lcm-chain-x10000/tests/check.py @@ -0,0 +1,21 @@ +"""Erdos #440 finite analogue: strictly increasing sequence, count indices with lcm(a_i, a_{i+1}) <= 10000 +(Finch/EFT skydiscover erdos_440_lcm_density, Apache-2.0). Exact integer check, same count as upstream +(invalid consecutive pairs are simply not counted). Changes: entries must be JSON integers (upstream +accepted integral floats), length and size are capped.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + a = ans.get("sequence") + if not isinstance(a, list) or not 2 <= len(a) <= inst["max_len"]: + raise Invalid(f"sequence must be a list of 2..{inst['max_len']} integers") + int_list(a, None, 1, inst["max_value"], "sequence") + if any(y <= x for x, y in zip(a, a[1:])): + raise Invalid("sequence must be strictly increasing") + X = inst["x"] + cnt = sum(1 for x, y in zip(a, a[1:]) if x // math.gcd(x, y) * y <= X) + if cnt < 1: + raise Invalid("no consecutive pair has lcm <= x") + return float(cnt), {} diff --git a/tasks/optimize-finch-lcm-chain-x10000/tests/instance.json b/tasks/optimize-finch-lcm-chain-x10000/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..398ebea3d6912078425a40ccceee442a935727fb --- /dev/null +++ b/tasks/optimize-finch-lcm-chain-x10000/tests/instance.json @@ -0,0 +1 @@ +{"x": 10000, "max_len": 20000, "max_value": 1000000000000, "direction": "maximize", "best_known": 179, "baseline": 99.0, "family": "finch_lcm_chain_10000", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-finch-lcm-chain-x10000/tests/run.py b/tasks/optimize-finch-lcm-chain-x10000/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-finch-lcm-chain-x10000/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/optimize-finch-lcm-chain-x10000/tests/test.sh b/tasks/optimize-finch-lcm-chain-x10000/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-finch-lcm-chain-x10000/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/optimize-fs-cap-set-n5/environment/Dockerfile b/tasks/optimize-fs-cap-set-n5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-fs-cap-set-n5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/optimize-fs-cap-set-n5/environment/instance.json b/tasks/optimize-fs-cap-set-n5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..73b01a095b6ee80bfc9eb98dea288512e442a796 --- /dev/null +++ b/tasks/optimize-fs-cap-set-n5/environment/instance.json @@ -0,0 +1 @@ +{"n": 5, "direction": "maximize", "family": "fs_cap_set", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-fs-cap-set-n5/solution/solve.sh b/tasks/optimize-fs-cap-set-n5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..35248838b09f27939acd395daae3abb7d646acfc --- /dev/null +++ b/tasks/optimize-fs-cap-set-n5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"vectors": [[1, 1, 1, 1, 2], [1, 1, 1, 2, 2], [1, 1, 2, 1, 2], [1, 2, 1, 1, 1], [1, 2, 1, 2, 1], [1, 2, 2, 1, 1], [2, 1, 1, 1, 1], [2, 1, 1, 2, 1], [2, 1, 2, 1, 1], [2, 2, 1, 1, 2], [2, 2, 1, 2, 2], [2, 2, 2, 1, 2], [0, 0, 1, 1, 0], [0, 0, 1, 2, 0], [0, 0, 2, 1, 0], [0, 0, 2, 2, 1], [0, 0, 2, 2, 2], [0, 1, 0, 0, 1], [0, 1, 0, 0, 2], [0, 1, 0, 1, 1], [0, 1, 0, 1, 2], [0, 1, 2, 0, 0], [0, 2, 0, 0, 1], [0, 2, 0, 0, 2], [0, 2, 0, 1, 1], [0, 2, 0, 1, 2], [0, 2, 2, 0, 0], [1, 0, 0, 0, 1], [1, 0, 0, 0, 2], [1, 0, 0, 2, 0], [1, 0, 1, 0, 1], [1, 0, 1, 0, 2], [1, 1, 0, 1, 0], [1, 1, 1, 0, 0], [1, 2, 0, 1, 0], [1, 2, 1, 0, 0], [2, 0, 0, 0, 1], [2, 0, 0, 0, 2], [2, 0, 0, 2, 0], [2, 0, 1, 0, 1], [2, 0, 1, 0, 2], [2, 1, 0, 1, 0], [2, 1, 1, 0, 0], [2, 2, 0, 1, 0], [2, 2, 1, 0, 0]]} +RLMATH_EOF diff --git a/tasks/optimize-fs-cap-set-n5/tests/check.py b/tasks/optimize-fs-cap-set-n5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e0b4309ffc9678bb5a2f8e30718868e5c68b1874 --- /dev/null +++ b/tasks/optimize-fs-cap-set-n5/tests/check.py @@ -0,0 +1,21 @@ +"""Cap set in F_3^n: no three distinct vectors x, y, z with x + y + z = 0 (mod 3). Score = size.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + vecs = ans.get("vectors") + if not isinstance(vecs, list) or not vecs or len(vecs) > 3 ** n: + raise Invalid(f"vectors must be a non-empty list of at most 3^{n} vectors") + pts = [tuple(int_list(v, n, 0, 2, "vector")) for v in vecs] + if len(set(pts)) != len(pts): + raise Invalid("duplicate vectors") + # incremental check (as in the FunSearch notebook's is_cap_set): a point may not be the third point of a + # line through two earlier points; O(c^2 n) and stops at the first violation + blocked = set() + for i, p in enumerate(pts): + if p in blocked: + raise Invalid(f"vector {list(p)} completes a line with two earlier vectors") + for q in pts[:i]: + blocked.add(tuple((-a - b) % 3 for a, b in zip(p, q))) + return float(len(pts)), {"size": len(pts)} diff --git a/tasks/optimize-fs-cap-set-n5/tests/instance.json b/tasks/optimize-fs-cap-set-n5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..87fa28ba26875ce0728b2d2f03144a7fc917ba8b --- /dev/null +++ b/tasks/optimize-fs-cap-set-n5/tests/instance.json @@ -0,0 +1 @@ +{"n": 5, "direction": "maximize", "best_known": 45, "baseline": 32, "family": "fs_cap_set", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-fs-cap-set-n5/tests/run.py b/tasks/optimize-fs-cap-set-n5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-fs-cap-set-n5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/optimize-fs-cap-set-n5/tests/test.sh b/tasks/optimize-fs-cap-set-n5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-fs-cap-set-n5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt